On this page
Overview
Captures a display surface as image, video, or GIF with explicit lifecycle events.
- Artifact
ScreenCapture.js· esm - Classification
public first party - Availability
Browser / native WebView - Normalization
State/events normalized; permission and codec errors mixed.
Import and lifecycle
import * as module from '/arcane/modules/ScreenCapture.js';
Display permission is requested only by capture methods. Image capture stops tracks in finally. Video/GIF retain streams and GIF sampling state until stop(); stop() encodes, stops tracks, and then resets state. reset() alone clears references and timers but does not stop active media tracks, so call stop() during an active capture.
Application-facing behavior: Event/status/error/reason and image-fallback constants; default ScreenCapture; acquire/capture/start/stop/reset methods, state-free EventTarget/on compatibility, and destroy().
Protocol and host implementation
getDisplayMedia, MediaRecorder, canvas, GifEncoder, and per-realm globalThis.arcaneEvents authority This detail does not widen the application-facing API or grant authority.
Exports, signatures, parameters, and results
| Binding | Form | Declaration or signature | Parameter syntax |
|---|---|---|---|
SCREEN_CAPTURE_EVENT_TYPES | variable · value | variable SCREEN_CAPTURE_EVENT_TYPES | — |
SCREEN_CAPTURE_STATUSES | variable · value | variable SCREEN_CAPTURE_STATUSES | — |
SCREEN_CAPTURE_IMAGE_TYPE_FALLBACK | variable · value | variable SCREEN_CAPTURE_IMAGE_TYPE_FALLBACK | — |
SCREEN_CAPTURE_ERRORS | variable · value | variable SCREEN_CAPTURE_ERRORS | — |
SCREEN_CAPTURE_ERROR_CODES | variable · value | variable SCREEN_CAPTURE_ERROR_CODES | — |
SCREEN_CAPTURE_REASONS | variable · value | variable SCREEN_CAPTURE_REASONS | — |
default | default · class | class ScreenCapture extends EventTarget | — |
| Member | Kind | Exact public declaration | Parameter syntax |
|---|---|---|---|
ScreenCapture.constructor | constructor | constructor({
mediaDevices=globalThis.navigator?.mediaDevices,
Recorder=globalThis.MediaRecorder,
documentRef=globalThis.document
}={}) | {
mediaDevices=globalThis.navigator?.mediaDevices,
Recorder=globalThis.MediaRecorder,
documentRef=globalThis.document
}={} |
ScreenCapture.addEventListener | method | addEventListener(type,listener,options) | type,listener,options |
ScreenCapture.removeEventListener | method | removeEventListener(type,listener,options) | type,listener,options |
ScreenCapture.on | method | on(type,listener,options) | type,listener,options |
ScreenCapture.subscribe | method | subscribe(type,listener,options) | type,listener,options |
ScreenCapture.dispatchEvent | method | dispatchEvent(value) | value |
ScreenCapture.available | method | available() | — |
ScreenCapture.assertIdle | method | assertIdle() | — |
ScreenCapture.acquire | async method | async acquire(optionsValue={}) | optionsValue={} |
ScreenCapture.captureImage | async method | async captureImage(optionsValue={}) | optionsValue={} |
ScreenCapture.startVideo | async method | async startVideo(optionsValue={}) | optionsValue={} |
ScreenCapture.startGif | async method | async startGif(optionsValue={}) | optionsValue={} |
ScreenCapture.stop | async method | async stop(optionsValue={}) | optionsValue={} |
ScreenCapture.prepare | async method | async prepare(stream,optionsValue={}) | stream,optionsValue={} |
ScreenCapture.stopTracks | method | stopTracks(stream) | stream |
ScreenCapture.reset | method | reset() | — |
ScreenCapture.emit | method | emit(type,detail={}) | type,detail={} |
ScreenCapture.destroy | method | destroy() | — |
ScreenCapture.dispose | method | dispose() | — |
Parameter meanings and results
new ScreenCapture({mediaDevices?,Recorder?,documentRef?}); available(); acquire({audio?,signal?}); captureImage({type='image/png',quality?,signal?,operationId?}) preserves the selected display dimensions and resolves {blob,mimeType,extension,duration,width,height}; startVideo({audio=true,signal?,operationId?}) and startGif({frameDelay?,signal?,operationId?}) resolve true; stop() resolves a complete capture result or null and releases tracks; reset() is state-only.
Events, side effects, and errors
Source-literal CustomEvent dispatches
No source-literal CustomEvent dispatch is part of this artifact.
Lifecycle and event flow
- capture-requesting with {mode}
- capture-start with {mode}
- capture-result with result
- capture-error with {error,mode}
- capture-stop
Direct coded failures
This artifact directly assigns no stable coded failure.
Exported Error subclasses
This artifact exports no Error subclass.
Documented failure behavior
- Uncoded permission, browser, media, codec, and encoding errors.
- Uncoded active-capture state error.
Availability and capabilities
Browser / native WebView. State/events normalized; permission and codec errors mixed.
None; browser getDisplayMedia, MediaRecorder, canvas, and user permission govern access.
Contract example
import ScreenCapture from '/arcane/modules/ScreenCapture.js';
const capture = new ScreenCapture();
document.querySelector('button').addEventListener('click', async () => {
const result = await capture.captureImage();
document.querySelector('img').src = URL.createObjectURL(result.blob);
});
Related reference
No direct Core call is claimed for this artifact. Any injected provider or consuming module retains its own documented authority.