@m2c2kit/addons 0.3.17 → 0.3.19

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.d.ts CHANGED
@@ -968,17 +968,26 @@ declare class CountdownTimer extends Composite implements CountdownTimerOptions
968
968
  /**
969
969
  * Starts the countdown timer.
970
970
  *
971
- * @remarks Calling start on a running timer or a stopped timer will raise
972
- * an error.
971
+ * @remarks Calling `start()` on a timer whose state is running (already started)
972
+ * or stopped will raise an error.
973
973
  */
974
974
  start(): void;
975
975
  /**
976
976
  * Stops the countdown timer.
977
977
  *
978
- * @remarks This method is idempotent. Calling stop() on a stopped timer has
979
- * no effect and will not raise an error.
978
+ * @remarks This method is idempotent. Calling `stop()` on a stopped timer
979
+ * has no effect and will not raise an error. This can be called on a
980
+ * CountdownTimer in any state.
980
981
  */
981
982
  stop(): void;
983
+ /**
984
+ * Resets the countdown timer to its initial state so it can be started
985
+ * again.
986
+ *
987
+ * @remarks This method is idempotent. Calling reset() multiple times will
988
+ * not raise an error. This can be called on a CountdownTimer in any state.
989
+ */
990
+ reset(): void;
982
991
  /**
983
992
  * Returns true if the countdown timer is running.
984
993
  */
package/dist/index.js CHANGED
@@ -840,7 +840,7 @@ class Dialog extends Composite {
840
840
  }
841
841
  set hidden(hidden) {
842
842
  this._hidden = hidden;
843
- this.needsInitialization;
843
+ this.needsInitialization = true;
844
844
  }
845
845
  /**
846
846
  * Duplicates a node using deep copy.
@@ -3024,10 +3024,13 @@ class CountdownTimer extends Composite {
3024
3024
  }
3025
3025
  initialize() {
3026
3026
  this.removeAllChildren();
3027
+ this._isRunning = false;
3028
+ this.hasStopped = false;
3027
3029
  if (this.timerShape?.circle === void 0 && this.timerShape?.rectangle === void 0 || this.timerShape?.circle !== void 0) {
3028
3030
  this.timerShapeNode = new Shape({
3029
3031
  circleOfRadius: this.timerShape.circle?.radius ?? 100,
3030
- fillColor: this.timerShape?.fillColor ?? WebColors.RoyalBlue
3032
+ fillColor: this.timerShape?.fillColor ?? WebColors.RoyalBlue,
3033
+ suppressEvents: true
3031
3034
  });
3032
3035
  this.addChild(this.timerShapeNode);
3033
3036
  } else if (this.timerShape?.rectangle !== void 0) {
@@ -3037,7 +3040,8 @@ class CountdownTimer extends Composite {
3037
3040
  height: this.timerShape?.rectangle?.height ?? 200
3038
3041
  },
3039
3042
  cornerRadius: this.timerShape?.rectangle?.cornerRadius,
3040
- fillColor: this.timerShape?.fillColor ?? WebColors.RoyalBlue
3043
+ fillColor: this.timerShape?.fillColor ?? WebColors.RoyalBlue,
3044
+ suppressEvents: true
3041
3045
  });
3042
3046
  this.addChild(this.timerShapeNode);
3043
3047
  } else {
@@ -3063,7 +3067,8 @@ class CountdownTimer extends Composite {
3063
3067
  endToEndOf: this.timerShapeNode,
3064
3068
  verticalBias: this.textVerticalBias
3065
3069
  }
3066
- }
3070
+ },
3071
+ suppressEvents: true
3067
3072
  });
3068
3073
  this.timerShapeNode.addChild(this.timerNumberLabel);
3069
3074
  this.countdownSequence = new Array();
@@ -3132,8 +3137,8 @@ class CountdownTimer extends Composite {
3132
3137
  /**
3133
3138
  * Starts the countdown timer.
3134
3139
  *
3135
- * @remarks Calling start on a running timer or a stopped timer will raise
3136
- * an error.
3140
+ * @remarks Calling `start()` on a timer whose state is running (already started)
3141
+ * or stopped will raise an error.
3137
3142
  */
