@leafer/web 1.0.0-rc.9 → 1.0.0

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/web",
3
- "version": "1.0.0-rc.9",
3
+ "version": "1.0.0",
4
4
  "description": "@leafer/web",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -22,13 +22,11 @@
22
22
  "leaferjs"
23
23
  ],
24
24
  "dependencies": {
25
- "@leafer/core": "1.0.0-rc.9",
26
- "@leafer/partner": "1.0.0-rc.9",
27
- "@leafer/canvas-web": "1.0.0-rc.9",
28
- "@leafer/interaction-web": "1.0.0-rc.9",
29
- "@leafer/image-web": "1.0.0-rc.9"
25
+ "@leafer/core": "1.0.0",
26
+ "@leafer/canvas-web": "1.0.0",
27
+ "@leafer/image-web": "1.0.0"
30
28
  },
31
29
  "devDependencies": {
32
- "@leafer/interface": "1.0.0-rc.9"
30
+ "@leafer/interface": "1.0.0"
33
31
  }
34
32
  }
package/src/index.ts CHANGED
@@ -1,16 +1,13 @@
1
1
  export * from '@leafer/core'
2
- export * from '@leafer/partner'
3
2
 
4
3
  export * from '@leafer/canvas-web'
5
4
  export * from '@leafer/image-web'
6
- export * from '@leafer/interaction-web'
7
5
 
8
6
  import { ICreator, IFunction, IExportImageType, IExportFileType, IObject, ICanvasType } from '@leafer/interface'
9
7
  import { Platform, Creator, FileHelper } from '@leafer/core'
10
8
 
11
9
  import { LeaferCanvas } from '@leafer/canvas-web'
12
10
  import { LeaferImage } from '@leafer/image-web'
13
- import { Interaction } from '@leafer/interaction-web'
14
11
 
15
12
 
16
13
  const { mineType, fileType } = FileHelper
@@ -18,10 +15,7 @@ const { mineType, fileType } = FileHelper
18
15
 
19
16
  Object.assign(Creator, {
20
17
  canvas: (options?, manager?) => new LeaferCanvas(options, manager),
21
- image: (options) => new LeaferImage(options),
22
- hitCanvas: (options?, manager?) => new LeaferCanvas(options, manager),
23
-
24
- interaction: (target, canvas, selector, options?) => new Interaction(target, canvas, selector, options),
18
+ image: (options) => new LeaferImage(options)
25
19
  } as ICreator)
26
20
 
27
21
 
@@ -36,9 +30,13 @@ export function useCanvas(_canvasType: ICanvasType, _power?: IObject): void {
36
30
  canvasToDataURL: (canvas: HTMLCanvasElement, type?: IExportImageType, quality?: number) => canvas.toDataURL(mineType(type), quality),
37
31
  canvasToBolb: (canvas: HTMLCanvasElement, type?: IExportFileType, quality?: number) => new Promise((resolve) => canvas.toBlob(resolve, mineType(type), quality)),
38
32
  canvasSaveAs: (canvas: HTMLCanvasElement, filename: string, quality?: any) => {
33
+ const url = canvas.toDataURL(mineType(fileType(filename)), quality)
34
+ return Platform.origin.download(url, filename)
35
+ },
36
+ download(url: string, filename: string): Promise<void> {
39
37
  return new Promise((resolve) => {
40
38
  let el = document.createElement('a')
41
- el.href = canvas.toDataURL(mineType(fileType(filename)), quality)
39
+ el.href = url
42
40
  el.download = filename
43
41
  document.body.appendChild(el)
44
42
  el.click()
@@ -49,12 +47,14 @@ export function useCanvas(_canvasType: ICanvasType, _power?: IObject): void {
49
47
  loadImage(src: any): Promise<HTMLImageElement> {
50
48
  return new Promise((resolve, reject) => {
51
49
  const img = new Image()
52
- img.setAttribute('crossOrigin', 'anonymous')
53
- img.crossOrigin = 'anonymous'
50
+ const { crossOrigin } = Platform.image
51
+ if (crossOrigin) {
52
+ img.setAttribute('crossOrigin', crossOrigin)
53
+ img.crossOrigin = crossOrigin
54
+ }
54
55
  img.onload = () => { resolve(img) }
55
56
  img.onerror = (e) => { reject(e) }
56
- if (!src.startsWith('data:') && Platform.image.suffix) src += (src.includes("?") ? "&" : "?") + Platform.image.suffix
57
- img.src = src
57
+ img.src = Platform.image.getRealURL(src)
58
58
  })
59
59
  }
60
60
  }
package/types/index.d.ts CHANGED
@@ -1,8 +1,6 @@
1
1
  export * from '@leafer/core';
2
- export * from '@leafer/partner';
3
2
  export * from '@leafer/canvas-web';
4
3
  export * from '@leafer/image-web';
5
- export * from '@leafer/interaction-web';
6
4
  import { ICanvasType, IObject } from '@leafer/interface';
7
5
 
8
6
  declare function useCanvas(_canvasType: ICanvasType, _power?: IObject): void;