@leafer-ui/core 1.0.0-rc.9 → 1.0.1

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/dist/core.cjs DELETED
@@ -1,2015 +0,0 @@
1
- 'use strict';
2
-
3
- var core = require('@leafer/core');
4
-
5
- /******************************************************************************
6
- Copyright (c) Microsoft Corporation.
7
-
8
- Permission to use, copy, modify, and/or distribute this software for any
9
- purpose with or without fee is hereby granted.
10
-
11
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
12
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
13
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
14
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
16
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17
- PERFORMANCE OF THIS SOFTWARE.
18
- ***************************************************************************** */
19
- /* global Reflect, Promise, SuppressedError, Symbol */
20
-
21
-
22
- function __decorate(decorators, target, key, desc) {
23
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
24
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
25
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
26
- return c > 3 && r && Object.defineProperty(target, key, r), r;
27
- }
28
-
29
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
30
- var e = new Error(message);
31
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
32
- };
33
-
34
- function draw(leafer) {
35
- const { config } = leafer;
36
- config.move.dragOut = false;
37
- }
38
-
39
- function design(leafer) {
40
- if (leafer.isApp)
41
- return;
42
- leafer.__eventIds.push(leafer.on_(core.MoveEvent.BEFORE_MOVE, (e) => { core.LeafHelper.moveWorld(leafer.zoomLayer, e.moveX, e.moveY); }), leafer.on_(core.ZoomEvent.BEFORE_ZOOM, (e) => {
43
- const { scaleX } = leafer.zoomLayer.__, { min, max } = leafer.app.config.zoom;
44
- let { scale } = e;
45
- if (scale * Math.abs(scaleX) < min)
46
- scale = min / scaleX;
47
- else if (scale * Math.abs(scaleX) > max)
48
- scale = max / scaleX;
49
- if (scale !== 1)
50
- core.LeafHelper.zoomOfWorld(leafer.zoomLayer, e, scale);
51
- }));
52
- }
53
-
54
- const debug$2 = core.Debug.get('LeaferTypeCreator');
55
- const LeaferTypeCreator = {
56
- list: {},
57
- register(name, fn) {
58
- if (list[name]) {
59
- debug$2.repeat(name);
60
- }
61
- else {
62
- list[name] = fn;
63
- }
64
- },
65
- run(name, leafer) {
66
- const fn = LeaferTypeCreator.list[name];
67
- if (fn) {
68
- fn(leafer);
69
- }
70
- else {
71
- debug$2.error('no', name);
72
- }
73
- }
74
- };
75
- const { list } = LeaferTypeCreator;
76
- LeaferTypeCreator.register('draw', draw);
77
- LeaferTypeCreator.register('user', draw);
78
- LeaferTypeCreator.register('design', design);
79
-
80
- const Effect = {};
81
- const Paint = {};
82
- const Animate = {};
83
- const TextConvert = {};
84
- const ColorConvert = {};
85
- const Export = {};
86
-
87
- const emptyPaint = {};
88
- const debug$1 = core.Debug.get('UIData');
89
- class UIData extends core.LeafData {
90
- get __autoWidth() { return !this._width; }
91
- get __autoHeight() { return !this._height; }
92
- get __autoBounds() { return !this._width && !this._height; }
93
- setVisible(value) {
94
- if (this.__leaf.leafer)
95
- this.__leaf.leafer.watcher.hasVisible = true;
96
- this._visible = value;
97
- }
98
- setWidth(value) {
99
- if (value < 0) {
100
- this._width = -value;
101
- this.__leaf.scaleX *= -1;
102
- debug$1.warn('width < 0, instead -scaleX ', this);
103
- }
104
- else {
105
- this._width = value;
106
- }
107
- }
108
- setHeight(value) {
109
- if (value < 0) {
110
- this._height = -value;
111
- this.__leaf.scaleY *= -1;
112
- debug$1.warn('height < 0, instead -scaleY', this);
113
- }
114
- else {
115
- this._height = value;
116
- }
117
- }
118
- setFill(value) {
119
- if (this.__naturalWidth)
120
- this.__naturalWidth = this.__naturalHeight = undefined;
121
- if (typeof value === 'string' || !value) {
122
- if (this.__isFills) {
123
- this.__removeInput('fill');
124
- Paint.recycleImage('fill', this);
125
- this.__isFills = false;
126
- if (this.__pixelFill)
127
- this.__pixelFill = false;
128
- }
129
- this._fill = value;
130
- }
131
- else if (typeof value === 'object') {
132
- this.__setInput('fill', value);
133
- this.__leaf.__layout.boxChanged || this.__leaf.__layout.boxChange();
134
- this.__isFills = true;
135
- this._fill || (this._fill = emptyPaint);
136
- }
137
- }
138
- setStroke(value) {
139
- if (typeof value === 'string' || !value) {
140
- if (this.__isStrokes) {
141
- this.__removeInput('stroke');
142
- Paint.recycleImage('stroke', this);
143
- this.__isStrokes = false;
144
- if (this.__pixelStroke)
145
- this.__pixelStroke = false;
146
- }
147
- this._stroke = value;
148
- }
149
- else if (typeof value === 'object') {
150
- this.__setInput('stroke', value);
151
- this.__leaf.__layout.boxChanged || this.__leaf.__layout.boxChange();
152
- this.__isStrokes = true;
153
- this._stroke || (this._stroke = emptyPaint);
154
- }
155
- }
156
- setShadow(value) {
157
- this.__setInput('shadow', value);
158
- if (value instanceof Array) {
159
- if (value.some((item) => item.visible === false))
160
- value = value.filter((item) => item.visible !== false);
161
- this._shadow = value.length ? value : null;
162
- }
163
- else if (value) {
164
- this._shadow = value.visible === false ? null : [value];
165
- }
166
- else {
167
- this._shadow = null;
168
- }
169
- }
170
- setInnerShadow(value) {
171
- this.__setInput('innerShadow', value);
172
- if (value instanceof Array) {
173
- if (value.some((item) => item.visible === false))
174
- value = value.filter((item) => item.visible !== false);
175
- this._innerShadow = value.length ? value : null;
176
- }
177
- else if (value) {
178
- this._innerShadow = value.visible === false ? null : [value];
179
- }
180
- else {
181
- this._innerShadow = null;
182
- }
183
- }
184
- }
185
- const UnitConvert = {
186
- number(value, percentRefer) {
187
- if (typeof value === 'object')
188
- return value.type === 'percent' ? value.value / 100 * percentRefer : value.value;
189
- return value;
190
- }
191
- };
192
-
193
- class GroupData extends UIData {
194
- }
195
-
196
- class BoxData extends GroupData {
197
- get __boxStroke() { return true; }
198
- }
199
-
200
- class LeaferData extends GroupData {
201
- }
202
-
203
- class FrameData extends BoxData {
204
- }
205
-
206
- class LineData extends UIData {
207
- }
208
-
209
- class ArrowData extends LineData {
210
- }
211
-
212
- class RectData extends UIData {
213
- get __boxStroke() { return true; }
214
- }
215
-
216
- class EllipseData extends UIData {
217
- get __boxStroke() { return true; }
218
- }
219
-
220
- class PolygonData extends UIData {
221
- }
222
-
223
- class StarData extends UIData {
224
- }
225
-
226
- const { parse } = core.PathConvert;
227
- class PathData extends UIData {
228
- setPath(value) {
229
- if (typeof value === 'string') {
230
- this.__setInput('path', value);
231
- this._path = parse(value);
232
- }
233
- else {
234
- if (this.__input)
235
- this.__removeInput('path');
236
- this._path = value;
237
- }
238
- }
239
- }
240
-
241
- class PenData extends GroupData {
242
- }
243
-
244
- const fontWeightMap = {
245
- 'thin': 100,
246
- 'extra-light': 200,
247
- 'light': 300,
248
- 'normal': 400,
249
- 'medium': 500,
250
- 'semi-bold': 600,
251
- 'bold': 700,
252
- 'extra-bold': 800,
253
- 'black': 900
254
- };
255
- class TextData extends UIData {
256
- setFontWeight(value) {
257
- if (typeof value === 'string') {
258
- this.__setInput('fontWeight', value);
259
- this._fontWeight = fontWeightMap[value] || 400;
260
- }
261
- else {
262
- if (this.__input)
263
- this.__removeInput('fontWeight');
264
- this._fontWeight = value;
265
- }
266
- }
267
- }
268
-
269
- class ImageData extends RectData {
270
- setUrl(value) {
271
- this.__setImageFill(value);
272
- this._url = value;
273
- }
274
- __setImageFill(value) {
275
- if (this.__leaf.image)
276
- this.__leaf.image = null;
277
- this.fill = value ? { type: 'image', mode: 'strench', url: value } : undefined;
278
- }
279
- __getData() {
280
- const data = super.__getData();
281
- delete data.fill;
282
- return data;
283
- }
284
- __getInputData() {
285
- const data = super.__getInputData();
286
- delete data.fill;
287
- return data;
288
- }
289
- }
290
-
291
- class CanvasData extends RectData {
292
- }
293
-
294
- function effectType(defaultValue) {
295
- return (target, key) => {
296
- core.defineLeafAttr(target, key, defaultValue, {
297
- set(value) {
298
- this.__setAttr(key, value);
299
- if (value)
300
- this.__.__useEffect = true;
301
- this.__layout.renderChanged || this.__layout.renderChange();
302
- }
303
- });
304
- };
305
- }
306
- function resizeType(defaultValue) {
307
- return (target, key) => {
308
- core.defineLeafAttr(target, key, defaultValue, {
309
- set(value) {
310
- this.__setAttr(key, value);
311
- this.__layout.boxChanged || this.__layout.boxChange();
312
- this.__updateSize();
313
- }
314
- });
315
- };
316
- }
317
-
318
- const UIBounds = {
319
- __updateStrokeSpread() {
320
- let width = 0, boxWidth = 0;
321
- const { stroke, hitStroke, strokeAlign, strokeWidth } = this.__;
322
- if ((stroke || hitStroke === 'all') && strokeWidth && strokeAlign !== 'inside') {
323
- boxWidth = width = strokeAlign === 'center' ? strokeWidth / 2 : strokeWidth;
324
- if (!this.__.__boxStroke) {
325
- const { miterLimit, strokeCap } = this.__;
326
- const miterLimitAddWidth = this.__tag !== 'Line' ? 1 / Math.sin(miterLimit * core.OneRadian / 2) * Math.sqrt(strokeWidth) - width : 0;
327
- const storkeCapAddWidth = strokeCap === 'none' ? 0 : strokeWidth;
328
- width += Math.max(miterLimitAddWidth, storkeCapAddWidth);
329
- }
330
- }
331
- this.__layout.strokeBoxSpread = boxWidth;
332
- return width;
333
- },
334
- __updateRenderSpread() {
335
- let width = 0;
336
- const { shadow, innerShadow, blur, backgroundBlur } = this.__;
337
- if (shadow)
338
- shadow.forEach(item => {
339
- width = Math.max(width, Math.max(Math.abs(item.y), Math.abs(item.x)) + (item.spread > 0 ? item.spread : 0) + item.blur * 1.5);
340
- });
341
- if (blur)
342
- width = Math.max(width, blur);
343
- let shapeWidth = width = Math.ceil(width);
344
- if (innerShadow)
345
- innerShadow.forEach(item => {
346
- shapeWidth = Math.max(shapeWidth, Math.max(Math.abs(item.y), Math.abs(item.x)) + (item.spread < 0 ? -item.spread : 0) + item.blur * 1.5);
347
- });
348
- if (backgroundBlur)
349
- shapeWidth = Math.max(shapeWidth, backgroundBlur);
350
- this.__layout.renderShapeSpread = shapeWidth;
351
- return width;
352
- }
353
- };
354
-
355
- const UIHit = {
356
- __updateHitCanvas() {
357
- if (!this.__hitCanvas)
358
- this.__hitCanvas = this.leafer.hitCanvasManager.getPathType(this);
359
- const h = this.__hitCanvas;
360
- this.__drawHitPath(h);
361
- h.setStrokeOptions(this.__);
362
- },
363
- __hit(inner) {
364
- const { __hitCanvas: h } = this;
365
- if (core.Platform.name === 'miniapp')
366
- this.__drawHitPath(h);
367
- const { fill, hitFill, windingRule } = this.__;
368
- const needHitFill = (fill && hitFill === 'path') || hitFill === 'all';
369
- const isHitFill = h.hitFill(inner, windingRule);
370
- if (needHitFill && isHitFill)
371
- return true;
372
- const { stroke, hitStroke, strokeWidth, strokeAlign } = this.__;
373
- const needHitStroke = (stroke && hitStroke === 'path') || hitStroke === 'all';
374
- const radiusWidth = inner.radiusX * 2;
375
- let hitWidth = radiusWidth;
376
- if (needHitStroke) {
377
- switch (strokeAlign) {
378
- case 'inside':
379
- hitWidth += strokeWidth * 2;
380
- if (!needHitFill && (isHitFill && h.hitStroke(inner, hitWidth)))
381
- return true;
382
- hitWidth = radiusWidth;
383
- break;
384
- case 'center':
385
- hitWidth += strokeWidth;
386
- break;
387
- case 'outside':
388
- hitWidth += strokeWidth * 2;
389
- if (!needHitFill) {
390
- if (!isHitFill && h.hitStroke(inner, hitWidth))
391
- return true;
392
- hitWidth = radiusWidth;
393
- }
394
- break;
395
- }
396
- }
397
- return hitWidth ? h.hitStroke(inner, hitWidth) : false;
398
- }
399
- };
400
-
401
- const UIRender = {
402
- __updateChange() {
403
- const data = this.__;
404
- if (data.__useEffect) {
405
- const { shadow, innerShadow, blur, backgroundBlur } = this.__;
406
- data.__useEffect = !!(shadow || innerShadow || blur || backgroundBlur);
407
- }
408
- data.__checkSingle();
409
- const complex = data.__isFills || data.__isStrokes || data.cornerRadius || data.__useEffect;
410
- if (complex) {
411
- data.__complex = true;
412
- }
413
- else {
414
- data.__complex && (data.__complex = false);
415
- }
416
- },
417
- __drawFast(canvas, options) {
418
- const { fill, stroke, __drawAfterFill } = this.__;
419
- this.__drawRenderPath(canvas);
420
- if (fill)
421
- Paint.fill(fill, this, canvas);
422
- if (__drawAfterFill)
423
- this.__drawAfterFill(canvas, options);
424
- if (stroke)
425
- Paint.stroke(stroke, this, canvas, options);
426
- },
427
- __draw(canvas, options) {
428
- if (this.__.__complex) {
429
- const { fill, stroke, __drawAfterFill } = this.__;
430
- this.__drawRenderPath(canvas);
431
- if (this.__.__useEffect) {
432
- const shape = Paint.shape(this, canvas, options);
433
- const { shadow, innerShadow } = this.__;
434
- if (shadow)
435
- Effect.shadow(this, canvas, shape, options);
436
- if (fill)
437
- this.__.__isFills ? Paint.fills(fill, this, canvas) : Paint.fill(fill, this, canvas);
438
- if (__drawAfterFill)
439
- this.__drawAfterFill(canvas, options);
440
- if (innerShadow)
441
- Effect.innerShadow(this, canvas, shape, options);
442
- if (stroke)
443
- this.__.__isStrokes ? Paint.strokes(stroke, this, canvas, options) : Paint.stroke(stroke, this, canvas, options);
444
- if (shape.worldCanvas)
445
- shape.worldCanvas.recycle();
446
- shape.canvas.recycle();
447
- }
448
- else {
449
- if (fill)
450
- this.__.__isFills ? Paint.fills(fill, this, canvas) : Paint.fill(fill, this, canvas);
451
- if (__drawAfterFill)
452
- this.__drawAfterFill(canvas, options);
453
- if (stroke)
454
- this.__.__isStrokes ? Paint.strokes(stroke, this, canvas, options) : Paint.stroke(stroke, this, canvas, options);
455
- }
456
- }
457
- else {
458
- this.__drawFast(canvas, options);
459
- }
460
- },
461
- __renderShape(canvas, renderOptions) {
462
- if (!this.__worldOpacity)
463
- return;
464
- canvas.setWorld(this.__world, renderOptions.matrix);
465
- const { fill, stroke } = this.__;
466
- this.__drawRenderPath(canvas);
467
- if (fill)
468
- this.__.__pixelFill ? Paint.fills(fill, this, canvas) : Paint.fill('#000000', this, canvas);
469
- if (stroke)
470
- this.__.__pixelStroke ? Paint.strokes(stroke, this, canvas, renderOptions) : Paint.stroke('#000000', this, canvas, renderOptions);
471
- }
472
- };
473
-
474
- const RectRender = {
475
- __drawFast(canvas, options) {
476
- const { width, height, fill, stroke, __drawAfterFill } = this.__;
477
- if (fill) {
478
- canvas.fillStyle = fill;
479
- canvas.fillRect(0, 0, width, height);
480
- }
481
- if (__drawAfterFill)
482
- this.__drawAfterFill(canvas, options);
483
- if (stroke) {
484
- const { strokeAlign, strokeWidth } = this.__;
485
- canvas.setStroke(stroke, strokeWidth, this.__);
486
- const half = strokeWidth / 2;
487
- switch (strokeAlign) {
488
- case 'center':
489
- canvas.strokeRect(0, 0, width, height);
490
- break;
491
- case 'inside':
492
- canvas.strokeRect(half, half, width - strokeWidth, height - strokeWidth);
493
- break;
494
- case 'outside':
495
- canvas.strokeRect(-half, -half, width + strokeWidth, height + strokeWidth);
496
- break;
497
- }
498
- }
499
- }
500
- };
501
-
502
- var UI_1;
503
- exports.UI = UI_1 = class UI extends core.Leaf {
504
- get app() { return this.leafer && this.leafer.app; }
505
- set scale(value) {
506
- if (typeof value === 'number') {
507
- this.scaleX = this.scaleY = value;
508
- }
509
- else {
510
- this.scaleX = value.x;
511
- this.scaleY = value.y;
512
- }
513
- }
514
- get scale() {
515
- const { scaleX, scaleY } = this;
516
- return scaleX !== scaleY ? { x: scaleX, y: scaleY } : scaleX;
517
- }
518
- constructor(data) {
519
- super(data);
520
- }
521
- reset(_data) { }
522
- set(data) {
523
- Object.assign(this, data);
524
- }
525
- get() {
526
- return this.__.__getInputData();
527
- }
528
- createProxyData() { return undefined; }
529
- find(condition, options) {
530
- return this.leafer ? this.leafer.selector.getBy(condition, this, false, options) : [];
531
- }
532
- findOne(condition, options) {
533
- return this.leafer ? this.leafer.selector.getBy(condition, this, true, options) : null;
534
- }
535
- getPath(curve, pathForRender) {
536
- this.__layout.update();
537
- let path = pathForRender ? this.__.__pathForRender : this.__.path;
538
- if (!path)
539
- this.__drawPathByBox(new core.PathCreator(path = []));
540
- return curve ? core.PathConvert.toCanvasData(path, true) : path;
541
- }
542
- getPathString(curve, pathForRender) {
543
- return core.PathConvert.stringify(this.getPath(curve, pathForRender));
544
- }
545
- __onUpdateSize() {
546
- if (this.__.__input) {
547
- const { fill, stroke } = this.__.__input;
548
- if (fill)
549
- Paint.compute('fill', this);
550
- if (stroke)
551
- Paint.compute('stroke', this);
552
- }
553
- }
554
- __updateRenderPath() {
555
- if (this.__.path) {
556
- const { __: data } = this;
557
- data.__pathForRender = data.cornerRadius ? core.PathCorner.smooth(data.path, data.cornerRadius, data.cornerSmoothing) : data.path;
558
- }
559
- }
560
- __drawRenderPath(canvas) {
561
- canvas.beginPath();
562
- this.__drawPathByData(canvas, this.__.__pathForRender);
563
- }
564
- __drawPath(canvas) {
565
- canvas.beginPath();
566
- this.__drawPathByData(canvas, this.__.path);
567
- }
568
- __drawPathByData(_drawer, _data) { }
569
- __drawPathByBox(drawer) {
570
- const { x, y, width, height } = this.__layout.boxBounds;
571
- if (this.__.cornerRadius) {
572
- drawer.roundRect(x, y, width, height, this.__.cornerRadius);
573
- }
574
- else {
575
- drawer.rect(x, y, width, height);
576
- }
577
- }
578
- export(filename, options) {
579
- return Export.export(this, filename, options);
580
- }
581
- clone() {
582
- return UI_1.one(this.toJSON());
583
- }
584
- static one(data, x, y, width, height) {
585
- return core.UICreator.get(data.tag || this.prototype.__tag, data, x, y, width, height);
586
- }
587
- destroy() {
588
- this.fill = this.stroke = null;
589
- super.destroy();
590
- }
591
- };
592
- __decorate([
593
- core.dataProcessor(UIData)
594
- ], exports.UI.prototype, "__", void 0);
595
- __decorate([
596
- core.dataType('')
597
- ], exports.UI.prototype, "id", void 0);
598
- __decorate([
599
- core.dataType('')
600
- ], exports.UI.prototype, "name", void 0);
601
- __decorate([
602
- core.dataType('')
603
- ], exports.UI.prototype, "className", void 0);
604
- __decorate([
605
- core.surfaceType('pass-through')
606
- ], exports.UI.prototype, "blendMode", void 0);
607
- __decorate([
608
- core.opacityType(1)
609
- ], exports.UI.prototype, "opacity", void 0);
610
- __decorate([
611
- core.opacityType(true)
612
- ], exports.UI.prototype, "visible", void 0);
613
- __decorate([
614
- core.maskType(false)
615
- ], exports.UI.prototype, "isMask", void 0);
616
- __decorate([
617
- core.eraserType(false)
618
- ], exports.UI.prototype, "isEraser", void 0);
619
- __decorate([
620
- core.dataType(false)
621
- ], exports.UI.prototype, "locked", void 0);
622
- __decorate([
623
- core.sortType(0)
624
- ], exports.UI.prototype, "zIndex", void 0);
625
- __decorate([
626
- core.positionType(0)
627
- ], exports.UI.prototype, "x", void 0);
628
- __decorate([
629
- core.positionType(0)
630
- ], exports.UI.prototype, "y", void 0);
631
- __decorate([
632
- core.boundsType(100)
633
- ], exports.UI.prototype, "width", void 0);
634
- __decorate([
635
- core.boundsType(100)
636
- ], exports.UI.prototype, "height", void 0);
637
- __decorate([
638
- core.scaleType(1)
639
- ], exports.UI.prototype, "scaleX", void 0);
640
- __decorate([
641
- core.scaleType(1)
642
- ], exports.UI.prototype, "scaleY", void 0);
643
- __decorate([
644
- core.rotationType(0)
645
- ], exports.UI.prototype, "rotation", void 0);
646
- __decorate([
647
- core.rotationType(0)
648
- ], exports.UI.prototype, "skewX", void 0);
649
- __decorate([
650
- core.rotationType(0)
651
- ], exports.UI.prototype, "skewY", void 0);
652
- __decorate([
653
- core.autoLayoutType()
654
- ], exports.UI.prototype, "around", void 0);
655
- __decorate([
656
- core.dataType(false)
657
- ], exports.UI.prototype, "draggable", void 0);
658
- __decorate([
659
- core.dataType(false)
660
- ], exports.UI.prototype, "editable", void 0);
661
- __decorate([
662
- core.dataType('size')
663
- ], exports.UI.prototype, "editSize", void 0);
664
- __decorate([
665
- core.hitType(true)
666
- ], exports.UI.prototype, "hittable", void 0);
667
- __decorate([
668
- core.hitType('path')
669
- ], exports.UI.prototype, "hitFill", void 0);
670
- __decorate([
671
- core.strokeType('path')
672
- ], exports.UI.prototype, "hitStroke", void 0);
673
- __decorate([
674
- core.hitType(false)
675
- ], exports.UI.prototype, "hitBox", void 0);
676
- __decorate([
677
- core.hitType(true)
678
- ], exports.UI.prototype, "hitChildren", void 0);
679
- __decorate([
680
- core.hitType(true)
681
- ], exports.UI.prototype, "hitSelf", void 0);
682
- __decorate([
683
- core.hitType()
684
- ], exports.UI.prototype, "hitRadius", void 0);
685
- __decorate([
686
- core.cursorType('')
687
- ], exports.UI.prototype, "cursor", void 0);
688
- __decorate([
689
- core.surfaceType()
690
- ], exports.UI.prototype, "fill", void 0);
691
- __decorate([
692
- core.strokeType()
693
- ], exports.UI.prototype, "stroke", void 0);
694
- __decorate([
695
- core.strokeType('inside')
696
- ], exports.UI.prototype, "strokeAlign", void 0);
697
- __decorate([
698
- core.strokeType(1)
699
- ], exports.UI.prototype, "strokeWidth", void 0);
700
- __decorate([
701
- core.strokeType('none')
702
- ], exports.UI.prototype, "strokeCap", void 0);
703
- __decorate([
704
- core.strokeType('miter')
705
- ], exports.UI.prototype, "strokeJoin", void 0);
706
- __decorate([
707
- core.strokeType()
708
- ], exports.UI.prototype, "dashPattern", void 0);
709
- __decorate([
710
- core.strokeType()
711
- ], exports.UI.prototype, "dashOffset", void 0);
712
- __decorate([
713
- core.strokeType(10)
714
- ], exports.UI.prototype, "miterLimit", void 0);
715
- __decorate([
716
- core.strokeType('none')
717
- ], exports.UI.prototype, "startArrow", void 0);
718
- __decorate([
719
- core.strokeType('none')
720
- ], exports.UI.prototype, "endArrow", void 0);
721
- __decorate([
722
- core.pathType(0)
723
- ], exports.UI.prototype, "cornerRadius", void 0);
724
- __decorate([
725
- core.pathType()
726
- ], exports.UI.prototype, "cornerSmoothing", void 0);
727
- __decorate([
728
- effectType()
729
- ], exports.UI.prototype, "shadow", void 0);
730
- __decorate([
731
- effectType()
732
- ], exports.UI.prototype, "innerShadow", void 0);
733
- __decorate([
734
- effectType()
735
- ], exports.UI.prototype, "blur", void 0);
736
- __decorate([
737
- effectType()
738
- ], exports.UI.prototype, "backgroundBlur", void 0);
739
- __decorate([
740
- effectType()
741
- ], exports.UI.prototype, "grayscale", void 0);
742
- __decorate([
743
- core.rewrite(core.Leaf.prototype.reset)
744
- ], exports.UI.prototype, "reset", null);
745
- __decorate([
746
- core.rewrite(core.PathDrawer.drawPathByData)
747
- ], exports.UI.prototype, "__drawPathByData", null);
748
- exports.UI = UI_1 = __decorate([
749
- core.useModule(UIBounds),
750
- core.useModule(UIHit),
751
- core.useModule(UIRender),
752
- core.rewriteAble()
753
- ], exports.UI);
754
-
755
- const matrix = core.MatrixHelper.get();
756
- exports.Group = class Group extends exports.UI {
757
- get __tag() { return 'Group'; }
758
- set mask(child) {
759
- if (this.__hasMask)
760
- this.__removeMask();
761
- if (child) {
762
- child.isMask = true;
763
- this.addAt(child, 0);
764
- }
765
- }
766
- get mask() {
767
- return this.children.find(item => item.isMask);
768
- }
769
- constructor(data) {
770
- super(data);
771
- this.__setBranch();
772
- }
773
- __setBranch() {
774
- this.isBranch = true;
775
- if (!this.children)
776
- this.children = [];
777
- }
778
- set(data) {
779
- if (data.children) {
780
- const { children } = data;
781
- delete data.children;
782
- if (!this.children) {
783
- this.__setBranch();
784
- }
785
- else {
786
- this.removeAll(true);
787
- }
788
- super.set(data);
789
- let child;
790
- children.forEach(childData => {
791
- child = core.UICreator.get(childData.tag, childData);
792
- this.add(child);
793
- });
794
- data.children = children;
795
- }
796
- else {
797
- super.set(data);
798
- }
799
- }
800
- toJSON() {
801
- const data = super.toJSON();
802
- data.children = this.children.map(child => child.toJSON());
803
- return data;
804
- }
805
- __scaleResize(scaleX, scaleY) {
806
- const { children } = this;
807
- for (let i = 0; i < children.length; i++) {
808
- matrix.a = scaleX;
809
- matrix.d = scaleY;
810
- children[i].transform(matrix, true);
811
- }
812
- }
813
- addAt(child, index) {
814
- this.add(child, index);
815
- }
816
- addAfter(child, after) {
817
- this.add(child, this.children.indexOf(after) + 1);
818
- }
819
- addBefore(child, before) {
820
- this.add(child, this.children.indexOf(before));
821
- }
822
- add(_child, _index) { }
823
- addMany(..._children) { }
824
- remove(_child, _destroy) { }
825
- removeAll(_destroy) { }
826
- };
827
- __decorate([
828
- core.dataProcessor(GroupData)
829
- ], exports.Group.prototype, "__", void 0);
830
- exports.Group = __decorate([
831
- core.useModule(core.Branch),
832
- core.registerUI()
833
- ], exports.Group);
834
-
835
- exports.Rect = class Rect extends exports.UI {
836
- get __tag() { return 'Rect'; }
837
- constructor(data) {
838
- super(data);
839
- }
840
- __drawPathByData(_drawer, _data) { }
841
- };
842
- __decorate([
843
- core.dataProcessor(RectData)
844
- ], exports.Rect.prototype, "__", void 0);
845
- __decorate([
846
- core.rewrite(exports.UI.prototype.__drawPathByBox)
847
- ], exports.Rect.prototype, "__drawPathByData", null);
848
- exports.Rect = __decorate([
849
- core.useModule(RectRender),
850
- core.rewriteAble(),
851
- core.registerUI()
852
- ], exports.Rect);
853
-
854
- const rect = exports.Rect.prototype;
855
- const group = exports.Group.prototype;
856
- const bounds = {};
857
- const { copy, add } = core.BoundsHelper;
858
- exports.Box = class Box extends exports.Group {
859
- get __tag() { return 'Box'; }
860
- constructor(data) {
861
- super(data);
862
- this.isBranchLeaf = true;
863
- this.__layout.renderChanged || this.__layout.renderChange();
864
- }
865
- __scaleResize(scaleX, scaleY) {
866
- if (this.__.__autoBounds && this.children.length) {
867
- super.__scaleResize(scaleX, scaleY);
868
- }
869
- else {
870
- this.width *= scaleX;
871
- this.height *= scaleY;
872
- }
873
- }
874
- __updateStrokeSpread() { return 0; }
875
- __updateRectRenderSpread() { return 0; }
876
- __updateRenderSpread() {
877
- let width = this.__updateRectRenderSpread() || super.__updateRenderSpread();
878
- this.__.__drawAfterFill = this.__.overflow === 'hide';
879
- if (!width)
880
- width = this.__.__drawAfterFill ? 0 : 1;
881
- return width;
882
- }
883
- __updateRectBoxBounds() { }
884
- __updateBoxBounds() {
885
- if (this.__.__autoBounds && this.children.length) {
886
- super.__updateBoxBounds();
887
- }
888
- else {
889
- this.__updateRectBoxBounds();
890
- }
891
- }
892
- __updateStrokeBounds() { }
893
- __updateRenderBounds() {
894
- this.__updateRectRenderBounds();
895
- if (!this.__.__drawAfterFill) {
896
- const { renderBounds } = this.__layout;
897
- copy(bounds, renderBounds);
898
- super.__updateRenderBounds();
899
- add(renderBounds, bounds);
900
- }
901
- }
902
- __updateRectRenderBounds() { }
903
- __updateRectChange() { }
904
- __updateChange() {
905
- super.__updateChange();
906
- this.__updateRectChange();
907
- }
908
- __drawPathByData(_drawer, _data) { }
909
- __renderRect(_canvas, _options) { }
910
- __renderGroup(_canvas, _options) { }
911
- __render(canvas, options) {
912
- if (this.__.__drawAfterFill) {
913
- this.__renderRect(canvas, options);
914
- }
915
- else {
916
- this.__renderRect(canvas, options);
917
- this.__renderGroup(canvas, options);
918
- }
919
- }
920
- __drawAfterFill(canvas, options) {
921
- canvas.save();
922
- canvas.clip();
923
- this.__renderGroup(canvas, options);
924
- canvas.restore();
925
- if (this.__.stroke)
926
- this.__drawRenderPath(canvas);
927
- }
928
- };
929
- __decorate([
930
- core.dataProcessor(BoxData)
931
- ], exports.Box.prototype, "__", void 0);
932
- __decorate([
933
- core.affectRenderBoundsType('show')
934
- ], exports.Box.prototype, "overflow", void 0);
935
- __decorate([
936
- core.rewrite(rect.__updateStrokeSpread)
937
- ], exports.Box.prototype, "__updateStrokeSpread", null);
938
- __decorate([
939
- core.rewrite(rect.__updateRenderSpread)
940
- ], exports.Box.prototype, "__updateRectRenderSpread", null);
941
- __decorate([
942
- core.rewrite(rect.__updateBoxBounds)
943
- ], exports.Box.prototype, "__updateRectBoxBounds", null);
944
- __decorate([
945
- core.rewrite(rect.__updateStrokeBounds)
946
- ], exports.Box.prototype, "__updateStrokeBounds", null);
947
- __decorate([
948
- core.rewrite(rect.__updateRenderBounds)
949
- ], exports.Box.prototype, "__updateRectRenderBounds", null);
950
- __decorate([
951
- core.rewrite(rect.__updateChange)
952
- ], exports.Box.prototype, "__updateRectChange", null);
953
- __decorate([
954
- core.rewrite(rect.__drawPathByData)
955
- ], exports.Box.prototype, "__drawPathByData", null);
956
- __decorate([
957
- core.rewrite(rect.__render)
958
- ], exports.Box.prototype, "__renderRect", null);
959
- __decorate([
960
- core.rewrite(group.__render)
961
- ], exports.Box.prototype, "__renderGroup", null);
962
- exports.Box = __decorate([
963
- core.rewriteAble(),
964
- core.registerUI()
965
- ], exports.Box);
966
-
967
- exports.Frame = class Frame extends exports.Box {
968
- get __tag() { return 'Frame'; }
969
- constructor(data) {
970
- super(data);
971
- this.isFrame = true;
972
- if (!this.__.fill)
973
- this.__.fill = '#FFFFFF';
974
- }
975
- };
976
- __decorate([
977
- core.dataProcessor(FrameData)
978
- ], exports.Frame.prototype, "__", void 0);
979
- __decorate([
980
- core.affectRenderBoundsType('hide')
981
- ], exports.Frame.prototype, "overflow", void 0);
982
- exports.Frame = __decorate([
983
- core.registerUI()
984
- ], exports.Frame);
985
-
986
- const { moveTo: moveTo$3, closePath: closePath$2, ellipse } = core.PathCommandDataHelper;
987
- exports.Ellipse = class Ellipse extends exports.UI {
988
- get __tag() { return 'Ellipse'; }
989
- constructor(data) {
990
- super(data);
991
- }
992
- __updatePath() {
993
- const { width, height, innerRadius, startAngle, endAngle } = this.__;
994
- const rx = width / 2, ry = height / 2;
995
- const path = this.__.path = [];
996
- if (innerRadius) {
997
- if (startAngle || endAngle) {
998
- if (innerRadius < 1)
999
- ellipse(path, rx, ry, rx * innerRadius, ry * innerRadius, 0, startAngle, endAngle, false);
1000
- ellipse(path, rx, ry, rx, ry, 0, endAngle, startAngle, true);
1001
- if (innerRadius < 1)
1002
- closePath$2(path);
1003
- }
1004
- else {
1005
- if (innerRadius < 1) {
1006
- ellipse(path, rx, ry, rx * innerRadius, ry * innerRadius);
1007
- moveTo$3(path, width, ry);
1008
- }
1009
- ellipse(path, rx, ry, rx, ry, 0, 360, 0, true);
1010
- }
1011
- if (core.Platform.ellipseToCurve)
1012
- this.__.path = this.getPath(true);
1013
- }
1014
- else {
1015
- if (startAngle || endAngle) {
1016
- moveTo$3(path, rx, ry);
1017
- ellipse(path, rx, ry, rx, ry, 0, startAngle, endAngle, false);
1018
- closePath$2(path);
1019
- }
1020
- else {
1021
- ellipse(path, rx, ry, rx, ry);
1022
- }
1023
- }
1024
- }
1025
- };
1026
- __decorate([
1027
- core.dataProcessor(EllipseData)
1028
- ], exports.Ellipse.prototype, "__", void 0);
1029
- __decorate([
1030
- core.pathType(0)
1031
- ], exports.Ellipse.prototype, "innerRadius", void 0);
1032
- __decorate([
1033
- core.pathType(0)
1034
- ], exports.Ellipse.prototype, "startAngle", void 0);
1035
- __decorate([
1036
- core.pathType(0)
1037
- ], exports.Ellipse.prototype, "endAngle", void 0);
1038
- exports.Ellipse = __decorate([
1039
- core.registerUI()
1040
- ], exports.Ellipse);
1041
-
1042
- const { moveTo: moveTo$2, lineTo: lineTo$2, drawPoints: drawPoints$1 } = core.PathCommandDataHelper;
1043
- const { rotate, getAngle, getDistance, defaultPoint } = core.PointHelper;
1044
- const { toBounds: toBounds$1 } = core.PathBounds;
1045
- exports.Line = class Line extends exports.UI {
1046
- get __tag() { return 'Line'; }
1047
- get toPoint() {
1048
- const { width, rotation } = this.__;
1049
- const to = { x: 0, y: 0 };
1050
- if (width)
1051
- to.x = width;
1052
- if (rotation)
1053
- rotate(to, rotation);
1054
- return to;
1055
- }
1056
- set toPoint(value) {
1057
- this.width = getDistance(defaultPoint, value);
1058
- this.rotation = getAngle(defaultPoint, value);
1059
- if (this.height)
1060
- this.height = 0;
1061
- }
1062
- constructor(data) {
1063
- super(data);
1064
- }
1065
- __updatePath() {
1066
- const path = this.__.path = [];
1067
- if (this.__.points) {
1068
- drawPoints$1(path, this.__.points, false);
1069
- }
1070
- else {
1071
- moveTo$2(path, 0, 0);
1072
- lineTo$2(path, this.width, 0);
1073
- }
1074
- }
1075
- __updateRenderPath() {
1076
- if (this.__.points && this.__.curve) {
1077
- drawPoints$1(this.__.__pathForRender = [], this.__.points, this.__.curve, this.__tag !== 'Line');
1078
- }
1079
- else {
1080
- super.__updateRenderPath();
1081
- }
1082
- }
1083
- __updateBoxBounds() {
1084
- if (this.points) {
1085
- toBounds$1(this.__.__pathForRender, this.__layout.boxBounds);
1086
- }
1087
- else {
1088
- super.__updateBoxBounds();
1089
- }
1090
- }
1091
- __scaleResize(scaleX, scaleY) {
1092
- if (this.points) {
1093
- core.PathScaler.scalePoints(this.__.points, scaleX, scaleY);
1094
- this.points = this.__.points;
1095
- }
1096
- else {
1097
- if (this.__tag === 'Line') {
1098
- const point = this.toPoint;
1099
- point.x *= scaleX;
1100
- point.y *= scaleY;
1101
- this.toPoint = point;
1102
- }
1103
- else {
1104
- super.__scaleResize(scaleX, scaleY);
1105
- }
1106
- }
1107
- }
1108
- };
1109
- __decorate([
1110
- core.dataProcessor(LineData)
1111
- ], exports.Line.prototype, "__", void 0);
1112
- __decorate([
1113
- core.affectStrokeBoundsType('center')
1114
- ], exports.Line.prototype, "strokeAlign", void 0);
1115
- __decorate([
1116
- core.boundsType(0)
1117
- ], exports.Line.prototype, "height", void 0);
1118
- __decorate([
1119
- core.pathType()
1120
- ], exports.Line.prototype, "points", void 0);
1121
- __decorate([
1122
- core.pathType(0)
1123
- ], exports.Line.prototype, "curve", void 0);
1124
- exports.Line = __decorate([
1125
- core.registerUI()
1126
- ], exports.Line);
1127
-
1128
- const { sin: sin$1, cos: cos$1, PI: PI$1 } = Math;
1129
- const { moveTo: moveTo$1, lineTo: lineTo$1, closePath: closePath$1, drawPoints } = core.PathCommandDataHelper;
1130
- const line = exports.Line.prototype;
1131
- exports.Polygon = class Polygon extends exports.UI {
1132
- get __tag() { return 'Polygon'; }
1133
- constructor(data) {
1134
- super(data);
1135
- }
1136
- __updatePath() {
1137
- const path = this.__.path = [];
1138
- if (this.__.points) {
1139
- drawPoints(path, this.__.points, false, true);
1140
- }
1141
- else {
1142
- const { width, height, sides } = this.__;
1143
- const rx = width / 2, ry = height / 2;
1144
- moveTo$1(path, rx, 0);
1145
- for (let i = 1; i < sides; i++) {
1146
- lineTo$1(path, rx + rx * sin$1((i * 2 * PI$1) / sides), ry - ry * cos$1((i * 2 * PI$1) / sides));
1147
- }
1148
- }
1149
- closePath$1(path);
1150
- }
1151
- __updateRenderPath() { }
1152
- __updateBoxBounds() { }
1153
- __scaleResize(_scaleX, _scaleY) { }
1154
- };
1155
- __decorate([
1156
- core.dataProcessor(PolygonData)
1157
- ], exports.Polygon.prototype, "__", void 0);
1158
- __decorate([
1159
- core.pathType(3)
1160
- ], exports.Polygon.prototype, "sides", void 0);
1161
- __decorate([
1162
- core.pathType()
1163
- ], exports.Polygon.prototype, "points", void 0);
1164
- __decorate([
1165
- core.pathType(0)
1166
- ], exports.Polygon.prototype, "curve", void 0);
1167
- __decorate([
1168
- core.rewrite(line.__updateRenderPath)
1169
- ], exports.Polygon.prototype, "__updateRenderPath", null);
1170
- __decorate([
1171
- core.rewrite(line.__updateBoxBounds)
1172
- ], exports.Polygon.prototype, "__updateBoxBounds", null);
1173
- __decorate([
1174
- core.rewrite(line.__scaleResize)
1175
- ], exports.Polygon.prototype, "__scaleResize", null);
1176
- exports.Polygon = __decorate([
1177
- core.rewriteAble(),
1178
- core.registerUI()
1179
- ], exports.Polygon);
1180
-
1181
- const { sin, cos, PI } = Math;
1182
- const { moveTo, lineTo, closePath } = core.PathCommandDataHelper;
1183
- exports.Star = class Star extends exports.UI {
1184
- get __tag() { return 'Star'; }
1185
- constructor(data) {
1186
- super(data);
1187
- }
1188
- __updatePath() {
1189
- const { width, height, corners, innerRadius } = this.__;
1190
- const rx = width / 2, ry = height / 2;
1191
- const path = this.__.path = [];
1192
- moveTo(path, rx, 0);
1193
- for (let i = 1; i < corners * 2; i++) {
1194
- lineTo(path, rx + (i % 2 === 0 ? rx : rx * innerRadius) * sin((i * PI) / corners), ry - (i % 2 === 0 ? ry : ry * innerRadius) * cos((i * PI) / corners));
1195
- }
1196
- closePath(path);
1197
- }
1198
- };
1199
- __decorate([
1200
- core.dataProcessor(StarData)
1201
- ], exports.Star.prototype, "__", void 0);
1202
- __decorate([
1203
- core.pathType(5)
1204
- ], exports.Star.prototype, "corners", void 0);
1205
- __decorate([
1206
- core.pathType(0.382)
1207
- ], exports.Star.prototype, "innerRadius", void 0);
1208
- exports.Star = __decorate([
1209
- core.registerUI()
1210
- ], exports.Star);
1211
-
1212
- exports.Image = class Image extends exports.Rect {
1213
- get __tag() { return 'Image'; }
1214
- get ready() { return this.image ? this.image.ready : false; }
1215
- constructor(data) {
1216
- super(data);
1217
- this.on(core.ImageEvent.LOADED, (e) => {
1218
- if (e.attrName === 'fill' && e.attrValue.url === this.url)
1219
- this.image = e.image;
1220
- });
1221
- }
1222
- destroy() {
1223
- this.image = null;
1224
- super.destroy();
1225
- }
1226
- };
1227
- __decorate([
1228
- core.dataProcessor(ImageData)
1229
- ], exports.Image.prototype, "__", void 0);
1230
- __decorate([
1231
- core.boundsType('')
1232
- ], exports.Image.prototype, "url", void 0);
1233
- exports.Image = __decorate([
1234
- core.registerUI()
1235
- ], exports.Image);
1236
-
1237
- exports.Canvas = class Canvas extends exports.Rect {
1238
- get __tag() { return 'Canvas'; }
1239
- constructor(data) {
1240
- super(data);
1241
- this.canvas = core.Creator.canvas(this.__);
1242
- this.context = this.canvas.context;
1243
- this.__.__drawAfterFill = true;
1244
- }
1245
- draw(ui, offset, scale, rotation) {
1246
- ui.__layout.update();
1247
- const matrix = new core.Matrix(ui.__world);
1248
- matrix.invert();
1249
- const m = new core.Matrix();
1250
- if (offset)
1251
- m.translate(offset.x, offset.y);
1252
- if (scale)
1253
- typeof scale === 'number' ? m.scale(scale) : m.scale(scale.x, scale.y);
1254
- if (rotation)
1255
- m.rotate(rotation);
1256
- matrix.multiplyParent(m);
1257
- ui.__render(this.canvas, { matrix });
1258
- this.paint();
1259
- }
1260
- paint() {
1261
- this.forceUpdate('fill');
1262
- }
1263
- __drawAfterFill(canvas, _options) {
1264
- const origin = this.canvas.view;
1265
- const { width, height } = this;
1266
- if (this.__.cornerRadius) {
1267
- canvas.save();
1268
- canvas.clip();
1269
- canvas.drawImage(this.canvas.view, 0, 0, origin.width, origin.height, 0, 0, width, height);
1270
- canvas.restore();
1271
- }
1272
- else {
1273
- canvas.drawImage(this.canvas.view, 0, 0, origin.width, origin.height, 0, 0, width, height);
1274
- }
1275
- }
1276
- __updateSize() {
1277
- const { canvas } = this;
1278
- if (canvas) {
1279
- const { smooth } = this.__;
1280
- if (canvas.smooth !== smooth)
1281
- canvas.smooth = smooth;
1282
- canvas.resize(this.__);
1283
- }
1284
- }
1285
- destroy() {
1286
- if (this.canvas) {
1287
- this.canvas.destroy();
1288
- this.canvas = null;
1289
- this.context = null;
1290
- }
1291
- super.destroy();
1292
- }
1293
- };
1294
- __decorate([
1295
- core.dataProcessor(ImageData)
1296
- ], exports.Canvas.prototype, "__", void 0);
1297
- __decorate([
1298
- resizeType(100)
1299
- ], exports.Canvas.prototype, "width", void 0);
1300
- __decorate([
1301
- resizeType(100)
1302
- ], exports.Canvas.prototype, "height", void 0);
1303
- __decorate([
1304
- resizeType(core.Platform.devicePixelRatio)
1305
- ], exports.Canvas.prototype, "pixelRatio", void 0);
1306
- __decorate([
1307
- resizeType(true)
1308
- ], exports.Canvas.prototype, "smooth", void 0);
1309
- __decorate([
1310
- core.hitType('all')
1311
- ], exports.Canvas.prototype, "hitFill", void 0);
1312
- exports.Canvas = __decorate([
1313
- core.registerUI()
1314
- ], exports.Canvas);
1315
-
1316
- const { copyAndSpread, includes, spread, setList } = core.BoundsHelper;
1317
- exports.Text = class Text extends exports.UI {
1318
- get __tag() { return 'Text'; }
1319
- get textDrawData() {
1320
- this.__layout.update();
1321
- return this.__.__textDrawData;
1322
- }
1323
- constructor(data) {
1324
- super(data);
1325
- }
1326
- __drawHitPath(canvas) {
1327
- const { __lineHeight, __baseLine, __textDrawData: data } = this.__;
1328
- canvas.beginPath();
1329
- if (this.__.__letterSpacing < 0) {
1330
- this.__drawPathByData(canvas);
1331
- }
1332
- else {
1333
- data.rows.forEach(row => canvas.rect(row.x, row.y - __baseLine, row.width, __lineHeight));
1334
- }
1335
- }
1336
- __drawPathByData(drawer, _data) {
1337
- const { x, y, width, height } = this.__layout.boxBounds;
1338
- drawer.rect(x, y, width, height);
1339
- }
1340
- __drawRenderPath(canvas) {
1341
- canvas.font = this.__.__font;
1342
- }
1343
- __updateTextDrawData() {
1344
- const data = this.__;
1345
- data.__textDrawData = TextConvert.getDrawData(data.text, this.__);
1346
- }
1347
- __updateBoxBounds() {
1348
- const data = this.__;
1349
- const layout = this.__layout;
1350
- const { lineHeight, letterSpacing, fontFamily, fontSize, fontWeight, italic, textCase, textOverflow, padding } = data;
1351
- const autoWidth = data.__autoWidth;
1352
- const autoHeight = data.__autoHeight;
1353
- data.__lineHeight = UnitConvert.number(lineHeight, fontSize);
1354
- data.__letterSpacing = UnitConvert.number(letterSpacing, fontSize);
1355
- data.__padding = padding ? core.MathHelper.fourNumber(padding) : undefined;
1356
- data.__baseLine = data.__lineHeight - (data.__lineHeight - fontSize * 0.7) / 2;
1357
- data.__font = `${italic ? 'italic ' : ''}${textCase === 'small-caps' ? 'small-caps ' : ''}${fontWeight !== 'normal' ? fontWeight + ' ' : ''}${fontSize}px ${fontFamily}`;
1358
- data.__clipText = textOverflow !== 'show' && !data.__autoBounds;
1359
- this.__updateTextDrawData();
1360
- const { bounds } = data.__textDrawData;
1361
- const b = layout.boxBounds;
1362
- if (data.__lineHeight < fontSize)
1363
- spread(bounds, fontSize / 2);
1364
- if (autoWidth || autoHeight) {
1365
- b.x = autoWidth ? bounds.x : 0;
1366
- b.y = autoHeight ? bounds.y : 0;
1367
- b.width = autoWidth ? bounds.width : data.width;
1368
- b.height = autoHeight ? bounds.height : data.height;
1369
- if (padding) {
1370
- const [top, right, bottom, left] = data.__padding;
1371
- if (autoWidth) {
1372
- b.x -= left;
1373
- b.width += (right + left);
1374
- }
1375
- if (autoHeight) {
1376
- b.y -= top;
1377
- b.height += (bottom + top);
1378
- }
1379
- }
1380
- this.__updateNaturalSize();
1381
- }
1382
- else {
1383
- super.__updateBoxBounds();
1384
- }
1385
- const contentBounds = includes(b, bounds) ? b : bounds;
1386
- if (contentBounds !== layout.contentBounds) {
1387
- layout.contentBounds = contentBounds;
1388
- layout.renderChanged = true;
1389
- setList(data.__textBoxBounds = {}, [b, bounds]);
1390
- }
1391
- else {
1392
- data.__textBoxBounds = contentBounds;
1393
- }
1394
- }
1395
- __updateRenderSpread() {
1396
- let width = super.__updateRenderSpread();
1397
- if (!width)
1398
- width = this.__layout.boxBounds === this.__layout.contentBounds ? 0 : 1;
1399
- return width;
1400
- }
1401
- __updateRenderBounds() {
1402
- copyAndSpread(this.__layout.renderBounds, this.__.__textBoxBounds, this.__layout.renderSpread);
1403
- }
1404
- };
1405
- __decorate([
1406
- core.dataProcessor(TextData)
1407
- ], exports.Text.prototype, "__", void 0);
1408
- __decorate([
1409
- core.boundsType(0)
1410
- ], exports.Text.prototype, "width", void 0);
1411
- __decorate([
1412
- core.boundsType(0)
1413
- ], exports.Text.prototype, "height", void 0);
1414
- __decorate([
1415
- core.boundsType(0)
1416
- ], exports.Text.prototype, "padding", void 0);
1417
- __decorate([
1418
- core.surfaceType('#000000')
1419
- ], exports.Text.prototype, "fill", void 0);
1420
- __decorate([
1421
- core.affectStrokeBoundsType('outside')
1422
- ], exports.Text.prototype, "strokeAlign", void 0);
1423
- __decorate([
1424
- core.hitType('all')
1425
- ], exports.Text.prototype, "hitFill", void 0);
1426
- __decorate([
1427
- core.boundsType('')
1428
- ], exports.Text.prototype, "text", void 0);
1429
- __decorate([
1430
- core.boundsType('L')
1431
- ], exports.Text.prototype, "fontFamily", void 0);
1432
- __decorate([
1433
- core.boundsType(12)
1434
- ], exports.Text.prototype, "fontSize", void 0);
1435
- __decorate([
1436
- core.boundsType('normal')
1437
- ], exports.Text.prototype, "fontWeight", void 0);
1438
- __decorate([
1439
- core.boundsType(false)
1440
- ], exports.Text.prototype, "italic", void 0);
1441
- __decorate([
1442
- core.boundsType('none')
1443
- ], exports.Text.prototype, "textCase", void 0);
1444
- __decorate([
1445
- core.boundsType('none')
1446
- ], exports.Text.prototype, "textDecoration", void 0);
1447
- __decorate([
1448
- core.boundsType(0)
1449
- ], exports.Text.prototype, "letterSpacing", void 0);
1450
- __decorate([
1451
- core.boundsType({ type: 'percent', value: 150 })
1452
- ], exports.Text.prototype, "lineHeight", void 0);
1453
- __decorate([
1454
- core.boundsType(0)
1455
- ], exports.Text.prototype, "paraIndent", void 0);
1456
- __decorate([
1457
- core.boundsType(0)
1458
- ], exports.Text.prototype, "paraSpacing", void 0);
1459
- __decorate([
1460
- core.boundsType('left')
1461
- ], exports.Text.prototype, "textAlign", void 0);
1462
- __decorate([
1463
- core.boundsType('top')
1464
- ], exports.Text.prototype, "verticalAlign", void 0);
1465
- __decorate([
1466
- core.boundsType('normal')
1467
- ], exports.Text.prototype, "textWrap", void 0);
1468
- __decorate([
1469
- core.boundsType('show')
1470
- ], exports.Text.prototype, "textOverflow", void 0);
1471
- exports.Text = __decorate([
1472
- core.registerUI()
1473
- ], exports.Text);
1474
-
1475
- const { toBounds } = core.PathBounds;
1476
- exports.Path = class Path extends exports.UI {
1477
- get __tag() { return 'Path'; }
1478
- constructor(data) {
1479
- super(data);
1480
- }
1481
- __scaleResize(scaleX, scaleY) {
1482
- core.PathScaler.scale(this.__.path, scaleX, scaleY);
1483
- this.path = this.__.path;
1484
- }
1485
- __updateBoxBounds() {
1486
- toBounds(this.__.path, this.__layout.boxBounds);
1487
- }
1488
- };
1489
- __decorate([
1490
- core.dataProcessor(PathData)
1491
- ], exports.Path.prototype, "__", void 0);
1492
- __decorate([
1493
- core.pathType()
1494
- ], exports.Path.prototype, "path", void 0);
1495
- __decorate([
1496
- core.pathType()
1497
- ], exports.Path.prototype, "windingRule", void 0);
1498
- __decorate([
1499
- core.affectStrokeBoundsType('center')
1500
- ], exports.Path.prototype, "strokeAlign", void 0);
1501
- exports.Path = __decorate([
1502
- core.registerUI()
1503
- ], exports.Path);
1504
-
1505
- exports.Pen = class Pen extends exports.Group {
1506
- get __tag() { return 'Pen'; }
1507
- constructor(data) {
1508
- super(data);
1509
- }
1510
- setStyle(data) {
1511
- const path = this.pathElement = new exports.Path(data);
1512
- this.pathStyle = data;
1513
- this.path = path.path || (path.path = []);
1514
- this.add(path);
1515
- return this;
1516
- }
1517
- beginPath() {
1518
- this.path.length = 0;
1519
- this.paint();
1520
- return this;
1521
- }
1522
- moveTo(_x, _y) { return this; }
1523
- lineTo(_x, _y) { return this; }
1524
- bezierCurveTo(_x1, _y1, _x2, _y2, _x, _y) { return this; }
1525
- quadraticCurveTo(_x1, _y1, _x, _y) { return this; }
1526
- closePath() { return this; }
1527
- rect(_x, _y, _width, _height) { return this; }
1528
- roundRect(_x, _y, _width, _height, _cornerRadius) { return this; }
1529
- ellipse(_x, _y, _radiusX, _radiusY, _rotation, _startAngle, _endAngle, _anticlockwise) { return this; }
1530
- arc(_x, _y, _radius, _startAngle, _endAngle, _anticlockwise) { return this; }
1531
- arcTo(_x1, _y1, _x2, _y2, _radius) { return this; }
1532
- drawEllipse(_x, _y, _radiusX, _radiusY, _rotation, _startAngle, _endAngle, _anticlockwise) { return this; }
1533
- drawArc(_x, _y, _radius, _startAngle, _endAngle, _anticlockwise) { return this; }
1534
- drawPoints(_points, _curve, _close) { return this; }
1535
- paint() {
1536
- this.pathElement.forceUpdate('path');
1537
- }
1538
- clear() {
1539
- this.removeAll(true);
1540
- }
1541
- };
1542
- __decorate([
1543
- core.dataProcessor(PenData)
1544
- ], exports.Pen.prototype, "__", void 0);
1545
- exports.Pen = __decorate([
1546
- core.useModule(core.PathCreator, ['beginPath']),
1547
- core.registerUI()
1548
- ], exports.Pen);
1549
-
1550
- const debug = core.Debug.get('Leafer');
1551
- exports.Leafer = class Leafer extends exports.Group {
1552
- get __tag() { return 'Leafer'; }
1553
- get isApp() { return false; }
1554
- get app() { return this.parent || this; }
1555
- get imageReady() { return this.viewReady && core.ImageManager.isComplete; }
1556
- get layoutLocked() { return !this.layouter.running; }
1557
- get cursorPoint() { return (this.interaction && this.interaction.hoverData) || { x: this.width / 2, y: this.height / 2 }; }
1558
- constructor(userConfig, data) {
1559
- super(data);
1560
- this.zoomLayer = this;
1561
- this.config = {
1562
- type: 'design',
1563
- start: true,
1564
- hittable: true,
1565
- smooth: true,
1566
- zoom: {
1567
- min: 0.02,
1568
- max: 256
1569
- },
1570
- move: {
1571
- holdSpaceKey: true,
1572
- dragOut: true,
1573
- autoDistance: 2
1574
- }
1575
- };
1576
- this.leafs = 0;
1577
- this.__eventIds = [];
1578
- this.__controllers = [];
1579
- this.__readyWait = [];
1580
- this.__viewReadyWait = [];
1581
- this.__viewCompletedWait = [];
1582
- this.__nextRenderWait = [];
1583
- this.userConfig = userConfig;
1584
- if (userConfig && (userConfig.view || userConfig.width))
1585
- this.init(userConfig);
1586
- }
1587
- init(userConfig, parentApp) {
1588
- if (this.canvas)
1589
- return;
1590
- this.__setLeafer(this);
1591
- if (userConfig)
1592
- core.DataHelper.assign(this.config, userConfig);
1593
- let start;
1594
- const { config } = this;
1595
- LeaferTypeCreator.run(config.type, this);
1596
- this.canvas = core.Creator.canvas(config);
1597
- this.__controllers.push(this.renderer = core.Creator.renderer(this, this.canvas, config), this.watcher = core.Creator.watcher(this, config), this.layouter = core.Creator.layouter(this, config));
1598
- if (this.isApp)
1599
- this.__setApp();
1600
- this.__checkAutoLayout(config);
1601
- this.view = this.canvas.view;
1602
- if (parentApp) {
1603
- this.__bindApp(parentApp);
1604
- start = parentApp.running;
1605
- }
1606
- else {
1607
- this.selector = core.Creator.selector(this);
1608
- this.__controllers.unshift(this.interaction = core.Creator.interaction(this, this.canvas, this.selector, config));
1609
- this.canvasManager = new core.CanvasManager();
1610
- this.hitCanvasManager = new core.HitCanvasManager();
1611
- start = config.start;
1612
- }
1613
- this.hittable = config.hittable;
1614
- this.fill = config.fill;
1615
- this.canvasManager.add(this.canvas);
1616
- this.__listenEvents();
1617
- if (start)
1618
- this.__startTimer = setTimeout(this.start.bind(this));
1619
- core.PluginManager.onLeafer(this);
1620
- }
1621
- set(data) {
1622
- if (!this.children) {
1623
- setTimeout(() => {
1624
- super.set(data);
1625
- });
1626
- }
1627
- else {
1628
- super.set(data);
1629
- }
1630
- }
1631
- start() {
1632
- clearTimeout(this.__startTimer);
1633
- if (!this.running && this.canvas) {
1634
- this.ready ? this.emitLeafer(core.LeaferEvent.RESTART) : this.emitLeafer(core.LeaferEvent.START);
1635
- this.__controllers.forEach(item => item.start());
1636
- if (!this.isApp)
1637
- this.renderer.render();
1638
- this.running = true;
1639
- }
1640
- }
1641
- stop() {
1642
- clearTimeout(this.__startTimer);
1643
- if (this.running && this.canvas) {
1644
- this.__controllers.forEach(item => item.stop());
1645
- this.running = false;
1646
- this.emitLeafer(core.LeaferEvent.STOP);
1647
- }
1648
- }
1649
- unlockLayout() {
1650
- this.layouter.start();
1651
- this.updateLayout();
1652
- }
1653
- lockLayout() {
1654
- this.updateLayout();
1655
- this.layouter.stop();
1656
- }
1657
- resize(size) {
1658
- const data = core.DataHelper.copyAttrs({}, size, core.canvasSizeAttrs);
1659
- Object.keys(data).forEach(key => this[key] = data[key]);
1660
- }
1661
- forceFullRender() {
1662
- this.renderer.addBlock(this.canvas.bounds);
1663
- if (this.viewReady)
1664
- this.renderer.update();
1665
- }
1666
- updateCursor() {
1667
- if (this.interaction)
1668
- this.interaction.updateCursor();
1669
- }
1670
- __doResize(size) {
1671
- if (!this.canvas || this.canvas.isSameSize(size))
1672
- return;
1673
- const old = core.DataHelper.copyAttrs({}, this.canvas, core.canvasSizeAttrs);
1674
- this.canvas.resize(size);
1675
- this.__onResize(new core.ResizeEvent(size, old));
1676
- }
1677
- __onResize(event) {
1678
- this.emitEvent(event);
1679
- core.DataHelper.copyAttrs(this.__, event, core.canvasSizeAttrs);
1680
- setTimeout(() => { if (this.canvasManager)
1681
- this.canvasManager.clearRecycled(); }, 0);
1682
- }
1683
- __setApp() { }
1684
- __bindApp(app) {
1685
- this.selector = app.selector;
1686
- this.interaction = app.interaction;
1687
- this.canvasManager = app.canvasManager;
1688
- this.hitCanvasManager = app.hitCanvasManager;
1689
- }
1690
- __setLeafer(leafer) {
1691
- this.leafer = leafer;
1692
- this.isLeafer = !!leafer;
1693
- this.__level = 1;
1694
- }
1695
- setZoomLayer(zoomLayer) {
1696
- this.zoomLayer = zoomLayer;
1697
- }
1698
- __checkAutoLayout(config) {
1699
- if (!config.width || !config.height) {
1700
- this.autoLayout = new core.AutoBounds(config);
1701
- this.canvas.startAutoLayout(this.autoLayout, this.__onResize.bind(this));
1702
- }
1703
- }
1704
- __setAttr(attrName, newValue) {
1705
- if (this.canvas) {
1706
- if (core.canvasSizeAttrs.includes(attrName)) {
1707
- this.__changeCanvasSize(attrName, newValue);
1708
- }
1709
- else if (attrName === 'fill') {
1710
- this.__changeFill(newValue);
1711
- }
1712
- else if (attrName === 'hittable') {
1713
- this.canvas.hittable = newValue;
1714
- }
1715
- }
1716
- super.__setAttr(attrName, newValue);
1717
- }
1718
- __getAttr(attrName) {
1719
- if (this.canvas && core.canvasSizeAttrs.includes(attrName))
1720
- return this.canvas[attrName];
1721
- return super.__getAttr(attrName);
1722
- }
1723
- __changeCanvasSize(attrName, newValue) {
1724
- const data = core.DataHelper.copyAttrs({}, this.canvas, core.canvasSizeAttrs);
1725
- data[attrName] = this.config[attrName] = newValue;
1726
- if (newValue)
1727
- this.canvas.stopAutoLayout();
1728
- this.__doResize(data);
1729
- }
1730
- __changeFill(newValue) {
1731
- this.config.fill = newValue;
1732
- if (this.canvas.allowBackgroundColor) {
1733
- this.canvas.backgroundColor = newValue;
1734
- }
1735
- else {
1736
- this.forceFullRender();
1737
- }
1738
- }
1739
- __onCreated() {
1740
- this.created = true;
1741
- }
1742
- __onReady() {
1743
- if (this.ready)
1744
- return;
1745
- this.ready = true;
1746
- this.emitLeafer(core.LeaferEvent.BEFORE_READY);
1747
- this.emitLeafer(core.LeaferEvent.READY);
1748
- this.emitLeafer(core.LeaferEvent.AFTER_READY);
1749
- core.WaitHelper.run(this.__readyWait);
1750
- }
1751
- __onViewReady() {
1752
- if (this.viewReady)
1753
- return;
1754
- this.viewReady = true;
1755
- this.emitLeafer(core.LeaferEvent.VIEW_READY);
1756
- core.WaitHelper.run(this.__viewReadyWait);
1757
- }
1758
- __onAnimateFrame() {
1759
- if (this.viewReady) {
1760
- if (this.__nextRenderWait.length)
1761
- core.WaitHelper.run(this.__nextRenderWait);
1762
- const { imageReady } = this;
1763
- if (imageReady && !this.viewCompleted)
1764
- this.__checkViewCompleted();
1765
- if (!imageReady)
1766
- this.viewCompleted = false;
1767
- }
1768
- }
1769
- __checkViewCompleted(emit = true) {
1770
- this.nextRender(() => {
1771
- if (this.imageReady) {
1772
- if (emit)
1773
- this.emitLeafer(core.LeaferEvent.VIEW_COMPLETED);
1774
- core.WaitHelper.run(this.__viewCompletedWait);
1775
- this.viewCompleted = true;
1776
- }
1777
- });
1778
- }
1779
- __onWatchData() {
1780
- if (this.watcher.childrenChanged && this.interaction) {
1781
- this.nextRender(() => this.interaction.updateCursor());
1782
- }
1783
- }
1784
- waitReady(item) {
1785
- this.ready ? item() : this.__readyWait.push(item);
1786
- }
1787
- waitViewReady(item) {
1788
- this.viewReady ? item() : this.__viewReadyWait.push(item);
1789
- }
1790
- waitViewCompleted(item) {
1791
- this.__viewCompletedWait.push(item);
1792
- if (this.viewCompleted) {
1793
- this.__checkViewCompleted(false);
1794
- }
1795
- else {
1796
- if (!this.running)
1797
- this.start();
1798
- }
1799
- }
1800
- nextRender(item) {
1801
- this.__nextRenderWait.push(item);
1802
- }
1803
- __checkUpdateLayout() {
1804
- this.__layout.update();
1805
- }
1806
- emitLeafer(type) {
1807
- this.emitEvent(new core.LeaferEvent(type, this));
1808
- }
1809
- __listenEvents() {
1810
- const runId = core.Run.start('FirstCreate ' + this.innerName);
1811
- this.once(core.LeaferEvent.START, () => core.Run.end(runId));
1812
- this.once(core.LayoutEvent.END, () => this.__onReady());
1813
- this.once(core.RenderEvent.START, () => this.__onCreated());
1814
- this.once(core.RenderEvent.END, () => this.__onViewReady());
1815
- this.__eventIds.push(this.on_(core.WatchEvent.DATA, this.__onWatchData, this), this.on_(core.AnimateEvent.FRAME, this.__onAnimateFrame, this), this.on_(core.LayoutEvent.CHECK_UPDATE, this.__checkUpdateLayout, this));
1816
- }
1817
- __removeListenEvents() {
1818
- this.off_(this.__eventIds);
1819
- this.__eventIds.length = 0;
1820
- }
1821
- destroy() {
1822
- setTimeout(() => {
1823
- if (!this.destroyed) {
1824
- try {
1825
- this.stop();
1826
- this.emitEvent(new core.LeaferEvent(core.LeaferEvent.END, this));
1827
- this.__removeListenEvents();
1828
- this.__controllers.forEach(item => {
1829
- if (!(this.parent && item === this.interaction))
1830
- item.destroy();
1831
- });
1832
- this.__controllers.length = 0;
1833
- if (!this.parent) {
1834
- this.selector.destroy();
1835
- this.canvasManager.destroy();
1836
- this.hitCanvasManager.destroy();
1837
- }
1838
- this.canvas.destroy();
1839
- this.config.view = this.view = null;
1840
- if (this.userConfig)
1841
- this.userConfig.view = null;
1842
- super.destroy();
1843
- setTimeout(() => { core.ImageManager.clearRecycled(); }, 100);
1844
- }
1845
- catch (e) {
1846
- debug.error(e);
1847
- }
1848
- }
1849
- });
1850
- }
1851
- };
1852
- __decorate([
1853
- core.dataProcessor(LeaferData)
1854
- ], exports.Leafer.prototype, "__", void 0);
1855
- __decorate([
1856
- core.boundsType()
1857
- ], exports.Leafer.prototype, "pixelRatio", void 0);
1858
- exports.Leafer = __decorate([
1859
- core.registerUI()
1860
- ], exports.Leafer);
1861
-
1862
- exports.App = class App extends exports.Leafer {
1863
- get __tag() { return 'App'; }
1864
- get isApp() { return true; }
1865
- constructor(userConfig, data) {
1866
- super(userConfig, data);
1867
- if (userConfig) {
1868
- const { ground, tree, sky, editor } = userConfig;
1869
- if (ground)
1870
- this.ground = this.addLeafer(ground);
1871
- if (tree || editor)
1872
- this.tree = this.addLeafer(tree);
1873
- if (sky || editor)
1874
- this.sky = this.addLeafer(sky || { type: 'draw', usePartRender: false });
1875
- if (editor) {
1876
- this.editor = core.Creator.editor(editor);
1877
- this.sky.add(this.editor);
1878
- }
1879
- }
1880
- }
1881
- __setApp() {
1882
- const { canvas } = this;
1883
- const { realCanvas, view } = this.config;
1884
- if (realCanvas || view === this.canvas.view || !canvas.parentView) {
1885
- this.realCanvas = true;
1886
- }
1887
- else {
1888
- canvas.unrealCanvas();
1889
- }
1890
- this.leafer = this;
1891
- this.watcher.disable();
1892
- this.layouter.disable();
1893
- this.__eventIds.push(this.on_(core.PropertyEvent.CHANGE, this.__onPropertyChange, this));
1894
- }
1895
- start() {
1896
- super.start();
1897
- this.children.forEach(leafer => leafer.start());
1898
- }
1899
- stop() {
1900
- this.children.forEach(leafer => leafer.stop());
1901
- super.stop();
1902
- }
1903
- unlockLayout() {
1904
- super.unlockLayout();
1905
- this.children.forEach(leafer => leafer.unlockLayout());
1906
- }
1907
- lockLayout() {
1908
- super.lockLayout();
1909
- this.children.forEach(leafer => leafer.lockLayout());
1910
- }
1911
- addLeafer(merge) {
1912
- const leafer = new exports.Leafer(merge);
1913
- this.add(leafer);
1914
- return leafer;
1915
- }
1916
- add(leafer) {
1917
- if (!leafer.view) {
1918
- if (this.realCanvas && !this.canvas.bounds) {
1919
- setTimeout(() => this.add(leafer), 10);
1920
- return;
1921
- }
1922
- leafer.init(this.__getChildConfig(leafer.userConfig), this);
1923
- }
1924
- super.add(leafer);
1925
- this.__listenChildEvents(leafer);
1926
- }
1927
- __onPropertyChange() {
1928
- if (core.Debug.showHitView)
1929
- this.children.forEach(leafer => leafer.forceUpdate('surface'));
1930
- }
1931
- __onCreated() {
1932
- this.created = this.children.every(child => child.created);
1933
- }
1934
- __onReady() {
1935
- if (this.children.every(child => child.ready))
1936
- super.__onReady();
1937
- }
1938
- __onViewReady() {
1939
- if (this.children.every(child => child.viewReady))
1940
- super.__onViewReady();
1941
- }
1942
- __onChildRenderEnd(e) {
1943
- this.renderer.addBlock(e.renderBounds);
1944
- if (this.viewReady)
1945
- this.renderer.update();
1946
- }
1947
- __render(canvas, _options) {
1948
- this.children.forEach(leafer => canvas.copyWorld(leafer.canvas));
1949
- }
1950
- __onResize(event) {
1951
- this.children.forEach(leafer => leafer.resize(event));
1952
- super.__onResize(event);
1953
- }
1954
- __checkUpdateLayout() {
1955
- this.children.forEach(leafer => leafer.__layout.update());
1956
- }
1957
- __getChildConfig(userConfig) {
1958
- let config = Object.assign({}, this.config);
1959
- config.hittable = config.realCanvas = undefined;
1960
- if (userConfig)
1961
- core.DataHelper.assign(config, userConfig);
1962
- if (this.autoLayout)
1963
- core.DataHelper.copyAttrs(config, this, core.canvasSizeAttrs);
1964
- config.view = this.realCanvas ? undefined : this.view;
1965
- config.fill = undefined;
1966
- return config;
1967
- }
1968
- __listenChildEvents(leafer) {
1969
- leafer.once(core.LayoutEvent.END, () => this.__onReady());
1970
- leafer.once(core.RenderEvent.START, () => this.__onCreated());
1971
- leafer.once(core.RenderEvent.END, () => this.__onViewReady());
1972
- if (this.realCanvas)
1973
- this.__eventIds.push(leafer.on_(core.RenderEvent.END, this.__onChildRenderEnd, this));
1974
- }
1975
- };
1976
- exports.App = __decorate([
1977
- core.registerUI()
1978
- ], exports.App);
1979
-
1980
- exports.Animate = Animate;
1981
- exports.ArrowData = ArrowData;
1982
- exports.BoxData = BoxData;
1983
- exports.CanvasData = CanvasData;
1984
- exports.ColorConvert = ColorConvert;
1985
- exports.Effect = Effect;
1986
- exports.EllipseData = EllipseData;
1987
- exports.Export = Export;
1988
- exports.FrameData = FrameData;
1989
- exports.GroupData = GroupData;
1990
- exports.ImageData = ImageData;
1991
- exports.LeaferData = LeaferData;
1992
- exports.LeaferTypeCreator = LeaferTypeCreator;
1993
- exports.LineData = LineData;
1994
- exports.Paint = Paint;
1995
- exports.PathData = PathData;
1996
- exports.PenData = PenData;
1997
- exports.PolygonData = PolygonData;
1998
- exports.RectData = RectData;
1999
- exports.RectRender = RectRender;
2000
- exports.StarData = StarData;
2001
- exports.TextConvert = TextConvert;
2002
- exports.TextData = TextData;
2003
- exports.UIBounds = UIBounds;
2004
- exports.UIData = UIData;
2005
- exports.UIHit = UIHit;
2006
- exports.UIRender = UIRender;
2007
- exports.UnitConvert = UnitConvert;
2008
- exports.effectType = effectType;
2009
- exports.resizeType = resizeType;
2010
- Object.keys(core).forEach(function (k) {
2011
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
2012
- enumerable: true,
2013
- get: function () { return core[k]; }
2014
- });
2015
- });