modern-canvas 0.27.9 → 0.27.11

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 CHANGED
@@ -4081,7 +4081,8 @@ var wr = class e extends z {
4081
4081
  });
4082
4082
  }
4083
4083
  _setupAutoUpdate() {
4084
- this.autoUpdate && this.isPlaying ? !this.fps && this.source.requestVideoFrameCallback ? (this._connected && (S.off(this.requestUpload), this._connected = !1, this._nextTime = 0), this._requestId === void 0 && (this._requestId = this.source.requestVideoFrameCallback(this._videoFrameRequestCallback))) : (this._requestId !== void 0 && (this.source.cancelVideoFrameCallback(this._requestId), this._requestId = void 0), this._connected || (S.on(this.requestUpload), this._connected = !0, this._nextTime = 0)) : (this._requestId !== void 0 && (this.source.cancelVideoFrameCallback(this._requestId), this._requestId = void 0), this._connected && (S.off(this.requestUpload), this._connected = !1, this._nextTime = 0));
4084
+ let e = !this.source.paused && !this.source.ended;
4085
+ this.autoUpdate && e ? !this.fps && this.source.requestVideoFrameCallback ? (this._connected && (S.off(this.requestUpload), this._connected = !1, this._nextTime = 0), this._requestId === void 0 && (this._requestId = this.source.requestVideoFrameCallback(this._videoFrameRequestCallback))) : (this._requestId !== void 0 && (this.source.cancelVideoFrameCallback(this._requestId), this._requestId = void 0), this._connected || (S.on(this.requestUpload), this._connected = !0, this._nextTime = 0)) : (this._requestId !== void 0 && (this.source.cancelVideoFrameCallback(this._requestId), this._requestId = void 0), this._connected && (S.off(this.requestUpload), this._connected = !1, this._nextTime = 0));
4085
4086
  }
