@leafer/node 1.0.0-rc.2 → 1.0.0-rc.20

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