@leafer/miniapp 1.0.0-rc.8 → 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/miniapp",
3
- "version": "1.0.0-rc.8",
3
+ "version": "1.0.0",
4
4
  "description": "@leafer/miniapp",
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.8",
26
- "@leafer/partner": "1.0.0-rc.8",
27
- "@leafer/canvas-miniapp": "1.0.0-rc.8",
28
- "@leafer/image-miniapp": "1.0.0-rc.8",
29
- "@leafer/interaction-miniapp": "1.0.0-rc.8"
25
+ "@leafer/core": "1.0.0",
26
+ "@leafer/canvas-miniapp": "1.0.0",
27
+ "@leafer/image-miniapp": "1.0.0"
30
28
  },
31
29
  "devDependencies": {
32
- "@leafer/interface": "1.0.0-rc.8"
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-miniapp'
5
4
  export * from '@leafer/image-miniapp'
6
- export * from '@leafer/interaction-miniapp'
7
5
 
8
6
  import { ICanvasType, ICreator, IExportFileType, IExportImageType, IFunction, IObject, IMiniappSelect, IMiniappSizeView, IBoundsData } from '@leafer/interface'
9
7
  import { Platform, Creator, FileHelper } from '@leafer/core'
10
8
 
11
9
  import { LeaferCanvas } from '@leafer/canvas-miniapp'
12
10
  import { LeaferImage } from '@leafer/image-miniapp'
13
- import { Interaction } from '@leafer/interaction-miniapp'
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?) => { return new Interaction(target, canvas, selector, options) }
18
+ image: (options) => new LeaferImage(options)
25
19
  } as ICreator)
26
20
 
27
21
 
@@ -32,9 +26,12 @@ export function useCanvas(_canvasType: ICanvasType, app?: IObject): void {
32
26
  canvasToDataURL: (canvas: IObject, type?: IExportImageType, quality?: number) => canvas.toDataURL(mineType(type), quality),
33
27
  canvasToBolb: (canvas: IObject, type?: IExportFileType, quality?: number) => canvas.toBuffer(type, { quality }),
34
28
  canvasSaveAs: (canvas: IObject, filePath: string, quality?: any) => {
29
+ let data: string = canvas.toDataURL(mineType(fileType(filePath)), quality)
30
+ data = data.substring(data.indexOf('64,') + 3)
31
+ return Platform.origin.download(data, filePath)
32
+ },
33
+ download(data: string, filePath: string): Promise<void> {
35
34
  return new Promise((resolve, reject) => {
36
- let data: string = canvas.toDataURL(mineType(fileType(filePath)), quality)
37
- data = data.substring(data.indexOf('64,') + 3)
38
35
  let toAlbum: boolean
39
36
  if (!filePath.includes('/')) {
40
37
  filePath = `${app.env.USER_DATA_PATH}/` + filePath
@@ -49,9 +46,12 @@ export function useCanvas(_canvasType: ICanvasType, app?: IObject): void {
49
46
  if (toAlbum) {
50
47
  Platform.miniapp.saveToAlbum(filePath).then(() => {
51
48
  fs.unlink({ filePath })
49
+ resolve()
52
50
  })
51
+ } else {
52
+ resolve()
53
53
  }
54
- resolve()
54
+
55
55
  },
56
56
  fail(error: any) {
57
57
  reject(error)
@@ -59,12 +59,12 @@ export function useCanvas(_canvasType: ICanvasType, app?: IObject): void {
59
59
  })
60
60
  })
61
61
  },
62
- loadImage(url: string): Promise<HTMLImageElement> {
62
+ loadImage(src: string): Promise<HTMLImageElement> {
63
63
  return new Promise((resolve, reject) => {
64
64
  const img = Platform.canvas.view.createImage()
65
65
  img.onload = () => { resolve(img) }
66
66
  img.onerror = (error: any) => { reject(error) }
67
- img.src = url
67
+ img.src = Platform.image.getRealURL(src)
68
68
  })
69
69
  },
70
70
  noRepeat: 'repeat-x' // fix: 微信小程序 createPattern 直接使用 no-repeat 有bug,导致无法显示
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-miniapp';
4
3
  export * from '@leafer/image-miniapp';
5
- export * from '@leafer/interaction-miniapp';
6
4
  import { ICanvasType, IObject } from '@leafer/interface';
7
5
 
8
6
  declare function useCanvas(_canvasType: ICanvasType, app?: IObject): void;