@leafer/canvas-miniapp 1.0.0-beta.8 → 1.0.0-rc.1

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/canvas-miniapp",
3
- "version": "1.0.0-beta.8",
3
+ "version": "1.0.0-rc.1",
4
4
  "description": "@leafer/canvas-miniapp",
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,13 @@
19
22
  "leaferjs"
20
23
  ],
21
24
  "dependencies": {
22
- "@leafer/canvas": "1.0.0-beta.8",
23
- "@leafer/data": "1.0.0-beta.8",
24
- "@leafer/event": "1.0.0-beta.8",
25
- "@leafer/platform": "1.0.0-beta.8",
26
- "@leafer/debug": "1.0.0-beta.8"
25
+ "@leafer/canvas": "1.0.0-rc.1",
26
+ "@leafer/data": "1.0.0-rc.1",
27
+ "@leafer/event": "1.0.0-rc.1",
28
+ "@leafer/platform": "1.0.0-rc.1",
29
+ "@leafer/debug": "1.0.0-rc.1"
27
30
  },
28
31
  "devDependencies": {
29
- "@leafer/interface": "1.0.0-beta.8"
32
+ "@leafer/interface": "1.0.0-rc.1"
30
33
  }
31
34
  }
@@ -1,15 +1,16 @@
1
- import { IResizeEventListener, IAutoBounds, IScreenSizeData, IFunction, IMiniappSelect } from '@leafer/interface'
2
- import { LeaferCanvasBase, canvasSizeAttrs } from '@leafer/canvas'
3
- import { Platform } from '@leafer/platform'
4
- import { DataHelper } from '@leafer/data'
5
- import { ResizeEvent } from '@leafer/event'
1
+ import { IResizeEventListener, IAutoBounds, IScreenSizeData, IFunction, IMiniappSelect, IObject } from '@leafer/interface'
2
+ import { LeaferCanvasBase, canvasPatch, canvasSizeAttrs, Platform, DataHelper, ResizeEvent } from '@leafer/core'
3
+
6
4
 
7
5
  export class LeaferCanvas extends LeaferCanvasBase {
8
6
 
9
7
  public get allowBackgroundColor(): boolean { return false }
10
8
 
11
- protected viewSelect: IMiniappSelect
12
- protected resizeListener: IResizeEventListener
9
+ public viewSelect: IMiniappSelect
10
+ public resizeListener: IResizeEventListener
11
+
12
+ public testView: any
13
+ public testContext: any
13
14
 
14
15
  public init(): void {
15
16
  let { view } = this.config
@@ -31,7 +32,7 @@ export class LeaferCanvas extends LeaferCanvasBase {
31
32
  }
32
33
  }
33
34
 
34
- protected initView(view?: any): void {
35
+ protected initView(view?: IObject): void {
35
36
  if (!view) {
36
37
  view = {}
37
38
  this.__createView()
@@ -42,6 +43,15 @@ export class LeaferCanvas extends LeaferCanvasBase {
42
43
  const { width, height, pixelRatio } = this.config
43
44
  const size = { width: width || view.width, height: height || view.height, pixelRatio }
44
45
  this.resize(size)
46
+
47
+ // fix roundRect
48
+ if (this.context.roundRect) {
49
+ this.roundRect = function (x: number, y: number, width: number, height: number, radius?: number | number[]): void {
50
+ this.context.roundRect(x, y, width, height, typeof radius === 'number' ? [radius] : radius)
51
+ }
52
+ }
53
+ canvasPatch((this.context as IObject).__proto__)
54
+
45
55
  }
46
56
 
47
57
  protected __createView(): void {
@@ -64,11 +74,9 @@ export class LeaferCanvas extends LeaferCanvasBase {
64
74
 
65
75
 
66
76
  public startAutoLayout(_autoBounds: IAutoBounds, listener: IResizeEventListener): void {
67
- if (!this.offscreen) {
68
- this.resizeListener = listener
69
- this.checkSize = this.checkSize.bind(this)
70
- Platform.miniapp.onWindowResize(this.checkSize)
71
- }
77
+ this.resizeListener = listener
78
+ this.checkSize = this.checkSize.bind(this)
79
+ Platform.miniapp.onWindowResize(this.checkSize)
72
80
  }
73
81
 
74
82
  public checkSize(): void {
@@ -95,5 +103,4 @@ export class LeaferCanvas extends LeaferCanvasBase {
95
103
  Platform.miniapp.offWindowResize(this.checkSize)
96
104
  }
97
105
 
98
-
99
106
  }
@@ -0,0 +1,20 @@
1
+ import { IMiniappSelect, IResizeEventListener, IObject, IFunction, IAutoBounds } from '@leafer/interface';
2
+ import { LeaferCanvasBase } from '@leafer/core';
3
+
4
+ declare class LeaferCanvas extends LeaferCanvasBase {
5
+ get allowBackgroundColor(): boolean;
6
+ viewSelect: IMiniappSelect;
7
+ resizeListener: IResizeEventListener;
8
+ testView: any;
9
+ testContext: any;
10
+ init(): void;
11
+ protected initView(view?: IObject): void;
12
+ protected __createView(): void;
13
+ updateViewSize(): void;
14
+ updateClientBounds(callback?: IFunction): void;
15
+ startAutoLayout(_autoBounds: IAutoBounds, listener: IResizeEventListener): void;
16
+ checkSize(): void;
17
+ stopAutoLayout(): void;
18
+ }
19
+
20
+ export { LeaferCanvas };