@m2c2kit/addons 0.3.28 → 0.3.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +47 -43
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { M2c2KitHelpers, Composite, WebColors, Shape, EventStoreMode, Equal, Label, CanvasKitHelpers, M2EventType, Timer, MutablePath, Easings, Story, Transition, TransitionDirection, LabelHorizontalAlignmentMode, Scene, Dimensions, Sprite, Action } from '@m2c2kit/core';
|
|
1
|
+
import { M2c2KitHelpers, Composite, WebColors, M2Error, Shape, EventStoreMode, Equal, Label, CanvasKitHelpers, M2EventType, Timer, MutablePath, Easings, Story, Transition, TransitionDirection, LabelHorizontalAlignmentMode, Scene, Dimensions, Sprite, Action } from '@m2c2kit/core';
|
|
2
2
|
|
|
3
3
|
class Grid extends Composite {
|
|
4
4
|
/**
|
|
@@ -26,25 +26,25 @@ class Grid extends Composite {
|
|
|
26
26
|
if (options.size) {
|
|
27
27
|
this.size = options.size;
|
|
28
28
|
} else {
|
|
29
|
-
throw new
|
|
29
|
+
throw new M2Error("grid size must be specified");
|
|
30
30
|
}
|
|
31
31
|
if (options.rows) {
|
|
32
32
|
if (options.rows >= 1) {
|
|
33
33
|
this.rows = options.rows;
|
|
34
34
|
} else {
|
|
35
|
-
throw new
|
|
35
|
+
throw new M2Error("grid rows must be at least 1");
|
|
36
36
|
}
|
|
37
37
|
} else {
|
|
38
|
-
throw new
|
|
38
|
+
throw new M2Error("grid rows must be specified");
|
|
39
39
|
}
|
|
40
40
|
if (options.columns) {
|
|
41
41
|
if (options.columns >= 1) {
|
|
42
42
|
this.columns = options.columns;
|
|
43
43
|
} else {
|
|
44
|
-
throw new
|
|
44
|
+
throw new M2Error("grid columns must be at least 1");
|
|
45
45
|
}
|
|
46
46
|
} else {
|
|
47
|
-
throw new
|
|
47
|
+
throw new M2Error("grid columns must be specified");
|
|
48
48
|
}
|
|
49
49
|
if (options.backgroundColor) {
|
|
50
50
|
this.gridBackgroundColor = options.backgroundColor;
|
|
@@ -138,7 +138,7 @@ class Grid extends Composite {
|
|
|
138
138
|
if (this.gridChildren.length > 0) {
|
|
139
139
|
this.gridChildren.forEach((gridChild) => {
|
|
140
140
|
if (!this.cellWidth || !this.cellHeight || !this.gridBackground) {
|
|
141
|
-
throw new
|
|
141
|
+
throw new M2Error(
|
|
142
142
|
"cellWidth, cellHeight, or gridBackground undefined or null"
|
|
143
143
|
);
|
|
144
144
|
}
|
|
@@ -153,7 +153,7 @@ class Grid extends Composite {
|
|
|
153
153
|
)
|
|
154
154
|
);
|
|
155
155
|
if (!childNode) {
|
|
156
|
-
throw new
|
|
156
|
+
throw new M2Error("grid: child node not found");
|
|
157
157
|
}
|
|
158
158
|
childNode?.parent?.removeChild(childNode);
|
|
159
159
|
this.cellContainers[gridChild.row][gridChild.column].addChild(
|
|
@@ -171,7 +171,7 @@ class Grid extends Composite {
|
|
|
171
171
|
}
|
|
172
172
|
get gridBackground() {
|
|
173
173
|
if (!this._gridBackground) {
|
|
174
|
-
throw new
|
|
174
|
+
throw new M2Error("gridBackground is null or undefined");
|
|
175
175
|
}
|
|
176
176
|
return this._gridBackground;
|
|
177
177
|
}
|
|
@@ -853,7 +853,7 @@ class Dialog extends Composite {
|
|
|
853
853
|
* provided, name will be the new uuid
|
|
854
854
|
*/
|
|
855
855
|
duplicate(newName) {
|
|
856
|
-
throw new
|
|
856
|
+
throw new M2Error(`duplicate not implemented. ${newName}`);
|
|
857
857
|
}
|
|
858
858
|
update() {
|
|
859
859
|
super.update();
|
|
@@ -909,7 +909,7 @@ class DrawPad extends Composite {
|
|
|
909
909
|
this.isUserInteractionEnabled = true;
|
|
910
910
|
}
|
|
911
911
|
if (!options.size) {
|
|
912
|
-
throw new
|
|
912
|
+
throw new M2Error("DrawPad size must be specified");
|
|
913
913
|
}
|
|
914
914
|
this.size = options.size;
|
|
915
915
|
if (options.lineColor) {
|
|
@@ -994,7 +994,7 @@ class DrawPad extends Composite {
|
|
|
994
994
|
handleTapDown(e) {
|
|
995
995
|
if (this.isUserInteractionEnabled) {
|
|
996
996
|
if (!this.drawShape?.path) {
|
|
997
|
-
throw new
|
|
997
|
+
throw new M2Error("DrawPad.handleTapDown(): no drawShape.path");
|
|
998
998
|
}
|
|
999
999
|
const path = this.drawShape.path;
|
|
1000
1000
|
if (this.continuousDrawingOnly && path.subpaths.length !== 0) {
|
|
@@ -1036,7 +1036,9 @@ class DrawPad extends Composite {
|
|
|
1036
1036
|
this.size
|
|
1037
1037
|
);
|
|
1038
1038
|
if (!this.drawShape?.path) {
|
|
1039
|
-
throw new
|
|
1039
|
+
throw new M2Error(
|
|
1040
|
+
"DrawPad.addInterpolatedStrokeMove(): no drawShape.path"
|
|
1041
|
+
);
|
|
1040
1042
|
}
|
|
1041
1043
|
const path = this.drawShape.path;
|
|
1042
1044
|
path.addLine(interpolatedPoint);
|
|
@@ -1119,7 +1121,7 @@ class DrawPad extends Composite {
|
|
|
1119
1121
|
handlePointerMove(e) {
|
|
1120
1122
|
if (this.isUserInteractionEnabled && this.isDrawingPointerDown) {
|
|
1121
1123
|
if (!this.drawShape?.path) {
|
|
1122
|
-
throw new
|
|
1124
|
+
throw new M2Error("DrawPad.handlePointerMove(): no drawShape.path");
|
|
1123
1125
|
}
|
|
1124
1126
|
const path = this.drawShape.path;
|
|
1125
1127
|
if (this.isDrawingPointerDown && !this.pointerIsDownAndPointerLeftDrawAreaWhenDown) {
|
|
@@ -1171,7 +1173,7 @@ class DrawPad extends Composite {
|
|
|
1171
1173
|
*/
|
|
1172
1174
|
clear() {
|
|
1173
1175
|
if (!this.drawShape?.path) {
|
|
1174
|
-
throw new
|
|
1176
|
+
throw new M2Error("DrawPad.clear(): no drawShape.path");
|
|
1175
1177
|
}
|
|
1176
1178
|
const path = this.drawShape.path;
|
|
1177
1179
|
path.clear();
|
|
@@ -1349,7 +1351,7 @@ class DrawPad extends Composite {
|
|
|
1349
1351
|
takeScreenshot() {
|
|
1350
1352
|
const drawArea = this.drawArea;
|
|
1351
1353
|
if (!drawArea) {
|
|
1352
|
-
throw new
|
|
1354
|
+
throw new M2Error("DrawPad.takeScreenshot(): no drawArea");
|
|
1353
1355
|
}
|
|
1354
1356
|
const sx = (drawArea.absolutePosition.x - drawArea.size.width / 2) * m2c2Globals.canvasScale;
|
|
1355
1357
|
const sy = (drawArea.absolutePosition.y - drawArea.size.height / 2) * m2c2Globals.canvasScale;
|
|
@@ -1370,11 +1372,11 @@ class DrawPad extends Composite {
|
|
|
1370
1372
|
pixelData.length / sh
|
|
1371
1373
|
);
|
|
1372
1374
|
if (!croppedImage) {
|
|
1373
|
-
throw new
|
|
1375
|
+
throw new M2Error("DrawPad.takeScreenshot(): no croppedImage");
|
|
1374
1376
|
}
|
|
1375
1377
|
const bytes = croppedImage.encodeToBytes();
|
|
1376
1378
|
if (!bytes) {
|
|
1377
|
-
throw new
|
|
1379
|
+
throw new M2Error(
|
|
1378
1380
|
"DrawPad.takeScreenshot(): croppedImage.encodeToBytes() failed"
|
|
1379
1381
|
);
|
|
1380
1382
|
}
|
|
@@ -1493,7 +1495,9 @@ class DrawPad extends Composite {
|
|
|
1493
1495
|
this.needsInitialization = true;
|
|
1494
1496
|
}
|
|
1495
1497
|
duplicate(newName) {
|
|
1496
|
-
throw new
|
|
1498
|
+
throw new M2Error(
|
|
1499
|
+
`DrawPad.duplicate(): Method not implemented. ${newName}`
|
|
1500
|
+
);
|
|
1497
1501
|
}
|
|
1498
1502
|
}
|
|
1499
1503
|
M2c2KitHelpers.registerM2NodeClass(DrawPad);
|
|
@@ -1741,7 +1745,7 @@ class VirtualKeyboard extends Composite {
|
|
|
1741
1745
|
});
|
|
1742
1746
|
}
|
|
1743
1747
|
duplicate(newName) {
|
|
1744
|
-
throw new
|
|
1748
|
+
throw new M2Error(`Method not implemented. ${newName}`);
|
|
1745
1749
|
}
|
|
1746
1750
|
handleKeyShapeTapDown(key, keyShape, tapEvent) {
|
|
1747
1751
|
if (key.isShift) {
|
|
@@ -1899,7 +1903,7 @@ class VirtualKeyboard extends Composite {
|
|
|
1899
1903
|
);
|
|
1900
1904
|
const keyShape = this.keyShapes.find((k) => k.userData.code === event.code);
|
|
1901
1905
|
if (!keyShape) {
|
|
1902
|
-
throw new
|
|
1906
|
+
throw new M2Error("keyShape is not defined");
|
|
1903
1907
|
}
|
|
1904
1908
|
this.shiftActivated = event.shiftKey;
|
|
1905
1909
|
switch (event.compositeEventType) {
|
|
@@ -1916,7 +1920,7 @@ class VirtualKeyboard extends Composite {
|
|
|
1916
1920
|
break;
|
|
1917
1921
|
}
|
|
1918
1922
|
default: {
|
|
1919
|
-
throw new
|
|
1923
|
+
throw new M2Error(
|
|
1920
1924
|
`Unknown VirtualKeyboardEvent: ${event.compositeEventType}`
|
|
1921
1925
|
);
|
|
1922
1926
|
}
|
|
@@ -1935,13 +1939,13 @@ class VirtualKeyboard extends Composite {
|
|
|
1935
1939
|
keyShape.fillColor = this.keyDownColor;
|
|
1936
1940
|
if (this.showKeyDownPreview) {
|
|
1937
1941
|
if (!this.letterCircle || !this.letterCircleLabel) {
|
|
1938
|
-
throw new
|
|
1942
|
+
throw new M2Error("letterCircle is not defined");
|
|
1939
1943
|
}
|
|
1940
1944
|
this.letterCircle.hidden = false;
|
|
1941
1945
|
const keyBox = keyShape.parent;
|
|
1942
1946
|
this.letterCircle.position.x = keyBox.position.x;
|
|
1943
1947
|
if (keyShape.rect?.size?.height === void 0) {
|
|
1944
|
-
throw new
|
|
1948
|
+
throw new M2Error("keyShape.rect.height is undefined");
|
|
1945
1949
|
}
|
|
1946
1950
|
this.letterCircle.position.y = keyBox.position.y - keyShape.rect.size.height * 1.2;
|
|
1947
1951
|
const keyboard2 = this.internalKeyboardRowsToInternalKeyboardConfiguration(
|
|
@@ -1949,7 +1953,7 @@ class VirtualKeyboard extends Composite {
|
|
|
1949
1953
|
);
|
|
1950
1954
|
const key = keyboard2.flat().find((k) => k.code === event.code);
|
|
1951
1955
|
if (!key) {
|
|
1952
|
-
throw new
|
|
1956
|
+
throw new M2Error("key is not defined");
|
|
1953
1957
|
}
|
|
1954
1958
|
if (this.shiftActivated) {
|
|
1955
1959
|
this.letterCircleLabel.text = key.labelTextShifted ?? key.code;
|
|
@@ -1970,7 +1974,7 @@ class VirtualKeyboard extends Composite {
|
|
|
1970
1974
|
}
|
|
1971
1975
|
keyShape.fillColor = this.keyColor;
|
|
1972
1976
|
if (!this.letterCircle) {
|
|
1973
|
-
throw new
|
|
1977
|
+
throw new M2Error("letterCircle is not defined");
|
|
1974
1978
|
}
|
|
1975
1979
|
this.letterCircle.hidden = true;
|
|
1976
1980
|
if (!event.code.toLowerCase().includes("shift") && event.shiftKey) {
|
|
@@ -1991,7 +1995,7 @@ class VirtualKeyboard extends Composite {
|
|
|
1991
1995
|
}
|
|
1992
1996
|
keyShape.fillColor = this.keyColor;
|
|
1993
1997
|
if (!this.letterCircle) {
|
|
1994
|
-
throw new
|
|
1998
|
+
throw new M2Error("letterCircle is not defined");
|
|
1995
1999
|
}
|
|
1996
2000
|
this.letterCircle.hidden = true;
|
|
1997
2001
|
}
|
|
@@ -2011,7 +2015,7 @@ class VirtualKeyboard extends Composite {
|
|
|
2011
2015
|
keyboard.flatMap((k) => k).forEach((k) => {
|
|
2012
2016
|
const keyLabel = this.keyLabels.find((l) => l.userData.code === k.code);
|
|
2013
2017
|
if (!keyLabel) {
|
|
2014
|
-
throw new
|
|
2018
|
+
throw new M2Error("keyLabel is not defined");
|
|
2015
2019
|
}
|
|
2016
2020
|
if (keyLabel.text !== void 0) {
|
|
2017
2021
|
keyLabel.text = k.labelTextShifted ?? "";
|
|
@@ -2034,7 +2038,7 @@ class VirtualKeyboard extends Composite {
|
|
|
2034
2038
|
keyboard.flatMap((k) => k).forEach((k) => {
|
|
2035
2039
|
const keyLabel = this.keyLabels.find((l) => l.userData.code === k.code);
|
|
2036
2040
|
if (!keyLabel) {
|
|
2037
|
-
throw new
|
|
2041
|
+
throw new M2Error("keyLabel is not defined");
|
|
2038
2042
|
}
|
|
2039
2043
|
if (keyLabel.text !== void 0) {
|
|
2040
2044
|
keyLabel.text = k.labelText ?? "";
|
|
@@ -2389,7 +2393,7 @@ class CountdownScene extends Scene {
|
|
|
2389
2393
|
constructor(options) {
|
|
2390
2394
|
super(options);
|
|
2391
2395
|
if (options?.transitionDurationMilliseconds !== void 0 && options?.transition) {
|
|
2392
|
-
throw new
|
|
2396
|
+
throw new M2Error(
|
|
2393
2397
|
"Both transition and transitionDurationMilliseconds options were provided. Only one should be provided. If using a custom transition, then the duration of that transition must be specified within the custom transition."
|
|
2394
2398
|
);
|
|
2395
2399
|
}
|
|
@@ -2429,7 +2433,7 @@ class CountdownScene extends Scene {
|
|
|
2429
2433
|
});
|
|
2430
2434
|
this.addChild(timerShape);
|
|
2431
2435
|
} else {
|
|
2432
|
-
throw new
|
|
2436
|
+
throw new M2Error("Invalid timer shape options.");
|
|
2433
2437
|
}
|
|
2434
2438
|
const timerInitialNumber = Math.floor(options.milliseconds / 1e3);
|
|
2435
2439
|
const timerNumberLabel = new Label({
|
|
@@ -2628,7 +2632,7 @@ class LocalePicker extends Composite {
|
|
|
2628
2632
|
});
|
|
2629
2633
|
}
|
|
2630
2634
|
if (this.localeOptions.length === 0) {
|
|
2631
|
-
throw new
|
|
2635
|
+
throw new M2Error("No locales available for LocalePicker");
|
|
2632
2636
|
}
|
|
2633
2637
|
this.children.filter((child) => child.name !== "localePickerIcon").forEach((child) => this.removeChild(child));
|
|
2634
2638
|
this.game.imageManager.loadImages([
|
|
@@ -3037,7 +3041,7 @@ class LocalePicker extends Composite {
|
|
|
3037
3041
|
* provided, name will be the new uuid
|
|
3038
3042
|
*/
|
|
3039
3043
|
duplicate(newName) {
|
|
3040
|
-
throw new
|
|
3044
|
+
throw new M2Error(`duplicate not implemented. ${newName}`);
|
|
3041
3045
|
}
|
|
3042
3046
|
}
|
|
3043
3047
|
|
|
@@ -3123,11 +3127,11 @@ class CountdownTimer extends Composite {
|
|
|
3123
3127
|
});
|
|
3124
3128
|
this.addChild(this.timerShapeNode);
|
|
3125
3129
|
} else {
|
|
3126
|
-
throw new
|
|
3130
|
+
throw new M2Error("Invalid timer shape options.");
|
|
3127
3131
|
}
|
|
3128
3132
|
this.size = this.timerShapeNode.size;
|
|
3129
3133
|
if (this.milliseconds % 1e3 !== 0) {
|
|
3130
|
-
throw new
|
|
3134
|
+
throw new M2Error(
|
|
3131
3135
|
"CountdownTimer milliseconds must be a multiple of 1000."
|
|
3132
3136
|
);
|
|
3133
3137
|
}
|
|
@@ -3220,10 +3224,10 @@ class CountdownTimer extends Composite {
|
|
|
3220
3224
|
*/
|
|
3221
3225
|
start() {
|
|
3222
3226
|
if (this.isRunning) {
|
|
3223
|
-
throw new
|
|
3227
|
+
throw new M2Error("CountdownTimer: cannot start. It is already running.");
|
|
3224
3228
|
}
|
|
3225
3229
|
if (this.hasStopped) {
|
|
3226
|
-
throw new
|
|
3230
|
+
throw new M2Error(
|
|
3227
3231
|
"CountdownTimer: It has stopped. You cannot start a stopped CountdownTimer. Instead, create a new CountdownTimer or call CountdownTimer.reset() before starting."
|
|
3228
3232
|
);
|
|
3229
3233
|
}
|
|
@@ -3269,7 +3273,7 @@ class CountdownTimer extends Composite {
|
|
|
3269
3273
|
}
|
|
3270
3274
|
handleCompositeEvent(event) {
|
|
3271
3275
|
if (!this.timerNumberLabel) {
|
|
3272
|
-
throw new
|
|
3276
|
+
throw new M2Error("Timer number label not found.");
|
|
3273
3277
|
}
|
|
3274
3278
|
switch (event.compositeEventType) {
|
|
3275
3279
|
case "CountdownTimerTick": {
|
|
@@ -3283,7 +3287,7 @@ class CountdownTimer extends Composite {
|
|
|
3283
3287
|
break;
|
|
3284
3288
|
}
|
|
3285
3289
|
default:
|
|
3286
|
-
throw new
|
|
3290
|
+
throw new M2Error(
|
|
3287
3291
|
`Invalid TimerCountdown event type: ${event.compositeEventType}`
|
|
3288
3292
|
);
|
|
3289
3293
|
}
|
|
@@ -3434,7 +3438,7 @@ class CountdownTimer extends Composite {
|
|
|
3434
3438
|
* provided, name will be the new uuid
|
|
3435
3439
|
*/
|
|
3436
3440
|
duplicate(newName) {
|
|
3437
|
-
throw new
|
|
3441
|
+
throw new M2Error(`Method not implemented. ${newName}`);
|
|
3438
3442
|
}
|
|
3439
3443
|
update() {
|
|
3440
3444
|
super.update();
|
|
@@ -3497,7 +3501,7 @@ class Slider extends Composite {
|
|
|
3497
3501
|
}
|
|
3498
3502
|
get thumbShape() {
|
|
3499
3503
|
if (this._thumbShape === void 0) {
|
|
3500
|
-
throw new
|
|
3504
|
+
throw new M2Error("thumbShape is not defined.");
|
|
3501
3505
|
}
|
|
3502
3506
|
return this._thumbShape;
|
|
3503
3507
|
}
|
|
@@ -3729,7 +3733,7 @@ class Slider extends Composite {
|
|
|
3729
3733
|
* provided, name will be the new uuid
|
|
3730
3734
|
*/
|
|
3731
3735
|
duplicate(newName) {
|
|
3732
|
-
throw new
|
|
3736
|
+
throw new M2Error(`Method not implemented. ${newName}`);
|
|
3733
3737
|
}
|
|
3734
3738
|
update() {
|
|
3735
3739
|
super.update();
|
|
@@ -3745,7 +3749,7 @@ class Slider extends Composite {
|
|
|
3745
3749
|
}
|
|
3746
3750
|
}
|
|
3747
3751
|
|
|
3748
|
-
console.log("\u26AA @m2c2kit/addons version 0.3.
|
|
3752
|
+
console.log("\u26AA @m2c2kit/addons version 0.3.29 (9f27c146)");
|
|
3749
3753
|
|
|
3750
3754
|
export { Button, CountdownScene, CountdownTimer, Dialog, DialogResult, DrawPad, DrawPadEventType, DrawPadItemEventType, Grid, Instructions, LocalePicker, Slider, VirtualKeyboard };
|
|
3751
3755
|
//# sourceMappingURL=index.js.map
|