@leafer/interface 1.0.0-rc.25 → 1.0.0-rc.27

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.25",
3
+ "version": "1.0.0-rc.27",
4
4
  "description": "@leafer/interface",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -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
  }
@@ -70,7 +70,7 @@ export interface ILeafAttrData {
70
70
 
71
71
  path: IPathCommandData | IPathString
72
72
  windingRule: IWindingRule
73
- closed: boolean
73
+ closed: IBoolean
74
74
 
75
75
  // auto layout
76
76
  flow: IFlowType
@@ -83,6 +83,7 @@ export interface ILeafAttrData {
83
83
  inFlow: IBoolean
84
84
  autoWidth: IAutoSize
85
85
  autoHeight: IAutoSize
86
+ lockRatio: IBoolean
86
87
  autoBox: IAutoBoxData | IConstraint
87
88
 
88
89
  widthRange: IRangeSize
@@ -110,6 +111,9 @@ export interface ILeafAttrData {
110
111
  focusStyle: ILeafInputData
111
112
  selectedStyle: ILeafInputData
112
113
  disabledStyle: ILeafInputData
114
+
115
+ // 预留给用户使用的数据对象
116
+ data: IObject
113
117
  }
114
118
 
115
119
 
@@ -324,7 +328,7 @@ export interface ILeafInputData {
324
328
 
325
329
  path?: IPathCommandData | IPathString
326
330
  windingRule?: IWindingRule
327
- closed?: boolean
331
+ closed?: IBoolean
328
332
 
329
333
  // auto layout
330
334
  flow?: IFlowType
@@ -337,6 +341,7 @@ export interface ILeafInputData {
337
341
  inFlow?: IBoolean
338
342
  autoWidth?: IAutoSize
339
343
  autoHeight?: IAutoSize
344
+ lockRatio?: IBoolean
340
345
  autoBox?: IAutoBoxData | IConstraint
341
346
 
342
347
  widthRange?: IRangeSize
@@ -365,6 +370,9 @@ export interface ILeafInputData {
365
370
  selectedStyle?: ILeafInputData
366
371
  disabledStyle?: ILeafInputData
367
372
 
373
+ // 预留给用户使用的数据对象
374
+ data?: IObject
375
+
368
376
  children?: ILeafInputData[]
369
377
 
370
378
  // other
@@ -424,6 +432,7 @@ export interface ILeafComputedData {
424
432
  inFlow?: boolean
425
433
  autoWidth?: IAutoSize
426
434
  autoHeight?: IAutoSize
435
+ lockRatio?: boolean
427
436
  autoBox?: IAutoBoxData | IConstraint
428
437
 
429
438
  widthRange?: IRangeSize
@@ -452,6 +461,10 @@ export interface ILeafComputedData {
452
461
  selectedStyle?: ILeafInputData
453
462
  disabledStyle?: ILeafInputData
454
463
 
464
+
465
+ // 预留给用户使用的数据对象
466
+ data?: IObject
467
+
455
468
  // other
456
469
  __childBranchNumber?: number // 存在子分支的个数
457
470
  __complex?: boolean // 外观是否复杂
@@ -563,10 +576,15 @@ export interface ILeaf extends ILeafRender, ILeafHit, ILeafBounds, ILeafMatrix,
563
576
 
564
577
  set(data: IObject): void
565
578
  get(name?: string | string[] | IObject): ILeafInputData | IValue
579
+ setAttr(name: string, value: any): void
580
+ getAttr(name: string): any
581
+ getComputedAttr(name: string): any
582
+
566
583
  toJSON(): IObject
567
584
  toString(): string
568
- toSVG?(): string
569
- toHTML?(): string
585
+ toSVG(): string
586
+ __SVG(data: IObject): void
587
+ toHTML(): string
570
588
 
571
589
  // ILeafData ->
572
590
  __setAttr(attrName: string, newValue: IValue, checkFiniteNumber?: boolean): boolean
@@ -577,8 +595,8 @@ export interface ILeaf extends ILeafRender, ILeafHit, ILeafBounds, ILeafMatrix,
577
595
  // find
578
596
  find(condition: number | string | IFindMethod, options?: any): ILeaf[]
579
597
  findTag(tag: string | string[]): ILeaf[]
580
- findOne(condition: number | string | IFindMethod, options?: any): ILeaf
581
- findId(id: number | string): ILeaf
598
+ findOne(condition: number | string | IFindMethod, options?: any): ILeaf | undefined
599
+ findId(id: number | string): ILeaf | undefined
582
600
 
583
601
  focus(value?: boolean): void
584
602
  forceUpdate(attrName?: string): void
@@ -648,9 +666,9 @@ export interface ILeaf extends ILeafRender, ILeafHit, ILeafBounds, ILeafMatrix,
648
666
  transform(transform?: IMatrixData, resize?: boolean): void
649
667
 
650
668
  move(x: number | IPointData, y?: number): void
651
- scaleOf(origin: IPointData, scaleX: number, scaleY?: number, resize?: boolean): void
652
- rotateOf(origin: IPointData, rotation: number): void
653
- skewOf(origin: IPointData, skewX: number, skewY?: number, resize?: boolean): void
669
+ scaleOf(origin: IPointData | IAlign, scaleX: number, scaleY?: number, resize?: boolean): void
670
+ rotateOf(origin: IPointData | IAlign, rotation: number): void
671
+ skewOf(origin: IPointData | IAlign, skewX: number, skewY?: number, resize?: boolean): void
654
672
 
655
673
  transformWorld(worldTransform?: IMatrixData, resize?: boolean): void
656
674
  moveWorld(x: number | IPointData, y?: number): void
@@ -661,6 +679,9 @@ export interface ILeaf extends ILeafRender, ILeafHit, ILeafBounds, ILeafMatrix,
661
679
  scaleResize(scaleX: number, scaleY: number, noResize?: boolean): void
662
680
  __scaleResize(scaleX: number, scaleY: number): void
663
681
 
682
+ resizeWidth(width: number): void
683
+ resizeHeight(height: number): void
684
+
664
685
  // ILeafHit ->
665
686
  __hitWorld(point: IRadiusPointData): boolean
666
687
  __hit(local: IRadiusPointData): boolean
@@ -3,7 +3,7 @@ import { ILeafList } from '../data/IList'
3
3
  import { IEvent } from './IEvent'
4
4
  import { ILeaferImage } from '../image/ILeaferImage'
5
5
  import { ILeaf } from '../display/ILeaf'
6
- import { IPointData } from '../math/IMath'
6
+ import { IPointData, IBoundsData } from '../math/IMath'
7
7
 
8
8
  export interface IUIEvent extends IEvent {
9
9
  x: number
@@ -55,6 +55,8 @@ export interface IDragEvent extends IPointerEvent {
55
55
  getPageTotal?(): IPointData
56
56
  getInnerTotal?(relative?: ILeaf): IPointData
57
57
  getLocalTotal?(relative?: ILeaf): IPointData
58
+
59
+ getPageBounds?(): IBoundsData
58
60
  }
59
61
 
60
62
  export interface IDropEvent extends IPointerEvent {
@@ -86,6 +86,7 @@ export interface IInteractionConfig {
86
86
  zoom?: IZoomConfig
87
87
  move?: IMoveConfig
88
88
  eventer?: IObject
89
+ keyEvent?: boolean
89
90
  }
90
91
 
91
92
  export interface IZoomConfig {
package/src/math/IMath.ts CHANGED
@@ -103,6 +103,7 @@ export interface IBounds extends IBoundsData, ITwoPointBoundsData {
103
103
  addListWithFn(list: IObject[], boundsDataHandle: IBoundsDataFn): IBounds
104
104
  setListWithFn(list: IObject[], boundsDataHandle: IBoundsDataFn): IBounds
105
105
 
106
+ setPoint(point: IPointData): IBounds
106
107
  setPoints(points: IPointData[]): IBounds
107
108
  addPoint(point: IPointData): IBounds
108
109
  getPoints(): IPointData[] // topLeft, topRight, bottomRight, bottomLeft
@@ -9,6 +9,7 @@ import { ICanvasType } from '../canvas/ISkiaCanvas'
9
9
  export interface IPlatform {
10
10
  name?: 'web' | 'node' | 'miniapp'
11
11
  os?: 'Mac' | 'Windows' | 'Linux'
12
+ toURL(text: string, fileType?: 'text' | 'svg'): string
12
13
  requestRender?(render: IFunction): void
13
14
  canvas?: ILeaferCanvas
14
15
  canvasType?: ICanvasType
@@ -18,7 +19,7 @@ export interface IPlatform {
18
19
  intWheelDeltaY?: boolean // firefox / Windows need
19
20
  conicGradientSupport?: boolean
20
21
  conicGradientRotate90?: boolean // firefox need rotate
21
- fullImageShadow?: boolean // safari need
22
+ fullImageShadow?: boolean // safari need
22
23
  syncDomFont?: boolean // firefox need
23
24
  layout?(target: ILeaf): void
24
25
  origin?: {
package/types/index.d.ts CHANGED
@@ -82,6 +82,7 @@ interface IBounds extends IBoundsData, ITwoPointBoundsData {
82
82
  setList(boundsList: IBoundsData[]): IBounds;
83
83
  addListWithFn(list: IObject[], boundsDataHandle: IBoundsDataFn): IBounds;
84
84
  setListWithFn(list: IObject[], boundsDataHandle: IBoundsDataFn): IBounds;
85
+ setPoint(point: IPointData): IBounds;
85
86
  setPoints(points: IPointData[]): IBounds;
86
87
  addPoint(point: IPointData): IBounds;
87
88
  getPoints(): IPointData[];
@@ -1255,7 +1256,7 @@ interface ILeafAttrData {
1255
1256
  pixelRatio: INumber;
1256
1257
  path: IPathCommandData | IPathString;
1257
1258
  windingRule: IWindingRule;
1258
- closed: boolean;
1259
+ closed: IBoolean;
1259
1260
  flow: IFlowType;
1260
1261
  padding: IFourNumber;
1261
1262
  gap: IGap | IPointGap;
@@ -1265,6 +1266,7 @@ interface ILeafAttrData {
1265
1266
  inFlow: IBoolean;
1266
1267
  autoWidth: IAutoSize;
1267
1268
  autoHeight: IAutoSize;
1269
+ lockRatio: IBoolean;
1268
1270
  autoBox: IAutoBoxData | IConstraint;
1269
1271
  widthRange: IRangeSize;
1270
1272
  heightRange: IRangeSize;
@@ -1285,6 +1287,7 @@ interface ILeafAttrData {
1285
1287
  focusStyle: ILeafInputData;
1286
1288
  selectedStyle: ILeafInputData;
1287
1289
  disabledStyle: ILeafInputData;
1290
+ data: IObject;
1288
1291
  }
1289
1292
  type IAxis = 'x' | 'y';
1290
1293
  type IAxisReverse = 'x-reverse' | 'y-reverse';
@@ -1371,7 +1374,7 @@ interface ILeafInputData {
1371
1374
  pixelRatio?: INumber;
1372
1375
  path?: IPathCommandData | IPathString;
1373
1376
  windingRule?: IWindingRule;
1374
- closed?: boolean;
1377
+ closed?: IBoolean;
1375
1378
  flow?: IFlowType;
1376
1379
  padding?: IFourNumber;
1377
1380
  gap?: IGap | IPointGap;
@@ -1381,6 +1384,7 @@ interface ILeafInputData {
1381
1384
  inFlow?: IBoolean;
1382
1385
  autoWidth?: IAutoSize;
1383
1386
  autoHeight?: IAutoSize;
1387
+ lockRatio?: IBoolean;
1384
1388
  autoBox?: IAutoBoxData | IConstraint;
1385
1389
  widthRange?: IRangeSize;
1386
1390
  heightRange?: IRangeSize;
@@ -1401,6 +1405,7 @@ interface ILeafInputData {
1401
1405
  focusStyle?: ILeafInputData;
1402
1406
  selectedStyle?: ILeafInputData;
1403
1407
  disabledStyle?: ILeafInputData;
1408
+ data?: IObject;
1404
1409
  children?: ILeafInputData[];
1405
1410
  noBounds?: boolean;
1406
1411
  }
@@ -1446,6 +1451,7 @@ interface ILeafComputedData {
1446
1451
  inFlow?: boolean;
1447
1452
  autoWidth?: IAutoSize;
1448
1453
  autoHeight?: IAutoSize;
1454
+ lockRatio?: boolean;
1449
1455
  autoBox?: IAutoBoxData | IConstraint;
1450
1456
  widthRange?: IRangeSize;
1451
1457
  heightRange?: IRangeSize;
@@ -1466,6 +1472,7 @@ interface ILeafComputedData {
1466
1472
  focusStyle?: ILeafInputData;
1467
1473
  selectedStyle?: ILeafInputData;
1468
1474
  disabledStyle?: ILeafInputData;
1475
+ data?: IObject;
1469
1476
  __childBranchNumber?: number;
1470
1477
  __complex?: boolean;
1471
1478
  __naturalWidth?: number;
@@ -1544,18 +1551,22 @@ interface ILeaf extends ILeafRender, ILeafHit, ILeafBounds, ILeafMatrix, ILeafDa
1544
1551
  __bindLeafer(leafer: ILeaferBase | null): void;
1545
1552
  set(data: IObject): void;
1546
1553
  get(name?: string | string[] | IObject): ILeafInputData | IValue;
1554
+ setAttr(name: string, value: any): void;
1555
+ getAttr(name: string): any;
1556
+ getComputedAttr(name: string): any;
1547
1557
  toJSON(): IObject;
1548
1558
  toString(): string;
1549
- toSVG?(): string;
1550
- toHTML?(): string;
1559
+ toSVG(): string;
1560
+ __SVG(data: IObject): void;
1561
+ toHTML(): string;
1551
1562
  __setAttr(attrName: string, newValue: IValue, checkFiniteNumber?: boolean): boolean;
1552
1563
  __getAttr(attrName: string): IValue;
1553
1564
  setProxyAttr(name: string, newValue: IValue): void;
1554
1565
  getProxyAttr(name: string): IValue;
1555
1566
  find(condition: number | string | IFindMethod, options?: any): ILeaf[];
1556
1567
  findTag(tag: string | string[]): ILeaf[];
1557
- findOne(condition: number | string | IFindMethod, options?: any): ILeaf;
1558
- findId(id: number | string): ILeaf;
1568
+ findOne(condition: number | string | IFindMethod, options?: any): ILeaf | undefined;
1569
+ findId(id: number | string): ILeaf | undefined;
1559
1570
  focus(value?: boolean): void;
1560
1571
  forceUpdate(attrName?: string): void;
1561
1572
  updateLayout(): void;
@@ -1601,9 +1612,9 @@ interface ILeaf extends ILeafRender, ILeafHit, ILeafBounds, ILeafMatrix, ILeafDa
1601
1612
  setTransform(transform?: IMatrixData, resize?: boolean): void;
1602
1613
  transform(transform?: IMatrixData, resize?: boolean): void;
1603
1614
  move(x: number | IPointData, y?: number): void;
1604
- scaleOf(origin: IPointData, scaleX: number, scaleY?: number, resize?: boolean): void;
1605
- rotateOf(origin: IPointData, rotation: number): void;
1606
- skewOf(origin: IPointData, skewX: number, skewY?: number, resize?: boolean): void;
1615
+ scaleOf(origin: IPointData | IAlign, scaleX: number, scaleY?: number, resize?: boolean): void;
1616
+ rotateOf(origin: IPointData | IAlign, rotation: number): void;
1617
+ skewOf(origin: IPointData | IAlign, skewX: number, skewY?: number, resize?: boolean): void;
1607
1618
  transformWorld(worldTransform?: IMatrixData, resize?: boolean): void;
1608
1619
  moveWorld(x: number | IPointData, y?: number): void;
1609
1620
  scaleOfWorld(worldOrigin: IPointData, scaleX: number, scaleY?: number, resize?: boolean): void;
@@ -1611,6 +1622,8 @@ interface ILeaf extends ILeafRender, ILeafHit, ILeafBounds, ILeafMatrix, ILeafDa
1611
1622
  skewOfWorld(worldOrigin: IPointData, skewX: number, skewY?: number, resize?: boolean): void;
1612
1623
  scaleResize(scaleX: number, scaleY: number, noResize?: boolean): void;
1613
1624
  __scaleResize(scaleX: number, scaleY: number): void;
1625
+ resizeWidth(width: number): void;
1626
+ resizeHeight(height: number): void;
1614
1627
  __hitWorld(point: IRadiusPointData): boolean;
1615
1628
  __hit(local: IRadiusPointData): boolean;
1616
1629
  __hitFill(inner: IRadiusPointData): boolean;
@@ -1720,6 +1733,7 @@ interface IDragEvent extends IPointerEvent {
1720
1733
  getPageTotal?(): IPointData;
1721
1734
  getInnerTotal?(relative?: ILeaf): IPointData;
1722
1735
  getLocalTotal?(relative?: ILeaf): IPointData;
1736
+ getPageBounds?(): IBoundsData;
1723
1737
  }
1724
1738
  interface IDropEvent extends IPointerEvent {
1725
1739
  list: ILeafList;
@@ -1801,6 +1815,7 @@ interface IInteractionConfig {
1801
1815
  zoom?: IZoomConfig;
1802
1816
  move?: IMoveConfig;
1803
1817
  eventer?: IObject;
1818
+ keyEvent?: boolean;
1804
1819
  }
1805
1820
  interface IZoomConfig {
1806
1821
  disabled?: boolean;
@@ -1851,7 +1866,7 @@ interface ICursorConfig {
1851
1866
  interface IHitCanvasManager extends ICanvasManager {
1852
1867
  maxTotal: number;
1853
1868
  getPathType(leaf: ILeaf): IHitCanvas;
1854
- getPixelType(leaf: ILeaf, config: ILeaferCanvasConfig): IHitCanvas;
1869
+ getPixelType(leaf: ILeaf, config?: ILeaferCanvasConfig): IHitCanvas;
1855
1870
  }
1856
1871
 
1857
1872
  interface IZoomView extends IBranch {
@@ -2040,6 +2055,7 @@ interface ISkiaNAPICanvas {
2040
2055
  interface IPlatform {
2041
2056
  name?: 'web' | 'node' | 'miniapp';
2042
2057
  os?: 'Mac' | 'Windows' | 'Linux';
2058
+ toURL(text: string, fileType?: 'text' | 'svg'): string;
2043
2059
  requestRender?(render: IFunction): void;
2044
2060
  canvas?: ILeaferCanvas;
2045
2061
  canvasType?: ICanvasType;