@twick/player 0.14.0 → 0.14.3

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/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2022 motion-canvas
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2022 motion-canvas
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/main.js CHANGED
@@ -1,41 +1,41 @@
1
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);
2
+ var y = (h, n, t) => n in h ? p(h, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : h[n] = t;
3
+ var e = (h, n, t) => (y(h, typeof n != "symbol" ? n + "" : n, t), t);
4
4
  import { Stage as M, getFullPreviewSettings as m, Player as b, Vector2 as v } from "@twick/core";
5
5
  const k = `.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:linear-gradient(0deg,rgba(0,0,0,.3) 0%,rgba(0,0,0,0) 100%)}.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,PHN2ZyB3aWR0aD0iMTEiIGhlaWdodD0iMTMiIHZpZXdCb3g9IjAgMCAxMSAxMyIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTAgMS4wMDE0VjExLjM2MTRDMCAxMi4xNTE0IDAuODcgMTIuNjMxNCAxLjU0IDEyLjIwMTRMOS42OCA3LjAyMTRDMTAuMyA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MxMiAxLjQ2OTU3IDExLjc4OTMgMC45NjA4NTkgMTEuNDE0MiAwLjU4NTc4NkMxMS4wMzkxIDAuMjEwNzE0IDEwLjUzMDQgMCAxMCAwWiIgZmlsbD0id2hpdGUiLz4KPC9zdmc+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
- `, f = `<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>
27
- <div part="message" class="message error">
28
- An error occurred while loading the animation.
29
- </div>
30
- <svg
31
- part="loader"
32
- class="loader loading"
33
- viewBox="0 0 24 24"
34
- stroke="#ffffff"
35
- stroke-width="2"
36
- fill="transparent"
37
- ></svg>
38
- </div>
6
+ `, f = `<div class="overlay" part="overlay">\r
7
+ <div class="controls">\r
8
+ <button\r
9
+ part="play-button"\r
10
+ title="Play / Pause"\r
11
+ class="button play-button ready"\r
12
+ tabindex="0"\r
13
+ ></button>\r
14
+ <!-- New button to the right -->\r
15
+ <span class="current-time" part="current-time">0:00 / 0:00</span>\r
16
+ <div class="timeline-container">\r
17
+ <input\r
18
+ type="range"\r
19
+ class="timeline"\r
20
+ value="0"\r
21
+ min="0"\r
22
+ max="100"\r
23
+ step="1"\r
24
+ />\r
25
+ </div>\r
26
+ </div>\r
27
+ <div part="message" class="message error">\r
28
+ An error occurred while loading the animation.\r
29
+ </div>\r
30
+ <svg\r
31
+ part="loader"\r
32
+ class="loader loading"\r
33
+ viewBox="0 0 24 24"\r
34
+ stroke="#ffffff"\r
35
+ stroke-width="2"\r
36
+ fill="transparent"\r
37
+ ></svg>\r
38
+ </div>\r
39
39
  `, x = `<style>${k}</style>${f}`, d = "twick-player";
40
40
  class w extends HTMLElement {
41
41
  constructor() {
@@ -97,9 +97,9 @@ class w extends HTMLElement {
97
97
  this.player.playback.duration
98
98
  );
99
99
  if (i) {
100
- const n = this.player.status.secondsToFrames(a);
101
- this.timeline.value = n.toString();
102
- const s = `linear-gradient(to right, rgb(180, 180, 180) 0%, rgb(180, 180, 180) ${100 * n / this.player.status.secondsToFrames(i)}%, white ${100 * n / this.player.status.secondsToFrames(i)}%, white 100%)`;
100
+ const r = this.player.status.secondsToFrames(a);
101
+ this.timeline.value = r.toString();
102
+ const s = `linear-gradient(to right, rgb(180, 180, 180) 0%, rgb(180, 180, 180) ${100 * r / this.player.status.secondsToFrames(i)}%, white ${100 * r / this.player.status.secondsToFrames(i)}%, white 100%)`;
103
103
  this.timeline.style.background = s, this.timeline.style.setProperty("--webkit-track", s), this.timeline.style.setProperty("--moz-track", s), this.timeline.style.setProperty("--ms-track", s);
104
104
  const o = this.formatTime(a), c = this.formatTime(i), l = this.root.querySelector(".current-time");
105
105
  l && (l.textContent = `${o} / ${c}`);
@@ -151,11 +151,11 @@ class w extends HTMLElement {
151
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);
152
152
  }
153
153
  async updateSource(t) {
154
- var n, s, o, c;
154
+ var r, s, o, c;
155
155
  this.setState(
156
156
  "initial"
157
157
  /* Initial */
158
- ), (n = this.abortController) == null || n.abort(), this.abortController = new AbortController();
158
+ ), (r = this.abortController) == null || r.abort(), this.abortController = new AbortController();
159
159
  let a;
160
160
  try {
161
161
  const l = import(
@@ -182,7 +182,7 @@ class w extends HTMLElement {
182
182
  );
183
183
  }
184
184
  attributeChangedCallback(t, a, i) {
185
- var n, s;
185
+ var r, s;
186
186
  switch (t) {
187
187
  case "auto":
188
188
  this.setPlaying(this.playing);
@@ -196,7 +196,7 @@ class w extends HTMLElement {
196
196
  this.updateSettings();
197
197
  break;
198
198
  case "variables":
199
- (n = this.player) == null || n.setVariables(this.variables), (s = this.player) == null || s.requestSeek(this.player.playback.frame);
199
+ (r = this.player) == null || r.setVariables(this.variables), (s = this.player) == null || s.requestSeek(this.player.playback.frame);
200
200
  }
201
201
  }
202
202
  disconnectedCallback() {
@@ -216,8 +216,8 @@ class w extends HTMLElement {
216
216
  this.stage.configure(t), this.player.configure(t);
217
217
  }
218
218
  formatTime(t) {
219
- const a = Math.floor(t / 60), i = Math.floor(t % 60), n = a.toString().padStart(2, "0"), s = i.toString().padStart(2, "0");
220
- return `${n}:${s}`;
219
+ const a = Math.floor(t / 60), i = Math.floor(t % 60), r = a.toString().padStart(2, "0"), s = i.toString().padStart(2, "0");
220
+ return `${r}:${s}`;
221
221
  }
222
222
  }
223
223
  customElements.get(d) || customElements.define(d, w);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twick/player",
3
- "version": "0.14.0",
3
+ "version": "0.14.3",
4
4
  "description": "A custom element for displaying animations made with twick",
5
5
  "main": "dist/main.js",
6
6
  "types": "types/main.d.ts",
@@ -22,9 +22,9 @@
22
22
  "types"
23
23
  ],
24
24
  "devDependencies": {
25
- "@twick/core": "^0.14.0",
25
+ "@twick/core": "0.14.3",
26
26
  "sass": "^1.58.0",
27
27
  "terser": "^5.16.1"
28
28
  },
29
- "gitHead": "54bd58bf80ea6afec48c27c061e6d455c1e0a885"
29
+ "gitHead": "71de575b466ee3c95d6d2c9c19135d7d80369948"
30
30
  }
package/types/main.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- export interface MotionCanvasPlayerProps {
2
- src: string;
3
- width?: number;
4
- height?: number;
5
- auto?: boolean;
6
- quality?: number;
7
- variables?: string;
8
- }
1
+ export interface MotionCanvasPlayerProps {
2
+ src: string;
3
+ width?: number;
4
+ height?: number;
5
+ auto?: boolean;
6
+ quality?: number;
7
+ variables?: string;
8
+ }