@vouchfor/embeds 0.0.0-experiment.0f953a2 → 0.0.0-experiment.107ae83
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/es/embeds.js +189 -168
- package/dist/es/embeds.js.map +1 -1
- package/dist/es/src/components/PlayerEmbed/index.d.ts +8 -7
- package/dist/es/src/components/PlayerEmbed/tests/data.d.ts +2 -1
- package/dist/es/src/components/PlayerEmbed/tests/media-data.d.ts +19 -0
- package/dist/iife/dialog-embed/embed.iife.js +2609 -317
- package/dist/iife/dialog-embed/embed.iife.js.map +1 -1
- package/dist/iife/embeds.iife.js +2610 -318
- package/dist/iife/embeds.iife.js.map +1 -1
- package/dist/iife/player-embed/embed.iife.js +2588 -296
- package/dist/iife/player-embed/embed.iife.js.map +1 -1
- package/package.json +12 -11
- package/src/components/PlayerEmbed/MultiEmbed.stories.ts +135 -0
- package/src/components/PlayerEmbed/PlayerEmbed.stories.ts +15 -1
- package/src/components/PlayerEmbed/controllers/tracking/index.ts +7 -7
- package/src/components/PlayerEmbed/index.ts +30 -18
- package/src/components/PlayerEmbed/tests/PlayerEmbed.spec.ts +14 -7
- package/src/components/PlayerEmbed/tests/data.ts +120 -76
- package/src/components/PlayerEmbed/tests/media-data.ts +22 -0
package/dist/es/embeds.js
CHANGED
@@ -1,25 +1,23 @@
|
|
1
|
-
import { css, LitElement, html } from
|
2
|
-
import { property, state, customElement } from
|
3
|
-
import { ifDefined } from
|
4
|
-
import { createRef, ref } from
|
5
|
-
import { Task } from
|
6
|
-
import { v4 } from
|
7
|
-
import { TEMPLATE_VERSION } from
|
8
|
-
import
|
9
|
-
import { styleMap } from
|
10
|
-
import { classMap } from
|
11
|
-
import
|
12
|
-
|
13
|
-
function forwardEvent(type, fromElement, toElement) {
|
1
|
+
import { css, LitElement, html } from "lit";
|
2
|
+
import { property, state, customElement } from "lit/decorators.js";
|
3
|
+
import { ifDefined } from "lit/directives/if-defined.js";
|
4
|
+
import { createRef, ref } from "lit/directives/ref.js";
|
5
|
+
import { Task } from "@lit/task";
|
6
|
+
import { v4 } from "uuid";
|
7
|
+
import { TEMPLATE_VERSION } from "@vouchfor/canvas-video";
|
8
|
+
import "@vouchfor/media-player";
|
9
|
+
import { styleMap } from "lit/directives/style-map.js";
|
10
|
+
import { classMap } from "lit/directives/class-map.js";
|
11
|
+
import "@a11y/focus-trap";
|
12
|
+
function forwardEvent(type2, fromElement, toElement) {
|
14
13
|
function forwarder(event) {
|
15
14
|
toElement.dispatchEvent(new CustomEvent(event.type, event));
|
16
15
|
}
|
17
|
-
fromElement.addEventListener(
|
16
|
+
fromElement.addEventListener(type2, forwarder);
|
18
17
|
return () => {
|
19
|
-
fromElement.removeEventListener(
|
18
|
+
fromElement.removeEventListener(type2, forwarder);
|
20
19
|
};
|
21
20
|
}
|
22
|
-
|
23
21
|
class EventForwardController {
|
24
22
|
constructor(host, events) {
|
25
23
|
this._events = [];
|
@@ -48,7 +46,6 @@ class EventForwardController {
|
|
48
46
|
this._cleanup = [];
|
49
47
|
}
|
50
48
|
}
|
51
|
-
|
52
49
|
const devVideoUrl = "https://d2rxhdlm2q91uk.cloudfront.net";
|
53
50
|
const stagingVideoUrl = "https://d1ix11aj5kfygl.cloudfront.net";
|
54
51
|
const prodVideoUrl = "https://d157jlwnudd93d.cloudfront.net";
|
@@ -92,11 +89,11 @@ function getEnvUrls(env) {
|
|
92
89
|
};
|
93
90
|
}
|
94
91
|
}
|
95
|
-
|
96
92
|
class FetcherController {
|
97
93
|
constructor(host) {
|
98
94
|
this._fetching = false;
|
99
95
|
this.getVouch = async (env, apiKey, vouchId) => {
|
96
|
+
var _a;
|
100
97
|
const { embedApiUrl } = getEnvUrls(env);
|
101
98
|
const cacheCheck = v4();
|
102
99
|
const res = await fetch(`${embedApiUrl}/vouches/${vouchId}`, {
|
@@ -107,8 +104,8 @@ class FetcherController {
|
|
107
104
|
]
|
108
105
|
});
|
109
106
|
const vouch = await res.json();
|
110
|
-
this.host.dispatchEvent(new CustomEvent("vouch:loaded", { detail: vouch
|
111
|
-
const resCacheCheck = res
|
107
|
+
this.host.dispatchEvent(new CustomEvent("vouch:loaded", { detail: vouch == null ? void 0 : vouch.id }));
|
108
|
+
const resCacheCheck = (_a = res == null ? void 0 : res.headers) == null ? void 0 : _a.get("X-Cache-Check");
|
112
109
|
if (resCacheCheck !== cacheCheck) {
|
113
110
|
fetch(`${embedApiUrl}/vouches/${vouchId}`, {
|
114
111
|
method: "GET",
|
@@ -121,6 +118,7 @@ class FetcherController {
|
|
121
118
|
return vouch;
|
122
119
|
};
|
123
120
|
this.getTemplate = async (env, apiKey, templateId) => {
|
121
|
+
var _a;
|
124
122
|
const { embedApiUrl } = getEnvUrls(env);
|
125
123
|
const cacheCheck = v4();
|
126
124
|
const res = await fetch(`${embedApiUrl}/templates/${templateId}`, {
|
@@ -131,7 +129,7 @@ class FetcherController {
|
|
131
129
|
]
|
132
130
|
});
|
133
131
|
const template = await res.json();
|
134
|
-
const resCacheCheck = res
|
132
|
+
const resCacheCheck = (_a = res == null ? void 0 : res.headers) == null ? void 0 : _a.get("X-Cache-Check");
|
135
133
|
if (resCacheCheck !== cacheCheck) {
|
136
134
|
fetch(`${embedApiUrl}/templates/${templateId}`, {
|
137
135
|
method: "GET",
|
@@ -147,6 +145,7 @@ class FetcherController {
|
|
147
145
|
new Task(
|
148
146
|
this.host,
|
149
147
|
async ([env, apiKey, data, vouchId, templateId]) => {
|
148
|
+
var _a, _b, _c, _d;
|
150
149
|
try {
|
151
150
|
host.vouch = void 0;
|
152
151
|
host.template = void 0;
|
@@ -157,7 +156,7 @@ class FetcherController {
|
|
157
156
|
template = await this.getTemplate(env, apiKey, templateId);
|
158
157
|
}
|
159
158
|
this._vouch = data;
|
160
|
-
host.template = template ?? data
|
159
|
+
host.template = template ?? ((_b = (_a = data == null ? void 0 : data.settings) == null ? void 0 : _a.template) == null ? void 0 : _b.instance);
|
161
160
|
} else if (vouchId) {
|
162
161
|
this.fetching = true;
|
163
162
|
const [vouch, template] = await Promise.all([
|
@@ -165,7 +164,7 @@ class FetcherController {
|
|
165
164
|
templateId ? this.getTemplate(env, apiKey, templateId) : null
|
166
165
|
]);
|
167
166
|
this._vouch = vouch;
|
168
|
-
host.template = template ?? vouch
|
167
|
+
host.template = template ?? ((_d = (_c = vouch == null ? void 0 : vouch.settings) == null ? void 0 : _c.template) == null ? void 0 : _d.instance);
|
169
168
|
}
|
170
169
|
} finally {
|
171
170
|
this.fetching = false;
|
@@ -179,7 +178,7 @@ class FetcherController {
|
|
179
178
|
host.vouch = vouch ? {
|
180
179
|
...vouch,
|
181
180
|
questions: {
|
182
|
-
items: vouch
|
181
|
+
items: vouch == null ? void 0 : vouch.questions.items.filter((_, index) => !(questions == null ? void 0 : questions.length) || (questions == null ? void 0 : questions.includes(index + 1)))
|
183
182
|
}
|
184
183
|
} : void 0;
|
185
184
|
},
|
@@ -196,9 +195,8 @@ class FetcherController {
|
|
196
195
|
return this._fetching;
|
197
196
|
}
|
198
197
|
}
|
199
|
-
|
200
198
|
const name = "@vouchfor/embeds";
|
201
|
-
const version = "0.0.0-experiment.
|
199
|
+
const version = "0.0.0-experiment.107ae83";
|
202
200
|
const license = "MIT";
|
203
201
|
const author = "Aaron Williams";
|
204
202
|
const main = "dist/es/embeds.js";
|
@@ -206,104 +204,104 @@ const module = "dist/es/embeds.js";
|
|
206
204
|
const type = "module";
|
207
205
|
const types = "dist/es/src/index.d.ts";
|
208
206
|
const exports = {
|
209
|
-
|
207
|
+
".": "./dist/es/embeds.js"
|
210
208
|
};
|
211
209
|
const files = [
|
212
|
-
|
213
|
-
|
210
|
+
"dist",
|
211
|
+
"src"
|
214
212
|
];
|
215
213
|
const publishConfig = {
|
216
|
-
|
217
|
-
|
214
|
+
tag: "experiment",
|
215
|
+
access: "public"
|
218
216
|
};
|
219
217
|
const engines = {
|
220
|
-
|
218
|
+
node: ">=18.18.0"
|
221
219
|
};
|
222
220
|
const scripts = {
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
221
|
+
build: "rm -rf dist && tsc && yarn build:self",
|
222
|
+
"build:deps": "yarn --cwd ../media-player build",
|
223
|
+
"build:self": "vite build --mode iife && vite build --mode es && node scripts/build.cjs",
|
224
|
+
"build:package": "yarn build",
|
225
|
+
"build:storybook": "yarn prebuild && storybook build",
|
226
|
+
"generate:manifest": "wca src --outFile custom-elements.json",
|
227
|
+
lint: "eslint . --quiet",
|
228
|
+
"lint:fix": "eslint . --fix",
|
229
|
+
"lint:staged": "lint-staged",
|
230
|
+
prepublishOnly: "yarn build",
|
231
|
+
size: "size-limit",
|
232
|
+
storybook: "yarn prebuild && storybook dev -p 6007",
|
233
|
+
prebuild: "yarn build:deps && yarn generate:manifest",
|
234
|
+
test: "rm -rf test/lib && yarn prebuild && vite build --mode test && web-test-runner",
|
235
|
+
"test:ci": "yarn test --config web-test-runner.ci.config.js",
|
236
|
+
"test:watch": "yarn test --watch"
|
238
237
|
};
|
239
238
|
const dependencies = {
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
239
|
+
"@a11y/focus-trap": "^1.0.5",
|
240
|
+
"@lit/task": "^1.0.0",
|
241
|
+
"@vouchfor/canvas-video": "^8.2.2",
|
242
|
+
"@vouchfor/media-player": "0.0.0-experiment.107ae83",
|
243
|
+
uuid: "^9.0.1"
|
245
244
|
};
|
246
245
|
const peerDependencies = {
|
247
|
-
|
246
|
+
lit: "^3.1.2"
|
248
247
|
};
|
249
248
|
const devDependencies = {
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
249
|
+
"@esm-bundle/chai": "^4.3.4-fix.0",
|
250
|
+
"@open-wc/testing": "^4.0.0",
|
251
|
+
"@storybook/addon-essentials": "^8.0.4",
|
252
|
+
"@storybook/addon-links": "^8.0.4",
|
253
|
+
"@storybook/blocks": "^8.0.4",
|
254
|
+
"@storybook/web-components": "^8.0.4",
|
255
|
+
"@storybook/web-components-vite": "^8.0.4",
|
256
|
+
"@svgr/core": "^8.1.0",
|
257
|
+
"@types/flat": "^5.0.5",
|
258
|
+
"@types/mocha": "^10.0.6",
|
259
|
+
"@vouchfor/eslint-config": "^1.0.1",
|
260
|
+
"@vouchfor/prettier-config": "^1.0.1",
|
261
|
+
"@vouchfor/video-utils": "0.0.0-experiment.107ae83",
|
262
|
+
"@web/dev-server-esbuild": "^1.0.2",
|
263
|
+
"@web/test-runner": "^0.18.1",
|
264
|
+
"@web/test-runner-browserstack": "^0.7.1",
|
265
|
+
"@web/test-runner-mocha": "^0.9.0",
|
266
|
+
"@web/test-runner-playwright": "^0.11.0",
|
267
|
+
glob: "^10.3.10",
|
268
|
+
"lint-staged": "^15.2.2",
|
269
|
+
lit: "^3.1.2",
|
270
|
+
lodash: "^4.17.21",
|
271
|
+
react: "^18.2.0",
|
272
|
+
"react-dom": "^18.2.0",
|
273
|
+
"rollup-plugin-tla": "^0.0.2",
|
274
|
+
sinon: "^17.0.1",
|
275
|
+
storybook: "^8.0.4",
|
276
|
+
svgson: "^5.3.1",
|
277
|
+
typescript: "^5.4.3",
|
278
|
+
vite: "^5.2.2",
|
279
|
+
"vite-plugin-commonjs": "^0.10.1",
|
280
|
+
"vite-plugin-dts": "^3.7.3",
|
281
|
+
"web-component-analyzer": "^2.0.0"
|
283
282
|
};
|
284
283
|
const packageJson = {
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
},
|
302
|
-
|
303
|
-
|
304
|
-
|
284
|
+
name,
|
285
|
+
version,
|
286
|
+
license,
|
287
|
+
author,
|
288
|
+
main,
|
289
|
+
module,
|
290
|
+
type,
|
291
|
+
types,
|
292
|
+
exports,
|
293
|
+
files,
|
294
|
+
publishConfig,
|
295
|
+
engines,
|
296
|
+
scripts,
|
297
|
+
"lint-staged": {
|
298
|
+
"**/*.{ts,tsx,js}": "eslint --fix --quiet",
|
299
|
+
"**/*.{md,json,yml}": "prettier --write"
|
300
|
+
},
|
301
|
+
dependencies,
|
302
|
+
peerDependencies,
|
303
|
+
devDependencies
|
305
304
|
};
|
306
|
-
|
307
305
|
function createVisitor(env) {
|
308
306
|
const { publicApiUrl } = getEnvUrls(env);
|
309
307
|
const visitorId = v4();
|
@@ -311,6 +309,7 @@ function createVisitor(env) {
|
|
311
309
|
return visitorId;
|
312
310
|
}
|
313
311
|
function getUids(env) {
|
312
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
314
313
|
if (typeof window === "undefined") {
|
315
314
|
return {
|
316
315
|
client: null,
|
@@ -318,21 +317,21 @@ function getUids(env) {
|
|
318
317
|
request: v4()
|
319
318
|
};
|
320
319
|
}
|
321
|
-
let visitorId = window.localStorage
|
322
|
-
let clientId = window.localStorage
|
323
|
-
let tabId = window.sessionStorage
|
320
|
+
let visitorId = (_b = (_a = window.localStorage) == null ? void 0 : _a.getItem) == null ? void 0 : _b.call(_a, "vouch-uid-visitor");
|
321
|
+
let clientId = (_d = (_c = window.localStorage) == null ? void 0 : _c.getItem) == null ? void 0 : _d.call(_c, "vouch-uid-client");
|
322
|
+
let tabId = (_f = (_e = window.sessionStorage) == null ? void 0 : _e.getItem) == null ? void 0 : _f.call(_e, "vouch-uid-tab");
|
324
323
|
const requestId = v4();
|
325
324
|
if (!visitorId) {
|
326
325
|
visitorId = createVisitor(env);
|
327
|
-
window.localStorage
|
326
|
+
(_h = (_g = window.localStorage) == null ? void 0 : _g.setItem) == null ? void 0 : _h.call(_g, "vouch-uid-visitor", visitorId);
|
328
327
|
}
|
329
328
|
if (!clientId) {
|
330
329
|
clientId = v4();
|
331
|
-
window.localStorage
|
330
|
+
(_j = (_i = window.localStorage) == null ? void 0 : _i.setItem) == null ? void 0 : _j.call(_i, "vouch-uid-client", clientId);
|
332
331
|
}
|
333
332
|
if (!tabId) {
|
334
333
|
tabId = v4();
|
335
|
-
window.sessionStorage
|
334
|
+
(_l = (_k = window.sessionStorage) == null ? void 0 : _k.setItem) == null ? void 0 : _l.call(_k, "vouch-uid-tab", tabId);
|
336
335
|
}
|
337
336
|
return {
|
338
337
|
client: clientId,
|
@@ -345,10 +344,11 @@ function findVouchId(payload, vouch) {
|
|
345
344
|
if (payload && "vouchId" in payload) {
|
346
345
|
return payload.vouchId;
|
347
346
|
}
|
348
|
-
return vouch
|
347
|
+
return (vouch == null ? void 0 : vouch.id) ?? null;
|
349
348
|
}
|
350
349
|
function getReportingMetadata(source = "embedded_player") {
|
351
|
-
|
350
|
+
var _a, _b;
|
351
|
+
const [country, region] = ((_b = (_a = Intl.DateTimeFormat().resolvedOptions().timeZone) == null ? void 0 : _a.split) == null ? void 0 : _b.call(_a, "/")) ?? [];
|
352
352
|
const utmParams = {};
|
353
353
|
[...new URLSearchParams(location.search).entries()].forEach(([key, value]) => {
|
354
354
|
if (/utm/.test(key)) {
|
@@ -371,7 +371,6 @@ function getReportingMetadata(source = "embedded_player") {
|
|
371
371
|
...utmParams
|
372
372
|
};
|
373
373
|
}
|
374
|
-
|
375
374
|
const MINIMUM_SEND_THRESHOLD = 1;
|
376
375
|
class TrackingController {
|
377
376
|
constructor(host) {
|
@@ -461,8 +460,7 @@ class TrackingController {
|
|
461
460
|
this._handleVideoTimeUpdate = ({ detail: { id, key, node } }) => {
|
462
461
|
if (
|
463
462
|
// We only want to count any time that the video is actually playing
|
464
|
-
!this.host.paused
|
465
|
-
id === this.host.scene?.video?.id
|
463
|
+
!this.host.paused
|
466
464
|
) {
|
467
465
|
this._currentlyPlayingVideo = { id, key, node };
|
468
466
|
this._streamLatestTime[key] = node.currentTime;
|
@@ -500,19 +498,21 @@ class TrackingController {
|
|
500
498
|
}
|
501
499
|
hostConnected() {
|
502
500
|
requestAnimationFrame(() => {
|
501
|
+
var _a, _b, _c, _d;
|
503
502
|
if ("onvisibilitychange" in document) {
|
504
503
|
document.addEventListener("visibilitychange", this._handleVisibilityChange);
|
505
504
|
} else {
|
506
505
|
window.addEventListener("pagehide", this._handlePageHide);
|
507
506
|
}
|
508
507
|
this.host.addEventListener("vouch:loaded", this._handleVouchLoaded);
|
509
|
-
this.host.mediaPlayer
|
510
|
-
this.host.mediaPlayer
|
511
|
-
this.host.mediaPlayer
|
512
|
-
this.host.mediaPlayer
|
508
|
+
(_a = this.host.mediaPlayer) == null ? void 0 : _a.addEventListener("play", this._handlePlay);
|
509
|
+
(_b = this.host.mediaPlayer) == null ? void 0 : _b.addEventListener("video:play", this._handleVideoPlay);
|
510
|
+
(_c = this.host.mediaPlayer) == null ? void 0 : _c.addEventListener("video:pause", this._handleVideoPause);
|
511
|
+
(_d = this.host.mediaPlayer) == null ? void 0 : _d.addEventListener("video:timeupdate", this._handleVideoTimeUpdate);
|
513
512
|
});
|
514
513
|
}
|
515
514
|
hostDisconnected() {
|
515
|
+
var _a, _b, _c, _d;
|
516
516
|
this._pageUnloading();
|
517
517
|
if ("onvisibilitychange" in document) {
|
518
518
|
document.removeEventListener("visibilitychange", this._handleVisibilityChange);
|
@@ -520,13 +520,12 @@ class TrackingController {
|
|
520
520
|
window.removeEventListener("pagehide", this._handlePageHide);
|
521
521
|
}
|
522
522
|
this.host.removeEventListener("vouch:loaded", this._handleVouchLoaded);
|
523
|
-
this.host.mediaPlayer
|
524
|
-
this.host.mediaPlayer
|
525
|
-
this.host.mediaPlayer
|
526
|
-
this.host.mediaPlayer
|
523
|
+
(_a = this.host.mediaPlayer) == null ? void 0 : _a.removeEventListener("play", this._handlePlay);
|
524
|
+
(_b = this.host.mediaPlayer) == null ? void 0 : _b.removeEventListener("video:play", this._handleVideoPlay);
|
525
|
+
(_c = this.host.mediaPlayer) == null ? void 0 : _c.removeEventListener("video:pause", this._handleVideoPause);
|
526
|
+
(_d = this.host.mediaPlayer) == null ? void 0 : _d.removeEventListener("video:timeupdate", this._handleVideoTimeUpdate);
|
527
527
|
}
|
528
528
|
}
|
529
|
-
|
530
529
|
var __defProp$3 = Object.defineProperty;
|
531
530
|
var __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor;
|
532
531
|
var __decorateClass$3 = (decorators, target, key, kind) => {
|
@@ -559,10 +558,12 @@ let PlayerEmbed = class extends LitElement {
|
|
559
558
|
"playing",
|
560
559
|
"ratechange",
|
561
560
|
"scenechange",
|
561
|
+
"scenesupdate",
|
562
562
|
"seeking",
|
563
563
|
"seeked",
|
564
564
|
"timeupdate",
|
565
565
|
"volumechange",
|
566
|
+
"processing",
|
566
567
|
"waiting",
|
567
568
|
"video:loadeddata",
|
568
569
|
"video:seeking",
|
@@ -576,8 +577,6 @@ let PlayerEmbed = class extends LitElement {
|
|
576
577
|
"video:error"
|
577
578
|
]);
|
578
579
|
this._fetcherController = new FetcherController(this);
|
579
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
580
|
-
// @ts-ignore
|
581
580
|
this._trackingController = new TrackingController(this);
|
582
581
|
this._mediaPlayerRef = createRef();
|
583
582
|
}
|
@@ -585,25 +584,32 @@ let PlayerEmbed = class extends LitElement {
|
|
585
584
|
return this._fetcherController.fetching;
|
586
585
|
}
|
587
586
|
get waiting() {
|
588
|
-
|
587
|
+
var _a;
|
588
|
+
return (_a = this._mediaPlayerRef.value) == null ? void 0 : _a.waiting;
|
589
589
|
}
|
590
590
|
get initialised() {
|
591
|
-
|
591
|
+
var _a;
|
592
|
+
return (_a = this._mediaPlayerRef.value) == null ? void 0 : _a.initialised;
|
592
593
|
}
|
593
594
|
get seeking() {
|
594
|
-
|
595
|
+
var _a;
|
596
|
+
return (_a = this._mediaPlayerRef.value) == null ? void 0 : _a.seeking;
|
595
597
|
}
|
596
598
|
get paused() {
|
597
|
-
|
599
|
+
var _a;
|
600
|
+
return (_a = this._mediaPlayerRef.value) == null ? void 0 : _a.paused;
|
598
601
|
}
|
599
602
|
get captions() {
|
600
|
-
|
603
|
+
var _a;
|
604
|
+
return (_a = this._mediaPlayerRef.value) == null ? void 0 : _a.captions;
|
601
605
|
}
|
602
606
|
get fullscreen() {
|
603
|
-
|
607
|
+
var _a;
|
608
|
+
return (_a = this._mediaPlayerRef.value) == null ? void 0 : _a.fullscreen;
|
604
609
|
}
|
605
610
|
get duration() {
|
606
|
-
|
611
|
+
var _a;
|
612
|
+
return (_a = this._mediaPlayerRef.value) == null ? void 0 : _a.duration;
|
607
613
|
}
|
608
614
|
set currentTime(value) {
|
609
615
|
if (this._mediaPlayerRef.value) {
|
@@ -611,7 +617,8 @@ let PlayerEmbed = class extends LitElement {
|
|
611
617
|
}
|
612
618
|
}
|
613
619
|
get currentTime() {
|
614
|
-
|
620
|
+
var _a;
|
621
|
+
return ((_a = this._mediaPlayerRef.value) == null ? void 0 : _a.currentTime) ?? 0;
|
615
622
|
}
|
616
623
|
set playbackRate(value) {
|
617
624
|
if (this._mediaPlayerRef.value) {
|
@@ -619,7 +626,8 @@ let PlayerEmbed = class extends LitElement {
|
|
619
626
|
}
|
620
627
|
}
|
621
628
|
get playbackRate() {
|
622
|
-
|
629
|
+
var _a;
|
630
|
+
return ((_a = this._mediaPlayerRef.value) == null ? void 0 : _a.playbackRate) ?? 1;
|
623
631
|
}
|
624
632
|
set volume(value) {
|
625
633
|
if (this._mediaPlayerRef.value) {
|
@@ -627,7 +635,8 @@ let PlayerEmbed = class extends LitElement {
|
|
627
635
|
}
|
628
636
|
}
|
629
637
|
get volume() {
|
630
|
-
|
638
|
+
var _a;
|
639
|
+
return ((_a = this._mediaPlayerRef.value) == null ? void 0 : _a.volume) ?? 1;
|
631
640
|
}
|
632
641
|
set muted(value) {
|
633
642
|
if (this._mediaPlayerRef.value) {
|
@@ -635,35 +644,40 @@ let PlayerEmbed = class extends LitElement {
|
|
635
644
|
}
|
636
645
|
}
|
637
646
|
get muted() {
|
638
|
-
|
639
|
-
|
640
|
-
get scene() {
|
641
|
-
return this._mediaPlayerRef.value?.scene ?? null;
|
642
|
-
}
|
643
|
-
get scenes() {
|
644
|
-
return this._mediaPlayerRef.value?.scenes ?? [];
|
645
|
-
}
|
646
|
-
get sceneConfig() {
|
647
|
-
return this._mediaPlayerRef.value?.sceneConfig ?? null;
|
647
|
+
var _a;
|
648
|
+
return ((_a = this._mediaPlayerRef.value) == null ? void 0 : _a.muted) ?? false;
|
648
649
|
}
|
649
|
-
get
|
650
|
-
|
650
|
+
// get scene(): Scene | null {
|
651
|
+
// return this._mediaPlayerRef.value?.scene ?? null;
|
652
|
+
// }
|
653
|
+
// get scenes(): Scene[] {
|
654
|
+
// return this._mediaPlayerRef.value?.scenes ?? [];
|
655
|
+
// }
|
656
|
+
// get sceneConfig(): Scenes | null {
|
657
|
+
// return this._mediaPlayerRef.value?.sceneConfig ?? null;
|
658
|
+
// }
|
659
|
+
get mediaState() {
|
660
|
+
var _a;
|
661
|
+
return (_a = this._mediaPlayerRef.value) == null ? void 0 : _a.mediaState;
|
651
662
|
}
|
652
663
|
get mediaPlayer() {
|
653
664
|
return this._mediaPlayerRef.value;
|
654
665
|
}
|
655
666
|
play() {
|
656
|
-
|
667
|
+
var _a;
|
668
|
+
(_a = this._mediaPlayerRef.value) == null ? void 0 : _a.play();
|
657
669
|
}
|
658
670
|
pause() {
|
659
|
-
|
671
|
+
var _a;
|
672
|
+
(_a = this._mediaPlayerRef.value) == null ? void 0 : _a.pause();
|
660
673
|
}
|
661
674
|
reset(time = 0, play = false) {
|
662
|
-
|
663
|
-
|
664
|
-
setScene(index) {
|
665
|
-
this._mediaPlayerRef.value?.setScene(index);
|
675
|
+
var _a;
|
676
|
+
(_a = this._mediaPlayerRef.value) == null ? void 0 : _a.reset(time, play);
|
666
677
|
}
|
678
|
+
// setScene(index: number) {
|
679
|
+
// this._mediaPlayerRef.value?.setScene(index);
|
680
|
+
// }
|
667
681
|
_renderStyles() {
|
668
682
|
if (!this.aspectRatio) {
|
669
683
|
return html`
|
@@ -686,6 +700,11 @@ let PlayerEmbed = class extends LitElement {
|
|
686
700
|
}
|
687
701
|
return null;
|
688
702
|
}
|
703
|
+
willUpdate(changedProperties) {
|
704
|
+
if (changedProperties.has("vouchId") && this.vouchId !== changedProperties.get("vouchId")) {
|
705
|
+
this.reset(0, false);
|
706
|
+
}
|
707
|
+
}
|
689
708
|
render() {
|
690
709
|
return html`
|
691
710
|
${this._renderStyles()}
|
@@ -694,10 +713,9 @@ let PlayerEmbed = class extends LitElement {
|
|
694
713
|
${this.eventController.register()}
|
695
714
|
?autoplay=${this.autoplay}
|
696
715
|
?loading=${this.fetching}
|
697
|
-
.data=${this.vouch}
|
698
|
-
.template=${this.template}
|
699
716
|
aspectRatio=${ifDefined(this.aspectRatio)}
|
700
717
|
preload=${ifDefined(this.preload)}
|
718
|
+
language=${ifDefined(this.language)}
|
701
719
|
.controls=${this.controls}
|
702
720
|
></vmp-media-player>
|
703
721
|
`;
|
@@ -746,6 +764,9 @@ __decorateClass$3([
|
|
746
764
|
__decorateClass$3([
|
747
765
|
property({ type: Number })
|
748
766
|
], PlayerEmbed.prototype, "aspectRatio", 2);
|
767
|
+
__decorateClass$3([
|
768
|
+
property({ type: String })
|
769
|
+
], PlayerEmbed.prototype, "language", 2);
|
749
770
|
__decorateClass$3([
|
750
771
|
state()
|
751
772
|
], PlayerEmbed.prototype, "vouch", 2);
|
@@ -755,7 +776,6 @@ __decorateClass$3([
|
|
755
776
|
PlayerEmbed = __decorateClass$3([
|
756
777
|
customElement("vouch-embed-player")
|
757
778
|
], PlayerEmbed);
|
758
|
-
|
759
779
|
var __defProp$2 = Object.defineProperty;
|
760
780
|
var __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor;
|
761
781
|
var __decorateClass$2 = (decorators, target, key, kind) => {
|
@@ -884,7 +904,6 @@ __decorateClass$2([
|
|
884
904
|
DialogOverlay = __decorateClass$2([
|
885
905
|
customElement("vouch-embed-dialog-overlay")
|
886
906
|
], DialogOverlay);
|
887
|
-
|
888
907
|
var __defProp$1 = Object.defineProperty;
|
889
908
|
var __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor;
|
890
909
|
var __decorateClass$1 = (decorators, target, key, kind) => {
|
@@ -909,22 +928,23 @@ let DialogPortal = class extends LitElement {
|
|
909
928
|
this._mediaPlayerRef = createRef();
|
910
929
|
this.open = false;
|
911
930
|
this._handleToggle = ({ detail }) => {
|
931
|
+
var _a, _b, _c;
|
912
932
|
if (this.id === detail) {
|
913
933
|
this.open = !this.open;
|
914
934
|
if (this.open) {
|
915
|
-
if (!this.disableAutoplay && this._mediaPlayerRef
|
935
|
+
if (!this.disableAutoplay && ((_a = this._mediaPlayerRef) == null ? void 0 : _a.value)) {
|
916
936
|
this._mediaPlayerRef.value.muted = false;
|
917
937
|
this._mediaPlayerRef.value.play();
|
918
938
|
}
|
919
939
|
} else {
|
920
|
-
this._mediaPlayerRef
|
940
|
+
(_c = (_b = this._mediaPlayerRef) == null ? void 0 : _b.value) == null ? void 0 : _c.pause();
|
921
941
|
}
|
922
942
|
}
|
923
943
|
};
|
924
|
-
// We could do the same thing on close and check for the correct ID but it doesn't really matter
|
925
944
|
this._handleClose = () => {
|
945
|
+
var _a, _b;
|
926
946
|
this.open = false;
|
927
|
-
this._mediaPlayerRef
|
947
|
+
(_b = (_a = this._mediaPlayerRef) == null ? void 0 : _a.value) == null ? void 0 : _b.pause();
|
928
948
|
};
|
929
949
|
this._handleDocumentKeyUp = (e) => {
|
930
950
|
if (e.key === "Escape") {
|
@@ -1015,7 +1035,6 @@ __decorateClass$1([
|
|
1015
1035
|
DialogPortal = __decorateClass$1([
|
1016
1036
|
customElement("vouch-embed-dialog-portal")
|
1017
1037
|
], DialogPortal);
|
1018
|
-
|
1019
1038
|
var __defProp = Object.defineProperty;
|
1020
1039
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
1021
1040
|
var __decorateClass = (decorators, target, key, kind) => {
|
@@ -1121,6 +1140,8 @@ __decorateClass([
|
|
1121
1140
|
DialogEmbed = __decorateClass([
|
1122
1141
|
customElement("vouch-embed-dialog")
|
1123
1142
|
], DialogEmbed);
|
1124
|
-
|
1125
|
-
|
1143
|
+
export {
|
1144
|
+
DialogEmbed,
|
1145
|
+
PlayerEmbed
|
1146
|
+
};
|
1126
1147
|
//# sourceMappingURL=embeds.js.map
|