3138
3143
  start() {
3139
3144
  if (this.isRunning) {
@@ -3141,9 +3146,12 @@ class CountdownTimer extends Composite {
3141
3146
  }
3142
3147
  if (this.hasStopped) {
3143
3148
  throw new Error(
3144
- "CountdownTimer: It has stopped. You cannot start a stopped CountdownTimer. Instead, create a new CountdownTimer."
3149
+ "CountdownTimer: It has stopped. You cannot start a stopped CountdownTimer. Instead, create a new CountdownTimer or call CountdownTimer.reset() before starting."
3145
3150
  );
3146
3151
  }
3152
+ if (this.needsInitialization) {
3153
+ this.initialize();
3154
+ }
3147
3155
  this.run(
3148
3156
  Action.sequence(this.countdownSequence),
3149
3157
  "__countdownSequenceAction"
@@ -3153,8 +3161,9 @@ class CountdownTimer extends Composite {
3153
3161
  /**
3154
3162
  * Stops the countdown timer.
3155
3163
  *
3156
- * @remarks This method is idempotent. Calling stop() on a stopped timer has
3157
- * no effect and will not raise an error.
3164
+ * @remarks This method is idempotent. Calling `stop()` on a stopped timer
3165
+ * has no effect and will not raise an error. This can be called on a
3166
+ * CountdownTimer in any state.
3158
3167
  */
3159
3168
  stop() {
3160
3169
  if (this.isRunning) {
@@ -3163,6 +3172,17 @@ class CountdownTimer extends Composite {
3163
3172
  this.hasStopped = true;
3164
3173
  }
3165
3174
  }
3175
+ /**
3176
+ * Resets the countdown timer to its initial state so it can be started
3177
+ * again.
3178
+ *
3179
+ * @remarks This method is idempotent. Calling reset() multiple times will
3180
+ * not raise an error. This can be called on a CountdownTimer in any state.
3181
+ */
3182
+ reset() {
3183
+ this.stop();
3184
+ this.initialize();
3185
+ }
3166
3186
  /**
3167
3187
  * Returns true if the countdown timer is running.
3168
3188
  */
@@ -3242,6 +3262,7 @@ class CountdownTimer extends Composite {
3242
3262
  return;
3243
3263
  }
3244
3264
  this._milliseconds = milliseconds;
3265
+ this.needsInitialization = true;
3245
3266
  this.savePropertyChangeEvent("milliseconds", milliseconds);
3246
3267
  }
3247
3268
  get tickIntervalMilliseconds() {
@@ -3252,6 +3273,7 @@ class CountdownTimer extends Composite {
3252
3273
  return;
3253
3274
  }
3254
3275
  this._tickIntervalMilliseconds = tickIntervalMilliseconds;
3276
+ this.needsInitialization = true;
3255
3277
  this.savePropertyChangeEvent(
3256
3278
  "tickIntervalMilliseconds",
3257
3279
  tickIntervalMilliseconds
@@ -3298,6 +3320,7 @@ class CountdownTimer extends Composite {
3298
3320
  return;
3299
3321
  }
3300
3322
  this._zeroString = zeroString;
3323
+ this.needsInitialization = true;
3301
3324
  this.savePropertyChangeEvent("zeroString", zeroString);
3302
3325
  }
3303
3326
  get timerShape() {
@@ -3308,6 +3331,7 @@ class CountdownTimer extends Composite {
3308
3331
  return;
3309
3332
  }
3310
3333
  this._timerShape = shape;
3334
+ this.needsInitialization = true;
3311
3335
  this.savePropertyChangeEvent("timerShape", shape);
3312
3336
  }
3313
3337
  get textVerticalBias() {
@@ -3318,6 +3342,7 @@ class CountdownTimer extends Composite {
3318
3342
  return;
3319
3343
  }
3320
3344
  this._textVerticalBias = textVerticalBias;
3345
+ this.needsInitialization = true;
3321
3346
  this.savePropertyChangeEvent("textVerticalBias", textVerticalBias);
3322
3347
  }
3323
3348
  /**
@@ -3350,7 +3375,7 @@ M2c2KitHelpers.registerM2NodeClass(
3350
3375
  CountdownTimer
3351
3376
  );
3352
3377
 
3353
- console.log("\u26AA @m2c2kit/addons version 0.3.17 (faa531ea)");
3378
+ console.log("\u26AA @m2c2kit/addons version 0.3.19 (33cadc6d)");
3354
3379
 
3355
3380
  export { Button, CountdownScene, CountdownTimer, Dialog, DialogResult, DrawPad, DrawPadEventType, DrawPadItemEventType, Grid, Instructions, LocalePicker, VirtualKeyboard };
3356
3381
  //# sourceMappingURL=index.js.map