ScramjetController class manages Scramjet instances, handles configuration, and provides frame creation. It extends EventTarget to support listening for global Scramjet events.
Constructor
Creates a newScramjetController instance.
Partial<ScramjetInitConfig>
required
Configuration options for Scramjet. See config types for details.
Example
Methods
init()
Initializes the controller by loading codecs, opening IndexedDB, and setting up message listeners.Example
createFrame()
Creates a newScramjetFrame instance for managing an iframe.
HTMLIFrameElement
Optional existing iframe element. If not provided, a new iframe is created.
Returns
AScramjetFrame instance for managing the iframe.
Example
encodeUrl()
Encodes a real URL into a Scramjet-proxied URL.string | URL
required
The real URL to encode
Returns
The encoded URL with the Scramjet prefix.Example
Only HTTP and HTTPS URLs are encoded. Other protocols are returned unchanged.
decodeUrl()
Decodes a Scramjet-proxied URL back to the real URL.string | URL
required
The proxied URL to decode
Returns
The decoded real URL.Example
modifyConfig()
Dynamically updates the Scramjet configuration.Partial<ScramjetInitConfig>
required
The configuration properties to update
Example
Configuration changes are persisted to IndexedDB and synchronized with the service worker.
addEventListener()
Adds an event listener for Scramjet global events.'download'
required
The event type to listen for
Function
required
The callback function to execute when the event fires
boolean | AddEventListenerOptions
Event listener options
Example
Events
download
Fired when a download is intercepted by Scramjet.ScramjetDownload interface.