@instructure/studio-player 1.2.3 → 1.3.0

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.
@@ -1,56 +1,57 @@
1
- var G = Object.defineProperty;
2
- var z = (a) => {
1
+ var Q = Object.defineProperty;
2
+ var B = (a) => {
3
3
  throw TypeError(a);
4
4
  };
5
- var H = (a, o, e) => o in a ? G(a, o, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[o] = e;
6
- var w = (a, o, e) => H(a, typeof o != "symbol" ? o + "" : o, e), E = (a, o, e) => o.has(a) || z("Cannot " + e);
7
- var s = (a, o, e) => (E(a, o, "read from private field"), e ? e.call(a) : o.get(a)), p = (a, o, e) => o.has(a) ? z("Cannot add the same private member more than once") : o instanceof WeakSet ? o.add(a) : o.set(a, e), l = (a, o, e, t) => (E(a, o, "write to private field"), t ? t.call(a, e) : o.set(a, e), e), r = (a, o, e) => (E(a, o, "access private method"), e);
8
- import { E as Q, d as W, x as X, p as Z, y as ee, a as te, J as se, z as ie, Y as k, K as ae, M as _, T as j, O as ne } from "./vidstack-VlpmInuO.js";
9
- const oe = /(?:youtu\.be|youtube|youtube\.com|youtube-nocookie\.com)(?:\/shorts)?\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=|)((?:\w|-){11})/, C = /* @__PURE__ */ new Map(), R = /* @__PURE__ */ new Map();
10
- function B(a) {
5
+ var W = (a, o, e) => o in a ? Q(a, o, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[o] = e;
6
+ var w = (a, o, e) => W(a, typeof o != "symbol" ? o + "" : o, e), E = (a, o, e) => o.has(a) || B("Cannot " + e);
7
+ var s = (a, o, e) => (E(a, o, "read from private field"), e ? e.call(a) : o.get(a)), p = (a, o, e) => o.has(a) ? B("Cannot add the same private member more than once") : o instanceof WeakSet ? o.add(a) : o.set(a, e), l = (a, o, e, t) => (E(a, o, "write to private field"), t ? t.call(a, e) : o.set(a, e), e), r = (a, o, e) => (E(a, o, "access private method"), e);
8
+ import { E as X, d as Z, x as ee, p as te, y as se, a as ie, J as ae, z as ne, Y as k, K as oe, M as _, T as j, O as re } from "./vidstack-B8iikcPv.js";
9
+ const ue = /(?:youtu\.be|youtube|youtube\.com|youtube-nocookie\.com)(?:\/shorts)?\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=|)((?:\w|-){11})/, Y = /* @__PURE__ */ new Map(), V = /* @__PURE__ */ new Map();
10
+ function F(a) {
11
11
  var o;
12
- return (o = a.match(oe)) == null ? void 0 : o[1];
12
+ return (o = a.match(ue)) == null ? void 0 : o[1];
13
13
  }
14
- async function re(a, o) {
15
- if (C.has(a)) return C.get(a);
16
- if (R.has(a)) return R.get(a);
14
+ async function de(a, o) {
15
+ if (Y.has(a)) return Y.get(a);
16
+ if (V.has(a)) return V.get(a);
17
17
  const e = new Promise(async (t) => {
18
18
  const u = ["maxresdefault", "sddefault", "hqdefault"];
19
- for (const h of u)
20
- for (const d of [!0, !1]) {
21
- const c = ue(a, h, d);
19
+ for (const d of u)
20
+ for (const h of [!0, !1]) {
21
+ const c = he(a, d, h);
22
22
  if ((await fetch(c, {
23
23
  mode: "no-cors",
24
24
  signal: o.signal
25
25
  })).status < 400) {
26
- C.set(a, c), t(c);
26
+ Y.set(a, c), t(c);
27
27
  return;
28
28
  }
29
29
  }
30
- }).catch(() => "").finally(() => R.delete(a));
31
- return R.set(a, e), e;
30
+ }).catch(() => "").finally(() => V.delete(a));
31
+ return V.set(a, e), e;
32
32
  }
33
- function ue(a, o, e) {
33
+ function he(a, o, e) {
34
34
  return `https://i.ytimg.com/${e ? "vi_webp" : "vi"}/${a}/${o}.${e ? "webp" : "jpg"}`;
35
35
  }
36
- const ye = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
36
+ const me = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
37
37
  __proto__: null,
38
- findYouTubePoster: re,
39
- resolveYouTubeVideoId: B
38
+ findYouTubePoster: de,
39
+ resolveYouTubeVideoId: F
40
40
  }, Symbol.toStringTag, { value: "Module" }));
