@leafer/image 1.0.0-alpha.9 → 1.0.0-beta

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer/image",
3
- "version": "1.0.0-alpha.9",
3
+ "version": "1.0.0-beta",
4
4
  "description": "@leafer/image",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -19,6 +19,6 @@
19
19
  "leaferjs"
20
20
  ],
21
21
  "devDependencies": {
22
- "@leafer/interface": "1.0.0-alpha.9"
22
+ "@leafer/interface": "1.0.0-beta"
23
23
  }
24
24
  }
@@ -1,21 +1,34 @@
1
- import { ILeaferCanvas, ILeafer, ILeaferCanvasConfig, IImageManager } from '@leafer/interface'
1
+ import { ILeafer, ILeaferCanvasConfig, IImageManager, ILeaferImageConfig, ILeaferImage } from '@leafer/interface'
2
+ import { Creator } from '@leafer/platform'
3
+
4
+
5
+ interface ILeaferImageMap {
6
+ [name: string]: ILeaferImage
7
+ }
8
+
2
9
 
3
10
  export class ImageManager implements IImageManager {
4
11
 
5
12
  public leafer: ILeafer
6
13
 
7
- public list: ILeaferCanvas[] = []
14
+ public map: ILeaferImageMap = {}
8
15
 
9
16
  constructor(leafer: ILeafer, _config: ILeaferCanvasConfig) {
10
17
  this.leafer = leafer
11
18
  }
12
19
 
13
- public load(): void {
14
-
20
+ public get(config: ILeaferImageConfig): ILeaferImage {
21
+ let image = this.map[config.url]
22
+ if (!image) {
23
+ image = Creator.image(config)
24
+ this.map[config.url] = image
25
+ }
26
+ return image
15
27
  }
16
28
 
17
29
  public destory(): void {
18
- this.leafer = undefined
30
+ this.leafer = null
31
+ this.map = null
19
32
  }
20
33
 
21
34
  }