@leafer/miniapp 1.0.0-rc.2 → 1.0.0-rc.21
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 +5 -7
- package/src/index.ts +12 -10
- package/types/index.d.ts +0 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer/miniapp",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.21",
|
|
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.
|
|
26
|
-
"@leafer/
|
|
27
|
-
"@leafer/
|
|
28
|
-
"@leafer/image-miniapp": "1.0.0-rc.2",
|
|
29
|
-
"@leafer/interaction-miniapp": "1.0.0-rc.2"
|
|
25
|
+
"@leafer/core": "1.0.0-rc.21",
|
|
26
|
+
"@leafer/canvas-miniapp": "1.0.0-rc.21",
|
|
27
|
+
"@leafer/image-miniapp": "1.0.0-rc.21"
|
|
30
28
|
},
|
|
31
29
|
"devDependencies": {
|
|
32
|
-
"@leafer/interface": "1.0.0-rc.
|
|
30
|
+
"@leafer/interface": "1.0.0-rc.21"
|
|
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
|
|
@@ -123,6 +120,12 @@ export function useCanvas(_canvasType: ICanvasType, app?: IObject): void {
|
|
|
123
120
|
}
|
|
124
121
|
}
|
|
125
122
|
|
|
123
|
+
Platform.event = {
|
|
124
|
+
stopDefault(_origin: IObject): void { },
|
|
125
|
+
stopNow(_origin: IObject): void { },
|
|
126
|
+
stop(_origin: IObject): void { }
|
|
127
|
+
}
|
|
128
|
+
|
|
126
129
|
Platform.canvas = Creator.canvas()
|
|
127
130
|
Platform.conicGradientSupport = !!Platform.canvas.context.createConicGradient
|
|
128
131
|
}
|
|
@@ -131,4 +134,3 @@ export function useCanvas(_canvasType: ICanvasType, app?: IObject): void {
|
|
|
131
134
|
Platform.name = 'miniapp'
|
|
132
135
|
Platform.requestRender = function (render: IFunction): void { Platform.canvas.view.requestAnimationFrame(render) }
|
|
133
136
|
Platform.devicePixelRatio = wx.getSystemInfoSync().pixelRatio
|
|
134
|
-
Platform.realtimeLayout = true
|
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;
|