@m2c2kit/core 0.1.9 → 0.3.5
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/assets/canvaskit.wasm +0 -0
- package/assets/css/bootstrap-datepicker.standalone.css +539 -0
- package/assets/css/bootstrap-slider.css +328 -0
- package/assets/css/defaultV2.css +3655 -0
- package/assets/css/m2c2kit.css +72 -0
- package/assets/css/modern.css +2564 -0
- package/assets/css/nouislider.css +309 -0
- package/assets/css/select2.css +712 -0
- package/assets/css/survey.css +1006 -0
- package/dist/index.d.ts +2876 -1680
- package/dist/index.js +7657 -16
- package/index.html +31 -0
- package/package.json +29 -23
- package/post-install.mjs +98 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,1685 +1,2881 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Image, CanvasKit, FontMgr, Typeface, Canvas, Surface, EmbindObject, Font, Paint, ParagraphBuilder, Paragraph, Path, PaintStyle } from 'canvaskit-wasm';
|
|
2
2
|
|
|
3
|
-
declare class GlobalVariables {
|
|
4
|
-
now: number;
|
|
5
|
-
deltaTime: number;
|
|
6
|
-
canvasScale: number;
|
|
7
|
-
rootScale: number;
|
|
8
|
-
canvasCssWidth: number;
|
|
9
|
-
canvasCssHeight: number;
|
|
3
|
+
declare class GlobalVariables {
|
|
4
|
+
now: number;
|
|
5
|
+
deltaTime: number;
|
|
6
|
+
canvasScale: number;
|
|
7
|
+
rootScale: number;
|
|
8
|
+
canvasCssWidth: number;
|
|
9
|
+
canvasCssHeight: number;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
declare global {
|
|
13
|
-
var Globals: GlobalVariables;
|
|
14
|
-
}
|
|
12
|
+
declare global {
|
|
13
|
+
var Globals: GlobalVariables;
|
|
14
|
+
}
|
|
15
15
|
//# sourceMappingURL=Globals.d.ts.map
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
*/
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
|
|
88
|
-
*/
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
*
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
*
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
*/
|
|
175
|
-
|
|
176
|
-
/**
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
/**
|
|
198
|
-
*
|
|
199
|
-
*
|
|
200
|
-
* @
|
|
201
|
-
*
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
/**
|
|
209
|
-
*
|
|
210
|
-
*
|
|
211
|
-
* @
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
*
|
|
216
|
-
*
|
|
217
|
-
* @
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
*
|
|
225
|
-
*
|
|
226
|
-
*
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
*
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
*
|
|
237
|
-
*
|
|
238
|
-
*
|
|
239
|
-
*
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
*
|
|
249
|
-
*
|
|
250
|
-
*
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
private
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
/**
|
|
322
|
-
*
|
|
323
|
-
*
|
|
324
|
-
*
|
|
325
|
-
* @
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
*
|
|
332
|
-
*
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
/**
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
/**
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
*
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
*
|
|
459
|
-
*
|
|
460
|
-
* @
|
|
461
|
-
*
|
|
462
|
-
*
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
*
|
|
470
|
-
*
|
|
471
|
-
*
|
|
472
|
-
*
|
|
473
|
-
*
|
|
474
|
-
*
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
*
|
|
481
|
-
*
|
|
482
|
-
*
|
|
483
|
-
*
|
|
484
|
-
*
|
|
485
|
-
*
|
|
486
|
-
* @param
|
|
487
|
-
*
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
*
|
|
494
|
-
*
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
/**
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
interface
|
|
612
|
-
/**
|
|
613
|
-
|
|
614
|
-
/**
|
|
615
|
-
|
|
616
|
-
}
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
/**
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
/**
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
static
|
|
749
|
-
static
|
|
750
|
-
static
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
*
|
|
819
|
-
*
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
*
|
|
827
|
-
*
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
*
|
|
832
|
-
*
|
|
833
|
-
*
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
*
|
|
845
|
-
*
|
|
846
|
-
* @param
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
}
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
}
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
private
|
|
1062
|
-
private
|
|
1063
|
-
private
|
|
1064
|
-
private
|
|
1065
|
-
private
|
|
1066
|
-
|
|
1067
|
-
private
|
|
1068
|
-
private
|
|
1069
|
-
private
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
*
|
|
1074
|
-
*
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
*
|
|
1081
|
-
*
|
|
1082
|
-
* @
|
|
1083
|
-
*
|
|
1084
|
-
*
|
|
1085
|
-
*
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
*
|
|
1092
|
-
*
|
|
1093
|
-
*
|
|
1094
|
-
*
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
*
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
*
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
/**
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
*
|
|
1159
|
-
*
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
*
|
|
1218
|
-
*
|
|
1219
|
-
*
|
|
1220
|
-
*
|
|
1221
|
-
*
|
|
1222
|
-
*
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
*
|
|
1229
|
-
*
|
|
1230
|
-
* @
|
|
1231
|
-
*
|
|
1232
|
-
*
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
*
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
*
|
|
1242
|
-
*
|
|
1243
|
-
* @
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
*
|
|
1248
|
-
*
|
|
1249
|
-
*
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
/**
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
/**
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
/**
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
private
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
*
|
|
1325
|
-
*
|
|
1326
|
-
*
|
|
1327
|
-
*
|
|
1328
|
-
*
|
|
1329
|
-
*
|
|
1330
|
-
* @param
|
|
1331
|
-
*
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
*
|
|
1366
|
-
*
|
|
1367
|
-
* @
|
|
1368
|
-
*
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
*
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
*
|
|
1410
|
-
*
|
|
1411
|
-
* @
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
*
|
|
1429
|
-
*
|
|
1430
|
-
*
|
|
1431
|
-
* @
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
draw
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
*
|
|
1444
|
-
*
|
|
1445
|
-
*
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
*
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
*
|
|
1459
|
-
*
|
|
1460
|
-
* @
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
*
|
|
1465
|
-
*
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
*
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
*
|
|
1475
|
-
*
|
|
1476
|
-
* @
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
*
|
|
1485
|
-
*
|
|
1486
|
-
*
|
|
1487
|
-
*
|
|
1488
|
-
*
|
|
1489
|
-
*
|
|
1490
|
-
*
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
*
|
|
1496
|
-
*
|
|
1497
|
-
* @
|
|
1498
|
-
*
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
/**
|
|
1517
|
-
*
|
|
1518
|
-
*
|
|
1519
|
-
*
|
|
1520
|
-
*
|
|
1521
|
-
*
|
|
1522
|
-
*
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
17
|
+
/**
|
|
18
|
+
* The type of activity.
|
|
19
|
+
*
|
|
20
|
+
* @remarks Currently, m2c2kit has only Game and Survey activities.
|
|
21
|
+
*/
|
|
22
|
+
declare enum ActivityType {
|
|
23
|
+
Game = "Game",
|
|
24
|
+
Survey = "Survey"
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** Base interface for all Activity events. */
|
|
28
|
+
interface ActivityEvent extends EventBase {
|
|
29
|
+
target: Activity;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Data from activities are stored as key (string) value pairs. */
|
|
33
|
+
interface ActivityKeyValueData {
|
|
34
|
+
[key: string]: string | number | boolean | object | undefined | null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** A snapshot of performance at a single point in time.
|
|
38
|
+
*
|
|
39
|
+
* @remarks This describes performance of the application internals, not the
|
|
40
|
+
* participant. Do not store participant data here. Use snake case because
|
|
41
|
+
* these data will be directly exported to persistence.
|
|
42
|
+
*/
|
|
43
|
+
interface ActivityMetric {
|
|
44
|
+
[key: string]: string | number | boolean | object | undefined | null;
|
|
45
|
+
activity_type: ActivityType;
|
|
46
|
+
activity_uuid: string;
|
|
47
|
+
iso8601_timestamp: string;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
interface JsonSchema {
|
|
51
|
+
/** Data type of the value or array of acceptable data types. */
|
|
52
|
+
type?: JsonSchemaDataType | JsonSchemaDataType[];
|
|
53
|
+
/** Values the schema can have. */
|
|
54
|
+
enum?: unknown[];
|
|
55
|
+
/** Annotation to indicate the type of string value, e.g., "date-time" or "email". */
|
|
56
|
+
format?: string;
|
|
57
|
+
/** Intent of the schema. */
|
|
58
|
+
title?: string;
|
|
59
|
+
/** Description of the schema. */
|
|
60
|
+
description?: string;
|
|
61
|
+
/** If the value is an object, the properties in JsonSchema. */
|
|
62
|
+
properties?: {
|
|
63
|
+
[key: string]: JsonSchema;
|
|
64
|
+
};
|
|
65
|
+
/** If the value is an array, the array items in JsonSchema. */
|
|
66
|
+
items?: JsonSchema;
|
|
67
|
+
/** Required properties. */
|
|
68
|
+
required?: string[];
|
|
69
|
+
/** Reference to object definitions. */
|
|
70
|
+
$ref?: string;
|
|
71
|
+
/** Object definitions. */
|
|
72
|
+
$defs?: object;
|
|
73
|
+
/** Comment string. */
|
|
74
|
+
$comment?: string;
|
|
75
|
+
/** Dialect of JSON Schema. */
|
|
76
|
+
$schema?: string;
|
|
77
|
+
/** Default value. */
|
|
78
|
+
default?: any;
|
|
79
|
+
}
|
|
80
|
+
type JsonSchemaDataType = "string" | "number" | "integer" | "object" | "array" | "boolean" | "null";
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* All the data created by an activity.
|
|
84
|
+
*/
|
|
85
|
+
interface ActivityResults {
|
|
86
|
+
/** All the data created by the activity. */
|
|
87
|
+
data: ActivityKeyValueData;
|
|
88
|
+
/** JSON schema describing the structure of the data. */
|
|
89
|
+
dataSchema: JsonSchema;
|
|
90
|
+
/** Parameters under which the activity was run. */
|
|
91
|
+
activityConfiguration: unknown;
|
|
92
|
+
/** JSON schema describing the activity parameters. */
|
|
93
|
+
activityConfigurationSchema: JsonSchema;
|
|
94
|
+
/** Metrics describing internal application performance. */
|
|
95
|
+
activityMetrics?: Array<ActivityMetric>;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Dispatched when new data is created by an activity.
|
|
100
|
+
*
|
|
101
|
+
* @remarks Event contains all the data created by an activity, with
|
|
102
|
+
* separate properties for the newly created data. ActivityResultsEvent
|
|
103
|
+
* inherts "data" from ActivityResults, which contains the complete data
|
|
104
|
+
* up to this point (both new and existing data).
|
|
105
|
+
*/
|
|
106
|
+
interface ActivityResultsEvent extends ActivityEvent, ActivityResults {
|
|
107
|
+
/** New data created by the activity, which dispatched this event */
|
|
108
|
+
newData: ActivityKeyValueData;
|
|
109
|
+
/** JSON schema describing the new data */
|
|
110
|
+
newDataSchema: JsonSchema;
|
|
111
|
+
/** ISO 8601 timestamp of the event. Specifically, value of "new Date().toISOString()" executed on the device when the ActivityResultsEvent occured. */
|
|
112
|
+
iso8601Timestamp: string;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* An interface for persisting data.
|
|
117
|
+
*
|
|
118
|
+
* @remarks This interface saves activity results as well as saves and
|
|
119
|
+
* retrieves arbitrary key-value items that activities can use.
|
|
120
|
+
*
|
|
121
|
+
* The underlying persistence provider of the store must
|
|
122
|
+
* be previously set in the activity's `Session` before use. The
|
|
123
|
+
* implementation of the store is not provided by the \@m2c2kit/core library.
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* ```
|
|
127
|
+
* import { LocalDatabase } from "@m2c2kit/db";
|
|
128
|
+
* ...
|
|
129
|
+
* const db: IDataStore = new LocalDatabase();
|
|
130
|
+
* session.dataStore = db;
|
|
131
|
+
* session.init();
|
|
132
|
+
* ```
|
|
133
|
+
*/
|
|
134
|
+
interface IDataStore {
|
|
135
|
+
/** Saves activity results in the data store. */
|
|
136
|
+
saveActivityResults(ev: ActivityResultsEvent): Promise<string>;
|
|
137
|
+
/** Sets the value of an item. The key will be saved to the store as provided;
|
|
138
|
+
* if namespacing or other formatting is desired, it must be done before
|
|
139
|
+
* calling this method. activityId can be used by the store for indexing. */
|
|
140
|
+
setItem(key: string, value: string | number | boolean | object | undefined | null, activityId: string): Promise<string>;
|
|
141
|
+
/** Gets the value of an item by its key. */
|
|
142
|
+
getItem<T extends string | number | boolean | object | undefined | null>(key: string): Promise<T>;
|
|
143
|
+
/** Deletes an item by its key. */
|
|
144
|
+
deleteItem(key: string): Promise<void>;
|
|
145
|
+
/** Deletes all items. */
|
|
146
|
+
clearItemsByActivityId(activityId: string): Promise<void>;
|
|
147
|
+
/** Returns keys of all items. */
|
|
148
|
+
itemsKeysByActivityId(activityId: string): Promise<string[]>;
|
|
149
|
+
/** Determines if the key exists. */
|
|
150
|
+
itemExists(key: string): Promise<boolean>;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
declare class LoadedImage {
|
|
154
|
+
name: string;
|
|
155
|
+
image: Image;
|
|
156
|
+
width: number;
|
|
157
|
+
height: number;
|
|
158
|
+
constructor(name: string, image: Image, width: number, height: number);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Image that can be rendered by a browser from a URL or from a
|
|
163
|
+
* HTML svg tag in string form. Provide either url or svgString, not both.
|
|
164
|
+
*/
|
|
165
|
+
interface BrowserImage {
|
|
166
|
+
/** Name that will be used to refer to the image. Must be unique among all
|
|
167
|
+
* images within a game */
|
|
168
|
+
imageName: string;
|
|
169
|
+
/** Width to scale image to */
|
|
170
|
+
width: number;
|
|
171
|
+
/** Height to scale image to */
|
|
172
|
+
height: number;
|
|
173
|
+
/** The HTML SVG tag, in string form, that will be rendered and loaded.
|
|
174
|
+
* Must begin with <svg> and end with </svg> */
|
|
175
|
+
svgString?: string;
|
|
176
|
+
/** URL of image asset (svg, png, jpg) to render and load */
|
|
177
|
+
url?: string;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
interface GameImages {
|
|
181
|
+
uuid: string;
|
|
182
|
+
images: Array<BrowserImage>;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
declare class LoadedImages {
|
|
186
|
+
[gameUuid: string]: {
|
|
187
|
+
[name: string]: LoadedImage;
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
declare class ImageManager {
|
|
191
|
+
canvasKit?: CanvasKit;
|
|
192
|
+
private renderedImages;
|
|
193
|
+
loadedImages: LoadedImages;
|
|
194
|
+
private _scratchCanvas?;
|
|
195
|
+
private ctx?;
|
|
196
|
+
private scale?;
|
|
197
|
+
/**
|
|
198
|
+
* Returns a CanvasKit Image that was previously rendered by the ImageManager.
|
|
199
|
+
*
|
|
200
|
+
* @remarks Typically, this won't be called directly because a programmer
|
|
201
|
+
* will use a higher-level abstraction (m2c2kit Sprite).
|
|
202
|
+
*
|
|
203
|
+
* @param gameUuid - The game that the image resource is part of
|
|
204
|
+
* @param imageName - The name given to the rendered image
|
|
205
|
+
* @returns A CanvasKit Image
|
|
206
|
+
*/
|
|
207
|
+
getLoadedImage(gameUuid: string, imageName: string): LoadedImage;
|
|
208
|
+
/**
|
|
209
|
+
* Adds a CanvasKit Image to the images available to a given game.
|
|
210
|
+
*
|
|
211
|
+
* @remarks Typically, a programmer won't call this because images will be
|
|
212
|
+
* automatically rendered and loaded in the Activity async init.
|
|
213
|
+
* The only time this function is called in-game is when our internal
|
|
214
|
+
* methods add screenshot images needed for transitions.
|
|
215
|
+
*
|
|
216
|
+
* @param loadedImage - An image that has been converted to a CanvasKit Image
|
|
217
|
+
* @param gameUuid - The game that the Image is part of
|
|
218
|
+
*/
|
|
219
|
+
addLoadedImage(loadedImage: LoadedImage, gameUuid: string): void;
|
|
220
|
+
/**
|
|
221
|
+
* Renders game images from their original format (png, jpg, svg) to
|
|
222
|
+
* CanvasKit Image.
|
|
223
|
+
*
|
|
224
|
+
* @remarks Typically, a programmer won't call this because the Session
|
|
225
|
+
* object will manage this. Rendering is an async activity, and thus
|
|
226
|
+
* this method returns a promise. Rendering of all images is done in
|
|
227
|
+
* parallel.
|
|
228
|
+
*
|
|
229
|
+
* @param allGamesImages - An array of GameImages data structures that
|
|
230
|
+
* specify the image's desired size, it's name, and where the image to be
|
|
231
|
+
* rendered is located (e.g., embedded svgString or url)
|
|
232
|
+
* @returns A promise that completes when all game images have rendered
|
|
233
|
+
*/
|
|
234
|
+
renderImages(allGamesImages: Array<GameImages>): Promise<void[]>;
|
|
235
|
+
/**
|
|
236
|
+
* Adds all rendered CanvasKit Images to the images available to m2c2kit.
|
|
237
|
+
*
|
|
238
|
+
* @remarks Typically, a programmer won't call this because the Session
|
|
239
|
+
* object will manage this.
|
|
240
|
+
*/
|
|
241
|
+
loadAllGamesRenderedImages(): void;
|
|
242
|
+
/**
|
|
243
|
+
* Our private method rendering an image to a CanvasKit Image
|
|
244
|
+
*
|
|
245
|
+
* @remarks This is complex because there is a separate flow to render
|
|
246
|
+
* svg images versus other (e.g., jpg, png). Svg images may be provided
|
|
247
|
+
* in a url or inline. In addition, there is a Firefox svg rendering issue,
|
|
248
|
+
* see below, that must be handled.
|
|
249
|
+
* Additional complexity comes from the potentially multiple async steps and
|
|
250
|
+
* the multiple errors that can happen throughout.
|
|
251
|
+
*
|
|
252
|
+
* @param gameUuid
|
|
253
|
+
* @param browserImage
|
|
254
|
+
* @returns A promise of type void
|
|
255
|
+
*/
|
|
256
|
+
private renderBrowserImage;
|
|
257
|
+
private inferImageSubtypeFromUrl;
|
|
258
|
+
private convertRenderedDataUrlImageToCanvasKitImage;
|
|
259
|
+
/**
|
|
260
|
+
* Returns the scratchCanvas, which is an extra, non-visible canvas in the
|
|
261
|
+
* DOM we use so the native browser can render images like svg, png, jpg,
|
|
262
|
+
* that we later will convert to CanvasKit Image.
|
|
263
|
+
*/
|
|
264
|
+
private get scratchCanvas();
|
|
265
|
+
private dataURLtoArrayBuffer;
|
|
266
|
+
removeScratchCanvas(): void;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
interface GameFontUrls {
|
|
270
|
+
uuid: string;
|
|
271
|
+
fontUrls: Array<string>;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* This class contains all the fonts for all the games in the activity.
|
|
276
|
+
* Fonts have been converted to canvaskit Typeface
|
|
277
|
+
*/
|
|
278
|
+
declare class GameTypefaces {
|
|
279
|
+
[gameUuid: string]: {
|
|
280
|
+
[fontFamily: string]: Typeface;
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Class for loading, preparing, and providing fonts to games.
|
|
285
|
+
*
|
|
286
|
+
* @remarks FOR INTERNAL USE ONLY
|
|
287
|
+
*/
|
|
288
|
+
declare class FontManager {
|
|
289
|
+
canvasKit?: CanvasKit;
|
|
290
|
+
fontMgr?: FontMgr;
|
|
291
|
+
gameTypefaces: GameTypefaces;
|
|
292
|
+
private allGamesFontData?;
|
|
293
|
+
/**
|
|
294
|
+
* Gets a typeface that was previously loaded for the specified game.
|
|
295
|
+
*
|
|
296
|
+
* @param gameUuid
|
|
297
|
+
* @param fontFamily
|
|
298
|
+
* @returns the requested Typeface
|
|
299
|
+
*/
|
|
300
|
+
getTypeface(gameUuid: string, fontFamily: string): Typeface;
|
|
301
|
+
/**
|
|
302
|
+
* Gets names of fonts loaded for the specified game.
|
|
303
|
+
*
|
|
304
|
+
* @param gameUuid
|
|
305
|
+
* @returns array of font family names
|
|
306
|
+
*/
|
|
307
|
+
getFontNames(gameUuid: string): Array<string>;
|
|
308
|
+
/**
|
|
309
|
+
* Fetches all fonts for all games.
|
|
310
|
+
*
|
|
311
|
+
* @param allGamesFontUrls
|
|
312
|
+
* @returns
|
|
313
|
+
*/
|
|
314
|
+
fetchFonts(allGamesFontUrls: Array<GameFontUrls>): Promise<void>;
|
|
315
|
+
/**
|
|
316
|
+
* Takes the fonts, which have been previously fetched and converted into
|
|
317
|
+
* Array Buffers using FontManager.fetchFonts(), and makes them available
|
|
318
|
+
* to our engine
|
|
319
|
+
*/
|
|
320
|
+
loadAllGamesFontData(): void;
|
|
321
|
+
/**
|
|
322
|
+
* For the specified game, fetches all fonts in the array of urls and
|
|
323
|
+
* stores fonts as array buffers.
|
|
324
|
+
*
|
|
325
|
+
* @param gameUuid
|
|
326
|
+
* @param fontUrls - array of font urls
|
|
327
|
+
* @returns
|
|
328
|
+
*/
|
|
329
|
+
private fetchGameFontsAsArrayBuffers;
|
|
330
|
+
/**
|
|
331
|
+
* For the specified game, loads all fonts from array buffers and makes
|
|
332
|
+
* fonts available within canvaskit as a Typeface
|
|
333
|
+
*
|
|
334
|
+
* @param gameUuid
|
|
335
|
+
* @param fonts - array of fonts in array buffer form
|
|
336
|
+
*/
|
|
337
|
+
private loadGameFonts;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* Notifies when an activity starts, ends, cancels, or
|
|
342
|
+
* creates data.
|
|
343
|
+
*/
|
|
344
|
+
interface ActivityLifecycleEvent extends ActivityEvent {
|
|
345
|
+
results?: ActivityResults;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
interface ActivityCallbacks {
|
|
349
|
+
/** Callback executed when the activity lifecycle changes, such as when it ends. */
|
|
350
|
+
onActivityLifecycle?: (event: ActivityLifecycleEvent) => void;
|
|
351
|
+
/** Callback executed when an activity creates some data. */
|
|
352
|
+
onActivityResults?: (event: ActivityResultsEvent) => void;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/** Base interface for all Session events. */
|
|
356
|
+
interface SessionEvent extends EventBase {
|
|
357
|
+
target: Session;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* Notifies when a session starts, ends, or initializes.
|
|
362
|
+
*/
|
|
363
|
+
interface SessionLifecycleEvent extends SessionEvent {
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
interface SessionCallbacks {
|
|
367
|
+
/** Callback executed when the session lifecycle changes, such as when it is initialized. */
|
|
368
|
+
onSessionLifecycle?: (event: SessionLifecycleEvent) => void;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
interface SessionOptions {
|
|
372
|
+
/** The activities that compose this session */
|
|
373
|
+
activities: Array<Activity>;
|
|
374
|
+
/** Callbacks executed when activity events occurs, such as when activity creates data or ends */
|
|
375
|
+
activityCallbacks?: ActivityCallbacks;
|
|
376
|
+
/** Callbacks executed when session events occur */
|
|
377
|
+
sessionCallbacks?: SessionCallbacks;
|
|
378
|
+
/** Url of the canvaskit.wasm binary. Always set to the default value of "assets/canvaskit.wasm" */
|
|
379
|
+
canvasKitWasmUrl: "assets/canvaskit.wasm";
|
|
380
|
+
/** Use a specified session UUID, rather than create a new one */
|
|
381
|
+
sessionUuid?: string;
|
|
382
|
+
/** NOT IMPLEMENTED YET: Orientation the screen should be locked to for this session. Value will be passed into the ScreenOrientation.lock() Web API. */
|
|
383
|
+
orientation?: "natural" | "landscape" | "portrait" | "portrait-primary" | "portrait-secondary" | "landscape-primary" | "landscape-secondary";
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
declare class Session {
|
|
387
|
+
options: SessionOptions;
|
|
388
|
+
fontManager: FontManager;
|
|
389
|
+
imageManager: ImageManager;
|
|
390
|
+
currentActivity?: Activity;
|
|
391
|
+
uuid: string;
|
|
392
|
+
dataStore?: IDataStore;
|
|
393
|
+
private sessionDictionary;
|
|
394
|
+
private canvasKit?;
|
|
395
|
+
private version;
|
|
396
|
+
/**
|
|
397
|
+
* A Session contains one or more activities. The session manages the start
|
|
398
|
+
* and stop of activities, and advancement to next activity
|
|
399
|
+
*
|
|
400
|
+
* @param options
|
|
401
|
+
*/
|
|
402
|
+
constructor(options: SessionOptions);
|
|
403
|
+
/**
|
|
404
|
+
* Asynchronously initializes the m2c2kit engine and loads assets
|
|
405
|
+
*/
|
|
406
|
+
init(): Promise<void>;
|
|
407
|
+
/**
|
|
408
|
+
* Starts the session and starts the first activity.
|
|
409
|
+
*/
|
|
410
|
+
start(): Promise<void>;
|
|
411
|
+
/**
|
|
412
|
+
* Declares the session ended and sends callback.
|
|
413
|
+
*/
|
|
414
|
+
end(): void;
|
|
415
|
+
private stop;
|
|
416
|
+
/**
|
|
417
|
+
* Frees up resources that were allocated to run the session.
|
|
418
|
+
*
|
|
419
|
+
* @remarks This will be done automatically by the m2c2kit library;
|
|
420
|
+
* the end-user must not call this.
|
|
421
|
+
*/
|
|
422
|
+
private dispose;
|
|
423
|
+
/**
|
|
424
|
+
* Stops the current activity and goes to the activity with the provided id.
|
|
425
|
+
*
|
|
426
|
+
* @param options
|
|
427
|
+
*/
|
|
428
|
+
goToActivity(options: GoToActivityOptions): Promise<void>;
|
|
429
|
+
/**
|
|
430
|
+
* Stops the current activity and advances to next activity in the session.
|
|
431
|
+
* If there is no activity after the current activity, throws error.
|
|
432
|
+
*/
|
|
433
|
+
goToNextActivity(): Promise<void>;
|
|
434
|
+
/**
|
|
435
|
+
* Stops the current activity and advances to next activity in the session.
|
|
436
|
+
* If there is no activity after the current activity, throws error.
|
|
437
|
+
*
|
|
438
|
+
* @deprecated Use goToNextActivity() instead.
|
|
439
|
+
*/
|
|
440
|
+
advanceToNextActivity(): Promise<void>;
|
|
441
|
+
/**
|
|
442
|
+
* Gets the next activity after the current one, or undefined if
|
|
443
|
+
* this is the last activity.
|
|
444
|
+
*/
|
|
445
|
+
get nextActivity(): Activity | undefined;
|
|
446
|
+
/**
|
|
447
|
+
* Saves an item to the session's key-value dictionary.
|
|
448
|
+
*
|
|
449
|
+
* @remarks The session dictionary is not persisted. It is available only
|
|
450
|
+
* during the actively running session. It is useful for storing temporary
|
|
451
|
+
* data to coordinate between activities.
|
|
452
|
+
*
|
|
453
|
+
* @param key - item key
|
|
454
|
+
* @param value - item value
|
|
455
|
+
*/
|
|
456
|
+
dictionarySetItem(key: string, value: SessionDictionaryValues): void;
|
|
457
|
+
/**
|
|
458
|
+
* Gets an item value from the session's key-value dictionary.
|
|
459
|
+
*
|
|
460
|
+
* @remarks The session dictionary is not persisted. It is available only
|
|
461
|
+
* during the actively running session. It is useful for storing temporary
|
|
462
|
+
* data to coordinate between activities.
|
|
463
|
+
*
|
|
464
|
+
* @param key - item key
|
|
465
|
+
* @returns value of the item
|
|
466
|
+
*/
|
|
467
|
+
dictionaryGetItem<T extends SessionDictionaryValues>(key: string): T;
|
|
468
|
+
/**
|
|
469
|
+
* Deletes an item value from the session's key-value dictionary.
|
|
470
|
+
*
|
|
471
|
+
* @remarks The session dictionary is not persisted. It is available only
|
|
472
|
+
* during the actively running session. It is useful for storing temporary
|
|
473
|
+
* data to coordinate between activities.
|
|
474
|
+
*
|
|
475
|
+
* @param key - item key
|
|
476
|
+
* @returns true if the item was deleted, false if it did not exist
|
|
477
|
+
*/
|
|
478
|
+
dictionaryDeleteItem(key: string): boolean;
|
|
479
|
+
/**
|
|
480
|
+
* Determines if a key exists in the activity's key-value dictionary.
|
|
481
|
+
*
|
|
482
|
+
* @remarks The session dictionary is not persisted. It is available only
|
|
483
|
+
* during the actively running session. It is useful for storing temporary
|
|
484
|
+
* data to coordinate between activities.
|
|
485
|
+
*
|
|
486
|
+
* @param key - item key
|
|
487
|
+
* @returns true if the key exists, false otherwise
|
|
488
|
+
*/
|
|
489
|
+
dictionaryItemExists(key: string): boolean;
|
|
490
|
+
/**
|
|
491
|
+
* Gets asynchronous assets, including initialization of canvaskit wasm,
|
|
492
|
+
* fetching of fonts from specified urls, and rendering and fetching
|
|
493
|
+
* of images
|
|
494
|
+
* @returns
|
|
495
|
+
*/
|
|
496
|
+
private getAsynchronousAssets;
|
|
497
|
+
private loadCanvasKit;
|
|
498
|
+
private loadAssets;
|
|
499
|
+
private assignCanvasKit;
|
|
500
|
+
private getFontsConfigurationFromGames;
|
|
501
|
+
private getImagesConfigurationFromGames;
|
|
502
|
+
}
|
|
503
|
+
interface GoToActivityOptions {
|
|
504
|
+
/** ActivityId of the activity to go to. */
|
|
505
|
+
id: string;
|
|
506
|
+
}
|
|
507
|
+
/**
|
|
508
|
+
* Types of values that can be stored in the session dictonary.
|
|
509
|
+
*/
|
|
510
|
+
type SessionDictionaryValues = string | number | boolean | object | null | undefined;
|
|
511
|
+
|
|
512
|
+
interface Activity {
|
|
513
|
+
/** The type of activity: Game or Survey */
|
|
514
|
+
type: ActivityType;
|
|
515
|
+
/** Initializes the activity. All code to create the activity's appearance and behavior must be placed in this method. This method is asynchronous, and must be awaited. When writing a new game by extending the `Game` class, this method will be overridden, but the base method must still be called with `await super.init()`. */
|
|
516
|
+
init(): Promise<void>;
|
|
517
|
+
/** Starts the activity */
|
|
518
|
+
start(): Promise<void>;
|
|
519
|
+
/** Stops the activity */
|
|
520
|
+
stop(): void;
|
|
521
|
+
/** The activity's parent session */
|
|
522
|
+
session: Session;
|
|
523
|
+
/** The activity's unique identifier. NOTE: This is newly generated each session. The uuid for an activity will vary across sessions. */
|
|
524
|
+
uuid: string;
|
|
525
|
+
/** Human-friendly name of this activity */
|
|
526
|
+
name: string;
|
|
527
|
+
/** Short identifier of this activity */
|
|
528
|
+
id: string;
|
|
529
|
+
/** The value of performance.now() immediately before the activity begins */
|
|
530
|
+
beginTimestamp: number;
|
|
531
|
+
/** The value of new Date().toISOString() immediately before the activity begins */
|
|
532
|
+
beginIso8601Timestamp: string;
|
|
533
|
+
/** Sets additional activity parameters if defaults are not sufficient. */
|
|
534
|
+
setParameters(additionalParameters: unknown): void;
|
|
535
|
+
/** Additional activity parameters that were set. */
|
|
536
|
+
readonly additionalParameters?: unknown;
|
|
537
|
+
/** Optional store to use for saving data. The implementation of the store is not provided by the \@m2c2kit/core library. */
|
|
538
|
+
dataStore?: IDataStore;
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
/**
|
|
542
|
+
* Base interface for all m2c2kit events.
|
|
543
|
+
*
|
|
544
|
+
* @remarks I would have named it Event, but that would collide with
|
|
545
|
+
* the existing DOM Event
|
|
546
|
+
*/
|
|
547
|
+
interface EventBase {
|
|
548
|
+
/** Type of event. */
|
|
549
|
+
type: EventType;
|
|
550
|
+
/** The object on which the event occurred. */
|
|
551
|
+
target: Entity | Session | Activity;
|
|
552
|
+
/** Has the event been taken care of by the listener and not be dispatched to other targets? */
|
|
553
|
+
handled?: boolean;
|
|
554
|
+
}
|
|
555
|
+
/**
|
|
556
|
+
* The different events that are dispatched by m2c2kit.
|
|
557
|
+
*/
|
|
558
|
+
declare enum EventType {
|
|
559
|
+
SessionInitialize = "SessionInitialize",
|
|
560
|
+
SessionStart = "SessionStart",
|
|
561
|
+
SessionEnd = "SessionEnd",
|
|
562
|
+
ActivityStart = "ActivityStart",
|
|
563
|
+
ActivityEnd = "ActivityEnd",
|
|
564
|
+
ActivityCancel = "ActivityCancel",
|
|
565
|
+
ActivityData = "ActivityData",
|
|
566
|
+
TapDown = "TapDown",
|
|
567
|
+
TapUp = "TapUp",
|
|
568
|
+
TapUpAny = "TapUpAny",
|
|
569
|
+
TapLeave = "TapLeave",
|
|
570
|
+
PointerDown = "PointerDown",
|
|
571
|
+
PointerUp = "PointerUp",
|
|
572
|
+
PointerMove = "PointerMove",
|
|
573
|
+
Drag = "Drag",
|
|
574
|
+
DragStart = "DragStart",
|
|
575
|
+
DragEnd = "DragEnd",
|
|
576
|
+
CompositeCustom = "CompositeCustom"
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
/** Base interface for all Entity events. */
|
|
580
|
+
interface EntityEvent extends EventBase {
|
|
581
|
+
/** The Entity on which the event occurred. */
|
|
582
|
+
target: Entity;
|
|
583
|
+
/** For composites that raise events, type of the composite custom event. */
|
|
584
|
+
compositeType?: string;
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
interface EntityEventListener {
|
|
588
|
+
type: EventType;
|
|
589
|
+
/** For composites that raise events, type of the composite custom event. */
|
|
590
|
+
compositeType?: string;
|
|
591
|
+
entityUuid: string;
|
|
592
|
+
callback: (event: EntityEvent) => void;
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
/**
|
|
596
|
+
* Position in two-dimensional space.
|
|
597
|
+
*/
|
|
598
|
+
interface Point {
|
|
599
|
+
/** Horizonal coordinate */
|
|
600
|
+
x: number;
|
|
601
|
+
/** Vertical coordinate */
|
|
602
|
+
y: number;
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
/**
|
|
606
|
+
* Describes an interaction between the pointer (mouse, touches) and an entity.
|
|
607
|
+
*
|
|
608
|
+
* @remarks I would have named it PointerEvent, but that would collide with
|
|
609
|
+
* the existing DOM PointerEvent.
|
|
610
|
+
*/
|
|
611
|
+
interface M2PointerEvent extends EntityEvent {
|
|
612
|
+
/** Point that was tapped on entity, relative to the entity coordinate system */
|
|
613
|
+
point: Point;
|
|
614
|
+
/** Buttons being pressed when event was fired. Taken from DOM MouseEvent.buttons */
|
|
615
|
+
buttons: number;
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
/**
|
|
619
|
+
* Desrcibes an interaction of a pointer (mouse, touches) pressing an entity.
|
|
620
|
+
*
|
|
621
|
+
* @remarks Unlike M2PointerEvent, TapEvent considers how the pointer, while
|
|
622
|
+
* in the down state, moves in relation to the bounds of the entity.
|
|
623
|
+
*/
|
|
624
|
+
interface TapEvent extends EntityEvent {
|
|
625
|
+
/** Point that was tapped on entity, relative to the entity coordinate system */
|
|
626
|
+
point: Point;
|
|
627
|
+
/** Buttons being pressed when event was fired. Taken from DOM MouseEvent.buttons */
|
|
628
|
+
buttons: number;
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
interface DrawableOptions {
|
|
632
|
+
/** Point within the entity that determines its position. Default is \{ x: 0.5, y: 0.5 \}, which centers the entity on its position */
|
|
633
|
+
anchorPoint?: Point;
|
|
634
|
+
/** Value along the z-axis to determine drawing and tap order. Larger values are on top. */
|
|
635
|
+
zPosition?: number;
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
/**
|
|
639
|
+
* Constraints for defining relative layouts.
|
|
640
|
+
*
|
|
641
|
+
* @remarks FOR INTERNAL USE ONLY
|
|
642
|
+
*/
|
|
643
|
+
interface Constraints {
|
|
644
|
+
/** Constrain the top (vertical axis) of this entity to the top of the specified entity. The tops of both will appear at the same vertical location */
|
|
645
|
+
topToTopOf?: Entity | string;
|
|
646
|
+
/** Constrain the top (vertical axis) of this entity to the bottom of the specified entity. This entity will appear immediately below the specified entity */
|
|
647
|
+
topToBottomOf?: Entity | string;
|
|
648
|
+
/** Constrain the bottom (vertical axis) of this entity to the top of the specified entity. This entity will appear immediately above of the specified entity */
|
|
649
|
+
bottomToTopOf?: Entity | string;
|
|
650
|
+
/** Constrain the bottom (vertical axis) of this entity to the bottom of the specified entity. The bottoms of both will appear at the same vertical location */
|
|
651
|
+
bottomToBottomOf?: Entity | string;
|
|
652
|
+
/** Constrain the start (horizontal axis) of this entity to the start of the specified entity. The start of both will appear at the same horizontal location */
|
|
653
|
+
startToStartOf?: Entity | string;
|
|
654
|
+
/** Constrain the start (horizontal axis) of this entity to the end of the specified entity. This entity will appear immediately to the right of the specified entity */
|
|
655
|
+
startToEndOf?: Entity | string;
|
|
656
|
+
/** Constrain the end (horizontal axis) of this entity to the end of the specified entity. The end of both will appear at the same horizontal location */
|
|
657
|
+
endToEndOf?: Entity | string;
|
|
658
|
+
/** Constrain the end (horizontal axis) of this entity to the start of the specified entity. This entity will appear immediately to the left of the specified entity */
|
|
659
|
+
endToStartOf?: Entity | string;
|
|
660
|
+
/** When opposing horizontal constraints are applied, the default is to center the entity within the constraints (horizontalBias = .5). Setting horizontalBias less than .5 will pull the entity towards the start (to the left). Setting horizontalBias greater than .5 will pull the entity towards the end (to the right) */
|
|
661
|
+
horizontalBias?: number;
|
|
662
|
+
/** When opposing vertical constraints are applied, the default is to center the entity within the constraints (verticalBias = .5). Setting verticalBias less than .5 will pull the entity towards the top. Setting verticalBias greater than .5 will pull the entity towards the bottom */
|
|
663
|
+
verticalBias?: number;
|
|
664
|
+
[key: string]: Entity | string | number | undefined;
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
/**
|
|
668
|
+
* The Layout allows relative positioning via constraints.
|
|
669
|
+
* This is not fully implemented yet: DO NOT USE!
|
|
670
|
+
* We use it internally for instructions.
|
|
671
|
+
*/
|
|
672
|
+
interface Layout {
|
|
673
|
+
height?: number;
|
|
674
|
+
width?: number;
|
|
675
|
+
marginStart?: number;
|
|
676
|
+
marginEnd?: number;
|
|
677
|
+
marginTop?: number;
|
|
678
|
+
marginBottom?: number;
|
|
679
|
+
constraints?: Constraints;
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
/**
|
|
683
|
+
* Color in red (0-255), green (0-255), blue (0-255), alpha (0-1) format. Must be numeric array of length 4.
|
|
684
|
+
*/
|
|
685
|
+
type RgbaColor = [number, number, number, number];
|
|
686
|
+
|
|
687
|
+
interface TextOptions {
|
|
688
|
+
/** Text to be displayed */
|
|
689
|
+
text?: string;
|
|
690
|
+
/** Name of font to use for text. Must have been previously loaded */
|
|
691
|
+
fontName?: string;
|
|
692
|
+
/** Color of text. Default is Constants.DEFAULT_FONT_COLOR (WebColors.Black) */
|
|
693
|
+
fontColor?: RgbaColor;
|
|
694
|
+
/** Size of text. Default is Constants.DEFAULT_FONT_SIZE (16) */
|
|
695
|
+
fontSize?: number;
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
/**
|
|
699
|
+
* Width and height on two-dimensional space
|
|
700
|
+
*/
|
|
701
|
+
interface Size {
|
|
702
|
+
/** Horizonal width, x-axis */
|
|
703
|
+
width: number;
|
|
704
|
+
/** Vertical height, y-axis */
|
|
705
|
+
height: number;
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
interface EntityOptions {
|
|
709
|
+
/** Name of the entity. Only needed if the entity will be referred to by name in a later function */
|
|
710
|
+
name?: string;
|
|
711
|
+
/** Position of the entity within its parent coordinate system. Default is (0, 0) */
|
|
712
|
+
position?: Point;
|
|
713
|
+
/** Scale of the entity. Default is 1.0 */
|
|
714
|
+
scale?: number;
|
|
715
|
+
/** Does the entity respond to user events, such as taps? Default is false */
|
|
716
|
+
isUserInteractionEnabled?: boolean;
|
|
717
|
+
/** Can the entity be dragged? */
|
|
718
|
+
draggable?: boolean;
|
|
719
|
+
/** Is the entity, and its children, hidden? (not displayed). Default is false */
|
|
720
|
+
hidden?: boolean;
|
|
721
|
+
/** FOR INTERNAL USE ONLY */
|
|
722
|
+
layout?: Layout;
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
declare enum EntityType {
|
|
726
|
+
Entity = "Entity",
|
|
727
|
+
Scene = "Scene",
|
|
728
|
+
Sprite = "Sprite",
|
|
729
|
+
Label = "Label",
|
|
730
|
+
TextLine = "TextLine",
|
|
731
|
+
Shape = "Shape",
|
|
732
|
+
Composite = "Composite"
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
type EasingFunction = (
|
|
736
|
+
/** elapsed time since start of action */
|
|
737
|
+
t: number,
|
|
738
|
+
/** start value of value to be eased */
|
|
739
|
+
b: number,
|
|
740
|
+
/** total change of value to be eased */
|
|
741
|
+
c: number,
|
|
742
|
+
/** total duration of action */
|
|
743
|
+
d: number) => number;
|
|
744
|
+
/**
|
|
745
|
+
* The Easings class has static methods for creating easings to be used in actions.
|
|
746
|
+
*/
|
|
747
|
+
declare class Easings {
|
|
748
|
+
static none: EasingFunction;
|
|
749
|
+
static linear: EasingFunction;
|
|
750
|
+
static quadraticIn: EasingFunction;
|
|
751
|
+
static quadraticOut: EasingFunction;
|
|
752
|
+
static quadraticInOut: EasingFunction;
|
|
753
|
+
static cubicIn: EasingFunction;
|
|
754
|
+
static cubicOut: EasingFunction;
|
|
755
|
+
static cubicInOut: EasingFunction;
|
|
756
|
+
static quarticIn: EasingFunction;
|
|
757
|
+
static quarticOut: EasingFunction;
|
|
758
|
+
static quarticInOut: EasingFunction;
|
|
759
|
+
static quinticIn: EasingFunction;
|
|
760
|
+
static quinticOut: EasingFunction;
|
|
761
|
+
static quinticInOut: EasingFunction;
|
|
762
|
+
static sinusoidalIn: EasingFunction;
|
|
763
|
+
static sinusoidalOut: EasingFunction;
|
|
764
|
+
static sinusoidalInOut: EasingFunction;
|
|
765
|
+
static exponentialIn: EasingFunction;
|
|
766
|
+
static exponentialOut: EasingFunction;
|
|
767
|
+
static exponentialInOut: EasingFunction;
|
|
768
|
+
static circularIn: EasingFunction;
|
|
769
|
+
static circularOut: EasingFunction;
|
|
770
|
+
static circularInOut: EasingFunction;
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
interface IDrawable {
|
|
774
|
+
draw(canvas: Canvas): void;
|
|
775
|
+
warmup(canvas: Canvas): void;
|
|
776
|
+
/**
|
|
777
|
+
* Frees up resources that were allocated for this drawable entity.
|
|
778
|
+
*
|
|
779
|
+
* @remarks This will be done automatically by the m2c2kit library;
|
|
780
|
+
* the end-user must not call this.
|
|
781
|
+
*/
|
|
782
|
+
dispose(): void;
|
|
783
|
+
anchorPoint: Point;
|
|
784
|
+
zPosition: number;
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
interface SceneOptions extends EntityOptions, DrawableOptions {
|
|
788
|
+
/** Background color of the scene. Default is Constants.DEFAULT_SCENE_BACKGROUND_COLOR (WebColors.White) */
|
|
789
|
+
backgroundColor?: RgbaColor;
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
declare class Scene extends Entity implements IDrawable, SceneOptions {
|
|
793
|
+
readonly type = EntityType.Scene;
|
|
794
|
+
isDrawable: boolean;
|
|
795
|
+
anchorPoint: {
|
|
796
|
+
x: number;
|
|
797
|
+
y: number;
|
|
798
|
+
};
|
|
799
|
+
zPosition: number;
|
|
800
|
+
private _backgroundColor;
|
|
801
|
+
_active: boolean;
|
|
802
|
+
_transitioning: boolean;
|
|
803
|
+
_setupCallback?: (scene: Scene) => void;
|
|
804
|
+
_appearCallback?: (scene: Scene) => void;
|
|
805
|
+
private backgroundPaint?;
|
|
806
|
+
/**
|
|
807
|
+
* Top-level entity that holds all other entities, such as sprites, rectangles, or labels, that will be displayed on the screen
|
|
808
|
+
*
|
|
809
|
+
* @remarks The scene is the game screen or stage, and fills the entire available screen. There are usually multiple screens to contain multiple stages of the game, such as various instruction pages or phases of a game.
|
|
810
|
+
*
|
|
811
|
+
* @param options - {@link SceneOptions}
|
|
812
|
+
*/
|
|
813
|
+
constructor(options?: SceneOptions);
|
|
814
|
+
initialize(): void;
|
|
815
|
+
dispose(): void;
|
|
816
|
+
set game(game: Game);
|
|
817
|
+
/**
|
|
818
|
+
* The game which this scene is a part of.
|
|
819
|
+
*
|
|
820
|
+
* @remarks Throws error if scene is not part of the game object.
|
|
821
|
+
*/
|
|
822
|
+
get game(): Game;
|
|
823
|
+
get backgroundColor(): RgbaColor;
|
|
824
|
+
set backgroundColor(backgroundColor: RgbaColor);
|
|
825
|
+
/**
|
|
826
|
+
* Duplicates an entity using deep copy.
|
|
827
|
+
*
|
|
828
|
+
* @remarks This is a deep recursive clone (entity and children).
|
|
829
|
+
* The uuid property of all duplicated entities will be newly created,
|
|
830
|
+
* because uuid must be unique.
|
|
831
|
+
*
|
|
832
|
+
* @param newName - optional name of the new, duplicated entity. If not
|
|
833
|
+
* provided, name will be the new uuid
|
|
834
|
+
*/
|
|
835
|
+
duplicate(newName?: string): Scene;
|
|
836
|
+
/**
|
|
837
|
+
* Code that will be called every time the scene is presented.
|
|
838
|
+
*
|
|
839
|
+
* @remarks Use this callback to set entities to their initial state, if
|
|
840
|
+
* that state might be changed later. For example, if a scene allows
|
|
841
|
+
* players to place dots on a grid, the setup() method should ensure the
|
|
842
|
+
* grid is clear of any prior dots from previous times this scene may
|
|
843
|
+
* have been displayed. In addition, if entities should vary in each
|
|
844
|
+
* iteration, that should be done here.
|
|
845
|
+
*
|
|
846
|
+
* @param callback
|
|
847
|
+
*/
|
|
848
|
+
onSetup(callback: (scene: Scene) => void): void;
|
|
849
|
+
/**
|
|
850
|
+
*
|
|
851
|
+
* Code that will be called after the scene has finished any transitions
|
|
852
|
+
* and has fully appeared on the screen.
|
|
853
|
+
*
|
|
854
|
+
* @param callback
|
|
855
|
+
*/
|
|
856
|
+
onAppear(callback: (scene: Scene) => void): void;
|
|
857
|
+
draw(canvas: Canvas): void;
|
|
858
|
+
warmup(canvas: Canvas): void;
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
interface SlideTransitionOptions {
|
|
862
|
+
/** Direction in which the slide action goes */
|
|
863
|
+
direction: TransitionDirection;
|
|
864
|
+
/** Duration, in millis, of the transition */
|
|
865
|
+
duration: number;
|
|
866
|
+
/** Easing function for movement; default is linear */
|
|
867
|
+
easing?: EasingFunction;
|
|
868
|
+
}
|
|
869
|
+
/**
|
|
870
|
+
* The Transition class has static methods for creating animations that run as one scene transitions to another.
|
|
871
|
+
*/
|
|
872
|
+
declare abstract class Transition {
|
|
873
|
+
abstract type: TransitionType;
|
|
874
|
+
abstract easing: EasingFunction;
|
|
875
|
+
abstract duration: number;
|
|
876
|
+
/**
|
|
877
|
+
* Creates a scene transition in which the outgoing scene slides out and the incoming scene slides in, as if the incoming scene pushes it.
|
|
878
|
+
*
|
|
879
|
+
* @param options - {@link SlideTransitionOptions}
|
|
880
|
+
* @returns
|
|
881
|
+
*/
|
|
882
|
+
static slide(options: SlideTransitionOptions): SlideTransition;
|
|
883
|
+
/**
|
|
884
|
+
* Creates a scene transition with no animation or duration. The next scene is immediately drawn.
|
|
885
|
+
*/
|
|
886
|
+
static none(): NoneTransition;
|
|
887
|
+
}
|
|
888
|
+
declare class NoneTransition extends Transition {
|
|
889
|
+
type: TransitionType;
|
|
890
|
+
easing: EasingFunction;
|
|
891
|
+
duration: number;
|
|
892
|
+
constructor();
|
|
893
|
+
}
|
|
894
|
+
declare class SlideTransition extends Transition {
|
|
895
|
+
type: TransitionType;
|
|
896
|
+
easing: EasingFunction;
|
|
897
|
+
duration: number;
|
|
898
|
+
direction: TransitionDirection;
|
|
899
|
+
constructor(direction: TransitionDirection, duration: number, easing: EasingFunction);
|
|
900
|
+
}
|
|
901
|
+
declare enum TransitionType {
|
|
902
|
+
Slide = "Slide",
|
|
903
|
+
None = "None"
|
|
904
|
+
}
|
|
905
|
+
declare enum TransitionDirection {
|
|
906
|
+
Up = "Up",
|
|
907
|
+
Down = "Down",
|
|
908
|
+
Right = "Right",
|
|
909
|
+
Left = "Left"
|
|
910
|
+
}
|
|
911
|
+
declare class SceneTransition {
|
|
912
|
+
scene: Scene;
|
|
913
|
+
transition: Transition;
|
|
914
|
+
constructor(scene: Scene, transition: Transition);
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
/**
|
|
918
|
+
* TrialSchema defines the data that are generated for each trial. They are
|
|
919
|
+
* key-value pairs in which the key is the variable name, and the value is
|
|
920
|
+
* JSON Schema that defines the type of the variable.
|
|
921
|
+
*/
|
|
922
|
+
interface TrialSchema {
|
|
923
|
+
[key: string]: JsonSchema;
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
/**
|
|
927
|
+
* GameParameters are the configurable options that change how the game runs.
|
|
928
|
+
* They are key-value pairs in which the key is the game parameter name, and
|
|
929
|
+
* the value is JSON Schema that defines the type of the game parameter, with
|
|
930
|
+
* a required parameter named "default" that is the default value for the
|
|
931
|
+
* parameter.
|
|
932
|
+
*/
|
|
933
|
+
interface GameParameters {
|
|
934
|
+
/** The key is the game parameter name */
|
|
935
|
+
[key: string]: DefaultParameter;
|
|
936
|
+
}
|
|
937
|
+
interface DefaultParameter extends JsonSchema {
|
|
938
|
+
/** Default value for the game parameter. */
|
|
939
|
+
default: any;
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
/**
|
|
943
|
+
* Translations is a map of a locale to a map of keys to translations.
|
|
944
|
+
*
|
|
945
|
+
* @example
|
|
946
|
+
* ```
|
|
947
|
+
* const translations: Translations = {
|
|
948
|
+
* "en-US": {
|
|
949
|
+
* "NEXT_BUTTON": "Next"
|
|
950
|
+
* },
|
|
951
|
+
* "es-MX": {
|
|
952
|
+
* "NEXT_BUTTON": "Siguiente"
|
|
953
|
+
* }
|
|
954
|
+
* }
|
|
955
|
+
* ```
|
|
956
|
+
*/
|
|
957
|
+
interface Translations {
|
|
958
|
+
[locale: string]: {
|
|
959
|
+
[key: string]: string;
|
|
960
|
+
};
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
/**
|
|
964
|
+
* Options to specify HTML canvas, set game canvas size, and load game assets.
|
|
965
|
+
*/
|
|
966
|
+
interface GameOptions {
|
|
967
|
+
/** Human-friendly name of this game */
|
|
968
|
+
name: string;
|
|
969
|
+
/** Short identifier of this game; unique among published games and url-friendly (no spaces, special characters, or slashes)*/
|
|
970
|
+
id: string;
|
|
971
|
+
/** Version of this game */
|
|
972
|
+
version: string;
|
|
973
|
+
/** Uri (repository, webpage, or other location where full information about the game can be found) */
|
|
974
|
+
uri?: string;
|
|
975
|
+
/** Brief description of game */
|
|
976
|
+
shortDescription?: string;
|
|
977
|
+
/** Full description of game */
|
|
978
|
+
longDescription?: string;
|
|
979
|
+
/** Id of the HTML canvas that game will be drawn on. If not provided, the first canvas found will be used */
|
|
980
|
+
canvasId?: string;
|
|
981
|
+
/** Width of game canvas */
|
|
982
|
+
width: number;
|
|
983
|
+
/** Height of game canvas */
|
|
984
|
+
height: number;
|
|
985
|
+
/** Stretch to fill screen? Default is false */
|
|
986
|
+
stretch?: boolean;
|
|
987
|
+
/** Schema of trial data; JSON object where key is variable name, value is data type */
|
|
988
|
+
trialSchema?: TrialSchema;
|
|
989
|
+
/** Default game parameters; JSON object where key is the game parameter, value is default value */
|
|
990
|
+
parameters?: GameParameters;
|
|
991
|
+
/** String array of urls from which to load fonts. The first element will be the default font */
|
|
992
|
+
fontUrls?: Array<string>;
|
|
993
|
+
/** Array of BrowserImage objects to render and load */
|
|
994
|
+
images?: Array<BrowserImage>;
|
|
995
|
+
/** Show FPS in upper left corner? Default is false */
|
|
996
|
+
showFps?: boolean;
|
|
997
|
+
/** Color of the html body, if the game does not fill the screen. Useful for showing scene boundaries. Default is the scene background color */
|
|
998
|
+
bodyBackgroundColor?: RgbaColor;
|
|
999
|
+
/** Maximum number of activity metrics to log. */
|
|
1000
|
+
maximumRecordedActivityMetrics?: number;
|
|
1001
|
+
/** The FPS will be logged in game metrics if the FPS is lower than this value. Default is 59, as defined in Constants.FPS_METRIC_REPORT_THRESHOLD */
|
|
1002
|
+
fpsMetricReportThreshold?: number;
|
|
1003
|
+
/** Adapt execution for unit testing? Default is false */
|
|
1004
|
+
_unitTesting?: boolean;
|
|
1005
|
+
/** Advance through time step-by-step, for development and debugging */
|
|
1006
|
+
timeStepping?: boolean;
|
|
1007
|
+
/** Translations for localization. */
|
|
1008
|
+
translations?: Translations;
|
|
1009
|
+
/** Show logs for WebGl activity? */
|
|
1010
|
+
logWebGl?: boolean;
|
|
1011
|
+
}
|
|
1012
|
+
|
|
1013
|
+
interface GameData extends ActivityKeyValueData {
|
|
1014
|
+
trials: Array<TrialData>;
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1017
|
+
/**
|
|
1018
|
+
* Localization information that is passed to the I18n constructor.
|
|
1019
|
+
*/
|
|
1020
|
+
interface LocalizationOptions {
|
|
1021
|
+
/** Locale to use for localization, or "auto" to request from the environment. */
|
|
1022
|
+
locale: string;
|
|
1023
|
+
/** Locale to use if requested locale translation is not availble, or if "auto" locale was requested and environment cannot provide a locale. */
|
|
1024
|
+
fallbackLocale?: string;
|
|
1025
|
+
/** Font color for strings that are missing translation and use the fallback locale or untranslated string. */
|
|
1026
|
+
missingTranslationFontColor?: RgbaColor;
|
|
1027
|
+
/** Translations for localization. */
|
|
1028
|
+
translations?: Translations;
|
|
1029
|
+
/** Additional translations for localization provided through game parameters. These will be merged into existing translations. */
|
|
1030
|
+
additionalTranslations?: Translations;
|
|
1031
|
+
}
|
|
1032
|
+
|
|
1033
|
+
declare class I18n {
|
|
1034
|
+
private _translations;
|
|
1035
|
+
locale: string;
|
|
1036
|
+
fallbackLocale: string;
|
|
1037
|
+
private environmentLocale;
|
|
1038
|
+
options: LocalizationOptions;
|
|
1039
|
+
static makeLocalizationParameters(): GameParameters;
|
|
1040
|
+
constructor(options: LocalizationOptions);
|
|
1041
|
+
t(key: string, useFallback?: boolean): string | undefined;
|
|
1042
|
+
get translations(): Translations;
|
|
1043
|
+
set translations(value: Translations);
|
|
1044
|
+
private getEnvironmentLocale;
|
|
1045
|
+
private mergeAdditionalTranslations;
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
interface TrialData {
|
|
1049
|
+
[key: string]: string | number | boolean | object | undefined | null;
|
|
1050
|
+
}
|
|
1051
|
+
declare class Game implements Activity {
|
|
1052
|
+
readonly type = ActivityType.Game;
|
|
1053
|
+
_canvasKit?: CanvasKit;
|
|
1054
|
+
_session?: Session;
|
|
1055
|
+
uuid: string;
|
|
1056
|
+
name: string;
|
|
1057
|
+
id: string;
|
|
1058
|
+
options: GameOptions;
|
|
1059
|
+
beginTimestamp: number;
|
|
1060
|
+
beginIso8601Timestamp: string;
|
|
1061
|
+
private gameMetrics;
|
|
1062
|
+
private fpsMetricReportThreshold;
|
|
1063
|
+
private maximumRecordedActivityMetrics;
|
|
1064
|
+
private stepCount;
|
|
1065
|
+
private steppingNow;
|
|
1066
|
+
i18n?: I18n;
|
|
1067
|
+
private warmupFunctionQueue;
|
|
1068
|
+
private loaderElementsRemoved;
|
|
1069
|
+
private _dataStore?;
|
|
1070
|
+
additionalParameters?: unknown;
|
|
1071
|
+
/**
|
|
1072
|
+
* The base class for all games. New games should extend this class.
|
|
1073
|
+
*
|
|
1074
|
+
* @param options - {@link GameOptions}
|
|
1075
|
+
*/
|
|
1076
|
+
constructor(options: GameOptions);
|
|
1077
|
+
private addLocalizationParametersToGameParameters;
|
|
1078
|
+
init(): Promise<void>;
|
|
1079
|
+
/**
|
|
1080
|
+
* Saves an item to the activity's key-value store.
|
|
1081
|
+
*
|
|
1082
|
+
* @remarks The underlying persistence provider of the key-value store must
|
|
1083
|
+
* be previously set in the activity's `Session` before use:
|
|
1084
|
+
* ```
|
|
1085
|
+
* const db: IDataStore = new LocalDatabase();
|
|
1086
|
+
* session.dataStore = db;
|
|
1087
|
+
* session.init();
|
|
1088
|
+
* ```
|
|
1089
|
+
* @param key - item key
|
|
1090
|
+
* @param value - item value
|
|
1091
|
+
* @param globalStore - if true, treat the item as "global" and not
|
|
1092
|
+
* associated with a specific activity; global items can be accessed
|
|
1093
|
+
* by any activity. Default is false.
|
|
1094
|
+
* @returns key
|
|
1095
|
+
*/
|
|
1096
|
+
storeSetItem(key: string, value: string | number | boolean | object | undefined | null, globalStore?: boolean): Promise<string>;
|
|
1097
|
+
/**
|
|
1098
|
+
* Gets an item value from the activity's key-value store.
|
|
1099
|
+
*
|
|
1100
|
+
* @remarks The underlying persistence provider of the key-value store must
|
|
1101
|
+
* be previously set in the activity's `Session` before use:
|
|
1102
|
+
* ```
|
|
1103
|
+
* const db: IDataStore = new LocalDatabase();
|
|
1104
|
+
* session.dataStore = db;
|
|
1105
|
+
* session.init();
|
|
1106
|
+
* ```
|
|
1107
|
+
* @param key - item key
|
|
1108
|
+
* @param globalStore - if true, treat the item as "global" and not
|
|
1109
|
+
* associated with a specific activity; global items can be accessed
|
|
1110
|
+
* by any activity. Default is false.
|
|
1111
|
+
* @returns value of the item
|
|
1112
|
+
*/
|
|
1113
|
+
storeGetItem<T extends string | number | boolean | object | undefined | null>(key: string, globalStore?: boolean): Promise<T>;
|
|
1114
|
+
/**
|
|
1115
|
+
* Deletes an item value from the activity's key-value store.
|
|
1116
|
+
*
|
|
1117
|
+
* @remarks The underlying persistence provider of the key-value store must
|
|
1118
|
+
* be previously set in the activity's `Session` before use:
|
|
1119
|
+
* ```
|
|
1120
|
+
* const db: IDataStore = new LocalDatabase();
|
|
1121
|
+
* session.dataStore = db;
|
|
1122
|
+
* session.init();
|
|
1123
|
+
* ```
|
|
1124
|
+
* @param key - item key
|
|
1125
|
+
* @param globalStore - if true, treat the item as "global" and not
|
|
1126
|
+
* associated with a specific activity; global items can be accessed
|
|
1127
|
+
* by any activity. Default is false.
|
|
1128
|
+
*/
|
|
1129
|
+
storeDeleteItem(key: string, globalStore?: boolean): Promise<void>;
|
|
1130
|
+
/**
|
|
1131
|
+
* Deletes all items from the activity's key-value store.
|
|
1132
|
+
*
|
|
1133
|
+
* @remarks The underlying persistence provider of the key-value store must
|
|
1134
|
+
* be previously set in the activity's `Session` before use:
|
|
1135
|
+
* ```
|
|
1136
|
+
* const db: IDataStore = new LocalDatabase();
|
|
1137
|
+
* session.dataStore = db;
|
|
1138
|
+
* session.init();
|
|
1139
|
+
* ```
|
|
1140
|
+
*/
|
|
1141
|
+
storeClearItems(): Promise<void>;
|
|
1142
|
+
/**
|
|
1143
|
+
* Returns keys of all items in the activity's key-value store.
|
|
1144
|
+
*
|
|
1145
|
+
* @remarks The underlying persistence provider of the key-value store must
|
|
1146
|
+
* be previously set in the activity's `Session` before use:
|
|
1147
|
+
* ```
|
|
1148
|
+
* const db: IDataStore = new LocalDatabase();
|
|
1149
|
+
* session.dataStore = db;
|
|
1150
|
+
* session.init();
|
|
1151
|
+
* ```
|
|
1152
|
+
* @param globalStore - if true, treat the item as "global" and not
|
|
1153
|
+
* associated with a specific activity; global items can be accessed
|
|
1154
|
+
* by any activity. Default is false.
|
|
1155
|
+
*/
|
|
1156
|
+
storeItemsKeys(globalStore?: boolean): Promise<string[]>;
|
|
1157
|
+
/**
|
|
1158
|
+
* Determines if a key exists in the activity's key-value store.
|
|
1159
|
+
*
|
|
1160
|
+
* @remarks The underlying persistence provider of the key-value store must
|
|
1161
|
+
* be previously set in the activity's `Session` before use:
|
|
1162
|
+
* ```
|
|
1163
|
+
* const db: IDataStore = new LocalDatabase();
|
|
1164
|
+
* session.dataStore = db;
|
|
1165
|
+
* session.init();
|
|
1166
|
+
* ```
|
|
1167
|
+
* @param key - item key
|
|
1168
|
+
* @param globalStore - if true, treat the item as "global" and not
|
|
1169
|
+
* associated with a specific activity; global items can be accessed
|
|
1170
|
+
* by any activity. Default is false.
|
|
1171
|
+
* @returns true if the key exists, false otherwise
|
|
1172
|
+
*/
|
|
1173
|
+
storeItemExists(key: string, globalStore?: boolean): Promise<boolean>;
|
|
1174
|
+
get dataStore(): IDataStore;
|
|
1175
|
+
set dataStore(dataStore: IDataStore);
|
|
1176
|
+
private getLocalizationOptionsFromGameParameters;
|
|
1177
|
+
private isLocalizationRequested;
|
|
1178
|
+
setParameters(additionalParameters: unknown): void;
|
|
1179
|
+
get canvasKit(): CanvasKit;
|
|
1180
|
+
set canvasKit(canvasKit: CanvasKit);
|
|
1181
|
+
get session(): Session;
|
|
1182
|
+
set session(session: Session);
|
|
1183
|
+
/** 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 */
|
|
1184
|
+
entryScene?: Scene | string;
|
|
1185
|
+
data: GameData;
|
|
1186
|
+
/** The 0-based index of the current trial */
|
|
1187
|
+
trialIndex: number;
|
|
1188
|
+
private htmlCanvas?;
|
|
1189
|
+
surface?: Surface;
|
|
1190
|
+
private showFps?;
|
|
1191
|
+
private bodyBackgroundColor?;
|
|
1192
|
+
private currentScene?;
|
|
1193
|
+
private priorUpdateTime?;
|
|
1194
|
+
private fpsTextFont?;
|
|
1195
|
+
private fpsTextPaint?;
|
|
1196
|
+
private drawnFrames;
|
|
1197
|
+
private lastFpsUpdate;
|
|
1198
|
+
private nextFpsUpdate;
|
|
1199
|
+
private fpsRate;
|
|
1200
|
+
private animationFramesRequested;
|
|
1201
|
+
private limitFps;
|
|
1202
|
+
private unitTesting;
|
|
1203
|
+
private gameStopRequested;
|
|
1204
|
+
private webGlRendererInfo;
|
|
1205
|
+
canvasCssWidth: number;
|
|
1206
|
+
canvasCssHeight: number;
|
|
1207
|
+
scenes: Scene[];
|
|
1208
|
+
private freeEntitiesScene;
|
|
1209
|
+
private incomingSceneTransitions;
|
|
1210
|
+
private currentSceneSnapshot?;
|
|
1211
|
+
private pendingScreenshot?;
|
|
1212
|
+
/**
|
|
1213
|
+
* Adds an entity as a free entity (an entity that is not part of a scene)
|
|
1214
|
+
* to the game.
|
|
1215
|
+
*
|
|
1216
|
+
* @remarks Once added to the game, a free entity will always be drawn,
|
|
1217
|
+
* and it will not be part of any scene transitions. This is useful if
|
|
1218
|
+
* an entity must persisently be drawn and not move with scene
|
|
1219
|
+
* transitions. The appearance of the free entity must be managed
|
|
1220
|
+
* by the programmer. Note: internally, the free entities are part of a
|
|
1221
|
+
* special scene (named "__freeEntitiesScene"), but this scene is handled
|
|
1222
|
+
* apart from regular scenes in order to achieve the free entity behavior.
|
|
1223
|
+
*
|
|
1224
|
+
* @param entity - entity to add as a free entity
|
|
1225
|
+
*/
|
|
1226
|
+
addFreeEntity(entity: Entity): void;
|
|
1227
|
+
/**
|
|
1228
|
+
* Removes a free entity from the game.
|
|
1229
|
+
*
|
|
1230
|
+
* @remarks Throws exception if the entity to remove is not currently added
|
|
1231
|
+
* to the game as a free entity
|
|
1232
|
+
*
|
|
1233
|
+
* @param entity - the free entity to remove or its name as a string
|
|
1234
|
+
*/
|
|
1235
|
+
removeFreeEntity(entity: Entity | string): void;
|
|
1236
|
+
/**
|
|
1237
|
+
* Removes all free entities from the game.
|
|
1238
|
+
*/
|
|
1239
|
+
removeAllFreeEntities(): void;
|
|
1240
|
+
/**
|
|
1241
|
+
* Returns array of free entities that have been added to the game.
|
|
1242
|
+
*
|
|
1243
|
+
* @returns array of free entities
|
|
1244
|
+
*/
|
|
1245
|
+
get freeEntities(): Array<Entity>;
|
|
1246
|
+
/**
|
|
1247
|
+
* Adds a scene to the game.
|
|
1248
|
+
*
|
|
1249
|
+
* @remarks A scene, and its children entities, cannot be presented unless it has been added to the game object.
|
|
1250
|
+
*
|
|
1251
|
+
* @param scene
|
|
1252
|
+
*/
|
|
1253
|
+
addScene(scene: Scene): void;
|
|
1254
|
+
/**
|
|
1255
|
+
* Adds multiple scenes to the game.
|
|
1256
|
+
*
|
|
1257
|
+
* @param scenes
|
|
1258
|
+
*/
|
|
1259
|
+
addScenes(scenes: Array<Scene>): void;
|
|
1260
|
+
/**
|
|
1261
|
+
* Removes a scene from the game.
|
|
1262
|
+
*
|
|
1263
|
+
* @param scene - the scene to remove or its name as a string
|
|
1264
|
+
*/
|
|
1265
|
+
removeScene(scene: Scene | string): void;
|
|
1266
|
+
/**
|
|
1267
|
+
* Specifies the scene that will be presented upon the next frame draw.
|
|
1268
|
+
*
|
|
1269
|
+
* @param scene
|
|
1270
|
+
* @param transition
|
|
1271
|
+
*/
|
|
1272
|
+
presentScene(scene: string | Scene, transition?: NoneTransition): void;
|
|
1273
|
+
/**
|
|
1274
|
+
* Gets the value of the game parameter. If parameterName
|
|
1275
|
+
* is not found, then throw exception.
|
|
1276
|
+
*
|
|
1277
|
+
* @param parameterName - the name of the game parameter whose value is requested
|
|
1278
|
+
* @returns
|
|
1279
|
+
*/
|
|
1280
|
+
getParameter<T>(parameterName: string): T;
|
|
1281
|
+
/**
|
|
1282
|
+
* Gets the value of the game parameter. If parameterName
|
|
1283
|
+
* is not found, then return fallback value
|
|
1284
|
+
*
|
|
1285
|
+
* @param parameterName - the name of the game parameter whose value is requested
|
|
1286
|
+
* @param fallback - the value to return if parameterName is not found
|
|
1287
|
+
* @returns
|
|
1288
|
+
*/
|
|
1289
|
+
getParameterOrFallback<T, U>(parameterName: string, fallbackValue: U): T | U;
|
|
1290
|
+
/**
|
|
1291
|
+
* Returns true if a game parameter exists for the given string.
|
|
1292
|
+
*
|
|
1293
|
+
* @param parameterName - the name of the game parameter whose existence is queried
|
|
1294
|
+
* @returns
|
|
1295
|
+
*/
|
|
1296
|
+
hasParameter(parameterName: string): boolean;
|
|
1297
|
+
/**
|
|
1298
|
+
* Starts the game loop.
|
|
1299
|
+
*
|
|
1300
|
+
* @remarks If entryScene is undefined, the game will start with scene
|
|
1301
|
+
* defined in the game object's entryScene property. If that is undefined,
|
|
1302
|
+
* the game will start with the first scene in the game object's scenes.
|
|
1303
|
+
* If there are no scenes in the game object's scenes, it will throw
|
|
1304
|
+
* an error.
|
|
1305
|
+
* Although the method has no awaitable calls, we will likely do
|
|
1306
|
+
* so in the future. Thus this method is async.
|
|
1307
|
+
*
|
|
1308
|
+
* @param entryScene - The scene (Scene object or its string name) to display when the game starts
|
|
1309
|
+
*/
|
|
1310
|
+
start(entryScene?: Scene | string): Promise<void>;
|
|
1311
|
+
private addTimeSteppingControlsToDom;
|
|
1312
|
+
private updateTimeSteppingOutput;
|
|
1313
|
+
private advanceStepsHandler;
|
|
1314
|
+
private removeTimeSteppingControlsFromDom;
|
|
1315
|
+
/**
|
|
1316
|
+
* Warms up the Skia-based shaders underlying canvaskit by drawing
|
|
1317
|
+
* primitives.
|
|
1318
|
+
*
|
|
1319
|
+
* @remarks Some canvaskit methods take extra time the first time they are
|
|
1320
|
+
* called because a WebGL shader must be compiled. If the method is part of
|
|
1321
|
+
* an animation, then this may cause frame drops or "jank." To alleviate
|
|
1322
|
+
* this, we can "warm up" the shader associated with the method by calling
|
|
1323
|
+
* it at the beginning of our game. Thus, all warmup operations will be
|
|
1324
|
+
* concentrated at the beginning and will not be noticeable. This warmup
|
|
1325
|
+
* function draws a series of primitives to the canvas. From testing,
|
|
1326
|
+
* the actual WebGl shaders compiled by canvaskit vary depending on the
|
|
1327
|
+
* device hardware. Thus, warmup functions that might call all relevant
|
|
1328
|
+
* WebGL shaders on desktop hardware may not be sufficient for mobile.
|
|
1329
|
+
*
|
|
1330
|
+
* @param canvas - the canvaskit-canvas to draw on
|
|
1331
|
+
* @param positionOffset - an offset to add to the position of each
|
|
1332
|
+
* primitive. Different shaders may be compiled depending on if the position
|
|
1333
|
+
* was fractional or not. This offset allows us to warmup both cases.
|
|
1334
|
+
*/
|
|
1335
|
+
private warmupShadersWithPrimitives;
|
|
1336
|
+
/**
|
|
1337
|
+
* Warms up the Skia-based shaders underlying canvaskit by drawing
|
|
1338
|
+
* m2c2kit entities.
|
|
1339
|
+
*
|
|
1340
|
+
* @remarks While warmupShadersWithPrimitives draws a predefined set of
|
|
1341
|
+
* primitives, this function initializes and draws all canvaskit objects
|
|
1342
|
+
* that have been defined as m2c2kit entities. This not only is another
|
|
1343
|
+
* opportunity for shader warmup, it also does the entity initialization.
|
|
1344
|
+
*
|
|
1345
|
+
* @param canvas - the canvaskit-canvas to draw on
|
|
1346
|
+
*/
|
|
1347
|
+
private warmupShadersWithScenes;
|
|
1348
|
+
stop(): void;
|
|
1349
|
+
/**
|
|
1350
|
+
* Frees up resources that were allocated to run the game.
|
|
1351
|
+
*
|
|
1352
|
+
* @remarks This will be done automatically by the m2c2kit library;
|
|
1353
|
+
* the end-user must not call this.
|
|
1354
|
+
*/
|
|
1355
|
+
dispose(): void;
|
|
1356
|
+
private initData;
|
|
1357
|
+
private propertySchemaDataTypeIsValid;
|
|
1358
|
+
private getDeviceMetadata;
|
|
1359
|
+
/**
|
|
1360
|
+
* Adds data to the game's TrialData object.
|
|
1361
|
+
*
|
|
1362
|
+
* @remarks The variableName must be previously defined in the trialSchema
|
|
1363
|
+
* object passed in during game initialization through
|
|
1364
|
+
* {@link GameInitOptions.trialSchema}. The type of the value must match
|
|
1365
|
+
* what was defined in the trialSchema, otherwise an error is thrown.
|
|
1366
|
+
*
|
|
1367
|
+
* @param variableName - variable to be set
|
|
1368
|
+
* @param value - value of the variable to set
|
|
1369
|
+
*/
|
|
1370
|
+
addTrialData(variableName: string, value: any): void;
|
|
1371
|
+
/**
|
|
1372
|
+
* Should be called when the current trial has completed. It will
|
|
1373
|
+
* also increment the trial index.
|
|
1374
|
+
*
|
|
1375
|
+
* @remarks Calling will trigger the onActivityResults callback function,
|
|
1376
|
+
* if one was provided in SessionOptions. This is how the game communicates
|
|
1377
|
+
* trial data to the parent session, which can then save or process the data.
|
|
1378
|
+
* It is the responsibility of the the game programmer to call this at
|
|
1379
|
+
* the appropriate time. It is not triggered automatically.
|
|
1380
|
+
*/
|
|
1381
|
+
trialComplete(): void;
|
|
1382
|
+
/**
|
|
1383
|
+
* The m2c2kit engine will automatically include these schema and their
|
|
1384
|
+
* values in the trial data.
|
|
1385
|
+
*/
|
|
1386
|
+
private readonly automaticTrialSchema;
|
|
1387
|
+
private makeNewGameDataSchema;
|
|
1388
|
+
private makeGameDataSchema;
|
|
1389
|
+
/**
|
|
1390
|
+
* GameParameters combines default parameters values and
|
|
1391
|
+
* JSON Schema to describe what the parameters are.
|
|
1392
|
+
* The next two functions extract GameParameters's two parts
|
|
1393
|
+
* (the default values and the schema) so they can be returned
|
|
1394
|
+
* separately in the activityData event
|
|
1395
|
+
*/
|
|
1396
|
+
private makeGameActivityConfiguration;
|
|
1397
|
+
private makeGameActivityConfigurationSchema;
|
|
1398
|
+
/**
|
|
1399
|
+
* Should be called when current game has ended successfully.
|
|
1400
|
+
*
|
|
1401
|
+
* @remarks This will trigger the onActivityLifecycleChange callback function,
|
|
1402
|
+
* if one was provided in SessionOptions. This is how the game can communicate
|
|
1403
|
+
* its state to the parent session. It is the responsibility of the the game
|
|
1404
|
+
* programmer to call this at the appropriate time. It is not triggered
|
|
1405
|
+
* automatically.
|
|
1406
|
+
*/
|
|
1407
|
+
end(): void;
|
|
1408
|
+
/**
|
|
1409
|
+
* Should be called when current game has been canceled by a user action.
|
|
1410
|
+
*
|
|
1411
|
+
* @remarks This will trigger the onActivityLifecycleChange callback function,
|
|
1412
|
+
* if one was provided in SessionOptions. This is how the game can communicate
|
|
1413
|
+
* its state to the parent session. It is the responsibility of the the game
|
|
1414
|
+
* programmer to call this at the appropriate time. It is not triggered
|
|
1415
|
+
* automatically.
|
|
1416
|
+
*/
|
|
1417
|
+
cancel(): void;
|
|
1418
|
+
private setupHtmlCanvases;
|
|
1419
|
+
private setupCanvasKitSurface;
|
|
1420
|
+
private interceptWebGlCalls;
|
|
1421
|
+
private setupFpsFont;
|
|
1422
|
+
private setupCanvasDomEventHandlers;
|
|
1423
|
+
private loop;
|
|
1424
|
+
snapshots: Image[];
|
|
1425
|
+
private updateGameTime;
|
|
1426
|
+
private handleIncomingSceneTransitions;
|
|
1427
|
+
/**
|
|
1428
|
+
* Creates a scene that has a screen shot of the current scene.
|
|
1429
|
+
*
|
|
1430
|
+
* @param outgoingSceneImage - an image of the current scene
|
|
1431
|
+
* @returns - the scene with the screen shot
|
|
1432
|
+
*/
|
|
1433
|
+
private createOutgoingScene;
|
|
1434
|
+
private update;
|
|
1435
|
+
private draw;
|
|
1436
|
+
private calculateFps;
|
|
1437
|
+
private takeCurrentSceneSnapshot;
|
|
1438
|
+
private handlePendingScreenshot;
|
|
1439
|
+
/**
|
|
1440
|
+
* Takes screenshot of canvas
|
|
1441
|
+
*
|
|
1442
|
+
* @remarks Coordinates should be provided unscaled; that is, the method
|
|
1443
|
+
* will handle any scaling that happened due to device pixel ratios
|
|
1444
|
+
* not equal to 1. This returns a promise because the screenshot request
|
|
1445
|
+
* must be queued and completed once a draw cycle has completed. See
|
|
1446
|
+
* the loop() method.
|
|
1447
|
+
*
|
|
1448
|
+
* @param sx - Upper left coordinate of screenshot
|
|
1449
|
+
* @param sy - Upper right coordinate of screenshot
|
|
1450
|
+
* @param sw - width of area to screenshot
|
|
1451
|
+
* @param sh - hegith of area to screenshot
|
|
1452
|
+
* @returns Promise of Uint8Array of image data
|
|
1453
|
+
*/
|
|
1454
|
+
takeScreenshot(sx?: number, sy?: number, sw?: number, sh?: number): Promise<Uint8Array | null>;
|
|
1455
|
+
private animateSceneTransition;
|
|
1456
|
+
private drawFps;
|
|
1457
|
+
/**
|
|
1458
|
+
* Creates an event listener for an entity based on the entity name
|
|
1459
|
+
*
|
|
1460
|
+
* @remarks Typically, event listeners will be created using a method specific to the event, such as onTapDown(). This alternative allows creation with entity name.
|
|
1461
|
+
*
|
|
1462
|
+
* @param type - the type of event to listen for, e.g., "tapdown"
|
|
1463
|
+
* @param entityName - the entity name for which an event will be listened
|
|
1464
|
+
* @param callback
|
|
1465
|
+
* @param replaceExistingCallback
|
|
1466
|
+
*/
|
|
1467
|
+
createEventListener(type: EventType, entityName: string, callback: (event: EntityEvent) => void, replaceExistingCallback?: boolean): void;
|
|
1468
|
+
/**
|
|
1469
|
+
* Returns array of all entities that have been added to the game object.
|
|
1470
|
+
*/
|
|
1471
|
+
get entities(): Array<Entity>;
|
|
1472
|
+
/**
|
|
1473
|
+
* Receives callback from DOM PointerDown event
|
|
1474
|
+
*
|
|
1475
|
+
* @param domPointerEvent - PointerEvent from the DOM
|
|
1476
|
+
* @returns
|
|
1477
|
+
*/
|
|
1478
|
+
private htmlCanvasPointerDownHandler;
|
|
1479
|
+
private htmlCanvasPointerUpHandler;
|
|
1480
|
+
private htmlCanvasPointerMoveHandler;
|
|
1481
|
+
/**
|
|
1482
|
+
* Adjusts dragging behavior when the pointer leaves the canvas
|
|
1483
|
+
*
|
|
1484
|
+
* @remarks This is necessary because the pointerup event is not fired when
|
|
1485
|
+
* the pointer leaves the canvas. On desktop, this means that the user might
|
|
1486
|
+
* lift the pointer outside the canvas, but the entity will still be dragged
|
|
1487
|
+
* when the pointer is moved back into the canvas.
|
|
1488
|
+
*
|
|
1489
|
+
* @param domPointerEvent
|
|
1490
|
+
* @returns
|
|
1491
|
+
*/
|
|
1492
|
+
private htmlCanvasPointerLeaveHandler;
|
|
1493
|
+
/**
|
|
1494
|
+
* Determines if/how m2c2kit entities respond to the DOM PointerDown event
|
|
1495
|
+
*
|
|
1496
|
+
* @param entity - entity that might be affected by the DOM PointerDown event
|
|
1497
|
+
* @param m2Event
|
|
1498
|
+
* @param domPointerEvent
|
|
1499
|
+
*/
|
|
1500
|
+
private processDomPointerDown;
|
|
1501
|
+
private processDomPointerUp;
|
|
1502
|
+
private processDomPointerMove;
|
|
1503
|
+
private raiseM2PointerDownEvent;
|
|
1504
|
+
private raiseTapDownEvent;
|
|
1505
|
+
private raiseTapLeaveEvent;
|
|
1506
|
+
private raiseM2PointerUpEvent;
|
|
1507
|
+
private raiseTapUpEvent;
|
|
1508
|
+
private raiseTapUpAny;
|
|
1509
|
+
private raiseM2PointerMoveEvent;
|
|
1510
|
+
private raiseM2DragStartEvent;
|
|
1511
|
+
private raiseM2DragEvent;
|
|
1512
|
+
private raiseM2DragEndEvent;
|
|
1513
|
+
private calculatePointWithinEntityFromDomPointerEvent;
|
|
1514
|
+
private raiseEventOnListeningEntities;
|
|
1515
|
+
private sceneCanReceiveUserInteraction;
|
|
1516
|
+
/**
|
|
1517
|
+
*
|
|
1518
|
+
* Checks if the given canvas point is within the entity's bounds.
|
|
1519
|
+
*
|
|
1520
|
+
* @param entity - entity to check bounds for
|
|
1521
|
+
* @param x - x coordinate of the canvas point
|
|
1522
|
+
* @param y - y coordinate of the canvas point
|
|
1523
|
+
* @returns true if x, y point is within the entity's bounds
|
|
1524
|
+
*/
|
|
1525
|
+
private IsCanvasPointWithinEntityBounds;
|
|
1526
|
+
private calculateEntityAbsoluteBoundingBox;
|
|
1527
|
+
}
|
|
1528
|
+
|
|
1529
|
+
/**
|
|
1530
|
+
* Describes a drag and drop operation.
|
|
1531
|
+
*
|
|
1532
|
+
* @remarks I would have named it DragEvent, but that would collide with
|
|
1533
|
+
* the existing DOM DragEvent.
|
|
1534
|
+
*/
|
|
1535
|
+
interface M2DragEvent extends EntityEvent {
|
|
1536
|
+
/** Position of the entity at the time of the M2DragEvent, relative to the parent entity coordinate system. */
|
|
1537
|
+
position: Point;
|
|
1538
|
+
/** Buttons being pressed when event was fired. Taken from DOM MouseEvent.buttons. */
|
|
1539
|
+
buttons: number;
|
|
1540
|
+
}
|
|
1541
|
+
|
|
1542
|
+
declare function handleInterfaceOptions(entity: Entity, options: EntityOptions): void;
|
|
1543
|
+
declare abstract class Entity implements EntityOptions {
|
|
1544
|
+
type: EntityType;
|
|
1545
|
+
isDrawable: boolean;
|
|
1546
|
+
isShape: boolean;
|
|
1547
|
+
isText: boolean;
|
|
1548
|
+
name: string;
|
|
1549
|
+
position: Point;
|
|
1550
|
+
scale: number;
|
|
1551
|
+
isUserInteractionEnabled: boolean;
|
|
1552
|
+
draggable: boolean;
|
|
1553
|
+
hidden: boolean;
|
|
1554
|
+
layout: Layout;
|
|
1555
|
+
_game?: Game;
|
|
1556
|
+
parent?: Entity;
|
|
1557
|
+
children: Entity[];
|
|
1558
|
+
absolutePosition: Point;
|
|
1559
|
+
size: Size;
|
|
1560
|
+
absoluteScale: number;
|
|
1561
|
+
actions: Action[];
|
|
1562
|
+
queuedAction?: Action;
|
|
1563
|
+
originalActions: Action[];
|
|
1564
|
+
eventListeners: EntityEventListener[];
|
|
1565
|
+
readonly uuid: string;
|
|
1566
|
+
needsInitialization: boolean;
|
|
1567
|
+
userData: any;
|
|
1568
|
+
loopMessages: Set<string>;
|
|
1569
|
+
/** Is the entity in a pressed state? E.g., did the user put the pointer
|
|
1570
|
+
* down on the entity and not yet release it? */
|
|
1571
|
+
pressed: boolean;
|
|
1572
|
+
/** Is the entity in a pressed state AND is the pointer within the entity's
|
|
1573
|
+
* hit area? For example, a user may put the pointer down on the entity, but
|
|
1574
|
+
* then move the pointer, while still down, beyond the entity's hit area. In
|
|
1575
|
+
* this case, pressed = true, but pressedAndWithinHitArea = false. */
|
|
1576
|
+
pressedAndWithinHitArea: boolean;
|
|
1577
|
+
/** When the entity initially enters the pressed state, what is the pointer
|
|
1578
|
+
* offset? (offset from the canvas's origin to the pointer position). We
|
|
1579
|
+
* save this because it will be needed if this press then led to a drag. */
|
|
1580
|
+
pressedInitialPointerOffset: Point;
|
|
1581
|
+
/** What was the previous pointer offset when the entity was in a dragging
|
|
1582
|
+
* state? */
|
|
1583
|
+
draggingLastPointerOffset: Point;
|
|
1584
|
+
/** Is the entity in a dragging state? */
|
|
1585
|
+
dragging: boolean;
|
|
1586
|
+
constructor(options?: EntityOptions);
|
|
1587
|
+
initialize(): void;
|
|
1588
|
+
/**
|
|
1589
|
+
* The game which this entity is a part of.
|
|
1590
|
+
*
|
|
1591
|
+
* @remarks Throws error if entity is not part of the game object.
|
|
1592
|
+
*/
|
|
1593
|
+
get game(): Game;
|
|
1594
|
+
/**
|
|
1595
|
+
* Overrides toString() and returns a human-friendly description of the entity.
|
|
1596
|
+
*
|
|
1597
|
+
* @remarks Inspiration from https://stackoverflow.com/a/35361695
|
|
1598
|
+
*/
|
|
1599
|
+
toString: () => string;
|
|
1600
|
+
/**
|
|
1601
|
+
* Adds a child to this parent entity. Thows exception if the child's name
|
|
1602
|
+
* is not unique with respect to other children of this parent.
|
|
1603
|
+
*
|
|
1604
|
+
* @param child - The child entity to add
|
|
1605
|
+
*/
|
|
1606
|
+
addChild(child: Entity): void;
|
|
1607
|
+
/**
|
|
1608
|
+
* Removes all children from the entity.
|
|
1609
|
+
*/
|
|
1610
|
+
removeAllChildren(): void;
|
|
1611
|
+
/**
|
|
1612
|
+
* Removes the specific child from this parent entity. Throws exception if
|
|
1613
|
+
* this parent does not contain the child.
|
|
1614
|
+
*
|
|
1615
|
+
* @param child
|
|
1616
|
+
*/
|
|
1617
|
+
removeChild(child: Entity): void;
|
|
1618
|
+
/**
|
|
1619
|
+
* Removes the children from the parent. Throws error if the parent does not
|
|
1620
|
+
* contain all of the children.
|
|
1621
|
+
*
|
|
1622
|
+
* @param children - An array of children to remove from the parent entity
|
|
1623
|
+
*/
|
|
1624
|
+
removeChildren(children: Array<Entity>): void;
|
|
1625
|
+
/**
|
|
1626
|
+
* Searches all descendants by name and returns first matching entity.
|
|
1627
|
+
*
|
|
1628
|
+
* @remarks Descendants are children and children of children, recursively.
|
|
1629
|
+
* Throws exception if no descendant with the given name is found.
|
|
1630
|
+
*
|
|
1631
|
+
* @param name - Name of the descendant entity to return
|
|
1632
|
+
* @returns
|
|
1633
|
+
*/
|
|
1634
|
+
descendant<T extends Entity>(name: string): T;
|
|
1635
|
+
/**
|
|
1636
|
+
* Returns all descendant entities.
|
|
1637
|
+
*
|
|
1638
|
+
* @remarks Descendants are children and children of children, recursively.
|
|
1639
|
+
*/
|
|
1640
|
+
get descendants(): Array<Entity>;
|
|
1641
|
+
/**
|
|
1642
|
+
* Returns all ancestor entities, not including the entity itself.
|
|
1643
|
+
*/
|
|
1644
|
+
get ancestors(): Array<Entity>;
|
|
1645
|
+
/**
|
|
1646
|
+
* Determines if this entity or ancestor is part of an active action that
|
|
1647
|
+
* affects it appearance.
|
|
1648
|
+
*
|
|
1649
|
+
* @remarks This is used to determine if the entity should be rendered with
|
|
1650
|
+
* anti-aliasing or not. Anti-aliasing on some devices causes a new shader
|
|
1651
|
+
* to be compiled during the action, which causes jank.
|
|
1652
|
+
*
|
|
1653
|
+
* @returns true if part of active action affecting appearance
|
|
1654
|
+
*/
|
|
1655
|
+
involvedInActionAffectingAppearance(): boolean;
|
|
1656
|
+
/**
|
|
1657
|
+
* Determines if the entity is a transitioning Scene or a descendant of a
|
|
1658
|
+
* transitioning Scene.
|
|
1659
|
+
*
|
|
1660
|
+
* @returns true if transitioning
|
|
1661
|
+
*/
|
|
1662
|
+
involvedInSceneTransition(): boolean;
|
|
1663
|
+
/**
|
|
1664
|
+
* Executes a callback when the user presses down on the entity.
|
|
1665
|
+
*
|
|
1666
|
+
* @remarks TapDown is a pointer down (mouse click or touches begin) within
|
|
1667
|
+
* the bounds of the entity.
|
|
1668
|
+
*
|
|
1669
|
+
* @param callback - function to execute
|
|
1670
|
+
* @param replaceExistingCallback - should the provided callback replace
|
|
1671
|
+
* any existing callbacks of the same event type on this entity? Usually
|
|
1672
|
+
* there should be only one callback defined, instead of chaining multiple
|
|
1673
|
+
* ones. It is strongly recommended not to change this, unless you have a
|
|
1674
|
+
* special use case. Default is true.
|
|
1675
|
+
*/
|
|
1676
|
+
onTapDown(callback: (tapEvent: TapEvent) => void, replaceExistingCallback?: boolean): void;
|
|
1677
|
+
/**
|
|
1678
|
+
* Executes a callback when the user releases a press, that has been fully
|
|
1679
|
+
* within the entity, from the entity.
|
|
1680
|
+
*
|
|
1681
|
+
* @remarks TapUp is a pointer up (mouse click release or touches end) within
|
|
1682
|
+
* the bounds of the entity and the pointer, while down, has never moved
|
|
1683
|
+
* beyond the bounds of the entity.
|
|
1684
|
+
*
|
|
1685
|
+
* @param callback - function to execute
|
|
1686
|
+
* @param replaceExistingCallback - should the provided callback replace
|
|
1687
|
+
* any existing callbacks of the same event type on this entity? Usually
|
|
1688
|
+
* there should be only one callback defined, instead of chaining multiple
|
|
1689
|
+
* ones. It is strongly recommended not to change this, unless you have a
|
|
1690
|
+
* special use case. Default is true.
|
|
1691
|
+
*/
|
|
1692
|
+
onTapUp(callback: (tapEvent: TapEvent) => void, replaceExistingCallback?: boolean): void;
|
|
1693
|
+
/**
|
|
1694
|
+
* Executes a callback when the user releases a press from the entity within
|
|
1695
|
+
* the bounds of the entity.
|
|
1696
|
+
*
|
|
1697
|
+
* @remarks TapUpAny is a pointer up (mouse click release or touches end)
|
|
1698
|
+
* within the bounds of the entity and the pointer, while down, is allowed to
|
|
1699
|
+
* have been beyond the bounds of the entity during the press before the
|
|
1700
|
+
* release.
|
|
1701
|
+
*
|
|
1702
|
+
* @param callback - function to execute
|
|
1703
|
+
* @param replaceExistingCallback - should the provided callback replace
|
|
1704
|
+
* any existing callbacks of the same event type on this entity? Usually
|
|
1705
|
+
* there should be only one callback defined, instead of chaining multiple
|
|
1706
|
+
* ones. It is strongly recommended not to change this, unless you have a
|
|
1707
|
+
* special use case. Default is true.
|
|
1708
|
+
*/
|
|
1709
|
+
onTapUpAny(callback: (tapEvent: TapEvent) => void, replaceExistingCallback?: boolean): void;
|
|
1710
|
+
/**
|
|
1711
|
+
* Executes a callback when the user moves the pointer (mouse, touches) beyond
|
|
1712
|
+
* the bounds of the entity while the pointer is down.
|
|
1713
|
+
*
|
|
1714
|
+
* @remarks TapLeave occurs when the pointer (mouse, touches) that has
|
|
1715
|
+
* previously pressed the entity moves beyond the bounds of the entity
|
|
1716
|
+
* before the press release.
|
|
1717
|
+
*
|
|
1718
|
+
* @param callback - function to execute
|
|
1719
|
+
* @param replaceExistingCallback - should the provided callback replace
|
|
1720
|
+
* any existing callbacks of the same event type on this entity? Usually
|
|
1721
|
+
* there should be only one callback defined, instead of chaining multiple
|
|
1722
|
+
* ones. It is strongly recommended not to change this, unless you have a
|
|
1723
|
+
* special use case. Default is true.
|
|
1724
|
+
*/
|
|
1725
|
+
onTapLeave(callback: (tapEvent: TapEvent) => void, replaceExistingCallback?: boolean): void;
|
|
1726
|
+
/**
|
|
1727
|
+
* Executes a callback when the pointer first is down on the entity.
|
|
1728
|
+
*
|
|
1729
|
+
* @remarks PointerDown is a pointer down (mouse click or touches begin) within
|
|
1730
|
+
* the bounds of the entity. It occurs under the same conditions as TapDown.
|
|
1731
|
+
*
|
|
1732
|
+
* @param callback - function to execute
|
|
1733
|
+
* @param replaceExistingCallback - should the provided callback replace
|
|
1734
|
+
* any existing callbacks of the same event type on this entity? Usually
|
|
1735
|
+
* there should be only one callback defined, instead of chaining multiple
|
|
1736
|
+
* ones. It is strongly recommended not to change this, unless you have a
|
|
1737
|
+
* special use case. Default is true.
|
|
1738
|
+
*/
|
|
1739
|
+
onPointerDown(callback: (m2PointerEvent: M2PointerEvent) => void, replaceExistingCallback?: boolean): void;
|
|
1740
|
+
/**
|
|
1741
|
+
* Executes a callback when the user releases a press from the entity within
|
|
1742
|
+
* the bounds of the entity.
|
|
1743
|
+
*
|
|
1744
|
+
* @remarks PointerUp is a pointer up (mouse click release or touches end)
|
|
1745
|
+
* within the bounds of the entity. It does not require that there was a
|
|
1746
|
+
* previous PointerDown on the entity.
|
|
1747
|
+
*
|
|
1748
|
+
* @param callback - function to execute
|
|
1749
|
+
* @param replaceExistingCallback - should the provided callback replace
|
|
1750
|
+
* any existing callbacks of the same event type on this entity? Usually
|
|
1751
|
+
* there should be only one callback defined, instead of chaining multiple
|
|
1752
|
+
* ones. It is strongly recommended not to change this, unless you have a
|
|
1753
|
+
* special use case. Default is true.
|
|
1754
|
+
*/
|
|
1755
|
+
onPointerUp(callback: (m2PointerEvent: M2PointerEvent) => void, replaceExistingCallback?: boolean): void;
|
|
1756
|
+
/**
|
|
1757
|
+
* Executes a callback when the user moves the pointer (mouse or touches)
|
|
1758
|
+
* within the bounds of the entity.
|
|
1759
|
+
*
|
|
1760
|
+
* @param callback - function to execute
|
|
1761
|
+
* @param replaceExistingCallback - should the provided callback replace
|
|
1762
|
+
* any existing callbacks of the same event type on this entity? Usually
|
|
1763
|
+
* there should be only one callback defined, instead of chaining multiple
|
|
1764
|
+
* ones. It is strongly recommended not to change this, unless you have a
|
|
1765
|
+
* special use case. Default is true.
|
|
1766
|
+
*/
|
|
1767
|
+
onPointerMove(callback: (m2PointerEvent: M2PointerEvent) => void, replaceExistingCallback?: boolean): void;
|
|
1768
|
+
/**
|
|
1769
|
+
* Executes a callback when the user begins dragging an entity.
|
|
1770
|
+
*
|
|
1771
|
+
* @param callback - function to execute
|
|
1772
|
+
* @param replaceExistingCallback - should the provided callback replace
|
|
1773
|
+
* any existing callbacks of the same event type on this entity? Usually
|
|
1774
|
+
* there should be only one callback defined, instead of chaining multiple
|
|
1775
|
+
* ones. It is strongly recommended not to change this, unless you have a
|
|
1776
|
+
* special use case. Default is true.
|
|
1777
|
+
*/
|
|
1778
|
+
onDragStart(callback: (m2DragEvent: M2DragEvent) => void, replaceExistingCallback?: boolean): void;
|
|
1779
|
+
/**
|
|
1780
|
+
* Executes a callback when the user continues dragging an entity.
|
|
1781
|
+
*
|
|
1782
|
+
* @param callback - function to execute
|
|
1783
|
+
* @param replaceExistingCallback - should the provided callback replace
|
|
1784
|
+
* any existing callbacks of the same event type on this entity? Usually
|
|
1785
|
+
* there should be only one callback defined, instead of chaining multiple
|
|
1786
|
+
* ones. It is strongly recommended not to change this, unless you have a
|
|
1787
|
+
* special use case. Default is true.
|
|
1788
|
+
*/
|
|
1789
|
+
onDrag(callback: (m2DragEvent: M2DragEvent) => void, replaceExistingCallback?: boolean): void;
|
|
1790
|
+
/**
|
|
1791
|
+
* Executes a callback when the user stop dragging an entity.
|
|
1792
|
+
*
|
|
1793
|
+
* @param callback - function to execute
|
|
1794
|
+
* @param replaceExistingCallback - should the provided callback replace
|
|
1795
|
+
* any existing callbacks of the same event type on this entity? Usually
|
|
1796
|
+
* there should be only one callback defined, instead of chaining multiple
|
|
1797
|
+
* ones. It is strongly recommended not to change this, unless you have a
|
|
1798
|
+
* special use case. Default is true.
|
|
1799
|
+
*/
|
|
1800
|
+
onDragEnd(callback: (m2DragEvent: M2DragEvent) => void, replaceExistingCallback?: boolean): void;
|
|
1801
|
+
private addEventListener;
|
|
1802
|
+
private parseLayoutConstraints;
|
|
1803
|
+
private calculateYFromConstraint;
|
|
1804
|
+
private calculateXFromConstraint;
|
|
1805
|
+
update(): void;
|
|
1806
|
+
/**
|
|
1807
|
+
* Draws each child entity that is Drawable and is not hidden, by zPosition
|
|
1808
|
+
* order (highest zPosition on top).
|
|
1809
|
+
*
|
|
1810
|
+
* @param canvas - CanvasKit canvas
|
|
1811
|
+
*/
|
|
1812
|
+
drawChildren(canvas: Canvas): void;
|
|
1813
|
+
/**
|
|
1814
|
+
* Runs an action on this entity.
|
|
1815
|
+
*
|
|
1816
|
+
* @remarks If the entity is part of an active scene, the action runs
|
|
1817
|
+
* immediately. Otherwise, the action will run when the entity's scene
|
|
1818
|
+
* becomes active. Calling run() multiple times on an entity will add
|
|
1819
|
+
* to existing actions, not replace them.
|
|
1820
|
+
*
|
|
1821
|
+
* @param action - The action to run
|
|
1822
|
+
* @param key - key (string identifier) used to identify the action.
|
|
1823
|
+
* Only needed if the action will be referred to later
|
|
1824
|
+
*/
|
|
1825
|
+
run(action: Action, key?: string): void;
|
|
1826
|
+
/**
|
|
1827
|
+
* Remove an action from this entity. If the action is running, it will be
|
|
1828
|
+
* stopped.
|
|
1829
|
+
*
|
|
1830
|
+
* @param key - key (string identifier) of the action to remove
|
|
1831
|
+
*/
|
|
1832
|
+
removeAction(key: string): void;
|
|
1833
|
+
/**
|
|
1834
|
+
* Remove all actions from this entity. If actions are running, they will be
|
|
1835
|
+
* stopped.
|
|
1836
|
+
*/
|
|
1837
|
+
removeAllActions(): void;
|
|
1838
|
+
/**
|
|
1839
|
+
* Duplicates an entity using deep copy.
|
|
1840
|
+
*
|
|
1841
|
+
* @remarks This is a deep recursive clone (entity and children).
|
|
1842
|
+
* The uuid property of all duplicated entities will be newly created,
|
|
1843
|
+
* because uuid must be unique.
|
|
1844
|
+
*
|
|
1845
|
+
* @param newName - optional name of the new, duplicated entity. If not
|
|
1846
|
+
* provided, name will be the new uuid
|
|
1847
|
+
*/
|
|
1848
|
+
abstract duplicate(newName?: string): Entity;
|
|
1849
|
+
protected getEntityOptions(): EntityOptions;
|
|
1850
|
+
protected getDrawableOptions(): DrawableOptions;
|
|
1851
|
+
protected getTextOptions(): TextOptions;
|
|
1852
|
+
/**
|
|
1853
|
+
* Gets the scene that contains this entity by searching up the ancestor tree recursively. Throws exception if entity is not part of a scene.
|
|
1854
|
+
*
|
|
1855
|
+
* @returns Scene that contains this entity
|
|
1856
|
+
*/
|
|
1857
|
+
get canvasKit(): CanvasKit;
|
|
1858
|
+
get parentSceneAsEntity(): Entity;
|
|
1859
|
+
/**
|
|
1860
|
+
* For a given directed acyclic graph, topological ordering of the vertices will be identified using BFS
|
|
1861
|
+
* @param adjList Adjacency List that represent a graph with vertices and edges
|
|
1862
|
+
*/
|
|
1863
|
+
private findTopologicalSort;
|
|
1864
|
+
}
|
|
1865
|
+
|
|
1866
|
+
interface MoveActionOptions {
|
|
1867
|
+
/** Destination point. The point is relative to the entity's parent coordinate system */
|
|
1868
|
+
point: Point;
|
|
1869
|
+
/** Duration of move, in milliseconds */
|
|
1870
|
+
duration: number;
|
|
1871
|
+
/** Easing function for movement; default is linear */
|
|
1872
|
+
easing?: EasingFunction;
|
|
1873
|
+
/** Should the action run during screen trnsitions? Default is no */
|
|
1874
|
+
runDuringTransition?: boolean;
|
|
1875
|
+
}
|
|
1876
|
+
|
|
1877
|
+
interface WaitActionOptions {
|
|
1878
|
+
/** Duration of wait, in milliseconds */
|
|
1879
|
+
duration: number;
|
|
1880
|
+
/** Should the action run during screen transitions? Default is no */
|
|
1881
|
+
runDuringTransition?: boolean;
|
|
1882
|
+
}
|
|
1883
|
+
|
|
1884
|
+
interface CustomActionOptions {
|
|
1885
|
+
/** callback - The callback function to be executed */
|
|
1886
|
+
callback: () => void;
|
|
1887
|
+
/** Should the action run during screen transitions? Default is no */
|
|
1888
|
+
runDuringTransition?: boolean;
|
|
1889
|
+
}
|
|
1890
|
+
|
|
1891
|
+
interface ScaleActionOptions {
|
|
1892
|
+
/** The scaling ratio. 1 is no change, greater than 1 is make bigger, less than 1 is make smaller */
|
|
1893
|
+
scale: number;
|
|
1894
|
+
/** Duration of scale, in milliseconds */
|
|
1895
|
+
duration: number;
|
|
1896
|
+
/** Should the action run during screen transitions? Default is no */
|
|
1897
|
+
runDuringTransition?: boolean;
|
|
1898
|
+
}
|
|
1899
|
+
|
|
1900
|
+
interface IActionContainer {
|
|
1901
|
+
children?: Array<Action>;
|
|
1902
|
+
}
|
|
1903
|
+
|
|
1904
|
+
/** The type of action */
|
|
1905
|
+
declare enum ActionType {
|
|
1906
|
+
Sequence = "Sequence",
|
|
1907
|
+
Group = "Group",
|
|
1908
|
+
Wait = "Wait",
|
|
1909
|
+
Custom = "Custom",
|
|
1910
|
+
Move = "Move",
|
|
1911
|
+
Scale = "Scale"
|
|
1912
|
+
}
|
|
1913
|
+
|
|
1914
|
+
/**
|
|
1915
|
+
* The Action class has static methods for creating actions to be executed by
|
|
1916
|
+
* an Entity.
|
|
1917
|
+
*/
|
|
1918
|
+
declare abstract class Action {
|
|
1919
|
+
abstract type: ActionType;
|
|
1920
|
+
startOffset: number;
|
|
1921
|
+
endOffset: number;
|
|
1922
|
+
started: boolean;
|
|
1923
|
+
running: boolean;
|
|
1924
|
+
completed: boolean;
|
|
1925
|
+
runStartTime: number;
|
|
1926
|
+
duration: number;
|
|
1927
|
+
runDuringTransition: boolean;
|
|
1928
|
+
parent?: Action;
|
|
1929
|
+
isParent: boolean;
|
|
1930
|
+
isChild: boolean;
|
|
1931
|
+
key?: string;
|
|
1932
|
+
constructor(runDuringTransition?: boolean);
|
|
1933
|
+
/**
|
|
1934
|
+
* Creates an action that will move an entity to a point on the screen.
|
|
1935
|
+
*
|
|
1936
|
+
* @param options - {@link MoveActionOptions}
|
|
1937
|
+
* @returns The move action
|
|
1938
|
+
*/
|
|
1939
|
+
static move(options: MoveActionOptions): Action;
|
|
1940
|
+
/**
|
|
1941
|
+
* Creates an action that will wait a given duration before it is considered complete.
|
|
1942
|
+
*
|
|
1943
|
+
* @param options - {@link WaitActionOptions}
|
|
1944
|
+
* @returns The wait action
|
|
1945
|
+
*/
|
|
1946
|
+
static wait(options: WaitActionOptions): Action;
|
|
1947
|
+
/**
|
|
1948
|
+
* Creates an action that will execute a callback function.
|
|
1949
|
+
*
|
|
1950
|
+
* @param options - {@link CustomActionOptions}
|
|
1951
|
+
* @returns The custom action
|
|
1952
|
+
*/
|
|
1953
|
+
static custom(options: CustomActionOptions): Action;
|
|
1954
|
+
/**
|
|
1955
|
+
* Creates an action that will scale the entity's size.
|
|
1956
|
+
*
|
|
1957
|
+
* @remarks Scaling is relative to any inherited scaling, which is multiplicative. For example, if the entity's parent is scaled to 2.0 and this entity's action scales to 3.0, then the entity will appear 6 times as large as original.
|
|
1958
|
+
*
|
|
1959
|
+
* @param options - {@link ScaleActionOptions}
|
|
1960
|
+
* @returns The scale action
|
|
1961
|
+
*/
|
|
1962
|
+
static scale(options: ScaleActionOptions): Action;
|
|
1963
|
+
/**
|
|
1964
|
+
* Creates an array of actions that will be run in order.
|
|
1965
|
+
*
|
|
1966
|
+
* @remarks The next action will not begin until the current one has finished. The sequence will be considered completed when the last action has completed.
|
|
1967
|
+
*
|
|
1968
|
+
* @param actions - One or more actions that form the sequence
|
|
1969
|
+
* @returns
|
|
1970
|
+
*/
|
|
1971
|
+
static sequence(actions: Array<Action>): Action;
|
|
1972
|
+
/**
|
|
1973
|
+
* Create an array of actions that will be run simultaneously.
|
|
1974
|
+
*
|
|
1975
|
+
* @remarks All actions within the group will begin to run at the same time. The group will be considered completed when the longest-running action has completed.
|
|
1976
|
+
*
|
|
1977
|
+
* @param actions - One or more actions that form the group
|
|
1978
|
+
* @returns
|
|
1979
|
+
*/
|
|
1980
|
+
static group(actions: Array<Action>): Action;
|
|
1981
|
+
initialize(entity: Entity, key?: string): Array<Action>;
|
|
1982
|
+
static cloneAction(action: Action, key?: string): Action;
|
|
1983
|
+
static evaluateAction(action: Action, entity: Entity, now: number, dt: number): void;
|
|
1984
|
+
/**
|
|
1985
|
+
* Calculates the duration of an action, including any children actions
|
|
1986
|
+
* the action may contain.
|
|
1987
|
+
*
|
|
1988
|
+
* @remarks Uses recursion to handle arbitrary level of nesting parent
|
|
1989
|
+
* actions within parent actions
|
|
1990
|
+
*
|
|
1991
|
+
* @param action
|
|
1992
|
+
* @returns the calculated duration
|
|
1993
|
+
*/
|
|
1994
|
+
private calculateDuration;
|
|
1995
|
+
/**
|
|
1996
|
+
* Update each action's start and end offsets.
|
|
1997
|
+
*
|
|
1998
|
+
* @remarks Uses recursion to handle arbitrary level of nesting parent
|
|
1999
|
+
* actions within parent actions.
|
|
2000
|
+
*
|
|
2001
|
+
* @param action that needs assigning start and end offsets
|
|
2002
|
+
*/
|
|
2003
|
+
private calculateStartEndOffsets;
|
|
2004
|
+
/**
|
|
2005
|
+
* Takes an action hierarchy and flattens to an array of non-nested actions
|
|
2006
|
+
*
|
|
2007
|
+
* @remarks Uses recursion to handle arbitrary level of nesting parent
|
|
2008
|
+
* actions within parent actions
|
|
2009
|
+
*
|
|
2010
|
+
* @param action - the action to flatten
|
|
2011
|
+
* @param actions - the accumulator array of flattened actions. This will be
|
|
2012
|
+
* undefined on the first call, and an array on recursive calls
|
|
2013
|
+
* @returns flattened array of actions
|
|
2014
|
+
*/
|
|
2015
|
+
private flattenActions;
|
|
2016
|
+
/**
|
|
2017
|
+
* Parses the action hierarchy and assigns each action its parent and
|
|
2018
|
+
* root action.
|
|
2019
|
+
*
|
|
2020
|
+
* @remarks Uses recursion to handle arbitrary level of nesting parent
|
|
2021
|
+
* actions within parent actions
|
|
2022
|
+
*
|
|
2023
|
+
* @param action
|
|
2024
|
+
* @param rootAction - top-level action passed to the run method
|
|
2025
|
+
* @param key - optional string to identify an action
|
|
2026
|
+
*/
|
|
2027
|
+
private assignParents;
|
|
2028
|
+
}
|
|
2029
|
+
declare class SequenceAction extends Action implements IActionContainer {
|
|
2030
|
+
type: ActionType;
|
|
2031
|
+
children: Array<Action>;
|
|
2032
|
+
constructor(actions: Array<Action>);
|
|
2033
|
+
}
|
|
2034
|
+
declare class GroupAction extends Action implements IActionContainer {
|
|
2035
|
+
type: ActionType;
|
|
2036
|
+
children: Action[];
|
|
2037
|
+
constructor(actions: Array<Action>);
|
|
2038
|
+
}
|
|
2039
|
+
declare class CustomAction extends Action {
|
|
2040
|
+
type: ActionType;
|
|
2041
|
+
callback: () => void;
|
|
2042
|
+
constructor(callback: () => void, runDuringTransition?: boolean);
|
|
2043
|
+
}
|
|
2044
|
+
declare class WaitAction extends Action {
|
|
2045
|
+
type: ActionType;
|
|
2046
|
+
constructor(duration: number, runDuringTransition: boolean);
|
|
2047
|
+
}
|
|
2048
|
+
declare class MoveAction extends Action {
|
|
2049
|
+
type: ActionType;
|
|
2050
|
+
point: Point;
|
|
2051
|
+
startPoint: Point;
|
|
2052
|
+
dx: number;
|
|
2053
|
+
dy: number;
|
|
2054
|
+
easing: EasingFunction;
|
|
2055
|
+
constructor(point: Point, duration: number, easing: EasingFunction, runDuringTransition: boolean);
|
|
2056
|
+
}
|
|
2057
|
+
declare class ScaleAction extends Action {
|
|
2058
|
+
type: ActionType;
|
|
2059
|
+
scale: number;
|
|
2060
|
+
delta: number;
|
|
2061
|
+
constructor(scale: number, duration: number, runDuringTransition?: boolean);
|
|
2062
|
+
}
|
|
2063
|
+
|
|
2064
|
+
declare class CanvasKitHelpers {
|
|
2065
|
+
/**
|
|
2066
|
+
* Frees up resources that were allocated by CanvasKit.
|
|
2067
|
+
*
|
|
2068
|
+
* @remarks This frees objects created in WebAssembly by
|
|
2069
|
+
* canvaskit-wasm. JavaScript garbage collection won't
|
|
2070
|
+
* free these wasm objects.
|
|
2071
|
+
*/
|
|
2072
|
+
static Dispose(objects: Array<undefined | null | EmbindObject<Font | Paint | ParagraphBuilder | Paragraph | Image | Typeface | FontMgr | Path>>): void;
|
|
2073
|
+
static makePaint(canvasKit: CanvasKit, color: RgbaColor, style: PaintStyle, isAntialiased: boolean): Paint;
|
|
2074
|
+
}
|
|
2075
|
+
|
|
2076
|
+
interface CompositeOptions extends EntityOptions, DrawableOptions {
|
|
2077
|
+
}
|
|
2078
|
+
|
|
2079
|
+
declare abstract class Composite extends Entity implements IDrawable {
|
|
2080
|
+
readonly type = EntityType.Composite;
|
|
2081
|
+
compositeType: string;
|
|
2082
|
+
isDrawable: boolean;
|
|
2083
|
+
anchorPoint: Point;
|
|
2084
|
+
zPosition: number;
|
|
2085
|
+
/**
|
|
2086
|
+
* Base Drawable object for creating custom entities ("composites") composed of primitive entities.
|
|
2087
|
+
*
|
|
2088
|
+
* @param options
|
|
2089
|
+
*/
|
|
2090
|
+
constructor(options?: CompositeOptions);
|
|
2091
|
+
initialize(): void;
|
|
2092
|
+
dispose(): void;
|
|
2093
|
+
update(): void;
|
|
2094
|
+
draw(canvas: Canvas): void;
|
|
2095
|
+
abstract warmup(canvas: Canvas): void;
|
|
2096
|
+
}
|
|
2097
|
+
|
|
2098
|
+
/**
|
|
2099
|
+
* Reasonable defaults to use if values are not specified.
|
|
2100
|
+
*/
|
|
2101
|
+
declare class Constants {
|
|
2102
|
+
/** Size of the font showing frames per second */
|
|
2103
|
+
static readonly FPS_DISPLAY_TEXT_FONT_SIZE = 12;
|
|
2104
|
+
/** Color of the font showing frames per second */
|
|
2105
|
+
static readonly FPS_DISPLAY_TEXT_COLOR: RgbaColor;
|
|
2106
|
+
/** Frequency, in milliseconds, at which to update frames per second metric shown on the screen */
|
|
2107
|
+
static readonly FPS_DISPLAY_UPDATE_INTERVAL = 1000;
|
|
2108
|
+
/** Maximum number of activity metrics to log. */
|
|
2109
|
+
static readonly MAXIMUM_RECORDED_ACTIVITY_METRICS = 32;
|
|
2110
|
+
/** The frames per second will be logged in game metrics if the FPS is lower than this value */
|
|
2111
|
+
static readonly FPS_METRIC_REPORT_THRESHOLD = 59;
|
|
2112
|
+
/** Scene color, if none is specified. */
|
|
2113
|
+
static readonly DEFAULT_SCENE_BACKGROUND_COLOR: RgbaColor;
|
|
2114
|
+
/** Shape fill color, if none is specified. */
|
|
2115
|
+
static readonly DEFAULT_SHAPE_FILL_COLOR: RgbaColor;
|
|
2116
|
+
/** Color of paths in a shape, if none is specified. */
|
|
2117
|
+
static readonly DEFAULT_PATH_STROKE_COLOR: RgbaColor;
|
|
2118
|
+
/** Line width of paths in a shape, if none is specified. */
|
|
2119
|
+
static readonly DEFAULT_PATH_LINE_WIDTH = 2;
|
|
2120
|
+
/** Color of text in Label and TextLine, if none is specified. */
|
|
2121
|
+
static readonly DEFAULT_FONT_COLOR: RgbaColor;
|
|
2122
|
+
/** Font size in Label and TextLine, if none is specified. */
|
|
2123
|
+
static readonly DEFAULT_FONT_SIZE = 16;
|
|
2124
|
+
static readonly LIMITED_FPS_RATE = 5;
|
|
2125
|
+
static readonly FREE_ENTITIES_SCENE_NAME = "__freeEntitiesScene";
|
|
2126
|
+
static readonly OUTGOING_SCENE_NAME = "__outgoingScene";
|
|
2127
|
+
static readonly OUTGOING_SCENE_SPRITE_NAME = "__outgoingSceneSprite";
|
|
2128
|
+
static readonly OUTGOING_SCENE_IMAGE_NAME = "__outgoingSceneSnapshot";
|
|
2129
|
+
}
|
|
2130
|
+
|
|
2131
|
+
/**
|
|
2132
|
+
* This enum is used interally for processing the layout constraints. We use
|
|
2133
|
+
* an enum to avoid magic strings. NOTE: the casing in ConstraintType must
|
|
2134
|
+
* match the casing in Constraints.ts. Thus, this enum's members are in
|
|
2135
|
+
* lowercase, which is not typical Typescript style.
|
|
2136
|
+
*/
|
|
2137
|
+
declare enum ConstraintType {
|
|
2138
|
+
topToTopOf = "topToTopOf",
|
|
2139
|
+
topToBottomOf = "topToBottomOf",
|
|
2140
|
+
bottomToTopOf = "bottomToTopOf",
|
|
2141
|
+
bottomToBottomOf = "bottomToBottomOf",
|
|
2142
|
+
startToStartOf = "startToStartOf",
|
|
2143
|
+
startToEndOf = "startToEndOf",
|
|
2144
|
+
endToEndOf = "endToEndOf",
|
|
2145
|
+
endToStartOf = "endToStartOf"
|
|
2146
|
+
}
|
|
2147
|
+
|
|
2148
|
+
declare enum Dimensions {
|
|
2149
|
+
MatchConstraint = 0
|
|
2150
|
+
}
|
|
2151
|
+
|
|
2152
|
+
/**
|
|
2153
|
+
* Utility class for comparing equality of m2c2kit objects.
|
|
2154
|
+
*/
|
|
2155
|
+
declare class Equals {
|
|
2156
|
+
/**
|
|
2157
|
+
* Compares two RgbaColor objects and returns true if they are equal.
|
|
2158
|
+
*
|
|
2159
|
+
* @remarks If either of the colors is undefined, the comparison will
|
|
2160
|
+
* return false. RgbaColor is an array of 4 numbers, and thus is a
|
|
2161
|
+
* reference type. We need this method to compare two RgbaColor objects
|
|
2162
|
+
* for value equality.
|
|
2163
|
+
*
|
|
2164
|
+
* @param color1
|
|
2165
|
+
* @param color2
|
|
2166
|
+
* @returns
|
|
2167
|
+
*/
|
|
2168
|
+
static rgbaColor(color1?: RgbaColor, color2?: RgbaColor): boolean;
|
|
2169
|
+
}
|
|
2170
|
+
|
|
2171
|
+
interface FontData {
|
|
2172
|
+
gameUuid: string;
|
|
2173
|
+
fontUrl: string;
|
|
2174
|
+
fontArrayBuffer: ArrayBuffer;
|
|
2175
|
+
}
|
|
2176
|
+
|
|
2177
|
+
interface IText {
|
|
2178
|
+
text?: string;
|
|
2179
|
+
fontName?: string;
|
|
2180
|
+
fontColor?: RgbaColor;
|
|
2181
|
+
fontSize?: number;
|
|
2182
|
+
}
|
|
2183
|
+
|
|
2184
|
+
declare enum LabelHorizontalAlignmentMode {
|
|
2185
|
+
Center = 0,
|
|
2186
|
+
Left = 1,
|
|
2187
|
+
Right = 2
|
|
2188
|
+
}
|
|
2189
|
+
|
|
2190
|
+
interface LabelOptions extends EntityOptions, DrawableOptions, TextOptions {
|
|
2191
|
+
/** Horizontal alignment of label text. see {@link LabelHorizontalAlignmentMode}. Default is LabelHorizontalAlignmentMode.center */
|
|
2192
|
+
horizontalAlignmentMode?: LabelHorizontalAlignmentMode;
|
|
2193
|
+
/** Maximum width of label text before wrapping occurs. Default is the canvas width */
|
|
2194
|
+
preferredMaxLayoutWidth?: number;
|
|
2195
|
+
/** Background color of label text. Default is no background color */
|
|
2196
|
+
backgroundColor?: RgbaColor;
|
|
2197
|
+
}
|
|
2198
|
+
|
|
2199
|
+
declare class Label extends Entity implements IDrawable, IText, LabelOptions {
|
|
2200
|
+
readonly type = EntityType.Label;
|
|
2201
|
+
isDrawable: boolean;
|
|
2202
|
+
isText: boolean;
|
|
2203
|
+
anchorPoint: {
|
|
2204
|
+
x: number;
|
|
2205
|
+
y: number;
|
|
2206
|
+
};
|
|
2207
|
+
zPosition: number;
|
|
2208
|
+
private _text;
|
|
2209
|
+
private _fontName;
|
|
2210
|
+
private _fontColor;
|
|
2211
|
+
private _fontSize;
|
|
2212
|
+
private _horizontalAlignmentMode;
|
|
2213
|
+
private _preferredMaxLayoutWidth;
|
|
2214
|
+
private _backgroundColor?;
|
|
2215
|
+
private paragraph?;
|
|
2216
|
+
private paraStyle?;
|
|
2217
|
+
private builder?;
|
|
2218
|
+
private _translatedText;
|
|
2219
|
+
/**
|
|
2220
|
+
* Single or multi-line text formatted and rendered on the screen.
|
|
2221
|
+
*
|
|
2222
|
+
* @remarks Label (in contrast to TextLine) has enhanced text support for line wrapping, centering/alignment, and background colors.
|
|
2223
|
+
*
|
|
2224
|
+
* @param options - {@link LabelOptions}
|
|
2225
|
+
*/
|
|
2226
|
+
constructor(options?: LabelOptions);
|
|
2227
|
+
initialize(): void;
|
|
2228
|
+
dispose(): void;
|
|
2229
|
+
get text(): string;
|
|
2230
|
+
set text(text: string);
|
|
2231
|
+
get translatedText(): string;
|
|
2232
|
+
get fontName(): string | undefined;
|
|
2233
|
+
set fontName(fontName: string | undefined);
|
|
2234
|
+
get fontColor(): RgbaColor;
|
|
2235
|
+
set fontColor(fontColor: RgbaColor);
|
|
2236
|
+
get fontSize(): number;
|
|
2237
|
+
set fontSize(fontSize: number);
|
|
2238
|
+
get horizontalAlignmentMode(): LabelHorizontalAlignmentMode;
|
|
2239
|
+
set horizontalAlignmentMode(horizontalAlignmentMode: LabelHorizontalAlignmentMode);
|
|
2240
|
+
get preferredMaxLayoutWidth(): number | undefined;
|
|
2241
|
+
set preferredMaxLayoutWidth(preferredMaxLayoutWidth: number | undefined);
|
|
2242
|
+
get backgroundColor(): RgbaColor | undefined;
|
|
2243
|
+
set backgroundColor(backgroundColor: RgbaColor | undefined);
|
|
2244
|
+
/**
|
|
2245
|
+
* Duplicates an entity using deep copy.
|
|
2246
|
+
*
|
|
2247
|
+
* @remarks This is a deep recursive clone (entity and children).
|
|
2248
|
+
* The uuid property of all duplicated entities will be newly created,
|
|
2249
|
+
* because uuid must be unique.
|
|
2250
|
+
*
|
|
2251
|
+
* @param newName - optional name of the new, duplicated entity. If not
|
|
2252
|
+
* provided, name will be the new uuid
|
|
2253
|
+
*/
|
|
2254
|
+
duplicate(newName?: string): Label;
|
|
2255
|
+
update(): void;
|
|
2256
|
+
draw(canvas: Canvas): void;
|
|
2257
|
+
warmup(canvas: Canvas): void;
|
|
2258
|
+
}
|
|
2259
|
+
|
|
2260
|
+
/**
|
|
2261
|
+
* This class is used internally for processing layout constraints that
|
|
2262
|
+
* have been defined according to the Contraints interface.
|
|
2263
|
+
*
|
|
2264
|
+
* Imagine we have two entities, A and B. B's position is set
|
|
2265
|
+
* using its position property. A's position is set using the layout
|
|
2266
|
+
* constraint "bottomToTopOf B." A is the focal entity in this example.
|
|
2267
|
+
* What this means is that A's y coordinate will be computed such that
|
|
2268
|
+
* the bottom of A is the top of B. If A and B are squares, then A sits
|
|
2269
|
+
* on top of B with no gap.
|
|
2270
|
+
*/
|
|
2271
|
+
declare class LayoutConstraint {
|
|
2272
|
+
type: ConstraintType;
|
|
2273
|
+
alterEntity: Entity;
|
|
2274
|
+
verticalConstraint: boolean;
|
|
2275
|
+
focalEntityMinimum: boolean;
|
|
2276
|
+
alterEntityMinimum: boolean;
|
|
2277
|
+
verticalTypes: ConstraintType[];
|
|
2278
|
+
focalEntityMinimumTypes: ConstraintType[];
|
|
2279
|
+
alterEntityMinimumTypes: ConstraintType[];
|
|
2280
|
+
constructor(type: ConstraintType, alterEntity: Entity);
|
|
2281
|
+
}
|
|
2282
|
+
|
|
2283
|
+
/**
|
|
2284
|
+
* A set of lines and/or shapes to draw.
|
|
2285
|
+
*/
|
|
2286
|
+
interface M2Path {
|
|
2287
|
+
/** The subpath that compose up the path */
|
|
2288
|
+
subpaths: Array<Array<Point>>;
|
|
2289
|
+
/** The size of the path. This is neeeded to properly position the shape that is drawn by the path */
|
|
2290
|
+
size: Size;
|
|
2291
|
+
}
|
|
2292
|
+
|
|
2293
|
+
/**
|
|
2294
|
+
* Lines and/or shapes, and methods for creating them.
|
|
2295
|
+
*/
|
|
2296
|
+
declare class MutablePath implements M2Path {
|
|
2297
|
+
size: Size;
|
|
2298
|
+
_subpaths: Point[][];
|
|
2299
|
+
get subpaths(): Array<Array<Point>>;
|
|
2300
|
+
private currentPath;
|
|
2301
|
+
/**
|
|
2302
|
+
* Starts a new subpath at a given point.
|
|
2303
|
+
*
|
|
2304
|
+
* @param point - location at which to start the new subpath
|
|
2305
|
+
*/
|
|
2306
|
+
move(point: Point): void;
|
|
2307
|
+
/**
|
|
2308
|
+
* Adds a straight line to the current subpath.
|
|
2309
|
+
*
|
|
2310
|
+
* @remarks The line is added from the last point in the current subpath to
|
|
2311
|
+
* the given point.
|
|
2312
|
+
*
|
|
2313
|
+
* @param point - location where the line will end
|
|
2314
|
+
*/
|
|
2315
|
+
addLine(point: Point): void;
|
|
2316
|
+
clear(): void;
|
|
2317
|
+
duplicate(newName?: string | undefined): Entity;
|
|
2318
|
+
}
|
|
2319
|
+
|
|
2320
|
+
declare class RandomDraws {
|
|
2321
|
+
/**
|
|
2322
|
+
* Draws a single random integer from a uniform distribution of integers in
|
|
2323
|
+
* the specified range.
|
|
2324
|
+
*
|
|
2325
|
+
* @param minimumInclusive - Lower bound of range
|
|
2326
|
+
* @param maximumInclusive - Upper bound of range
|
|
2327
|
+
* @returns A sampled integer
|
|
2328
|
+
*/
|
|
2329
|
+
static SingleFromRange(minimumInclusive: number, maximumInclusive: number): number;
|
|
2330
|
+
/**
|
|
2331
|
+
* Draws random integers, without replacement, from a uniform distribution
|
|
2332
|
+
* of integers in the specified range.
|
|
2333
|
+
*
|
|
2334
|
+
* @param n - Number of draws
|
|
2335
|
+
* @param minimumInclusive - Lower bound of range
|
|
2336
|
+
* @param maximumInclusive - Upper bound of range
|
|
2337
|
+
* @returns An array of integers
|
|
2338
|
+
*/
|
|
2339
|
+
static FromRangeWithoutReplacement(n: number, minimumInclusive: number, maximumInclusive: number): Array<number>;
|
|
2340
|
+
/**
|
|
2341
|
+
* Draw random grid cell locations, without replacement, from a uniform
|
|
2342
|
+
* distribution of all grid cells. Grid cell locations are zero-based,
|
|
2343
|
+
* i.e., upper-left is (0,0).
|
|
2344
|
+
*
|
|
2345
|
+
* @param n - Number of draws
|
|
2346
|
+
* @param rows - Number of rows in grid; must be at least 1
|
|
2347
|
+
* @param columns - Number of columns in grid; must be at least 1
|
|
2348
|
+
* @param predicate - Optional lambda function that takes a grid row number
|
|
2349
|
+
* and grid column number pair and returns a boolean to indicate if the pair
|
|
2350
|
+
* should be allowed. For example, if one wanted to constrain the random
|
|
2351
|
+
* grid location to be along the diagonal, the predicate would be:
|
|
2352
|
+
* (row, column) => row === column
|
|
2353
|
+
* @returns Array of grid cells. Each cell is object in form of:
|
|
2354
|
+
* \{ row: number, column: number \}. Grid cell locations are zero-based
|
|
2355
|
+
*/
|
|
2356
|
+
static FromGridWithoutReplacement(n: number, rows: number, columns: number, predicate?: (row: number, column: number) => boolean): Array<{
|
|
2357
|
+
row: number;
|
|
2358
|
+
column: number;
|
|
2359
|
+
}>;
|
|
2360
|
+
}
|
|
2361
|
+
|
|
2362
|
+
interface RectOptions {
|
|
2363
|
+
/** Position of rectangle */
|
|
2364
|
+
origin?: Point;
|
|
2365
|
+
/** Size of rectangle */
|
|
2366
|
+
size?: Size;
|
|
2367
|
+
/** X coordinate of rectangle position; this can be used instead of setting the origin property */
|
|
2368
|
+
x?: number;
|
|
2369
|
+
/** Y coordinate of rectangle position; this can be used instead of setting the origin property */
|
|
2370
|
+
y?: number;
|
|
2371
|
+
/** Width of rectangle; this can be used instead of setting the size property */
|
|
2372
|
+
width?: number;
|
|
2373
|
+
/** Height of rectangle; this can be used instead of setting the size property */
|
|
2374
|
+
height?: number;
|
|
2375
|
+
}
|
|
2376
|
+
|
|
2377
|
+
declare enum ShapeType {
|
|
2378
|
+
Undefined = "Undefined",
|
|
2379
|
+
Rectangle = "Rectangle",
|
|
2380
|
+
Circle = "Circle",
|
|
2381
|
+
Path = "Path"
|
|
2382
|
+
}
|
|
2383
|
+
|
|
2384
|
+
/**
|
|
2385
|
+
* A path created from an SVG string path.
|
|
2386
|
+
*/
|
|
2387
|
+
interface SvgStringPath {
|
|
2388
|
+
/** SVG string from which to create te path */
|
|
2389
|
+
svgString?: string;
|
|
2390
|
+
/** If provided, scale the SVG path to this height, and scale the width to keep the original SVG proportions */
|
|
2391
|
+
height?: number;
|
|
2392
|
+
/** If provided, scale the SVG path to this width, and scale the height to keep the original SVG proportions */
|
|
2393
|
+
width?: number;
|
|
2394
|
+
}
|
|
2395
|
+
|
|
2396
|
+
interface ShapeOptions extends EntityOptions, DrawableOptions {
|
|
2397
|
+
shapeType?: ShapeType;
|
|
2398
|
+
/** If provided, shape will be a circle with given radius */
|
|
2399
|
+
circleOfRadius?: number;
|
|
2400
|
+
/** If provided, shape will be a rectangle as specified in {@link Rect} */
|
|
2401
|
+
rect?: RectOptions;
|
|
2402
|
+
/** Radius of rectangle's corners */
|
|
2403
|
+
cornerRadius?: number;
|
|
2404
|
+
/** Color with which to fill shape. Default is Constants.DEFAULT_SHAPE_FILL_COLOR (WebColors.Red) */
|
|
2405
|
+
fillColor?: RgbaColor;
|
|
2406
|
+
/** Color with which to outline shape. Default is no color for rectangle and circle, red for path. */
|
|
2407
|
+
strokeColor?: RgbaColor;
|
|
2408
|
+
/** Width of outline. Default is undefined for rectangle and cricle, 2 for path. */
|
|
2409
|
+
lineWidth?: number;
|
|
2410
|
+
/** A path from which to create the shape */
|
|
2411
|
+
path?: M2Path | SvgStringPath;
|
|
2412
|
+
/** Size of container "viewbox" for path shapes. Leave undefined for circle and rectangle shapes. */
|
|
2413
|
+
size?: Size;
|
|
2414
|
+
/** Should the shape be drawn with antialiasing. Default is yes. */
|
|
2415
|
+
isAntialiased?: boolean;
|
|
2416
|
+
}
|
|
2417
|
+
|
|
2418
|
+
declare class Shape extends Entity implements IDrawable, ShapeOptions {
|
|
2419
|
+
readonly type = EntityType.Shape;
|
|
2420
|
+
isDrawable: boolean;
|
|
2421
|
+
isShape: boolean;
|
|
2422
|
+
anchorPoint: {
|
|
2423
|
+
x: number;
|
|
2424
|
+
y: number;
|
|
2425
|
+
};
|
|
2426
|
+
zPosition: number;
|
|
2427
|
+
shapeType: ShapeType;
|
|
2428
|
+
circleOfRadius?: number;
|
|
2429
|
+
rect?: RectOptions;
|
|
2430
|
+
path?: M2Path | SvgStringPath;
|
|
2431
|
+
ckPath: Path | null;
|
|
2432
|
+
ckPathWidth?: number;
|
|
2433
|
+
ckPathHeight?: number;
|
|
2434
|
+
pathSvgString?: string;
|
|
2435
|
+
cornerRadius: number;
|
|
2436
|
+
private _fillColor;
|
|
2437
|
+
private _strokeColor?;
|
|
2438
|
+
lineWidth?: number;
|
|
2439
|
+
private _isAntialiased;
|
|
2440
|
+
private _fillColorPaintAntialiased?;
|
|
2441
|
+
private _strokeColorPaintAntialiased?;
|
|
2442
|
+
private _fillColorPaintNotAntialiased?;
|
|
2443
|
+
private _strokeColorPaintNotAntialiased?;
|
|
2444
|
+
private svgPathRequestedWidth?;
|
|
2445
|
+
private svgPathRequestedHeight?;
|
|
2446
|
+
private svgPathScaleForResizing;
|
|
2447
|
+
private svgPathWidth;
|
|
2448
|
+
private svgPathHeight;
|
|
2449
|
+
private svgPreviousAbsoluteScale;
|
|
2450
|
+
private svgPreviousAbsoluteX;
|
|
2451
|
+
private svgPreviousAbsoluteY;
|
|
2452
|
+
private pathIsSvgStringPath;
|
|
2453
|
+
/**
|
|
2454
|
+
* Rectangular, circular, or path-based shape
|
|
2455
|
+
*
|
|
2456
|
+
* @param options - {@link ShapeOptions}
|
|
2457
|
+
*/
|
|
2458
|
+
constructor(options?: ShapeOptions);
|
|
2459
|
+
initialize(): void;
|
|
2460
|
+
dispose(): void;
|
|
2461
|
+
/**
|
|
2462
|
+
* Duplicates an entity using deep copy.
|
|
2463
|
+
*
|
|
2464
|
+
* @remarks This is a deep recursive clone (entity and children).
|
|
2465
|
+
* The uuid property of all duplicated entities will be newly created,
|
|
2466
|
+
* because uuid must be unique.
|
|
2467
|
+
*
|
|
2468
|
+
* @param newName - optional name of the new, duplicated entity. If not
|
|
2469
|
+
* provided, name will be the new uuid
|
|
2470
|
+
*/
|
|
2471
|
+
duplicate(newName?: string): Shape;
|
|
2472
|
+
update(): void;
|
|
2473
|
+
draw(canvas: Canvas): void;
|
|
2474
|
+
private drawPathFromM2Path;
|
|
2475
|
+
private drawPathFromSvgString;
|
|
2476
|
+
private calculateSvgPathY;
|
|
2477
|
+
private calculateSvgPathX;
|
|
2478
|
+
private saveSvgPathDrawParameters;
|
|
2479
|
+
private calculateTransformationMatrix;
|
|
2480
|
+
private pathNeedsTransform;
|
|
2481
|
+
private drawCircle;
|
|
2482
|
+
private drawRectangle;
|
|
2483
|
+
private drawCircleWithCanvasKit;
|
|
2484
|
+
private drawRectangleWithCanvasKit;
|
|
2485
|
+
private calculateCKRoundedRectangle;
|
|
2486
|
+
private getFillPaint;
|
|
2487
|
+
private getStrokePaint;
|
|
2488
|
+
warmup(canvas: Canvas): void;
|
|
2489
|
+
private warmupFilledCircle;
|
|
2490
|
+
private warmupStrokedCircle;
|
|
2491
|
+
private warmupFilledRectangle;
|
|
2492
|
+
private warmupStrokedRectangle;
|
|
2493
|
+
get fillColor(): RgbaColor;
|
|
2494
|
+
set fillColor(fillColor: RgbaColor);
|
|
2495
|
+
get strokeColor(): RgbaColor | undefined;
|
|
2496
|
+
set strokeColor(strokeColor: RgbaColor | undefined);
|
|
2497
|
+
get isAntialiased(): boolean;
|
|
2498
|
+
set isAntialiased(isAntialiased: boolean);
|
|
2499
|
+
get fillColorPaintAntialiased(): Paint;
|
|
2500
|
+
set fillColorPaintAntialiased(value: Paint);
|
|
2501
|
+
get strokeColorPaintAntialiased(): Paint;
|
|
2502
|
+
set strokeColorPaintAntialiased(value: Paint);
|
|
2503
|
+
get fillColorPaintNotAntialiased(): Paint;
|
|
2504
|
+
set fillColorPaintNotAntialiased(value: Paint);
|
|
2505
|
+
get strokeColorPaintNotAntialiased(): Paint;
|
|
2506
|
+
set strokeColorPaintNotAntialiased(value: Paint);
|
|
2507
|
+
}
|
|
2508
|
+
|
|
2509
|
+
interface SpriteOptions extends EntityOptions, DrawableOptions {
|
|
2510
|
+
/** Name of image to use for sprite. Must have been previously loaded */
|
|
2511
|
+
imageName?: string;
|
|
2512
|
+
}
|
|
2513
|
+
|
|
2514
|
+
declare class Sprite extends Entity implements IDrawable, SpriteOptions {
|
|
2515
|
+
readonly type = EntityType.Sprite;
|
|
2516
|
+
isDrawable: boolean;
|
|
2517
|
+
anchorPoint: {
|
|
2518
|
+
x: number;
|
|
2519
|
+
y: number;
|
|
2520
|
+
};
|
|
2521
|
+
zPosition: number;
|
|
2522
|
+
private _imageName;
|
|
2523
|
+
private loadedImage?;
|
|
2524
|
+
/**
|
|
2525
|
+
* Visual image displayed on the screen.
|
|
2526
|
+
*
|
|
2527
|
+
* @remarks Images that will be used to create the sprite must be loaded during the Game.init() method prior to their use.
|
|
2528
|
+
*
|
|
2529
|
+
* @param options - {@link SpriteOptions}
|
|
2530
|
+
*/
|
|
2531
|
+
constructor(options?: SpriteOptions);
|
|
2532
|
+
initialize(): void;
|
|
2533
|
+
dispose(): void;
|
|
2534
|
+
set imageName(imageName: string);
|
|
2535
|
+
get imageName(): string;
|
|
2536
|
+
/**
|
|
2537
|
+
* Duplicates an entity using deep copy.
|
|
2538
|
+
*
|
|
2539
|
+
* @remarks This is a deep recursive clone (entity and children).
|
|
2540
|
+
* The uuid property of all duplicated entities will be newly created,
|
|
2541
|
+
* because uuid must be unique.
|
|
2542
|
+
*
|
|
2543
|
+
* @param newName - optional name of the new, duplicated entity. If not
|
|
2544
|
+
* provided, name will be the new uuid
|
|
2545
|
+
*/
|
|
2546
|
+
duplicate(newName?: string): Sprite;
|
|
2547
|
+
update(): void;
|
|
2548
|
+
draw(canvas: Canvas): void;
|
|
2549
|
+
warmup(canvas: Canvas): void;
|
|
2550
|
+
}
|
|
2551
|
+
|
|
2552
|
+
interface StoryOptions {
|
|
2553
|
+
sceneNamePrefix?: string;
|
|
2554
|
+
}
|
|
2555
|
+
|
|
2556
|
+
declare abstract class Story {
|
|
2557
|
+
static Create(options: StoryOptions): Array<Scene>;
|
|
2558
|
+
}
|
|
2559
|
+
|
|
2560
|
+
interface TextLineOptions extends EntityOptions, DrawableOptions, TextOptions {
|
|
2561
|
+
width?: number;
|
|
2562
|
+
}
|
|
2563
|
+
|
|
2564
|
+
declare class TextLine extends Entity implements IDrawable, IText, TextLineOptions {
|
|
2565
|
+
readonly type = EntityType.TextLine;
|
|
2566
|
+
isDrawable: boolean;
|
|
2567
|
+
isText: boolean;
|
|
2568
|
+
zPosition: number;
|
|
2569
|
+
anchorPoint: {
|
|
2570
|
+
x: number;
|
|
2571
|
+
y: number;
|
|
2572
|
+
};
|
|
2573
|
+
private _text;
|
|
2574
|
+
private _fontName;
|
|
2575
|
+
private _fontColor;
|
|
2576
|
+
private _fontSize;
|
|
2577
|
+
private paint?;
|
|
2578
|
+
private font?;
|
|
2579
|
+
private typeface;
|
|
2580
|
+
private _translatedText;
|
|
2581
|
+
private missingTranslationPaint?;
|
|
2582
|
+
/**
|
|
2583
|
+
* Single-line text rendered on the screen.
|
|
2584
|
+
*
|
|
2585
|
+
* @remarks TextLine has no paragraph formatting options; Label will be preferred in most use cases.
|
|
2586
|
+
*
|
|
2587
|
+
* @param options - {@link TextLineOptions}
|
|
2588
|
+
*/
|
|
2589
|
+
constructor(options?: TextLineOptions);
|
|
2590
|
+
get text(): string;
|
|
2591
|
+
set text(text: string);
|
|
2592
|
+
get translatedText(): string;
|
|
2593
|
+
get fontName(): string | undefined;
|
|
2594
|
+
set fontName(fontName: string | undefined);
|
|
2595
|
+
get fontColor(): RgbaColor;
|
|
2596
|
+
set fontColor(fontColor: RgbaColor);
|
|
2597
|
+
get fontSize(): number;
|
|
2598
|
+
set fontSize(fontSize: number);
|
|
2599
|
+
update(): void;
|
|
2600
|
+
initialize(): void;
|
|
2601
|
+
dispose(): void;
|
|
2602
|
+
/**
|
|
2603
|
+
* Duplicates an entity using deep copy.
|
|
2604
|
+
*
|
|
2605
|
+
* @remarks This is a deep recursive clone (entity and children).
|
|
2606
|
+
* The uuid property of all duplicated entities will be newly created,
|
|
2607
|
+
* because uuid must be unique.
|
|
2608
|
+
*
|
|
2609
|
+
* @param newName - optional name of the new, duplicated entity. If not
|
|
2610
|
+
* provided, name will be the new uuid
|
|
2611
|
+
*/
|
|
2612
|
+
duplicate(newName?: string): TextLine;
|
|
2613
|
+
draw(canvas: Canvas): void;
|
|
2614
|
+
warmup(canvas: Canvas): void;
|
|
2615
|
+
}
|
|
2616
|
+
|
|
2617
|
+
declare class Timer {
|
|
2618
|
+
private startTime;
|
|
2619
|
+
private stopTime;
|
|
2620
|
+
private stopped;
|
|
2621
|
+
/**
|
|
2622
|
+
* cumulativeElapsed is a cumulative total of elapsed time while the timer
|
|
2623
|
+
* was in previous started (running) states, NOT INCLUDING the possibily
|
|
2624
|
+
* active run's duration
|
|
2625
|
+
*/
|
|
2626
|
+
private cumulativeElapsed;
|
|
2627
|
+
private name;
|
|
2628
|
+
private static _timers;
|
|
2629
|
+
constructor(name: string);
|
|
2630
|
+
/**
|
|
2631
|
+
* Aliases performance.now()
|
|
2632
|
+
*
|
|
2633
|
+
* @remarks The m2c2kit Timer class is designed to measure elapsed durations
|
|
2634
|
+
* after a designated start point for a uniquely named timer. However, if a
|
|
2635
|
+
* timestamp based on the
|
|
2636
|
+
* [time origin](https://developer.mozilla.org/en-US/docs/Web/API/DOMHighResTimeStamp#the_time_origin)
|
|
2637
|
+
* is needed, this method can be used.
|
|
2638
|
+
*
|
|
2639
|
+
* @returns a [DOMHighResTimeStamp](https://developer.mozilla.org/en-US/docs/Web/API/DOMHighResTimeStamp)
|
|
2640
|
+
*/
|
|
2641
|
+
static now(): number;
|
|
2642
|
+
/**
|
|
2643
|
+
* Starts a millisecond-resolution timer based on
|
|
2644
|
+
* [performance.now()](https://developer.mozilla.org/en-US/docs/Web/API/Performance/now).
|
|
2645
|
+
*
|
|
2646
|
+
* @remarks The method throws an error if a timer with the given
|
|
2647
|
+
* name is already in a started state.
|
|
2648
|
+
*
|
|
2649
|
+
* @param name - The name of the timer to be started
|
|
2650
|
+
*/
|
|
2651
|
+
static start(name: string): void;
|
|
2652
|
+
/**
|
|
2653
|
+
* Stops a timer.
|
|
2654
|
+
*
|
|
2655
|
+
* @remarks The method throws an error if a timer with the given
|
|
2656
|
+
* name is already in a stopped state, or if a timer with the
|
|
2657
|
+
* given name has not been started.
|
|
2658
|
+
*
|
|
2659
|
+
* @param name - The name of the timer to be stopped
|
|
2660
|
+
*/
|
|
2661
|
+
static stop(name: string): void;
|
|
2662
|
+
/**
|
|
2663
|
+
* Restarts a timer.
|
|
2664
|
+
*
|
|
2665
|
+
* @remarks The timer elapsed duration is set to 0 and it starts anew.
|
|
2666
|
+
* The method throws an error if a timer with the given
|
|
2667
|
+
* name does not exist (if there is not a started or stopped timer
|
|
2668
|
+
* with the given name).
|
|
2669
|
+
*
|
|
2670
|
+
* @param name - The name of the timer to be restarted
|
|
2671
|
+
*/
|
|
2672
|
+
static restart(name: string): void;
|
|
2673
|
+
/**
|
|
2674
|
+
* Returns the total time elapsed, in milliseconds, of the timer.
|
|
2675
|
+
*
|
|
2676
|
+
* @remarks The total time elapsed will include all durations from multiple
|
|
2677
|
+
* starts and stops of the timer, if applicable. A timer's elapsed duration
|
|
2678
|
+
* can be read while it is in started or stopped state. The method throws
|
|
2679
|
+
* an error if a timer with the given name does not exist.
|
|
2680
|
+
*
|
|
2681
|
+
* @param name - The name of the timer whose elapsed duration is requested
|
|
2682
|
+
*/
|
|
2683
|
+
static elapsed(name: string): number;
|
|
2684
|
+
/**
|
|
2685
|
+
* Removes a timer.
|
|
2686
|
+
*
|
|
2687
|
+
* @remarks After removal, no additional methods can be used with a timer
|
|
2688
|
+
* of the given name, other than to start a new timer with the given name,
|
|
2689
|
+
* whose duration will begin at 0 again. The method throws an error if
|
|
2690
|
+
* a timer with the given name does not exist.
|
|
2691
|
+
*
|
|
2692
|
+
* @param name - The name of the timer to be removed
|
|
2693
|
+
*/
|
|
2694
|
+
static remove(name: string): void;
|
|
2695
|
+
/**
|
|
2696
|
+
* Remove all timers.
|
|
2697
|
+
*
|
|
2698
|
+
* @remarks This method will {@link remove} any timers in a started or
|
|
2699
|
+
* stopped state. This method is idempotent; method is safe to call even
|
|
2700
|
+
* if there are no timers to remove; no errors are thrown if there are
|
|
2701
|
+
* not any timers that can be removed.
|
|
2702
|
+
*/
|
|
2703
|
+
static removeAll(): void;
|
|
2704
|
+
/**
|
|
2705
|
+
* Checks if a timer of the given name exists.
|
|
2706
|
+
*
|
|
2707
|
+
* @remarks The method checks if there is a timer with the given name.
|
|
2708
|
+
*
|
|
2709
|
+
* @param name - The name of the timer to check for existence
|
|
2710
|
+
* @returns boolean
|
|
2711
|
+
*/
|
|
2712
|
+
static exists(name: string): boolean;
|
|
2713
|
+
}
|
|
2714
|
+
|
|
2715
|
+
declare class Uuid {
|
|
2716
|
+
static generate(): string;
|
|
2717
|
+
}
|
|
2718
|
+
|
|
2719
|
+
declare class WebColors {
|
|
2720
|
+
static Transparent: RgbaColor;
|
|
2721
|
+
static MediumVioletRed: RgbaColor;
|
|
2722
|
+
static DeepPink: RgbaColor;
|
|
2723
|
+
static PaleVioletRed: RgbaColor;
|
|
2724
|
+
static HotPink: RgbaColor;
|
|
2725
|
+
static LightPink: RgbaColor;
|
|
2726
|
+
static Pink: RgbaColor;
|
|
2727
|
+
static DarkRed: RgbaColor;
|
|
2728
|
+
static Red: RgbaColor;
|
|
2729
|
+
static Firebrick: RgbaColor;
|
|
2730
|
+
static Crimson: RgbaColor;
|
|
2731
|
+
static IndianRed: RgbaColor;
|
|
2732
|
+
static LightCoral: RgbaColor;
|
|
2733
|
+
static Salmon: RgbaColor;
|
|
2734
|
+
static DarkSalmon: RgbaColor;
|
|
2735
|
+
static LightSalmon: RgbaColor;
|
|
2736
|
+
static OrangeRed: RgbaColor;
|
|
2737
|
+
static Tomato: RgbaColor;
|
|
2738
|
+
static DarkOrange: RgbaColor;
|
|
2739
|
+
static Coral: RgbaColor;
|
|
2740
|
+
static Orange: RgbaColor;
|
|
2741
|
+
static DarkKhaki: RgbaColor;
|
|
2742
|
+
static Gold: RgbaColor;
|
|
2743
|
+
static Khaki: RgbaColor;
|
|
2744
|
+
static PeachPuff: RgbaColor;
|
|
2745
|
+
static Yellow: RgbaColor;
|
|
2746
|
+
static PaleGoldenrod: RgbaColor;
|
|
2747
|
+
static Moccasin: RgbaColor;
|
|
2748
|
+
static PapayaWhip: RgbaColor;
|
|
2749
|
+
static LightGoldenrodYellow: RgbaColor;
|
|
2750
|
+
static LemonChiffon: RgbaColor;
|
|
2751
|
+
static LightYellow: RgbaColor;
|
|
2752
|
+
static Maroon: RgbaColor;
|
|
2753
|
+
static Brown: RgbaColor;
|
|
2754
|
+
static SaddleBrown: RgbaColor;
|
|
2755
|
+
static Sienna: RgbaColor;
|
|
2756
|
+
static Chocolate: RgbaColor;
|
|
2757
|
+
static DarkGoldenrod: RgbaColor;
|
|
2758
|
+
static Peru: RgbaColor;
|
|
2759
|
+
static RosyBrown: RgbaColor;
|
|
2760
|
+
static Goldenrod: RgbaColor;
|
|
2761
|
+
static SandyBrown: RgbaColor;
|
|
2762
|
+
static Tan: RgbaColor;
|
|
2763
|
+
static Burlywood: RgbaColor;
|
|
2764
|
+
static Wheat: RgbaColor;
|
|
2765
|
+
static NavajoWhite: RgbaColor;
|
|
2766
|
+
static Bisque: RgbaColor;
|
|
2767
|
+
static BlanchedAlmond: RgbaColor;
|
|
2768
|
+
static Cornsilk: RgbaColor;
|
|
2769
|
+
static DarkGreen: RgbaColor;
|
|
2770
|
+
static Green: RgbaColor;
|
|
2771
|
+
static DarkOliveGreen: RgbaColor;
|
|
2772
|
+
static ForestGreen: RgbaColor;
|
|
2773
|
+
static SeaGreen: RgbaColor;
|
|
2774
|
+
static Olive: RgbaColor;
|
|
2775
|
+
static OliveDrab: RgbaColor;
|
|
2776
|
+
static MediumSeaGreen: RgbaColor;
|
|
2777
|
+
static LimeGreen: RgbaColor;
|
|
2778
|
+
static Lime: RgbaColor;
|
|
2779
|
+
static SpringGreen: RgbaColor;
|
|
2780
|
+
static MediumSpringGreen: RgbaColor;
|
|
2781
|
+
static DarkSeaGreen: RgbaColor;
|
|
2782
|
+
static MediumAquamarine: RgbaColor;
|
|
2783
|
+
static YellowGreen: RgbaColor;
|
|
2784
|
+
static LawnGreen: RgbaColor;
|
|
2785
|
+
static Chartreuse: RgbaColor;
|
|
2786
|
+
static LightGreen: RgbaColor;
|
|
2787
|
+
static GreenYellow: RgbaColor;
|
|
2788
|
+
static PaleGreen: RgbaColor;
|
|
2789
|
+
static Teal: RgbaColor;
|
|
2790
|
+
static DarkCyan: RgbaColor;
|
|
2791
|
+
static LightSeaGreen: RgbaColor;
|
|
2792
|
+
static CadetBlue: RgbaColor;
|
|
2793
|
+
static DarkTurquoise: RgbaColor;
|
|
2794
|
+
static MediumTurquoise: RgbaColor;
|
|
2795
|
+
static Turquoise: RgbaColor;
|
|
2796
|
+
static Aqua: RgbaColor;
|
|
2797
|
+
static Cyan: RgbaColor;
|
|
2798
|
+
static Aquamarine: RgbaColor;
|
|
2799
|
+
static PaleTurquoise: RgbaColor;
|
|
2800
|
+
static LightCyan: RgbaColor;
|
|
2801
|
+
static Navy: RgbaColor;
|
|
2802
|
+
static DarkBlue: RgbaColor;
|
|
2803
|
+
static MediumBlue: RgbaColor;
|
|
2804
|
+
static Blue: RgbaColor;
|
|
2805
|
+
static MidnightBlue: RgbaColor;
|
|
2806
|
+
static RoyalBlue: RgbaColor;
|
|
2807
|
+
static SteelBlue: RgbaColor;
|
|
2808
|
+
static DodgerBlue: RgbaColor;
|
|
2809
|
+
static DeepSkyBlue: RgbaColor;
|
|
2810
|
+
static CornflowerBlue: RgbaColor;
|
|
2811
|
+
static SkyBlue: RgbaColor;
|
|
2812
|
+
static LightSkyBlue: RgbaColor;
|
|
2813
|
+
static LightSteelBlue: RgbaColor;
|
|
2814
|
+
static LightBlue: RgbaColor;
|
|
2815
|
+
static PowderBlue: RgbaColor;
|
|
2816
|
+
static Indigo: RgbaColor;
|
|
2817
|
+
static Purple: RgbaColor;
|
|
2818
|
+
static DarkMagenta: RgbaColor;
|
|
2819
|
+
static DarkViolet: RgbaColor;
|
|
2820
|
+
static DarkSlateBlue: RgbaColor;
|
|
2821
|
+
static BlueViolet: RgbaColor;
|
|
2822
|
+
static DarkOrchid: RgbaColor;
|
|
2823
|
+
static Fuchsia: RgbaColor;
|
|
2824
|
+
static Magenta: RgbaColor;
|
|
2825
|
+
static SlateBlue: RgbaColor;
|
|
2826
|
+
static MediumSlateBlue: RgbaColor;
|
|
2827
|
+
static MediumOrchid: RgbaColor;
|
|
2828
|
+
static MediumPurple: RgbaColor;
|
|
2829
|
+
static Orchid: RgbaColor;
|
|
2830
|
+
static Violet: RgbaColor;
|
|
2831
|
+
static Plum: RgbaColor;
|
|
2832
|
+
static Thistle: RgbaColor;
|
|
2833
|
+
static Lavender: RgbaColor;
|
|
2834
|
+
static MistyRose: RgbaColor;
|
|
2835
|
+
static AntiqueWhite: RgbaColor;
|
|
2836
|
+
static Linen: RgbaColor;
|
|
2837
|
+
static Beige: RgbaColor;
|
|
2838
|
+
static WhiteSmoke: RgbaColor;
|
|
2839
|
+
static LavenderBlush: RgbaColor;
|
|
2840
|
+
static OldLace: RgbaColor;
|
|
2841
|
+
static AliceBlue: RgbaColor;
|
|
2842
|
+
static Seashell: RgbaColor;
|
|
2843
|
+
static GhostWhite: RgbaColor;
|
|
2844
|
+
static Honeydew: RgbaColor;
|
|
2845
|
+
static FloralWhite: RgbaColor;
|
|
2846
|
+
static Azure: RgbaColor;
|
|
2847
|
+
static MintCream: RgbaColor;
|
|
2848
|
+
static Snow: RgbaColor;
|
|
2849
|
+
static Ivory: RgbaColor;
|
|
2850
|
+
static White: RgbaColor;
|
|
2851
|
+
static Black: RgbaColor;
|
|
2852
|
+
static DarkSlateGray: RgbaColor;
|
|
2853
|
+
static DimGray: RgbaColor;
|
|
2854
|
+
static SlateGray: RgbaColor;
|
|
2855
|
+
static Gray: RgbaColor;
|
|
2856
|
+
static LightSlateGray: RgbaColor;
|
|
2857
|
+
static DarkGray: RgbaColor;
|
|
2858
|
+
static Silver: RgbaColor;
|
|
2859
|
+
static LightGray: RgbaColor;
|
|
2860
|
+
static Gainsboro: RgbaColor;
|
|
2861
|
+
static RebeccaPurple: RgbaColor;
|
|
2862
|
+
}
|
|
2863
|
+
|
|
2864
|
+
declare class WebGlInfo {
|
|
2865
|
+
/**
|
|
2866
|
+
* Returns graphics driver vendor and renderer information.
|
|
2867
|
+
*
|
|
2868
|
+
* @remarks Information is from parameters UNMASKED_VENDOR_WEBGL and
|
|
2869
|
+
* UNMASKED_RENDERER_WEBGL when asking for WEBGL_debug_renderer_info
|
|
2870
|
+
* from the WebGLRenderingContext.
|
|
2871
|
+
*
|
|
2872
|
+
* @returns string
|
|
2873
|
+
*/
|
|
2874
|
+
static getRendererString(): string;
|
|
2875
|
+
/**
|
|
2876
|
+
* Removes the temporary canvas that was created to get WebGL information.
|
|
2877
|
+
*/
|
|
2878
|
+
static dispose(): void;
|
|
2879
|
+
}
|
|
2880
|
+
|
|
2881
|
+
export { Action, Activity, ActivityKeyValueData, ActivityLifecycleEvent, ActivityResultsEvent, ActivityType, BrowserImage, CanvasKitHelpers, Composite, CompositeOptions, Constants, ConstraintType, Constraints, CustomAction, CustomActionOptions, DefaultParameter, Dimensions, DrawableOptions, EasingFunction, Easings, Entity, EntityEvent, EntityEventListener, EntityOptions, EntityType, Equals, EventBase, EventType, FontData, FontManager, Game, GameData, GameOptions, GameParameters, GlobalVariables, GoToActivityOptions, GroupAction, I18n, IDataStore, IDrawable, IText, ImageManager, Label, LabelHorizontalAlignmentMode, LabelOptions, Layout, LayoutConstraint, LoadedImage, M2DragEvent, M2Path, MoveAction, MoveActionOptions, MutablePath, NoneTransition, Point, RandomDraws, RectOptions, RgbaColor, ScaleAction, ScaleActionOptions, Scene, SceneOptions, SceneTransition, SequenceAction, Session, SessionDictionaryValues, SessionLifecycleEvent, SessionOptions, Shape, ShapeOptions, ShapeType, Size, SlideTransition, SlideTransitionOptions, Sprite, SpriteOptions, Story, StoryOptions, TextLine, TextLineOptions, TextOptions, Timer, Transition, TransitionDirection, TransitionType, Translations, TrialData, TrialSchema, Uuid, WaitAction, WaitActionOptions, WebColors, WebGlInfo, handleInterfaceOptions };
|