@leafer/interface 1.0.0-rc.26 → 1.0.0-rc.28

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/interface",
3
- "version": "1.0.0-rc.26",
3
+ "version": "1.0.0-rc.28",
4
4
  "description": "@leafer/interface",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -17,7 +17,7 @@ import { IControl } from '../control/IControl'
17
17
  import { IFunction } from '../function/IFunction'
18
18
 
19
19
 
20
- export type ILeaferType = 'draw' | 'design' | 'board' | 'document' | 'app' | 'website' | 'game' | 'player' | 'chart'
20
+ export type ILeaferType = 'draw' | 'editor' | 'design' | 'board' | 'document' | 'app' | 'website' | 'game' | 'player' | 'chart' | 'custom'
21
21
  export interface ILeaferConfig extends IRendererConfig, ILeaferCanvasConfig, IInteractionConfig, ILayouterConfig {
22
22
  start?: boolean
23
23
  type?: ILeaferType
@@ -70,7 +70,6 @@ export interface ILeaferAttrData {
70
70
  unlockLayout(): void
71
71
  lockLayout(): void
72
72
 
73
- forceRender(bounds?: IBoundsData): void
74
73
  updateCursor(cursor?: ICursorType): void
75
74
  resize(size: IScreenSizeData): void
76
75
 
@@ -5,5 +5,5 @@ import { IHitCanvas, ILeaferCanvasConfig } from './ILeaferCanvas'
5
5
  export interface IHitCanvasManager extends ICanvasManager {
6
6
  maxTotal: number // 最多缓存多少张画布
7
7
  getPathType(leaf: ILeaf): IHitCanvas
8
- getPixelType(leaf: ILeaf, config: ILeaferCanvasConfig): IHitCanvas
8
+ getPixelType(leaf: ILeaf, config?: ILeaferCanvasConfig): IHitCanvas
9
9
  }
@@ -158,6 +158,9 @@ export interface ILeaferCanvas extends ICanvasAttr, ICanvasMethod, IPathDrawer {
158
158
  backgroundColor?: string
159
159
  hittable?: boolean
160
160
 
161
+ zIndex?: number
162
+ childIndex?: number
163
+
161
164
  bounds: IBounds
162
165
  clientBounds: IBoundsData
163
166
 
@@ -111,6 +111,9 @@ export interface ILeafAttrData {
111
111
  focusStyle: ILeafInputData
112
112
  selectedStyle: ILeafInputData
113
113
  disabledStyle: ILeafInputData
114
+
115
+ // 预留给用户使用的数据对象
116
+ data: IObject
114
117
  }
115
118
 
116
119
 
@@ -367,6 +370,9 @@ export interface ILeafInputData {
367
370
  selectedStyle?: ILeafInputData
368
371
  disabledStyle?: ILeafInputData
369
372
 
373
+ // 预留给用户使用的数据对象
374
+ data?: IObject
375
+
370
376
  children?: ILeafInputData[]
371
377
 
372
378
  // other
@@ -455,6 +461,10 @@ export interface ILeafComputedData {
455
461
  selectedStyle?: ILeafInputData
456
462
  disabledStyle?: ILeafInputData
457
463
 
464
+
465
+ // 预留给用户使用的数据对象
466
+ data?: IObject
467
+
458
468
  // other
459
469
  __childBranchNumber?: number // 存在子分支的个数
460
470
  __complex?: boolean // 外观是否复杂
@@ -546,6 +556,7 @@ export interface ILeaf extends ILeafRender, ILeafHit, ILeafBounds, ILeafMatrix,
546
556
 
547
557
  readonly __onlyHitMask: boolean
548
558
  readonly __ignoreHitWorld: boolean
559
+ readonly __inLazyBounds: boolean
549
560
 
550
561
  readonly pathInputed: boolean
551
562
 
@@ -566,6 +577,10 @@ export interface ILeaf extends ILeafRender, ILeafHit, ILeafBounds, ILeafMatrix,
566
577
 
567
578
  set(data: IObject): void
568
579
  get(name?: string | string[] | IObject): ILeafInputData | IValue
580
+ setAttr(name: string, value: any): void
581
+ getAttr(name: string): any
582
+ getComputedAttr(name: string): any
583
+
569
584
  toJSON(): IObject
570
585
  toString(): string
571
586
  toSVG(): string
@@ -585,9 +600,10 @@ export interface ILeaf extends ILeafRender, ILeafHit, ILeafBounds, ILeafMatrix,
585
600
  findId(id: number | string): ILeaf | undefined
586
601
 
587
602
  focus(value?: boolean): void
588
- forceUpdate(attrName?: string): void
589
603
 
590
604
  updateLayout(): void
605
+ forceUpdate(attrName?: string): void
606
+ forceRender(_bounds?: IBoundsData): void
591
607
 
592
608
  // ILeafMatrix ->
593
609
  __updateWorldMatrix(): void
@@ -629,6 +645,7 @@ export interface ILeaf extends ILeafRender, ILeafHit, ILeafBounds, ILeafMatrix,
629
645
 
630
646
  getBounds(type?: IBoundsType, relative?: ILocationType | ILeaf): IBoundsData
631
647
  getLayoutBounds(type?: IBoundsType, relative?: ILocationType | ILeaf, unscale?: boolean): ILayoutBoundsData
648
+ getLayoutPoints(type?: IBoundsType, relative?: ILocationType | ILeaf): IPointData[]
632
649
 
633
650
  getWorldBounds(inner: IBoundsData, relative?: ILeaf, change?: boolean): IBoundsData
634
651
 
@@ -1,19 +1,21 @@
1
1
  import { IBlob, ILeaferCanvas } from '../canvas/ILeaferCanvas'
2
+ import { ICanvasContext2DSettings } from '../canvas/ICanvas'
2
3
  import { ILeaf } from '../display/ILeaf'
3
4
  import { ILocationType } from '../layout/ILeafLayout'
4
5
  import { IBoundsData } from '../math/IMath'
5
6
 
6
-
7
7
  export interface IExportOptions {
8
8
  quality?: number
9
9
  blob?: boolean
10
10
  scale?: number
11
+ smooth?: boolean
11
12
  pixelRatio?: number
12
13
  slice?: boolean
13
14
  trim?: boolean
14
15
  fill?: string
15
16
  screenshot?: IBoundsData | boolean
16
17
  relative?: ILocationType | ILeaf
18
+ contextSettings?: ICanvasContext2DSettings
17
19
  onCanvas?: IExportOnCanvasFunction
18
20
  }
19
21
 
@@ -82,10 +82,10 @@ export interface IInteractionCanvas extends ILeaferCanvas {
82
82
  export interface IInteractionConfig {
83
83
  wheel?: IWheelConfig
84
84
  pointer?: IPointerConfig
85
- cursor?: ICursorConfig
86
85
  zoom?: IZoomConfig
87
86
  move?: IMoveConfig
88
87
  eventer?: IObject
88
+ cursor?: boolean
89
89
  keyEvent?: boolean
90
90
  }
91
91
 
@@ -1,4 +1,4 @@
1
- import { IFunction } from '../function/IFunction'
1
+ import { IFunction, IStringFunction } from '../function/IFunction'
2
2
  import { ILeaferCanvas } from '../canvas/ILeaferCanvas'
3
3
  import { ILeaf } from '../display/ILeaf'
4
4
  import { IExportFileType, IExportImageType } from '../file/IFileType'
@@ -43,8 +43,10 @@ export interface IPlatform {
43
43
  hitCanvasSize: number // 图片生成碰撞画布的最大尺寸(单边)
44
44
  maxCacheSize: number // 最大等级缓存,一般取当前屏幕大小,默认2k: 2560 * 1600
45
45
  maxPatternSize: number // 最大repeat pattern缓存, 默认4k: 4096 * 2160
46
- suffix: string // 需要带上后缀区分dom中image标签的缓存,否则会导致浏览器缓存跨域问题
46
+ prefix?: string // url加前缀
47
+ suffix?: string // 需要带上后缀区分dom中image标签的缓存,否则会导致浏览器缓存跨域问题
47
48
  crossOrigin: string | false // 跨域设置
49
+ getRealURL: IStringFunction // 处理前缀、后缀
48
50
  }
49
51
  }
50
52
 
package/types/index.d.ts CHANGED
@@ -880,12 +880,14 @@ interface IExportOptions {
880
880
  quality?: number;
881
881
  blob?: boolean;
882
882
  scale?: number;
883
+ smooth?: boolean;
883
884
  pixelRatio?: number;
884
885
  slice?: boolean;
885
886
  trim?: boolean;
886
887
  fill?: string;
887
888
  screenshot?: IBoundsData | boolean;
888
889
  relative?: ILocationType | ILeaf;
890
+ contextSettings?: ICanvasContext2DSettings;
889
891
  onCanvas?: IExportOnCanvasFunction;
890
892
  }
891
893
  interface IExportResult {
@@ -1010,6 +1012,8 @@ interface ILeaferCanvas extends ICanvasAttr, ICanvasMethod, IPathDrawer {
1010
1012
  readonly allowBackgroundColor?: boolean;
1011
1013
  backgroundColor?: string;
1012
1014
  hittable?: boolean;
1015
+ zIndex?: number;
1016
+ childIndex?: number;
1013
1017
  bounds: IBounds;
1014
1018
  clientBounds: IBoundsData;
1015
1019
  config: ILeaferCanvasConfig;
@@ -1287,6 +1291,7 @@ interface ILeafAttrData {
1287
1291
  focusStyle: ILeafInputData;
1288
1292
  selectedStyle: ILeafInputData;
1289
1293
  disabledStyle: ILeafInputData;
1294
+ data: IObject;
1290
1295
  }
1291
1296
  type IAxis = 'x' | 'y';
1292
1297
  type IAxisReverse = 'x-reverse' | 'y-reverse';
@@ -1404,6 +1409,7 @@ interface ILeafInputData {
1404
1409
  focusStyle?: ILeafInputData;
1405
1410
  selectedStyle?: ILeafInputData;
1406
1411
  disabledStyle?: ILeafInputData;
1412
+ data?: IObject;
1407
1413
  children?: ILeafInputData[];
1408
1414
  noBounds?: boolean;
1409
1415
  }
@@ -1470,6 +1476,7 @@ interface ILeafComputedData {
1470
1476
  focusStyle?: ILeafInputData;
1471
1477
  selectedStyle?: ILeafInputData;
1472
1478
  disabledStyle?: ILeafInputData;
1479
+ data?: IObject;
1473
1480
  __childBranchNumber?: number;
1474
1481
  __complex?: boolean;
1475
1482
  __naturalWidth?: number;
@@ -1535,6 +1542,7 @@ interface ILeaf extends ILeafRender, ILeafHit, ILeafBounds, ILeafMatrix, ILeafDa
1535
1542
  __hasGrow?: boolean;
1536
1543
  readonly __onlyHitMask: boolean;
1537
1544
  readonly __ignoreHitWorld: boolean;
1545
+ readonly __inLazyBounds: boolean;
1538
1546
  readonly pathInputed: boolean;
1539
1547
  __parentWait?: IFunction[];
1540
1548
  __leaferWait?: IFunction[];
@@ -1548,6 +1556,9 @@ interface ILeaf extends ILeafRender, ILeafHit, ILeafBounds, ILeafMatrix, ILeafDa
1548
1556
  __bindLeafer(leafer: ILeaferBase | null): void;
1549
1557
  set(data: IObject): void;
1550
1558
  get(name?: string | string[] | IObject): ILeafInputData | IValue;
1559
+ setAttr(name: string, value: any): void;
1560
+ getAttr(name: string): any;
1561
+ getComputedAttr(name: string): any;
1551
1562
  toJSON(): IObject;
1552
1563
  toString(): string;
1553
1564
  toSVG(): string;
@@ -1562,8 +1573,9 @@ interface ILeaf extends ILeafRender, ILeafHit, ILeafBounds, ILeafMatrix, ILeafDa
1562
1573
  findOne(condition: number | string | IFindMethod, options?: any): ILeaf | undefined;
1563
1574
  findId(id: number | string): ILeaf | undefined;
1564
1575
  focus(value?: boolean): void;
1565
- forceUpdate(attrName?: string): void;
1566
1576
  updateLayout(): void;
1577
+ forceUpdate(attrName?: string): void;
1578
+ forceRender(_bounds?: IBoundsData): void;
1567
1579
  __updateWorldMatrix(): void;
1568
1580
  __updateLocalMatrix(): void;
1569
1581
  __updateWorldBounds(): void;
@@ -1590,6 +1602,7 @@ interface ILeaf extends ILeafRender, ILeafHit, ILeafBounds, ILeafMatrix, ILeafDa
1590
1602
  getTransform(relative?: ILocationType | ILeaf): IMatrixData;
1591
1603
  getBounds(type?: IBoundsType, relative?: ILocationType | ILeaf): IBoundsData;
1592
1604
  getLayoutBounds(type?: IBoundsType, relative?: ILocationType | ILeaf, unscale?: boolean): ILayoutBoundsData;
1605
+ getLayoutPoints(type?: IBoundsType, relative?: ILocationType | ILeaf): IPointData[];
1593
1606
  getWorldBounds(inner: IBoundsData, relative?: ILeaf, change?: boolean): IBoundsData;
1594
1607
  worldToLocal(world: IPointData, to?: IPointData, distance?: boolean, relative?: ILeaf): void;
1595
1608
  localToWorld(local: IPointData, to?: IPointData, distance?: boolean, relative?: ILeaf): void;
@@ -1805,10 +1818,10 @@ interface IInteractionCanvas extends ILeaferCanvas {
1805
1818
  interface IInteractionConfig {
1806
1819
  wheel?: IWheelConfig;
1807
1820
  pointer?: IPointerConfig;
1808
- cursor?: ICursorConfig;
1809
1821
  zoom?: IZoomConfig;
1810
1822
  move?: IMoveConfig;
1811
1823
  eventer?: IObject;
1824
+ cursor?: boolean;
1812
1825
  keyEvent?: boolean;
1813
1826
  }
1814
1827
  interface IZoomConfig {
@@ -1853,20 +1866,17 @@ interface IPointerConfig {
1853
1866
  preventDefault?: boolean;
1854
1867
  preventDefaultMenu?: boolean;
1855
1868
  }
1856
- interface ICursorConfig {
1857
- stop?: boolean;
1858
- }
1859
1869
 
1860
1870
  interface IHitCanvasManager extends ICanvasManager {
1861
1871
  maxTotal: number;
1862
1872
  getPathType(leaf: ILeaf): IHitCanvas;
1863
- getPixelType(leaf: ILeaf, config: ILeaferCanvasConfig): IHitCanvas;
1873
+ getPixelType(leaf: ILeaf, config?: ILeaferCanvasConfig): IHitCanvas;
1864
1874
  }
1865
1875
 
1866
1876
  interface IZoomView extends IBranch {
1867
1877
  }
1868
1878
 
1869
- type ILeaferType = 'draw' | 'design' | 'board' | 'document' | 'app' | 'website' | 'game' | 'player' | 'chart';
1879
+ type ILeaferType = 'draw' | 'editor' | 'design' | 'board' | 'document' | 'app' | 'website' | 'game' | 'player' | 'chart' | 'custom';
1870
1880
  interface ILeaferConfig extends IRendererConfig, ILeaferCanvasConfig, IInteractionConfig, ILayouterConfig {
1871
1881
  start?: boolean;
1872
1882
  type?: ILeaferType;
@@ -1904,7 +1914,6 @@ interface ILeaferAttrData {
1904
1914
  stop(): void;
1905
1915
  unlockLayout(): void;
1906
1916
  lockLayout(): void;
1907
- forceRender(bounds?: IBoundsData): void;
1908
1917
  updateCursor(cursor?: ICursorType): void;
1909
1918
  resize(size: IScreenSizeData): void;
1910
1919
  waitReady(item: IFunction, bind?: IObject): void;
@@ -2083,8 +2092,10 @@ interface IPlatform {
2083
2092
  hitCanvasSize: number;
2084
2093
  maxCacheSize: number;
2085
2094
  maxPatternSize: number;
2086
- suffix: string;
2095
+ prefix?: string;
2096
+ suffix?: string;
2087
2097
  crossOrigin: string | false;
2098
+ getRealURL: IStringFunction;
2088
2099
  };
2089
2100
  }
2090
2101
  interface IMiniappSelect extends IObject {