modern-canvas 0.27.10 → 0.27.12
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
|
-
|
|
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([_({
|
|
@@ -6783,6 +6784,9 @@ var Y = class extends w {
|
|
|
6783
6784
|
isValid() {
|
|
6784
6785
|
return !!(this.enabled && (this.texture || this.animatedTexture || this.color || this.image === "viewport"));
|
|
6785
6786
|
}
|
|
6787
|
+
_resolveThemeColor(e) {
|
|
6788
|
+
return this._parent.tree?.resolveThemeColor(e) ?? e;
|
|
6789
|
+
}
|
|
6786
6790
|
draw() {
|
|
6787
6791
|
let { width: e, height: t } = this._parent.size, n = this._parent.context, r = { size: {
|
|
6788
6792
|
width: e,
|
|
@@ -6804,7 +6808,7 @@ var Y = class extends w {
|
|
|
6804
6808
|
width: e,
|
|
6805
6809
|
height: t
|
|
6806
6810
|
})
|
|
6807
|
-
}, n.fillStyle = i ?? this.color ?? "#000000FF";
|
|
6811
|
+
}, n.fillStyle = i ?? this._resolveThemeColor(this.color) ?? "#000000FF";
|
|
6808
6812
|
}
|
|
6809
6813
|
n.fill(r);
|
|
6810
6814
|
}
|
|
@@ -8819,7 +8823,7 @@ var Ma = class extends Oa {
|
|
|
8819
8823
|
super._process(e), this._updateVideoCurrentTime();
|
|
8820
8824
|
}
|
|
8821
8825
|
};
|
|
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);
|
|
8826
|
+
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
8827
|
//#endregion
|
|
8824
8828
|
//#region src/scene/animation/Animation.ts
|
|
8825
8829
|
function Na(e) {
|
|
@@ -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;
|
|
@@ -39,6 +39,8 @@ export declare class Element2DFill extends CoreObject implements NormalizedFill
|
|
|
39
39
|
protected _pipelineImageToCanvas(image: PipelineImage): HTMLCanvasElement | undefined;
|
|
40
40
|
protected _updateTexture(): Promise<void>;
|
|
41
41
|
isValid(): boolean;
|
|
42
|
+
/** Resolve `@token` theme colors lazily on draw, same as outline / text do. */
|
|
43
|
+
protected _resolveThemeColor<T = any>(value: T): T | string;
|
|
42
44
|
draw(): void;
|
|
43
45
|
protected _getFrameCurrentTime(): number;
|
|
44
46
|
updateFrameIndex(): this;
|