41
- var n, g, P, S, v, b, y, M, i, he, ce, F, U, m, L, I, J, Y, V, N, q, D, $, K;
42
- class de extends Q {
41
+ var n, b, P, S, O, T, g, y, R, i, le, pe, U, L, m, I, J, N, D, C, q, K, x, M, A;
42
+ class ce extends X {
43
43
  constructor(e, t) {
44
44
  super(e);
45
45
  p(this, i);
46
46
  w(this, "$$PROVIDER_TYPE", "YOUTUBE");
47
- w(this, "scope", W());
47
+ w(this, "scope", Z());
48
48
  p(this, n);
49
- p(this, g, X(""));
49
+ p(this, b, ee(""));
50
50
  p(this, P, -1);
51
51
  p(this, S, null);
52
- p(this, v, -1);
53
- p(this, b, !1);
52
+ p(this, O, null);
53
+ p(this, T, -1);
54
+ p(this, g, !1);
54
55
  p(this, y, /* @__PURE__ */ new Map());
55
56
  /**
56
57
  * Sets the player's interface language. The parameter value is an ISO 639-1 two-letter
@@ -84,7 +85,7 @@ class de extends Q {
84
85
  *
85
86
  * @defaultValue `undefined`
86
87
  */
87
- p(this, M);
88
+ p(this, R);
88
89
  l(this, n, t);
89
90
  }
90
91
  /**
@@ -94,7 +95,7 @@ class de extends Q {
94
95
  * @defaultValue `undefined`
95
96
  */
96
97
  set encryptedPayload(e) {
97
- l(this, M, e);
98
+ l(this, R, e);
98
99
  }
99
100
  get currentSrc() {
100
101
  return s(this, S);
@@ -103,16 +104,16 @@ class de extends Q {
103
104
  return "youtube";
104
105
  }
105
106
  get videoId() {
106
- return s(this, g).call(this);
107
+ return s(this, b).call(this);
107
108
  }
108
109
  preconnect() {
109
- Z(this.getOrigin());
110
+ te(this.getOrigin());
110
111
  }
111
112
  setup() {
112
- super.setup(), ee(r(this, i, F).bind(this)), s(this, n).notify("provider-setup", this);
113
+ super.setup(), se(r(this, i, U).bind(this)), s(this, n).notify("provider-setup", this);
113
114
  }
114
115
  destroy() {
115
- r(this, i, D).call(this);
116
+ r(this, i, x).call(this);
116
117
  const e = "provider destroyed";
117
118
  for (const t of s(this, y).values())
118
119
  for (const { reject: u } of t) u(e);
@@ -137,12 +138,12 @@ class de extends Q {
137
138
  r(this, i, m).call(this, "setPlaybackRate", e);
138
139
  }
139
140
  async loadSource(e) {
140
- if (!te(e.src)) {
141
- l(this, S, null), s(this, g).set("");
141
+ if (!ie(e.src)) {
142
+ l(this, S, null), s(this, b).set("");
142
143
  return;
143
144
  }
144
- const t = B(e.src);
145
- s(this, g).set(t ?? ""), l(this, S, e);
145
+ const t = F(e.src);
146
+ s(this, b).set(t ?? ""), l(this, S, e);
146
147
  }
147
148
  getOrigin() {
148
149
  switch (!0) {
@@ -155,145 +156,144 @@ class de extends Q {
155
156
  }
156
157
  }
157
158
  buildParams() {
158
- const { keyDisabled: e } = s(this, n).$props, { muted: t, playsInline: u, nativeControls: h } = s(this, n).$state, d = h();
159
+ const { keyDisabled: e } = s(this, n).$props, { muted: t, playsInline: u, nativeControls: d } = s(this, n).$state, h = d();
159
160
  return {
160
161
  rel: 0,
161
162
  autoplay: 0,
162
- cc_lang_pref: this.language,
163
- cc_load_policy: d ? 1 : void 0,
164
163
  color: this.color,
165
- controls: d ? 1 : 0,
166
- disablekb: !d || e() ? 1 : 0,
164
+ cc_load_policy: 1,
165
+ controls: h ? 1 : 0,
166
+ disablekb: !h || e() ? 1 : 0,
167
167
  enablejsapi: 1,
168
168
  fs: 1,
169
169
  hl: this.language,
170
- iv_load_policy: d ? 1 : 3,
170
+ iv_load_policy: h ? 1 : 3,
171
171
  mute: t() ? 1 : 0,
172
172
  playsinline: u() ? 1 : 0,
173
- videoId: s(this, g).call(this),
174
- embed_config: r(this, i, U).call(this)
173
+ videoId: s(this, b).call(this),
174
+ embed_config: r(this, i, L).call(this)
175
175
  };
176
176
  }
177
177
  onLoad() {
178
178
  window.setTimeout(() => this.postMessage({ event: "listening" }), 100);
179
179
  }
180
180
  onMessage({ info: e }, t) {
181
- var c;
181
+ var c, $;
182
182
  if (!e) return;
183
- const { title: u, intrinsicDuration: h, playbackRate: d } = s(this, n).$state;
184
- if (ae(e.videoData) && e.videoData.title !== u() && s(this, n).notify("title-change", e.videoData.title, t), _(e.duration) && e.duration !== h()) {
183
+ const { title: u, intrinsicDuration: d, playbackRate: h } = s(this, n).$state;
184
+ if (oe(e.videoData) && e.videoData.title !== u() && s(this, n).notify("title-change", e.videoData.title, t), (c = e.namespaces) != null && c.includes("captions") && e.captions && s(this, O) === null && (l(this, O, e.captions.tracklist), s(this, n).notify("loaded-metadata")), _(e.duration) && e.duration !== d()) {
185
185
  if (_(e.videoLoadedFraction)) {
186
- const f = ((c = e.progressState) == null ? void 0 : c.loaded) ?? e.videoLoadedFraction * e.duration, T = new j(0, e.duration);
187
- r(this, i, Y).call(this, f, T, t);
186
+ const f = (($ = e.progressState) == null ? void 0 : $.loaded) ?? e.videoLoadedFraction * e.duration, v = new j(0, e.duration);
187
+ r(this, i, D).call(this, f, v, t);
188
188
  }
189
189
  s(this, n).notify("duration-change", e.duration, t);
190
190
  }
191
- if (_(e.playbackRate) && e.playbackRate !== d() && s(this, n).notify("rate-change", e.playbackRate, t), e.progressState) {
192
- const { current: f, seekableStart: T, seekableEnd: O, loaded: A, duration: x } = e.progressState;
193
- r(this, i, J).call(this, f, t), r(this, i, Y).call(this, A, new j(T, O), t), x !== h() && s(this, n).notify("duration-change", x, t);
191
+ if (_(e.playbackRate) && e.playbackRate !== h() && s(this, n).notify("rate-change", e.playbackRate, t), e.progressState) {
192
+ const { current: f, seekableStart: v, seekableEnd: G, loaded: H, duration: z } = e.progressState;
193
+ r(this, i, N).call(this, f, t), r(this, i, D).call(this, H, new j(v, G), t), z !== d() && s(this, n).notify("duration-change", z, t);
194
194
  }
195
- if (_(e.volume) && ne(e.muted) && !s(this, b)) {
195
+ if (_(e.volume) && re(e.muted) && !s(this, g)) {
196
196
  const f = {
197
197
  muted: e.muted,
198
198
  volume: e.volume / 100
199
199
  };
200
200
  s(this, n).notify("volume-change", f, t);
201
201
  }
202
- _(e.playerState) && e.playerState !== s(this, P) && r(this, i, q).call(this, e.playerState, t);
202
+ _(e.playerState) && e.playerState !== s(this, P) && r(this, i, K).call(this, e.playerState, t);
203
203
  }
204
204
  }
205
- n = new WeakMap(), g = new WeakMap(), P = new WeakMap(), S = new WeakMap(), v = new WeakMap(), b = new WeakMap(), y = new WeakMap(), M = new WeakMap(), i = new WeakSet(), he = function(e) {
205
+ n = new WeakMap(), b = new WeakMap(), P = new WeakMap(), S = new WeakMap(), O = new WeakMap(), T = new WeakMap(), g = new WeakMap(), y = new WeakMap(), R = new WeakMap(), i = new WeakSet(), le = function(e) {
206
206
  var t;
207
- (t = r(this, i, $).call(this, "playVideo")) == null || t.reject(e);
208
- }, ce = function(e) {
207
+ (t = r(this, i, M).call(this, "playVideo")) == null || t.reject(e);
208
+ }, pe = function(e) {
209
209
  var t;
210
- (t = r(this, i, $).call(this, "pauseVideo")) == null || t.reject(e);
211
- }, F = function() {
212
- r(this, i, D).call(this);
213
- const e = s(this, g).call(this);
210
+ (t = r(this, i, M).call(this, "pauseVideo")) == null || t.reject(e);
211
+ }, U = function() {
212
+ r(this, i, x).call(this);
213
+ const e = s(this, b).call(this);
214
214
  if (!e) {
215
215
  this.src.set("");
216
216
  return;
217
217
  }
218
218
  this.src.set(`${this.getOrigin()}/embed/${e}`), s(this, n).notify("load-start");
219
- }, U = function() {
220
- const e = s(this, M);
221
- if (!se(e))
222
- return JSON.stringify({ enc: e });
219
+ }, L = function() {
220
+ const e = s(this, R);
221
+ if (!ae(e))
222
+ return JSON.stringify({ enc: e, hideTitle: !0 });
223
223
  }, m = function(e, t) {
224
- let u = ie(), h = s(this, y).get(e);
225
- return h || s(this, y).set(e, h = []), h.push(u), this.postMessage({
224
+ let u = ne(), d = s(this, y).get(e);
225
+ return d || s(this, y).set(e, d = []), d.push(u), this.postMessage({
226
226
  event: "command",
227
227
  func: e,
228
228
  args: t ? [t] : void 0
229
229
  }), u.promise;
230
- }, L = function(e) {
231
- s(this, n).notify("loaded-metadata"), s(this, n).notify("loaded-data"), s(this, n).delegate.ready(void 0, e);
232
230
  }, I = function(e) {
231
+ s(this, n).notify("loaded-data"), s(this, n).delegate.ready(void 0, e);
232
+ }, J = function(e) {
233
233
  var t;
234
- (t = r(this, i, $).call(this, "pauseVideo")) == null || t.resolve(), s(this, n).notify("pause", void 0, e);
235
- }, J = function(e, t) {
236
- const { duration: u, realCurrentTime: h } = s(this, n).$state, d = s(this, P) === k.Ended, c = d ? u() : e;
237
- s(this, n).notify("time-change", c, t), !d && Math.abs(c - h()) > 1 && s(this, n).notify("seeking", c, t);
238
- }, Y = function(e, t, u) {
239
- const h = {
234
+ (t = r(this, i, M).call(this, "pauseVideo")) == null || t.resolve(), s(this, n).notify("pause", void 0, e);
235
+ }, N = function(e, t) {
236
+ const { duration: u, realCurrentTime: d } = s(this, n).$state, h = s(this, P) === k.Ended, c = h ? u() : e;
237
+ s(this, n).notify("time-change", c, t), !h && Math.abs(c - d()) > 1 && s(this, n).notify("seeking", c, t);
238
+ }, D = function(e, t, u) {
239
+ const d = {
240
240
  buffered: new j(0, e),
241
241
  seekable: t
242
242
  };
243
- s(this, n).notify("progress", h, u);
244
- const { seeking: d, realCurrentTime: c } = s(this, n).$state;
245
- d() && e > c() && r(this, i, V).call(this, u);
246
- }, V = function(e) {
243
+ s(this, n).notify("progress", d, u);
244
+ const { seeking: h, realCurrentTime: c } = s(this, n).$state;
245
+ h() && e > c() && r(this, i, C).call(this, u);
246
+ }, C = function(e) {
247
247
  const { paused: t, realCurrentTime: u } = s(this, n).$state;
248
- window.clearTimeout(s(this, v)), l(this, v, window.setTimeout(
248
+ window.clearTimeout(s(this, T)), l(this, T, window.setTimeout(
249
249
  () => {
250
- s(this, n).notify("seeked", u(), e), l(this, v, -1);
250
+ s(this, n).notify("seeked", u(), e), l(this, T, -1);
251
251
  },
252
252
  t() ? 100 : 0
253
253
  ));
254
- }, N = function(e) {
254
+ }, q = function(e) {
255
255
  const { seeking: t } = s(this, n).$state;
256
- t() && r(this, i, V).call(this, e), s(this, n).notify("pause", void 0, e), s(this, n).notify("end", void 0, e);
257
- }, q = function(e, t) {
258
- var O;
259
- const { paused: u, seeking: h } = s(this, n).$state, d = e === k.Playing, c = e === k.Buffering, f = r(this, i, K).call(this, "playVideo"), T = u() && (c || d);
260
- if (c && s(this, n).notify("waiting", void 0, t), h() && d && r(this, i, V).call(this, t), s(this, b) && d) {
261
- this.pause(), l(this, b, !1), this.setMuted(s(this, n).$state.muted());
256
+ t() && r(this, i, C).call(this, e), s(this, n).notify("pause", void 0, e), s(this, n).notify("end", void 0, e);
257
+ }, K = function(e, t) {
258
+ var v;
259
+ const { paused: u, seeking: d } = s(this, n).$state, h = e === k.Playing, c = e === k.Buffering, $ = r(this, i, A).call(this, "playVideo"), f = u() && (c || h);
260
+ if (c && s(this, n).notify("waiting", void 0, t), d() && h && r(this, i, C).call(this, t), s(this, g) && h) {
261
+ this.pause(), l(this, g, !1), this.setMuted(s(this, n).$state.muted());
262
262
  return;
263
263
  }
264
- if (!f && T) {
265
- l(this, b, !0), this.setMuted(!0);
264
+ if (!$ && f) {
265
+ l(this, g, !0), this.setMuted(!0);
266
266
  return;
267
267
  }
268
- switch (T && ((O = r(this, i, $).call(this, "playVideo")) == null || O.resolve(), s(this, n).notify("play", void 0, t)), e) {
268
+ switch (f && ((v = r(this, i, M).call(this, "playVideo")) == null || v.resolve(), s(this, n).notify("play", void 0, t)), e) {
269
269
  case k.Cued:
270
- r(this, i, L).call(this, t);
270
+ r(this, i, I).call(this, t);
271
271
  break;
272
272
  case k.Playing:
273
273
  s(this, n).notify("playing", void 0, t);
274
274
  break;
275
275
  case k.Paused:
276
- r(this, i, I).call(this, t);
276
+ r(this, i, J).call(this, t);
277
277
  break;
278
278
  case k.Ended:
279
- r(this, i, N).call(this, t);
279
+ r(this, i, q).call(this, t);
280
280
  break;
281
281
  }
282
282
  l(this, P, e);
283
- }, D = function() {
284
- l(this, P, -1), l(this, v, -1), l(this, b, !1);
285
- }, $ = function(e) {
283
+ }, x = function() {
284
+ l(this, P, -1), l(this, T, -1), l(this, g, !1);
285
+ }, M = function(e) {
286
286
  var t;
287
287
  return (t = s(this, y).get(e)) == null ? void 0 : t.shift();
288
- }, K = function(e) {
288
+ }, A = function(e) {
289
289
  var t;
290
290
  return !!((t = s(this, y).get(e)) != null && t.length);
291
291
  };
292
- const fe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
292
+ const be = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
293
293
  __proto__: null,
294
- YouTubeProvider: de
294
+ YouTubeProvider: ce
295
295
  }, Symbol.toStringTag, { value: "Module" }));
296
296
  export {
297
- fe as p,
298
- ye as u
297
+ be as p,
298
+ me as u
299
299
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/studio-player",
3
- "version": "1.2.3",
3
+ "version": "1.3.0",
4
4
  "private": false,
5
5
  "description": "Next generation media player for Instructure",
6
6
  "module": "./dist/studio-player.es.js",
@@ -66,10 +66,12 @@
66
66
  },
67
67
  "dependencies": {
68
68
  "@floating-ui/react": "^0.27.3",
69
+ "@nanostores/react": "^1.0.0",
69
70
  "clsx": "^2.1.1",
70
71
  "dashjs": "4.7.4",
71
72
  "i18next": "^24.2.1",
72
73
  "i18next-resources-to-backend": "^1.2.1",
74
+ "nanostores": "^1.0.1",
73
75
  "react": "^18.3.1",
74
76
  "react-dom": "^18.3.1",
75
77
  "react-i18next": "^15.4.0"