@leafer-game/miniapp 1.0.10 → 1.1.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/miniapp.cjs CHANGED
@@ -2,668 +2,21 @@
2
2
 
3
3
  var miniapp = require('@leafer-ui/miniapp');
4
4
  var robot = require('@leafer-in/robot');
5
- var draw = require('@leafer-ui/draw');
6
- var core = require('@leafer-ui/core');
5
+ var state = require('@leafer-in/state');
7
6
  var animate = require('@leafer-in/animate');
8
- var core$1 = require('@leafer/core');
9
-
10
- function stateType(defaultValue, styleName) {
11
- return draw.decorateLeafAttr(defaultValue, (key) => draw.attr({
12
- set(value) {
13
- this.__setAttr(key, value);
14
- this.waitLeafer(() => styleName ? draw.State.setStyleName(this, styleName, value) : draw.State.set(this, value));
15
- }
16
- }));
17
- }
18
- function stateStyleType(defaultValue) {
19
- return draw.decorateLeafAttr(defaultValue, (key) => draw.attr({
20
- set(value) {
21
- this.__setAttr(key, value);
22
- this.__layout.stateStyleChanged = true;
23
- }
24
- }));
25
- }
26
-
27
- function findParentButton(leaf, button) {
28
- if (button && button !== true)
29
- return button;
30
- if (!leaf.button) {
31
- let { parent } = leaf;
32
- for (let i = 0; i < 2; i++) {
33
- if (parent) {
34
- if (parent.button)
35
- return parent;
36
- parent = parent.parent;
37
- }
38
- }
39
- }
40
- return null;
41
- }
42
-
43
- function setStyle(leaf, style) {
44
- if (typeof style !== 'object')
45
- style = undefined;
46
- updateStyle(leaf, style, 'in');
47
- }
48
- function unsetStyle(leaf, style) {
49
- const { normalStyle } = leaf;
50
- if (typeof style !== 'object')
51
- style = undefined;
52
- if (normalStyle) {
53
- if (!style)
54
- style = normalStyle;
55
- updateStyle(leaf, style, 'out');
56
- }
57
- }
58
- const emprtyStyle = {};
59
- function updateStyle(leaf, style, type) {
60
- const { normalStyle } = leaf;
61
- if (!style)
62
- style = emprtyStyle;
63
- if (style.scale) {
64
- core.MathHelper.assignScale(style, style.scale);
65
- delete style.scale;
66
- }
67
- if (style === emprtyStyle || !core.State.canAnimate)
68
- type = null;
69
- let transition = type ? getTransition(type, style, leaf) : false;
70
- const fromStyle = transition ? getFromStyle(leaf, style) : undefined;
71
- leaf.killAnimate('transition');
72
- if (normalStyle)
73
- leaf.set(normalStyle, true);
74
- const statesStyle = getStyle(leaf);
75
- if (statesStyle) {
76
- const { animation } = statesStyle;
77
- if (animation) {
78
- const animate = leaf.animate(animation, undefined, 'animation', true);
79
- Object.assign(statesStyle, animate.endingStyle);
80
- if (type !== 'in' || style.animation !== animation)
81
- animate.kill();
82
- else
83
- transition = false;
84
- delete statesStyle.animation;
85
- }
86
- leaf.normalStyle = filterStyle(statesStyle, leaf);
87
- leaf.set(statesStyle, true);
88
- }
89
- else {
90
- leaf.normalStyle = undefined;
91
- }
92
- if (transition) {
93
- const toStyle = filterStyle(fromStyle, leaf);
94
- leaf.set(fromStyle, true);
95
- leaf.animate([fromStyle, toStyle], transition, 'transition', true);
96
- }
97
- leaf.__layout.stateStyleChanged = false;
98
- }
99
- function getStyle(leaf) {
100
- let exist;
101
- const style = {}, { state } = leaf, button = findParentButton(leaf);
102
- const stateStyle = state && leaf.states[state];
103
- if (stateStyle && core.State.isState(state, leaf, button))
104
- exist = assign(style, stateStyle);
105
- const selectedStyle = style.selectedStyle || leaf.selectedStyle;
106
- if (selectedStyle && core.State.isSelected(leaf, button))
107
- exist = assign(style, selectedStyle);
108
- if (core.State.isDisabled(leaf, button)) {
109
- const disabledStyle = style.disabledStyle || leaf.disabledStyle;
110
- if (disabledStyle)
111
- exist = assign(style, disabledStyle);
112
- }
113
- else {
114
- const focusStyle = style.focusStyle || leaf.focusStyle;
115
- if (focusStyle && core.State.isFocus(leaf, button))
116
- exist = assign(style, focusStyle);
117
- const hoverStyle = style.hoverStyle || leaf.hoverStyle;
118
- if (hoverStyle && core.State.isHover(leaf, button))
119
- exist = assign(style, hoverStyle);
120
- const pressStyle = style.pressStyle || leaf.pressStyle;
121
- if (pressStyle && core.State.isPress(leaf, button))
122
- exist = assign(style, pressStyle);
123
- }
124
- return exist ? style : undefined;
125
- }
126
- function filterStyle(style, data, addStyle, useAnimateExcludes) {
127
- const to = addStyle ? style : {}, forStyle = addStyle || style;
128
- for (let key in forStyle) {
129
- if (useAnimateExcludes) {
130
- if (!core.State.animateExcludes[key])
131
- to[key] = data[key];
132
- }
133
- else
134
- to[key] = data[key];
135
- }
136
- return to;
137
- }
138
- function filterAnimateStyle(style, data, addStyle) {
139
- return filterStyle(style, data, addStyle, true);
140
- }
141
- function getFromStyle(leaf, style) {
142
- const fromStyle = filterAnimateStyle(style, leaf), animate = leaf.animate();
143
- if (animate)
144
- filterAnimateStyle(fromStyle, leaf, animate.fromStyle);
145
- return fromStyle;
146
- }
147
- function getTransition(type, style, data) {
148
- let name = type === 'in' ? 'transition' : 'transitionOut';
149
- if (type === 'out' && core.isNull(data[name]) && core.isNull(style[name]))
150
- name = 'transition';
151
- return core.isNull(style[name]) ? data[name] : style[name];
152
- }
153
- function assign(style, stateStyle) {
154
- Object.assign(style, stateStyle);
155
- return true;
156
- }
157
-
158
- function setPointerState(leaf, stateName) {
159
- const style = leaf[stateName];
160
- if (style)
161
- setStyle(leaf, style);
162
- if (leaf.button)
163
- setChildrenState(leaf.children, stateName);
164
- }
165
- function setState(leaf, stateName, stateStyle) {
166
- if (!stateStyle)
167
- stateStyle = leaf.states[stateName];
168
- setStyle(leaf, stateStyle);
169
- if (leaf.button)
170
- setChildrenState(leaf.children, null, stateName);
171
- }
172
- function setChildrenState(children, stateType, state) {
173
- if (!children)
174
- return;
175
- let leaf, update;
176
- for (let i = 0, len = children.length; i < len; i++) {
177
- leaf = children[i];
178
- if (stateType) {
179
- update = true;
180
- switch (stateType) {
181
- case 'hoverStyle':
182
- if (core.State.isHover(leaf))
183
- update = false;
184
- break;
185
- case 'pressStyle':
186
- if (core.State.isPress(leaf))
187
- update = false;
188
- break;
189
- case 'focusStyle':
190
- if (core.State.isFocus(leaf))
191
- update = false;
192
- }
193
- if (update)
194
- setPointerState(leaf, stateType);
195
- }
196
- else if (state)
197
- setState(leaf, state);
198
- if (leaf.isBranch)
199
- setChildrenState(leaf.children, stateType, state);
200
- }
201
- }
202
-
203
- function unsetPointerState(leaf, stateName) {
204
- const style = leaf[stateName];
205
- if (style)
206
- unsetStyle(leaf, style);
207
- if (leaf.button)
208
- unsetChildrenState(leaf.children, stateName);
209
- }
210
- function unsetState(leaf, stateName, stateStyle) {
211
- unsetStyle(leaf, stateStyle);
212
- if (leaf.button)
213
- unsetChildrenState(leaf.children, null, stateName);
214
- }
215
- function unsetChildrenState(children, stateType, state) {
216
- if (!children)
217
- return;
218
- let leaf;
219
- for (let i = 0, len = children.length; i < len; i++) {
220
- leaf = children[i];
221
- if (stateType)
222
- unsetPointerState(leaf, stateType);
223
- else if (state)
224
- unsetState(leaf, state);
225
- if (leaf.isBranch)
226
- unsetChildrenState(leaf.children, stateType, state);
227
- }
228
- }
229
-
230
- function updateEventStyle(leaf, eventType) {
231
- switch (eventType) {
232
- case core.PointerEvent.ENTER:
233
- setPointerState(leaf, 'hoverStyle');
234
- break;
235
- case core.PointerEvent.LEAVE:
236
- unsetPointerState(leaf, 'hoverStyle');
237
- break;
238
- case core.PointerEvent.DOWN:
239
- setPointerState(leaf, 'pressStyle');
240
- break;
241
- case core.PointerEvent.UP:
242
- unsetPointerState(leaf, 'pressStyle');
243
- break;
244
- }
245
- }
246
-
247
- function checkPointerState(fnName, leaf, button) {
248
- let find;
249
- const interaction = leaf.leafer ? leaf.leafer.interaction : null;
250
- if (interaction) {
251
- find = interaction[fnName](leaf);
252
- if (!find && button) {
253
- const parentButton = findParentButton(leaf, button);
254
- if (parentButton)
255
- find = interaction[fnName](parentButton);
256
- }
257
- }
258
- return find;
259
- }
260
- function checkFixedState(attrName, leaf, button) {
261
- let find = leaf[attrName];
262
- if (!find && button) {
263
- const parentButton = findParentButton(leaf, button);
264
- if (parentButton)
265
- find = parentButton[attrName];
266
- }
267
- return find;
268
- }
269
- function checkState(stateName, leaf, button) {
270
- let find = leaf.states[stateName];
271
- if (!find && button) {
272
- const parentButton = findParentButton(leaf, button);
273
- if (parentButton)
274
- find = parentButton.states[stateName];
275
- }
276
- return !!find;
277
- }
278
-
279
- core.State.animateExcludes = {
280
- animation: 1,
281
- animationOut: 1,
282
- transition: 1,
283
- transitionOut: 1,
284
- states: 1,
285
- state: 1,
286
- normalStyle: 1,
287
- hoverStyle: 1,
288
- pressStyle: 1,
289
- focusStyle: 1,
290
- selectedStyle: 1,
291
- disabledStyle: 1
292
- };
293
- core.State.isState = function (state, leaf, button) { return checkState(state, leaf, button); };
294
- core.State.isSelected = function (leaf, button) { return checkFixedState('selected', leaf, button); };
295
- core.State.isDisabled = function (leaf, button) { return checkFixedState('disabled', leaf, button); };
296
- core.State.isFocus = function (leaf, button) { return checkPointerState('isFocus', leaf, button); };
297
- core.State.isHover = function (leaf, button) { return checkPointerState('isHover', leaf, button); };
298
- core.State.isPress = function (leaf, button) { return checkPointerState('isPress', leaf, button); };
299
- core.State.isDrag = function (leaf, button) { return checkPointerState('isDrag', leaf, button); };
300
- core.State.setStyleName = function (leaf, stateType, value) { value ? setState(leaf, stateType, leaf[stateType]) : unsetState(leaf, stateType, leaf[stateType]); };
301
- core.State.set = function (leaf, stateName) { const style = leaf.states[stateName]; style ? setState(leaf, stateName, style) : unsetState(leaf, stateName, style); };
302
- core.State.getStyle = getStyle;
303
- core.State.updateStyle = updateStyle;
304
- core.State.updateEventStyle = updateEventStyle;
305
- const ui$1 = core.UI.prototype;
306
- stateType(false, 'selectedStyle')(ui$1, 'selected');
307
- stateType(false, 'disabledStyle')(ui$1, 'disabled');
308
- stateStyleType({})(ui$1, 'states');
309
- stateType('')(ui$1, 'state');
310
- core.dataType()(ui$1, 'normalStyle');
311
- stateStyleType()(ui$1, 'hoverStyle');
312
- stateStyleType()(ui$1, 'pressStyle');
313
- stateStyleType()(ui$1, 'focusStyle');
314
- stateStyleType()(ui$1, 'selectedStyle');
315
- stateStyleType()(ui$1, 'disabledStyle');
316
- core.dataType(false)(ui$1, 'button');
317
- ui$1.focus = function (value = true) {
318
- this.waitLeafer(() => {
319
- let { focusData } = this.app.interaction;
320
- if (value) {
321
- if (focusData)
322
- focusData.focus(false);
323
- focusData = this;
324
- }
325
- else
326
- focusData = null;
327
- this.app.interaction.focusData = focusData;
328
- value ? setPointerState(this, 'focusStyle') : unsetPointerState(this, 'focusStyle');
329
- });
330
- };
331
- ui$1.updateState = function () {
332
- core.State.updateStyle(this, undefined, 'in');
333
- };
334
-
335
- const gaussNodes = [0.1488743389, 0.4333953941, 0.6794095682, 0.8650633666, 0.9739065285];
336
- const gaussWeights = [0.2955242247, 0.2692667193, 0.2190863625, 0.1494513491, 0.0666713443];
337
- const { sqrt } = Math;
338
- const HighBezierHelper = {
339
- getDistance(fromX, fromY, x1, y1, x2, y2, toX, toY) {
340
- let distance = 0, t1, t2, d1X, d1Y, d2X, d2Y;
341
- for (let i = 0; i < gaussNodes.length; i++) {
342
- t1 = 0.5 * (1 + gaussNodes[i]);
343
- t2 = 0.5 * (1 - gaussNodes[i]);
344
- d1X = getDerivative(t1, fromX, x1, x2, toX);
345
- d1Y = getDerivative(t1, fromY, y1, y2, toY);
346
- d2X = getDerivative(t2, fromX, x1, x2, toX);
347
- d2Y = getDerivative(t2, fromY, y1, y2, toY);
348
- distance += gaussWeights[i] * (sqrt(d1X * d1X + d1Y * d1Y) + sqrt(d2X * d2X + d2Y * d2Y));
349
- }
350
- return distance * 0.5;
351
- },
352
- getDerivative(t, fromV, v1, v2, toV) {
353
- const o = 1 - t;
354
- return 3 * o * o * (v1 - fromV) + 6 * o * t * (v2 - v1) + 3 * t * t * (toV - v2);
355
- },
356
- cut(data, t, fromX, fromY, x1, y1, x2, y2, toX, toY) {
357
- const o = 1 - t;
358
- const ax = o * fromX + t * x1, ay = o * fromY + t * y1;
359
- const mbx = o * x1 + t * x2, mby = o * y1 + t * y2;
360
- const mcx = o * x2 + t * toX, mcy = o * y2 + t * toY;
361
- const bx = o * ax + t * mbx, by = o * ay + t * mby;
362
- const mbcx = o * mbx + t * mcx, mbcy = o * mby + t * mcy;
363
- const cx = o * bx + t * mbcx, cy = o * by + t * mbcy;
364
- data.push(draw.PathCommandMap.C, ax, ay, bx, by, cx, cy);
365
- }
366
- };
367
- const { getDerivative } = HighBezierHelper;
368
-
369
- const { M, L, C, Z } = draw.PathCommandMap;
370
- const tempPoint = {}, tempFrom = {};
371
- const HighCurveHelper = {
372
- transform(data, matrix) {
373
- let i = 0, command;
374
- const len = data.length;
375
- while (i < len) {
376
- command = data[i];
377
- switch (command) {
378
- case M:
379
- case L:
380
- HighCurveHelper.transformPoints(data, matrix, i, 1);
381
- i += 3;
382
- break;
383
- case C:
384
- HighCurveHelper.transformPoints(data, matrix, i, 3);
385
- i += 7;
386
- break;
387
- case Z:
388
- i += 1;
389
- }
390
- }
391
- },
392
- transformPoints(data, matrix, start, pointCount) {
393
- for (let i = start + 1, end = i + pointCount * 2; i < end; i += 2) {
394
- tempPoint.x = data[i];
395
- tempPoint.y = data[i + 1];
396
- draw.MatrixHelper.toOuterPoint(matrix, tempPoint);
397
- data[i] = tempPoint.x;
398
- data[i + 1] = tempPoint.y;
399
- }
400
- },
401
- getMotionPathData(data) {
402
- let total = 0, distance, segments = [];
403
- let i = 0, x = 0, y = 0, toX, toY, command;
404
- const len = data.length;
405
- while (i < len) {
406
- command = data[i];
407
- switch (command) {
408
- case M:
409
- case L:
410
- toX = data[i + 1];
411
- toY = data[i + 2];
412
- distance = (command === L && i > 0) ? draw.PointHelper.getDistanceFrom(x, y, toX, toY) : 0;
413
- x = toX;
414
- y = toY;
415
- i += 3;
416
- break;
417
- case C:
418
- toX = data[i + 5];
419
- toY = data[i + 6];
420
- distance = HighBezierHelper.getDistance(x, y, data[i + 1], data[i + 2], data[i + 3], data[i + 4], toX, toY);
421
- x = toX;
422
- y = toY;
423
- i += 7;
424
- break;
425
- case Z:
426
- i += 1;
427
- default:
428
- distance = 0;
429
- }
430
- segments.push(distance);
431
- total += distance;
432
- }
433
- return { total, segments, data };
434
- },
435
- getDistancePoint(distanceData, motionDistance) {
436
- const { segments, data } = distanceData;
437
- motionDistance = draw.UnitConvert.number(motionDistance, distanceData.total);
438
- let total = 0, distance, to = {};
439
- let i = 0, index = 0, x = 0, y = 0, toX, toY, command;
440
- const len = data.length;
441
- while (i < len) {
442
- command = data[i];
443
- switch (command) {
444
- case M:
445
- case L:
446
- toX = data[i + 1];
447
- toY = data[i + 2];
448
- distance = segments[index];
449
- if (total + distance > motionDistance || !distanceData.total) {
450
- if (!i)
451
- x = toX, y = toY;
452
- tempFrom.x = x;
453
- tempFrom.y = y;
454
- to.x = toX;
455
- to.y = toY;
456
- draw.PointHelper.getDistancePoint(tempFrom, to, motionDistance - total, true);
457
- to.rotation = draw.PointHelper.getAngle(tempFrom, to);
458
- return to;
459
- }
460
- x = toX;
461
- y = toY;
462
- i += 3;
463
- break;
464
- case C:
465
- toX = data[i + 5];
466
- toY = data[i + 6];
467
- distance = segments[index];
468
- if (total + distance > motionDistance) {
469
- const x1 = data[i + 1], y1 = data[i + 2], x2 = data[i + 3], y2 = data[i + 4];
470
- motionDistance -= total;
471
- draw.BezierHelper.getPointAndSet(motionDistance / distance, x, y, x1, y1, x2, y2, toX, toY, to);
472
- draw.BezierHelper.getPointAndSet(Math.max(0, motionDistance - 0.1) / distance, x, y, x1, y1, x2, y2, toX, toY, tempFrom);
473
- to.rotation = draw.PointHelper.getAngle(tempFrom, to);
474
- return to;
475
- }
476
- x = toX;
477
- y = toY;
478
- i += 7;
479
- break;
480
- case Z:
481
- i += 1;
482
- default:
483
- distance = 0;
484
- }
485
- index++;
486
- total += distance;
487
- }
488
- return to;
489
- },
490
- getDistancePath(distanceData, motionDistance) {
491
- const { segments, data } = distanceData, path = [];
492
- motionDistance = draw.UnitConvert.number(motionDistance, distanceData.total);
493
- let total = 0, distance, to = {};
494
- let i = 0, index = 0, x = 0, y = 0, toX, toY, command;
495
- const len = data.length;
496
- while (i < len) {
497
- command = data[i];
498
- switch (command) {
499
- case M:
500
- case L:
501
- toX = data[i + 1];
502
- toY = data[i + 2];
503
- distance = segments[index];
504
- if (total + distance > motionDistance || !distanceData.total) {
505
- if (!i)
506
- x = toX, y = toY;
507
- tempFrom.x = x;
508
- tempFrom.y = y;
509
- to.x = toX;
510
- to.y = toY;
511
- draw.PointHelper.getDistancePoint(tempFrom, to, motionDistance - total, true);
512
- path.push(command, to.x, to.y);
513
- return path;
514
- }
515
- x = toX;
516
- y = toY;
517
- i += 3;
518
- path.push(command, x, y);
519
- break;
520
- case C:
521
- const x1 = data[i + 1], y1 = data[i + 2], x2 = data[i + 3], y2 = data[i + 4];
522
- toX = data[i + 5];
523
- toY = data[i + 6];
524
- distance = segments[index];
525
- if (total + distance > motionDistance) {
526
- HighBezierHelper.cut(path, (motionDistance - total) / distance, x, y, x1, y1, x2, y2, toX, toY);
527
- return path;
528
- }
529
- x = toX;
530
- y = toY;
531
- i += 7;
532
- path.push(command, x1, y1, x2, y2, toX, toY);
533
- break;
534
- case Z:
535
- i += 1;
536
- path.push(command);
537
- default:
538
- distance = 0;
539
- }
540
- index++;
541
- total += distance;
542
- }
543
- return path;
544
- }
545
- };
546
-
547
- function motionPathType(defaultValue) {
548
- return draw.decorateLeafAttr(defaultValue, (key) => draw.attr({
549
- set(value) {
550
- this.__setAttr(key, value);
551
- this.__hasMotionPath = this.motionPath || !draw.isNull(this.motion);
552
- this.__layout.matrixChanged || this.__layout.matrixChange();
553
- }
554
- }));
555
- }
556
-
557
- draw.Transition.register('motion', function (from, to, t, target) {
558
- if (!from)
559
- from = 0;
560
- else if (typeof from === 'object')
561
- from = draw.UnitConvert.number(from, target.getMotionTotal());
562
- if (!to)
563
- to = 0;
564
- else if (typeof to === 'object')
565
- to = draw.UnitConvert.number(to, target.getMotionTotal());
566
- return draw.Transition.number(from, to, t);
567
- });
568
- draw.Transition.register('motionRotation', function (from, to, t) {
569
- return draw.Transition.number(from, to, t);
570
- });
571
- const ui = draw.UI.prototype;
572
- const { updateMatrix, updateAllMatrix } = draw.LeafHelper;
573
- const { updateBounds } = draw.BranchHelper;
574
- motionPathType()(ui, 'motionPath');
575
- motionPathType()(ui, 'motion');
576
- motionPathType(true)(ui, 'motionRotation');
577
- ui.getMotionPathData = function () {
578
- return getMotionPathData(getMotionPath(this));
579
- };
580
- ui.getMotionPoint = function (motionDistance) {
581
- const path = getMotionPath(this);
582
- const data = getMotionPathData(path);
583
- if (!data.total)
584
- return {};
585
- const point = HighCurveHelper.getDistancePoint(data, motionDistance);
586
- draw.MatrixHelper.toOuterPoint(path.localTransform, point);
587
- const { motionRotation } = this;
588
- if (motionRotation === false)
589
- delete point.rotation;
590
- else if (typeof motionRotation === 'number')
591
- point.rotation += motionRotation;
592
- return point;
593
- };
594
- ui.getMotionTotal = function () {
595
- return this.getMotionPathData().total;
596
- };
597
- ui.__updateMotionPath = function () {
598
- const data = this.__;
599
- if (this.__layout.resized && data.__pathForMotion)
600
- data.__pathForMotion = undefined;
601
- if (this.motionPath) {
602
- let child;
603
- const { children } = this.parent, { leaferIsReady } = this;
604
- for (let i = 0; i < children.length; i++) {
605
- child = children[i];
606
- if (!draw.isNull(child.motion) && !child.__layout.matrixChanged) {
607
- if (leaferIsReady && child !== this)
608
- this.leafer.layouter.addExtra(child);
609
- updateMotion(child);
610
- }
611
- }
612
- }
613
- else
614
- updateMotion(this);
615
- };
616
- function updateMotion(leaf) {
617
- const { motion, leaferIsCreated } = leaf;
618
- if (draw.isNull(motion))
619
- return;
620
- if (leaferIsCreated)
621
- leaf.leafer.created = false;
622
- if (leaf.motionPath) {
623
- const data = getMotionPathData(leaf);
624
- if (data.total)
625
- leaf.__.__pathForRender = HighCurveHelper.getDistancePath(data, motion);
626
- }
627
- else {
628
- leaf.set(leaf.getMotionPoint(motion));
629
- if (!leaf.__hasAutoLayout) {
630
- if (leaf.isBranch)
631
- updateAllMatrix(leaf), updateBounds(leaf, leaf);
632
- else
633
- updateMatrix(leaf);
634
- }
635
- }
636
- if (leaferIsCreated)
637
- leaf.leafer.created = true;
638
- }
639
- function getMotionPath(leaf) {
640
- const { parent } = leaf;
641
- if (!leaf.motionPath && parent) {
642
- const { children } = parent;
643
- for (let i = 0; i < children.length; i++) {
644
- if (children[i].motionPath)
645
- return children[i];
646
- }
647
- }
648
- return leaf;
649
- }
650
- function getMotionPathData(leaf) {
651
- const data = leaf.__;
652
- if (data.__pathForMotion)
653
- return data.__pathForMotion;
654
- return data.__pathForMotion = HighCurveHelper.getMotionPathData(leaf.getPath(true, true));
655
- }
7
+ var motionPath = require('@leafer-in/motion-path');
8
+ var core = require('@leafer/core');
656
9
 
