@leafer/image 1.11.2 → 1.12.1
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/package.json +7 -7
- package/src/ImageManager.ts +23 -6
- package/src/LeaferImage.ts +7 -1
- package/types/index.d.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer/image",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.12.1",
|
|
4
4
|
"description": "@leafer/image",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -22,13 +22,13 @@
|
|
|
22
22
|
"leaferjs"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@leafer/task": "1.
|
|
26
|
-
"@leafer/file": "1.
|
|
27
|
-
"@leafer/data": "1.
|
|
28
|
-
"@leafer/math": "1.
|
|
29
|
-
"@leafer/platform": "1.
|
|
25
|
+
"@leafer/task": "1.12.1",
|
|
26
|
+
"@leafer/file": "1.12.1",
|
|
27
|
+
"@leafer/data": "1.12.1",
|
|
28
|
+
"@leafer/math": "1.12.1",
|
|
29
|
+
"@leafer/platform": "1.12.1"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@leafer/interface": "1.
|
|
32
|
+
"@leafer/interface": "1.12.1"
|
|
33
33
|
}
|
|
34
34
|
}
|
package/src/ImageManager.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IImageManager, ILeaferImageConfig, ILeaferImage, IExportFileType } from '@leafer/interface'
|
|
2
|
-
import { Creator } from '@leafer/platform'
|
|
2
|
+
import { Creator, Platform } from '@leafer/platform'
|
|
3
3
|
import { FileHelper, Resource } from '@leafer/file'
|
|
4
4
|
import { TaskProcessor } from '@leafer/task'
|
|
5
5
|
|
|
@@ -21,17 +21,34 @@ export const ImageManager: IImageManager = {
|
|
|
21
21
|
|
|
22
22
|
recycle(image: ILeaferImage): void {
|
|
23
23
|
image.use--
|
|
24
|
-
setTimeout(() => {
|
|
24
|
+
setTimeout(() => {
|
|
25
|
+
if (!image.use) {
|
|
26
|
+
if (Platform.image.isLarge(image)) {
|
|
27
|
+
if (image.url) Resource.remove(image.url)
|
|
28
|
+
} else {
|
|
29
|
+
image.clearLevels()
|
|
30
|
+
I.recycledList.push(image)
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
})
|
|
25
34
|
},
|
|
26
35
|
|
|
27
|
-
|
|
36
|
+
// maybe rewrite
|
|
37
|
+
recyclePaint(paint: any): void {
|
|
38
|
+
I.recycle(paint.image)
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
clearRecycled(force?: boolean): void {
|
|
28
42
|
const list = I.recycledList
|
|
29
|
-
if (list.length > I.maxRecycled) {
|
|
30
|
-
list.forEach(image => (!image.use && image.url) && Resource.remove(image.url))
|
|
43
|
+
if (list.length > I.maxRecycled || force) {
|
|
44
|
+
list.forEach(image => ((!image.use || force) && image.url) && Resource.remove(image.url))
|
|
31
45
|
list.length = 0
|
|
32
46
|
}
|
|
33
47
|
},
|
|
34
48
|
|
|
49
|
+
// need rewrite
|
|
50
|
+
clearLevels(): void { },
|
|
51
|
+
|
|
35
52
|
hasAlphaPixel(config: ILeaferImageConfig): boolean {
|
|
36
53
|
return FileHelper.alphaPixelTypes.some(item => I.isFormat(item, config))
|
|
37
54
|
},
|
|
@@ -49,7 +66,7 @@ export const ImageManager: IImageManager = {
|
|
|
49
66
|
},
|
|
50
67
|
|
|
51
68
|
destroy(): void {
|
|
52
|
-
|
|
69
|
+
this.clearRecycled(true)
|
|
53
70
|
}
|
|
54
71
|
|
|
55
72
|
}
|
package/src/LeaferImage.ts
CHANGED
|
@@ -121,10 +121,16 @@ export class LeaferImage implements ILeaferImage {
|
|
|
121
121
|
return pattern
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
+
// need rewrite
|
|
125
|
+
public clearLevels(_checkUse?: boolean): void { }
|
|
124
126
|
|
|
125
127
|
public destroy(): void {
|
|
128
|
+
this.clearLevels()
|
|
129
|
+
|
|
130
|
+
const { view } = this
|
|
131
|
+
if (view && view.close) view.close() // 可能为 ImageBitmap
|
|
126
132
|
this.config = { url: '' }
|
|
127
|
-
this.cache = null
|
|
133
|
+
this.cache = this.view = null
|
|
128
134
|
this.waitComplete.length = 0
|
|
129
135
|
}
|
|
130
136
|
|
package/types/index.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ declare class LeaferImage implements ILeaferImage {
|
|
|
24
24
|
getFull(_filters?: IObject): any;
|
|
25
25
|
getCanvas(width: number, height: number, opacity?: number, filters?: IObject, xGap?: number, yGap?: number, smooth?: boolean): any;
|
|
26
26
|
getPattern(canvas: any, repeat: string | null, transform?: IMatrixData, paint?: ILeaferImagePatternPaint): ICanvasPattern;
|
|
27
|
+
clearLevels(_checkUse?: boolean): void;
|
|
27
28
|
destroy(): void;
|
|
28
29
|
}
|
|
29
30
|
|