@leafer-ui/core 1.0.0-rc.8 → 1.0.0

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