4086
4087
  _videoFrameRequestCallback = () => {
4087
4088
  this.requestUpload(), this._requestId = this.source.requestVideoFrameCallback(this._videoFrameRequestCallback);
@@ -4093,7 +4094,7 @@ var wr = class e extends z {
4093
4094
  async load() {
4094
4095
  if (!this._sourceLoad) {
4095
4096
  let e = this.source;
4096
- (e.readyState === e.HAVE_ENOUGH_DATA || e.readyState === e.HAVE_FUTURE_DATA) && e.width && e.height && (e.complete = !0), e.addEventListener("play", this._onPlayStart), e.addEventListener("pause", this._onPlayStop), e.addEventListener("seeked", this._onSeeked), this.isReady ? this._onCanPlay() : (e.addEventListener("canplay", this._onCanPlay), e.addEventListener("canplaythrough", this._onCanPlay), e.addEventListener("error", this._onError, !0)), this._sourceLoad = new Promise((t, n) => {
4097
+ (e.readyState === e.HAVE_ENOUGH_DATA || e.readyState === e.HAVE_FUTURE_DATA) && e.width && e.height && (e.complete = !0), e.addEventListener("play", this._onPlayStart), e.addEventListener("playing", this._onPlayStart), e.addEventListener("pause", this._onPlayStop), e.addEventListener("seeked", this._onSeeked), this.isReady ? this._onCanPlay() : (e.addEventListener("canplay", this._onCanPlay), e.addEventListener("canplaythrough", this._onCanPlay), e.addEventListener("error", this._onError, !0)), this._sourceLoad = new Promise((t, n) => {
4097
4098
  this.isValid() ? (this._sourceLoad = void 0, t(this)) : (this._resolve = t, this._reject = n, e.load());
4098
4099
  });
4099
4100
  }
@@ -4102,7 +4103,7 @@ var wr = class e extends z {
4102
4103
  _destroy() {
4103
4104
  this._setupAutoUpdate(), this._flushSeekResolves();
4104
4105
  let e = this.source;
4105
- e && (e.removeEventListener("play", this._onPlayStart), e.removeEventListener("pause", this._onPlayStop), e.removeEventListener("seeked", this._onSeeked), e.removeEventListener("canplay", this._onCanPlay), e.removeEventListener("canplaythrough", this._onCanPlay), e.removeEventListener("error", this._onError, !0), e.pause(), e.src = "", e.load());
4106
+ e && (e.removeEventListener("play", this._onPlayStart), e.removeEventListener("playing", this._onPlayStart), e.removeEventListener("pause", this._onPlayStop), e.removeEventListener("seeked", this._onSeeked), e.removeEventListener("canplay", this._onCanPlay), e.removeEventListener("canplaythrough", this._onCanPlay), e.removeEventListener("error", this._onError, !0), e.pause(), e.src = "", e.load());
4106
4107
  }
4107
4108
  };
4108
4109
  k([_({
@@ -8819,7 +8820,7 @@ var Ma = class extends Oa {
8819
8820
  super._process(e), this._updateVideoCurrentTime();
8820
8821
  }
8821
8822
  };
8822
- k([_({ fallback: "" }), O("design:type", String)], Ma.prototype, "src", void 0), Ma = k([x("Video2D"), O("design:paramtypes", [typeof Partial > "u" ? Object : Partial, Array])], Ma);
8823
+ k([_({ fallback: "" }), O("design:type", String)], Ma.prototype, "src", void 0), k([_({ fallback: !0 }), O("design:type", Boolean)], Ma.prototype, "loop", void 0), Ma = k([x("Video2D"), O("design:paramtypes", [typeof Partial > "u" ? Object : Partial, Array])], Ma);
8823
8824
  //#endregion
8824
8825
  //#region src/scene/animation/Animation.ts
8825
8826
  function Na(e) {
@@ -10009,7 +10010,10 @@ var co = class extends nr {
10009
10010
  }
10010
10011
  }, mo = class extends nr {
10011
10012
  install(e) {
10012
- return this.load = (t) => e.awaitBy(() => new wr(t).load()), e.video = this, this;
10013
+ return this.load = (t) => e.awaitBy(async () => {
10014
+ let n = await new wr(t).load();
10015
+ return e.emit("loaded", t, n), n;
10016
+ }), e.video = this, this;
10013
10017
  }
10014
10018
  }, ho = Object.entries({
10015
10019
  "font/woff": ["woff"],
@@ -4,9 +4,22 @@ import type { TextureRect2DProperties } from './TextureRect2D';
4
4
  import { TextureRect2D } from './TextureRect2D';
5
5
  export interface Video2DProperties extends TextureRect2DProperties {
6
6
  src: string;
7
+ loop: boolean;
7
8
  }
8
9
  export declare class Video2D extends TextureRect2D<VideoTexture> {
9
10
  src: string;
11
+ /**
12
+ * Loop playback, on by default.
13
+ *
14
+ * `_updateVideoCurrentTime` has always forwarded this to the underlying `<video>`, but the
15
+ * property itself was never declared — it read as `undefined`, so native looping stayed off and
16
+ * a finished video only restarted via the fallbacks below (re-`play()` once `paused` flips, plus
17
+ * drift correction). Those are fragile: when the drift stays under the threshold, or the element
18
+ * is momentarily culled/invisible (which pauses and returns early), playback sticks on the last
19
+ * frame while the timeline keeps looping. Declaring it — defaulting to on — lets the browser
20
+ * loop natively and keeps the fallbacks as a safety net rather than the mechanism.
21
+ */
22
+ loop: boolean;
10
23
  get videoDuration(): number;
11
24
  protected _wait: Promise<void>;
12
25
  protected _loadAbort?: AbortController;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "modern-canvas",
3
3
  "type": "module",
4
- "version": "0.27.9",
4
+ "version": "0.27.11",
5
5
  "packageManager": "pnpm@10.19.0",
6
6
  "description": "A JavaScript WebGL rendering engine. only the ESM.",
7
7
  "author": "wxm",