@leafer/interface 2.0.1 → 2.0.3

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": "2.0.1",
3
+ "version": "2.0.3",
4
4
  "description": "@leafer/interface",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -13,9 +13,12 @@ import { IFourNumber, IObject } from '../data/IData'
13
13
  import { IZoomView } from '../display/IView'
14
14
  import { IAppBase } from './IApp'
15
15
  import { ILeaferImage, ILeaferImageConfig } from '../image/ILeaferImage'
16
+ import { ILeaferFilm, ILeaferFilmConfig } from '../image/ILeaferFilm'
17
+ import { ILeaferVideo, ILeaferVideoConfig } from '../image/ILeaferVideo'
16
18
  import { IControl } from '../control/IControl'
17
19
  import { IFunction } from '../function/IFunction'
18
20
  import { ITransition } from '../animate/ITransition'
21
+ import { ILeafMap } from '../data/IList'
19
22
 
20
23
 
21
24
  export type ILeaferType = 'draw' | 'block' | 'viewport' | 'editor' | 'design' | 'board' | 'document' | 'app' | 'website' | 'game' | 'player' | 'chart' | 'custom' // 应用场景类型
@@ -64,6 +67,12 @@ export interface ILeaferAttrData {
64
67
  config: ILeaferConfig
65
68
  userConfig?: ILeaferConfig
66
69
 
70
+ // @leafer-in/find
71
+ cacheId?: boolean
72
+ cacheInnerId?: boolean
73
+ innerIdMap?: ILeafMap
74
+ idMap?: ILeafMap
75
+
67
76
  readonly cursorPoint: IPointData
68
77
  readonly clientBounds: IBoundsData
69
78
  leafs: number
@@ -79,8 +88,8 @@ export interface ILeaferAttrData {
79
88
  start(): void
80
89
  stop(): void
81
90
 
82
- unlockLayout(): void
83
- lockLayout(): void
91
+ unlockLayout(updateLayout?: boolean): void
92
+ lockLayout(updateLayout?: boolean): void
84
93
 
85
94
  requestRender(change: boolean): void
86
95
 
@@ -135,6 +144,8 @@ export interface ILeaferTypeList {
135
144
 
136
145
  export interface ICreator {
137
146
  image?(options?: ILeaferImageConfig): ILeaferImage
147
+ film?(options?: ILeaferFilmConfig): ILeaferFilm
148
+ video?(options?: ILeaferVideoConfig): ILeaferVideo
138
149
  canvas?(options?: ILeaferCanvasConfig, manager?: ICanvasManager): ILeaferCanvas
139
150
  hitCanvas?(options?: IHitCanvasConfig, manager?: ICanvasManager): IHitCanvas
140
151
  hitCanvasManager?(): IHitCanvasManager
@@ -143,7 +154,7 @@ export interface ICreator {
143
154
  layouter?(target: ILeaf, options?: ILayouterConfig): ILayouter
144
155
  renderer?(target: ILeaf, canvas: ILeaferCanvas, options?: IRendererConfig): IRenderer
145
156
  selector?(target?: ILeaf, options?: ISelectorConfig): ISelector
146
- finder?(target?: ILeaf): IFinder
157
+ finder?(target?: ILeaf, options?: ISelectorConfig): IFinder
147
158
 
148
159
  interaction?(target: ILeaf, canvas: IInteractionCanvas, selector: ISelector, options?: IInteractionConfig): IInteraction
149
160
 
@@ -29,6 +29,7 @@ export interface ILeafDataOptions {
29
29
  export interface ILeafData extends IDataProcessor, ILeafComputedData {
30
30
  __single?: boolean
31
31
  readonly __hasMultiPaint?: boolean // fill 、stroke 、shadow 等同时存在两次以上外观绘制的情况
32
+ __willDestroy?: boolean
32
33
  __checkSingle(): void
33
34
  __removeNaturalSize(): void
34
35
  }
package/src/data/IList.ts CHANGED
@@ -15,6 +15,9 @@ export interface ILeafList {
15
15
  list: ILeaf[]
16
16
  keys: INumberMap
17
17
  readonly length: number
18
+
19
+ needUpdate?: boolean // 一般用于event更新path
20
+
18
21
  has(leaf: ILeaf): boolean
19
22
  indexAt(index: number): ILeaf
20
23
  indexOf(leaf: ILeaf): number
@@ -21,14 +21,7 @@ import { IWindingRule, IPath2D } from '../canvas/ICanvas'
21
21
  import { IJSONOptions } from '../file/IExport'
22
22
  import { IMotionPathData } from '../path/IPathData'
23
23
  import { ITransition } from '../animate/ITransition'
24
-
25
-
26
- export interface ICachedLeaf {
27
- canvas: ILeaferCanvas, // 完整的元素缓存画布
28
- matrix?: IMatrix, // 包含导出时附加的 options.matrix
29
- fitMatrix?: IMatrix, // 不包含导出时附加的 options.matrix
30
- bounds: IBoundsData
31
- }
24
+ import { ITaskItem } from '../task/ITaskProcessor'
32
25
 
33
26
 
34
27
  export type ISide = 'width' | 'height'
@@ -245,6 +238,7 @@ export interface ILeafAttrData {
245
238
  mask?: IBoolean | IMaskType
246
239
  eraser?: IBoolean | IEraserType
247
240
  filter?: IFilter | IFilter[]
241
+ complex?: boolean
248
242
 
249
243
  // layout data
250
244
  x?: INumber
@@ -353,6 +347,7 @@ export interface ILeafComputedData {
353
347
  mask?: boolean | IMaskType
354
348
  eraser?: boolean | IEraserType
355
349
  filter?: IFilter[]
350
+ complex?: boolean
356
351
 
357
352
  // layout data
358
353
  x?: number
@@ -432,6 +427,7 @@ export interface ILeafComputedData {
432
427
  // other
433
428
  __childBranchNumber?: number // 存在子分支的个数
434
429
  __complex?: boolean // 外观是否复杂
430
+ __complexData?: ILeafComplexCachedData // 复杂元素的缓存图
435
431
 
436
432
  __naturalWidth?: number
437
433
  __naturalHeight?: number
@@ -454,12 +450,19 @@ export interface ILeafComputedData {
454
450
  __pathInputed?: number // 是否为输入path, 0:否,1:是,2:永远是(不自动检测)
455
451
  __pathForRender?: IPathCommandData
456
452
  __path2DForRender?: IPath2D
457
- __pathForArrow?: IPathCommandData
453
+
454
+ __startArrowPath?: IArrowPathData
455
+ __endArrowPath?: IArrowPathData
458
456
  __pathForMotion?: IMotionPathData
459
457
 
460
458
  __clipAfterFill?: boolean // 一般用于判断是否裁剪 Box
461
459
  }
462
460
 
461
+ export interface IArrowPathData {
462
+ data: IPathCommandData
463
+ fill?: boolean
464
+ }
465
+
463
466
  export interface ILeaf extends ILeafRender, ILeafHit, ILeafBounds, ILeafMatrix, ILeafDataProxy, ILeafInputData, IEventer {
464
467
  tag: string
465
468
  readonly __tag: string
@@ -487,6 +490,7 @@ export interface ILeaf extends ILeafRender, ILeafHit, ILeafBounds, ILeafMatrix,
487
490
  proxyData?: ILeafInputData
488
491
  __proxyData?: ILeafInputData
489
492
 
493
+ skipJSON?: boolean // 跳过 JSON 导出
490
494
  syncEventer?: ILeaf // 同步触发一样事件的元素
491
495
  lockNormalStyle?: boolean
492
496
 
@@ -529,6 +533,7 @@ export interface ILeaf extends ILeafRender, ILeafHit, ILeafBounds, ILeafMatrix,
529
533
 
530
534
  __hasAutoLayout?: boolean
531
535
  __hasMotionPath?: boolean
536
+ __hasComplex?: boolean
532
537
 
533
538
  __hasMask?: boolean
534
539
  __hasEraser?: boolean
@@ -632,7 +637,7 @@ export interface ILeaf extends ILeafRender, ILeafHit, ILeafBounds, ILeafMatrix,
632
637
  // convert
633
638
  __getNowWorld(options: IRenderOptions): IMatrixWithBoundsScaleData // when render use other matrix
634
639
  getClampRenderScale(): number // 获取当前渲染元素的缩放比例,限制最小为1
635
- getRenderScaleData(abs?: boolean, scaleFixed?: IScaleFixed): IScaleData // 当前渲染的比例数据,必须马上分解使用
640
+ getRenderScaleData(abs?: boolean, scaleFixed?: IScaleFixed, unscale?: boolean): IScaleData // 当前渲染的比例数据,必须马上分解使用
636
641
 
637
642
  getTransform(relative?: ILocationType | ILeaf): IMatrixData
638
643
 
@@ -710,7 +715,7 @@ export interface ILeaf extends ILeafRender, ILeafHit, ILeafBounds, ILeafMatrix,
710
715
  __drawPath(canvas: ILeaferCanvas): void
711
716
  __drawRenderPath(canvas: ILeaferCanvas): void
712
717
  __updatePath(): void
713
- __updateRenderPath(): void
718
+ __updateRenderPath(updateCache?: boolean): void
714
719
 
715
720
  // motion path
716
721
  getMotionPathData(): IMotionPathData
@@ -738,3 +743,19 @@ export type ILeafAttrDescriptor = IObject & ThisType<ILeaf>
738
743
  export interface ILeafAttrDescriptorFn {
739
744
  (key: string): ILeafAttrDescriptor
740
745
  }
746
+
747
+ export interface ICachedLeaf {
748
+ canvas: ILeaferCanvas, // 完整的元素缓存画布
749
+ matrix?: IMatrix, // 包含导出时附加的 options.matrix
750
+ fitMatrix?: IMatrix, // 不包含导出时附加的 options.matrix
751
+ bounds: IBoundsData
752
+ }
753
+
754
+ export interface ILeafComplexCachedData { // 复杂元素缓存对象
755
+ canvas?: ILeaferCanvas
756
+ scaleX?: number
757
+ scaleY?: number
758
+ changed?: boolean
759
+ task?: ITaskItem
760
+ destroy(): void
761
+ }
@@ -1,2 +1,32 @@
1
- export type IExportImageType = 'jpg' | 'png' | 'webp' | 'bmp'
2
- export type IExportFileType = IExportImageType | 'svg' | 'pdf' | 'json'
1
+ export type IExportImageType =
2
+ | 'jpg'
3
+ | 'png'
4
+ | 'webp'
5
+ | 'bmp'
6
+
7
+ export type IExportFileType =
8
+ | 'svg'
9
+ | 'pdf'
10
+ | 'json'
11
+ | IExportImageType
12
+
13
+ export type IFilmFileType =
14
+ | 'gif'
15
+ | 'webp'
16
+ | 'png' // apng
17
+ | 'avif'
18
+
19
+ export type IVideoFileType =
20
+ | 'mp4'
21
+ | 'webm'
22
+ | 'ogv' // ogg
23
+
24
+ export type IMultimediaType =
25
+ | 'image'
26
+ | 'film'
27
+ | 'video'
28
+
29
+ export type IResponseType =
30
+ | 'text'
31
+ | 'json'
32
+ | 'arrayBuffer'
@@ -1,13 +1,18 @@
1
1
  import { ITaskProcessor } from '../task/ITaskProcessor'
2
2
  import { ILeaferImage } from '../image/ILeaferImage'
3
- import { IExportFileType } from './IFileType'
3
+ import { IExportFileType, IFilmFileType, IVideoFileType } from './IFileType'
4
4
  import { IObject } from '../data/IData'
5
5
  import { ILeaferCanvas } from '../canvas/ILeaferCanvas'
6
+ import { ILeaferFilm } from '../image/ILeaferFilm'
7
+ import { ILeaferVideo } from '../image/ILeaferVideo'
6
8
 
7
9
 
8
10
  export interface IResource {
9
11
  map: any,
12
+
10
13
  tasker: ITaskProcessor
14
+ queue: ITaskProcessor
15
+
11
16
  readonly isComplete: boolean
12
17
 
13
18
  set(key: string, value: any): void
@@ -17,5 +22,8 @@ export interface IResource {
17
22
  setImage(key: string, value: string | IObject | ILeaferImage | ILeaferCanvas, format?: IExportFileType): ILeaferImage
18
23
  loadImage(key: string, format?: IExportFileType): Promise<ILeaferImage>
19
24
 
25
+ loadFilm(key: string, format?: IFilmFileType): Promise<ILeaferFilm>
26
+ loadVideo(key: string, format?: IVideoFileType): Promise<ILeaferVideo>
27
+
20
28
  destroy(): void
21
29
  }
@@ -1,6 +1,6 @@
1
1
  import { ILeaferImage, ILeaferImageConfig } from './ILeaferImage'
2
2
  import { ITaskProcessor } from '../task/ITaskProcessor'
3
- import { IExportFileType } from '../file/IFileType'
3
+ import { IExportFileType, IMultimediaType } from '../file/IFileType'
4
4
 
5
5
 
6
6
  export interface IImageManager {
@@ -10,7 +10,7 @@ export interface IImageManager {
10
10
  patternTasker: ITaskProcessor
11
11
  patternLocked?: boolean // 锁定pattern不更新, 一般用于创建碰撞位图 UIHit.ts
12
12
 
13
- get(config: ILeaferImageConfig): ILeaferImage
13
+ get(config: ILeaferImageConfig, type?: IMultimediaType): ILeaferImage
14
14
  recycle(image: ILeaferImage): void
15
15
 
16
16
  recyclePaint(paint: any): void
@@ -0,0 +1,63 @@
1
+ import { ILeaferImage, ILeaferImageConfig } from './ILeaferImage'
2
+ import { ILeaf } from '../display/ILeaf'
3
+ import { IPointData, IOptionPointData } from '../math/IMath'
4
+ import { ICanvasContext2D } from '../canvas/ICanvas'
5
+
6
+ export interface ILeaferFilmConfig extends ILeaferImageConfig {
7
+
8
+ }
9
+
10
+ export interface ILeaferFilm extends ILeaferImage {
11
+
12
+ }
13
+
14
+ export interface IFilmDecoder {
15
+ width: number
16
+ height: number
17
+
18
+ total: number
19
+ loop: number
20
+ frames: IFilmFrame[]
21
+
22
+ atlas?: any // 合并图
23
+ atlasContext?: any // 合并图的上下文手柄
24
+ atlasGrid?: IPointData
25
+
26
+ decoder: any
27
+
28
+ bufferCanvas?: any // 缓冲图
29
+ bufferContext?: ICanvasContext2D
30
+
31
+ createAtlas(): void
32
+ decodeHeader(data: ArrayBuffer, type: string): Promise<void>
33
+ decodeFrame(frameIndex: number): Promise<IFilmFrame>
34
+ decodeOneFrame(frameIndex: number): Promise<IFilmFrame>
35
+ mergeFrame(frameIndex: number, destoryFrameImage: boolean): void
36
+
37
+ render(canvas: any, x: number, y: number, width: number, height: number, leaf: ILeaf, paint: any, imageScaleX: number, imageScaleY: number): void
38
+
39
+ destoryFrame(frameIndex: number, deleteIndex: boolean): void
40
+ destoryFrameImage(frame: IFilmFrame): void
41
+ destroyDecoder(): void
42
+ close(): void
43
+ }
44
+
45
+ export interface IFilmFrame extends IOptionPointData {
46
+ image?: any // 不存在时使用合并图
47
+ duration: number // 毫秒
48
+ decoding?: boolean // 正在解码中
49
+ }
50
+
51
+ export interface IFilmOptions {
52
+ nowIndex?: number
53
+ pauseIndex?: number // 播放到这一帧暂停
54
+ loop?: number
55
+ speed?: number
56
+ autoplay?: boolean
57
+ }
58
+
59
+ export interface IFilmPlayOptions extends IFilmOptions {
60
+ frameTime?: number
61
+ frameTimer?: any // 下一帧的timer
62
+ paused?: boolean
63
+ }
@@ -1,19 +1,19 @@
1
1
  import { ICanvasPattern } from '../canvas/ICanvas'
2
2
  import { IObject } from '../data/IData'
3
3
  import { InnerId } from '../event/IEventer'
4
- import { IExportFileType } from '../file/IFileType'
4
+ import { IExportFileType, IFilmFileType, IVideoFileType } from '../file/IFileType'
5
5
  import { IBoundsData, IMatrixData, IPointData, ISizeData } from '../math/IMath'
6
6
  import { ILeaferCanvas } from '../canvas/ILeaferCanvas'
7
7
  import { IProgressData } from '../event/IProgress'
8
8
  import { IImageCrossOrigin } from '../platform/IPlatform'
9
9
  import { ITaskItem } from '../task/ITaskProcessor'
10
- import { IRangeSize, IInterlace } from '../display/ILeaf'
10
+ import { IRangeSize, IInterlace, ILeaf } from '../display/ILeaf'
11
11
  import { IFunction } from '../function/IFunction'
12
12
 
13
13
  export interface ILeaferImageConfig {
14
14
  url: string
15
15
  lod?: IImageLOD
16
- format?: IExportFileType
16
+ format?: IExportFileType | IFilmFileType | IVideoFileType
17
17
  crossOrigin?: IImageCrossOrigin
18
18
  showProgress?: boolean | string // 是否显示进度
19
19
  view?: IObject | ILeaferImage | ILeaferCanvas
@@ -102,6 +102,12 @@ export interface ILeaferImage {
102
102
 
103
103
  isPlacehold?: boolean // 是否显示占位符,一般在加载100ms后自动判断
104
104
 
105
+ // filter
106
+ parent?: ILeaferImage
107
+ childrenMap?: ILeaferImageMap
108
+ filterKey?: string
109
+
110
+ // lod
105
111
  largeThumb?: ILeaferImageLevel
106
112
  thumb?: ILeaferImageLevel
107
113
  levels?: ILeaferImageLevel[]
@@ -120,6 +126,8 @@ export interface ILeaferImage {
120
126
  getCanvas(width: number, height: number, opacity?: number, filters?: IObject, xGap?: number, yGap?: number, smooth?: boolean, interlace?: IInterlace): any
121
127
  getPattern(canvas: any, repeat: string | null, transform?: IMatrixData, paint?: IObject): ICanvasPattern
122
128
 
129
+ render(canvas: any, x: number, y: number, width: number, height: number, leaf: ILeaf, paint: any, imageScaleX: number, imageScaleY: number): void
130
+
123
131
  getLoadUrl(thumbSize?: ISizeData): string
124
132
  setThumbView(view: number): void
125
133
  getThumbSize(lod?: IImageLOD): ISizeData
@@ -128,7 +136,12 @@ export interface ILeaferImage {
128
136
  getLevelData(level: number, width?: number, height?: number): ILeaferImageLevel
129
137
  clearLevels(checkUse?: boolean): void
130
138
 
139
+ destroyFilter(): void // parent and childrenMap
131
140
  destroy(): void
132
141
  }
133
142
 
143
+ export interface ILeaferImageMap {
144
+ [name: string]: ILeaferImage
145
+ }
146
+
134
147
  export type IImageStatus = 'wait' | 'thumb-loading' | 'thumb-success' | 'thumb-error' | 'loading' | 'success' | 'error'
@@ -0,0 +1,9 @@
1
+ import { ILeaferImage, ILeaferImageConfig } from './ILeaferImage'
2
+
3
+ export interface ILeaferVideoConfig extends ILeaferImageConfig {
4
+
5
+ }
6
+
7
+ export interface ILeaferVideo extends ILeaferImage {
8
+
9
+ }
package/src/index.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { IAppBase } from './app/IApp'
2
2
  export { ILeaferBase, ILeaferAttrData, ILeaferType, ILeaferMode, ILeaferTypeCreator, ILeaferTypeFunction, ILeaferTypeList, ILeaferConfig, ICreator, IUICreator, IZoomType, IZoomOptions } from './app/ILeafer'
3
- export { ILeaf, ILeafAttrData, ILeafComputedData, ILeafInputData, ICachedLeaf, IFlowType, IFlowBoxType, IAlign, IAxisAlign, IFlowAlign, IFlowAxisAlign, ISide, IAxis, IGap, IPointGap, IAxisReverse, IBaseLineAlign, IFlowWrap, IAutoSize, IRangeSize, IInterlace, IPercentData, IUnitData, IConstraint, IConstraintType, IScaleFixed, IHitType, IMaskType, IEraserType, IBlendMode, IEditSize, IDragBoundsType, IImageCursor, ICursorType, IStateStyleType, IDirection, IDirection4, IAround, IFilter, ILeafAttrDescriptor, ILeafAttrDescriptorFn } from './display/ILeaf'
3
+ export { ILeaf, ILeafAttrData, ILeafComputedData, ILeafInputData, ICachedLeaf, ILeafComplexCachedData, IFlowType, IFlowBoxType, IAlign, IAxisAlign, IFlowAlign, IFlowAxisAlign, ISide, IAxis, IGap, IPointGap, IAxisReverse, IBaseLineAlign, IFlowWrap, IAutoSize, IRangeSize, IInterlace, IPercentData, IUnitData, IConstraint, IConstraintType, IScaleFixed, IHitType, IMaskType, IEraserType, IBlendMode, IEditSize, IDragBoundsType, IImageCursor, ICursorType, IStateStyleType, IDirection, IDirection4, IAround, IFilter, ILeafAttrDescriptor, ILeafAttrDescriptorFn, IArrowPathData } from './display/ILeaf'
4
4
  export { IBranch } from './display/IBranch'
5
5
  export { IZoomView } from './display/IView'
6
6
 
@@ -40,9 +40,11 @@ export { IMotionPathData } from './path/IPathData'
40
40
  export { IWindingRule, ICanvasContext2D, ICanvasContext2DSettings, ITextMetrics, IPath2D, ICanvasPattern } from './canvas/ICanvas'
41
41
  export { CanvasPathCommand, IPathCommandData, MCommandData, HCommandData, VCommandData, LCommandData, CCommandData, SCommandData, QCommandData, TCommandData, ZCommandData, ACommandData, RectCommandData, RoundRectCommandData, EllipseCommandData, ArcCommandData, ArcToCommandData, MoveToCommandObject, LineToCommandObject, BezierCurveToCommandObject, QuadraticCurveToCommandObject, IPathCommandObject, IPathCommandNodeBase, MoveToCommandNode, LineToCommandNode, BezierCurveToCommandNode, ClosePathCommandNode, IPathCommandNode, PathNodeHandleType, PathNodeHandleName, IPathNodeBase } from './path/IPathCommand'
42
42
 
43
- export { ILeaferImage, ILeaferImageConfig, IImageLOD, IImageTileLOD, ILeaferImageSliceData, ILeaferImageSlice, ILeaferImageLevel, ILeaferImageOnLoaded, ILeaferImageOnError, ILeaferImageCacheCanvas, ILeaferImagePatternPaint } from './image/ILeaferImage'
43
+ export { ILeaferImage, ILeaferImageMap, ILeaferImageConfig, IImageLOD, IImageTileLOD, ILeaferImageSliceData, ILeaferImageSlice, ILeaferImageLevel, ILeaferImageOnLoaded, ILeaferImageOnError, ILeaferImageCacheCanvas, ILeaferImagePatternPaint } from './image/ILeaferImage'
44
+ export { ILeaferFilm, ILeaferFilmConfig, IFilmDecoder, IFilmFrame, IFilmOptions, IFilmPlayOptions } from './image/ILeaferFilm'
45
+ export { ILeaferVideo, ILeaferVideoConfig } from './image/ILeaferVideo'
44
46
  export { IResource } from './file/IResource'
45
- export { IExportFileType, IExportImageType } from './file/IFileType'
47
+ export { IExportFileType, IExportImageType, IFilmFileType, IVideoFileType, IMultimediaType, IResponseType } from './file/IFileType'
46
48
  export { IExportOptions, IJSONOptions, IExportResult, IExportResultFunction, IExportOnCanvasFunction } from './file/IExport'
47
49
 
48
50
  export { InnerId, IEventer, IEventParamsMap, IEventParams, IEventListener, IEventOption, IEventListenerOptions, IEventListenerMap, IEventListenerItem, IEventListenerId } from './event/IEventer'
@@ -56,7 +58,7 @@ export { ITransformer } from './interaction/ITransformer'
56
58
 
57
59
  export { INumber, IBoolean, IString, IValue, IFourNumber, IPathString, ITimer, IObject, INumberMap, IStringMap, IBooleanMap, IFunctionMap, IPointDataMap, IDataTypeHandle } from './data/IData'
58
60
  export { ILeafList, ILeafArrayMap, ILeafMap, ILeafLevelList, ILeafListItemCallback } from './data/IList'
59
- export { IPoint, IPointData, IFromToData, IUnitPointData, IRotationPointData, IScrollPointData, IClientPointData, IRadiusPointData, ISize, ISizeData, IOptionSizeData, IScreenSizeData, IBounds, IBoundsData, IBoundsDataFn, IOffsetBoundsData, IBoundsDataWithOptionRotation, ITwoPointBoundsData, IAutoBounds, IAutoBoxData, IAutoBoundsData, IMatrix, IMatrixData, IMatrixWithBoundsData, IMatrixWithScaleData, IMatrixWithOptionScaleData, IMatrixWithOptionHalfData, IMatrixWithBoundsScaleData, IMatrixWithLayoutData, IScaleRotationData, IScaleData, ISkewData, ILayoutBoundsData, ILayoutData, ILayoutAttr } from './math/IMath'
61
+ export { IPoint, IPointData, IOptionPointData, IFromToData, IUnitPointData, IRotationPointData, IScrollPointData, IClientPointData, IRadiusPointData, ISize, ISizeData, IOptionSizeData, IScreenSizeData, IBounds, IBoundsData, IBoundsDataFn, IOffsetBoundsData, IBoundsDataWithOptionRotation, ITwoPointBoundsData, IAutoBounds, IAutoBoxData, IAutoBoundsData, IMatrix, IMatrixData, IMatrixWithBoundsData, IMatrixWithScaleData, IMatrixWithOptionScaleData, IMatrixWithOptionHalfData, IMatrixWithBoundsScaleData, IMatrixWithLayoutData, IScaleRotationData, IScaleData, ISkewData, ILayoutBoundsData, ILayoutData, ILayoutAttr } from './math/IMath'
60
62
  export { IFunction, IStringFunction, INumberFunction, IObjectFunction, IValueFunction, IPointDataFunction, IAttrDecorator } from './function/IFunction'
61
63
 
62
64
  export { ITransition, IAnimateEasing, ICubicBezierEasing, IStepsEasing, IAnimateEasingFunction, IAnimateEasingName, IAnimateEnding, IAnimateEvents, IAnimateEventFunction, ICustomEasingFunction, IAnimateOptions } from './animate/ITransition'
@@ -24,6 +24,7 @@ export interface ILeafLayout {
24
24
  // localBoxBounds: IBoundsData // use leaf.__localBoxBounds
25
25
  localStrokeBounds: IBoundsData
26
26
  localRenderBounds: IBoundsData
27
+ localOuterBounds?: IBoundsData // | renderBounds * (1 / scaleFixed) |
27
28
 
28
29
  // world
29
30
 
@@ -57,13 +58,14 @@ export interface ILeafLayout {
57
58
  localBoxChanged: boolean // position
58
59
 
59
60
  // face changed
60
- surfaceChanged: boolean
61
+ surfaceChanged: boolean // 不能包含透明度变化
61
62
  opacityChanged: boolean
62
63
 
63
64
  hitCanvasChanged: boolean
64
65
 
65
66
  childrenSortChanged?: boolean
66
67
  stateStyleChanged?: boolean // hoverStyle ...
68
+ linkerChanged?: boolean
67
69
 
68
70
  // config changed
69
71
  scrollConfigChanged?: boolean
@@ -79,6 +81,10 @@ export interface ILeafLayout {
79
81
  renderSpread: IFourNumber // -1 表示需监视变化,不影响实际renderBounds,目前用在Box上
80
82
  renderShapeSpread: IFourNumber
81
83
 
84
+ // scale fixed
85
+ scaleFixed?: number
86
+ outerScale?: number // localOuterBounds: scaleFixed < 1
87
+
82
88
  // temp local
83
89
  a: number
84
90
  b: number
package/src/math/IMath.ts CHANGED
@@ -1,11 +1,16 @@
1
1
  import { IFourNumber, IObject } from '../data/IData'
2
- import { IAlign, ISide } from '../display/ILeaf'
2
+ import { IAlign, ISide, IAround } from '../display/ILeaf'
3
3
 
4
4
  export interface IPointData {
5
5
  x: number
6
6
  y: number
7
7
  }
8
8
 
9
+ export interface IOptionPointData {
10
+ x?: number
11
+ y?: number
12
+ }
13
+
9
14
  export interface IUnitPointData extends IPointData {
10
15
  type?: 'percent' | 'px'
11
16
  }
@@ -51,6 +56,8 @@ export interface IPoint extends IPointData {
51
56
  getAngle(to: IPointData): number
52
57
  getAtan2(to: IPointData): number
53
58
 
59
+ isSame(point: IPointData, quick?: boolean): boolean
60
+
54
61
  reset(): IPoint
55
62
  }
56
63
 
@@ -121,6 +128,7 @@ export interface IBounds extends IBoundsData, ITwoPointBoundsData {
121
128
  setPoints(points: IPointData[]): IBounds
122
129
  addPoint(point: IPointData): IBounds
123
130
  getPoints(): IPointData[] // topLeft, topRight, bottomRight, bottomLeft
131
+ getPoint(around: IAround, onlyBoxSize?: boolean, to?: IPointData): IPointData
124
132
 
125
133
  hitPoint(point: IPointData, pointMatrix?: IMatrixData): boolean
126
134
  hitRadiusPoint(point: IRadiusPointData, pointMatrix?: IMatrixWithLayoutData): boolean
@@ -1,13 +1,15 @@
1
1
  import { IFunction, IStringFunction } from '../function/IFunction'
2
2
  import { ILeaferCanvas } from '../canvas/ILeaferCanvas'
3
3
  import { IInterlace, ILeaf } from '../display/ILeaf'
4
- import { IExportFileType, IExportImageType } from '../file/IFileType'
4
+ import { IExportFileType, IExportImageType, IResponseType } from '../file/IFileType'
5
5
  import { IBoundsData, ISizeData, IMatrixData } from '../math/IMath'
6
6
  import { IObject } from '../data/IData'
7
7
  import { ICanvasType } from '../canvas/ISkiaCanvas'
8
8
  import { ISelector } from '../selector/ISelector'
9
9
  import { IRenderOptions } from '../renderer/IRenderer'
10
10
  import { ILeaferImage } from '../image/ILeaferImage'
11
+ import { ILeaferFilm } from '../image/ILeaferFilm'
12
+ import { ILeaferVideo } from '../image/ILeaferVideo'
11
13
  import { ICanvasPattern } from '../canvas/ICanvas'
12
14
 
13
15
 
@@ -45,6 +47,9 @@ export interface IPlatform {
45
47
  canvasSaveAs(canvas: any, filename: string, quality?: number): Promise<void>
46
48
  download(url: string, filename: string): Promise<void>
47
49
  loadImage(url: string, crossOrigin?: IImageCrossOrigin, leaferImage?: ILeaferImage): Promise<any>
50
+ loadFilm?(url: string, crossOrigin?: IImageCrossOrigin, leaferFilm?: ILeaferFilm): Promise<any>
51
+ loadVideo?(url: string, crossOrigin?: IImageCrossOrigin, leaferVideo?: ILeaferVideo): Promise<any>
52
+ loadContent(url: string, responseType: IResponseType): Promise<any>
48
53
  noRepeat?: string // fix: 微信小程序 createPattern 直接使用 no-repeat 有bug,导致无法显示
49
54
  Image?: any
50
55
  PointerEvent?: any
@@ -25,6 +25,9 @@ export interface IRenderOptions {
25
25
  ignoreFill?: boolean, // 绘制外形时忽略fill
26
26
  ignoreStroke?: boolean // 绘制外形时忽略stroke
27
27
 
28
+ ignoreOpacity?: boolean // 绘制时忽略元素的opacity
29
+
30
+
28
31
  cellList?: ILeafList
29
32
  }
30
33
 
@@ -66,6 +69,6 @@ export interface IRenderer extends IControl {
66
69
  clipRender(bounds: IBounds): void
67
70
  fullRender(): void
68
71
 
69
- addBlock(block: IBounds): void
72
+ addBlock(block: IBounds, leafList?: ILeafList): void
70
73
  mergeBlocks(): void
71
74
  }
package/types/index.d.ts CHANGED
@@ -4,6 +4,10 @@ interface IPointData {
4
4
  x: number;
5
5
  y: number;
6
6
  }
7
+ interface IOptionPointData {
8
+ x?: number;
9
+ y?: number;
10
+ }
7
11
  interface IUnitPointData extends IPointData {
8
12
  type?: 'percent' | 'px';
9
13
  }
@@ -39,6 +43,7 @@ interface IPoint extends IPointData {
39
43
  getDistancePoint(to: IPointData, distance: number, changeTo?: boolean): IPoint;
40
44
  getAngle(to: IPointData): number;
41
45
  getAtan2(to: IPointData): number;
46
+ isSame(point: IPointData, quick?: boolean): boolean;
42
47
  reset(): IPoint;
43
48
  }
44
49
  interface IRadiusPointData extends IPointData {
@@ -95,6 +100,7 @@ interface IBounds extends IBoundsData, ITwoPointBoundsData {
95
100
  setPoints(points: IPointData[]): IBounds;
96
101
  addPoint(point: IPointData): IBounds;
97
102
  getPoints(): IPointData[];
103
+ getPoint(around: IAround, onlyBoxSize?: boolean, to?: IPointData): IPointData;
98
104
  hitPoint(point: IPointData, pointMatrix?: IMatrixData): boolean;
99
105
  hitRadiusPoint(point: IRadiusPointData, pointMatrix?: IMatrixWithLayoutData): boolean;
100
106
  hit(bounds: IBoundsData, boundsMatrix?: IMatrixData): boolean;
@@ -264,6 +270,7 @@ interface ILeafList {
264
270
  list: ILeaf[];
265
271
  keys: INumberMap;
266
272
  readonly length: number;
273
+ needUpdate?: boolean;
267
274
  has(leaf: ILeaf): boolean;
268
275
  indexAt(index: number): ILeaf;
269
276
  indexOf(leaf: ILeaf): number;
@@ -911,7 +918,11 @@ interface ICanvasManager {
911
918
  }
912
919
 
913
920
  type IExportImageType = 'jpg' | 'png' | 'webp' | 'bmp';
914
- type IExportFileType = IExportImageType | 'svg' | 'pdf' | 'json';
921
+ type IExportFileType = 'svg' | 'pdf' | 'json' | IExportImageType;
922
+ type IFilmFileType = 'gif' | 'webp' | 'png' | 'avif';
923
+ type IVideoFileType = 'mp4' | 'webm' | 'ogv';
924
+ type IMultimediaType = 'image' | 'film' | 'video';
925
+ type IResponseType = 'text' | 'json' | 'arrayBuffer';
915
926
 
916
927
  type ILocationType = 'world' | 'page' | 'local' | 'inner';
917
928
  type IBoundsType = 'content' | 'box' | 'stroke' | 'render';
@@ -925,6 +936,7 @@ interface ILeafLayout {
925
936
  localContentBounds: IBoundsData;
926
937
  localStrokeBounds: IBoundsData;
927
938
  localRenderBounds: IBoundsData;
939
+ localOuterBounds?: IBoundsData;
928
940
  worldContentBounds: IBoundsData;
929
941
  worldBoxBounds: IBoundsData;
930
942
  worldStrokeBounds: IBoundsData;
@@ -946,6 +958,7 @@ interface ILeafLayout {
946
958
  hitCanvasChanged: boolean;
947
959
  childrenSortChanged?: boolean;
948
960
  stateStyleChanged?: boolean;
961
+ linkerChanged?: boolean;
949
962
  scrollConfigChanged?: boolean;
950
963
  editConfigChanged?: boolean;
951
964
  affectScaleOrRotation: boolean;
@@ -955,6 +968,8 @@ interface ILeafLayout {
955
968
  strokeBoxSpread: number;
956
969
  renderSpread: IFourNumber;
957
970
  renderShapeSpread: IFourNumber;
971
+ scaleFixed?: number;
972
+ outerScale?: number;
958
973
  a: number;
959
974
  b: number;
960
975
  c: number;
@@ -1197,6 +1212,7 @@ interface IRenderOptions {
1197
1212
  shape?: boolean;
1198
1213
  ignoreFill?: boolean;
1199
1214
  ignoreStroke?: boolean;
1215
+ ignoreOpacity?: boolean;
1200
1216
  cellList?: ILeafList;
1201
1217
  }
1202
1218
  interface IRendererConfig {
@@ -1228,7 +1244,7 @@ interface IRenderer extends IControl {
1228
1244
  partRender(): void;
1229
1245
  clipRender(bounds: IBounds): void;
1230
1246
  fullRender(): void;
1231
- addBlock(block: IBounds): void;
1247
+ addBlock(block: IBounds, leafList?: ILeafList): void;
1232
1248
  mergeBlocks(): void;
1233
1249
  }
1234
1250
 
@@ -1310,6 +1326,7 @@ interface ILeafDataOptions {
1310
1326
  interface ILeafData extends IDataProcessor, ILeafComputedData {
1311
1327
  __single?: boolean;
1312
1328
  readonly __hasMultiPaint?: boolean;
1329
+ __willDestroy?: boolean;
1313
1330
  __checkSingle(): void;
1314
1331
  __removeNaturalSize(): void;
1315
1332
  }
@@ -1435,12 +1452,49 @@ interface IAnimateEventFunction {
1435
1452
  (animate?: any): any;
1436
1453
  }
1437
1454
 
1438
- interface ICachedLeaf {
1439
- canvas: ILeaferCanvas;
1440
- matrix?: IMatrix;
1441
- fitMatrix?: IMatrix;
1442
- bounds: IBoundsData;
1455
+ interface ITaskProcessorConfig {
1456
+ onComplete?: IFunction;
1457
+ onTask?: IFunction;
1458
+ onError?: IFunction;
1459
+ parallel?: number;
1443
1460
  }
1461
+ interface ITaskProcessor {
1462
+ config: ITaskProcessorConfig;
1463
+ running: boolean;
1464
+ isComplete: boolean;
1465
+ percent: number;
1466
+ total: number;
1467
+ index: number;
1468
+ finishedIndex: number;
1469
+ remain: number;
1470
+ start(): void;
1471
+ pause(): void;
1472
+ resume(): void;
1473
+ skip(): void;
1474
+ stop(): void;
1475
+ add(taskCallback: IFunction, options?: ITaskOptions | number, canUse?: IFunction): ITaskItem;
1476
+ destroy(): void;
1477
+ }
1478
+ interface ITaskItem {
1479
+ parent: ITaskProcessor;
1480
+ parallel: boolean;
1481
+ isComplete: boolean;
1482
+ isCancel: boolean;
1483
+ time: number;
1484
+ task?: IFunction;
1485
+ canUse?: IFunction;
1486
+ run(): Promise<void>;
1487
+ complete(): void;
1488
+ cancel(): void;
1489
+ }
1490
+ interface ITaskOptions {
1491
+ start?: boolean;
1492
+ time?: number;
1493
+ parallel?: boolean;
1494
+ delay?: number;
1495
+ canUse?: IFunction;
1496
+ }
1497
+
1444
1498
  type ISide = 'width' | 'height';
1445
1499
  type IAxis = 'x' | 'y';
1446
1500
  type IAxisReverse = 'x-reverse' | 'y-reverse';
@@ -1521,6 +1575,7 @@ interface ILeafAttrData {
1521
1575
  mask?: IBoolean | IMaskType;
1522
1576
  eraser?: IBoolean | IEraserType;
1523
1577
  filter?: IFilter | IFilter[];
1578
+ complex?: boolean;
1524
1579
  x?: INumber;
1525
1580
  y?: INumber;
1526
1581
  width?: INumber;
@@ -1599,6 +1654,7 @@ interface ILeafComputedData {
1599
1654
  mask?: boolean | IMaskType;
1600
1655
  eraser?: boolean | IEraserType;
1601
1656
  filter?: IFilter[];
1657
+ complex?: boolean;
1602
1658
  x?: number;
1603
1659
  y?: number;
1604
1660
  width?: number;
@@ -1655,6 +1711,7 @@ interface ILeafComputedData {
1655
1711
  data?: IObject;
1656
1712
  __childBranchNumber?: number;
1657
1713
  __complex?: boolean;
1714
+ __complexData?: ILeafComplexCachedData;
1658
1715
  __naturalWidth?: number;
1659
1716
  __naturalHeight?: number;
1660
1717
  readonly __autoWidth?: boolean;
@@ -1672,10 +1729,15 @@ interface ILeafComputedData {
1672
1729
  __pathInputed?: number;
1673
1730
  __pathForRender?: IPathCommandData;
1674
1731
  __path2DForRender?: IPath2D;
1675
- __pathForArrow?: IPathCommandData;
1732
+ __startArrowPath?: IArrowPathData;
1733
+ __endArrowPath?: IArrowPathData;
1676
1734
  __pathForMotion?: IMotionPathData;
1677
1735
  __clipAfterFill?: boolean;
1678
1736
  }
1737
+ interface IArrowPathData {
1738
+ data: IPathCommandData;
1739
+ fill?: boolean;
1740
+ }
1679
1741
  interface ILeaf extends ILeafRender, ILeafHit, ILeafBounds, ILeafMatrix, ILeafDataProxy, ILeafInputData, IEventer {
1680
1742
  tag: string;
1681
1743
  readonly __tag: string;
@@ -1696,6 +1758,7 @@ interface ILeaf extends ILeafRender, ILeafHit, ILeafBounds, ILeafMatrix, ILeafDa
1696
1758
  __: ILeafData;
1697
1759
  proxyData?: ILeafInputData;
1698
1760
  __proxyData?: ILeafInputData;
1761
+ skipJSON?: boolean;
1699
1762
  syncEventer?: ILeaf;
1700
1763
  lockNormalStyle?: boolean;
1701
1764
  __layout: ILeafLayout;
@@ -1724,6 +1787,7 @@ interface ILeaf extends ILeafRender, ILeafHit, ILeafBounds, ILeafMatrix, ILeafDa
1724
1787
  animationOut?: IObject | IObject[];
1725
1788
  __hasAutoLayout?: boolean;
1726
1789
  __hasMotionPath?: boolean;
1790
+ __hasComplex?: boolean;
1727
1791
  __hasMask?: boolean;
1728
1792
  __hasEraser?: boolean;
1729
1793
  __hitCanvas?: IHitCanvas;
@@ -1795,7 +1859,7 @@ interface ILeaf extends ILeafRender, ILeafHit, ILeafBounds, ILeafMatrix, ILeafDa
1795
1859
  __renderEraser(canvas: ILeaferCanvas, options: IRenderOptions): void;
1796
1860
  __getNowWorld(options: IRenderOptions): IMatrixWithBoundsScaleData;
1797
1861
  getClampRenderScale(): number;
1798
- getRenderScaleData(abs?: boolean, scaleFixed?: IScaleFixed): IScaleData;
1862
+ getRenderScaleData(abs?: boolean, scaleFixed?: IScaleFixed, unscale?: boolean): IScaleData;
1799
1863
  getTransform(relative?: ILocationType | ILeaf): IMatrixData;
1800
1864
  getBounds(type?: IBoundsType, relative?: ILocationType | ILeaf): IBoundsData;
1801
1865
  getLayoutBounds(type?: IBoundsType, relative?: ILocationType | ILeaf, unscale?: boolean): ILayoutBoundsData;
@@ -1853,7 +1917,7 @@ interface ILeaf extends ILeafRender, ILeafHit, ILeafBounds, ILeafMatrix, ILeafDa
1853
1917
  __drawPath(canvas: ILeaferCanvas): void;
1854
1918
  __drawRenderPath(canvas: ILeaferCanvas): void;
1855
1919
  __updatePath(): void;
1856
- __updateRenderPath(): void;
1920
+ __updateRenderPath(updateCache?: boolean): void;
1857
1921
  getMotionPathData(): IMotionPathData;
1858
1922
  getMotionPoint(motionDistance: number | IUnitData): IRotationPointData;
1859
1923
  getMotionTotal(): number;
@@ -1871,6 +1935,20 @@ type ILeafAttrDescriptor = IObject & ThisType<ILeaf>;
1871
1935
  interface ILeafAttrDescriptorFn {
1872
1936
  (key: string): ILeafAttrDescriptor;
1873
1937
  }
1938
+ interface ICachedLeaf {
1939
+ canvas: ILeaferCanvas;
1940
+ matrix?: IMatrix;
1941
+ fitMatrix?: IMatrix;
1942
+ bounds: IBoundsData;
1943
+ }
1944
+ interface ILeafComplexCachedData {
1945
+ canvas?: ILeaferCanvas;
1946
+ scaleX?: number;
1947
+ scaleY?: number;
1948
+ changed?: boolean;
1949
+ task?: ITaskItem;
1950
+ destroy(): void;
1951
+ }
1874
1952
 
1875
1953
  interface IProgressData {
1876
1954
  value: number;
@@ -1910,6 +1988,56 @@ interface ISkiaNAPICanvas {
1910
1988
  toDataURLAsync(mime: 'image/jpeg' | 'image/webp' | string, quality?: number): Promise<string>;
1911
1989
  }
1912
1990
 
1991
+ interface ILeaferFilmConfig extends ILeaferImageConfig {
1992
+ }
1993
+ interface ILeaferFilm extends ILeaferImage {
1994
+ }
1995
+ interface IFilmDecoder {
1996
+ width: number;
1997
+ height: number;
1998
+ total: number;
1999
+ loop: number;
2000
+ frames: IFilmFrame[];
2001
+ atlas?: any;
2002
+ atlasContext?: any;
2003
+ atlasGrid?: IPointData;
2004
+ decoder: any;
2005
+ bufferCanvas?: any;
2006
+ bufferContext?: ICanvasContext2D;
2007
+ createAtlas(): void;
2008
+ decodeHeader(data: ArrayBuffer, type: string): Promise<void>;
2009
+ decodeFrame(frameIndex: number): Promise<IFilmFrame>;
2010
+ decodeOneFrame(frameIndex: number): Promise<IFilmFrame>;
2011
+ mergeFrame(frameIndex: number, destoryFrameImage: boolean): void;
2012
+ render(canvas: any, x: number, y: number, width: number, height: number, leaf: ILeaf, paint: any, imageScaleX: number, imageScaleY: number): void;
2013
+ destoryFrame(frameIndex: number, deleteIndex: boolean): void;
2014
+ destoryFrameImage(frame: IFilmFrame): void;
2015
+ destroyDecoder(): void;
2016
+ close(): void;
2017
+ }
2018
+ interface IFilmFrame extends IOptionPointData {
2019
+ image?: any;
2020
+ duration: number;
2021
+ decoding?: boolean;
2022
+ }
2023
+ interface IFilmOptions {
2024
+ nowIndex?: number;
2025
+ pauseIndex?: number;
2026
+ loop?: number;
2027
+ speed?: number;
2028
+ autoplay?: boolean;
2029
+ }
2030
+ interface IFilmPlayOptions extends IFilmOptions {
2031
+ frameTime?: number;
2032
+ frameTimer?: any;
2033
+ paused?: boolean;
2034
+ }
2035
+
2036
+ interface ILeaferVideoConfig extends ILeaferImageConfig {
2037
+ }
2038
+ interface ILeaferVideo extends ILeaferImage {
2039
+ }
2040
+
1913
2041
  interface IPlatform {
1914
2042
  name?: 'web' | 'node' | 'miniapp';
1915
2043
  os?: 'Mac' | 'Windows' | 'Linux';
@@ -1938,6 +2066,9 @@ interface IPlatform {
1938
2066
  canvasSaveAs(canvas: any, filename: string, quality?: number): Promise<void>;
1939
2067
  download(url: string, filename: string): Promise<void>;
1940
2068
  loadImage(url: string, crossOrigin?: IImageCrossOrigin, leaferImage?: ILeaferImage): Promise<any>;
2069
+ loadFilm?(url: string, crossOrigin?: IImageCrossOrigin, leaferFilm?: ILeaferFilm): Promise<any>;
2070
+ loadVideo?(url: string, crossOrigin?: IImageCrossOrigin, leaferVideo?: ILeaferVideo): Promise<any>;
2071
+ loadContent(url: string, responseType: IResponseType): Promise<any>;
1941
2072
  noRepeat?: string;
1942
2073
  Image?: any;
1943
2074
  PointerEvent?: any;
@@ -1984,53 +2115,10 @@ interface IMiniapp {
1984
2115
  saveToAlbum(path: string): Promise<any>;
1985
2116
  }
1986
2117
 
1987
- interface ITaskProcessorConfig {
1988
- onComplete?: IFunction;
1989
- onTask?: IFunction;
1990
- onError?: IFunction;
1991
- parallel?: number;
1992
- }
1993
- interface ITaskProcessor {
1994
- config: ITaskProcessorConfig;
1995
- running: boolean;
1996
- isComplete: boolean;
1997
- percent: number;
1998
- total: number;
1999
- index: number;
2000
- finishedIndex: number;
2001
- remain: number;
2002
- start(): void;
2003
- pause(): void;
2004
- resume(): void;
2005
- skip(): void;
2006
- stop(): void;
2007
- add(taskCallback: IFunction, options?: ITaskOptions | number, canUse?: IFunction): ITaskItem;
2008
- destroy(): void;
2009
- }
2010
- interface ITaskItem {
2011
- parent: ITaskProcessor;
2012
- parallel: boolean;
2013
- isComplete: boolean;
2014
- isCancel: boolean;
2015
- time: number;
2016
- task?: IFunction;
2017
- canUse?: IFunction;
2018
- run(): Promise<void>;
2019
- complete(): void;
2020
- cancel(): void;
2021
- }
2022
- interface ITaskOptions {
2023
- start?: boolean;
2024
- time?: number;
2025
- parallel?: boolean;
2026
- delay?: number;
2027
- canUse?: IFunction;
2028
- }
2029
-
2030
2118
  interface ILeaferImageConfig {
2031
2119
  url: string;
2032
2120
  lod?: IImageLOD;
2033
- format?: IExportFileType;
2121
+ format?: IExportFileType | IFilmFileType | IVideoFileType;
2034
2122
  crossOrigin?: IImageCrossOrigin;
2035
2123
  showProgress?: boolean | string;
2036
2124
  view?: IObject | ILeaferImage | ILeaferCanvas;
@@ -2101,6 +2189,9 @@ interface ILeaferImage {
2101
2189
  error: IObject;
2102
2190
  loading: boolean;
2103
2191
  isPlacehold?: boolean;
2192
+ parent?: ILeaferImage;
2193
+ childrenMap?: ILeaferImageMap;
2194
+ filterKey?: string;
2104
2195
  largeThumb?: ILeaferImageLevel;
2105
2196
  thumb?: ILeaferImageLevel;
2106
2197
  levels?: ILeaferImageLevel[];
@@ -2115,14 +2206,19 @@ interface ILeaferImage {
2115
2206
  getFull(filters?: IObject): any;
2116
2207
  getCanvas(width: number, height: number, opacity?: number, filters?: IObject, xGap?: number, yGap?: number, smooth?: boolean, interlace?: IInterlace): any;
2117
2208
  getPattern(canvas: any, repeat: string | null, transform?: IMatrixData, paint?: IObject): ICanvasPattern;
2209
+ render(canvas: any, x: number, y: number, width: number, height: number, leaf: ILeaf, paint: any, imageScaleX: number, imageScaleY: number): void;
2118
2210
  getLoadUrl(thumbSize?: ISizeData): string;
2119
2211
  setThumbView(view: number): void;
2120
2212
  getThumbSize(lod?: IImageLOD): ISizeData;
2121
2213
  getMinLevel(): number;
2122
2214
  getLevelData(level: number, width?: number, height?: number): ILeaferImageLevel;
2123
2215
  clearLevels(checkUse?: boolean): void;
2216
+ destroyFilter(): void;
2124
2217
  destroy(): void;
2125
2218
  }
2219
+ interface ILeaferImageMap {
2220
+ [name: string]: ILeaferImage;
2221
+ }
2126
2222
 
2127
2223
  interface IUIEvent extends IEvent {
2128
2224
  x: number;
@@ -2397,6 +2493,10 @@ interface ILeaferAttrData {
2397
2493
  lazyBounds: IBounds;
2398
2494
  config: ILeaferConfig;
2399
2495
  userConfig?: ILeaferConfig;
2496
+ cacheId?: boolean;
2497
+ cacheInnerId?: boolean;
2498
+ innerIdMap?: ILeafMap;
2499
+ idMap?: ILeafMap;
2400
2500
  readonly cursorPoint: IPointData;
2401
2501
  readonly clientBounds: IBoundsData;
2402
2502
  leafs: number;
@@ -2407,8 +2507,8 @@ interface ILeaferAttrData {
2407
2507
  init(userConfig?: ILeaferConfig, parentApp?: IAppBase): void;
2408
2508
  start(): void;
2409
2509
  stop(): void;
2410
- unlockLayout(): void;
2411
- lockLayout(): void;
2510
+ unlockLayout(updateLayout?: boolean): void;
2511
+ lockLayout(updateLayout?: boolean): void;
2412
2512
  requestRender(change: boolean): void;
2413
2513
  updateCursor(cursor?: ICursorType): void;
2414
2514
  resize(size: IScreenSizeData): void;
@@ -2450,6 +2550,8 @@ interface ILeaferTypeList {
2450
2550
  }
2451
2551
  interface ICreator {
2452
2552
  image?(options?: ILeaferImageConfig): ILeaferImage;
2553
+ film?(options?: ILeaferFilmConfig): ILeaferFilm;
2554
+ video?(options?: ILeaferVideoConfig): ILeaferVideo;
2453
2555
  canvas?(options?: ILeaferCanvasConfig, manager?: ICanvasManager): ILeaferCanvas;
2454
2556
  hitCanvas?(options?: IHitCanvasConfig, manager?: ICanvasManager): IHitCanvas;
2455
2557
  hitCanvasManager?(): IHitCanvasManager;
@@ -2457,7 +2559,7 @@ interface ICreator {
2457
2559
  layouter?(target: ILeaf, options?: ILayouterConfig): ILayouter;
2458
2560
  renderer?(target: ILeaf, canvas: ILeaferCanvas, options?: IRendererConfig): IRenderer;
2459
2561
  selector?(target?: ILeaf, options?: ISelectorConfig): ISelector;
2460
- finder?(target?: ILeaf): IFinder;
2562
+ finder?(target?: ILeaf, options?: ISelectorConfig): IFinder;
2461
2563
  interaction?(target: ILeaf, canvas: IInteractionCanvas, selector: ISelector, options?: IInteractionConfig): IInteraction;
2462
2564
  editor?(options?: IObject, app?: IAppBase): ILeaf;
2463
2565
  }
@@ -2481,7 +2583,7 @@ interface IImageManager {
2481
2583
  recycledList: ILeaferImage[];
2482
2584
  patternTasker: ITaskProcessor;
2483
2585
  patternLocked?: boolean;
2484
- get(config: ILeaferImageConfig): ILeaferImage;
2586
+ get(config: ILeaferImageConfig, type?: IMultimediaType): ILeaferImage;
2485
2587
  recycle(image: ILeaferImage): void;
2486
2588
  recyclePaint(paint: any): void;
2487
2589
  clearRecycled(force?: boolean): void;
@@ -2502,12 +2604,15 @@ interface IPlugin extends IObject {
2502
2604
  interface IResource {
2503
2605
  map: any;
2504
2606
  tasker: ITaskProcessor;
2607
+ queue: ITaskProcessor;
2505
2608
  readonly isComplete: boolean;
2506
2609
  set(key: string, value: any): void;
2507
2610
  get(key: string): any;
2508
2611
  remove(key: string): void;
2509
2612
  setImage(key: string, value: string | IObject | ILeaferImage | ILeaferCanvas, format?: IExportFileType): ILeaferImage;
2510
2613
  loadImage(key: string, format?: IExportFileType): Promise<ILeaferImage>;
2614
+ loadFilm(key: string, format?: IFilmFileType): Promise<ILeaferFilm>;
2615
+ loadVideo(key: string, format?: IVideoFileType): Promise<ILeaferVideo>;
2511
2616
  destroy(): void;
2512
2617
  }
2513
2618
 
@@ -2535,4 +2640,4 @@ interface ITransformer {
2535
2640
  }
2536
2641
 
2537
2642
  export { PathNodeHandleType };
2538
- export type { ACommandData, ArcCommandData, ArcToCommandData, BezierCurveToCommandNode, BezierCurveToCommandObject, CCommandData, CanvasPathCommand, ClosePathCommandNode, EllipseCommandData, HCommandData, IAlign, IAnimateEasing, IAnimateEasingFunction, IAnimateEasingName, IAnimateEnding, IAnimateEvent, IAnimateEventFunction, IAnimateEvents, IAnimateOptions, IAnswer, IAppBase, IAround, IAttrDecorator, IAutoBounds, IAutoBoundsData, IAutoBoxData, IAutoSize, IAxis, IAxisAlign, IAxisReverse, IBaseLineAlign, IBlendMode, IBlob, IBlobFunction, IBoolean, IBooleanMap, IBounds, IBoundsData, IBoundsDataFn, IBoundsDataWithOptionRotation, IBoundsEvent, IBoundsType, IBranch, IBranchRender, IBranchRenderModule, ICachedLeaf, ICanvasAttr, ICanvasCacheOptions, ICanvasContext2D, ICanvasContext2DSettings, ICanvasManager, ICanvasPattern, ICanvasSizeAttr, ICanvasStrokeOptions, ICanvasType, IChildEvent, IClientPointData, IConstraint, IConstraintType, IControl, ICreator, ICubicBezierEasing, ICursorConfig, ICursorRotate, ICursorRotateMap, ICursorType, ICursorTypeMap, ICustomEasingFunction, IDataProcessor, IDataTypeHandle, IDirection, IDirection4, IDragBoundsType, IDragEvent, IDropEvent, IEditSize, IEraserType, IEvent, IEventListener, IEventListenerId, IEventListenerItem, IEventListenerMap, IEventListenerOptions, IEventOption, IEventParams, IEventParamsMap, IEventTarget, IEventer, IExportFileType, IExportImageType, IExportOnCanvasFunction, IExportOptions, IExportResult, IExportResultFunction, IFilter, IFindCondition, IFindMethod, IFinder, IFlowAlign, IFlowAxisAlign, IFlowBoxType, IFlowType, IFlowWrap, IFourNumber, IFromToData, IFunction, IFunctionMap, IGap, IGestureType, IHitCanvas, IHitCanvasConfig, IHitCanvasManager, IHitType, IImageCrossOrigin, IImageCursor, IImageEvent, IImageLOD, IImageManager, IImageTileLOD, IInteraction, IInteractionCanvas, IInteractionConfig, IInterlace, IJSONOptions, IKeepTouchData, IKeyCodes, IKeyEvent, ILayoutAttr, ILayoutBlockData, ILayoutBoundsData, ILayoutChangedData, ILayoutData, ILayoutEvent, ILayouter, ILayouterConfig, ILeaf, ILeafArrayMap, ILeafAttrData, ILeafAttrDescriptor, ILeafAttrDescriptorFn, ILeafBounds, ILeafBoundsModule, ILeafComputedData, ILeafData, ILeafDataOptions, ILeafDataProxy, ILeafDataProxyModule, ILeafEventer, ILeafEventerModule, ILeafHit, ILeafHitModule, ILeafInputData, ILeafLayout, ILeafLevelList, ILeafList, ILeafListItemCallback, ILeafMap, ILeafMatrix, ILeafMatrixModule, ILeafRender, ILeafRenderModule, ILeaferAttrData, ILeaferBase, ILeaferCanvas, ILeaferCanvasConfig, ILeaferCanvasView, ILeaferConfig, ILeaferEvent, ILeaferImage, ILeaferImageCacheCanvas, ILeaferImageConfig, ILeaferImageLevel, ILeaferImageOnError, ILeaferImageOnLoaded, ILeaferImagePatternPaint, ILeaferImageSlice, ILeaferImageSliceData, ILeaferMode, ILeaferType, ILeaferTypeCreator, ILeaferTypeFunction, ILeaferTypeList, ILocationType, IMaskType, IMatrix, IMatrixData, IMatrixWithBoundsData, IMatrixWithBoundsScaleData, IMatrixWithLayoutData, IMatrixWithOptionHalfData, IMatrixWithOptionScaleData, IMatrixWithScaleData, IMiniapp, IMiniappSelect, IMiniappSizeView, IMotionPathData, IMoveConfig, IMoveEvent, IMultiTouchConfig, IMultiTouchData, INumber, INumberFunction, INumberMap, IObject, IObjectFunction, IOffsetBoundsData, IOptionSizeData, IPartLayoutConfig, IPath2D, IPathCommandData, IPathCommandNode, IPathCommandNodeBase, IPathCommandObject, IPathCreator, IPathDrawer, IPathNodeBase, IPathString, IPercentData, IPickBottom, IPickOptions, IPickResult, IPicker, IPlatform, IPlugin, IPoint, IPointData, IPointDataFunction, IPointDataMap, IPointGap, IPointerConfig, IPointerEvent, IProgressData, IProgressFunction, IPropertyEvent, IRadiusPointData, IRangeSize, IRenderEvent, IRenderOptions, IRenderer, IRendererConfig, IResizeEvent, IResizeEventListener, IResource, IRotateEvent, IRotationPointData, IScaleData, IScaleFixed, IScaleRotationData, IScreenSizeData, IScrollPointData, ISelector, ISelectorConfig, ISelectorProxy, IShortcutKeyCodes, IShortcutKeys, IShortcutKeysCheck, ISide, ISingleGestureConfig, ISize, ISizeData, ISkewData, ISkiaCanvas, ISkiaCanvasExportConfig, ISkiaNAPICanvas, IStateStyleType, IStepsEasing, IString, IStringFunction, IStringMap, ISwipeEvent, ITaskItem, ITaskOptions, ITaskProcessor, ITaskProcessorConfig, ITextMetrics, ITimer, ITouchConfig, ITouchEvent, ITransformer, ITransition, ITwoPointBoundsData, IUICreator, IUIEvent, IUnitData, IUnitPointData, IUpdateEvent, IValue, IValueFunction, IWatchEvent, IWatchEventData, IWatcher, IWatcherConfig, IWheelConfig, IWheelEvent, IWindingRule, IWindingRuleData, IZoomConfig, IZoomEvent, IZoomOptions, IZoomType, IZoomView, InnerId, LCommandData, LineToCommandNode, LineToCommandObject, MCommandData, MoveToCommandNode, MoveToCommandObject, PathNodeHandleName, PointerType, QCommandData, QuadraticCurveToCommandObject, RectCommandData, RoundRectCommandData, SCommandData, TCommandData, VCommandData, ZCommandData };
2643
+ export type { ACommandData, ArcCommandData, ArcToCommandData, BezierCurveToCommandNode, BezierCurveToCommandObject, CCommandData, CanvasPathCommand, ClosePathCommandNode, EllipseCommandData, HCommandData, IAlign, IAnimateEasing, IAnimateEasingFunction, IAnimateEasingName, IAnimateEnding, IAnimateEvent, IAnimateEventFunction, IAnimateEvents, IAnimateOptions, IAnswer, IAppBase, IAround, IArrowPathData, IAttrDecorator, IAutoBounds, IAutoBoundsData, IAutoBoxData, IAutoSize, IAxis, IAxisAlign, IAxisReverse, IBaseLineAlign, IBlendMode, IBlob, IBlobFunction, IBoolean, IBooleanMap, IBounds, IBoundsData, IBoundsDataFn, IBoundsDataWithOptionRotation, IBoundsEvent, IBoundsType, IBranch, IBranchRender, IBranchRenderModule, ICachedLeaf, ICanvasAttr, ICanvasCacheOptions, ICanvasContext2D, ICanvasContext2DSettings, ICanvasManager, ICanvasPattern, ICanvasSizeAttr, ICanvasStrokeOptions, ICanvasType, IChildEvent, IClientPointData, IConstraint, IConstraintType, IControl, ICreator, ICubicBezierEasing, ICursorConfig, ICursorRotate, ICursorRotateMap, ICursorType, ICursorTypeMap, ICustomEasingFunction, IDataProcessor, IDataTypeHandle, IDirection, IDirection4, IDragBoundsType, IDragEvent, IDropEvent, IEditSize, IEraserType, IEvent, IEventListener, IEventListenerId, IEventListenerItem, IEventListenerMap, IEventListenerOptions, IEventOption, IEventParams, IEventParamsMap, IEventTarget, IEventer, IExportFileType, IExportImageType, IExportOnCanvasFunction, IExportOptions, IExportResult, IExportResultFunction, IFilmDecoder, IFilmFileType, IFilmFrame, IFilmOptions, IFilmPlayOptions, IFilter, IFindCondition, IFindMethod, IFinder, IFlowAlign, IFlowAxisAlign, IFlowBoxType, IFlowType, IFlowWrap, IFourNumber, IFromToData, IFunction, IFunctionMap, IGap, IGestureType, IHitCanvas, IHitCanvasConfig, IHitCanvasManager, IHitType, IImageCrossOrigin, IImageCursor, IImageEvent, IImageLOD, IImageManager, IImageTileLOD, IInteraction, IInteractionCanvas, IInteractionConfig, IInterlace, IJSONOptions, IKeepTouchData, IKeyCodes, IKeyEvent, ILayoutAttr, ILayoutBlockData, ILayoutBoundsData, ILayoutChangedData, ILayoutData, ILayoutEvent, ILayouter, ILayouterConfig, ILeaf, ILeafArrayMap, ILeafAttrData, ILeafAttrDescriptor, ILeafAttrDescriptorFn, ILeafBounds, ILeafBoundsModule, ILeafComplexCachedData, ILeafComputedData, ILeafData, ILeafDataOptions, ILeafDataProxy, ILeafDataProxyModule, ILeafEventer, ILeafEventerModule, ILeafHit, ILeafHitModule, ILeafInputData, ILeafLayout, ILeafLevelList, ILeafList, ILeafListItemCallback, ILeafMap, ILeafMatrix, ILeafMatrixModule, ILeafRender, ILeafRenderModule, ILeaferAttrData, ILeaferBase, ILeaferCanvas, ILeaferCanvasConfig, ILeaferCanvasView, ILeaferConfig, ILeaferEvent, ILeaferFilm, ILeaferFilmConfig, ILeaferImage, ILeaferImageCacheCanvas, ILeaferImageConfig, ILeaferImageLevel, ILeaferImageMap, ILeaferImageOnError, ILeaferImageOnLoaded, ILeaferImagePatternPaint, ILeaferImageSlice, ILeaferImageSliceData, ILeaferMode, ILeaferType, ILeaferTypeCreator, ILeaferTypeFunction, ILeaferTypeList, ILeaferVideo, ILeaferVideoConfig, ILocationType, IMaskType, IMatrix, IMatrixData, IMatrixWithBoundsData, IMatrixWithBoundsScaleData, IMatrixWithLayoutData, IMatrixWithOptionHalfData, IMatrixWithOptionScaleData, IMatrixWithScaleData, IMiniapp, IMiniappSelect, IMiniappSizeView, IMotionPathData, IMoveConfig, IMoveEvent, IMultiTouchConfig, IMultiTouchData, IMultimediaType, INumber, INumberFunction, INumberMap, IObject, IObjectFunction, IOffsetBoundsData, IOptionPointData, IOptionSizeData, IPartLayoutConfig, IPath2D, IPathCommandData, IPathCommandNode, IPathCommandNodeBase, IPathCommandObject, IPathCreator, IPathDrawer, IPathNodeBase, IPathString, IPercentData, IPickBottom, IPickOptions, IPickResult, IPicker, IPlatform, IPlugin, IPoint, IPointData, IPointDataFunction, IPointDataMap, IPointGap, IPointerConfig, IPointerEvent, IProgressData, IProgressFunction, IPropertyEvent, IRadiusPointData, IRangeSize, IRenderEvent, IRenderOptions, IRenderer, IRendererConfig, IResizeEvent, IResizeEventListener, IResource, IResponseType, IRotateEvent, IRotationPointData, IScaleData, IScaleFixed, IScaleRotationData, IScreenSizeData, IScrollPointData, ISelector, ISelectorConfig, ISelectorProxy, IShortcutKeyCodes, IShortcutKeys, IShortcutKeysCheck, ISide, ISingleGestureConfig, ISize, ISizeData, ISkewData, ISkiaCanvas, ISkiaCanvasExportConfig, ISkiaNAPICanvas, IStateStyleType, IStepsEasing, IString, IStringFunction, IStringMap, ISwipeEvent, ITaskItem, ITaskOptions, ITaskProcessor, ITaskProcessorConfig, ITextMetrics, ITimer, ITouchConfig, ITouchEvent, ITransformer, ITransition, ITwoPointBoundsData, IUICreator, IUIEvent, IUnitData, IUnitPointData, IUpdateEvent, IValue, IValueFunction, IVideoFileType, IWatchEvent, IWatchEventData, IWatcher, IWatcherConfig, IWheelConfig, IWheelEvent, IWindingRule, IWindingRuleData, IZoomConfig, IZoomEvent, IZoomOptions, IZoomType, IZoomView, InnerId, LCommandData, LineToCommandNode, LineToCommandObject, MCommandData, MoveToCommandNode, MoveToCommandObject, PathNodeHandleName, PointerType, QCommandData, QuadraticCurveToCommandObject, RectCommandData, RoundRectCommandData, SCommandData, TCommandData, VCommandData, ZCommandData };