@leafer/node 1.0.0-beta.9 → 1.0.0-rc.11

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,12 +1,15 @@
1
1
  {
2
2
  "name": "@leafer/node",
3
- "version": "1.0.0-beta.9",
3
+ "version": "1.0.0-rc.11",
4
4
  "description": "@leafer/node",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
7
7
  "main": "src/index.ts",
8
+ "types": "types/index.d.ts",
8
9
  "files": [
9
- "src"
10
+ "src",
11
+ "types",
12
+ "dist"
10
13
  ],
11
14
  "repository": {
12
15
  "type": "git",
@@ -19,13 +22,11 @@
19
22
  "leaferjs"
20
23
  ],
21
24
  "dependencies": {
22
- "@leafer/core": "1.0.0-beta.9",
23
- "@leafer/partner": "1.0.0-beta.9",
24
- "@leafer/canvas-node": "1.0.0-beta.9",
25
- "@leafer/interaction": "1.0.0-beta.9",
26
- "@leafer/image-node": "1.0.0-beta.9"
25
+ "@leafer/core": "1.0.0-rc.11",
26
+ "@leafer/canvas-node": "1.0.0-rc.11",
27
+ "@leafer/image-node": "1.0.0-rc.11"
27
28
  },
28
29
  "devDependencies": {
29
- "@leafer/interface": "1.0.0-beta.9"
30
+ "@leafer/interface": "1.0.0-rc.11"
30
31
  }
31
32
  }
package/src/index.ts CHANGED
@@ -1,38 +1,65 @@
1
1
  export * from '@leafer/core'
2
- export * from '@leafer/partner'
3
2
 
4
3
  export * from '@leafer/canvas-node'
5
- export * from '@leafer/image-web'
4
+ export * from '@leafer/image-node'
6
5
 
7
- import { ICanvasType, ICreator, IExportFileType, IExportImageType, IFunction, IObject, ISkiaCanvas } from '@leafer/interface'
8
- import { Platform, Creator } from '@leafer/core'
6
+ import { ICanvasType, ICreator, IExportFileType, IExportImageType, IFunction, IObject, ISkiaCanvas, ISkiaNAPICanvas } from '@leafer/interface'
7
+ import { Platform, Creator, FileHelper } from '@leafer/core'
9
8
 
10
9
  import { LeaferCanvas } from '@leafer/canvas-node'
11
10
  import { LeaferImage } from '@leafer/image-node'
12
- import { InteractionBase } from '@leafer/interaction'
11
+
12
+ import { writeFileSync } from 'fs'
13
+
14
+
15
+ const { mineType, fileType } = FileHelper
13
16
 
14
17
 
15
18
  Object.assign(Creator, {
16
19
  canvas: (options?, manager?) => new LeaferCanvas(options, manager),
17
- image: (options) => new LeaferImage(options),
18
- hitCanvas: (options?, manager?) => new LeaferCanvas(options, manager),
19
-
20
- interaction: (target, canvas, selector, options?) => { return new InteractionBase(target, canvas, selector, options) }
20
+ image: (options) => new LeaferImage(options)
21
21
  } as ICreator)
22
22
 
23
23
 
24
24
  export function useCanvas(canvasType: ICanvasType, power: IObject): void {
25
+
26
+ Platform.canvasType = canvasType
27
+
25
28
  if (!Platform.origin) {
26
29
  if (canvasType === 'skia') {
30
+
27
31
  const { Canvas, loadImage } = power
28
32
  Platform.origin = {
29
33
  createCanvas: (width: number, height: number, format?: string) => new Canvas(width, height, format),
30
34
  canvasToDataURL: (canvas: ISkiaCanvas, type?: IExportImageType, quality?: number) => canvas.toDataURLSync(type, { quality }),
31
35
  canvasToBolb: (canvas: ISkiaCanvas, type?: IExportFileType, quality?: number) => canvas.toBuffer(type, { quality }),
32
- canvasSaveAs: (canvas: ISkiaCanvas, filename: string, quality?: any) => canvas.saveAs(filename, { quality }),
36
+ canvasSaveAs: (canvas: ISkiaCanvas, filename: string, quality?: number) => canvas.saveAs(filename, { quality }),
37
+ loadImage
38
+ }
39
+
40
+ Platform.roundRectPatch = true
41
+
42
+ } else if (canvasType === 'napi') {
43
+
44
+ const { Canvas, loadImage } = power
45
+ Platform.origin = {
46
+ createCanvas: (width: number, height: number, format?: string) => new Canvas(width, height, format),
47
+ canvasToDataURL: (canvas: ISkiaNAPICanvas, type?: IExportImageType, quality?: number) => canvas.toDataURL(mineType(type), quality),
48
+ canvasToBolb: async (canvas: ISkiaNAPICanvas, type?: IExportFileType, quality?: number) => canvas.toBuffer(mineType(type), quality),
49
+ canvasSaveAs: async (canvas: ISkiaNAPICanvas, filename: string, quality?: number) => writeFileSync(filename, canvas.toBuffer(mineType(fileType(filename)), quality)),
33
50
  loadImage
34
51
  }
52
+
35
53
  }
54
+
55
+ Platform.ellipseToCurve = true
56
+
57
+ Platform.event = {
58
+ stopDefault(_origin: IObject): void { },
59
+ stopNow(_origin: IObject): void { },
60
+ stop(_origin: IObject): void { }
61
+ }
62
+
36
63
  Platform.canvas = Creator.canvas()
37
64
  }
38
65
  }
@@ -41,4 +68,3 @@ Platform.name = 'node'
41
68
  Platform.requestRender = function (render: IFunction): void { setTimeout(render) }
42
69
  Platform.devicePixelRatio = 1
43
70
  Platform.conicGradientSupport = true
44
- Platform.realtimeLayout = true
@@ -0,0 +1,8 @@
1
+ export * from '@leafer/core';
2
+ export * from '@leafer/canvas-node';
3
+ export * from '@leafer/image-node';
4
+ import { ICanvasType, IObject } from '@leafer/interface';
5
+
6
+ declare function useCanvas(canvasType: ICanvasType, power: IObject): void;
7
+
8
+ export { useCanvas };