@esotericsoftware/spine-canvaskit 4.2.93 → 4.2.94
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.
- package/dist/esm/spine-canvaskit.min.mjs +2 -2
- package/dist/esm/spine-canvaskit.mjs +33 -6
- package/dist/esm/spine-canvaskit.mjs.map +2 -2
- package/dist/iife/spine-canvaskit.js +33 -6
- package/dist/iife/spine-canvaskit.js.map +2 -2
- package/dist/iife/spine-canvaskit.min.js +2 -2
- package/package.json +2 -2
|
@@ -5642,7 +5642,7 @@ var AssetManagerBase = class {
|
|
|
5642
5642
|
return blob ? createImageBitmap(blob, { premultiplyAlpha: "none", colorSpaceConversion: "none" }) : null;
|
|
5643
5643
|
}).then((bitmap) => {
|
|
5644
5644
|
if (bitmap) {
|
|
5645
|
-
const texture = this.
|
|
5645
|
+
const texture = this.createTexture(path, bitmap);
|
|
5646
5646
|
this.success(success, path, texture);
|
|
5647
5647
|
resolve(texture);
|
|
5648
5648
|
}
|
|
@@ -5652,7 +5652,7 @@ var AssetManagerBase = class {
|
|
|
5652
5652
|
let image = new Image();
|
|
5653
5653
|
image.crossOrigin = "anonymous";
|
|
5654
5654
|
image.onload = () => {
|
|
5655
|
-
const texture = this.
|
|
5655
|
+
const texture = this.createTexture(path, image);
|
|
5656
5656
|
this.success(success, path, texture);
|
|
5657
5657
|
resolve(texture);
|
|
5658
5658
|
};
|
|
@@ -5676,7 +5676,7 @@ var AssetManagerBase = class {
|
|
|
5676
5676
|
this.cache.assetsLoaded[path] = new Promise((resolve, reject) => {
|
|
5677
5677
|
this.downloader.downloadText(path, (atlasText) => {
|
|
5678
5678
|
try {
|
|
5679
|
-
|
|
5679
|
+
const atlas = this.createTextureAtlas(path, atlasText);
|
|
5680
5680
|
let toLoad = atlas.pages.length, abort = false;
|
|
5681
5681
|
for (let page of atlas.pages) {
|
|
5682
5682
|
this.loadTexture(
|
|
@@ -5720,7 +5720,7 @@ var AssetManagerBase = class {
|
|
|
5720
5720
|
this.cache.assetsLoaded[path] = new Promise((resolve, reject) => {
|
|
5721
5721
|
this.downloader.downloadText(path, (atlasText) => {
|
|
5722
5722
|
try {
|
|
5723
|
-
const atlas =
|
|
5723
|
+
const atlas = this.createTextureAtlas(path, atlasText);
|
|
5724
5724
|
this.success(success, path, atlas);
|
|
5725
5725
|
resolve(atlas);
|
|
5726
5726
|
} catch (e) {
|
|
@@ -5826,9 +5826,12 @@ var AssetManagerBase = class {
|
|
|
5826
5826
|
}
|
|
5827
5827
|
// dispose asset only if it's not used by others
|
|
5828
5828
|
disposeAsset(path) {
|
|
5829
|
-
|
|
5830
|
-
|
|
5829
|
+
const asset = this.cache.assets[path];
|
|
5830
|
+
if (asset instanceof TextureAtlas) {
|
|
5831
|
+
asset.dispose();
|
|
5832
|
+
return;
|
|
5831
5833
|
}
|
|
5834
|
+
this.disposeAssetInternal(path);
|
|
5832
5835
|
}
|
|
5833
5836
|
hasErrors() {
|
|
5834
5837
|
return Object.keys(this.errors).length > 0;
|
|
@@ -5836,6 +5839,30 @@ var AssetManagerBase = class {
|
|
|
5836
5839
|
getErrors() {
|
|
5837
5840
|
return this.errors;
|
|
5838
5841
|
}
|
|
5842
|
+
disposeAssetInternal(path) {
|
|
5843
|
+
if (this.cache.assetsRefCount[path] > 0 && --this.cache.assetsRefCount[path] === 0) {
|
|
5844
|
+
return this.remove(path);
|
|
5845
|
+
}
|
|
5846
|
+
}
|
|
5847
|
+
createTextureAtlas(path, atlasText) {
|
|
5848
|
+
const atlas = new TextureAtlas(atlasText);
|
|
5849
|
+
atlas.dispose = () => {
|
|
5850
|
+
if (this.cache.assetsRefCount[path] <= 0) return;
|
|
5851
|
+
this.disposeAssetInternal(path);
|
|
5852
|
+
for (const page of atlas.pages) {
|
|
5853
|
+
page.texture?.dispose();
|
|
5854
|
+
}
|
|
5855
|
+
};
|
|
5856
|
+
return atlas;
|
|
5857
|
+
}
|
|
5858
|
+
createTexture(path, image) {
|
|
5859
|
+
const texture = this.textureLoader(image);
|
|
5860
|
+
const textureDispose = texture.dispose.bind(texture);
|
|
5861
|
+
texture.dispose = () => {
|
|
5862
|
+
if (this.disposeAssetInternal(path)) textureDispose();
|
|
5863
|
+
};
|
|
5864
|
+
return texture;
|
|
5865
|
+
}
|
|
5839
5866
|
};
|
|
5840
5867
|
var AssetCache = class _AssetCache {
|
|
5841
5868
|
assets = {};
|