Capability first · transport second

ScreenCapture.js

Captures a display surface as image, video, or GIF with explicit lifecycle events.

SDK 0.5.18Runtime 0.8.12Protocol arcane/1
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

JavaScript
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

BindingFormDeclaration or signatureParameter syntax
SCREEN_CAPTURE_EVENT_TYPESvariable · valuevariable SCREEN_CAPTURE_EVENT_TYPES
SCREEN_CAPTURE_STATUSESvariable · valuevariable SCREEN_CAPTURE_STATUSES
SCREEN_CAPTURE_IMAGE_TYPE_FALLBACKvariable · valuevariable SCREEN_CAPTURE_IMAGE_TYPE_FALLBACK
SCREEN_CAPTURE_ERRORSvariable · valuevariable SCREEN_CAPTURE_ERRORS
SCREEN_CAPTURE_ERROR_CODESvariable · valuevariable SCREEN_CAPTURE_ERROR_CODES
SCREEN_CAPTURE_REASONSvariable · valuevariable SCREEN_CAPTURE_REASONS
defaultdefault · classclass ScreenCapture extends EventTarget
MemberKindExact public declarationParameter syntax
ScreenCapture.constructorconstructorconstructor({ mediaDevices=globalThis.navigator?.mediaDevices, Recorder=globalThis.MediaRecorder, documentRef=globalThis.document }={}){ mediaDevices=globalThis.navigator?.mediaDevices, Recorder=globalThis.MediaRecorder, documentRef=globalThis.document }={}
ScreenCapture.addEventListenermethodaddEventListener(type,listener,options)type,listener,options
ScreenCapture.removeEventListenermethodremoveEventListener(type,listener,options)type,listener,options
ScreenCapture.onmethodon(type,listener,options)type,listener,options
ScreenCapture.subscribemethodsubscribe(type,listener,options)type,listener,options
ScreenCapture.dispatchEventmethoddispatchEvent(value)value
ScreenCapture.availablemethodavailable()
ScreenCapture.assertIdlemethodassertIdle()
ScreenCapture.acquireasync methodasync acquire(optionsValue={})optionsValue={}
ScreenCapture.captureImageasync methodasync captureImage(optionsValue={})optionsValue={}
ScreenCapture.startVideoasync methodasync startVideo(optionsValue={})optionsValue={}
ScreenCapture.startGifasync methodasync startGif(optionsValue={})optionsValue={}
ScreenCapture.stopasync methodasync stop(optionsValue={})optionsValue={}
ScreenCapture.prepareasync methodasync prepare(stream,optionsValue={})stream,optionsValue={}
ScreenCapture.stopTracksmethodstopTracks(stream)stream
ScreenCapture.resetmethodreset()
ScreenCapture.emitmethodemit(type,detail={})type,detail={}
ScreenCapture.destroymethoddestroy()
ScreenCapture.disposemethoddispose()

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

JavaScript
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);
});

No direct Core call is claimed for this artifact. Any injected provider or consuming module retains its own documented authority.