657
10
  const systemInfo = wx.getSystemInfoSync();
658
11
  const platform = systemInfo.platform;
659
12
  if (platform === 'ios') {
660
- core$1.LeaferImage.prototype.getPattern = function (canvas, repeat, transform, paint) {
661
- const pattern = core$1.Platform.canvas.createPattern(this.view, repeat);
13
+ core.LeaferImage.prototype.getPattern = function (canvas, repeat, transform, paint) {
14
+ const pattern = core.Platform.canvas.createPattern(this.view, repeat);
662
15
  const { width, height } = canvas;
663
16
  if (this.width !== width || this.height !== height) {
664
17
  if (!transform)
665
- transform = core$1.MatrixHelper.get();
666
- core$1.MatrixHelper.scale(transform, width / this.width, height / this.height);
18
+ transform = core.MatrixHelper.get();
19
+ core.MatrixHelper.scale(transform, width / this.width, height / this.height);
667
20
  }
668
21
  try {
669
22
  if (transform && pattern.setTransform) {
@@ -678,11 +31,6 @@ if (platform === 'ios') {
678
31
  };
679
32
  }
680
33
 
681
- exports.HighBezierHelper = HighBezierHelper;
682
- exports.HighCurveHelper = HighCurveHelper;
683
- exports.motionPathType = motionPathType;
684
- exports.stateStyleType = stateStyleType;
685
- exports.stateType = stateType;
686
34
  Object.keys(miniapp).forEach(function (k) {
687
35
  if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
688
36
  enumerable: true,
@@ -695,9 +43,21 @@ Object.keys(robot).forEach(function (k) {
695
43
  get: function () { return robot[k]; }
696
44
  });
697
45
  });
46
+ Object.keys(state).forEach(function (k) {
47
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
48
+ enumerable: true,
49
+ get: function () { return state[k]; }
50
+ });
51
+ });
698
52
  Object.keys(animate).forEach(function (k) {
699
53
  if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
700
54
  enumerable: true,
701
55
  get: function () { return animate[k]; }
702
56
  });
703
57
  });
58
+ Object.keys(motionPath).forEach(function (k) {
59
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
60
+ enumerable: true,
61
+ get: function () { return motionPath[k]; }
62
+ });
63
+ });