@leafer/data 1.0.0-rc.1 → 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,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer/data",
3
- "version": "1.0.0-rc.1",
3
+ "version": "1.0.0-rc.11",
4
4
  "description": "@leafer/data",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -15,13 +15,13 @@
15
15
  "type": "git",
16
16
  "url": "https://github.com/leaferjs/leafer.git"
17
17
  },
18
- "homepage": "https://github.com/leaferjs/leafer/tree/main/packages/data",
18
+ "homepage": "https://github.com/leaferjs/leafer/tree/main/packages/display-module/data",
19
19
  "bugs": "https://github.com/leaferjs/leafer/issues",
20
20
  "keywords": [
21
21
  "leafer",
22
22
  "leaferjs"
23
23
  ],
24
24
  "devDependencies": {
25
- "@leafer/interface": "1.0.0-rc.1"
25
+ "@leafer/interface": "1.0.0-rc.11"
26
26
  }
27
27
  }
package/src/LeafData.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ILeafData, ILeaf, IObject, __Value } from '@leafer/interface'
1
+ import { ILeafData, ILeaf, IObject, IValue } from '@leafer/interface'
2
2
 
3
3
 
4
4
  export class LeafData implements ILeafData {
@@ -12,6 +12,12 @@ export class LeafData implements ILeafData {
12
12
  public __naturalWidth?: number
13
13
  public __naturalHeight?: number
14
14
 
15
+ public get __blendMode(): string {
16
+ if ((this as ILeafData).eraser) return 'destination-out'
17
+ const { blendMode } = (this as ILeafData)
18
+ return blendMode === 'pass-through' ? null : blendMode
19
+ }
20
+
15
21
  constructor(leaf: ILeaf) {
16
22
  this.__leaf = leaf
17
23
  }
@@ -24,6 +30,18 @@ export class LeafData implements ILeafData {
24
30
  return (this as IObject)[name]
25
31
  }
26
32
 
33
+ public __getData(): IObject {
34
+ const data: IObject = { tag: this.__leaf.tag }, { __input } = this
35
+ let inputValue: IValue
36
+ for (let key in this) {
37
+ if (key[0] !== '_') {
38
+ inputValue = __input ? __input[key] : undefined
39
+ data[key] = (inputValue === undefined) ? this[key] : inputValue
40
+ }
41
+ }
42
+ return data
43
+ }
44
+
27
45
  public __setInput(name: string, value: any): void {
28
46
  this.__input || (this.__input = {})
29
47
  this.__input[name] = value
@@ -43,13 +61,14 @@ export class LeafData implements ILeafData {
43
61
 
44
62
  public __getInputData(): IObject {
45
63
  const data: IObject = { tag: this.__leaf.tag }, { __input } = this
46
- let realKey: string, value: __Value
47
-
64
+ let value: IValue, inputValue: IValue
48
65
  for (let key in this) {
49
- realKey = key.substring(1)
50
- if ((this as any)[realKey] !== undefined) {
51
- value = __input ? __input[realKey] : undefined
52
- data[realKey] = value === undefined ? this[key] : value
66
+ if (key[0] !== '_') {
67
+ value = (this as IObject)['_' + key]
68
+ if (value !== undefined) {
69
+ inputValue = __input ? __input[key] : undefined
70
+ data[key] = (inputValue === undefined) ? value : inputValue
71
+ }
53
72
  }
54
73
  }
55
74
  return data
@@ -65,14 +84,16 @@ export class LeafData implements ILeafData {
65
84
  }
66
85
 
67
86
  public __checkSingle(): void {
68
- if ((this as ILeafData).blendMode === 'pass-through') {
69
- if (this.__leaf.__hasEraser || (this as ILeafData).isEraser) {
70
- this.__single = true
71
- } else if (this.__single) {
72
- this.__single = false
87
+ const t = this as ILeafData
88
+ if (t.blendMode === 'pass-through') {
89
+ const leaf = this.__leaf
90
+ if ((t.opacity < 1 && leaf.isBranch) || leaf.__hasEraser || t.eraser) {
91
+ t.__single = true
92
+ } else if (t.__single) {
93
+ t.__single = false
73
94
  }
74
95
  } else {
75
- this.__single = true
96
+ t.__single = true
76
97
  }
77
98
  }
78
99
 
package/src/index.ts CHANGED
@@ -1,2 +1,9 @@
1
1
  export { DataHelper } from './DataHelper'
2
2
  export { LeafData } from './LeafData'
3
+
4
+ export enum Answer {
5
+ No = 0,
6
+ Yes = 1,
7
+ NoAndSkip = 2,
8
+ YesAndSkip = 3
9
+ }
package/types/index.d.ts CHANGED
@@ -14,8 +14,10 @@ declare class LeafData implements ILeafData {
14
14
  __single: boolean;
15
15
  __naturalWidth?: number;
16
16
  __naturalHeight?: number;
17
+ get __blendMode(): string;
17
18
  constructor(leaf: ILeaf);
18
19
  __get(name: string): any;
20
+ __getData(): IObject;
19
21
  __setInput(name: string, value: any): void;
20
22
  __getInput(name: string): any;
21
23
  __removeInput(name: string): void;
@@ -26,4 +28,11 @@ declare class LeafData implements ILeafData {
26
28
  destroy(): void;
27
29
  }
28
30
 
29
- export { DataHelper, LeafData };
31
+ declare enum Answer {
32
+ No = 0,
33
+ Yes = 1,
34
+ NoAndSkip = 2,
35
+ YesAndSkip = 3
36
+ }
37
+
38
+ export { Answer, DataHelper, LeafData };