@m2c2kit/core 0.3.8 → 0.3.10
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/README.md +18 -1
- package/assets/canvaskit.wasm +0 -0
- package/dist/index.d.ts +218 -53
- package/dist/index.js +1122 -598
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -8,6 +8,12 @@ var ActionType = /* @__PURE__ */ ((ActionType2) => {
|
|
|
8
8
|
return ActionType2;
|
|
9
9
|
})(ActionType || {});
|
|
10
10
|
|
|
11
|
+
var __defProp$k = Object.defineProperty;
|
|
12
|
+
var __defNormalProp$k = (obj, key, value) => key in obj ? __defProp$k(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
13
|
+
var __publicField$k = (obj, key, value) => {
|
|
14
|
+
__defNormalProp$k(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
15
|
+
return value;
|
|
16
|
+
};
|
|
11
17
|
class Easings {
|
|
12
18
|
}
|
|
13
19
|
// These easing functions are adapted from work by Robert Penner
|
|
@@ -26,125 +32,134 @@ class Easings {
|
|
|
26
32
|
// Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
27
33
|
// Neither the name of the author nor the names of contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
|
28
34
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
29
|
-
Easings
|
|
35
|
+
__publicField$k(Easings, "none", (t, b, c, d) => {
|
|
30
36
|
return c + b;
|
|
31
|
-
};
|
|
32
|
-
Easings
|
|
37
|
+
});
|
|
38
|
+
__publicField$k(Easings, "linear", (t, b, c, d) => {
|
|
33
39
|
return c * t / d + b;
|
|
34
|
-
};
|
|
35
|
-
Easings
|
|
40
|
+
});
|
|
41
|
+
__publicField$k(Easings, "quadraticIn", (t, b, c, d) => {
|
|
36
42
|
t /= d;
|
|
37
43
|
return c * t * t + b;
|
|
38
|
-
};
|
|
39
|
-
Easings
|
|
44
|
+
});
|
|
45
|
+
__publicField$k(Easings, "quadraticOut", (t, b, c, d) => {
|
|
40
46
|
t /= d;
|
|
41
47
|
return -c * t * (t - 2) + b;
|
|
42
|
-
};
|
|
43
|
-
Easings
|
|
48
|
+
});
|
|
49
|
+
__publicField$k(Easings, "quadraticInOut", (t, b, c, d) => {
|
|
44
50
|
t /= d / 2;
|
|
45
51
|
if (t < 1)
|
|
46
52
|
return c / 2 * t * t + b;
|
|
47
53
|
t--;
|
|
48
54
|
return -c / 2 * (t * (t - 2) - 1) + b;
|
|
49
|
-
};
|
|
50
|
-
Easings
|
|
55
|
+
});
|
|
56
|
+
__publicField$k(Easings, "cubicIn", (t, b, c, d) => {
|
|
51
57
|
t /= d;
|
|
52
58
|
return c * t * t * t + b;
|
|
53
|
-
};
|
|
54
|
-
Easings
|
|
59
|
+
});
|
|
60
|
+
__publicField$k(Easings, "cubicOut", (t, b, c, d) => {
|
|
55
61
|
t /= d;
|
|
56
62
|
t--;
|
|
57
63
|
return c * (t * t * t + 1) + b;
|
|
58
|
-
};
|
|
59
|
-
Easings
|
|
64
|
+
});
|
|
65
|
+
__publicField$k(Easings, "cubicInOut", (t, b, c, d) => {
|
|
60
66
|
t /= d / 2;
|
|
61
67
|
if (t < 1)
|
|
62
68
|
return c / 2 * t * t * t + b;
|
|
63
69
|
t -= 2;
|
|
64
70
|
return c / 2 * (t * t * t + 2) + b;
|
|
65
|
-
};
|
|
66
|
-
Easings
|
|
71
|
+
});
|
|
72
|
+
__publicField$k(Easings, "quarticIn", (t, b, c, d) => {
|
|
67
73
|
t /= d;
|
|
68
74
|
return c * t * t * t * t + b;
|
|
69
|
-
};
|
|
70
|
-
Easings
|
|
75
|
+
});
|
|
76
|
+
__publicField$k(Easings, "quarticOut", (t, b, c, d) => {
|
|
71
77
|
t /= d;
|
|
72
78
|
t--;
|
|
73
79
|
return -c * (t * t * t * t - 1) + b;
|
|
74
|
-
};
|
|
75
|
-
Easings
|
|
80
|
+
});
|
|
81
|
+
__publicField$k(Easings, "quarticInOut", (t, b, c, d) => {
|
|
76
82
|
t /= d / 2;
|
|
77
83
|
if (t < 1)
|
|
78
84
|
return c / 2 * t * t * t * t + b;
|
|
79
85
|
t -= 2;
|
|
80
86
|
return -c / 2 * (t * t * t * t - 2) + b;
|
|
81
|
-
};
|
|
82
|
-
Easings
|
|
87
|
+
});
|
|
88
|
+
__publicField$k(Easings, "quinticIn", (t, b, c, d) => {
|
|
83
89
|
t /= d;
|
|
84
90
|
return c * t * t * t * t * t + b;
|
|
85
|
-
};
|
|
86
|
-
Easings
|
|
91
|
+
});
|
|
92
|
+
__publicField$k(Easings, "quinticOut", (t, b, c, d) => {
|
|
87
93
|
t /= d;
|
|
88
94
|
t--;
|
|
89
95
|
return c * (t * t * t * t * t + 1) + b;
|
|
90
|
-
};
|
|
91
|
-
Easings
|
|
96
|
+
});
|
|
97
|
+
__publicField$k(Easings, "quinticInOut", (t, b, c, d) => {
|
|
92
98
|
t /= d / 2;
|
|
93
99
|
if (t < 1)
|
|
94
100
|
return c / 2 * t * t * t * t * t + b;
|
|
95
101
|
t -= 2;
|
|
96
102
|
return c / 2 * (t * t * t * t * t + 2) + b;
|
|
97
|
-
};
|
|
98
|
-
Easings
|
|
103
|
+
});
|
|
104
|
+
__publicField$k(Easings, "sinusoidalIn", (t, b, c, d) => {
|
|
99
105
|
return -c * Math.cos(t / d * (Math.PI / 2)) + c + b;
|
|
100
|
-
};
|
|
101
|
-
Easings
|
|
106
|
+
});
|
|
107
|
+
__publicField$k(Easings, "sinusoidalOut", (t, b, c, d) => {
|
|
102
108
|
return c * Math.sin(t / d * (Math.PI / 2)) + b;
|
|
103
|
-
};
|
|
104
|
-
Easings
|
|
109
|
+
});
|
|
110
|
+
__publicField$k(Easings, "sinusoidalInOut", (t, b, c, d) => {
|
|
105
111
|
return -c / 2 * (Math.cos(Math.PI * t / d) - 1) + b;
|
|
106
|
-
};
|
|
107
|
-
Easings
|
|
112
|
+
});
|
|
113
|
+
__publicField$k(Easings, "exponentialIn", (t, b, c, d) => {
|
|
108
114
|
return c * Math.pow(2, 10 * (t / d - 1)) + b;
|
|
109
|
-
};
|
|
110
|
-
Easings
|
|
115
|
+
});
|
|
116
|
+
__publicField$k(Easings, "exponentialOut", (t, b, c, d) => {
|
|
111
117
|
return c * (-Math.pow(2, -10 * t / d) + 1) + b;
|
|
112
|
-
};
|
|
113
|
-
Easings
|
|
118
|
+
});
|
|
119
|
+
__publicField$k(Easings, "exponentialInOut", (t, b, c, d) => {
|
|
114
120
|
t /= d / 2;
|
|
115
121
|
if (t < 1)
|
|
116
122
|
return c / 2 * Math.pow(2, 10 * (t - 1)) + b;
|
|
117
123
|
t--;
|
|
118
124
|
return c / 2 * (-Math.pow(2, -10 * t) + 2) + b;
|
|
119
|
-
};
|
|
120
|
-
Easings
|
|
125
|
+
});
|
|
126
|
+
__publicField$k(Easings, "circularIn", (t, b, c, d) => {
|
|
121
127
|
t /= d;
|
|
122
128
|
return -c * (Math.sqrt(1 - t * t) - 1) + b;
|
|
123
|
-
};
|
|
124
|
-
Easings
|
|
129
|
+
});
|
|
130
|
+
__publicField$k(Easings, "circularOut", (t, b, c, d) => {
|
|
125
131
|
t /= d;
|
|
126
132
|
t--;
|
|
127
133
|
return c * Math.sqrt(1 - t * t) + b;
|
|
128
|
-
};
|
|
129
|
-
Easings
|
|
134
|
+
});
|
|
135
|
+
__publicField$k(Easings, "circularInOut", (t, b, c, d) => {
|
|
130
136
|
t /= d / 2;
|
|
131
137
|
if (t < 1)
|
|
132
138
|
return -c / 2 * (Math.sqrt(1 - t * t) - 1) + b;
|
|
133
139
|
t -= 2;
|
|
134
140
|
return c / 2 * (Math.sqrt(1 - t * t) + 1) + b;
|
|
135
|
-
};
|
|
141
|
+
});
|
|
136
142
|
|
|
143
|
+
var __defProp$j = Object.defineProperty;
|
|
144
|
+
var __defNormalProp$j = (obj, key, value) => key in obj ? __defProp$j(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
145
|
+
var __publicField$j = (obj, key, value) => {
|
|
146
|
+
__defNormalProp$j(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
147
|
+
return value;
|
|
148
|
+
};
|
|
137
149
|
class Action {
|
|
138
150
|
constructor(runDuringTransition = false) {
|
|
139
|
-
this
|
|
140
|
-
this
|
|
141
|
-
this
|
|
142
|
-
this
|
|
143
|
-
this
|
|
144
|
-
this
|
|
145
|
-
this
|
|
146
|
-
this
|
|
147
|
-
this
|
|
151
|
+
__publicField$j(this, "startOffset", -1);
|
|
152
|
+
__publicField$j(this, "endOffset", -1);
|
|
153
|
+
__publicField$j(this, "started", false);
|
|
154
|
+
__publicField$j(this, "running", false);
|
|
155
|
+
__publicField$j(this, "completed", false);
|
|
156
|
+
__publicField$j(this, "runStartTime", -1);
|
|
157
|
+
__publicField$j(this, "duration", 0);
|
|
158
|
+
__publicField$j(this, "runDuringTransition");
|
|
159
|
+
__publicField$j(this, "parent");
|
|
160
|
+
__publicField$j(this, "isParent", false);
|
|
161
|
+
__publicField$j(this, "isChild", false);
|
|
162
|
+
__publicField$j(this, "key");
|
|
148
163
|
this.runDuringTransition = runDuringTransition;
|
|
149
164
|
}
|
|
150
165
|
/**
|
|
@@ -497,7 +512,8 @@ class Action {
|
|
|
497
512
|
class SequenceAction extends Action {
|
|
498
513
|
constructor(actions) {
|
|
499
514
|
super();
|
|
500
|
-
this
|
|
515
|
+
__publicField$j(this, "type", ActionType.Sequence);
|
|
516
|
+
__publicField$j(this, "children");
|
|
501
517
|
this.children = actions;
|
|
502
518
|
this.isParent = true;
|
|
503
519
|
}
|
|
@@ -505,8 +521,8 @@ class SequenceAction extends Action {
|
|
|
505
521
|
class GroupAction extends Action {
|
|
506
522
|
constructor(actions) {
|
|
507
523
|
super();
|
|
508
|
-
this
|
|
509
|
-
this
|
|
524
|
+
__publicField$j(this, "type", ActionType.Group);
|
|
525
|
+
__publicField$j(this, "children", new Array());
|
|
510
526
|
this.children = actions;
|
|
511
527
|
this.isParent = true;
|
|
512
528
|
}
|
|
@@ -514,7 +530,8 @@ class GroupAction extends Action {
|
|
|
514
530
|
class CustomAction extends Action {
|
|
515
531
|
constructor(callback, runDuringTransition = false) {
|
|
516
532
|
super(runDuringTransition);
|
|
517
|
-
this
|
|
533
|
+
__publicField$j(this, "type", ActionType.Custom);
|
|
534
|
+
__publicField$j(this, "callback");
|
|
518
535
|
this.callback = callback;
|
|
519
536
|
this.isParent = false;
|
|
520
537
|
this.duration = 0;
|
|
@@ -523,7 +540,7 @@ class CustomAction extends Action {
|
|
|
523
540
|
class WaitAction extends Action {
|
|
524
541
|
constructor(duration, runDuringTransition) {
|
|
525
542
|
super(runDuringTransition);
|
|
526
|
-
this
|
|
543
|
+
__publicField$j(this, "type", ActionType.Wait);
|
|
527
544
|
this.duration = duration;
|
|
528
545
|
this.isParent = false;
|
|
529
546
|
}
|
|
@@ -531,9 +548,12 @@ class WaitAction extends Action {
|
|
|
531
548
|
class MoveAction extends Action {
|
|
532
549
|
constructor(point, duration, easing, runDuringTransition) {
|
|
533
550
|
super(runDuringTransition);
|
|
534
|
-
this
|
|
535
|
-
this
|
|
536
|
-
this
|
|
551
|
+
__publicField$j(this, "type", ActionType.Move);
|
|
552
|
+
__publicField$j(this, "point");
|
|
553
|
+
__publicField$j(this, "startPoint");
|
|
554
|
+
__publicField$j(this, "dx", 0);
|
|
555
|
+
__publicField$j(this, "dy", 0);
|
|
556
|
+
__publicField$j(this, "easing");
|
|
537
557
|
this.duration = duration;
|
|
538
558
|
this.point = point;
|
|
539
559
|
this.isParent = false;
|
|
@@ -544,8 +564,9 @@ class MoveAction extends Action {
|
|
|
544
564
|
class ScaleAction extends Action {
|
|
545
565
|
constructor(scale, duration, runDuringTransition = false) {
|
|
546
566
|
super(runDuringTransition);
|
|
547
|
-
this
|
|
548
|
-
this
|
|
567
|
+
__publicField$j(this, "type", ActionType.Scale);
|
|
568
|
+
__publicField$j(this, "scale");
|
|
569
|
+
__publicField$j(this, "delta", 0);
|
|
549
570
|
this.duration = duration;
|
|
550
571
|
this.scale = scale;
|
|
551
572
|
this.isParent = false;
|
|
@@ -578,17 +599,23 @@ class CanvasKitHelpers {
|
|
|
578
599
|
}
|
|
579
600
|
}
|
|
580
601
|
|
|
602
|
+
var __defProp$i = Object.defineProperty;
|
|
603
|
+
var __defNormalProp$i = (obj, key, value) => key in obj ? __defProp$i(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
604
|
+
var __publicField$i = (obj, key, value) => {
|
|
605
|
+
__defNormalProp$i(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
606
|
+
return value;
|
|
607
|
+
};
|
|
581
608
|
class GlobalVariables {
|
|
582
609
|
constructor() {
|
|
583
|
-
this
|
|
584
|
-
this
|
|
585
|
-
this
|
|
610
|
+
__publicField$i(this, "now", NaN);
|
|
611
|
+
__publicField$i(this, "deltaTime", NaN);
|
|
612
|
+
__publicField$i(this, "canvasScale", NaN);
|
|
586
613
|
// _rootScale is the scaling factor to be applied to scenes to scale up or
|
|
587
614
|
// down to fit the device's window while preserving the aspect ratio the
|
|
588
615
|
// game was designed for
|
|
589
|
-
this
|
|
590
|
-
this
|
|
591
|
-
this
|
|
616
|
+
__publicField$i(this, "rootScale", 1);
|
|
617
|
+
__publicField$i(this, "canvasCssWidth", NaN);
|
|
618
|
+
__publicField$i(this, "canvasCssHeight", NaN);
|
|
592
619
|
}
|
|
593
620
|
}
|
|
594
621
|
|
|
@@ -610,8 +637,20 @@ var ConstraintType = /* @__PURE__ */ ((ConstraintType2) => {
|
|
|
610
637
|
return ConstraintType2;
|
|
611
638
|
})(ConstraintType || {});
|
|
612
639
|
|
|
640
|
+
var __defProp$h = Object.defineProperty;
|
|
641
|
+
var __defNormalProp$h = (obj, key, value) => key in obj ? __defProp$h(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
642
|
+
var __publicField$h = (obj, key, value) => {
|
|
643
|
+
__defNormalProp$h(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
644
|
+
return value;
|
|
645
|
+
};
|
|
613
646
|
class LayoutConstraint {
|
|
614
647
|
constructor(type, alterEntity) {
|
|
648
|
+
// the constraint, e.g., bottomToTopOf
|
|
649
|
+
__publicField$h(this, "type");
|
|
650
|
+
// alter is the other entity that the focal entity is constrained to.
|
|
651
|
+
// in the example above, A is the focal entity, B is the alter
|
|
652
|
+
// thus the alter entity property is B
|
|
653
|
+
__publicField$h(this, "alterEntity");
|
|
615
654
|
// the below 3 properties are calculated from the constraint type
|
|
616
655
|
// (we set them to false by default to avoid undefined warnings, but
|
|
617
656
|
// they will be definitely assigned in the constructor logic)
|
|
@@ -619,37 +658,37 @@ class LayoutConstraint {
|
|
|
619
658
|
//
|
|
620
659
|
// does the constraint affect the Y or X axis? If not, then it's
|
|
621
660
|
// a horizontal constraint
|
|
622
|
-
this
|
|
661
|
+
__publicField$h(this, "verticalConstraint", false);
|
|
623
662
|
// does the constraint apply to the focal entity's "minimum" position
|
|
624
663
|
// along its axis? That is, does the constraint reference the focal
|
|
625
664
|
// entity's "top" or "start"? Top and start are considered minimums because
|
|
626
665
|
// our origin (0, 0) in the upper left.
|
|
627
666
|
// If not, then the constraint applies to the focal entity's "maximum"
|
|
628
667
|
// position, e.g., its "bottom" or "end".
|
|
629
|
-
this
|
|
668
|
+
__publicField$h(this, "focalEntityMinimum", false);
|
|
630
669
|
// does the constraint apply to the alter entity's "minimum" position
|
|
631
670
|
// along its axis?
|
|
632
|
-
this
|
|
633
|
-
this
|
|
671
|
+
__publicField$h(this, "alterEntityMinimum", false);
|
|
672
|
+
__publicField$h(this, "verticalTypes", [
|
|
634
673
|
ConstraintType.topToTopOf,
|
|
635
674
|
ConstraintType.topToBottomOf,
|
|
636
675
|
ConstraintType.bottomToTopOf,
|
|
637
676
|
ConstraintType.bottomToBottomOf
|
|
638
|
-
];
|
|
677
|
+
]);
|
|
639
678
|
// e.g., entity A
|
|
640
|
-
this
|
|
679
|
+
__publicField$h(this, "focalEntityMinimumTypes", [
|
|
641
680
|
ConstraintType.topToTopOf,
|
|
642
681
|
ConstraintType.topToBottomOf,
|
|
643
682
|
ConstraintType.startToStartOf,
|
|
644
683
|
ConstraintType.startToEndOf
|
|
645
|
-
];
|
|
684
|
+
]);
|
|
646
685
|
// e.g., entity B
|
|
647
|
-
this
|
|
686
|
+
__publicField$h(this, "alterEntityMinimumTypes", [
|
|
648
687
|
ConstraintType.topToTopOf,
|
|
649
688
|
ConstraintType.bottomToTopOf,
|
|
650
689
|
ConstraintType.startToStartOf,
|
|
651
690
|
ConstraintType.endToStartOf
|
|
652
|
-
];
|
|
691
|
+
]);
|
|
653
692
|
this.type = type;
|
|
654
693
|
this.alterEntity = alterEntity;
|
|
655
694
|
if (this.verticalTypes.includes(type)) {
|
|
@@ -732,6 +771,12 @@ var EventType = /* @__PURE__ */ ((EventType2) => {
|
|
|
732
771
|
return EventType2;
|
|
733
772
|
})(EventType || {});
|
|
734
773
|
|
|
774
|
+
var __defProp$g = Object.defineProperty;
|
|
775
|
+
var __defNormalProp$g = (obj, key, value) => key in obj ? __defProp$g(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
776
|
+
var __publicField$g = (obj, key, value) => {
|
|
777
|
+
__defNormalProp$g(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
778
|
+
return value;
|
|
779
|
+
};
|
|
735
780
|
function handleDrawableOptions(drawable, options) {
|
|
736
781
|
if (options.anchorPoint) {
|
|
737
782
|
drawable.anchorPoint = options.anchorPoint;
|
|
@@ -767,60 +812,69 @@ function handleInterfaceOptions(entity, options) {
|
|
|
767
812
|
}
|
|
768
813
|
class Entity {
|
|
769
814
|
constructor(options = {}) {
|
|
770
|
-
this
|
|
771
|
-
this
|
|
772
|
-
this
|
|
773
|
-
this
|
|
774
|
-
|
|
815
|
+
__publicField$g(this, "type", EntityType.Entity);
|
|
816
|
+
__publicField$g(this, "isDrawable", false);
|
|
817
|
+
__publicField$g(this, "isShape", false);
|
|
818
|
+
__publicField$g(this, "isText", false);
|
|
819
|
+
// Entity Options
|
|
820
|
+
__publicField$g(this, "name");
|
|
821
|
+
__publicField$g(this, "position", { x: 0, y: 0 });
|
|
775
822
|
// position of the entity in the parent coordinate system
|
|
776
|
-
this
|
|
777
|
-
this
|
|
778
|
-
this
|
|
779
|
-
this
|
|
780
|
-
this
|
|
781
|
-
this
|
|
782
|
-
this
|
|
823
|
+
__publicField$g(this, "scale", 1);
|
|
824
|
+
__publicField$g(this, "isUserInteractionEnabled", false);
|
|
825
|
+
__publicField$g(this, "draggable", false);
|
|
826
|
+
__publicField$g(this, "hidden", false);
|
|
827
|
+
__publicField$g(this, "layout", {});
|
|
828
|
+
__publicField$g(this, "_game");
|
|
829
|
+
__publicField$g(this, "parent");
|
|
830
|
+
__publicField$g(this, "children", new Array());
|
|
831
|
+
__publicField$g(this, "absolutePosition", { x: 0, y: 0 });
|
|
783
832
|
// position within the root coordinate system
|
|
784
|
-
this
|
|
785
|
-
this
|
|
786
|
-
this
|
|
787
|
-
this
|
|
788
|
-
this
|
|
789
|
-
this
|
|
790
|
-
this
|
|
833
|
+
__publicField$g(this, "size", { width: 0, height: 0 });
|
|
834
|
+
__publicField$g(this, "absoluteScale", 1);
|
|
835
|
+
__publicField$g(this, "actions", new Array());
|
|
836
|
+
__publicField$g(this, "queuedAction");
|
|
837
|
+
__publicField$g(this, "originalActions", new Array());
|
|
838
|
+
__publicField$g(this, "eventListeners", new Array());
|
|
839
|
+
__publicField$g(this, "uuid", Uuid.generate());
|
|
840
|
+
__publicField$g(this, "needsInitialization", true);
|
|
791
841
|
// library users might put anything in userData property
|
|
792
842
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
793
|
-
this
|
|
794
|
-
this
|
|
843
|
+
__publicField$g(this, "userData", {});
|
|
844
|
+
__publicField$g(this, "loopMessages", /* @__PURE__ */ new Set());
|
|
795
845
|
/** Is the entity in a pressed state? E.g., did the user put the pointer
|
|
796
846
|
* down on the entity and not yet release it? */
|
|
797
|
-
this
|
|
847
|
+
__publicField$g(this, "pressed", false);
|
|
798
848
|
/** Is the entity in a pressed state AND is the pointer within the entity's
|
|
799
849
|
* hit area? For example, a user may put the pointer down on the entity, but
|
|
800
850
|
* then move the pointer, while still down, beyond the entity's hit area. In
|
|
801
851
|
* this case, pressed = true, but pressedAndWithinHitArea = false. */
|
|
802
|
-
this
|
|
852
|
+
__publicField$g(this, "pressedAndWithinHitArea", false);
|
|
803
853
|
/** When the entity initially enters the pressed state, what is the pointer
|
|
804
854
|
* offset? (offset from the canvas's origin to the pointer position). We
|
|
805
855
|
* save this because it will be needed if this press then led to a drag. */
|
|
806
|
-
this
|
|
856
|
+
__publicField$g(this, "pressedInitialPointerOffset", { x: NaN, y: NaN });
|
|
807
857
|
/** What was the previous pointer offset when the entity was in a dragging
|
|
808
858
|
* state? */
|
|
809
|
-
this
|
|
859
|
+
__publicField$g(this, "draggingLastPointerOffset", { x: NaN, y: NaN });
|
|
810
860
|
/** Is the entity in a dragging state? */
|
|
811
|
-
this
|
|
861
|
+
__publicField$g(this, "dragging", false);
|
|
812
862
|
/**
|
|
813
863
|
* Overrides toString() and returns a human-friendly description of the entity.
|
|
814
864
|
*
|
|
815
865
|
* @remarks Inspiration from https://stackoverflow.com/a/35361695
|
|
816
866
|
*/
|
|
817
|
-
this
|
|
867
|
+
__publicField$g(this, "toString", () => {
|
|
868
|
+
let type = this.type.toString();
|
|
869
|
+
if (this.type == EntityType.Composite) {
|
|
870
|
+
type = this.compositeType;
|
|
871
|
+
}
|
|
818
872
|
if (this.name !== this.uuid) {
|
|
819
|
-
return `"${this.name}" (${
|
|
873
|
+
return `"${this.name}" (${type}, ${this.uuid})`;
|
|
820
874
|
} else {
|
|
821
|
-
return `"${
|
|
875
|
+
return `"${type} (${this.uuid})`;
|
|
822
876
|
}
|
|
823
|
-
};
|
|
877
|
+
});
|
|
824
878
|
if (options.name === void 0) {
|
|
825
879
|
this.name = this.uuid;
|
|
826
880
|
} else {
|
|
@@ -1020,11 +1074,11 @@ class Entity {
|
|
|
1020
1074
|
* ones. It is strongly recommended not to change this, unless you have a
|
|
1021
1075
|
* special use case. Default is true.
|
|
1022
1076
|
*/
|
|
1023
|
-
onTapDown(callback,
|
|
1077
|
+
onTapDown(callback, callbackOptions) {
|
|
1024
1078
|
this.addEventListener(
|
|
1025
1079
|
EventType.TapDown,
|
|
1026
1080
|
callback,
|
|
1027
|
-
|
|
1081
|
+
callbackOptions
|
|
1028
1082
|
);
|
|
1029
1083
|
}
|
|
1030
1084
|
/**
|
|
@@ -1042,11 +1096,11 @@ class Entity {
|
|
|
1042
1096
|
* ones. It is strongly recommended not to change this, unless you have a
|
|
1043
1097
|
* special use case. Default is true.
|
|
1044
1098
|
*/
|
|
1045
|
-
onTapUp(callback,
|
|
1099
|
+
onTapUp(callback, callbackOptions) {
|
|
1046
1100
|
this.addEventListener(
|
|
1047
1101
|
EventType.TapUp,
|
|
1048
1102
|
callback,
|
|
1049
|
-
|
|
1103
|
+
callbackOptions
|
|
1050
1104
|
);
|
|
1051
1105
|
}
|
|
1052
1106
|
/**
|
|
@@ -1065,11 +1119,11 @@ class Entity {
|
|
|
1065
1119
|
* ones. It is strongly recommended not to change this, unless you have a
|
|
1066
1120
|
* special use case. Default is true.
|
|
1067
1121
|
*/
|
|
1068
|
-
onTapUpAny(callback,
|
|
1122
|
+
onTapUpAny(callback, callbackOptions) {
|
|
1069
1123
|
this.addEventListener(
|
|
1070
1124
|
EventType.TapUpAny,
|
|
1071
1125
|
callback,
|
|
1072
|
-
|
|
1126
|
+
callbackOptions
|
|
1073
1127
|
);
|
|
1074
1128
|
}
|
|
1075
1129
|
/**
|
|
@@ -1087,11 +1141,11 @@ class Entity {
|
|
|
1087
1141
|
* ones. It is strongly recommended not to change this, unless you have a
|
|
1088
1142
|
* special use case. Default is true.
|
|
1089
1143
|
*/
|
|
1090
|
-
onTapLeave(callback,
|
|
1144
|
+
onTapLeave(callback, callbackOptions) {
|
|
1091
1145
|
this.addEventListener(
|
|
1092
1146
|
EventType.TapLeave,
|
|
1093
1147
|
callback,
|
|
1094
|
-
|
|
1148
|
+
callbackOptions
|
|
1095
1149
|
);
|
|
1096
1150
|
}
|
|
1097
1151
|
/**
|
|
@@ -1107,11 +1161,11 @@ class Entity {
|
|
|
1107
1161
|
* ones. It is strongly recommended not to change this, unless you have a
|
|
1108
1162
|
* special use case. Default is true.
|
|
1109
1163
|
*/
|
|
1110
|
-
onPointerDown(callback,
|
|
1164
|
+
onPointerDown(callback, callbackOptions) {
|
|
1111
1165
|
this.addEventListener(
|
|
1112
1166
|
EventType.PointerDown,
|
|
1113
1167
|
callback,
|
|
1114
|
-
|
|
1168
|
+
callbackOptions
|
|
1115
1169
|
);
|
|
1116
1170
|
}
|
|
1117
1171
|
/**
|
|
@@ -1129,11 +1183,11 @@ class Entity {
|
|
|
1129
1183
|
* ones. It is strongly recommended not to change this, unless you have a
|
|
1130
1184
|
* special use case. Default is true.
|
|
1131
1185
|
*/
|
|
1132
|
-
onPointerUp(callback,
|
|
1186
|
+
onPointerUp(callback, callbackOptions) {
|
|
1133
1187
|
this.addEventListener(
|
|
1134
1188
|
EventType.PointerUp,
|
|
1135
1189
|
callback,
|
|
1136
|
-
|
|
1190
|
+
callbackOptions
|
|
1137
1191
|
);
|
|
1138
1192
|
}
|
|
1139
1193
|
/**
|
|
@@ -1147,11 +1201,11 @@ class Entity {
|
|
|
1147
1201
|
* ones. It is strongly recommended not to change this, unless you have a
|
|
1148
1202
|
* special use case. Default is true.
|
|
1149
1203
|
*/
|
|
1150
|
-
onPointerMove(callback,
|
|
1204
|
+
onPointerMove(callback, callbackOptions) {
|
|
1151
1205
|
this.addEventListener(
|
|
1152
1206
|
EventType.PointerMove,
|
|
1153
1207
|
callback,
|
|
1154
|
-
|
|
1208
|
+
callbackOptions
|
|
1155
1209
|
);
|
|
1156
1210
|
}
|
|
1157
1211
|
/**
|
|
@@ -1164,11 +1218,11 @@ class Entity {
|
|
|
1164
1218
|
* ones. It is strongly recommended not to change this, unless you have a
|
|
1165
1219
|
* special use case. Default is true.
|
|
1166
1220
|
*/
|
|
1167
|
-
onDragStart(callback,
|
|
1221
|
+
onDragStart(callback, callbackOptions) {
|
|
1168
1222
|
this.addEventListener(
|
|
1169
1223
|
EventType.DragStart,
|
|
1170
1224
|
callback,
|
|
1171
|
-
|
|
1225
|
+
callbackOptions
|
|
1172
1226
|
);
|
|
1173
1227
|
}
|
|
1174
1228
|
/**
|
|
@@ -1181,11 +1235,11 @@ class Entity {
|
|
|
1181
1235
|
* ones. It is strongly recommended not to change this, unless you have a
|
|
1182
1236
|
* special use case. Default is true.
|
|
1183
1237
|
*/
|
|
1184
|
-
onDrag(callback,
|
|
1238
|
+
onDrag(callback, callbackOptions) {
|
|
1185
1239
|
this.addEventListener(
|
|
1186
1240
|
EventType.Drag,
|
|
1187
1241
|
callback,
|
|
1188
|
-
|
|
1242
|
+
callbackOptions
|
|
1189
1243
|
);
|
|
1190
1244
|
}
|
|
1191
1245
|
/**
|
|
@@ -1198,24 +1252,29 @@ class Entity {
|
|
|
1198
1252
|
* ones. It is strongly recommended not to change this, unless you have a
|
|
1199
1253
|
* special use case. Default is true.
|
|
1200
1254
|
*/
|
|
1201
|
-
onDragEnd(callback,
|
|
1255
|
+
onDragEnd(callback, callbackOptions) {
|
|
1202
1256
|
this.addEventListener(
|
|
1203
1257
|
EventType.DragEnd,
|
|
1204
1258
|
callback,
|
|
1205
|
-
|
|
1259
|
+
callbackOptions
|
|
1206
1260
|
);
|
|
1207
1261
|
}
|
|
1208
|
-
addEventListener(type, callback,
|
|
1262
|
+
addEventListener(type, callback, callbackOptions) {
|
|
1209
1263
|
const eventListener = {
|
|
1210
1264
|
type,
|
|
1211
1265
|
entityUuid: this.uuid,
|
|
1212
1266
|
callback
|
|
1213
1267
|
};
|
|
1214
|
-
if (
|
|
1268
|
+
if (callbackOptions == null ? void 0 : callbackOptions.replaceExisting) {
|
|
1215
1269
|
this.eventListeners = this.eventListeners.filter(
|
|
1216
1270
|
(listener) => !(listener.entityUuid === eventListener.entityUuid && listener.type === eventListener.type)
|
|
1217
1271
|
);
|
|
1218
1272
|
}
|
|
1273
|
+
if (this.eventListeners.some((listener) => listener.type == type)) {
|
|
1274
|
+
console.warn(
|
|
1275
|
+
`game {${this.game.id}}: listener for event ${type} has already been added to this entity {${this}}. This is usually not intended.`
|
|
1276
|
+
);
|
|
1277
|
+
}
|
|
1219
1278
|
this.eventListeners.push(eventListener);
|
|
1220
1279
|
}
|
|
1221
1280
|
parseLayoutConstraints(constraints, allGameEntities) {
|
|
@@ -1590,6 +1649,12 @@ class Entity {
|
|
|
1590
1649
|
}
|
|
1591
1650
|
}
|
|
1592
1651
|
|
|
1652
|
+
var __defProp$f = Object.defineProperty;
|
|
1653
|
+
var __defNormalProp$f = (obj, key, value) => key in obj ? __defProp$f(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1654
|
+
var __publicField$f = (obj, key, value) => {
|
|
1655
|
+
__defNormalProp$f(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1656
|
+
return value;
|
|
1657
|
+
};
|
|
1593
1658
|
class Composite extends Entity {
|
|
1594
1659
|
/**
|
|
1595
1660
|
* Base Drawable object for creating custom entities ("composites") composed of primitive entities.
|
|
@@ -1598,12 +1663,12 @@ class Composite extends Entity {
|
|
|
1598
1663
|
*/
|
|
1599
1664
|
constructor(options = {}) {
|
|
1600
1665
|
super(options);
|
|
1601
|
-
this
|
|
1602
|
-
this
|
|
1603
|
-
this
|
|
1666
|
+
__publicField$f(this, "type", EntityType.Composite);
|
|
1667
|
+
__publicField$f(this, "compositeType", "<compositeType>");
|
|
1668
|
+
__publicField$f(this, "isDrawable", true);
|
|
1604
1669
|
// Drawable options
|
|
1605
|
-
this
|
|
1606
|
-
this
|
|
1670
|
+
__publicField$f(this, "anchorPoint", { x: 0.5, y: 0.5 });
|
|
1671
|
+
__publicField$f(this, "zPosition", 0);
|
|
1607
1672
|
handleInterfaceOptions(this, options);
|
|
1608
1673
|
}
|
|
1609
1674
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
@@ -1620,180 +1685,193 @@ class Composite extends Entity {
|
|
|
1620
1685
|
}
|
|
1621
1686
|
}
|
|
1622
1687
|
|
|
1688
|
+
var __defProp$e = Object.defineProperty;
|
|
1689
|
+
var __defNormalProp$e = (obj, key, value) => key in obj ? __defProp$e(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1690
|
+
var __publicField$e = (obj, key, value) => {
|
|
1691
|
+
__defNormalProp$e(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1692
|
+
return value;
|
|
1693
|
+
};
|
|
1623
1694
|
class WebColors {
|
|
1624
1695
|
}
|
|
1625
|
-
WebColors
|
|
1626
|
-
WebColors
|
|
1627
|
-
WebColors
|
|
1628
|
-
WebColors
|
|
1629
|
-
WebColors
|
|
1630
|
-
WebColors
|
|
1631
|
-
WebColors
|
|
1632
|
-
WebColors
|
|
1633
|
-
WebColors
|
|
1634
|
-
WebColors
|
|
1635
|
-
WebColors
|
|
1636
|
-
WebColors
|
|
1637
|
-
WebColors
|
|
1638
|
-
WebColors
|
|
1639
|
-
WebColors
|
|
1640
|
-
WebColors
|
|
1641
|
-
WebColors
|
|
1642
|
-
WebColors
|
|
1643
|
-
WebColors
|
|
1644
|
-
WebColors
|
|
1645
|
-
WebColors
|
|
1646
|
-
WebColors
|
|
1647
|
-
WebColors
|
|
1648
|
-
WebColors
|
|
1649
|
-
WebColors
|
|
1650
|
-
WebColors
|
|
1651
|
-
WebColors
|
|
1652
|
-
WebColors
|
|
1653
|
-
WebColors
|
|
1654
|
-
WebColors
|
|
1655
|
-
WebColors
|
|
1656
|
-
WebColors
|
|
1657
|
-
WebColors
|
|
1658
|
-
WebColors
|
|
1659
|
-
WebColors
|
|
1660
|
-
WebColors
|
|
1661
|
-
WebColors
|
|
1662
|
-
WebColors
|
|
1663
|
-
WebColors
|
|
1664
|
-
WebColors
|
|
1665
|
-
WebColors
|
|
1666
|
-
WebColors
|
|
1667
|
-
WebColors
|
|
1668
|
-
WebColors
|
|
1669
|
-
WebColors
|
|
1670
|
-
WebColors
|
|
1671
|
-
WebColors
|
|
1672
|
-
WebColors
|
|
1673
|
-
WebColors
|
|
1674
|
-
WebColors
|
|
1675
|
-
WebColors
|
|
1676
|
-
WebColors
|
|
1677
|
-
WebColors
|
|
1678
|
-
WebColors
|
|
1679
|
-
WebColors
|
|
1680
|
-
WebColors
|
|
1681
|
-
WebColors
|
|
1682
|
-
WebColors
|
|
1683
|
-
WebColors
|
|
1684
|
-
WebColors
|
|
1685
|
-
WebColors
|
|
1686
|
-
WebColors
|
|
1687
|
-
WebColors
|
|
1688
|
-
WebColors
|
|
1689
|
-
WebColors
|
|
1690
|
-
WebColors
|
|
1691
|
-
WebColors
|
|
1692
|
-
WebColors
|
|
1693
|
-
WebColors
|
|
1694
|
-
WebColors
|
|
1695
|
-
WebColors
|
|
1696
|
-
WebColors
|
|
1697
|
-
WebColors
|
|
1698
|
-
WebColors
|
|
1699
|
-
WebColors
|
|
1700
|
-
WebColors
|
|
1701
|
-
WebColors
|
|
1702
|
-
WebColors
|
|
1703
|
-
WebColors
|
|
1704
|
-
WebColors
|
|
1705
|
-
WebColors
|
|
1706
|
-
WebColors
|
|
1707
|
-
WebColors
|
|
1708
|
-
WebColors
|
|
1709
|
-
WebColors
|
|
1710
|
-
WebColors
|
|
1711
|
-
WebColors
|
|
1712
|
-
WebColors
|
|
1713
|
-
WebColors
|
|
1714
|
-
WebColors
|
|
1715
|
-
WebColors
|
|
1716
|
-
WebColors
|
|
1717
|
-
WebColors
|
|
1718
|
-
WebColors
|
|
1719
|
-
WebColors
|
|
1720
|
-
WebColors
|
|
1721
|
-
WebColors
|
|
1722
|
-
WebColors
|
|
1723
|
-
WebColors
|
|
1724
|
-
WebColors
|
|
1725
|
-
WebColors
|
|
1726
|
-
WebColors
|
|
1727
|
-
WebColors
|
|
1728
|
-
WebColors
|
|
1729
|
-
WebColors
|
|
1730
|
-
WebColors
|
|
1731
|
-
WebColors
|
|
1732
|
-
WebColors
|
|
1733
|
-
WebColors
|
|
1734
|
-
WebColors
|
|
1735
|
-
WebColors
|
|
1736
|
-
WebColors
|
|
1737
|
-
WebColors
|
|
1738
|
-
WebColors
|
|
1739
|
-
WebColors
|
|
1740
|
-
WebColors
|
|
1741
|
-
WebColors
|
|
1742
|
-
WebColors
|
|
1743
|
-
WebColors
|
|
1744
|
-
WebColors
|
|
1745
|
-
WebColors
|
|
1746
|
-
WebColors
|
|
1747
|
-
WebColors
|
|
1748
|
-
WebColors
|
|
1749
|
-
WebColors
|
|
1750
|
-
WebColors
|
|
1751
|
-
WebColors
|
|
1752
|
-
WebColors
|
|
1753
|
-
WebColors
|
|
1754
|
-
WebColors
|
|
1755
|
-
WebColors
|
|
1756
|
-
WebColors
|
|
1757
|
-
WebColors
|
|
1758
|
-
WebColors
|
|
1759
|
-
WebColors
|
|
1760
|
-
WebColors
|
|
1761
|
-
WebColors
|
|
1762
|
-
WebColors
|
|
1763
|
-
WebColors
|
|
1764
|
-
WebColors
|
|
1765
|
-
WebColors
|
|
1766
|
-
WebColors
|
|
1696
|
+
__publicField$e(WebColors, "Transparent", [0, 0, 0, 0]);
|
|
1697
|
+
__publicField$e(WebColors, "MediumVioletRed", [199, 21, 133, 1]);
|
|
1698
|
+
__publicField$e(WebColors, "DeepPink", [255, 20, 147, 1]);
|
|
1699
|
+
__publicField$e(WebColors, "PaleVioletRed", [219, 112, 147, 1]);
|
|
1700
|
+
__publicField$e(WebColors, "HotPink", [255, 105, 180, 1]);
|
|
1701
|
+
__publicField$e(WebColors, "LightPink", [255, 182, 193, 1]);
|
|
1702
|
+
__publicField$e(WebColors, "Pink", [255, 192, 203, 1]);
|
|
1703
|
+
__publicField$e(WebColors, "DarkRed", [139, 0, 0, 1]);
|
|
1704
|
+
__publicField$e(WebColors, "Red", [255, 0, 0, 1]);
|
|
1705
|
+
__publicField$e(WebColors, "Firebrick", [178, 34, 34, 1]);
|
|
1706
|
+
__publicField$e(WebColors, "Crimson", [220, 20, 60, 1]);
|
|
1707
|
+
__publicField$e(WebColors, "IndianRed", [205, 92, 92, 1]);
|
|
1708
|
+
__publicField$e(WebColors, "LightCoral", [240, 128, 128, 1]);
|
|
1709
|
+
__publicField$e(WebColors, "Salmon", [250, 128, 114, 1]);
|
|
1710
|
+
__publicField$e(WebColors, "DarkSalmon", [233, 150, 122, 1]);
|
|
1711
|
+
__publicField$e(WebColors, "LightSalmon", [255, 160, 122, 1]);
|
|
1712
|
+
__publicField$e(WebColors, "OrangeRed", [255, 69, 0, 1]);
|
|
1713
|
+
__publicField$e(WebColors, "Tomato", [255, 99, 71, 1]);
|
|
1714
|
+
__publicField$e(WebColors, "DarkOrange", [255, 140, 0, 1]);
|
|
1715
|
+
__publicField$e(WebColors, "Coral", [255, 127, 80, 1]);
|
|
1716
|
+
__publicField$e(WebColors, "Orange", [255, 165, 0, 1]);
|
|
1717
|
+
__publicField$e(WebColors, "DarkKhaki", [189, 183, 107, 1]);
|
|
1718
|
+
__publicField$e(WebColors, "Gold", [255, 215, 0, 1]);
|
|
1719
|
+
__publicField$e(WebColors, "Khaki", [240, 230, 140, 1]);
|
|
1720
|
+
__publicField$e(WebColors, "PeachPuff", [255, 218, 185, 1]);
|
|
1721
|
+
__publicField$e(WebColors, "Yellow", [255, 255, 0, 1]);
|
|
1722
|
+
__publicField$e(WebColors, "PaleGoldenrod", [238, 232, 170, 1]);
|
|
1723
|
+
__publicField$e(WebColors, "Moccasin", [255, 228, 181, 1]);
|
|
1724
|
+
__publicField$e(WebColors, "PapayaWhip", [255, 239, 213, 1]);
|
|
1725
|
+
__publicField$e(WebColors, "LightGoldenrodYellow", [250, 250, 210, 1]);
|
|
1726
|
+
__publicField$e(WebColors, "LemonChiffon", [255, 250, 205, 1]);
|
|
1727
|
+
__publicField$e(WebColors, "LightYellow", [255, 255, 224, 1]);
|
|
1728
|
+
__publicField$e(WebColors, "Maroon", [128, 0, 0, 1]);
|
|
1729
|
+
__publicField$e(WebColors, "Brown", [165, 42, 42, 1]);
|
|
1730
|
+
__publicField$e(WebColors, "SaddleBrown", [139, 69, 19, 1]);
|
|
1731
|
+
__publicField$e(WebColors, "Sienna", [160, 82, 45, 1]);
|
|
1732
|
+
__publicField$e(WebColors, "Chocolate", [210, 105, 30, 1]);
|
|
1733
|
+
__publicField$e(WebColors, "DarkGoldenrod", [184, 134, 11, 1]);
|
|
1734
|
+
__publicField$e(WebColors, "Peru", [205, 133, 63, 1]);
|
|
1735
|
+
__publicField$e(WebColors, "RosyBrown", [188, 143, 143, 1]);
|
|
1736
|
+
__publicField$e(WebColors, "Goldenrod", [218, 165, 32, 1]);
|
|
1737
|
+
__publicField$e(WebColors, "SandyBrown", [244, 164, 96, 1]);
|
|
1738
|
+
__publicField$e(WebColors, "Tan", [210, 180, 140, 1]);
|
|
1739
|
+
__publicField$e(WebColors, "Burlywood", [222, 184, 135, 1]);
|
|
1740
|
+
__publicField$e(WebColors, "Wheat", [245, 222, 179, 1]);
|
|
1741
|
+
__publicField$e(WebColors, "NavajoWhite", [255, 222, 173, 1]);
|
|
1742
|
+
__publicField$e(WebColors, "Bisque", [255, 228, 196, 1]);
|
|
1743
|
+
__publicField$e(WebColors, "BlanchedAlmond", [255, 235, 205, 1]);
|
|
1744
|
+
__publicField$e(WebColors, "Cornsilk", [255, 248, 220, 1]);
|
|
1745
|
+
__publicField$e(WebColors, "DarkGreen", [0, 100, 0, 1]);
|
|
1746
|
+
__publicField$e(WebColors, "Green", [0, 128, 0, 1]);
|
|
1747
|
+
__publicField$e(WebColors, "DarkOliveGreen", [85, 107, 47, 1]);
|
|
1748
|
+
__publicField$e(WebColors, "ForestGreen", [34, 139, 34, 1]);
|
|
1749
|
+
__publicField$e(WebColors, "SeaGreen", [46, 139, 87, 1]);
|
|
1750
|
+
__publicField$e(WebColors, "Olive", [128, 128, 0, 1]);
|
|
1751
|
+
__publicField$e(WebColors, "OliveDrab", [107, 142, 35, 1]);
|
|
1752
|
+
__publicField$e(WebColors, "MediumSeaGreen", [60, 179, 113, 1]);
|
|
1753
|
+
__publicField$e(WebColors, "LimeGreen", [50, 205, 50, 1]);
|
|
1754
|
+
__publicField$e(WebColors, "Lime", [0, 255, 0, 1]);
|
|
1755
|
+
__publicField$e(WebColors, "SpringGreen", [0, 255, 127, 1]);
|
|
1756
|
+
__publicField$e(WebColors, "MediumSpringGreen", [0, 250, 154, 1]);
|
|
1757
|
+
__publicField$e(WebColors, "DarkSeaGreen", [143, 188, 143, 1]);
|
|
1758
|
+
__publicField$e(WebColors, "MediumAquamarine", [102, 205, 170, 1]);
|
|
1759
|
+
__publicField$e(WebColors, "YellowGreen", [154, 205, 50, 1]);
|
|
1760
|
+
__publicField$e(WebColors, "LawnGreen", [124, 252, 0, 1]);
|
|
1761
|
+
__publicField$e(WebColors, "Chartreuse", [127, 255, 0, 1]);
|
|
1762
|
+
__publicField$e(WebColors, "LightGreen", [144, 238, 144, 1]);
|
|
1763
|
+
__publicField$e(WebColors, "GreenYellow", [173, 255, 47, 1]);
|
|
1764
|
+
__publicField$e(WebColors, "PaleGreen", [152, 251, 152, 1]);
|
|
1765
|
+
__publicField$e(WebColors, "Teal", [0, 128, 128, 1]);
|
|
1766
|
+
__publicField$e(WebColors, "DarkCyan", [0, 139, 139, 1]);
|
|
1767
|
+
__publicField$e(WebColors, "LightSeaGreen", [32, 178, 170, 1]);
|
|
1768
|
+
__publicField$e(WebColors, "CadetBlue", [95, 158, 160, 1]);
|
|
1769
|
+
__publicField$e(WebColors, "DarkTurquoise", [0, 206, 209, 1]);
|
|
1770
|
+
__publicField$e(WebColors, "MediumTurquoise", [72, 209, 204, 1]);
|
|
1771
|
+
__publicField$e(WebColors, "Turquoise", [64, 224, 208, 1]);
|
|
1772
|
+
__publicField$e(WebColors, "Aqua", [0, 255, 255, 1]);
|
|
1773
|
+
__publicField$e(WebColors, "Cyan", [0, 255, 255, 1]);
|
|
1774
|
+
__publicField$e(WebColors, "Aquamarine", [127, 255, 212, 1]);
|
|
1775
|
+
__publicField$e(WebColors, "PaleTurquoise", [175, 238, 238, 1]);
|
|
1776
|
+
__publicField$e(WebColors, "LightCyan", [224, 255, 255, 1]);
|
|
1777
|
+
__publicField$e(WebColors, "Navy", [0, 0, 128, 1]);
|
|
1778
|
+
__publicField$e(WebColors, "DarkBlue", [0, 0, 139, 1]);
|
|
1779
|
+
__publicField$e(WebColors, "MediumBlue", [0, 0, 205, 1]);
|
|
1780
|
+
__publicField$e(WebColors, "Blue", [0, 0, 255, 1]);
|
|
1781
|
+
__publicField$e(WebColors, "MidnightBlue", [25, 25, 112, 1]);
|
|
1782
|
+
__publicField$e(WebColors, "RoyalBlue", [65, 105, 225, 1]);
|
|
1783
|
+
__publicField$e(WebColors, "SteelBlue", [70, 130, 180, 1]);
|
|
1784
|
+
__publicField$e(WebColors, "DodgerBlue", [30, 144, 255, 1]);
|
|
1785
|
+
__publicField$e(WebColors, "DeepSkyBlue", [0, 191, 255, 1]);
|
|
1786
|
+
__publicField$e(WebColors, "CornflowerBlue", [100, 149, 237, 1]);
|
|
1787
|
+
__publicField$e(WebColors, "SkyBlue", [135, 206, 235, 1]);
|
|
1788
|
+
__publicField$e(WebColors, "LightSkyBlue", [135, 206, 250, 1]);
|
|
1789
|
+
__publicField$e(WebColors, "LightSteelBlue", [176, 196, 222, 1]);
|
|
1790
|
+
__publicField$e(WebColors, "LightBlue", [173, 216, 230, 1]);
|
|
1791
|
+
__publicField$e(WebColors, "PowderBlue", [176, 224, 230, 1]);
|
|
1792
|
+
__publicField$e(WebColors, "Indigo", [75, 0, 130, 1]);
|
|
1793
|
+
__publicField$e(WebColors, "Purple", [128, 0, 128, 1]);
|
|
1794
|
+
__publicField$e(WebColors, "DarkMagenta", [139, 0, 139, 1]);
|
|
1795
|
+
__publicField$e(WebColors, "DarkViolet", [148, 0, 211, 1]);
|
|
1796
|
+
__publicField$e(WebColors, "DarkSlateBlue", [72, 61, 139, 1]);
|
|
1797
|
+
__publicField$e(WebColors, "BlueViolet", [138, 43, 226, 1]);
|
|
1798
|
+
__publicField$e(WebColors, "DarkOrchid", [153, 50, 204, 1]);
|
|
1799
|
+
__publicField$e(WebColors, "Fuchsia", [255, 0, 255, 1]);
|
|
1800
|
+
__publicField$e(WebColors, "Magenta", [255, 0, 255, 1]);
|
|
1801
|
+
__publicField$e(WebColors, "SlateBlue", [106, 90, 205, 1]);
|
|
1802
|
+
__publicField$e(WebColors, "MediumSlateBlue", [123, 104, 238, 1]);
|
|
1803
|
+
__publicField$e(WebColors, "MediumOrchid", [186, 85, 211, 1]);
|
|
1804
|
+
__publicField$e(WebColors, "MediumPurple", [147, 112, 219, 1]);
|
|
1805
|
+
__publicField$e(WebColors, "Orchid", [218, 112, 214, 1]);
|
|
1806
|
+
__publicField$e(WebColors, "Violet", [238, 130, 238, 1]);
|
|
1807
|
+
__publicField$e(WebColors, "Plum", [221, 160, 221, 1]);
|
|
1808
|
+
__publicField$e(WebColors, "Thistle", [216, 191, 216, 1]);
|
|
1809
|
+
__publicField$e(WebColors, "Lavender", [230, 230, 250, 1]);
|
|
1810
|
+
__publicField$e(WebColors, "MistyRose", [255, 228, 225, 1]);
|
|
1811
|
+
__publicField$e(WebColors, "AntiqueWhite", [250, 235, 215, 1]);
|
|
1812
|
+
__publicField$e(WebColors, "Linen", [250, 240, 230, 1]);
|
|
1813
|
+
__publicField$e(WebColors, "Beige", [245, 245, 220, 1]);
|
|
1814
|
+
__publicField$e(WebColors, "WhiteSmoke", [245, 245, 245, 1]);
|
|
1815
|
+
__publicField$e(WebColors, "LavenderBlush", [255, 240, 245, 1]);
|
|
1816
|
+
__publicField$e(WebColors, "OldLace", [253, 245, 230, 1]);
|
|
1817
|
+
__publicField$e(WebColors, "AliceBlue", [240, 248, 255, 1]);
|
|
1818
|
+
__publicField$e(WebColors, "Seashell", [255, 245, 238, 1]);
|
|
1819
|
+
__publicField$e(WebColors, "GhostWhite", [248, 248, 255, 1]);
|
|
1820
|
+
__publicField$e(WebColors, "Honeydew", [240, 255, 240, 1]);
|
|
1821
|
+
__publicField$e(WebColors, "FloralWhite", [255, 250, 240, 1]);
|
|
1822
|
+
__publicField$e(WebColors, "Azure", [240, 255, 255, 1]);
|
|
1823
|
+
__publicField$e(WebColors, "MintCream", [245, 255, 250, 1]);
|
|
1824
|
+
__publicField$e(WebColors, "Snow", [255, 250, 250, 1]);
|
|
1825
|
+
__publicField$e(WebColors, "Ivory", [255, 255, 240, 1]);
|
|
1826
|
+
__publicField$e(WebColors, "White", [255, 255, 255, 1]);
|
|
1827
|
+
__publicField$e(WebColors, "Black", [0, 0, 0, 1]);
|
|
1828
|
+
__publicField$e(WebColors, "DarkSlateGray", [47, 79, 79, 1]);
|
|
1829
|
+
__publicField$e(WebColors, "DimGray", [105, 105, 105, 1]);
|
|
1830
|
+
__publicField$e(WebColors, "SlateGray", [112, 128, 144, 1]);
|
|
1831
|
+
__publicField$e(WebColors, "Gray", [128, 128, 128, 1]);
|
|
1832
|
+
__publicField$e(WebColors, "LightSlateGray", [119, 136, 153, 1]);
|
|
1833
|
+
__publicField$e(WebColors, "DarkGray", [169, 169, 169, 1]);
|
|
1834
|
+
__publicField$e(WebColors, "Silver", [192, 192, 192, 1]);
|
|
1835
|
+
__publicField$e(WebColors, "LightGray", [211, 211, 211, 1]);
|
|
1836
|
+
__publicField$e(WebColors, "Gainsboro", [220, 220, 220, 1]);
|
|
1837
|
+
__publicField$e(WebColors, "RebeccaPurple", [102, 51, 153, 1]);
|
|
1767
1838
|
|
|
1839
|
+
var __defProp$d = Object.defineProperty;
|
|
1840
|
+
var __defNormalProp$d = (obj, key, value) => key in obj ? __defProp$d(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1841
|
+
var __publicField$d = (obj, key, value) => {
|
|
1842
|
+
__defNormalProp$d(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1843
|
+
return value;
|
|
1844
|
+
};
|
|
1768
1845
|
class Constants {
|
|
1769
1846
|
}
|
|
1770
1847
|
/** Size of the font showing frames per second */
|
|
1771
|
-
Constants
|
|
1848
|
+
__publicField$d(Constants, "FPS_DISPLAY_TEXT_FONT_SIZE", 12);
|
|
1772
1849
|
/** Color of the font showing frames per second */
|
|
1773
|
-
Constants
|
|
1850
|
+
__publicField$d(Constants, "FPS_DISPLAY_TEXT_COLOR", [0, 0, 0, 0.5]);
|
|
1774
1851
|
/** Frequency, in milliseconds, at which to update frames per second metric shown on the screen */
|
|
1775
|
-
Constants
|
|
1852
|
+
__publicField$d(Constants, "FPS_DISPLAY_UPDATE_INTERVAL", 1e3);
|
|
1776
1853
|
/** Maximum number of activity metrics to log. */
|
|
1777
|
-
Constants
|
|
1854
|
+
__publicField$d(Constants, "MAXIMUM_RECORDED_ACTIVITY_METRICS", 32);
|
|
1778
1855
|
/** The frames per second will be logged in game metrics if the FPS is lower than this value */
|
|
1779
|
-
Constants
|
|
1856
|
+
__publicField$d(Constants, "FPS_METRIC_REPORT_THRESHOLD", 59);
|
|
1780
1857
|
/** Scene color, if none is specified. */
|
|
1781
|
-
Constants
|
|
1858
|
+
__publicField$d(Constants, "DEFAULT_SCENE_BACKGROUND_COLOR", WebColors.White);
|
|
1782
1859
|
/** Shape fill color, if none is specified. */
|
|
1783
|
-
Constants
|
|
1860
|
+
__publicField$d(Constants, "DEFAULT_SHAPE_FILL_COLOR", WebColors.Red);
|
|
1784
1861
|
/** Color of paths in a shape, if none is specified. */
|
|
1785
|
-
Constants
|
|
1862
|
+
__publicField$d(Constants, "DEFAULT_PATH_STROKE_COLOR", WebColors.Red);
|
|
1786
1863
|
/** Line width of paths in a shape, if none is specified. */
|
|
1787
|
-
Constants
|
|
1864
|
+
__publicField$d(Constants, "DEFAULT_PATH_LINE_WIDTH", 2);
|
|
1788
1865
|
/** Color of text in Label and TextLine, if none is specified. */
|
|
1789
|
-
Constants
|
|
1866
|
+
__publicField$d(Constants, "DEFAULT_FONT_COLOR", WebColors.Black);
|
|
1790
1867
|
/** Font size in Label and TextLine, if none is specified. */
|
|
1791
|
-
Constants
|
|
1792
|
-
Constants
|
|
1793
|
-
Constants
|
|
1794
|
-
Constants
|
|
1795
|
-
Constants
|
|
1796
|
-
Constants
|
|
1868
|
+
__publicField$d(Constants, "DEFAULT_FONT_SIZE", 16);
|
|
1869
|
+
__publicField$d(Constants, "LIMITED_FPS_RATE", 5);
|
|
1870
|
+
__publicField$d(Constants, "FREE_ENTITIES_SCENE_NAME", "__freeEntitiesScene");
|
|
1871
|
+
__publicField$d(Constants, "OUTGOING_SCENE_NAME", "__outgoingScene");
|
|
1872
|
+
__publicField$d(Constants, "OUTGOING_SCENE_SPRITE_NAME", "__outgoingSceneSprite");
|
|
1873
|
+
__publicField$d(Constants, "OUTGOING_SCENE_IMAGE_NAME", "__outgoingSceneSnapshot");
|
|
1874
|
+
__publicField$d(Constants, "SESSION_INITIALIZATION_POLLING_INTERVAL_MS", 50);
|
|
1797
1875
|
|
|
1798
1876
|
var Dimensions = /* @__PURE__ */ ((Dimensions2) => {
|
|
1799
1877
|
Dimensions2[Dimensions2["MatchConstraint"] = 0] = "MatchConstraint";
|
|
@@ -2039,12 +2117,22 @@ function property(e) {
|
|
|
2039
2117
|
return meta;
|
|
2040
2118
|
}
|
|
2041
2119
|
|
|
2120
|
+
var __defProp$c = Object.defineProperty;
|
|
2121
|
+
var __defNormalProp$c = (obj, key, value) => key in obj ? __defProp$c(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2122
|
+
var __publicField$c = (obj, key, value) => {
|
|
2123
|
+
__defNormalProp$c(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
2124
|
+
return value;
|
|
2125
|
+
};
|
|
2042
2126
|
class GameTypefaces {
|
|
2043
2127
|
}
|
|
2044
2128
|
class FontManager {
|
|
2045
2129
|
constructor(session) {
|
|
2046
|
-
this
|
|
2047
|
-
this
|
|
2130
|
+
__publicField$c(this, "canvasKit");
|
|
2131
|
+
__publicField$c(this, "fontMgr");
|
|
2132
|
+
__publicField$c(this, "gameTypefaces", new GameTypefaces());
|
|
2133
|
+
__publicField$c(this, "fontData", new Array());
|
|
2134
|
+
__publicField$c(this, "session");
|
|
2135
|
+
__publicField$c(this, "games");
|
|
2048
2136
|
this.session = session;
|
|
2049
2137
|
}
|
|
2050
2138
|
/**
|
|
@@ -2097,7 +2185,13 @@ class FontManager {
|
|
|
2097
2185
|
return Promise.all([Promise.resolve()]);
|
|
2098
2186
|
}
|
|
2099
2187
|
const fetchFontsPromises = fontsToFetch.map((font) => {
|
|
2188
|
+
if (!font) {
|
|
2189
|
+
throw new Error("font undefined");
|
|
2190
|
+
}
|
|
2100
2191
|
const game = games.filter((g) => g.uuid === font.gameUuid).find(Boolean);
|
|
2192
|
+
if (!game) {
|
|
2193
|
+
throw new Error("game undefined");
|
|
2194
|
+
}
|
|
2101
2195
|
const fontUrl = game.prependAssetsGameIdUrl(font.fontUrl);
|
|
2102
2196
|
return fetch(fontUrl).then((response) => response.arrayBuffer()).then((arrayBuffer) => {
|
|
2103
2197
|
this.fontData.push({
|
|
@@ -2170,42 +2264,48 @@ class FontManager {
|
|
|
2170
2264
|
}
|
|
2171
2265
|
}
|
|
2172
2266
|
|
|
2173
|
-
var __defProp$
|
|
2267
|
+
var __defProp$b = Object.defineProperty;
|
|
2174
2268
|
var __defProps$5 = Object.defineProperties;
|
|
2175
2269
|
var __getOwnPropDescs$5 = Object.getOwnPropertyDescriptors;
|
|
2176
|
-
var __getOwnPropSymbols$
|
|
2177
|
-
var __hasOwnProp$
|
|
2178
|
-
var __propIsEnum$
|
|
2179
|
-
var __defNormalProp$
|
|
2180
|
-
var __spreadValues$
|
|
2270
|
+
var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
|
|
2271
|
+
var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
|
|
2272
|
+
var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
|
|
2273
|
+
var __defNormalProp$b = (obj, key, value) => key in obj ? __defProp$b(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2274
|
+
var __spreadValues$7 = (a, b) => {
|
|
2181
2275
|
for (var prop in b || (b = {}))
|
|
2182
|
-
if (__hasOwnProp$
|
|
2183
|
-
__defNormalProp$
|
|
2184
|
-
if (__getOwnPropSymbols$
|
|
2185
|
-
for (var prop of __getOwnPropSymbols$
|
|
2186
|
-
if (__propIsEnum$
|
|
2187
|
-
__defNormalProp$
|
|
2276
|
+
if (__hasOwnProp$7.call(b, prop))
|
|
2277
|
+
__defNormalProp$b(a, prop, b[prop]);
|
|
2278
|
+
if (__getOwnPropSymbols$7)
|
|
2279
|
+
for (var prop of __getOwnPropSymbols$7(b)) {
|
|
2280
|
+
if (__propIsEnum$7.call(b, prop))
|
|
2281
|
+
__defNormalProp$b(a, prop, b[prop]);
|
|
2188
2282
|
}
|
|
2189
2283
|
return a;
|
|
2190
2284
|
};
|
|
2191
2285
|
var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
|
|
2286
|
+
var __publicField$b = (obj, key, value) => {
|
|
2287
|
+
__defNormalProp$b(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
2288
|
+
return value;
|
|
2289
|
+
};
|
|
2192
2290
|
class Sprite extends Entity {
|
|
2193
2291
|
/**
|
|
2194
2292
|
* Visual image displayed on the screen.
|
|
2195
2293
|
*
|
|
2196
|
-
* @remarks Images that will be used to create the sprite must be loaded during the Game.
|
|
2294
|
+
* @remarks Images that will be used to create the sprite must be loaded during the Game.initialize() method prior to their use.
|
|
2197
2295
|
*
|
|
2198
2296
|
* @param options - {@link SpriteOptions}
|
|
2199
2297
|
*/
|
|
2200
2298
|
constructor(options = {}) {
|
|
2201
2299
|
super(options);
|
|
2202
|
-
this
|
|
2203
|
-
this
|
|
2300
|
+
__publicField$b(this, "type", EntityType.Sprite);
|
|
2301
|
+
__publicField$b(this, "isDrawable", true);
|
|
2204
2302
|
// Drawable options
|
|
2205
|
-
this
|
|
2206
|
-
this
|
|
2303
|
+
__publicField$b(this, "anchorPoint", { x: 0.5, y: 0.5 });
|
|
2304
|
+
__publicField$b(this, "zPosition", 0);
|
|
2207
2305
|
// Sprite options
|
|
2208
|
-
this
|
|
2306
|
+
__publicField$b(this, "_imageName", "");
|
|
2307
|
+
// public getter/setter is below
|
|
2308
|
+
__publicField$b(this, "loadedImage");
|
|
2209
2309
|
handleInterfaceOptions(this, options);
|
|
2210
2310
|
if (options.imageName) {
|
|
2211
2311
|
this.imageName = options.imageName;
|
|
@@ -2250,7 +2350,7 @@ class Sprite extends Entity {
|
|
|
2250
2350
|
* provided, name will be the new uuid
|
|
2251
2351
|
*/
|
|
2252
2352
|
duplicate(newName) {
|
|
2253
|
-
const dest = new Sprite(__spreadProps$5(__spreadValues$
|
|
2353
|
+
const dest = new Sprite(__spreadProps$5(__spreadValues$7(__spreadValues$7({}, this.getEntityOptions()), this.getDrawableOptions()), {
|
|
2254
2354
|
imageName: this.imageName,
|
|
2255
2355
|
name: newName
|
|
2256
2356
|
}));
|
|
@@ -2305,25 +2405,29 @@ class LoadedImage {
|
|
|
2305
2405
|
}
|
|
2306
2406
|
}
|
|
2307
2407
|
|
|
2308
|
-
var __defProp$
|
|
2408
|
+
var __defProp$a = Object.defineProperty;
|
|
2309
2409
|
var __defProps$4 = Object.defineProperties;
|
|
2310
2410
|
var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
|
|
2311
|
-
var __getOwnPropSymbols$
|
|
2312
|
-
var __hasOwnProp$
|
|
2313
|
-
var __propIsEnum$
|
|
2314
|
-
var __defNormalProp$
|
|
2315
|
-
var __spreadValues$
|
|
2411
|
+
var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
|
|
2412
|
+
var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
|
|
2413
|
+
var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
|
|
2414
|
+
var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2415
|
+
var __spreadValues$6 = (a, b) => {
|
|
2316
2416
|
for (var prop in b || (b = {}))
|
|
2317
|
-
if (__hasOwnProp$
|
|
2318
|
-
__defNormalProp$
|
|
2319
|
-
if (__getOwnPropSymbols$
|
|
2320
|
-
for (var prop of __getOwnPropSymbols$
|
|
2321
|
-
if (__propIsEnum$
|
|
2322
|
-
__defNormalProp$
|
|
2417
|
+
if (__hasOwnProp$6.call(b, prop))
|
|
2418
|
+
__defNormalProp$a(a, prop, b[prop]);
|
|
2419
|
+
if (__getOwnPropSymbols$6)
|
|
2420
|
+
for (var prop of __getOwnPropSymbols$6(b)) {
|
|
2421
|
+
if (__propIsEnum$6.call(b, prop))
|
|
2422
|
+
__defNormalProp$a(a, prop, b[prop]);
|
|
2323
2423
|
}
|
|
2324
2424
|
return a;
|
|
2325
2425
|
};
|
|
2326
2426
|
var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
|
|
2427
|
+
var __publicField$a = (obj, key, value) => {
|
|
2428
|
+
__defNormalProp$a(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
2429
|
+
return value;
|
|
2430
|
+
};
|
|
2327
2431
|
class Scene extends Entity {
|
|
2328
2432
|
/**
|
|
2329
2433
|
* Top-level entity that holds all other entities, such as sprites, rectangles, or labels, that will be displayed on the screen
|
|
@@ -2334,15 +2438,18 @@ class Scene extends Entity {
|
|
|
2334
2438
|
*/
|
|
2335
2439
|
constructor(options = {}) {
|
|
2336
2440
|
super(options);
|
|
2337
|
-
this
|
|
2338
|
-
this
|
|
2441
|
+
__publicField$a(this, "type", EntityType.Scene);
|
|
2442
|
+
__publicField$a(this, "isDrawable", true);
|
|
2339
2443
|
// Drawable options
|
|
2340
|
-
this
|
|
2341
|
-
this
|
|
2444
|
+
__publicField$a(this, "anchorPoint", { x: 0, y: 0 });
|
|
2445
|
+
__publicField$a(this, "zPosition", 0);
|
|
2342
2446
|
// Scene options
|
|
2343
|
-
this
|
|
2344
|
-
this
|
|
2345
|
-
this
|
|
2447
|
+
__publicField$a(this, "_backgroundColor", Constants.DEFAULT_SCENE_BACKGROUND_COLOR);
|
|
2448
|
+
__publicField$a(this, "_active", false);
|
|
2449
|
+
__publicField$a(this, "_transitioning", false);
|
|
2450
|
+
__publicField$a(this, "_setupCallback");
|
|
2451
|
+
__publicField$a(this, "_appearCallback");
|
|
2452
|
+
__publicField$a(this, "backgroundPaint");
|
|
2346
2453
|
handleInterfaceOptions(this, options);
|
|
2347
2454
|
if (options.backgroundColor) {
|
|
2348
2455
|
this.backgroundColor = options.backgroundColor;
|
|
@@ -2399,7 +2506,7 @@ class Scene extends Entity {
|
|
|
2399
2506
|
* provided, name will be the new uuid
|
|
2400
2507
|
*/
|
|
2401
2508
|
duplicate(newName) {
|
|
2402
|
-
const dest = new Scene(__spreadProps$4(__spreadValues$
|
|
2509
|
+
const dest = new Scene(__spreadProps$4(__spreadValues$6(__spreadValues$6({}, this.getEntityOptions()), this.getDrawableOptions()), {
|
|
2403
2510
|
backgroundColor: this.backgroundColor,
|
|
2404
2511
|
name: newName
|
|
2405
2512
|
}));
|
|
@@ -2483,6 +2590,12 @@ class Scene extends Entity {
|
|
|
2483
2590
|
}
|
|
2484
2591
|
}
|
|
2485
2592
|
|
|
2593
|
+
var __defProp$9 = Object.defineProperty;
|
|
2594
|
+
var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2595
|
+
var __publicField$9 = (obj, key, value) => {
|
|
2596
|
+
__defNormalProp$9(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
2597
|
+
return value;
|
|
2598
|
+
};
|
|
2486
2599
|
class Transition {
|
|
2487
2600
|
/**
|
|
2488
2601
|
* Creates a scene transition in which the outgoing scene slides out and the incoming scene slides in, as if the incoming scene pushes it.
|
|
@@ -2508,7 +2621,9 @@ class Transition {
|
|
|
2508
2621
|
class NoneTransition extends Transition {
|
|
2509
2622
|
constructor() {
|
|
2510
2623
|
super();
|
|
2511
|
-
this
|
|
2624
|
+
__publicField$9(this, "type", "None" /* None */);
|
|
2625
|
+
__publicField$9(this, "easing");
|
|
2626
|
+
__publicField$9(this, "duration");
|
|
2512
2627
|
this.duration = NaN;
|
|
2513
2628
|
this.easing = Easings.none;
|
|
2514
2629
|
}
|
|
@@ -2516,7 +2631,10 @@ class NoneTransition extends Transition {
|
|
|
2516
2631
|
class SlideTransition extends Transition {
|
|
2517
2632
|
constructor(direction, duration, easing) {
|
|
2518
2633
|
super();
|
|
2519
|
-
this
|
|
2634
|
+
__publicField$9(this, "type", "Slide" /* Slide */);
|
|
2635
|
+
__publicField$9(this, "easing");
|
|
2636
|
+
__publicField$9(this, "duration");
|
|
2637
|
+
__publicField$9(this, "direction");
|
|
2520
2638
|
this.direction = direction;
|
|
2521
2639
|
this.duration = duration;
|
|
2522
2640
|
this.easing = easing;
|
|
@@ -2541,18 +2659,25 @@ class SceneTransition {
|
|
|
2541
2659
|
}
|
|
2542
2660
|
}
|
|
2543
2661
|
|
|
2544
|
-
|
|
2662
|
+
var __defProp$8 = Object.defineProperty;
|
|
2663
|
+
var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2664
|
+
var __publicField$8 = (obj, key, value) => {
|
|
2665
|
+
__defNormalProp$8(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
2666
|
+
return value;
|
|
2667
|
+
};
|
|
2668
|
+
const _Timer = class _Timer {
|
|
2545
2669
|
constructor(name) {
|
|
2546
2670
|
// startTime is the timestamp of the current active run
|
|
2547
|
-
this
|
|
2548
|
-
this
|
|
2549
|
-
this
|
|
2671
|
+
__publicField$8(this, "startTime", NaN);
|
|
2672
|
+
__publicField$8(this, "stopTime", NaN);
|
|
2673
|
+
__publicField$8(this, "stopped", true);
|
|
2550
2674
|
/**
|
|
2551
2675
|
* cumulativeElapsed is a cumulative total of elapsed time while the timer
|
|
2552
2676
|
* was in previous started (running) states, NOT INCLUDING the possibly
|
|
2553
2677
|
* active run's duration
|
|
2554
2678
|
*/
|
|
2555
|
-
this
|
|
2679
|
+
__publicField$8(this, "cumulativeElapsed", NaN);
|
|
2680
|
+
__publicField$8(this, "name");
|
|
2556
2681
|
this.name = name;
|
|
2557
2682
|
}
|
|
2558
2683
|
/**
|
|
@@ -2704,8 +2829,8 @@ const _Timer = class {
|
|
|
2704
2829
|
return this._timers.some((t) => t.name === name);
|
|
2705
2830
|
}
|
|
2706
2831
|
};
|
|
2832
|
+
__publicField$8(_Timer, "_timers", new Array());
|
|
2707
2833
|
let Timer = _Timer;
|
|
2708
|
-
Timer._timers = new Array();
|
|
2709
2834
|
|
|
2710
2835
|
const deviceMetadataSchema = {
|
|
2711
2836
|
type: "object",
|
|
@@ -2814,27 +2939,33 @@ class WebGlInfo {
|
|
|
2814
2939
|
}
|
|
2815
2940
|
}
|
|
2816
2941
|
|
|
2817
|
-
var __defProp$
|
|
2818
|
-
var __getOwnPropSymbols$
|
|
2819
|
-
var __hasOwnProp$
|
|
2820
|
-
var __propIsEnum$
|
|
2821
|
-
var __defNormalProp$
|
|
2822
|
-
var __spreadValues$
|
|
2942
|
+
var __defProp$7 = Object.defineProperty;
|
|
2943
|
+
var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
|
|
2944
|
+
var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
|
|
2945
|
+
var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
|
|
2946
|
+
var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2947
|
+
var __spreadValues$5 = (a, b) => {
|
|
2823
2948
|
for (var prop in b || (b = {}))
|
|
2824
|
-
if (__hasOwnProp$
|
|
2825
|
-
__defNormalProp$
|
|
2826
|
-
if (__getOwnPropSymbols$
|
|
2827
|
-
for (var prop of __getOwnPropSymbols$
|
|
2828
|
-
if (__propIsEnum$
|
|
2829
|
-
__defNormalProp$
|
|
2949
|
+
if (__hasOwnProp$5.call(b, prop))
|
|
2950
|
+
__defNormalProp$7(a, prop, b[prop]);
|
|
2951
|
+
if (__getOwnPropSymbols$5)
|
|
2952
|
+
for (var prop of __getOwnPropSymbols$5(b)) {
|
|
2953
|
+
if (__propIsEnum$5.call(b, prop))
|
|
2954
|
+
__defNormalProp$7(a, prop, b[prop]);
|
|
2830
2955
|
}
|
|
2831
2956
|
return a;
|
|
2832
2957
|
};
|
|
2958
|
+
var __publicField$7 = (obj, key, value) => {
|
|
2959
|
+
__defNormalProp$7(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
2960
|
+
return value;
|
|
2961
|
+
};
|
|
2833
2962
|
class I18n {
|
|
2834
2963
|
constructor(options) {
|
|
2835
|
-
this
|
|
2836
|
-
this
|
|
2837
|
-
this
|
|
2964
|
+
__publicField$7(this, "_translations");
|
|
2965
|
+
__publicField$7(this, "locale", "");
|
|
2966
|
+
__publicField$7(this, "fallbackLocale", "en");
|
|
2967
|
+
__publicField$7(this, "environmentLocale", this.getEnvironmentLocale());
|
|
2968
|
+
__publicField$7(this, "options");
|
|
2838
2969
|
var _a;
|
|
2839
2970
|
this.options = options;
|
|
2840
2971
|
this._translations = (_a = this.mergeAdditionalTranslations(
|
|
@@ -2922,7 +3053,7 @@ class I18n {
|
|
|
2922
3053
|
const processedLocales = new Array();
|
|
2923
3054
|
for (const locale in baseTranslations) {
|
|
2924
3055
|
processedLocales.push(locale);
|
|
2925
|
-
result[locale] = __spreadValues$
|
|
3056
|
+
result[locale] = __spreadValues$5(__spreadValues$5({}, baseTranslations[locale]), additionalTranslations[locale]);
|
|
2926
3057
|
}
|
|
2927
3058
|
for (const locale in additionalTranslations) {
|
|
2928
3059
|
if (processedLocales.includes(locale)) {
|
|
@@ -3052,21 +3183,21 @@ var ShapeType = /* @__PURE__ */ ((ShapeType2) => {
|
|
|
3052
3183
|
return ShapeType2;
|
|
3053
3184
|
})(ShapeType || {});
|
|
3054
3185
|
|
|
3055
|
-
var __defProp$
|
|
3186
|
+
var __defProp$6 = Object.defineProperty;
|
|
3056
3187
|
var __defProps$3 = Object.defineProperties;
|
|
3057
3188
|
var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
|
|
3058
|
-
var __getOwnPropSymbols$
|
|
3059
|
-
var __hasOwnProp$
|
|
3060
|
-
var __propIsEnum$
|
|
3061
|
-
var __defNormalProp$
|
|
3062
|
-
var __spreadValues$
|
|
3189
|
+
var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
|
|
3190
|
+
var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
|
|
3191
|
+
var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
|
|
3192
|
+
var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3193
|
+
var __spreadValues$4 = (a, b) => {
|
|
3063
3194
|
for (var prop in b || (b = {}))
|
|
3064
|
-
if (__hasOwnProp$
|
|
3065
|
-
__defNormalProp$
|
|
3066
|
-
if (__getOwnPropSymbols$
|
|
3067
|
-
for (var prop of __getOwnPropSymbols$
|
|
3068
|
-
if (__propIsEnum$
|
|
3069
|
-
__defNormalProp$
|
|
3195
|
+
if (__hasOwnProp$4.call(b, prop))
|
|
3196
|
+
__defNormalProp$6(a, prop, b[prop]);
|
|
3197
|
+
if (__getOwnPropSymbols$4)
|
|
3198
|
+
for (var prop of __getOwnPropSymbols$4(b)) {
|
|
3199
|
+
if (__propIsEnum$4.call(b, prop))
|
|
3200
|
+
__defNormalProp$6(a, prop, b[prop]);
|
|
3070
3201
|
}
|
|
3071
3202
|
return a;
|
|
3072
3203
|
};
|
|
@@ -3074,15 +3205,19 @@ var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
|
|
|
3074
3205
|
var __objRest = (source, exclude) => {
|
|
3075
3206
|
var target = {};
|
|
3076
3207
|
for (var prop in source)
|
|
3077
|
-
if (__hasOwnProp$
|
|
3208
|
+
if (__hasOwnProp$4.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
3078
3209
|
target[prop] = source[prop];
|
|
3079
|
-
if (source != null && __getOwnPropSymbols$
|
|
3080
|
-
for (var prop of __getOwnPropSymbols$
|
|
3081
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum$
|
|
3210
|
+
if (source != null && __getOwnPropSymbols$4)
|
|
3211
|
+
for (var prop of __getOwnPropSymbols$4(source)) {
|
|
3212
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$4.call(source, prop))
|
|
3082
3213
|
target[prop] = source[prop];
|
|
3083
3214
|
}
|
|
3084
3215
|
return target;
|
|
3085
3216
|
};
|
|
3217
|
+
var __publicField$6 = (obj, key, value) => {
|
|
3218
|
+
__defNormalProp$6(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
3219
|
+
return value;
|
|
3220
|
+
};
|
|
3086
3221
|
class Game {
|
|
3087
3222
|
/**
|
|
3088
3223
|
* The base class for all games. New games should extend this class.
|
|
@@ -3090,43 +3225,66 @@ class Game {
|
|
|
3090
3225
|
* @param options - {@link GameOptions}
|
|
3091
3226
|
*/
|
|
3092
3227
|
constructor(options) {
|
|
3093
|
-
this
|
|
3094
|
-
this
|
|
3095
|
-
this
|
|
3096
|
-
this
|
|
3097
|
-
this
|
|
3098
|
-
this
|
|
3099
|
-
this
|
|
3100
|
-
this
|
|
3101
|
-
this
|
|
3102
|
-
this
|
|
3103
|
-
this
|
|
3228
|
+
__publicField$6(this, "type", ActivityType.Game);
|
|
3229
|
+
__publicField$6(this, "_canvasKit");
|
|
3230
|
+
__publicField$6(this, "_session");
|
|
3231
|
+
__publicField$6(this, "uuid", Uuid.generate());
|
|
3232
|
+
__publicField$6(this, "name");
|
|
3233
|
+
__publicField$6(this, "id");
|
|
3234
|
+
__publicField$6(this, "options");
|
|
3235
|
+
__publicField$6(this, "beginTimestamp", NaN);
|
|
3236
|
+
__publicField$6(this, "beginIso8601Timestamp", "");
|
|
3237
|
+
__publicField$6(this, "eventListeners", new Array());
|
|
3238
|
+
__publicField$6(this, "gameMetrics", new Array());
|
|
3239
|
+
__publicField$6(this, "fpsMetricReportThreshold");
|
|
3240
|
+
__publicField$6(this, "maximumRecordedActivityMetrics");
|
|
3241
|
+
__publicField$6(this, "stepCount", 0);
|
|
3242
|
+
__publicField$6(this, "steppingNow", 0);
|
|
3243
|
+
__publicField$6(this, "i18n");
|
|
3244
|
+
__publicField$6(this, "warmupFunctionQueue", new Array());
|
|
3245
|
+
__publicField$6(this, "loaderElementsRemoved", false);
|
|
3246
|
+
__publicField$6(this, "_dataStore");
|
|
3247
|
+
__publicField$6(this, "additionalParameters");
|
|
3248
|
+
__publicField$6(this, "staticTrialSchema", {});
|
|
3249
|
+
/** The scene, or its name as a string, to be presented when the game is started. If this is undefined, the game will start with the first scene that has been added */
|
|
3250
|
+
__publicField$6(this, "entryScene");
|
|
3251
|
+
__publicField$6(this, "data", {
|
|
3104
3252
|
trials: new Array()
|
|
3105
|
-
};
|
|
3253
|
+
});
|
|
3106
3254
|
/** The 0-based index of the current trial */
|
|
3107
|
-
this
|
|
3108
|
-
this
|
|
3109
|
-
this
|
|
3110
|
-
this
|
|
3111
|
-
this
|
|
3112
|
-
this
|
|
3113
|
-
this
|
|
3114
|
-
this
|
|
3115
|
-
this
|
|
3116
|
-
this
|
|
3117
|
-
this
|
|
3118
|
-
this
|
|
3119
|
-
this
|
|
3120
|
-
this
|
|
3255
|
+
__publicField$6(this, "trialIndex", 0);
|
|
3256
|
+
__publicField$6(this, "htmlCanvas");
|
|
3257
|
+
__publicField$6(this, "surface");
|
|
3258
|
+
__publicField$6(this, "showFps");
|
|
3259
|
+
__publicField$6(this, "bodyBackgroundColor");
|
|
3260
|
+
__publicField$6(this, "currentScene");
|
|
3261
|
+
__publicField$6(this, "priorUpdateTime");
|
|
3262
|
+
__publicField$6(this, "fpsTextFont");
|
|
3263
|
+
__publicField$6(this, "fpsTextPaint");
|
|
3264
|
+
__publicField$6(this, "drawnFrames", 0);
|
|
3265
|
+
__publicField$6(this, "lastFpsUpdate", 0);
|
|
3266
|
+
__publicField$6(this, "nextFpsUpdate", 0);
|
|
3267
|
+
__publicField$6(this, "fpsRate", 0);
|
|
3268
|
+
__publicField$6(this, "animationFramesRequested", 0);
|
|
3269
|
+
__publicField$6(this, "limitFps", false);
|
|
3270
|
+
__publicField$6(this, "unitTesting", false);
|
|
3271
|
+
__publicField$6(this, "gameStopRequested", false);
|
|
3272
|
+
__publicField$6(this, "webGlRendererInfo", "");
|
|
3273
|
+
__publicField$6(this, "canvasCssWidth", 0);
|
|
3274
|
+
__publicField$6(this, "canvasCssHeight", 0);
|
|
3275
|
+
__publicField$6(this, "scenes", new Array());
|
|
3276
|
+
__publicField$6(this, "freeEntitiesScene", new Scene({
|
|
3121
3277
|
name: Constants.FREE_ENTITIES_SCENE_NAME,
|
|
3122
3278
|
backgroundColor: [255, 255, 255, 0]
|
|
3123
|
-
});
|
|
3124
|
-
this
|
|
3279
|
+
}));
|
|
3280
|
+
__publicField$6(this, "incomingSceneTransitions", new Array());
|
|
3281
|
+
__publicField$6(this, "currentSceneSnapshot");
|
|
3282
|
+
__publicField$6(this, "pendingScreenshot");
|
|
3125
3283
|
/**
|
|
3126
3284
|
* The m2c2kit engine will automatically include these schema and their
|
|
3127
3285
|
* values in the trial data.
|
|
3128
3286
|
*/
|
|
3129
|
-
this
|
|
3287
|
+
__publicField$6(this, "automaticTrialSchema", {
|
|
3130
3288
|
document_uuid: {
|
|
3131
3289
|
type: "string",
|
|
3132
3290
|
format: "uuid",
|
|
@@ -3144,7 +3302,7 @@ class Game {
|
|
|
3144
3302
|
},
|
|
3145
3303
|
activity_id: {
|
|
3146
3304
|
type: "string",
|
|
3147
|
-
description: "
|
|
3305
|
+
description: "Human-readable identifier of the activity."
|
|
3148
3306
|
},
|
|
3149
3307
|
activity_version: {
|
|
3150
3308
|
type: "string",
|
|
@@ -3158,8 +3316,8 @@ class Game {
|
|
|
3158
3316
|
type: "integer",
|
|
3159
3317
|
description: "Difference in minutes between UTC and device timezone. Calculated from Date.getTimezoneOffset()."
|
|
3160
3318
|
}
|
|
3161
|
-
};
|
|
3162
|
-
this
|
|
3319
|
+
});
|
|
3320
|
+
__publicField$6(this, "snapshots", new Array());
|
|
3163
3321
|
var _a, _b;
|
|
3164
3322
|
if (!options.id || options.id.trim() === "") {
|
|
3165
3323
|
throw new Error("id is required in GameOptions");
|
|
@@ -3172,15 +3330,30 @@ class Game {
|
|
|
3172
3330
|
this.fpsMetricReportThreshold = (_a = options.fpsMetricReportThreshold) != null ? _a : Constants.FPS_METRIC_REPORT_THRESHOLD;
|
|
3173
3331
|
this.maximumRecordedActivityMetrics = (_b = options.maximumRecordedActivityMetrics) != null ? _b : Constants.MAXIMUM_RECORDED_ACTIVITY_METRICS;
|
|
3174
3332
|
this.addLocalizationParametersToGameParameters();
|
|
3333
|
+
if (!this.options.trialSchema) {
|
|
3334
|
+
this.options.trialSchema = {};
|
|
3335
|
+
}
|
|
3175
3336
|
}
|
|
3176
3337
|
addLocalizationParametersToGameParameters() {
|
|
3177
|
-
this.options.parameters = __spreadValues$
|
|
3338
|
+
this.options.parameters = __spreadValues$4(__spreadValues$4({}, this.options.parameters), I18n.makeLocalizationParameters());
|
|
3178
3339
|
}
|
|
3179
3340
|
async init() {
|
|
3341
|
+
return this.initialize();
|
|
3342
|
+
}
|
|
3343
|
+
async initialize() {
|
|
3344
|
+
var _a, _b;
|
|
3180
3345
|
if (this.isLocalizationRequested()) {
|
|
3181
3346
|
const options = this.getLocalizationOptionsFromGameParameters();
|
|
3182
3347
|
this.i18n = new I18n(options);
|
|
3183
3348
|
}
|
|
3349
|
+
if ((_a = this.session.options.activityCallbacks) == null ? void 0 : _a.onActivityLifecycle) {
|
|
3350
|
+
this.onStart(this.session.options.activityCallbacks.onActivityLifecycle);
|
|
3351
|
+
this.onCancel(this.session.options.activityCallbacks.onActivityLifecycle);
|
|
3352
|
+
this.onEnd(this.session.options.activityCallbacks.onActivityLifecycle);
|
|
3353
|
+
}
|
|
3354
|
+
if ((_b = this.session.options.activityCallbacks) == null ? void 0 : _b.onActivityResults) {
|
|
3355
|
+
this.onData(this.session.options.activityCallbacks.onActivityResults);
|
|
3356
|
+
}
|
|
3184
3357
|
}
|
|
3185
3358
|
/**
|
|
3186
3359
|
* Saves an item to the activity's key-value store.
|
|
@@ -3190,7 +3363,7 @@ class Game {
|
|
|
3190
3363
|
* ```
|
|
3191
3364
|
* const db: IDataStore = new LocalDatabase();
|
|
3192
3365
|
* session.dataStore = db;
|
|
3193
|
-
* session.
|
|
3366
|
+
* session.initialize();
|
|
3194
3367
|
* ```
|
|
3195
3368
|
* @param key - item key
|
|
3196
3369
|
* @param value - item value
|
|
@@ -3212,7 +3385,7 @@ class Game {
|
|
|
3212
3385
|
* ```
|
|
3213
3386
|
* const db: IDataStore = new LocalDatabase();
|
|
3214
3387
|
* session.dataStore = db;
|
|
3215
|
-
* session.
|
|
3388
|
+
* session.initialize();
|
|
3216
3389
|
* ```
|
|
3217
3390
|
* @param key - item key
|
|
3218
3391
|
* @param globalStore - if true, treat the item as "global" and not
|
|
@@ -3232,7 +3405,7 @@ class Game {
|
|
|
3232
3405
|
* ```
|
|
3233
3406
|
* const db: IDataStore = new LocalDatabase();
|
|
3234
3407
|
* session.dataStore = db;
|
|
3235
|
-
* session.
|
|
3408
|
+
* session.initialize();
|
|
3236
3409
|
* ```
|
|
3237
3410
|
* @param key - item key
|
|
3238
3411
|
* @param globalStore - if true, treat the item as "global" and not
|
|
@@ -3251,7 +3424,7 @@ class Game {
|
|
|
3251
3424
|
* ```
|
|
3252
3425
|
* const db: IDataStore = new LocalDatabase();
|
|
3253
3426
|
* session.dataStore = db;
|
|
3254
|
-
* session.
|
|
3427
|
+
* session.initialize();
|
|
3255
3428
|
* ```
|
|
3256
3429
|
*/
|
|
3257
3430
|
storeClearItems() {
|
|
@@ -3265,7 +3438,7 @@ class Game {
|
|
|
3265
3438
|
* ```
|
|
3266
3439
|
* const db: IDataStore = new LocalDatabase();
|
|
3267
3440
|
* session.dataStore = db;
|
|
3268
|
-
* session.
|
|
3441
|
+
* session.initialize();
|
|
3269
3442
|
* ```
|
|
3270
3443
|
* @param globalStore - if true, treat the item as "global" and not
|
|
3271
3444
|
* associated with a specific activity; global items can be accessed
|
|
@@ -3282,7 +3455,7 @@ class Game {
|
|
|
3282
3455
|
* ```
|
|
3283
3456
|
* const db: IDataStore = new LocalDatabase();
|
|
3284
3457
|
* session.dataStore = db;
|
|
3285
|
-
* session.
|
|
3458
|
+
* session.initialize();
|
|
3286
3459
|
* ```
|
|
3287
3460
|
* @param key - item key
|
|
3288
3461
|
* @param globalStore - if true, treat the item as "global" and not
|
|
@@ -3561,7 +3734,7 @@ class Game {
|
|
|
3561
3734
|
* @param entryScene - The scene (Scene object or its string name) to display when the game starts
|
|
3562
3735
|
*/
|
|
3563
3736
|
async start(entryScene) {
|
|
3564
|
-
var _a, _b
|
|
3737
|
+
var _a, _b;
|
|
3565
3738
|
const gameInitOptions = this.options;
|
|
3566
3739
|
this.unitTesting = (_a = gameInitOptions._unitTesting) != null ? _a : false;
|
|
3567
3740
|
this.setupHtmlCanvases(
|
|
@@ -3621,12 +3794,11 @@ class Game {
|
|
|
3621
3794
|
warmupFunction: this.warmupShadersWithScenes
|
|
3622
3795
|
});
|
|
3623
3796
|
this.surface.requestAnimationFrame(this.loop.bind(this));
|
|
3624
|
-
|
|
3625
|
-
this
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
}
|
|
3797
|
+
const activityStartEvent = {
|
|
3798
|
+
target: this,
|
|
3799
|
+
type: EventType.ActivityStart
|
|
3800
|
+
};
|
|
3801
|
+
this.raiseActivityEventOnListeners(activityStartEvent);
|
|
3630
3802
|
}
|
|
3631
3803
|
addTimeSteppingControlsToDom() {
|
|
3632
3804
|
const existingDiv = document.getElementById("m2c2kit-time-stepping-div");
|
|
@@ -3956,7 +4128,7 @@ class Game {
|
|
|
3956
4128
|
for (const [variableName2] of variables) {
|
|
3957
4129
|
emptyTrial[variableName2] = null;
|
|
3958
4130
|
}
|
|
3959
|
-
this.data.trials.push(__spreadProps$3(__spreadValues$
|
|
4131
|
+
this.data.trials.push(__spreadProps$3(__spreadValues$4({
|
|
3960
4132
|
document_uuid: Uuid.generate(),
|
|
3961
4133
|
session_uuid: this.session.uuid,
|
|
3962
4134
|
activity_uuid: this.uuid,
|
|
@@ -4008,6 +4180,9 @@ class Game {
|
|
|
4008
4180
|
addTrialSchema(schema) {
|
|
4009
4181
|
const keys = Object.keys(schema);
|
|
4010
4182
|
keys.forEach((key) => {
|
|
4183
|
+
if (!this.options.trialSchema) {
|
|
4184
|
+
throw new Error("trial schema is undefined");
|
|
4185
|
+
}
|
|
4011
4186
|
this.options.trialSchema[key] = schema[key];
|
|
4012
4187
|
});
|
|
4013
4188
|
}
|
|
@@ -4037,6 +4212,9 @@ class Game {
|
|
|
4037
4212
|
* @param value - value of the variable to set
|
|
4038
4213
|
*/
|
|
4039
4214
|
addStaticTrialData(variableName, value) {
|
|
4215
|
+
if (!this.options.trialSchema) {
|
|
4216
|
+
throw new Error("trial schema is undefined");
|
|
4217
|
+
}
|
|
4040
4218
|
if (this.options.trialSchema[variableName] === void 0) {
|
|
4041
4219
|
throw new Error(`trial variable ${variableName} not defined in schema`);
|
|
4042
4220
|
}
|
|
@@ -4053,31 +4231,30 @@ class Game {
|
|
|
4053
4231
|
* the appropriate time. It is not triggered automatically.
|
|
4054
4232
|
*/
|
|
4055
4233
|
trialComplete() {
|
|
4056
|
-
var _a, _b
|
|
4234
|
+
var _a, _b;
|
|
4057
4235
|
if (Object.keys(this.staticTrialSchema).length > 0) {
|
|
4058
|
-
this.data.trials[this.trialIndex] = __spreadValues$
|
|
4236
|
+
this.data.trials[this.trialIndex] = __spreadValues$4(__spreadValues$4({}, this.data.trials[this.trialIndex]), this.staticTrialSchema);
|
|
4059
4237
|
}
|
|
4060
4238
|
this.trialIndex++;
|
|
4061
|
-
|
|
4062
|
-
|
|
4063
|
-
|
|
4064
|
-
|
|
4065
|
-
|
|
4066
|
-
|
|
4067
|
-
|
|
4068
|
-
|
|
4069
|
-
|
|
4070
|
-
|
|
4071
|
-
|
|
4072
|
-
|
|
4073
|
-
|
|
4074
|
-
|
|
4075
|
-
|
|
4076
|
-
|
|
4077
|
-
|
|
4078
|
-
|
|
4079
|
-
|
|
4080
|
-
}
|
|
4239
|
+
const resultsEvent = {
|
|
4240
|
+
type: EventType.ActivityData,
|
|
4241
|
+
iso8601Timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
4242
|
+
target: this,
|
|
4243
|
+
/** newData is only the trial that recently completed */
|
|
4244
|
+
newData: this.data.trials[this.trialIndex - 1],
|
|
4245
|
+
newDataSchema: this.makeNewGameDataSchema(),
|
|
4246
|
+
/** data is all the data collected so far in the game */
|
|
4247
|
+
data: this.data,
|
|
4248
|
+
dataSchema: this.makeGameDataSchema(),
|
|
4249
|
+
activityConfiguration: this.makeGameActivityConfiguration(
|
|
4250
|
+
(_a = this.options.parameters) != null ? _a : {}
|
|
4251
|
+
),
|
|
4252
|
+
activityConfigurationSchema: this.makeGameActivityConfigurationSchema(
|
|
4253
|
+
(_b = this.options.parameters) != null ? _b : {}
|
|
4254
|
+
),
|
|
4255
|
+
activityMetrics: this.gameMetrics
|
|
4256
|
+
};
|
|
4257
|
+
this.raiseActivityEventOnListeners(resultsEvent);
|
|
4081
4258
|
}
|
|
4082
4259
|
makeNewGameDataSchema() {
|
|
4083
4260
|
const newDataSchema = {
|
|
@@ -4085,7 +4262,7 @@ class Game {
|
|
|
4085
4262
|
$comment: `Activity identifier: ${this.options.id}, version: ${this.options.version}.`,
|
|
4086
4263
|
$schema: "https://json-schema.org/draft/2019-09/schema",
|
|
4087
4264
|
type: "object",
|
|
4088
|
-
properties: __spreadProps$3(__spreadValues$
|
|
4265
|
+
properties: __spreadProps$3(__spreadValues$4(__spreadValues$4({}, this.automaticTrialSchema), this.options.trialSchema), {
|
|
4089
4266
|
device_metadata: deviceMetadataSchema
|
|
4090
4267
|
})
|
|
4091
4268
|
};
|
|
@@ -4108,7 +4285,7 @@ class Game {
|
|
|
4108
4285
|
$defs: {
|
|
4109
4286
|
trial: {
|
|
4110
4287
|
type: "object",
|
|
4111
|
-
properties: __spreadProps$3(__spreadValues$
|
|
4288
|
+
properties: __spreadProps$3(__spreadValues$4(__spreadValues$4({}, this.automaticTrialSchema), this.options.trialSchema), {
|
|
4112
4289
|
device_metadata: deviceMetadataSchema
|
|
4113
4290
|
})
|
|
4114
4291
|
}
|
|
@@ -4176,60 +4353,60 @@ class Game {
|
|
|
4176
4353
|
/**
|
|
4177
4354
|
* Should be called when current game has ended successfully.
|
|
4178
4355
|
*
|
|
4179
|
-
* @remarks This will
|
|
4180
|
-
*
|
|
4181
|
-
*
|
|
4182
|
-
*
|
|
4183
|
-
*
|
|
4356
|
+
* @remarks This will send an ActivityEnd event to any listeners, such as
|
|
4357
|
+
* a function provided to Game.onEnd() or a callback defined in
|
|
4358
|
+
* SessionOptions.activityCallbacks.onActivityLifecycle. This is how the
|
|
4359
|
+
* game can communicate changes in activity state to the parent session.
|
|
4360
|
+
* It is the responsibility of the the game programmer to call this at the
|
|
4361
|
+
* appropriate time. It is not triggered automatically.
|
|
4184
4362
|
*/
|
|
4185
4363
|
end() {
|
|
4186
|
-
var _a, _b
|
|
4187
|
-
|
|
4188
|
-
this
|
|
4189
|
-
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
|
|
4195
|
-
|
|
4196
|
-
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
|
|
4201
|
-
|
|
4202
|
-
|
|
4203
|
-
}
|
|
4364
|
+
var _a, _b;
|
|
4365
|
+
const activityEndEvent = {
|
|
4366
|
+
target: this,
|
|
4367
|
+
type: EventType.ActivityEnd
|
|
4368
|
+
};
|
|
4369
|
+
const results = {
|
|
4370
|
+
data: this.data,
|
|
4371
|
+
dataSchema: this.makeGameDataSchema(),
|
|
4372
|
+
activityConfiguration: this.makeGameActivityConfiguration(
|
|
4373
|
+
(_a = this.options.parameters) != null ? _a : {}
|
|
4374
|
+
),
|
|
4375
|
+
activityConfigurationSchema: this.makeGameActivityConfigurationSchema(
|
|
4376
|
+
(_b = this.options.parameters) != null ? _b : {}
|
|
4377
|
+
),
|
|
4378
|
+
activityMetrics: this.gameMetrics
|
|
4379
|
+
};
|
|
4380
|
+
this.raiseActivityEventOnListeners(activityEndEvent, results);
|
|
4204
4381
|
}
|
|
4205
4382
|
/**
|
|
4206
4383
|
* Should be called when current game has been canceled by a user action.
|
|
4207
4384
|
*
|
|
4208
|
-
* @remarks This will
|
|
4209
|
-
*
|
|
4210
|
-
*
|
|
4211
|
-
*
|
|
4212
|
-
*
|
|
4385
|
+
* @remarks This will send an ActivityCancel event to any listeners, such as
|
|
4386
|
+
* a function provided to Game.onCancel() or a callback defined in
|
|
4387
|
+
* SessionOptions.activityCallbacks.onActivityLifecycle. This is how the
|
|
4388
|
+
* game can communicate changes in activity state to the parent session.
|
|
4389
|
+
* It is the responsibility of the the game programmer to call this at the
|
|
4390
|
+
* appropriate time. It is not triggered automatically.
|
|
4213
4391
|
*/
|
|
4214
4392
|
cancel() {
|
|
4215
|
-
var _a, _b
|
|
4216
|
-
|
|
4217
|
-
this
|
|
4218
|
-
|
|
4219
|
-
|
|
4220
|
-
|
|
4221
|
-
|
|
4222
|
-
|
|
4223
|
-
|
|
4224
|
-
|
|
4225
|
-
|
|
4226
|
-
|
|
4227
|
-
|
|
4228
|
-
|
|
4229
|
-
|
|
4230
|
-
|
|
4231
|
-
|
|
4232
|
-
}
|
|
4393
|
+
var _a, _b;
|
|
4394
|
+
const activityCancelEvent = {
|
|
4395
|
+
target: this,
|
|
4396
|
+
type: EventType.ActivityCancel
|
|
4397
|
+
};
|
|
4398
|
+
const results = {
|
|
4399
|
+
data: this.data,
|
|
4400
|
+
dataSchema: this.makeGameDataSchema(),
|
|
4401
|
+
activityConfiguration: this.makeGameActivityConfiguration(
|
|
4402
|
+
(_a = this.options.parameters) != null ? _a : {}
|
|
4403
|
+
),
|
|
4404
|
+
activityConfigurationSchema: this.makeGameActivityConfigurationSchema(
|
|
4405
|
+
(_b = this.options.parameters) != null ? _b : {}
|
|
4406
|
+
),
|
|
4407
|
+
activityMetrics: this.gameMetrics
|
|
4408
|
+
};
|
|
4409
|
+
this.raiseActivityEventOnListeners(activityCancelEvent, results);
|
|
4233
4410
|
}
|
|
4234
4411
|
setupHtmlCanvases(canvasId, width, height, stretch) {
|
|
4235
4412
|
Globals.canvasScale = Math.round(window.devicePixelRatio * 100) / 100;
|
|
@@ -4830,10 +5007,10 @@ class Game {
|
|
|
4830
5007
|
*
|
|
4831
5008
|
* @param type - the type of event to listen for, e.g., "tapDown"
|
|
4832
5009
|
* @param entityName - the entity name for which an event will be listened
|
|
4833
|
-
* @param callback
|
|
4834
|
-
* @param
|
|
5010
|
+
* @param callback - the callback to be invoked when the event occurs
|
|
5011
|
+
* @param callbackOptions
|
|
4835
5012
|
*/
|
|
4836
|
-
createEventListener(type, entityName, callback,
|
|
5013
|
+
createEventListener(type, entityName, callback, callbackOptions) {
|
|
4837
5014
|
const entities = this.entities.filter(
|
|
4838
5015
|
(entity2) => entity2.name === entityName
|
|
4839
5016
|
);
|
|
@@ -4848,17 +5025,12 @@ class Game {
|
|
|
4848
5025
|
`could not create event listener. entity with name ${entityName} could not be found in the game entity tree`
|
|
4849
5026
|
);
|
|
4850
5027
|
}
|
|
4851
|
-
|
|
4852
|
-
|
|
4853
|
-
|
|
4854
|
-
|
|
4855
|
-
}
|
|
4856
|
-
default: {
|
|
4857
|
-
throw new Error(
|
|
4858
|
-
`could not create event listener: event type ${type} is not known`
|
|
4859
|
-
);
|
|
4860
|
-
}
|
|
5028
|
+
if (!Object.values(EventType).includes(type)) {
|
|
5029
|
+
throw new Error(
|
|
5030
|
+
`game ${this.id}: could not create event listener. event type ${type} is not known`
|
|
5031
|
+
);
|
|
4861
5032
|
}
|
|
5033
|
+
entity.addEventListener(type, callback, callbackOptions);
|
|
4862
5034
|
}
|
|
4863
5035
|
/**
|
|
4864
5036
|
* Returns array of all entities that have been added to the game object.
|
|
@@ -5196,6 +5368,67 @@ class Game {
|
|
|
5196
5368
|
const relativeY = (y - bb.yMin) / (bb.yMax - bb.yMin) * height;
|
|
5197
5369
|
return { x: relativeX, y: relativeY };
|
|
5198
5370
|
}
|
|
5371
|
+
/**
|
|
5372
|
+
* Executes a callback when the game starts.
|
|
5373
|
+
*
|
|
5374
|
+
* @param callback - function to execute.
|
|
5375
|
+
* @param options - options for the callback.
|
|
5376
|
+
*/
|
|
5377
|
+
onStart(callback, options) {
|
|
5378
|
+
this.addEventListener(EventType.ActivityStart, callback, options);
|
|
5379
|
+
}
|
|
5380
|
+
/**
|
|
5381
|
+
* Executes a callback when the game is canceled.
|
|
5382
|
+
*
|
|
5383
|
+
* @param callback - function to execute.
|
|
5384
|
+
* @param options - options for the callback.
|
|
5385
|
+
*/
|
|
5386
|
+
onCancel(callback, options) {
|
|
5387
|
+
this.addEventListener(EventType.ActivityCancel, callback, options);
|
|
5388
|
+
}
|
|
5389
|
+
/**
|
|
5390
|
+
* Executes a callback when the game ends.
|
|
5391
|
+
*
|
|
5392
|
+
* @param callback - function to execute.
|
|
5393
|
+
* @param options - options for the callback.
|
|
5394
|
+
*/
|
|
5395
|
+
onEnd(callback, options) {
|
|
5396
|
+
this.addEventListener(EventType.ActivityEnd, callback, options);
|
|
5397
|
+
}
|
|
5398
|
+
/**
|
|
5399
|
+
* Executes a callback when the game generates data.
|
|
5400
|
+
*
|
|
5401
|
+
* @param callback - function to execute.
|
|
5402
|
+
* @param options - options for the callback.
|
|
5403
|
+
*/
|
|
5404
|
+
onData(callback, options) {
|
|
5405
|
+
this.addEventListener(
|
|
5406
|
+
EventType.ActivityData,
|
|
5407
|
+
callback,
|
|
5408
|
+
options
|
|
5409
|
+
);
|
|
5410
|
+
}
|
|
5411
|
+
addEventListener(type, callback, options) {
|
|
5412
|
+
const eventListener = {
|
|
5413
|
+
type,
|
|
5414
|
+
activityUuid: this.uuid,
|
|
5415
|
+
callback
|
|
5416
|
+
};
|
|
5417
|
+
if (options == null ? void 0 : options.replaceExisting) {
|
|
5418
|
+
this.eventListeners = this.eventListeners.filter(
|
|
5419
|
+
(listener) => !(listener.activityUuid === eventListener.activityUuid && listener.type === eventListener.type)
|
|
5420
|
+
);
|
|
5421
|
+
}
|
|
5422
|
+
this.eventListeners.push(eventListener);
|
|
5423
|
+
}
|
|
5424
|
+
raiseActivityEventOnListeners(activityEvent, extra) {
|
|
5425
|
+
if (extra) {
|
|
5426
|
+
activityEvent = __spreadValues$4(__spreadValues$4({}, activityEvent), extra);
|
|
5427
|
+
}
|
|
5428
|
+
this.eventListeners.filter((listener) => listener.type === activityEvent.type).forEach((listener) => {
|
|
5429
|
+
listener.callback(activityEvent);
|
|
5430
|
+
});
|
|
5431
|
+
}
|
|
5199
5432
|
raiseEventOnListeningEntities(entity, m2Event, domEvent) {
|
|
5200
5433
|
entity.eventListeners.filter((listener) => listener.type === m2Event.type).forEach((listener) => {
|
|
5201
5434
|
if (listener.entityUuid === entity.uuid) {
|
|
@@ -5322,14 +5555,25 @@ class RenderedDataUrlImage {
|
|
|
5322
5555
|
}
|
|
5323
5556
|
}
|
|
5324
5557
|
|
|
5558
|
+
var __defProp$5 = Object.defineProperty;
|
|
5559
|
+
var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
5560
|
+
var __publicField$5 = (obj, key, value) => {
|
|
5561
|
+
__defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5562
|
+
return value;
|
|
5563
|
+
};
|
|
5325
5564
|
class RenderedImages {
|
|
5326
5565
|
}
|
|
5327
5566
|
class LoadedImages {
|
|
5328
5567
|
}
|
|
5329
5568
|
class ImageManager {
|
|
5330
5569
|
constructor(session) {
|
|
5331
|
-
this
|
|
5332
|
-
this
|
|
5570
|
+
__publicField$5(this, "canvasKit");
|
|
5571
|
+
__publicField$5(this, "renderedImages", new RenderedImages());
|
|
5572
|
+
__publicField$5(this, "loadedImages", new LoadedImages());
|
|
5573
|
+
__publicField$5(this, "_scratchCanvas");
|
|
5574
|
+
__publicField$5(this, "ctx");
|
|
5575
|
+
__publicField$5(this, "scale");
|
|
5576
|
+
__publicField$5(this, "session");
|
|
5333
5577
|
this.session = session;
|
|
5334
5578
|
}
|
|
5335
5579
|
/**
|
|
@@ -5535,6 +5779,9 @@ class ImageManager {
|
|
|
5535
5779
|
reloadImageUsingViewBoxWidthHeight(svgElement);
|
|
5536
5780
|
} else if (browserImage.url) {
|
|
5537
5781
|
const game = this.session.options.activities.filter((a) => a.type === ActivityType.Game).filter((g) => g.uuid === gameUuid).map((g) => g).find(Boolean);
|
|
5782
|
+
if (!game) {
|
|
5783
|
+
throw new Error("game undefined");
|
|
5784
|
+
}
|
|
5538
5785
|
const browserImageUrl = game.prependAssetsGameIdUrl(
|
|
5539
5786
|
browserImage.url
|
|
5540
5787
|
);
|
|
@@ -5575,6 +5822,9 @@ class ImageManager {
|
|
|
5575
5822
|
image.src = "data:image/svg+xml," + encodeURIComponent(browserImage.svgString);
|
|
5576
5823
|
} else if (browserImage.url) {
|
|
5577
5824
|
const game = this.session.options.activities.filter((a) => a.type === ActivityType.Game).filter((g) => g.uuid === gameUuid).map((g) => g).find(Boolean);
|
|
5825
|
+
if (!game) {
|
|
5826
|
+
throw new Error("game undefined");
|
|
5827
|
+
}
|
|
5578
5828
|
const browserImageUrl = game.prependAssetsGameIdUrl(browserImage.url);
|
|
5579
5829
|
fetch(browserImageUrl).then((response) => response.arrayBuffer()).then((data) => {
|
|
5580
5830
|
const base64String = this.arrayBufferToBase64String(data);
|
|
@@ -5684,25 +5934,29 @@ var LabelHorizontalAlignmentMode = /* @__PURE__ */ ((LabelHorizontalAlignmentMod
|
|
|
5684
5934
|
return LabelHorizontalAlignmentMode2;
|
|
5685
5935
|
})(LabelHorizontalAlignmentMode || {});
|
|
5686
5936
|
|
|
5687
|
-
var __defProp$
|
|
5937
|
+
var __defProp$4 = Object.defineProperty;
|
|
5688
5938
|
var __defProps$2 = Object.defineProperties;
|
|
5689
5939
|
var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
|
|
5690
|
-
var __getOwnPropSymbols$
|
|
5691
|
-
var __hasOwnProp$
|
|
5692
|
-
var __propIsEnum$
|
|
5693
|
-
var __defNormalProp$
|
|
5694
|
-
var __spreadValues$
|
|
5940
|
+
var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
|
|
5941
|
+
var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
|
|
5942
|
+
var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
|
|
5943
|
+
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
5944
|
+
var __spreadValues$3 = (a, b) => {
|
|
5695
5945
|
for (var prop in b || (b = {}))
|
|
5696
|
-
if (__hasOwnProp$
|
|
5697
|
-
__defNormalProp$
|
|
5698
|
-
if (__getOwnPropSymbols$
|
|
5699
|
-
for (var prop of __getOwnPropSymbols$
|
|
5700
|
-
if (__propIsEnum$
|
|
5701
|
-
__defNormalProp$
|
|
5946
|
+
if (__hasOwnProp$3.call(b, prop))
|
|
5947
|
+
__defNormalProp$4(a, prop, b[prop]);
|
|
5948
|
+
if (__getOwnPropSymbols$3)
|
|
5949
|
+
for (var prop of __getOwnPropSymbols$3(b)) {
|
|
5950
|
+
if (__propIsEnum$3.call(b, prop))
|
|
5951
|
+
__defNormalProp$4(a, prop, b[prop]);
|
|
5702
5952
|
}
|
|
5703
5953
|
return a;
|
|
5704
5954
|
};
|
|
5705
5955
|
var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
|
|
5956
|
+
var __publicField$4 = (obj, key, value) => {
|
|
5957
|
+
__defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5958
|
+
return value;
|
|
5959
|
+
};
|
|
5706
5960
|
class Label extends Entity {
|
|
5707
5961
|
/**
|
|
5708
5962
|
* Single or multi-line text formatted and rendered on the screen.
|
|
@@ -5713,22 +5967,34 @@ class Label extends Entity {
|
|
|
5713
5967
|
*/
|
|
5714
5968
|
constructor(options = {}) {
|
|
5715
5969
|
super(options);
|
|
5716
|
-
this
|
|
5717
|
-
this
|
|
5718
|
-
this
|
|
5970
|
+
__publicField$4(this, "type", EntityType.Label);
|
|
5971
|
+
__publicField$4(this, "isDrawable", true);
|
|
5972
|
+
__publicField$4(this, "isText", true);
|
|
5719
5973
|
// Drawable options
|
|
5720
|
-
this
|
|
5721
|
-
this
|
|
5974
|
+
__publicField$4(this, "anchorPoint", { x: 0.5, y: 0.5 });
|
|
5975
|
+
__publicField$4(this, "zPosition", 0);
|
|
5722
5976
|
// Text options
|
|
5723
|
-
this
|
|
5977
|
+
__publicField$4(this, "_text", "");
|
|
5978
|
+
// public getter/setter is below
|
|
5979
|
+
__publicField$4(this, "_fontName");
|
|
5980
|
+
// public getter/setter is below
|
|
5981
|
+
__publicField$4(this, "_fontNames");
|
|
5724
5982
|
// public getter/setter is below
|
|
5725
|
-
this
|
|
5983
|
+
__publicField$4(this, "_fontColor", Constants.DEFAULT_FONT_COLOR);
|
|
5726
5984
|
// public getter/setter is below
|
|
5727
|
-
this
|
|
5985
|
+
__publicField$4(this, "_fontSize", Constants.DEFAULT_FONT_SIZE);
|
|
5728
5986
|
// public getter/setter is below
|
|
5729
5987
|
// Label options
|
|
5730
|
-
this
|
|
5731
|
-
|
|
5988
|
+
__publicField$4(this, "_horizontalAlignmentMode", LabelHorizontalAlignmentMode.Center);
|
|
5989
|
+
// public getter/setter is below
|
|
5990
|
+
__publicField$4(this, "_preferredMaxLayoutWidth");
|
|
5991
|
+
// public getter/setter is below
|
|
5992
|
+
__publicField$4(this, "_backgroundColor");
|
|
5993
|
+
// public getter/setter is below
|
|
5994
|
+
__publicField$4(this, "paragraph");
|
|
5995
|
+
__publicField$4(this, "paraStyle");
|
|
5996
|
+
__publicField$4(this, "builder");
|
|
5997
|
+
__publicField$4(this, "_translatedText", "");
|
|
5732
5998
|
handleInterfaceOptions(this, options);
|
|
5733
5999
|
if (options.horizontalAlignmentMode) {
|
|
5734
6000
|
this.horizontalAlignmentMode = options.horizontalAlignmentMode;
|
|
@@ -5826,9 +6092,14 @@ class Label extends Entity {
|
|
|
5826
6092
|
fontManager.gameTypefaces[this.game.uuid][this.fontName].fontFamily
|
|
5827
6093
|
);
|
|
5828
6094
|
} else {
|
|
5829
|
-
|
|
5830
|
-
|
|
6095
|
+
const typefaces = Object.values(
|
|
6096
|
+
fontManager.gameTypefaces[this.game.uuid]
|
|
5831
6097
|
);
|
|
6098
|
+
const defaultTypeface = typefaces.filter((f) => f.isDefault).find(Boolean);
|
|
6099
|
+
if (!defaultTypeface) {
|
|
6100
|
+
throw new Error("no default font");
|
|
6101
|
+
}
|
|
6102
|
+
fontFamilies.push(defaultTypeface.fontFamily);
|
|
5832
6103
|
}
|
|
5833
6104
|
this.paraStyle = new this.canvasKit.ParagraphStyle({
|
|
5834
6105
|
textStyle: {
|
|
@@ -5948,7 +6219,7 @@ class Label extends Entity {
|
|
|
5948
6219
|
* provided, name will be the new uuid
|
|
5949
6220
|
*/
|
|
5950
6221
|
duplicate(newName) {
|
|
5951
|
-
const dest = new Label(__spreadProps$2(__spreadValues$
|
|
6222
|
+
const dest = new Label(__spreadProps$2(__spreadValues$3(__spreadValues$3(__spreadValues$3({}, this.getEntityOptions()), this.getDrawableOptions()), this.getTextOptions()), {
|
|
5952
6223
|
horizontalAlignmentMode: this.horizontalAlignmentMode,
|
|
5953
6224
|
preferredMaxLayoutWidth: this.preferredMaxLayoutWidth,
|
|
5954
6225
|
backgroundColor: this.backgroundColor,
|
|
@@ -5994,11 +6265,17 @@ class Label extends Entity {
|
|
|
5994
6265
|
}
|
|
5995
6266
|
}
|
|
5996
6267
|
|
|
6268
|
+
var __defProp$3 = Object.defineProperty;
|
|
6269
|
+
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6270
|
+
var __publicField$3 = (obj, key, value) => {
|
|
6271
|
+
__defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
6272
|
+
return value;
|
|
6273
|
+
};
|
|
5997
6274
|
class MutablePath {
|
|
5998
6275
|
constructor() {
|
|
5999
|
-
this
|
|
6000
|
-
this
|
|
6001
|
-
this
|
|
6276
|
+
__publicField$3(this, "size", { width: 0, height: 0 });
|
|
6277
|
+
__publicField$3(this, "_subpaths", new Array());
|
|
6278
|
+
__publicField$3(this, "currentPath", new Array());
|
|
6002
6279
|
}
|
|
6003
6280
|
get subpaths() {
|
|
6004
6281
|
if (this.currentPath.length > 0) {
|
|
@@ -6633,20 +6910,20 @@ var w;w||(w=typeof CanvasKitInit !== 'undefined' ? CanvasKitInit : {});var da,ea
|
|
|
6633
6910
|
function Vd(a){var b=Array(oa(a)+1);ra(a,b,0,b.length);return b}
|
|
6634
6911
|
var pe={U:function(){return 0},Bb:function(){},Db:function(){return 0},yb:function(){},zb:function(){},V:function(){},Ab:function(){},C:function(a){var b=Fb[a];delete Fb[a];var d=b.gf,f=b.le,h=b.sf,m=h.map(u=>u.Tf).concat(h.map(u=>u.fg));Qb([a],m,u=>{var n={};h.forEach((q,v)=>{var E=u[v],G=q.Rf,L=q.Sf,z=u[v+h.length],N=q.eg,T=q.gg;n[q.Lf]={read:U=>E.fromWireType(G(L,U)),write:(U,pa)=>{var ta=[];N(T,U,z.toWireType(ta,pa));Gb(ta);}};});return [{name:b.name,fromWireType:function(q){var v={},E;for(E in n)v[E]=
|
|
6635
6912
|
n[E].read(q);f(q);return v},toWireType:function(q,v){for(var E in n)if(!(E in v))throw new TypeError('Missing field: "'+E+'"');var G=d();for(E in n)n[E].write(G,v[E]);null!==q&&q.push(f,G);return G},argPackAdvance:8,readValueFromPointer:Hb,ee:f}]});},qb:function(){},Hb:function(a,b,d,f,h){var m=Sb(d);b=ac(b);Rb(a,{name:b,fromWireType:function(u){return !!u},toWireType:function(u,n){return n?f:h},argPackAdvance:8,readValueFromPointer:function(u){if(1===d)var n=lb;else if(2===d)n=$a;else if(4===d)n=
|
|
6636
|
-
Q;else throw new TypeError("Unknown boolean type size: "+b);return this.fromWireType(n[u>>m])},ee:null});},
|
|
6913
|
+
Q;else throw new TypeError("Unknown boolean type size: "+b);return this.fromWireType(n[u>>m])},ee:null});},q:function(a,b,d,f,h,m,u,n,q,v,E,G,L){E=ac(E);m=Ic(h,m);n&&(n=Ic(u,n));v&&(v=Ic(q,v));L=Ic(G,L);var z=Lb(E);rc(z,function(){Nc("Cannot construct "+E+" due to unbound types",[f]);});Qb([a,b,d],f?[f]:[],function(N){N=N[0];if(f){var T=N.Rd;var U=T.Ge;}else U=pc.prototype;N=Mb(z,function(){if(Object.getPrototypeOf(this)!==pa)throw new bc("Use 'new' to construct "+E);if(void 0===ta.oe)throw new bc(E+
|
|
6637
6914
|
" has no accessible constructor");var hb=ta.oe[arguments.length];if(void 0===hb)throw new bc("Tried to invoke ctor of "+E+" with invalid number of parameters ("+arguments.length+") - expected ("+Object.keys(ta.oe).toString()+") parameters instead!");return hb.apply(this,arguments)});var pa=Object.create(U,{constructor:{value:N}});N.prototype=pa;var ta=new sc(E,N,pa,L,T,m,n,v);T=new zc(E,ta,!0,!1,!1);U=new zc(E+"*",ta,!1,!1,!1);var gb=new zc(E+" const*",ta,!1,!0,!1);hc[a]={pointerType:U,Ff:gb};Ac(z,
|
|
6638
|
-
N);return [T,U,gb]});},h:function(a,b,d,f,h,m,u){var n=Pc(d,f);b=ac(b);m=Ic(h,m);Qb([],[a],function(q){function v(){Nc("Cannot call "+E+" due to unbound types",n);}q=q[0];var E=q.name+"."+b;b.startsWith("@@")&&(b=Symbol[b.substring(2)]);var G=q.Rd.constructor;void 0===G[b]?(v.De=d-1,G[b]=v):(qc(G,b,E),G[b].Zd[d-1]=v);Qb([],n,function(L){L=[L[0],null].concat(L.slice(1));L=Oc(E,L,null,m,u);void 0===G[b].Zd?(L.De=d-1,G[b]=L):G[b].Zd[d-1]=L;return []});return []});},
|
|
6915
|
+
N);return [T,U,gb]});},h:function(a,b,d,f,h,m,u){var n=Pc(d,f);b=ac(b);m=Ic(h,m);Qb([],[a],function(q){function v(){Nc("Cannot call "+E+" due to unbound types",n);}q=q[0];var E=q.name+"."+b;b.startsWith("@@")&&(b=Symbol[b.substring(2)]);var G=q.Rd.constructor;void 0===G[b]?(v.De=d-1,G[b]=v):(qc(G,b,E),G[b].Zd[d-1]=v);Qb([],n,function(L){L=[L[0],null].concat(L.slice(1));L=Oc(E,L,null,m,u);void 0===G[b].Zd?(L.De=d-1,G[b]=L):G[b].Zd[d-1]=L;return []});return []});},B:function(a,b,d,f,h,m){0<b||Qa();var u=
|
|
6639
6916
|
Pc(b,d);h=Ic(f,h);Qb([],[a],function(n){n=n[0];var q="constructor "+n.name;void 0===n.Rd.oe&&(n.Rd.oe=[]);if(void 0!==n.Rd.oe[b-1])throw new bc("Cannot register multiple constructors with identical number of parameters ("+(b-1)+") for class '"+n.name+"'! Overload resolution is currently only performed using the parameter count, not actual type info!");n.Rd.oe[b-1]=()=>{Nc("Cannot construct "+n.name+" due to unbound types",u);};Qb([],u,function(v){v.splice(1,0,null);n.Rd.oe[b-1]=Oc(q,v,null,h,m);return []});
|
|
6640
6917
|
return []});},b:function(a,b,d,f,h,m,u,n){var q=Pc(d,f);b=ac(b);m=Ic(h,m);Qb([],[a],function(v){function E(){Nc("Cannot call "+G+" due to unbound types",q);}v=v[0];var G=v.name+"."+b;b.startsWith("@@")&&(b=Symbol[b.substring(2)]);n&&v.Rd.bg.push(b);var L=v.Rd.Ge,z=L[b];void 0===z||void 0===z.Zd&&z.className!==v.name&&z.De===d-2?(E.De=d-2,E.className=v.name,L[b]=E):(qc(L,b,G),L[b].Zd[d-2]=E);Qb([],q,function(N){N=Oc(G,N,v,m,u);void 0===L[b].Zd?(N.De=d-2,L[b]=N):L[b].Zd[d-2]=N;return []});return []});},u:function(a,
|
|
6641
6918
|
b,d){a=ac(a);Qb([],[b],function(f){f=f[0];w[a]=f.fromWireType(d);return []});},Gb:function(a,b){b=ac(b);Rb(a,{name:b,fromWireType:function(d){var f=Tc(d);Sc(d);return f},toWireType:function(d,f){return xc(f)},argPackAdvance:8,readValueFromPointer:Hb,ee:null});},n:function(a,b,d,f){function h(){}d=Sb(d);b=ac(b);h.values={};Rb(a,{name:b,constructor:h,fromWireType:function(m){return this.constructor.values[m]},toWireType:function(m,u){return u.value},argPackAdvance:8,readValueFromPointer:Uc(b,d,f),ee:null});
|
|
6642
6919
|
rc(b,h);},e:function(a,b,d){var f=Vc(a,"enum");b=ac(b);a=f.constructor;f=Object.create(f.constructor.prototype,{value:{value:d},constructor:{value:Mb(f.name+"_"+b,function(){})}});a.values[d]=f;a[b]=f;},Y:function(a,b,d){d=Sb(d);b=ac(b);Rb(a,{name:b,fromWireType:function(f){return f},toWireType:function(f,h){return h},argPackAdvance:8,readValueFromPointer:Wc(b,d),ee:null});},y:function(a,b,d,f,h,m){var u=Pc(b,d);a=ac(a);h=Ic(f,h);rc(a,function(){Nc("Cannot call "+a+" due to unbound types",u);},b-1);Qb([],
|
|
6643
6920
|
u,function(n){n=[n[0],null].concat(n.slice(1));Ac(a,Oc(a,n,null,h,m),b-1);return []});},E:function(a,b,d,f,h){b=ac(b);-1===h&&(h=4294967295);h=Sb(d);var m=n=>n;if(0===f){var u=32-8*d;m=n=>n<<u>>>u;}d=b.includes("unsigned")?function(n,q){return q>>>0}:function(n,q){return q};Rb(a,{name:b,fromWireType:m,toWireType:d,argPackAdvance:8,readValueFromPointer:Xc(b,h,0!==f),ee:null});},v:function(a,b,d){function f(m){m>>=2;var u=mb;return new h(kb,u[m+1],u[m])}var h=[Int8Array,Uint8Array,Int16Array,Uint16Array,
|
|
6644
|
-
Int32Array,Uint32Array,Float32Array,Float64Array][b];d=ac(d);Rb(a,{name:d,fromWireType:f,argPackAdvance:8,readValueFromPointer:f},{Vf:!0});},
|
|
6921
|
+
Int32Array,Uint32Array,Float32Array,Float64Array][b];d=ac(d);Rb(a,{name:d,fromWireType:f,argPackAdvance:8,readValueFromPointer:f},{Vf:!0});},t:function(a,b,d,f,h,m,u,n,q,v,E,G){d=ac(d);m=Ic(h,m);n=Ic(u,n);v=Ic(q,v);G=Ic(E,G);Qb([a],[b],function(L){L=L[0];return [new zc(d,L.Rd,!1,!1,!0,L,f,m,n,v,G)]});},X:function(a,b){b=ac(b);var d="std::string"===b;Rb(a,{name:b,fromWireType:function(f){var h=mb[f>>2],m=f+4;if(d)for(var u=m,n=0;n<=h;++n){var q=m+n;if(n==h||0==K[q]){u=Wa(u,q-u);if(void 0===v)var v=u;
|
|
6645
6922
|
else v+=String.fromCharCode(0),v+=u;u=q+1;}}else {v=Array(h);for(n=0;n<h;++n)v[n]=String.fromCharCode(K[m+n]);v=v.join("");}Mc(f);return v},toWireType:function(f,h){h instanceof ArrayBuffer&&(h=new Uint8Array(h));var m="string"==typeof h;m||h instanceof Uint8Array||h instanceof Uint8ClampedArray||h instanceof Int8Array||X("Cannot pass non-string to std::string");var u=d&&m?oa(h):h.length;var n=Hd(4+u+1),q=n+4;mb[n>>2]=u;if(d&&m)ra(h,K,q,u+1);else if(m)for(m=0;m<u;++m){var v=h.charCodeAt(m);255<v&&(Mc(q),
|
|
6646
6923
|
X("String has UTF-16 code units that do not fit in 8 bits"));K[q+m]=v;}else for(m=0;m<u;++m)K[q+m]=h[m];null!==f&&f.push(Mc,n);return n},argPackAdvance:8,readValueFromPointer:Hb,ee:function(f){Mc(f);}});},P:function(a,b,d){d=ac(d);if(2===b){var f=Ya;var h=cb;var m=db;var u=()=>Za;var n=1;}else 4===b&&(f=eb,h=fb,m=jb,u=()=>mb,n=2);Rb(a,{name:d,fromWireType:function(q){for(var v=mb[q>>2],E=u(),G,L=q+4,z=0;z<=v;++z){var N=q+4+z*b;if(z==v||0==E[N>>n])L=f(L,N-L),void 0===G?G=L:(G+=String.fromCharCode(0),G+=
|
|
6647
6924
|
L),L=N+b;}Mc(q);return G},toWireType:function(q,v){"string"!=typeof v&&X("Cannot pass non-string to C++ string type "+d);var E=m(v),G=Hd(4+E+b);mb[G>>2]=E>>n;h(v,G+4,E+b);null!==q&&q.push(Mc,G);return G},argPackAdvance:8,readValueFromPointer:Hb,ee:function(q){Mc(q);}});},D:function(a,b,d,f,h,m){Fb[a]={name:ac(b),gf:Ic(d,f),le:Ic(h,m),sf:[]};},g:function(a,b,d,f,h,m,u,n,q,v){Fb[a].sf.push({Lf:ac(b),Tf:d,Rf:Ic(f,h),Sf:m,fg:u,eg:Ic(n,q),gg:v});},Ib:function(a,b){b=ac(b);Rb(a,{Xf:!0,name:b,argPackAdvance:0,
|
|
6648
|
-
fromWireType:function(){},toWireType:function(){}});},Fb:function(){return !0},sb:function(){throw Infinity;},I:function(a,b,d){a=Tc(a);b=Vc(b,"emval::as");var f=[],h=xc(f);mb[d>>2]=h;return b.toWireType(f,a)},$:function(a,b,d,f,h){a=$c[a];b=Tc(b);d=Zc(d);var m=[];mb[f>>2]=xc(m);return a(b,d,m,h)},
|
|
6649
|
-
"$";var h=dd[b];if(void 0!==h)return h;var m=Array(a-1);h=bd((u,n,q,v)=>{for(var E=0,G=0;G<a-1;++G)m[G]=d[G+1].readValueFromPointer(v+E),E+=d[G+1].argPackAdvance;u=u[n].apply(u,m);for(G=0;G<a-1;++G)d[G+1].If&&d[G+1].If(m[G]);if(!f.Xf)return f.toWireType(q,u)});return dd[b]=h},H:function(a,b){a=Tc(a);b=Tc(b);return xc(a[b])},r:function(a){4<a&&(Rc[a].hf+=1);},
|
|
6925
|
+
fromWireType:function(){},toWireType:function(){}});},Fb:function(){return !0},sb:function(){throw Infinity;},I:function(a,b,d){a=Tc(a);b=Vc(b,"emval::as");var f=[],h=xc(f);mb[d>>2]=h;return b.toWireType(f,a)},$:function(a,b,d,f,h){a=$c[a];b=Tc(b);d=Zc(d);var m=[];mb[f>>2]=xc(m);return a(b,d,m,h)},A:function(a,b,d,f){a=$c[a];b=Tc(b);d=Zc(d);a(b,d,null,f);},f:Sc,M:function(a){if(0===a)return xc(ad());a=Zc(a);return xc(ad()[a])},z:function(a,b){var d=cd(a,b),f=d[0];b=f.name+"_$"+d.slice(1).map(function(u){return u.name}).join("_")+
|
|
6926
|
+
"$";var h=dd[b];if(void 0!==h)return h;var m=Array(a-1);h=bd((u,n,q,v)=>{for(var E=0,G=0;G<a-1;++G)m[G]=d[G+1].readValueFromPointer(v+E),E+=d[G+1].argPackAdvance;u=u[n].apply(u,m);for(G=0;G<a-1;++G)d[G+1].If&&d[G+1].If(m[G]);if(!f.Xf)return f.toWireType(q,u)});return dd[b]=h},H:function(a,b){a=Tc(a);b=Tc(b);return xc(a[b])},r:function(a){4<a&&(Rc[a].hf+=1);},L:function(a,b,d,f){a=Tc(a);var h=fd[b];h||(h=ed(b),fd[b]=h);return h(a,d,f)},J:function(){return xc([])},i:function(a){return xc(Zc(a))},G:function(){return xc({})},
|
|
6650
6927
|
mb:function(a){a=Tc(a);return !a},F:function(a){var b=Tc(a);Gb(b);Sc(a);},m:function(a,b,d){a=Tc(a);b=Tc(b);d=Tc(d);a[b]=d;},j:function(a,b){a=Vc(a,"_emval_take_value");a=a.readValueFromPointer(b);return xc(a)},ub:function(){return -52},vb:function(){},a:function(){Qa("");},Eb:gd,bd:function(a){Y.activeTexture(a);},cd:function(a,b){Y.attachShader(nd[a],qd[b]);},ca:function(a,b,d){Y.bindAttribLocation(nd[a],b,Wa(d));},da:function(a,b){35051==a?Y.df=b:35052==a&&(Y.Ee=b);Y.bindBuffer(a,md[b]);},ba:function(a,
|
|
6651
6928
|
b){Y.bindFramebuffer(a,od[b]);},fc:function(a,b){Y.bindRenderbuffer(a,pd[b]);},Rb:function(a,b){Y.bindSampler(a,sd[b]);},ea:function(a,b){Y.bindTexture(a,ka[b]);},Cc:function(a){Y.bindVertexArray(rd[a]);},xc:function(a){Y.bindVertexArray(rd[a]);},fa:function(a,b,d,f){Y.blendColor(a,b,d,f);},ga:function(a){Y.blendEquation(a);},ha:function(a,b){Y.blendFunc(a,b);},$b:function(a,b,d,f,h,m,u,n,q,v){Y.blitFramebuffer(a,b,d,f,h,m,u,n,q,v);},ia:function(a,b,d,f){2<=x.version?d&&b?Y.bufferData(a,K,f,d,b):Y.bufferData(a,
|
|
6652
6929
|
b,f):Y.bufferData(a,d?K.subarray(d,d+b):b,f);},ja:function(a,b,d,f){2<=x.version?d&&Y.bufferSubData(a,b,K,f,d):Y.bufferSubData(a,b,K.subarray(f,f+d));},gc:function(a){return Y.checkFramebufferStatus(a)},S:function(a){Y.clear(a);},aa:function(a,b,d,f){Y.clearColor(a,b,d,f);},W:function(a){Y.clearStencil(a);},kb:function(a,b,d,f){return Y.clientWaitSync(td[a],b,(d>>>0)+4294967296*f)},ka:function(a,b,d,f){Y.colorMask(!!a,!!b,!!d,!!f);},la:function(a){Y.compileShader(qd[a]);},ma:function(a,b,d,f,h,m,u,n){2<=
|
|
@@ -6656,7 +6933,7 @@ var w;w||(w=typeof CanvasKitInit !== 'undefined' ? CanvasKitInit : {});var da,ea
|
|
|
6656
6933
|
Dc:function(a,b){for(var d=0;d<a;d++){var f=Q[b+4*d>>2];Y.deleteVertexArray(rd[f]);rd[f]=null;}},yc:function(a,b){for(var d=0;d<a;d++){var f=Q[b+4*d>>2];Y.deleteVertexArray(rd[f]);rd[f]=null;}},wa:function(a){Y.depthMask(!!a);},xa:function(a){Y.disable(a);},ya:function(a){Y.disableVertexAttribArray(a);},za:function(a,b,d){Y.drawArrays(a,b,d);},Ac:function(a,b,d,f){Y.drawArraysInstanced(a,b,d,f);},vc:function(a,b,d,f,h){Y.qf.drawArraysInstancedBaseInstanceWEBGL(a,b,d,f,h);},tc:function(a,b){for(var d=Dd[a],
|
|
6657
6934
|
f=0;f<a;f++)d[f]=Q[b+4*f>>2];Y.drawBuffers(d);},Aa:function(a,b,d,f){Y.drawElements(a,b,d,f);},Bc:function(a,b,d,f,h){Y.drawElementsInstanced(a,b,d,f,h);},wc:function(a,b,d,f,h,m,u){Y.qf.drawElementsInstancedBaseVertexBaseInstanceWEBGL(a,b,d,f,h,m,u);},nc:function(a,b,d,f,h,m){Y.drawElements(a,f,h,m);},Ba:function(a){Y.enable(a);},Ca:function(a){Y.enableVertexAttribArray(a);},Xb:function(a,b){return (a=Y.fenceSync(a,b))?(b=ha(td),a.name=b,td[b]=a,b):0},Da:function(){Y.finish();},Ea:function(){Y.flush();},jc:function(a,
|
|
6658
6935
|
b,d,f){Y.framebufferRenderbuffer(a,b,d,pd[f]);},kc:function(a,b,d,f,h){Y.framebufferTexture2D(a,b,d,ka[f],h);},Fa:function(a){Y.frontFace(a);},Ga:function(a,b){Ed(a,b,"createBuffer",md);},lc:function(a,b){Ed(a,b,"createFramebuffer",od);},mc:function(a,b){Ed(a,b,"createRenderbuffer",pd);},Tb:function(a,b){Ed(a,b,"createSampler",sd);},Ha:function(a,b){Ed(a,b,"createTexture",ka);},Ec:function(a,b){Ed(a,b,"createVertexArray",rd);},zc:function(a,b){Ed(a,b,"createVertexArray",rd);},bc:function(a){Y.generateMipmap(a);},
|
|
6659
|
-
Ia:function(a,b,d){d?Q[d>>2]=Y.getBufferParameter(a,b):xd(1281);},Ja:function(){var a=Y.getError()||Ad;Ad=0;return a},Ka:function(a,b){Fd(a,b,2);},cc:function(a,b,d,f){a=Y.getFramebufferAttachmentParameter(a,b,d);if(a instanceof WebGLRenderbuffer||a instanceof WebGLTexture)a=a.name|0;Q[f>>2]=a;},
|
|
6936
|
+
Ia:function(a,b,d){d?Q[d>>2]=Y.getBufferParameter(a,b):xd(1281);},Ja:function(){var a=Y.getError()||Ad;Ad=0;return a},Ka:function(a,b){Fd(a,b,2);},cc:function(a,b,d,f){a=Y.getFramebufferAttachmentParameter(a,b,d);if(a instanceof WebGLRenderbuffer||a instanceof WebGLTexture)a=a.name|0;Q[f>>2]=a;},N:function(a,b){Fd(a,b,0);},La:function(a,b,d,f){a=Y.getProgramInfoLog(nd[a]);null===a&&(a="(unknown error)");b=0<b&&f?ra(a,K,f,b):0;d&&(Q[d>>2]=b);},Ma:function(a,b,d){if(d)if(a>=ld)xd(1281);else if(a=nd[a],35716==
|
|
6660
6937
|
b)a=Y.getProgramInfoLog(a),null===a&&(a="(unknown error)"),Q[d>>2]=a.length+1;else if(35719==b){if(!a.Xe)for(b=0;b<Y.getProgramParameter(a,35718);++b)a.Xe=Math.max(a.Xe,Y.getActiveUniform(a,b).name.length+1);Q[d>>2]=a.Xe;}else if(35722==b){if(!a.Ve)for(b=0;b<Y.getProgramParameter(a,35721);++b)a.Ve=Math.max(a.Ve,Y.getActiveAttrib(a,b).name.length+1);Q[d>>2]=a.Ve;}else if(35381==b){if(!a.We)for(b=0;b<Y.getProgramParameter(a,35382);++b)a.We=Math.max(a.We,Y.getActiveUniformBlockName(a,b).length+1);Q[d>>
|
|
6661
6938
|
2]=a.We;}else Q[d>>2]=Y.getProgramParameter(a,b);else xd(1281);},dc:function(a,b,d){d?Q[d>>2]=Y.getRenderbufferParameter(a,b):xd(1281);},Na:function(a,b,d,f){a=Y.getShaderInfoLog(qd[a]);null===a&&(a="(unknown error)");b=0<b&&f?ra(a,K,f,b):0;d&&(Q[d>>2]=b);},Ob:function(a,b,d,f){a=Y.getShaderPrecisionFormat(a,b);Q[d>>2]=a.rangeMin;Q[d+4>>2]=a.rangeMax;Q[f>>2]=a.precision;},Oa:function(a,b,d){d?35716==b?(a=Y.getShaderInfoLog(qd[a]),null===a&&(a="(unknown error)"),Q[d>>2]=a?a.length+1:0):35720==b?(a=Y.getShaderSource(qd[a]),
|
|
6662
6939
|
Q[d>>2]=a?a.length+1:0):Q[d>>2]=Y.getShaderParameter(qd[a],b):xd(1281);},R:function(a){var b=ud[a];if(!b){switch(a){case 7939:b=Y.getSupportedExtensions()||[];b=b.concat(b.map(function(f){return "GL_"+f}));b=Gd(b.join(" "));break;case 7936:case 7937:case 37445:case 37446:(b=Y.getParameter(a))||xd(1280);b=b&&Gd(b);break;case 7938:b=Y.getParameter(7938);b=2<=x.version?"OpenGL ES 3.0 ("+b+")":"OpenGL ES 2.0 ("+b+")";b=Gd(b);break;case 35724:b=Y.getParameter(35724);var d=b.match(/^WebGL GLSL ES ([0-9]\.[0-9][0-9]?)(?:$| .*)/);
|
|
@@ -6676,7 +6953,7 @@ var w;w||(w=typeof CanvasKitInit !== 'undefined' ? CanvasKitInit : {});var da,ea
|
|
|
6676
6953
|
m[n+15];}}else h=S.subarray(f>>2,f+64*b>>2);Y.uniformMatrix4fv(Z(a),!!d,h);}},Kc:function(a){a=nd[a];Y.useProgram(a);Y.Hf=a;},Lc:function(a,b){Y.vertexAttrib1f(a,b);},Mc:function(a,b){Y.vertexAttrib2f(a,S[b>>2],S[b+4>>2]);},Nc:function(a,b){Y.vertexAttrib3f(a,S[b>>2],S[b+4>>2],S[b+8>>2]);},Oc:function(a,b){Y.vertexAttrib4f(a,S[b>>2],S[b+4>>2],S[b+8>>2],S[b+12>>2]);},pc:function(a,b){Y.vertexAttribDivisor(a,b);},qc:function(a,b,d,f,h){Y.vertexAttribIPointer(a,b,d,f,h);},Pc:function(a,b,d,f,h,m){Y.vertexAttribPointer(a,
|
|
6677
6954
|
b,d,!!f,h,m);},Qc:function(a,b,d,f){Y.viewport(a,b,d,f);},lb:function(a,b,d,f){Y.waitSync(td[a],b,(d>>>0)+4294967296*f);},tb:function(a){var b=K.length;a>>>=0;if(2147483648<a)return !1;for(var d=1;4>=d;d*=2){var f=b*(1+.2/d);f=Math.min(f,a+100663296);var h=Math;f=Math.max(a,f);h=h.min.call(h,2147483648,f+(65536-f%65536)%65536);a:{try{Ra.grow(h-kb.byteLength+65535>>>16);ob();var m=1;break a}catch(u){}m=void 0;}if(m)return !0}return !1},nb:function(){return x?x.Uf:0},wb:function(a,b){var d=0;Od().forEach(function(f,
|
|
6678
6955
|
h){var m=b+d;h=mb[a+4*h>>2]=m;for(m=0;m<f.length;++m)lb[h++>>0]=f.charCodeAt(m);lb[h>>0]=0;d+=f.length+1;});return 0},xb:function(a,b){var d=Od();mb[a>>2]=d.length;var f=0;d.forEach(function(h){f+=h.length+1;});mb[b>>2]=f;return 0},Jb:function(a){if(!noExitRuntime){if(w.onExit)w.onExit(a);Sa=!0;}wa(a,new Ja(a));},O:function(){return 52},ob:function(){return 52},Cb:function(){return 52},pb:function(){return 70},T:function(a,b,d,f){for(var h=0,m=0;m<d;m++){var u=mb[b>>2],n=mb[b+4>>2];b+=8;for(var q=0;q<
|
|
6679
|
-
n;q++){var v=K[u+q],E=Qd[a];0===v||10===v?((1===a?La:Ka)(Va(E,0)),E.length=0):E.push(v);}h+=n;}mb[f>>2]=h;return 0},c:function(){return Ma},k:ae,
|
|
6956
|
+
n;q++){var v=K[u+q],E=Qd[a];0===v||10===v?((1===a?La:Ka)(Va(E,0)),E.length=0):E.push(v);}h+=n;}mb[f>>2]=h;return 0},c:function(){return Ma},k:ae,o:be,l:ce,K:de,Lb:ee,_:fe,Z:ge,Q:he,p:ie,x:je,s:ke,w:le,Kb:me,Mb:ne,Nb:oe,d:function(a){Ma=a;},rb:function(a,b,d,f){return Ud(a,b,d,f)}};
|
|
6680
6957
|
(function(){function a(h){w.asm=h.exports;Ra=w.asm.dd;ob();pb=w.asm.fd;rb.unshift(w.asm.ed);ub--;w.monitorRunDependencies&&w.monitorRunDependencies(ub);0==ub&&(wb&&(h=wb,wb=null,h()));}function b(h){a(h.instance);}function d(h){return Cb().then(function(m){return WebAssembly.instantiate(m,f)}).then(function(m){return m}).then(h,function(m){Ka("failed to asynchronously prepare wasm: "+m);Qa(m);})}var f={a:pe};ub++;w.monitorRunDependencies&&w.monitorRunDependencies(ub);
|
|
6681
6958
|
if(w.instantiateWasm)try{return w.instantiateWasm(f,a)}catch(h){return Ka("Module.instantiateWasm callback failed with error: "+h),!1}(function(){return Na||"function"!=typeof WebAssembly.instantiateStreaming||yb()||zb.startsWith("file://")||za||"function"!=typeof fetch?d(b):fetch(zb,{credentials:"same-origin"}).then(function(h){return WebAssembly.instantiateStreaming(h,f).then(b,function(m){Ka("wasm streaming compile failed: "+m);Ka("falling back to ArrayBuffer instantiation");return d(b)})})})().catch(ea);
|
|
6682
6959
|
return {}})();w.___wasm_call_ctors=function(){return (w.___wasm_call_ctors=w.asm.ed).apply(null,arguments)};var Mc=w._free=function(){return (Mc=w._free=w.asm.gd).apply(null,arguments)},Hd=w._malloc=function(){return (Hd=w._malloc=w.asm.hd).apply(null,arguments)},Lc=w.___getTypeName=function(){return (Lc=w.___getTypeName=w.asm.id).apply(null,arguments)};w.___embind_register_native_and_builtin_types=function(){return (w.___embind_register_native_and_builtin_types=w.asm.jd).apply(null,arguments)};
|
|
@@ -6702,6 +6979,26 @@ var w;w||(w=typeof CanvasKitInit !== 'undefined' ? CanvasKitInit : {});var da,ea
|
|
|
6702
6979
|
var canvaskitExports = canvaskit.exports;
|
|
6703
6980
|
var CanvasKitInit = /*@__PURE__*/getDefaultExportFromCjs(canvaskitExports);
|
|
6704
6981
|
|
|
6982
|
+
var __defProp$2 = Object.defineProperty;
|
|
6983
|
+
var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
|
|
6984
|
+
var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
|
|
6985
|
+
var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
|
|
6986
|
+
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6987
|
+
var __spreadValues$2 = (a, b) => {
|
|
6988
|
+
for (var prop in b || (b = {}))
|
|
6989
|
+
if (__hasOwnProp$2.call(b, prop))
|
|
6990
|
+
__defNormalProp$2(a, prop, b[prop]);
|
|
6991
|
+
if (__getOwnPropSymbols$2)
|
|
6992
|
+
for (var prop of __getOwnPropSymbols$2(b)) {
|
|
6993
|
+
if (__propIsEnum$2.call(b, prop))
|
|
6994
|
+
__defNormalProp$2(a, prop, b[prop]);
|
|
6995
|
+
}
|
|
6996
|
+
return a;
|
|
6997
|
+
};
|
|
6998
|
+
var __publicField$2 = (obj, key, value) => {
|
|
6999
|
+
__defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
7000
|
+
return value;
|
|
7001
|
+
};
|
|
6705
7002
|
class Session {
|
|
6706
7003
|
/**
|
|
6707
7004
|
* A Session contains one or more activities. The session manages the start
|
|
@@ -6710,8 +7007,17 @@ class Session {
|
|
|
6710
7007
|
* @param options
|
|
6711
7008
|
*/
|
|
6712
7009
|
constructor(options) {
|
|
6713
|
-
this
|
|
6714
|
-
this
|
|
7010
|
+
__publicField$2(this, "options");
|
|
7011
|
+
__publicField$2(this, "fontManager");
|
|
7012
|
+
__publicField$2(this, "imageManager");
|
|
7013
|
+
__publicField$2(this, "currentActivity");
|
|
7014
|
+
__publicField$2(this, "uuid");
|
|
7015
|
+
__publicField$2(this, "dataStore");
|
|
7016
|
+
__publicField$2(this, "eventListeners", new Array());
|
|
7017
|
+
__publicField$2(this, "sessionDictionary", /* @__PURE__ */ new Map());
|
|
7018
|
+
__publicField$2(this, "canvasKit");
|
|
7019
|
+
__publicField$2(this, "initialized", false);
|
|
7020
|
+
__publicField$2(this, "version", "0.3.10 (b15b374e)");
|
|
6715
7021
|
this.options = options;
|
|
6716
7022
|
for (const activity of this.options.activities) {
|
|
6717
7023
|
if (this.options.activities.filter((a) => a === activity).length > 1) {
|
|
@@ -6729,61 +7035,253 @@ class Session {
|
|
|
6729
7035
|
this.uuid = Uuid.generate();
|
|
6730
7036
|
}
|
|
6731
7037
|
}
|
|
7038
|
+
/**
|
|
7039
|
+
* Executes a callback when the session initializes.
|
|
7040
|
+
*
|
|
7041
|
+
* @param callback - function to execute.
|
|
7042
|
+
* @param options - options for the callback.
|
|
7043
|
+
*/
|
|
7044
|
+
onInitialize(callback, options) {
|
|
7045
|
+
this.addEventListener(
|
|
7046
|
+
EventType.SessionInitialize,
|
|
7047
|
+
callback,
|
|
7048
|
+
options
|
|
7049
|
+
);
|
|
7050
|
+
}
|
|
7051
|
+
/**
|
|
7052
|
+
* Executes a callback when the session starts.
|
|
7053
|
+
*
|
|
7054
|
+
* @param callback - function to execute.
|
|
7055
|
+
* @param options - options for the callback.
|
|
7056
|
+
*/
|
|
7057
|
+
onStart(callback, options) {
|
|
7058
|
+
this.addEventListener(
|
|
7059
|
+
EventType.SessionStart,
|
|
7060
|
+
callback,
|
|
7061
|
+
options
|
|
7062
|
+
);
|
|
7063
|
+
}
|
|
7064
|
+
/**
|
|
7065
|
+
* Executes a callback when the session ends.
|
|
7066
|
+
*
|
|
7067
|
+
* @param callback - function to execute.
|
|
7068
|
+
* @param options - options for the callback.
|
|
7069
|
+
*/
|
|
7070
|
+
onEnd(callback, options) {
|
|
7071
|
+
this.addEventListener(
|
|
7072
|
+
EventType.SessionEnd,
|
|
7073
|
+
callback,
|
|
7074
|
+
options
|
|
7075
|
+
);
|
|
7076
|
+
}
|
|
7077
|
+
/**
|
|
7078
|
+
* Executes a callback when any activity in the session generates data.
|
|
7079
|
+
*
|
|
7080
|
+
* @param callback - function to execute.
|
|
7081
|
+
* @param options - options for the callback.
|
|
7082
|
+
*/
|
|
7083
|
+
onActivityData(callback, options) {
|
|
7084
|
+
this.addEventListener(
|
|
7085
|
+
EventType.ActivityData,
|
|
7086
|
+
callback,
|
|
7087
|
+
options
|
|
7088
|
+
);
|
|
7089
|
+
}
|
|
7090
|
+
addEventListener(type, callback, options) {
|
|
7091
|
+
const eventListener = {
|
|
7092
|
+
type,
|
|
7093
|
+
callback,
|
|
7094
|
+
key: options == null ? void 0 : options.key
|
|
7095
|
+
};
|
|
7096
|
+
if (options == null ? void 0 : options.replaceExisting) {
|
|
7097
|
+
this.eventListeners = this.eventListeners.filter(
|
|
7098
|
+
(listener) => !(listener.type === eventListener.type)
|
|
7099
|
+
);
|
|
7100
|
+
}
|
|
7101
|
+
this.eventListeners.push(eventListener);
|
|
7102
|
+
}
|
|
7103
|
+
raiseEventOnListeners(event, extra) {
|
|
7104
|
+
if (extra) {
|
|
7105
|
+
event = __spreadValues$2(__spreadValues$2({}, event), extra);
|
|
7106
|
+
}
|
|
7107
|
+
this.eventListeners.filter((listener) => listener.type === event.type).forEach((listener) => {
|
|
7108
|
+
listener.callback(event);
|
|
7109
|
+
});
|
|
7110
|
+
}
|
|
7111
|
+
async sessionActivityStartHandler(event) {
|
|
7112
|
+
const activityType = event.target.type === ActivityType.Game ? "game" : "survey";
|
|
7113
|
+
console.log(`\u{1F7E2} started activity (${activityType}) ${event.target.name}`);
|
|
7114
|
+
}
|
|
7115
|
+
async sessionActivityCancelHandler(event) {
|
|
7116
|
+
const activityType = event.target.type === ActivityType.Game ? "game" : "survey";
|
|
7117
|
+
console.log(`\u{1F6AB} canceled activity (${activityType}) ${event.target.name}`);
|
|
7118
|
+
if (this.nextActivity && this.options.autoGoToNextActivity !== false) {
|
|
7119
|
+
await this.goToNextActivity();
|
|
7120
|
+
return;
|
|
7121
|
+
}
|
|
7122
|
+
if (!this.nextActivity && this.options.autoEndAfterLastActivity !== false) {
|
|
7123
|
+
this.end();
|
|
7124
|
+
}
|
|
7125
|
+
}
|
|
7126
|
+
async sessionActivityEndHandler(event) {
|
|
7127
|
+
const activityType = event.target.type === ActivityType.Game ? "game" : "survey";
|
|
7128
|
+
console.log(`\u{1F534} ended activity (${activityType}) ${event.target.name}`);
|
|
7129
|
+
if (this.nextActivity && this.options.autoGoToNextActivity !== false) {
|
|
7130
|
+
await this.goToNextActivity();
|
|
7131
|
+
return;
|
|
7132
|
+
}
|
|
7133
|
+
if (!this.nextActivity && this.options.autoEndAfterLastActivity !== false) {
|
|
7134
|
+
this.end();
|
|
7135
|
+
}
|
|
7136
|
+
}
|
|
7137
|
+
async sessionActivityLifecycleHandler(event) {
|
|
7138
|
+
if (event.type === EventType.ActivityStart) {
|
|
7139
|
+
await this.sessionActivityStartHandler(event);
|
|
7140
|
+
return;
|
|
7141
|
+
}
|
|
7142
|
+
if (event.type === EventType.ActivityCancel) {
|
|
7143
|
+
await this.sessionActivityCancelHandler(event);
|
|
7144
|
+
return;
|
|
7145
|
+
}
|
|
7146
|
+
if (event.type === EventType.ActivityEnd) {
|
|
7147
|
+
await this.sessionActivityEndHandler(event);
|
|
7148
|
+
return;
|
|
7149
|
+
}
|
|
7150
|
+
throw new Error("unknown activity lifecycle event type");
|
|
7151
|
+
}
|
|
7152
|
+
activityResultsEventHandler(event) {
|
|
7153
|
+
this.raiseEventOnListeners(event);
|
|
7154
|
+
}
|
|
6732
7155
|
/**
|
|
6733
7156
|
* Asynchronously initializes the m2c2kit engine and loads assets
|
|
7157
|
+
*
|
|
7158
|
+
* @deprecated Use Session.initialize() instead.
|
|
6734
7159
|
*/
|
|
6735
7160
|
async init() {
|
|
6736
|
-
|
|
7161
|
+
console.warn(
|
|
7162
|
+
`The init() method of Session is deprecated. Use initialize() instead.`
|
|
7163
|
+
);
|
|
7164
|
+
return this.initialize();
|
|
7165
|
+
}
|
|
7166
|
+
/**
|
|
7167
|
+
* Check if the Activity uses the deprecated init() method.
|
|
7168
|
+
*
|
|
7169
|
+
* @remarks Activity.init() is deprecated and should be replaced with
|
|
7170
|
+
* Activity.initialize().
|
|
7171
|
+
*
|
|
7172
|
+
* @param activity
|
|
7173
|
+
* @returns true if the activity defines its own init() method, false otherwise.
|
|
7174
|
+
*/
|
|
7175
|
+
activityUsesDeprecatedInit(activity) {
|
|
7176
|
+
if (activity.type === ActivityType.Survey) {
|
|
7177
|
+
return false;
|
|
7178
|
+
}
|
|
7179
|
+
const activityPrototype = Object.getPrototypeOf(activity);
|
|
7180
|
+
const gamePrototype = Object.getPrototypeOf(activityPrototype);
|
|
7181
|
+
return (activityPrototype == null ? void 0 : activityPrototype.init) !== (gamePrototype == null ? void 0 : gamePrototype.init);
|
|
7182
|
+
}
|
|
7183
|
+
/**
|
|
7184
|
+
* Asynchronously initializes the m2c2kit engine and loads assets
|
|
7185
|
+
*/
|
|
7186
|
+
async initialize() {
|
|
6737
7187
|
console.log(`\u26AA @m2c2kit/core version ${this.version}`);
|
|
6738
|
-
Timer.start("
|
|
7188
|
+
Timer.start("sessionInitialize");
|
|
7189
|
+
const sessionInitializeEvent = {
|
|
7190
|
+
target: this,
|
|
7191
|
+
type: EventType.SessionInitialize
|
|
7192
|
+
};
|
|
7193
|
+
this.raiseEventOnListeners(sessionInitializeEvent);
|
|
6739
7194
|
DomHelpers.addLoadingElements();
|
|
6740
7195
|
DomHelpers.setSpinnerVisibility(true);
|
|
6741
7196
|
DomHelpers.setCanvasOverlayVisibility(true);
|
|
6742
7197
|
await Promise.all(
|
|
6743
7198
|
this.options.activities.map((activity) => {
|
|
6744
7199
|
activity.dataStore = this.dataStore;
|
|
6745
|
-
|
|
7200
|
+
activity.onStart(this.sessionActivityLifecycleHandler.bind(this));
|
|
7201
|
+
activity.onCancel(this.sessionActivityLifecycleHandler.bind(this));
|
|
7202
|
+
activity.onEnd(this.sessionActivityLifecycleHandler.bind(this));
|
|
7203
|
+
activity.onData((event) => {
|
|
7204
|
+
this.activityResultsEventHandler(event);
|
|
7205
|
+
});
|
|
7206
|
+
if (this.activityUsesDeprecatedInit(activity)) {
|
|
7207
|
+
console.warn(
|
|
7208
|
+
`game ${activity.id}: Activity.init() is deprecated. In the assessment class that extends Game, use Activity.initialize() instead:
|
|
7209
|
+
async initialize() {
|
|
7210
|
+
await super.initialize();
|
|
7211
|
+
...
|
|
7212
|
+
}
|
|
7213
|
+
`
|
|
7214
|
+
);
|
|
7215
|
+
return activity.init();
|
|
7216
|
+
}
|
|
7217
|
+
return activity.initialize();
|
|
6746
7218
|
})
|
|
6747
7219
|
);
|
|
6748
7220
|
const [canvasKit] = await this.getAsynchronousAssets();
|
|
6749
7221
|
this.loadAssets(canvasKit);
|
|
6750
7222
|
this.imageManager.removeScratchCanvas();
|
|
6751
7223
|
console.log(
|
|
6752
|
-
`\u26AA Session.
|
|
7224
|
+
`\u26AA Session.sessionInitialize() took ${Timer.elapsed(
|
|
7225
|
+
"sessionInitialize"
|
|
7226
|
+
).toFixed(0)} ms`
|
|
6753
7227
|
);
|
|
6754
|
-
Timer.remove("
|
|
6755
|
-
|
|
6756
|
-
if (
|
|
6757
|
-
|
|
6758
|
-
|
|
6759
|
-
|
|
6760
|
-
|
|
7228
|
+
Timer.remove("sessionInitialize");
|
|
7229
|
+
this.initialized = true;
|
|
7230
|
+
if (this.options.autoStartAfterInit !== false) {
|
|
7231
|
+
await this.start();
|
|
7232
|
+
}
|
|
7233
|
+
}
|
|
7234
|
+
/**
|
|
7235
|
+
* Waits for the session to be initialized.
|
|
7236
|
+
*
|
|
7237
|
+
* @remarks Session.initialize() is asynchronous, and it should be awaited
|
|
7238
|
+
* so that the session is fully initialized before calling Session.start().
|
|
7239
|
+
* If it is not awaited (or it cannot be awaited because the target
|
|
7240
|
+
* environment does not support top-level await), this function ensures that
|
|
7241
|
+
* the session has been initialized.
|
|
7242
|
+
*/
|
|
7243
|
+
async waitForSessionInitialization() {
|
|
7244
|
+
while (!this.initialized) {
|
|
7245
|
+
await new Promise(
|
|
7246
|
+
(resolve) => setTimeout(
|
|
7247
|
+
resolve,
|
|
7248
|
+
Constants.SESSION_INITIALIZATION_POLLING_INTERVAL_MS
|
|
7249
|
+
)
|
|
7250
|
+
);
|
|
6761
7251
|
}
|
|
6762
7252
|
}
|
|
6763
7253
|
/**
|
|
6764
7254
|
* Starts the session and starts the first activity.
|
|
6765
7255
|
*/
|
|
6766
7256
|
async start() {
|
|
7257
|
+
await this.waitForSessionInitialization();
|
|
7258
|
+
console.log("\u{1F7E2} started session");
|
|
7259
|
+
const sessionStartEvent = {
|
|
7260
|
+
target: this,
|
|
7261
|
+
type: EventType.SessionStart
|
|
7262
|
+
};
|
|
7263
|
+
this.raiseEventOnListeners(sessionStartEvent);
|
|
6767
7264
|
this.currentActivity = this.options.activities.find(Boolean);
|
|
6768
7265
|
if (this.currentActivity) {
|
|
6769
7266
|
DomHelpers.configureDomForActivity(this.currentActivity);
|
|
6770
7267
|
await this.currentActivity.start();
|
|
7268
|
+
} else {
|
|
7269
|
+
console.warn("no activities in session.");
|
|
7270
|
+
this.end();
|
|
6771
7271
|
}
|
|
6772
7272
|
}
|
|
6773
7273
|
/**
|
|
6774
7274
|
* Declares the session ended and sends callback.
|
|
6775
7275
|
*/
|
|
6776
7276
|
end() {
|
|
6777
|
-
|
|
6778
|
-
const sessionLifecycleChangeCallback = (_a = this.options.sessionCallbacks) == null ? void 0 : _a.onSessionLifecycle;
|
|
6779
|
-
if (sessionLifecycleChangeCallback) {
|
|
6780
|
-
sessionLifecycleChangeCallback({
|
|
6781
|
-
target: this,
|
|
6782
|
-
type: EventType.SessionEnd
|
|
6783
|
-
});
|
|
6784
|
-
}
|
|
7277
|
+
console.log("\u{1F534} ended session");
|
|
6785
7278
|
DomHelpers.hideAll();
|
|
6786
7279
|
this.stop();
|
|
7280
|
+
const sessionEndEvent = {
|
|
7281
|
+
target: this,
|
|
7282
|
+
type: EventType.SessionEnd
|
|
7283
|
+
};
|
|
7284
|
+
this.raiseEventOnListeners(sessionEndEvent);
|
|
6787
7285
|
}
|
|
6788
7286
|
stop() {
|
|
6789
7287
|
this.dispose();
|
|
@@ -6841,7 +7339,7 @@ class Session {
|
|
|
6841
7339
|
this.fontManager.gameTypefaces[this.currentActivity.uuid] = this.fontManager.gameTypefaces[currentActivityOldObject.uuid];
|
|
6842
7340
|
delete this.fontManager.gameTypefaces[currentActivityOldObject.uuid];
|
|
6843
7341
|
}
|
|
6844
|
-
await this.currentActivity.
|
|
7342
|
+
await this.currentActivity.initialize();
|
|
6845
7343
|
await this.currentActivity.start();
|
|
6846
7344
|
}
|
|
6847
7345
|
/**
|
|
@@ -6857,10 +7355,8 @@ class Session {
|
|
|
6857
7355
|
}
|
|
6858
7356
|
this.currentActivity.stop();
|
|
6859
7357
|
this.currentActivity = this.nextActivity;
|
|
6860
|
-
|
|
6861
|
-
|
|
6862
|
-
await this.currentActivity.start();
|
|
6863
|
-
}
|
|
7358
|
+
DomHelpers.configureDomForActivity(this.currentActivity);
|
|
7359
|
+
await this.currentActivity.start();
|
|
6864
7360
|
}
|
|
6865
7361
|
/**
|
|
6866
7362
|
* Stops the current activity and advances to next activity in the session.
|
|
@@ -7020,6 +7516,10 @@ var __spreadValues$1 = (a, b) => {
|
|
|
7020
7516
|
return a;
|
|
7021
7517
|
};
|
|
7022
7518
|
var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
|
|
7519
|
+
var __publicField$1 = (obj, key, value) => {
|
|
7520
|
+
__defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
7521
|
+
return value;
|
|
7522
|
+
};
|
|
7023
7523
|
class Shape extends Entity {
|
|
7024
7524
|
/**
|
|
7025
7525
|
* Rectangular, circular, or path-based shape
|
|
@@ -7029,31 +7529,45 @@ class Shape extends Entity {
|
|
|
7029
7529
|
constructor(options = {}) {
|
|
7030
7530
|
var _a;
|
|
7031
7531
|
super(options);
|
|
7032
|
-
this
|
|
7033
|
-
this
|
|
7034
|
-
this
|
|
7532
|
+
__publicField$1(this, "type", EntityType.Shape);
|
|
7533
|
+
__publicField$1(this, "isDrawable", true);
|
|
7534
|
+
__publicField$1(this, "isShape", true);
|
|
7035
7535
|
// Drawable options
|
|
7036
|
-
this
|
|
7037
|
-
this
|
|
7536
|
+
__publicField$1(this, "anchorPoint", { x: 0.5, y: 0.5 });
|
|
7537
|
+
__publicField$1(this, "zPosition", 0);
|
|
7038
7538
|
// Shape options
|
|
7039
7539
|
// TODO: fix the Size issue; should be readonly (calculated value) in all entities, but Rectangle
|
|
7040
|
-
this
|
|
7041
|
-
this
|
|
7042
|
-
this
|
|
7043
|
-
this
|
|
7044
|
-
this
|
|
7045
|
-
this
|
|
7046
|
-
this
|
|
7047
|
-
this
|
|
7048
|
-
this
|
|
7049
|
-
this
|
|
7050
|
-
this
|
|
7051
|
-
this
|
|
7540
|
+
__publicField$1(this, "shapeType", ShapeType.Undefined);
|
|
7541
|
+
__publicField$1(this, "circleOfRadius");
|
|
7542
|
+
__publicField$1(this, "rect");
|
|
7543
|
+
__publicField$1(this, "path");
|
|
7544
|
+
__publicField$1(this, "ckPath", null);
|
|
7545
|
+
__publicField$1(this, "ckPathWidth");
|
|
7546
|
+
__publicField$1(this, "ckPathHeight");
|
|
7547
|
+
__publicField$1(this, "pathSvgString");
|
|
7548
|
+
__publicField$1(this, "cornerRadius", 0);
|
|
7549
|
+
__publicField$1(this, "_fillColor", Constants.DEFAULT_SHAPE_FILL_COLOR);
|
|
7550
|
+
__publicField$1(this, "_strokeColor");
|
|
7551
|
+
__publicField$1(this, "lineWidth");
|
|
7552
|
+
__publicField$1(this, "_isAntialiased", true);
|
|
7553
|
+
__publicField$1(this, "_fillColorPaintAntialiased");
|
|
7554
|
+
__publicField$1(this, "_strokeColorPaintAntialiased");
|
|
7555
|
+
__publicField$1(this, "_fillColorPaintNotAntialiased");
|
|
7556
|
+
__publicField$1(this, "_strokeColorPaintNotAntialiased");
|
|
7557
|
+
__publicField$1(this, "svgPathRequestedWidth");
|
|
7558
|
+
__publicField$1(this, "svgPathRequestedHeight");
|
|
7559
|
+
__publicField$1(this, "svgPathScaleForResizing", 1);
|
|
7560
|
+
__publicField$1(this, "svgPathWidth", 0);
|
|
7561
|
+
__publicField$1(this, "svgPathHeight", 0);
|
|
7562
|
+
__publicField$1(this, "svgPreviousAbsoluteScale", NaN);
|
|
7563
|
+
__publicField$1(this, "svgPreviousAbsoluteX", NaN);
|
|
7564
|
+
__publicField$1(this, "svgPreviousAbsoluteY", NaN);
|
|
7565
|
+
__publicField$1(this, "pathIsSvgStringPath", false);
|
|
7052
7566
|
handleInterfaceOptions(this, options);
|
|
7053
|
-
if (((_a = options == null ? void 0 : options.path) == null ? void 0 : _a.
|
|
7567
|
+
if (((_a = options == null ? void 0 : options.path) == null ? void 0 : _a.svgPathString) !== void 0) {
|
|
7054
7568
|
this.shapeType = ShapeType.Path;
|
|
7055
7569
|
this.pathIsSvgStringPath = true;
|
|
7056
|
-
this.pathSvgString = options.path.
|
|
7570
|
+
this.pathSvgString = options.path.svgPathString;
|
|
7057
7571
|
this.svgPathRequestedWidth = options.path.width;
|
|
7058
7572
|
this.svgPathRequestedHeight = options.path.height;
|
|
7059
7573
|
if (this.svgPathRequestedHeight !== void 0 && this.svgPathRequestedWidth !== void 0) {
|
|
@@ -7531,6 +8045,10 @@ var __spreadValues = (a, b) => {
|
|
|
7531
8045
|
return a;
|
|
7532
8046
|
};
|
|
7533
8047
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
8048
|
+
var __publicField = (obj, key, value) => {
|
|
8049
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
8050
|
+
return value;
|
|
8051
|
+
};
|
|
7534
8052
|
class TextLine extends Entity {
|
|
7535
8053
|
/**
|
|
7536
8054
|
* Single-line text rendered on the screen.
|
|
@@ -7542,22 +8060,28 @@ class TextLine extends Entity {
|
|
|
7542
8060
|
constructor(options = {}) {
|
|
7543
8061
|
var _a;
|
|
7544
8062
|
super(options);
|
|
7545
|
-
this
|
|
7546
|
-
this
|
|
7547
|
-
this
|
|
8063
|
+
__publicField(this, "type", EntityType.TextLine);
|
|
8064
|
+
__publicField(this, "isDrawable", true);
|
|
8065
|
+
__publicField(this, "isText", true);
|
|
7548
8066
|
// Drawable options
|
|
7549
|
-
this
|
|
8067
|
+
__publicField(this, "zPosition", 0);
|
|
7550
8068
|
// We don't know TextLine width in advance, so we must text align left,
|
|
7551
8069
|
// and so anchorPoint is (0, .5). (we do know height, which is fontSize)
|
|
7552
|
-
this
|
|
8070
|
+
__publicField(this, "anchorPoint", { x: 0, y: 0.5 });
|
|
7553
8071
|
// Text options
|
|
7554
|
-
this
|
|
8072
|
+
__publicField(this, "_text", "");
|
|
8073
|
+
// public getter/setter is below
|
|
8074
|
+
__publicField(this, "_fontName");
|
|
8075
|
+
// public getter/setter is below
|
|
8076
|
+
__publicField(this, "_fontColor", Constants.DEFAULT_FONT_COLOR);
|
|
7555
8077
|
// public getter/setter is below
|
|
7556
|
-
this
|
|
8078
|
+
__publicField(this, "_fontSize", Constants.DEFAULT_FONT_SIZE);
|
|
7557
8079
|
// public getter/setter is below
|
|
7558
|
-
this
|
|
7559
|
-
this
|
|
7560
|
-
this
|
|
8080
|
+
__publicField(this, "paint");
|
|
8081
|
+
__publicField(this, "font");
|
|
8082
|
+
__publicField(this, "typeface", null);
|
|
8083
|
+
__publicField(this, "_translatedText", "");
|
|
8084
|
+
__publicField(this, "missingTranslationPaint");
|
|
7561
8085
|
handleInterfaceOptions(this, options);
|
|
7562
8086
|
this.size.height = this.fontSize;
|
|
7563
8087
|
this.size.width = (_a = options.width) != null ? _a : NaN;
|