pts 0.11.4 → 0.11.6

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
@@ -22,6 +22,8 @@ declare const UIPointerActions: {
22
22
  click: string;
23
23
  keydown: string;
24
24
  keyup: string;
25
+ pointerdown: string;
26
+ pointerup: string;
25
27
  contextmenu: string;
26
28
  all: string;
27
29
  };
@@ -464,9 +466,11 @@ declare abstract class MultiTouchSpace extends Space {
464
466
  bindTouch(bind?: boolean, passive?: boolean, customTarget?: Element): this;
465
467
  bindKeyboard(bind?: boolean): this;
466
468
  touchesToPoints(evt: TouchEvent, which?: TouchPointsKey): Pt[];
467
- protected _mouseAction(type: string, evt: MouseEvent | TouchEvent): void;
469
+ protected _mouseAction(type: string, evt: MouseEvent | TouchEvent | PointerEvent): void;
468
470
  protected _mouseDown(evt: MouseEvent | TouchEvent): boolean;
471
+ protected _pointerDown(evt: PointerEvent): boolean;
469
472
  protected _mouseUp(evt: MouseEvent | TouchEvent): boolean;
473
+ protected _pointerUp(evt: PointerEvent): boolean;
470
474
  protected _mouseMove(evt: MouseEvent | TouchEvent): boolean;
471
475
  protected _mouseOver(evt: MouseEvent | TouchEvent): boolean;
472
476
  protected _mouseOut(evt: MouseEvent | TouchEvent): boolean;
@@ -619,14 +623,16 @@ declare class CanvasForm extends VisualForm {
619
623
  protected _ctx: CanvasRenderingContext2D;
620
624
  protected _estimateTextWidth: (string: any) => number;
621
625
  protected _style: DefaultFormStyle;
622
- constructor(space: CanvasSpace | CanvasRenderingContext2D);
626
+ constructor(space?: CanvasSpace | CanvasRenderingContext2D);
623
627
  get space(): CanvasSpace;
624
628
  get ctx(): PtsCanvasRenderingContext2D;
625
629
  useOffscreen(off?: boolean, clear?: boolean | string): this;
626
630
  renderOffscreen(offset?: PtLike): void;
627
631
  alpha(a: number): this;
628
632
  fill(c: string | boolean | CanvasGradient | CanvasPattern): this;
633
+ fillOnly(c: string | boolean | CanvasGradient | CanvasPattern): this;
629
634
  stroke(c: string | boolean | CanvasGradient | CanvasPattern, width?: number, linejoin?: CanvasLineJoin, linecap?: CanvasLineCap): this;
635
+ strokeOnly(c: string | boolean | CanvasGradient | CanvasPattern, width?: number, linejoin?: CanvasLineJoin, linecap?: CanvasLineCap): this;
630
636
  applyFillStroke(filled?: boolean | string, stroked?: boolean | string, strokeWidth?: number): this;
631
637
  gradient(stops: [number, string][] | string[]): ((area1: GroupLike, area2?: GroupLike) => CanvasGradient);
632
638
  composite(mode?: GlobalCompositeOperation): this;
package/dist/index.js CHANGED
@@ -2178,7 +2178,7 @@ var Num = class {
2178
2178
  */
2179
2179
  static randomPt(a, b) {
2180
2180
  let p = new Pt(a.length);
2181
- let range = b ? Vec.subtract(b, a) : a;
2181
+ let range = b ? Vec.subtract(b.slice(), a) : a;
2182
2182
  let start = b ? a : new Pt(a.length).fill(0);
2183
2183
  for (let i = 0, len = p.length; i < len; i++) {
2184
2184
  p[i] = Num.random() * range[i] + start[i];
@@ -4300,6 +4300,8 @@ var UIPointerActions = {
4300
4300
  click: "click",
4301
4301
  keydown: "keydown",
4302
4302
  keyup: "keyup",
4303
+ pointerdown: "pointerdown",
4304
+ pointerup: "pointerup",
4303
4305
  contextmenu: "contextmenu",
4304
4306
  all: "all"
4305
4307
  };
@@ -4775,7 +4777,7 @@ var Space = class {
4775
4777
  add(p) {
4776
4778
  let player = typeof p == "function" ? { animate: p } : p;
4777
4779
  let k = this.playerCount++;
4778
- let pid = this.id + k;
4780
+ let pid = player.animateID || this.id + k;
4779
4781
  this.players[pid] = player;
4780
4782
  player.animateID = pid;
4781
4783
  if (player.resize && this.bound.inited)
@@ -5012,9 +5014,13 @@ var MultiTouchSpace = class extends Space {
5012
5014
  this._mouseOut = this._mouseOut.bind(this);
5013
5015
  this._mouseMove = this._mouseMove.bind(this);
5014
5016
  this._mouseClick = this._mouseClick.bind(this);
5017
+ this._pointerDown = this._pointerDown.bind(this);
5018
+ this._pointerUp = this._pointerUp.bind(this);
5015
5019
  this._contextMenu = this._contextMenu.bind(this);
5016
5020
  this.bindCanvas("mousedown", this._mouseDown, {}, customTarget);
5021
+ this.bindCanvas("pointerdown", this._pointerDown, {}, customTarget);
5017
5022
  this.bindCanvas("mouseup", this._mouseUp, {}, customTarget);
5023
+ this.bindCanvas("pointerup", this._pointerUp, {}, customTarget);
5018
5024
  this.bindCanvas("mouseover", this._mouseOver, {}, customTarget);
5019
5025
  this.bindCanvas("mouseout", this._mouseOut, {}, customTarget);
5020
5026
  this.bindCanvas("mousemove", this._mouseMove, {}, customTarget);
@@ -5023,7 +5029,9 @@ var MultiTouchSpace = class extends Space {
5023
5029
  this._hasMouse = true;
5024
5030
  } else {
5025
5031
  this.unbindCanvas("mousedown", this._mouseDown, {}, customTarget);
5032
+ this.unbindCanvas("pointerdown", this._pointerDown, {}, customTarget);
5026
5033
  this.unbindCanvas("mouseup", this._mouseUp, {}, customTarget);
5034
+ this.unbindCanvas("pointerup", this._pointerUp, {}, customTarget);
5027
5035
  this.unbindCanvas("mouseover", this._mouseOver, {}, customTarget);
5028
5036
  this.unbindCanvas("mouseout", this._mouseOut, {}, customTarget);
5029
5037
  this.unbindCanvas("mousemove", this._mouseMove, {}, customTarget);
@@ -5135,6 +5143,13 @@ var MultiTouchSpace = class extends Space {
5135
5143
  this._pressed = true;
5136
5144
  return false;
5137
5145
  }
5146
+ _pointerDown(evt) {
5147
+ this._mouseAction(UIPointerActions.pointerdown, evt);
5148
+ if (evt.target instanceof Element) {
5149
+ evt.target.setPointerCapture(evt.pointerId);
5150
+ }
5151
+ return false;
5152
+ }
5138
5153
  /**
5139
5154
  * MouseUp handler.
5140
5155
  * @param evt
@@ -5149,6 +5164,16 @@ var MultiTouchSpace = class extends Space {
5149
5164
  this._dragged = false;
5150
5165
  return false;
5151
5166
  }
5167
+ _pointerUp(evt) {
5168
+ this._mouseAction(UIPointerActions.pointerup, evt);
5169
+ if (evt.target instanceof Element) {
5170
+ evt.target.releasePointerCapture(evt.pointerId);
5171
+ if (this._dragged)
5172
+ this._mouseAction(UIPointerActions.drop, evt);
5173
+ this._dragged = false;
5174
+ }
5175
+ return false;
5176
+ }
5152
5177
  /**
5153
5178
  * MouseMove handler.
5154
5179
  * @param evt
@@ -6254,6 +6279,14 @@ var CanvasForm = class extends VisualForm {
6254
6279
  return this;
6255
6280
  }
6256
6281
  /**
6282
+ * Set current fill style and remove stroke style.
6283
+ * @param c fill color which can be as color, gradient, or pattern. (See [canvas documentation](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/fillStyle))
6284
+ */
6285
+ fillOnly(c) {
6286
+ this.stroke(false);
6287
+ return this.fill(c);
6288
+ }
6289
+ /**
6257
6290
  * Set current stroke style. Provide a valid color string or `false` to specify no stroke color.
6258
6291
  * @example `form.stroke("#F90")`, `form.stroke("rgba(0,0,0,.5")`, `form.stroke(false)`, `form.stroke("#000", 0.5, 'round', 'square')`
6259
6292
  * @param c stroke color which can be as color, gradient, or pattern. (See [canvas documentation](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/strokeStyle))
@@ -6283,6 +6316,17 @@ var CanvasForm = class extends VisualForm {
6283
6316
  }
6284
6317
  return this;
6285
6318
  }
6319
+ /**
6320
+ * Set stroke style and remove fill style.
6321
+ * @param c stroke color which can be as color, gradient, or pattern. (See [canvas documentation](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/strokeStyle))
6322
+ * @param width Optional value (can be floating point) to set line width
6323
+ * @param linejoin Optional string to set line joint style. Can be "miter", "bevel", or "round".
6324
+ * @param linecap Optional string to set line cap style. Can be "butt", "round", or "square".
6325
+ */
6326
+ strokeOnly(c, width, linejoin, linecap) {
6327
+ this.fill(false);
6328
+ return this.stroke(c, width, linejoin, linecap);
6329
+ }
6286
6330
  /**
6287
6331
  * A convenient function to apply fill and/or stroke after custom drawings using canvas context (eg, `form.ctx.ellipse(...)`).
6288
6332
  * You don't need to call this function if you're using Pts' drawing functions like `form.point` or `form.rect`
@@ -10302,7 +10346,9 @@ var Sound = class {
10302
10346
  reject("Error loading sound");
10303
10347
  });
10304
10348
  s._source.addEventListener("canplaythrough", function() {
10305
- s._node = s._ctx.createMediaElementSource(s._source);
10349
+ if (!s._node) {
10350
+ s._node = s._ctx.createMediaElementSource(s._source);
10351
+ }
10306
10352
  resolve(s);
10307
10353
  });
10308
10354
  });
package/dist/index.mjs CHANGED
@@ -2110,7 +2110,7 @@ var Num = class {
2110
2110
  */
2111
2111
  static randomPt(a, b) {
2112
2112
  let p = new Pt(a.length);
2113
- let range = b ? Vec.subtract(b, a) : a;
2113
+ let range = b ? Vec.subtract(b.slice(), a) : a;
2114
2114
  let start = b ? a : new Pt(a.length).fill(0);
2115
2115
  for (let i = 0, len = p.length; i < len; i++) {
2116
2116
  p[i] = Num.random() * range[i] + start[i];
@@ -4232,6 +4232,8 @@ var UIPointerActions = {
4232
4232
  click: "click",
4233
4233
  keydown: "keydown",
4234
4234
  keyup: "keyup",
4235
+ pointerdown: "pointerdown",
4236
+ pointerup: "pointerup",
4235
4237
  contextmenu: "contextmenu",
4236
4238
  all: "all"
4237
4239
  };
@@ -4707,7 +4709,7 @@ var Space = class {
4707
4709
  add(p) {
4708
4710
  let player = typeof p == "function" ? { animate: p } : p;
4709
4711
  let k = this.playerCount++;
4710
- let pid = this.id + k;
4712
+ let pid = player.animateID || this.id + k;
4711
4713
  this.players[pid] = player;
4712
4714
  player.animateID = pid;
4713
4715
  if (player.resize && this.bound.inited)
@@ -4944,9 +4946,13 @@ var MultiTouchSpace = class extends Space {
4944
4946
  this._mouseOut = this._mouseOut.bind(this);
4945
4947
  this._mouseMove = this._mouseMove.bind(this);
4946
4948
  this._mouseClick = this._mouseClick.bind(this);
4949
+ this._pointerDown = this._pointerDown.bind(this);
4950
+ this._pointerUp = this._pointerUp.bind(this);
4947
4951
  this._contextMenu = this._contextMenu.bind(this);
4948
4952
  this.bindCanvas("mousedown", this._mouseDown, {}, customTarget);
4953
+ this.bindCanvas("pointerdown", this._pointerDown, {}, customTarget);
4949
4954
  this.bindCanvas("mouseup", this._mouseUp, {}, customTarget);
4955
+ this.bindCanvas("pointerup", this._pointerUp, {}, customTarget);
4950
4956
  this.bindCanvas("mouseover", this._mouseOver, {}, customTarget);
4951
4957
  this.bindCanvas("mouseout", this._mouseOut, {}, customTarget);
4952
4958
  this.bindCanvas("mousemove", this._mouseMove, {}, customTarget);
@@ -4955,7 +4961,9 @@ var MultiTouchSpace = class extends Space {
4955
4961
  this._hasMouse = true;
4956
4962
  } else {
4957
4963
  this.unbindCanvas("mousedown", this._mouseDown, {}, customTarget);
4964
+ this.unbindCanvas("pointerdown", this._pointerDown, {}, customTarget);
4958
4965
  this.unbindCanvas("mouseup", this._mouseUp, {}, customTarget);
4966
+ this.unbindCanvas("pointerup", this._pointerUp, {}, customTarget);
4959
4967
  this.unbindCanvas("mouseover", this._mouseOver, {}, customTarget);
4960
4968
  this.unbindCanvas("mouseout", this._mouseOut, {}, customTarget);
4961
4969
  this.unbindCanvas("mousemove", this._mouseMove, {}, customTarget);
@@ -5067,6 +5075,13 @@ var MultiTouchSpace = class extends Space {
5067
5075
  this._pressed = true;
5068
5076
  return false;
5069
5077
  }
5078
+ _pointerDown(evt) {
5079
+ this._mouseAction(UIPointerActions.pointerdown, evt);
5080
+ if (evt.target instanceof Element) {
5081
+ evt.target.setPointerCapture(evt.pointerId);
5082
+ }
5083
+ return false;
5084
+ }
5070
5085
  /**
5071
5086
  * MouseUp handler.
5072
5087
  * @param evt
@@ -5081,6 +5096,16 @@ var MultiTouchSpace = class extends Space {
5081
5096
  this._dragged = false;
5082
5097
  return false;
5083
5098
  }
5099
+ _pointerUp(evt) {
5100
+ this._mouseAction(UIPointerActions.pointerup, evt);
5101
+ if (evt.target instanceof Element) {
5102
+ evt.target.releasePointerCapture(evt.pointerId);
5103
+ if (this._dragged)
5104
+ this._mouseAction(UIPointerActions.drop, evt);
5105
+ this._dragged = false;
5106
+ }
5107
+ return false;
5108
+ }
5084
5109
  /**
5085
5110
  * MouseMove handler.
5086
5111
  * @param evt
@@ -6186,6 +6211,14 @@ var CanvasForm = class extends VisualForm {
6186
6211
  return this;
6187
6212
  }
6188
6213
  /**
6214
+ * Set current fill style and remove stroke style.
6215
+ * @param c fill color which can be as color, gradient, or pattern. (See [canvas documentation](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/fillStyle))
6216
+ */
6217
+ fillOnly(c) {
6218
+ this.stroke(false);
6219
+ return this.fill(c);
6220
+ }
6221
+ /**
6189
6222
  * Set current stroke style. Provide a valid color string or `false` to specify no stroke color.
6190
6223
  * @example `form.stroke("#F90")`, `form.stroke("rgba(0,0,0,.5")`, `form.stroke(false)`, `form.stroke("#000", 0.5, 'round', 'square')`
6191
6224
  * @param c stroke color which can be as color, gradient, or pattern. (See [canvas documentation](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/strokeStyle))
@@ -6215,6 +6248,17 @@ var CanvasForm = class extends VisualForm {
6215
6248
  }
6216
6249
  return this;
6217
6250
  }
6251
+ /**
6252
+ * Set stroke style and remove fill style.
6253
+ * @param c stroke color which can be as color, gradient, or pattern. (See [canvas documentation](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/strokeStyle))
6254
+ * @param width Optional value (can be floating point) to set line width
6255
+ * @param linejoin Optional string to set line joint style. Can be "miter", "bevel", or "round".
6256
+ * @param linecap Optional string to set line cap style. Can be "butt", "round", or "square".
6257
+ */
6258
+ strokeOnly(c, width, linejoin, linecap) {
6259
+ this.fill(false);
6260
+ return this.stroke(c, width, linejoin, linecap);
6261
+ }
6218
6262
  /**
6219
6263
  * A convenient function to apply fill and/or stroke after custom drawings using canvas context (eg, `form.ctx.ellipse(...)`).
6220
6264
  * You don't need to call this function if you're using Pts' drawing functions like `form.point` or `form.rect`
@@ -10234,7 +10278,9 @@ var Sound = class {
10234
10278
  reject("Error loading sound");
10235
10279
  });
10236
10280
  s._source.addEventListener("canplaythrough", function() {
10237
- s._node = s._ctx.createMediaElementSource(s._source);
10281
+ if (!s._node) {
10282
+ s._node = s._ctx.createMediaElementSource(s._source);
10283
+ }
10238
10284
  resolve(s);
10239
10285
  });
10240
10286
  });
package/dist/pts.js CHANGED
@@ -1,4 +1,4 @@
1
- /* Copyright © 2017-2023 William Ngan and contributors.
1
+ /* Copyright © 2017-2024 William Ngan and contributors.
2
2
  Licensed under Apache 2.0 License.
3
3
  See https://github.com/williamngan/pts for details. */
4
4
  (() => {
@@ -2188,7 +2188,7 @@ See https://github.com/williamngan/pts for details. */
2188
2188
  */
2189
2189
  static randomPt(a, b) {
2190
2190
  let p = new Pt(a.length);
2191
- let range = b ? Vec.subtract(b, a) : a;
2191
+ let range = b ? Vec.subtract(b.slice(), a) : a;
2192
2192
  let start = b ? a : new Pt(a.length).fill(0);
2193
2193
  for (let i = 0, len = p.length; i < len; i++) {
2194
2194
  p[i] = Num.random() * range[i] + start[i];
@@ -4318,6 +4318,8 @@ See https://github.com/williamngan/pts for details. */
4318
4318
  click: "click",
4319
4319
  keydown: "keydown",
4320
4320
  keyup: "keyup",
4321
+ pointerdown: "pointerdown",
4322
+ pointerup: "pointerup",
4321
4323
  contextmenu: "contextmenu",
4322
4324
  all: "all"
4323
4325
  };
@@ -4793,7 +4795,7 @@ See https://github.com/williamngan/pts for details. */
4793
4795
  add(p) {
4794
4796
  let player = typeof p == "function" ? { animate: p } : p;
4795
4797
  let k = this.playerCount++;
4796
- let pid = this.id + k;
4798
+ let pid = player.animateID || this.id + k;
4797
4799
  this.players[pid] = player;
4798
4800
  player.animateID = pid;
4799
4801
  if (player.resize && this.bound.inited)
@@ -5030,9 +5032,13 @@ See https://github.com/williamngan/pts for details. */
5030
5032
  this._mouseOut = this._mouseOut.bind(this);
5031
5033
  this._mouseMove = this._mouseMove.bind(this);
5032
5034
  this._mouseClick = this._mouseClick.bind(this);
5035
+ this._pointerDown = this._pointerDown.bind(this);
5036
+ this._pointerUp = this._pointerUp.bind(this);
5033
5037
  this._contextMenu = this._contextMenu.bind(this);
5034
5038
  this.bindCanvas("mousedown", this._mouseDown, {}, customTarget);
5039
+ this.bindCanvas("pointerdown", this._pointerDown, {}, customTarget);
5035
5040
  this.bindCanvas("mouseup", this._mouseUp, {}, customTarget);
5041
+ this.bindCanvas("pointerup", this._pointerUp, {}, customTarget);
5036
5042
  this.bindCanvas("mouseover", this._mouseOver, {}, customTarget);
5037
5043
  this.bindCanvas("mouseout", this._mouseOut, {}, customTarget);
5038
5044
  this.bindCanvas("mousemove", this._mouseMove, {}, customTarget);
@@ -5041,7 +5047,9 @@ See https://github.com/williamngan/pts for details. */
5041
5047
  this._hasMouse = true;
5042
5048
  } else {
5043
5049
  this.unbindCanvas("mousedown", this._mouseDown, {}, customTarget);
5050
+ this.unbindCanvas("pointerdown", this._pointerDown, {}, customTarget);
5044
5051
  this.unbindCanvas("mouseup", this._mouseUp, {}, customTarget);
5052
+ this.unbindCanvas("pointerup", this._pointerUp, {}, customTarget);
5045
5053
  this.unbindCanvas("mouseover", this._mouseOver, {}, customTarget);
5046
5054
  this.unbindCanvas("mouseout", this._mouseOut, {}, customTarget);
5047
5055
  this.unbindCanvas("mousemove", this._mouseMove, {}, customTarget);
@@ -5153,6 +5161,13 @@ See https://github.com/williamngan/pts for details. */
5153
5161
  this._pressed = true;
5154
5162
  return false;
5155
5163
  }
5164
+ _pointerDown(evt) {
5165
+ this._mouseAction(UIPointerActions.pointerdown, evt);
5166
+ if (evt.target instanceof Element) {
5167
+ evt.target.setPointerCapture(evt.pointerId);
5168
+ }
5169
+ return false;
5170
+ }
5156
5171
  /**
5157
5172
  * MouseUp handler.
5158
5173
  * @param evt
@@ -5167,6 +5182,16 @@ See https://github.com/williamngan/pts for details. */
5167
5182
  this._dragged = false;
5168
5183
  return false;
5169
5184
  }
5185
+ _pointerUp(evt) {
5186
+ this._mouseAction(UIPointerActions.pointerup, evt);
5187
+ if (evt.target instanceof Element) {
5188
+ evt.target.releasePointerCapture(evt.pointerId);
5189
+ if (this._dragged)
5190
+ this._mouseAction(UIPointerActions.drop, evt);
5191
+ this._dragged = false;
5192
+ }
5193
+ return false;
5194
+ }
5170
5195
  /**
5171
5196
  * MouseMove handler.
5172
5197
  * @param evt
@@ -6286,6 +6311,14 @@ See https://github.com/williamngan/pts for details. */
6286
6311
  return this;
6287
6312
  }
6288
6313
  /**
6314
+ * Set current fill style and remove stroke style.
6315
+ * @param c fill color which can be as color, gradient, or pattern. (See [canvas documentation](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/fillStyle))
6316
+ */
6317
+ fillOnly(c) {
6318
+ this.stroke(false);
6319
+ return this.fill(c);
6320
+ }
6321
+ /**
6289
6322
  * Set current stroke style. Provide a valid color string or `false` to specify no stroke color.
6290
6323
  * @example `form.stroke("#F90")`, `form.stroke("rgba(0,0,0,.5")`, `form.stroke(false)`, `form.stroke("#000", 0.5, 'round', 'square')`
6291
6324
  * @param c stroke color which can be as color, gradient, or pattern. (See [canvas documentation](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/strokeStyle))
@@ -6315,6 +6348,17 @@ See https://github.com/williamngan/pts for details. */
6315
6348
  }
6316
6349
  return this;
6317
6350
  }
6351
+ /**
6352
+ * Set stroke style and remove fill style.
6353
+ * @param c stroke color which can be as color, gradient, or pattern. (See [canvas documentation](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/strokeStyle))
6354
+ * @param width Optional value (can be floating point) to set line width
6355
+ * @param linejoin Optional string to set line joint style. Can be "miter", "bevel", or "round".
6356
+ * @param linecap Optional string to set line cap style. Can be "butt", "round", or "square".
6357
+ */
6358
+ strokeOnly(c, width, linejoin, linecap) {
6359
+ this.fill(false);
6360
+ return this.stroke(c, width, linejoin, linecap);
6361
+ }
6318
6362
  /**
6319
6363
  * A convenient function to apply fill and/or stroke after custom drawings using canvas context (eg, `form.ctx.ellipse(...)`).
6320
6364
  * You don't need to call this function if you're using Pts' drawing functions like `form.point` or `form.rect`
@@ -10366,7 +10410,9 @@ See https://github.com/williamngan/pts for details. */
10366
10410
  reject("Error loading sound");
10367
10411
  });
10368
10412
  s._source.addEventListener("canplaythrough", function() {
10369
- s._node = s._ctx.createMediaElementSource(s._source);
10413
+ if (!s._node) {
10414
+ s._node = s._ctx.createMediaElementSource(s._source);
10415
+ }
10370
10416
  resolve(s);
10371
10417
  });
10372
10418
  });