@leafer-ui/app 1.5.2 → 1.6.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-ui/app",
3
- "version": "1.5.2",
3
+ "version": "1.6.0",
4
4
  "description": "@leafer-ui/app",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -22,12 +22,12 @@
22
22
  "leaferjs"
23
23
  ],
24
24
  "dependencies": {
25
- "@leafer/core": "1.5.2",
26
- "@leafer-ui/display": "1.5.2",
27
- "@leafer-ui/data": "1.5.2"
25
+ "@leafer/core": "1.6.0",
26
+ "@leafer-ui/display": "1.6.0",
27
+ "@leafer-ui/data": "1.6.0"
28
28
  },
29
29
  "devDependencies": {
30
- "@leafer/interface": "1.5.2",
31
- "@leafer-ui/interface": "1.5.2"
30
+ "@leafer/interface": "1.6.0",
31
+ "@leafer-ui/interface": "1.6.0"
32
32
  }
33
33
  }
package/src/App.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { ILeaferConfig, IResizeEvent, ILeaferCanvas, IRenderOptions, ILeaferBase, IBoundsData } from '@leafer/interface'
2
- import { Creator, DataHelper, Debug, LayoutEvent, PropertyEvent, RenderEvent, canvasSizeAttrs, registerUI } from '@leafer/core'
2
+ import { Creator, DataHelper, LayoutEvent, RenderEvent, canvasSizeAttrs, registerUI } from '@leafer/core'
3
3
 
4
- import { IApp, IAppConfig, IAppInputData, IEditorBase, ILeafer } from '@leafer-ui/interface'
4
+ import { IApp, IAppConfig, IAppForEachFn, IAppInputData, IEditorBase, ILeafer } from '@leafer-ui/interface'
5
5
 
6
6
  import { Leafer } from '@leafer-ui/draw'
7
7
 
@@ -45,32 +45,30 @@ export class App extends Leafer implements IApp {
45
45
  this.leafer = this
46
46
  this.watcher.disable()
47
47
  this.layouter.disable()
48
-
49
- this.__eventIds.push(this.on_(PropertyEvent.CHANGE, this.__onPropertyChange, this))
50
48
  }
51
49
 
52
50
  override start(): void {
53
51
  super.start()
54
- this.children.forEach(leafer => leafer.start())
52
+ this.forEach(leafer => leafer.start())
55
53
  }
56
54
 
57
55
  override stop(): void {
58
- this.children.forEach(leafer => leafer.stop())
56
+ this.forEach(leafer => leafer.stop())
59
57
  super.stop()
60
58
  }
61
59
 
62
60
  override unlockLayout(): void {
63
61
  super.unlockLayout()
64
- this.children.forEach(leafer => leafer.unlockLayout())
62
+ this.forEach(leafer => leafer.unlockLayout())
65
63
  }
66
64
 
67
65
  override lockLayout(): void {
68
66
  super.lockLayout()
69
- this.children.forEach(leafer => leafer.lockLayout())
67
+ this.forEach(leafer => leafer.lockLayout())
70
68
  }
71
69
 
72
70
  override forceRender(bounds?: IBoundsData, sync?: boolean): void {
73
- this.children.forEach(leafer => leafer.forceRender(bounds, sync))
71
+ this.forEach(leafer => leafer.forceRender(bounds, sync))
74
72
  }
75
73
 
76
74
  public addLeafer(merge?: ILeaferConfig): Leafer {
@@ -93,8 +91,8 @@ export class App extends Leafer implements IApp {
93
91
  this.__listenChildEvents(leafer)
94
92
  }
95
93
 
96
- protected __onPropertyChange(): void {
97
- if (Debug.showHitView) this.children.forEach(leafer => leafer.forceUpdate('surface'))
94
+ public forEach(fn: IAppForEachFn): void {
95
+ this.children.forEach(fn)
98
96
  }
99
97
 
100
98
  protected __onCreated(): void {
@@ -118,21 +116,21 @@ export class App extends Leafer implements IApp {
118
116
  if (canvas.context) {
119
117
  const m = options.matrix
120
118
  if (m) canvas.setTransform(m.a, m.b, m.c, m.d, m.e, m.f) // screenshot
121
- this.children.forEach(leafer => canvas.copyWorld(leafer.canvas))
119
+ this.forEach(leafer => canvas.copyWorld(leafer.canvas))
122
120
  }
123
121
  }
124
122
 
125
123
  public __onResize(event: IResizeEvent): void {
126
- this.children.forEach(leafer => leafer.resize(event))
124
+ this.forEach(leafer => leafer.resize(event))
127
125
  super.__onResize(event)
128
126
  }
129
127
 
130
128
  public updateLayout(): void {
131
- this.children.forEach(leafer => leafer.updateLayout())
129
+ this.forEach(leafer => leafer.updateLayout())
132
130
  }
133
131
 
134
132
  protected __getChildConfig(userConfig?: ILeaferConfig): ILeaferConfig {
135
- let config = { ...this.config }
133
+ const config = { ...this.config }
136
134
  config.hittable = config.realCanvas = undefined
137
135
  if (userConfig) DataHelper.assign(config, userConfig)
138
136
 
package/types/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { IBoundsData, ILeaferConfig, ILeaferCanvas, IRenderOptions, IResizeEvent, ILeaferBase } from '@leafer/interface';
2
2
  import { RenderEvent } from '@leafer/core';
3
- import { IApp, ILeafer, IAppConfig, IAppInputData } from '@leafer-ui/interface';
3
+ import { IApp, ILeafer, IAppConfig, IAppInputData, IAppForEachFn } from '@leafer-ui/interface';
4
4
  import { Leafer } from '@leafer-ui/draw';
5
5
 
6
6
  declare class App extends Leafer implements IApp {
@@ -21,7 +21,7 @@ declare class App extends Leafer implements IApp {
21
21
  forceRender(bounds?: IBoundsData, sync?: boolean): void;
22
22
  addLeafer(merge?: ILeaferConfig): Leafer;
23
23
  add(leafer: ILeafer, index?: number): void;
24
- protected __onPropertyChange(): void;
24
+ forEach(fn: IAppForEachFn): void;
25
25
  protected __onCreated(): void;
26
26
  protected __onReady(): void;
27
27
  protected __onViewReady(): void;