1import { Controller } from "@hotwired/stimulus" 2 3// Boots the terminal-recording player for whichever <lb-cast> element this 4// controller wraps. 5// 6// The player is dynamic-import()ed here rather than pinned into application.js, 7// so a page without a recording on it never downloads a byte of it (nor the 8// stylesheet, which the module injects on import). Eager controller loading 9// registers this module; the import only fires when an element actually 10// connects. Module-scoped promise so two recordings on one page share a single 11// download. 12let player 13 14function loadPlayer() { 15 player ||= import("src/cast") 16 return player 17} 18 19export default class extends Controller { 20 async connect() { 21 await loadPlayer() 22 // Turbo may have torn us down while the module was in flight. Without this 23 // the custom element upgrades into a page that is no longer on screen. 24 if (!this.element.isConnected) return 25 26 // Importing calls customElements.define, which upgrades the <lb-cast> 27 // already in the DOM synchronously â so it is live by the time we return. 28 this.dispatch("ready", { bubbles: true }) 29 } 30}
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.