@revideo/player 0.2.1-alpha.891 → 0.2.1-alpha.892

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.
Files changed (2) hide show
  1. package/dist/main.js +143 -167
  2. package/package.json +2 -2
package/dist/main.js CHANGED
@@ -1,19 +1,29 @@
1
- var g = Object.defineProperty;
2
- var p = (o, s, t) =>
3
- s in o
4
- ? g(o, s, {enumerable: !0, configurable: !0, writable: !0, value: t})
5
- : (o[s] = t);
6
- var e = (o, s, t) => (p(o, typeof s != 'symbol' ? s + '' : s, t), t);
7
- import {Player as b, Vector2 as m, Stage as v} from '@revideo/core';
8
- const f = `.initial{display:none}.state-initial .initial{display:block}.loading{display:none}.state-loading .loading{display:block}.ready{display:none}.state-ready .ready{display:block}.error{display:none}.state-error .error{display:block}:host{position:relative;display:block}.overlay{position:absolute;left:0;right:0;top:0;bottom:0;display:flex;align-items:center;justify-content:center;opacity:0;background-color:#0000008a;transition:opacity .1s}.overlay.state-ready:not(.auto){cursor:pointer}.overlay.playing:not(.hover):hover{cursor:none}.overlay.hover,.overlay.state-ready:focus-within,.overlay.state-ready:not(.playing){opacity:1}.overlay.hover .button,.overlay.state-ready:focus-within .button,.overlay.state-ready:not(.playing) .button{scale:1;transition:scale .1s ease-out}.overlay.state-loading,.overlay.state-error{opacity:1;transition:opacity 1s}.overlay.state-ready.auto{opacity:0}.button{width:50%;max-width:96px;aspect-ratio:1;scale:.5;transition:scale .1s ease-in,opacity .1s;background-color:transparent;border:none;background-size:100% 100%;background-repeat:no-repeat;opacity:.54;cursor:inherit;background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMjRweCIgdmlld0JveD0iMCAwIDI0IDI0IiB3aWR0aD0iMjRweCIgZmlsbD0iI2ZmZmZmZiI+PHBhdGggZD0iTTAgMGgyNHYyNEgwVjB6IiBmaWxsPSJub25lIi8+PHBhdGggZD0iTTEyIDJDNi40OCAyIDIgNi40OCAyIDEyczQuNDggMTAgMTAgMTAgMTAtNC40OCAxMC0xMFMxNy41MiAyIDEyIDJ6bS0yIDE0LjV2LTlsNiA0LjUtNiA0LjV6Ii8+PC9zdmc+)}.playing .button{background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGVuYWJsZS1iYWNrZ3JvdW5kPSJuZXcgMCAwIDI0IDI0IiBoZWlnaHQ9IjI0cHgiIHZpZXdCb3g9IjAgMCAyNCAyNCIgd2lkdGg9IjI0cHgiIGZpbGw9IiNmZmZmZmYiPjxnPjxyZWN0IGZpbGw9Im5vbmUiIGhlaWdodD0iMjQiIHdpZHRoPSIyNCIvPjxyZWN0IGZpbGw9Im5vbmUiIGhlaWdodD0iMjQiIHdpZHRoPSIyNCIvPjxyZWN0IGZpbGw9Im5vbmUiIGhlaWdodD0iMjQiIHdpZHRoPSIyNCIvPjwvZz48Zz48Zy8+PHBhdGggZD0iTTEyLDJDNi40OCwyLDIsNi40OCwyLDEyczQuNDgsMTAsMTAsMTBzMTAtNC40OCwxMC0xMFMxNy41MiwyLDEyLDJ6IE0xMSwxNkg5VjhoMlYxNnogTTE1LDE2aC0yVjhoMlYxNnoiLz48L2c+PC9zdmc+)}.button:focus,.overlay:hover .button{opacity:.87}.auto .button{display:none}.canvas{width:100%;display:block;opacity:0;transition:opacity .1s}.canvas.state-ready{opacity:1}.message{font-family:JetBrains Mono,sans-serif;text-align:center;font-size:20px;padding:8px 16px;margin:16px;border-radius:4px;color:#fff9;background-color:#000000de}.loader{width:50%;max-width:96px;display:none;rotate:-90deg;animation:stroke 2s cubic-bezier(.5,0,.5,1) infinite,rotate 2s linear infinite}@keyframes stroke{0%{stroke-dasharray:5.6548667765px 50.8938009883px;stroke-dashoffset:2.8274333882px}50%{stroke-dasharray:50.8938009883px 5.6548667765px;stroke-dashoffset:-2.8274333882px}to{stroke-dasharray:5.6548667765px 50.8938009883px;stroke-dashoffset:-53.7212343766px}}@keyframes rotate{0%{rotate:-110deg}to{rotate:250deg}}
9
- `,
10
- I = `<div class="overlay" part="overlay">
11
- <button
12
- part="play-button"
13
- title="Play / Pause"
14
- class="button ready"
15
- tabindex="0"
16
- ></button>
1
+ var p = Object.defineProperty;
2
+ var y = (h, r, t) => r in h ? p(h, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : h[r] = t;
3
+ var e = (h, r, t) => (y(h, typeof r != "symbol" ? r + "" : r, t), t);
4
+ import { Stage as M, Player as m, Vector2 as b } from "@revideo/core";
5
+ const v = `.initial{display:none}.state-initial .initial{display:block}.loading{display:none}.state-loading .loading{display:block}.ready{display:none}.state-ready .ready{display:block}.error{display:none}.state-error .error{display:block}:host{position:relative;display:block}.controls{position:absolute;left:0;right:0;display:flex;align-items:center;justify-content:space-between;bottom:0%;height:10%;background:rgba(0,0,0,0)}.timeline-container{height:100%;width:calc(100% - 32px);top:0%;position:absolute;z-index:5}.timeline{position:absolute;-webkit-appearance:none;-moz-appearance:none;appearance:none;margin-left:16px;margin-right:16px;width:100%;background:transparent;cursor:pointer;background-size:100% 40px;background-repeat:no-repeat;bottom:10px;z-index:10}.timeline::-webkit-slider-runnable-track{width:100%;height:5px;background:white;background:var(--webkit-track, white)}.timeline:hover::-webkit-slider-runnable-track{width:100%;height:5px;background:white;background:var(--webkit-track, white)}.timeline::-moz-range-track{width:100%;height:5px;background:white;background:var(--moz-track, white)}.timeline::-ms-track{width:100%;height:4px;background:white;background:var(--ms-track, rgb(201, 199, 199))}.timeline::-webkit-slider-thumb{-webkit-appearance:none;-moz-appearance:none;appearance:none;width:16px;height:16px;background:#fff;border-radius:50%;cursor:pointer;opacity:0;transition:opacity .2s ease;margin-top:-6px}.timeline::-moz-range-thumb{-webkit-appearance:none;-moz-appearance:none;appearance:none;width:16px;height:16px;background:#fff;border-radius:50%;cursor:pointer;opacity:0;transition:opacity .2s ease;margin-top:-6px}.timeline::-ms-thumb{-webkit-appearance:none;-moz-appearance:none;appearance:none;width:16px;height:16px;background:#fff;border-radius:50%;cursor:pointer;opacity:0;transition:opacity .2s ease;margin-top:-6px}.timeline:hover::-webkit-slider-thumb{opacity:1;background:#fff}.timeline:hover::-moz-range-thumb{opacity:1;background:#fff}.timeline:hover::-ms-thumb{opacity:1;background:#fff}.overlay{position:absolute;left:0;right:0;top:0;bottom:0;display:flex;align-items:center;justify-content:center;opacity:0;transition:opacity .1s;z-index:0}.overlay.state-ready:not(.auto){cursor:pointer}.overlay.playing:not(.hover):hover{cursor:none}.overlay.hover,.overlay.state-ready:focus-within,.overlay.state-ready:not(.playing){opacity:1}.overlay.state-loading,.overlay.state-error{opacity:1;transition:opacity 1s}.overlay.state-ready.auto{opacity:0}.button{width:16px;position:absolute;bottom:25px;left:14px;height:14px;transition:scale .1s ease-in,opacity .1s;background-color:transparent;border:none;background-size:100% 100%;background-repeat:no-repeat;cursor:inherit;background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTEiIGhlaWdodD0iMTMiIHZpZXdCb3g9IjAgMCAxMSAxMyIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTAgMS4wMDE0VjExLjM2MTRDMCAxMi4xNTE0IDAuODcgMTIuNjMxNCAxLjU0IDEyLjIwMTRMOS42OCA3LjAyMTRDMTAuMyA2LjYzMTQgMTAuMyA1LjczMTQgOS42OCA1LjMzMTRMMS41NCAwLjE2MTQwNUMwLjg3IC0wLjI2ODU5NiAwIDAuMjExNDA1IDAgMS4wMDE0WiIgZmlsbD0id2hpdGUiLz4KPC9zdmc+Cg==)}.playing .play-button{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTIiIGhlaWdodD0iMTQiIHZpZXdCb3g9IjAgMCAxMiAxNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTIgMEMxLjQ2OTU3IDAgMC45NjA4NTkgMC4yMTA3MTQgMC41ODU3ODYgMC41ODU3ODZDMC4yMTA3MTQgMC45NjA4NTkgMCAxLjQ2OTU3IDAgMlYxMkMwIDEyLjUzMDQgMC4yMTA3MTQgMTMuMDM5MSAwLjU4NTc4NiAxMy40MTQyQzAuOTYwODU5IDEzLjc4OTMgMS40Njk1NyAxNCAyIDE0QzIuNTMwNDMgMTQgMy4wMzkxNCAxMy43ODkzIDMuNDE0MjEgMTMuNDE0MkMzLjc4OTI5IDEzLjAzOTEgNCAxMi41MzA0IDQgMTJWMkM0IDEuNDY5NTcgMy43ODkyOSAwLjk2MDg1OSAzLjQxNDIxIDAuNTg1Nzg2QzMuMDM5MTQgMC4yMTA3MTQgMi41MzA0MyAwIDIgMFpNMTAgMEM5LjQ2OTU3IDAgOC45NjA4NiAwLjIxMDcxNCA4LjU4NTc5IDAuNTg1Nzg2QzguMjEwNzEgMC45NjA4NTkgOCAxLjQ2OTU3IDggMlYxMkM4IDEyLjUzMDQgOC4yMTA3MSAxMy4wMzkxIDguNTg1NzkgMTMuNDE0MkM4Ljk2MDg2IDEzLjc4OTMgOS40Njk1NyAxNCAxMCAxNEMxMC41MzA0IDE0IDExLjAzOTEgMTMuNzg5MyAxMS40MTQyIDEzLjQxNDJDMTEuNzg5MyAxMy4wMzkxIDEyIDEyLjUzMDQgMTIgMTJWMkMxMiAxLjQ2OTU3IDExLjc4OTMgMC45NjA4NTkgMTEuNDE0MiAwLjU4NTc4NkMxMS4wMzkxIDAuMjEwNzE0IDEwLjUzMDQgMCAxMCAwWiIgZmlsbD0id2hpdGUiLz4KPC9zdmc+Cg==)}.auto .play-button{display:none}.current-time{position:absolute;left:44px;bottom:25px;color:#fff;font-family:Arial,sans-serif;font-size:14px;line-height:14px}.canvas{width:100%;display:block;opacity:0;transition:opacity .1s}.canvas.state-ready{opacity:1}.message{font-family:JetBrains Mono,sans-serif;text-align:center;font-size:20px;padding:8px 16px;margin:16px;border-radius:4px;color:#fff9;background-color:#000000de}.loader{width:50%;max-width:96px;display:none;rotate:-90deg;animation:stroke 2s cubic-bezier(.5,0,.5,1) infinite,rotate 2s linear infinite}@keyframes stroke{0%{stroke-dasharray:5.6548667765px 50.8938009883px;stroke-dashoffset:2.8274333882px}50%{stroke-dasharray:50.8938009883px 5.6548667765px;stroke-dashoffset:-2.8274333882px}to{stroke-dasharray:5.6548667765px 50.8938009883px;stroke-dashoffset:-53.7212343766px}}@keyframes rotate{0%{rotate:-110deg}to{rotate:250deg}}
6
+ `, k = `<div class="overlay" part="overlay">
7
+ <div class="controls">
8
+ <button
9
+ part="play-button"
10
+ title="Play / Pause"
11
+ class="button play-button ready"
12
+ tabindex="0"
13
+ ></button>
14
+ <!-- New button to the right -->
15
+ <span class="current-time" part="current-time">0:00 / 0:00</span>
16
+ <div class="timeline-container">
17
+ <input
18
+ type="range"
19
+ class="timeline"
20
+ value="0"
21
+ min="0"
22
+ max="100"
23
+ step="1"
24
+ />
25
+ </div>
26
+ </div>
17
27
  <div part="message" class="message error">
18
28
  An error occurred while loading the animation.
19
29
  </div>
@@ -24,224 +34,190 @@ const f = `.initial{display:none}.state-initial .initial{display:block}.loading{
24
34
  stroke="#ffffff"
25
35
  stroke-width="2"
26
36
  fill="transparent"
27
- >
28
- <circle cx="12" cy="12" r="9" />
29
- </svg>
37
+ ></svg>
30
38
  </div>
31
- `,
32
- M = `<style>${f}</style>${I}`,
33
- c = 'revideo-player';
34
- class w extends HTMLElement {
39
+ `, f = `<style>${v}</style>${k}`, d = "revideo-player";
40
+ class x extends HTMLElement {
35
41
  constructor() {
36
42
  super();
37
- e(this, 'root');
38
- e(this, 'canvas');
39
- e(this, 'overlay');
40
- e(this, 'button');
41
- e(this, 'state', 'initial');
42
- e(this, 'project', null);
43
- e(this, 'player', null);
44
- e(this, 'defaultSettings');
45
- e(this, 'abortController', null);
46
- e(this, 'mouseMoveId', null);
47
- e(this, 'finished', !1);
48
- e(this, 'playing', !1);
49
- e(this, 'connected', !1);
50
- e(this, 'stage', new v());
51
- e(this, 'handleMouseMove', () => {
52
- this.mouseMoveId && clearTimeout(this.mouseMoveId),
53
- this.hover && !this.playing && this.setPlaying(!0),
54
- (this.mouseMoveId = window.setTimeout(() => {
55
- (this.mouseMoveId = null), this.updateClass();
56
- }, 2e3)),
57
- this.updateClass();
43
+ e(this, "root");
44
+ e(this, "canvas");
45
+ e(this, "overlay");
46
+ e(this, "button");
47
+ e(this, "state", "initial");
48
+ e(this, "project", null);
49
+ e(this, "player", null);
50
+ e(this, "defaultSettings");
51
+ e(this, "abortController", null);
52
+ e(this, "mouseMoveId", null);
53
+ e(this, "finished", !1);
54
+ e(this, "playing", !1);
55
+ e(this, "connected", !1);
56
+ e(this, "stage", new M());
57
+ e(this, "timeline");
58
+ e(this, "handleTimelineChange", (t) => {
59
+ var n, o;
60
+ const a = t.target, i = parseFloat(a.value);
61
+ ((n = this.player) == null ? void 0 : n.playback.duration) && ((o = this.player) == null || o.requestSeek(i));
62
+ });
63
+ e(this, "handleMouseMove", () => {
64
+ this.mouseMoveId && clearTimeout(this.mouseMoveId), this.hover && !this.playing && this.setPlaying(!0), this.mouseMoveId = window.setTimeout(() => {
65
+ this.mouseMoveId = null, this.updateClass();
66
+ }, 2e3), this.updateClass();
58
67
  });
59
- e(this, 'handleMouseLeave', () => {
60
- this.hover && this.setPlaying(!1),
61
- this.mouseMoveId &&
62
- (clearTimeout(this.mouseMoveId),
63
- (this.mouseMoveId = null),
64
- this.updateClass());
68
+ e(this, "handleMouseLeave", () => {
69
+ this.hover && this.setPlaying(!1), this.mouseMoveId && (clearTimeout(this.mouseMoveId), this.mouseMoveId = null, this.updateClass());
65
70
  });
66
- e(this, 'handleMouseDown', t => {
67
- t.preventDefault();
71
+ e(this, "handleMouseDown", (t) => {
72
+ t.target.closest(".timeline") || t.preventDefault();
68
73
  });
69
- e(this, 'handleClick', () => {
70
- this.auto ||
71
- (this.handleMouseMove(),
72
- this.setPlaying(!this.playing),
73
- this.button.animate(
74
- [
75
- {scale: '0.9'},
76
- {
77
- scale: '1',
78
- easing: 'ease-out',
79
- },
80
- ],
81
- {duration: 200},
82
- ));
74
+ e(this, "handleClick", (t) => {
75
+ t.target.closest(".timeline") || this.auto || (this.handleMouseMove(), this.setPlaying(!this.playing), this.button.animate(
76
+ [
77
+ { scale: "0.9" },
78
+ {
79
+ scale: "1",
80
+ easing: "ease-out"
81
+ }
82
+ ],
83
+ { duration: 200 }
84
+ ));
83
85
  });
84
- e(this, 'render', async () => {
85
- this.player &&
86
- (await this.stage.render(
86
+ e(this, "render", async () => {
87
+ var t;
88
+ if (this.player) {
89
+ await this.stage.render(
87
90
  this.player.playback.currentScene,
88
- this.player.playback.previousScene,
89
- ));
91
+ this.player.playback.previousScene
92
+ ), this.timeline.setAttribute("min", "0"), this.timeline.setAttribute("step", "1"), this.timeline.setAttribute(
93
+ "max",
94
+ (t = this.player) == null ? void 0 : t.playback.duration.toString()
95
+ );
96
+ const a = this.player.status.time, i = this.player.status.framesToSeconds(
97
+ this.player.playback.duration
98
+ );
99
+ if (i) {
100
+ const s = this.player.status.secondsToFrames(a);
101
+ this.timeline.value = s.toString();
102
+ const n = `linear-gradient(to right, rgb(180, 180, 180) 0%, rgb(180, 180, 180) ${100 * s / this.player.status.secondsToFrames(i)}%, white ${100 * s / this.player.status.secondsToFrames(i)}%, white 100%)`;
103
+ this.timeline.style.background = n, this.timeline.style.setProperty("--webkit-track", n), this.timeline.style.setProperty("--moz-track", n), this.timeline.style.setProperty("--ms-track", n);
104
+ const o = this.formatTime(a), c = this.formatTime(i), l = this.root.querySelector(".current-time");
105
+ l && (l.textContent = `${o} / ${c}`);
106
+ }
107
+ }
90
108
  });
91
- (this.root = this.attachShadow({mode: 'open'})),
92
- (this.root.innerHTML = M),
93
- (this.overlay = this.root.querySelector('.overlay')),
94
- (this.button = this.root.querySelector('.button')),
95
- (this.canvas = this.stage.finalBuffer),
96
- this.canvas.classList.add('canvas'),
97
- this.root.prepend(this.canvas),
98
- this.overlay.addEventListener('click', this.handleClick),
99
- this.overlay.addEventListener('mousemove', this.handleMouseMove),
100
- this.overlay.addEventListener('mouseleave', this.handleMouseLeave),
101
- this.button.addEventListener('mousedown', this.handleMouseDown),
102
- this.setState(
103
- 'initial',
104
- /* Initial */
105
- );
109
+ this.root = this.attachShadow({ mode: "open" }), this.root.innerHTML = f, this.overlay = this.root.querySelector(".overlay"), this.button = this.root.querySelector(".button"), this.canvas = this.stage.finalBuffer, this.canvas.classList.add("canvas"), this.root.prepend(this.canvas), this.timeline = this.root.querySelector(".timeline"), this.timeline.addEventListener("input", this.handleTimelineChange), this.timeline.addEventListener("change", this.handleTimelineChange), this.button.addEventListener("click", this.handleClick), this.button.addEventListener("mousedown", this.handleMouseDown), this.overlay.addEventListener("click", this.handleClick), this.overlay.addEventListener("mousemove", this.handleMouseMove), this.overlay.addEventListener("mouseleave", this.handleMouseLeave), this.overlay.addEventListener("mousedown", this.handleMouseDown), this.setState(
110
+ "initial"
111
+ /* Initial */
112
+ );
106
113
  }
107
114
  static get observedAttributes() {
108
- return ['src', 'quality', 'width', 'height', 'auto', 'variables'];
115
+ return ["src", "quality", "width", "height", "auto", "variables"];
109
116
  }
110
117
  get auto() {
111
- return !!this.getAttribute('auto');
118
+ return !!this.getAttribute("auto");
112
119
  }
113
120
  get hover() {
114
- return this.getAttribute('auto') === 'hover';
121
+ return this.getAttribute("auto") === "hover";
115
122
  }
116
123
  get quality() {
117
- const t = this.getAttribute('quality');
124
+ const t = this.getAttribute("quality");
118
125
  return t ? parseFloat(t) : this.defaultSettings.resolutionScale;
119
126
  }
120
127
  get width() {
121
- const t = this.getAttribute('width');
128
+ const t = this.getAttribute("width");
122
129
  return t ? parseFloat(t) : this.defaultSettings.size.width;
123
130
  }
124
131
  get height() {
125
- const t = this.getAttribute('height');
132
+ const t = this.getAttribute("height");
126
133
  return t ? parseFloat(t) : this.defaultSettings.size.height;
127
134
  }
128
135
  get variables() {
129
136
  try {
130
- const t = this.getAttribute('variables');
137
+ const t = this.getAttribute("variables");
131
138
  return t ? JSON.parse(t) : {};
132
139
  } catch {
133
- return (
134
- this.project.logger.warn('Project variables could not be parsed.'), {}
135
- );
140
+ return this.project.logger.warn("Project variables could not be parsed."), {};
136
141
  }
137
142
  }
138
143
  setState(t) {
139
- (this.state = t), this.setPlaying(this.playing);
144
+ this.state = t, this.setPlaying(this.playing);
140
145
  }
141
146
  setPlaying(t) {
142
147
  var a, i;
143
- this.state === 'ready' && (t || (this.auto && !this.hover))
144
- ? ((a = this.player) == null || a.togglePlayback(!0), (this.playing = !0))
145
- : ((i = this.player) == null || i.togglePlayback(!1),
146
- (this.playing = !1)),
147
- this.updateClass();
148
+ this.state === "ready" && (t || this.auto && !this.hover) ? ((a = this.player) == null || a.togglePlayback(!0), this.playing = !0) : ((i = this.player) == null || i.togglePlayback(!1), this.playing = !1), this.updateClass();
148
149
  }
149
150
  updateClass() {
150
- (this.overlay.className = `overlay state-${this.state}`),
151
- (this.canvas.className = `canvas state-${this.state}`),
152
- this.overlay.classList.toggle('playing', this.playing),
153
- this.overlay.classList.toggle('auto', this.auto),
154
- this.overlay.classList.toggle('hover', this.mouseMoveId !== null),
155
- this.player,
156
- this.connected &&
157
- (this.mouseMoveId !== null || !this.playing
158
- ? (this.dataset.overlay = '')
159
- : delete this.dataset.overlay);
151
+ this.overlay.className = `overlay state-${this.state}`, this.canvas.className = `canvas state-${this.state}`, this.overlay.classList.toggle("playing", this.playing), this.overlay.classList.toggle("auto", this.auto), this.overlay.classList.toggle("hover", this.mouseMoveId !== null), this.connected && (this.mouseMoveId !== null || !this.playing ? this.dataset.overlay = "" : delete this.dataset.overlay);
160
152
  }
161
153
  async updateSource(t) {
162
- var r, l, h, d;
154
+ var s, n, o, c;
163
155
  this.setState(
164
- 'initial',
156
+ "initial"
165
157
  /* Initial */
166
- ),
167
- (r = this.abortController) == null || r.abort(),
168
- (this.abortController = new AbortController());
158
+ ), (s = this.abortController) == null || s.abort(), this.abortController = new AbortController();
169
159
  let a;
170
160
  try {
171
- const n = import(
172
- /* webpackIgnore: true */
173
- /* @vite-ignore */
174
- t
175
- ),
176
- y = new Promise(u => setTimeout(u, 200));
177
- await Promise.any([y, n]),
178
- this.setState(
179
- 'loading',
180
- /* Loading */
181
- ),
182
- (a = (await n).default);
183
- } catch (n) {
184
- console.error(n),
185
- this.setState(
186
- 'error',
187
- /* Error */
188
- );
161
+ const l = import(
162
+ /* webpackIgnore: true */
163
+ /* @vite-ignore */
164
+ t
165
+ ), u = new Promise((g) => setTimeout(g, 200));
166
+ await Promise.any([u, l]), this.setState(
167
+ "loading"
168
+ /* Loading */
169
+ ), a = (await l).default;
170
+ } catch (l) {
171
+ console.error(l), this.setState(
172
+ "error"
173
+ /* Error */
174
+ );
189
175
  return;
190
176
  }
191
177
  this.defaultSettings = a.meta.getFullRenderingSettings();
192
- const i = new b(a);
193
- i.setVariables(this.variables),
194
- (this.finished = !1),
195
- (l = this.player) == null || l.onRender.unsubscribe(this.render),
196
- (h = this.player) == null || h.togglePlayback(!1),
197
- (d = this.player) == null || d.deactivate(),
198
- (this.project = a),
199
- (this.player = i),
200
- this.updateSettings(),
201
- this.player.onRender.subscribe(this.render),
202
- this.player.togglePlayback(this.playing),
203
- this.setState(
204
- 'ready',
205
- /* Ready */
206
- );
178
+ const i = new m(a);
179
+ i.setVariables(this.variables), this.finished = !1, (n = this.player) == null || n.onRender.unsubscribe(this.render), (o = this.player) == null || o.togglePlayback(!1), (c = this.player) == null || c.deactivate(), this.project = a, this.player = i, this.updateSettings(), this.player.onRender.subscribe(this.render), this.player.togglePlayback(this.playing), this.setState(
180
+ "ready"
181
+ /* Ready */
182
+ );
207
183
  }
208
184
  attributeChangedCallback(t, a, i) {
209
- var r;
185
+ var s;
210
186
  switch (t) {
211
- case 'auto':
187
+ case "auto":
212
188
  this.setPlaying(this.playing);
213
189
  break;
214
- case 'src':
190
+ case "src":
215
191
  this.updateSource(i);
216
192
  break;
217
- case 'quality':
218
- case 'width':
219
- case 'height':
193
+ case "quality":
194
+ case "width":
195
+ case "height":
220
196
  this.updateSettings();
221
197
  break;
222
- case 'variables':
223
- (r = this.player) == null || r.setVariables(this.variables);
198
+ case "variables":
199
+ (s = this.player) == null || s.setVariables(this.variables), this.player.requestSeek(this.player.playback.frame);
224
200
  }
225
201
  }
226
202
  disconnectedCallback() {
227
203
  var t, a;
228
- (this.connected = !1),
229
- (t = this.player) == null || t.deactivate(),
230
- (a = this.player) == null || a.onRender.unsubscribe(this.render);
204
+ this.connected = !1, (t = this.player) == null || t.deactivate(), (a = this.player) == null || a.onRender.unsubscribe(this.render);
231
205
  }
232
206
  connectedCallback() {
233
207
  var t, a;
234
- (this.connected = !0),
235
- (t = this.player) == null || t.activate(),
236
- (a = this.player) == null || a.onRender.subscribe(this.render);
208
+ this.connected = !0, (t = this.player) == null || t.activate(), (a = this.player) == null || a.onRender.subscribe(this.render);
237
209
  }
238
210
  updateSettings() {
239
211
  const t = {
240
212
  ...this.defaultSettings,
241
- size: new m(this.width, this.height),
242
- resolutionScale: this.quality,
213
+ size: new b(this.width, this.height),
214
+ resolutionScale: this.quality
243
215
  };
244
216
  this.stage.configure(t), this.player.configure(t);
245
217
  }
218
+ formatTime(t) {
219
+ const a = Math.floor(t / 60), i = Math.floor(t % 60), s = a.toString().padStart(2, "0"), n = i.toString().padStart(2, "0");
220
+ return `${s}:${n}`;
221
+ }
246
222
  }
247
- customElements.get(c) || customElements.define(c, w);
223
+ customElements.get(d) || customElements.define(d, x);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@revideo/player",
3
- "version": "0.2.1-alpha.891+b6a0386",
3
+ "version": "0.2.1-alpha.892+474c60e",
4
4
  "description": "A custom element for displaying animations made with revideo",
5
5
  "main": "dist/main.js",
6
6
  "types": "types/main.d.ts",
@@ -26,5 +26,5 @@
26
26
  "sass": "^1.58.0",
27
27
  "terser": "^5.16.1"
28
28
  },
29
- "gitHead": "b6a03863cd5ee2f9bde38d1b199e8b7a03ab7bdc"
29
+ "gitHead": "474c60ece59ba496cfe5e9053449b30fa03ba4c0"
30
30
  }