1import { 2 withProviderContext 3} from "./chunk-EE3KHIPD.js"; 4import { 5 decodeJSON 6} from "./chunk-TOW5VNHK.js"; 7import { 8 MediaType 9} from "./chunk-QMWOXIQS.js"; 10import "./chunk-IRGHVTNQ.js"; 11import { 12 ViewType 13} from "./chunk-FHUDTZUI.js"; 14import { 15 createProviderDispatcher, 16 withProviderConnect 17} from "./chunk-Z6DUGZGQ.js"; 18import "./chunk-PYPDBNBC.js"; 19import "./chunk-LEPT57MZ.js"; 20import "./chunk-LIYRVSU4.js"; 21import { 22 deferredPromise, 23 isNumber, 24 isString, 25 isUndefined, 26 withComponentRegistry 27} from "./chunk-LCBMSPVY.js"; 28import { 29 createEvent, 30 h, 31 registerInstance 32} from "./chunk-UE3DGOBI.js"; 33import "./chunk-OS3CCBHP.js"; 34 35// node_modules/@vime/core/dist/esm/vm-vimeo.entry.js 36var VimeoEvent; 37(function(VimeoEvent2) { 38 VimeoEvent2["Play"] = "play"; 39 VimeoEvent2["Pause"] = "pause"; 40 VimeoEvent2["Seeking"] = "seeking"; 41 VimeoEvent2["Seeked"] = "seeked"; 42 VimeoEvent2["TimeUpdate"] = "timeupdate"; 43 VimeoEvent2["VolumeChange"] = "volumechange"; 44 VimeoEvent2["DurationChange"] = "durationchange"; 45 VimeoEvent2["FullscreenChange"] = "fullscreenchange"; 46 VimeoEvent2["CueChange"] = "cuechange"; 47 VimeoEvent2["Progress"] = "progress"; 48 VimeoEvent2["Error"] = "error"; 49 VimeoEvent2["PlaybackRateChange"] = "playbackratechange"; 50 VimeoEvent2["Loaded"] = "loaded"; 51 VimeoEvent2["BufferStart"] = "bufferstart"; 52 VimeoEvent2["BufferEnd"] = "bufferend"; 53 VimeoEvent2["TextTrackChange"] = "texttrackchange"; 54 VimeoEvent2["Waiting"] = "waiting"; 55 VimeoEvent2["Ended"] = "ended"; 56})(VimeoEvent || (VimeoEvent = {})); 57var vimeoCss = ":host{z-index:var(--vm-media-z-index)}vm-embed{position:absolute;top:0;left:0;width:100%;height:100%}vm-embed.hideControls{display:block;width:100%;height:auto;position:relative}"; 58var __awaiter = function(thisArg, _arguments, P, generator) { 59 function adopt(value) { 60 return value instanceof P ? value : new P(function(resolve) { 61 resolve(value); 62 }); 63 } 64 return new (P || (P = Promise))(function(resolve, reject) { 65 function fulfilled(value) { 66 try { 67 step(generator.next(value)); 68 } catch (e) { 69 reject(e); 70 } 71 } 72 function rejected(value) { 73 try { 74 step(generator["throw"](value)); 75 } catch (e) { 76 reject(e); 77 } 78 } 79 function step(result) { 80 result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); 81 } 82 step((generator = generator.apply(thisArg, _arguments || [])).next()); 83 }); 84}; 85var videoInfoCache = /* @__PURE__ */ new Map(); 86var Vimeo = class { 87 constructor(hostRef) { 88 registerInstance(this, hostRef); 89 this.vmLoadStart = createEvent(this, "vmLoadStart", 7); 90 this.vmError = createEvent(this, "vmError", 7); 91 this.defaultInternalState = {}; 92 this.volume = 50; 93 this.hasLoaded = false; 94 this.internalState = { 95 paused: true, 96 playing: false, 97 seeking: false, 98 currentTime: 0, 99 buffered: 0, 100 playbackStarted: false, 101 playRequest: false 102 }; 103 this.embedSrc = ""; 104 this.mediaTitle = ""; 105 this.byline = true; 106 this.portrait = true; 107 this.noAutoAspectRatio = false; 108 this.cookies = true; 109 this.language = "en"; 110 this.aspectRatio = "16:9"; 111 this.autoplay = false; 112 this.controls = false; 113 this.loop = false; 114 this.muted = false; 115 this.playsinline = false; 116 withComponentRegistry(this); 117 withProviderConnect(this); 118 withProviderContext(this); 119 } 120 onVideoIdChange() { 121 this.cancelTimeUpdates(); 122 if (!this.videoId) { 123 this.embedSrc = ""; 124 return; 125 } 126 this.embedSrc = `${this.getOrigin()}/video/${this.videoId}`; 127 this.pendingDurationCall = deferredPromise(); 128 this.pendingMediaTitleCall = deferredPromise(); 129 this.fetchVideoInfo = this.getVideoInfo(); 130 } 131 onCustomPosterChange() { 132 this.dispatch("currentPoster", this.poster); 133 } 134 connectedCallback() { 135 this.dispatch = createProviderDispatcher(this); 136 this.dispatch("viewType", ViewType.Video); 137 this.onVideoIdChange(); 138 this.defaultInternalState = Object.assign({}, this.internalState); 139 } 140 componentWillLoad() { 141 this.initialMuted = this.muted; 142 } 143 disconnectedCallback() { 144 this.cancelTimeUpdates(); 145 this.pendingPlayRequest = void 0; 146 } 147 getOrigin() { 148 return "https://player.vimeo.com"; 149 }
vendor: 5,019 bytes, lines 150-298
150 getPreconnections() { 151 return [ 152 this.getOrigin(), 153 "https://i.vimeocdn.com", 154 "https://f.vimeocdn.com", 155 "https://fresnel.vimeocdn.com" 156 ]; 157 } 158 remoteControl(command, arg) { 159 return this.embed.postMessage({ 160 method: command, 161 value: arg 162 }); 163 } 164 buildParams() { 165 return { 166 byline: this.byline, 167 color: this.color, 168 portrait: this.portrait, 169 autopause: false, 170 transparent: false, 171 autoplay: this.autoplay, 172 muted: this.initialMuted, 173 playsinline: this.playsinline, 174 dnt: !this.cookies 175 }; 176 } 177 getVideoInfo() { 178 return __awaiter(this, void 0, void 0, function* () { 179 if (videoInfoCache.has(this.videoId)) 180 return videoInfoCache.get(this.videoId); 181 return window.fetch(`https://vimeo.com/api/oembed.json?url=${this.embedSrc}`).then((response) => response.json()).then((data) => { 182 var _a; 183 const thumnailRegex = /vimeocdn.com\/video\/(.*)?_/; 184 const thumbnailId = (_a = data === null || data === void 0 ? void 0 : data.thumbnail_url) === null || _a === void 0 ? void 0 : _a.match(thumnailRegex)[1]; 185 const poster = `https://i.vimeocdn.com/video/${thumbnailId}_1920x1080.jpg`; 186 const info = { poster, width: data === null || data === void 0 ? void 0 : data.width, height: data === null || data === void 0 ? void 0 : data.height }; 187 videoInfoCache.set(this.videoId, info); 188 return info; 189 }); 190 }); 191 } 192 onTimeChange(time) { 193 if (this.internalState.currentTime === time) 194 return; 195 this.dispatch("currentTime", time); 196 if (Math.abs(this.internalState.currentTime - time) > 1.5) { 197 this.internalState.seeking = true; 198 this.dispatch("seeking", true); 199 if (this.internalState.playing && this.internalState.buffered < time) { 200 this.dispatch("buffering", true); 201 } 202 window.clearTimeout(this.pendingPlayRequest); 203 if (!this.internalState.paused) { 204 this.internalState.playRequest = true; 205 } 206 this.remoteControl( 207 this.internalState.playbackStarted ? "pause" : "play" 208 /* Play */ 209 ); 210 } 211 this.internalState.currentTime = time; 212 } 213 cancelTimeUpdates() { 214 if (isNumber(this.timeRAF)) 215 window.cancelAnimationFrame(this.timeRAF); 216 } 217 requestTimeUpdates() { 218 this.remoteControl( 219 "getCurrentTime" 220 /* GetCurrentTime */ 221 ); 222 this.timeRAF = window.requestAnimationFrame(() => { 223 this.requestTimeUpdates(); 224 }); 225 } 226 onSeeked() { 227 if (!this.internalState.seeking) 228 return; 229 this.dispatch("seeking", false); 230 this.internalState.seeking = false; 231 if (this.internalState.playRequest) { 232 window.setTimeout(() => { 233 this.remoteControl( 234 "play" 235 /* Play */ 236 ); 237 }, 150); 238 } 239 } 240 onVimeoMethod(method, arg) { 241 var _a, _b; 242 switch (method) { 243 case "getCurrentTime": 244 if (!this.internalState.seeking) 245 this.onTimeChange(arg); 246 break; 247 case "getDuration": 248 (_a = this.pendingDurationCall) === null || _a === void 0 ? void 0 : _a.resolve(arg); 249 break; 250 case "getVideoTitle": 251 (_b = this.pendingMediaTitleCall) === null || _b === void 0 ? void 0 : _b.resolve(arg); 252 break; 253 } 254 } 255 onLoaded() { 256 var _a, _b; 257 if (this.hasLoaded) 258 return; 259 this.pendingPlayRequest = void 0; 260 this.internalState = Object.assign({}, this.defaultInternalState); 261 this.dispatch("currentSrc", this.embedSrc); 262 this.dispatch("mediaType", MediaType.Video); 263 this.remoteControl( 264 "getDuration" 265 /* GetDuration */ 266 ); 267 this.remoteControl( 268 "getVideoTitle" 269 /* GetVideoTitle */ 270 ); 271 Promise.all([ 272 this.fetchVideoInfo, 273 (_a = this.pendingDurationCall) === null || _a === void 0 ? void 0 : _a.promise, 274 (_b = this.pendingMediaTitleCall) === null || _b === void 0 ? void 0 : _b.promise 275 ]).then(([info, duration, mediaTitle]) => { 276 var _a2, _b2, _c; 277 this.requestTimeUpdates(); 278 this.dispatch("aspectRatio", `${(_a2 = info === null || info === void 0 ? void 0 : info.width) !== null && _a2 !== void 0 ? _a2 : 16}:${(_b2 = info === null || info === void 0 ? void 0 : info.height) !== null && _b2 !== void 0 ? _b2 : 9}`); 279 this.dispatch("currentPoster", (_c = this.poster) !== null && _c !== void 0 ? _c : info === null || info === void 0 ? void 0 : info.poster); 280 this.dispatch("duration", duration !== null && duration !== void 0 ? duration : -1); 281 this.dispatch("mediaTitle", mediaTitle); 282 this.dispatch("playbackReady", true); 283 }); 284 this.hasLoaded = true; 285 } 286 onVimeoEvent(event, payload) { 287 switch (event) { 288 case "ready": 289 Object.values(VimeoEvent).forEach((e) => { 290 this.remoteControl("addEventListener", e); 291 }); 292 break; 293 case "loaded": 294 this.onLoaded(); 295 break; 296 case "play": 297 this.onLoaded(); 298 this.internalState.paused = false;
vendor: 4,891 bytes, lines 299-444
299 this.dispatch("paused", false); 300 break; 301 case "playProgress": 302 if (!this.internalState.playing) { 303 this.dispatch("playing", true); 304 this.internalState.playing = true; 305 this.internalState.playbackStarted = true; 306 this.pendingPlayRequest = window.setTimeout(() => { 307 this.internalState.playRequest = false; 308 this.pendingPlayRequest = void 0; 309 }, 1e3); 310 } 311 this.dispatch("buffering", false); 312 this.onSeeked(); 313 break; 314 case "pause": 315 this.internalState.paused = true; 316 this.internalState.playing = false; 317 this.dispatch("paused", true); 318 this.dispatch("buffering", false); 319 break; 320 case "loadProgress": 321 this.internalState.buffered = payload.seconds; 322 this.dispatch("buffered", payload.seconds); 323 break; 324 case "bufferstart": 325 this.dispatch("buffering", true); 326 if (this.internalState.paused) { 327 this.internalState.paused = false; 328 this.dispatch("paused", false); 329 this.dispatch("playbackStarted", true); 330 } 331 break; 332 case "bufferend": 333 this.dispatch("buffering", false); 334 if (this.internalState.paused) 335 this.onSeeked(); 336 break; 337 case "volumechange": 338 if (payload.volume > 0) { 339 const newVolume = Math.floor(payload.volume * 100); 340 this.dispatch("muted", false); 341 if (this.volume !== newVolume) { 342 this.volume = newVolume; 343 this.dispatch("volume", this.volume); 344 } 345 } else { 346 this.dispatch("muted", true); 347 } 348 break; 349 case "durationchange": 350 this.dispatch("duration", payload.duration); 351 break; 352 case "playbackratechange": 353 this.dispatch("playbackRate", payload.playbackRate); 354 break; 355 case "fullscreenchange": 356 this.dispatch("isFullscreenActive", payload.fullscreen); 357 break; 358 case "finish": 359 if (this.loop) { 360 this.remoteControl("setCurrentTime", 0); 361 setTimeout(() => { 362 this.remoteControl( 363 "play" 364 /* Play */ 365 ); 366 }, 200); 367 } else { 368 this.dispatch("playbackEnded", true); 369 } 370 break; 371 case "error": 372 this.vmError.emit(payload); 373 break; 374 } 375 } 376 onEmbedSrcChange() { 377 this.hasLoaded = false; 378 this.vmLoadStart.emit(); 379 this.dispatch("viewType", ViewType.Video); 380 } 381 onEmbedMessage(event) { 382 const message = event.detail; 383 if (!isUndefined(message.event)) 384 this.onVimeoEvent(message.event, message.data); 385 if (!isUndefined(message.method)) 386 this.onVimeoMethod(message.method, message.value); 387 } 388 adjustPosition() { 389 if (this.controls) { 390 return {}; 391 } 392 const [aw, ah] = this.aspectRatio.split(":").map((r) => parseInt(r, 10)); 393 const height = 240; 394 const padding = 100 / aw * ah; 395 const offset = (height - padding) / (height / 50); 396 return { 397 paddingBottom: `${height}%`, 398 transform: `translateY(-${offset + 0.02}%)` 399 }; 400 } 401 /** @internal */ 402 getAdapter() { 403 return __awaiter(this, void 0, void 0, function* () { 404 const canPlayRegex = /vimeo(?:\.com|)\/([0-9]{9,})/; 405 const fileRegex = /vimeo\.com\/external\/[0-9]+\..+/; 406 return { 407 getInternalPlayer: () => __awaiter(this, void 0, void 0, function* () { 408 return this.embed; 409 }), 410 play: () => __awaiter(this, void 0, void 0, function* () { 411 this.remoteControl( 412 "play" 413 /* Play */ 414 ); 415 }), 416 pause: () => __awaiter(this, void 0, void 0, function* () { 417 this.remoteControl( 418 "pause" 419 /* Pause */ 420 ); 421 }), 422 canPlay: (type) => __awaiter(this, void 0, void 0, function* () { 423 return isString(type) && !fileRegex.test(type) && canPlayRegex.test(type); 424 }), 425 setCurrentTime: (time) => __awaiter(this, void 0, void 0, function* () { 426 if (time !== this.internalState.currentTime) { 427 this.remoteControl("setCurrentTime", time); 428 } 429 }), 430 setMuted: (muted) => __awaiter(this, void 0, void 0, function* () { 431 if (!muted) 432 this.volume = this.volume > 0 ? this.volume : 30; 433 this.remoteControl("setVolume", muted ? 0 : this.volume / 100); 434 }), 435 setVolume: (volume) => __awaiter(this, void 0, void 0, function* () { 436 if (!this.muted) { 437 this.remoteControl("setVolume", volume / 100); 438 } else { 439 this.dispatch("volume", volume); 440 } 441 }), 442 // @TODO how to check if Vimeo pro? 443 canSetPlaybackRate: () => __awaiter(this, void 0, void 0, function* () { 444 return false;
445 }), 446 setPlaybackRate: (rate) => __awaiter(this, void 0, void 0, function* () { 447 this.remoteControl("setPlaybackRate", rate); 448 }) 449 }; 450 }); 451 } 452 render() { 453 return h("vm-embed", { class: { hideControls: !this.controls }, style: this.adjustPosition(), embedSrc: this.embedSrc, mediaTitle: this.mediaTitle, origin: this.getOrigin(), params: this.buildParams(), decoder: decodeJSON, preconnections: this.getPreconnections(), onVmEmbedMessage: this.onEmbedMessage.bind(this), onVmEmbedSrcChange: this.onEmbedSrcChange.bind(this), ref: (el) => { 454 this.embed = el; 455 } }); 456 } 457 static get watchers() { 458 return { 459 "videoId": ["onVideoIdChange"], 460 "poster": ["onCustomPosterChange"] 461 }; 462 } 463}; 464Vimeo.style = vimeoCss; 465export { 466 Vimeo as vm_vimeo 467}; 468//# sourceMappingURL=chunk-GCNDWCCN.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.