recursal/MDN huggingface dataset:
XRWebGLLayer: getViewport() method
==================================

**Experimental:** **This is an experimental technology**  
Check the Browser compatibility table carefully before using this in production.

 The `XRWebGLLayer` interface's
 **`getViewport()`** method returns the
 `XRViewport` that should be used to render the specified
 `XRView` into the WebGL layer. For WebXR devices which use a
 single framebuffer for both the left and right eyes, the returned viewport represents
 the region of the framebuffer into which the scene should be rendered for the eye
 represented by the view.

Syntax
------


```js
getViewport(view)
```

### Parameters

`view`

 An `XRView` object indicating the view for which the viewport is to be
 returned.


### Return value

 A `XRViewport` object representing the viewport which will restrict
 drawing to the portion of the layer corresponding to the specified `view`.

### Exceptions

`InvalidStateError` `DOMException`

 Thrown if either the specified `view` is not in an active `XRFrame` or
 that `XRFrame` and the `XRWebGLLayer` are not part of the same
 WebXR session.


Examples
--------

 This example demonstrates in part what the callback for the
 `requestAnimationFrame()` function might
 look like, using `getViewport()` to get the viewport so that drawing can be
 constrained to the area set aside for the eye whose viewpoint is currently being
 rendered.

 This works because the set of views returned by an `XRViewerPose` each
 represent one eye's perspective on the scene. Since the framebuffer is split in half,
 one half for each eye, setting the WebGL viewport to match the WebXR layer's viewport
 will ensure that when rendering the scene for the current eye's pose, it is rendered
 into the correct half of the framebuffer.

**<<<--- add link to appropriate section in the Cameras and views
article --->>>**


```js
function drawFrame(time, frame) {
  const session = frame.session;

  const pose = frame.getViewerPose(mainReferenceSpace);

  if (pose) {
    const glLayer = session.renderState.baseLayer;
    gl.bindFramebuffer(gl.FRAMEBUFFER, glLayer.framebuffer);

    gl.clearColor(0, 0, 0, 1.0);
    gl.clearDepth(1.0);
    gl.clear(gl.COLOR\_BUFFER\_BIT, gl.DEPTH\_COLOR\_BIT);

    for (const view of pose.views) {
      const viewport = glLayer.getViewport(view);
      gl.viewport(viewport.x, viewport.y, viewport.width, viewport.height);

      /\* Render the scene now \*/
    }
  }
}
```

Specifications
--------------

| Specification |
| --- |
| WebXR Device API # dom-xrwebgllayer-getviewport |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* WebXR Device API
XRWebGLLayer: fixedFoveation property
=====================================

**Experimental:** **This is an experimental technology**  
Check the Browser compatibility table carefully before using this in production.

The **`fixedFoveation`** property of the `XRWebGLLayer` interface is a number indicating the amount of foveation used by the XR compositor. Fixed Foveated Rendering (FFR) renders the edges of the eye textures at a lower resolution than the center and reduces the GPU load.

It is most useful for low contrast textures, such as background images but less for high contrast ones such as text or detailed images. Authors can adjust the level on a per frame basis to achieve the best tradeoff between performance and visual quality.

Value
-----

A number between 0 and 1.

* The minium amount of foveation is indicated by 0 (full resolution).
* The maximum amount of foveation is indicated by 1 (the edges render at lower resolution).

It's up to the user agent how to interpret the numbers in this range. When changing the foveation level, the effect will visible in the next `XRFrame`.

Note that some user agents might implement certain levels of foveation, so you might need to adjust the foveation level in large increments to see an effect. Example levels:

* `0`: no foveation
* `1/3`: low foveation
* `2/3`: medium foveation
* `1.0`: maximum foveation

Some devices don't support foveated rendering. In that case `fixedFoveation` is `null` and setting it will not do anything.

Examples
--------

### Dynamically setting the level of fixed foveation rendering

The `fixedFoveation` property allows you to set the level of foveation at runtime and for each frame. To set the maximum foveation for a given `XRWebGLLayer`, use a value of `1`.


```js
let glLayer = xrSession.renderState.baseLayer;
glLayer.fixedFoveation = 1; // maximum foveation
```

Specifications
--------------

| Specification |
| --- |
| WebXR Device API # dom-xrwebgllayer-fixedfoveation |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* Foveated rendering
PresentationConnectionAvailableEvent: connection property
=========================================================

**Experimental:** **This is an experimental technology**  
Check the Browser compatibility table carefully before using this in production.

When an incoming connection is created, a receiving user agent fires a trusted event, named `connectionavailable`, on a `PresentationReceiver`. The trusted event is fired at the presentation controller's monitor, using the `PresentationConnectionAvailableEvent` interface, with the `connection` attribute set to the `PresentationConnection` object that was created.

The event is fired for all connections that are created when monitoring incoming presentation connections.

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
PresentationConnectionAvailableEvent: PresentationConnectionAvailableEvent() constructor
========================================================================================

**Experimental:** **This is an experimental technology**  
Check the Browser compatibility table carefully before using this in production.

The **`PresentationConnectionAvailableEvent()`** constructor creates a new `PresentationConnectionAvailableEvent` object.

Syntax
------


```js
new PresentationConnectionAvailableInit(type, options)
```

### Parameters

`type`

 A string with the name of the event.
 It is case-sensitive and browsers set it to `connectionavailable`.


`options`

An object that, *in addition of the properties defined in `Event()`*, can have the following properties:

`connection`

The association `PresentationConnection` object.


### Return value

A new `PresentationConnectionAvailableEvent` object.

Specifications
--------------

| Specification |
| --- |
| Presentation API # dom-presentationconnectionavailableevent-constructor |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
TextDecoderStream: TextDecoderStream() constructor
==================================================

The **`TextDecoderStream()`** constructor creates a new `TextDecoderStream` object which is used to convert a stream of text in a binary encoding into strings.

Syntax
------


```js
new TextDecoderStream(label)
new TextDecoderStream(label, options)
```

### Parameters

`label`

 A string defaulting to `utf-8`.
 This may be any valid label.


`options` Optional

An object with the following properties:

`fatal` Optional

 A boolean value indicating if the `TextDecoder.decode()` method must throw a `TypeError` when decoding invalid data.
 It defaults to `false`, which means that the decoder will substitute malformed data with a replacement character.


`ignoreBOM` Optional

 A boolean value indicating whether the byte order mark will be included in the output or skipped over.
 It defaults to `false`, which means that the byte order mark will be skipped over when decoding and will not be included in the decoded text.



### Exceptions

`RangeError`

Thrown if the value of `label` is unknown, or is one of the values leading to a `'replacement'` decoding algorithm (`"iso-2022-cn"` or `"iso-2022-cn-ext"`).

Examples
--------

 The following example demonstrates how to decode binary data retrieved from a `fetch()` call.
 The data will be interpreted as UTF-8, as no `label` has been passed.


```js
const response = await fetch("https://example.com");
const stream = response.body.pipeThrough(new TextDecoderStream());
```

Specifications
--------------

| Specification |
| --- |
| Encoding Standard # ref-for-dom-textdecoderstream① |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
TextDecoderStream: readable property
====================================

The **`readable`** read-only property of the `TextDecoderStream` interface returns a `ReadableStream`.

Value
-----

A `ReadableStream`.

Examples
--------

This example shows how to return a `ReadableStream` from a `TextDecoderStream`.


```js
stream = new TextDecoderStream();
console.log(stream.readable); //a ReadableStream
```

Specifications
--------------

| Specification |
| --- |
| Streams Standard # dom-generictransformstream-readable |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
TextDecoderStream: fatal property
=================================

The **`fatal`** read-only property of the `TextDecoderStream` interface is a `boolean` indicating if the error mode of the `TextDecoderStream` object is set to `fatal`.

 If the property is `true` then a decoder will throw a `TypeError` if it encounters malformed data while decoding.
 If `false` the decoder will substitute the invalid data with the replacement character `U+FFFD` (�).
 The value of the property is set in the `TextDecoderStream()` constructor.

Value
-----

 A `boolean` which will return `true` if the error mode is set to "fatal".
 Otherwise it returns `false`, indicating that the error mode is "replacement".

Examples
--------


```js
stream = new TextDecoderStream();
console.log(stream.fatal); // returns false
```

Specifications
--------------

| Specification |
| --- |
| Encoding Standard # dom-textdecoder-fatal |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
TextDecoderStream: encoding property
====================================

The **`encoding`** read-only property of the `TextDecoderStream` interface returns a string containing the name of the encoding algorithm used by the specific decoder.

The encoding is set by the constructor `label` parameter, and defaults to `utf-8`.

Value
-----

A string containing the lower-cased ASCII name of the encoding format.

The allowed values are the same as those listed in `TextDecoder.encoding` (the labels in Encoding API Encodings).

Examples
--------

Returning the value of `encoding` from a `TextDecoderStream`.


```js
stream = new TextDecoderStream();
console.log(stream.encoding); // returns the default "utf-8"
```

Specifications
--------------

| Specification |
| --- |
| Encoding Standard # dom-textdecoder-encoding |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
TextDecoderStream: writable property
====================================

The **`writable`** read-only property of the `TextDecoderStream` interface returns a `WritableStream`.

Value
-----

A `WritableStream`.

Examples
--------

Returning a `WritableStream` from a `TextDecoderStream`.


```js
stream = new TextDecoderStream();
console.log(stream.writable); // A WritableStream
```

Specifications
--------------

| Specification |
| --- |
| Streams Standard # dom-generictransformstream-writable |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
TextDecoderStream: ignoreBOM property
=====================================

The **`ignoreBOM`** read-only property of the `TextDecoderStream` interface is a `Boolean` indicating whether the byte order mark will be included in the output or skipped over.

Value
-----

`true` if the byte order mark will be included in the decoded text; `false` if it will be skipped over when decoding and omitted.

Examples
--------


```js
stream = new TextDecoderStream();
console.log(stream.ignoreBOM); // returns false
```

Specifications
--------------

| Specification |
| --- |
| Encoding Standard # textdecoder-ignore-bom-flag |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
Worker: messageerror event
==========================

The `messageerror` event is fired on a `Worker` object when it receives a message that can't be deserialized.

This event is not cancellable and does not bubble.

Syntax
------

Use the event name in methods like `addEventListener()`, or set an event handler property.


```js
addEventListener("messageerror", (event) => {});

onmessageerror = (event) => {};
```

Event type
----------

A `MessageEvent`. Inherits from `Event`.

Event

MessageEventEvent properties
----------------

*This interface also inherits properties from its parent, `Event`.*

`MessageEvent.data` Read only 

The data sent by the message emitter.

`MessageEvent.origin` Read only 

A string representing the origin of the message emitter.

`MessageEvent.lastEventId` Read only 

A string representing a unique ID for the event.

`MessageEvent.source` Read only 

A `MessageEventSource` (which can be a WindowProxy, `MessagePort`, or `ServiceWorker` object) representing the message emitter.

`MessageEvent.ports` Read only 

An array of `MessagePort` objects representing the ports associated with the channel the message is being sent through (where appropriate, e.g. in channel messaging or when sending a message to a shared worker).

Examples
--------

Create a worker, and listen for `message` and `messageerror` events using `addEventListener()`:


```js
// main.js

const worker = new Worker("static/scripts/worker.js");

worker.addEventListener("message", (event) => {
  console.error(`Received message from worker: ${event}`);
});

worker.addEventListener("messageerror", (event) => {
  console.error(`Error receiving message from worker: ${event}`);
});
```


The same, but using the `onmessageerror` event handler property:


```js
// main.js

const worker = new Worker("static/scripts/worker.js");

worker.onmessage = (event) => {
  console.error(`Received message from worker: ${event}`);
};

worker.onmessageerror = (event) => {
  console.error(`Error receiving message from worker: ${event}`);
};
```

Specifications
--------------

| Specification |
| --- |
| HTML Standard # event-messageerror |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* `Worker.postMessage()`
* Related events: `message`
Worker: Worker() constructor
============================

The **`Worker()`** constructor creates a `Worker` object that executes the script at the specified URL. This script must obey the same-origin policy.

**Note:** that there is a disagreement among browser manufacturers about whether a data URL is of the same origin or not. Though Firefox 10 and later accept data URLs, that's not the case in all other browsers.

Syntax
------


```js
new Worker(aURL)
new Worker(aURL, options)
```

### Parameters

`aURL`

A string representing the URL of the script the worker will execute. It must obey the same-origin policy.

`options` Optional

An object containing option properties that can be set when creating the object instance. Available properties are as follows:

`type`

A string specifying the type of worker to create. The value can be `classic` or `module`. If not specified, the default used is `classic`.

`credentials`

A string specifying the type of credentials to use for the worker. The value can be `omit`, `same-origin`, or *`include`. If not specified, or if type is `classic`, the default used is `omit` (no credentials required).*

`name`

A string specifying an identifying name for the `DedicatedWorkerGlobalScope` representing the scope of the worker, which is mainly useful for debugging purposes.


### Exceptions

`SecurityError` `DOMException`

Thrown if the document is not allowed to start workers, e.g. if the URL has an invalid syntax or if the same-origin policy is violated.

`NetworkError` `DOMException`

 Thrown if the MIME type of the worker script is incorrect. It *should* always be `text/javascript`
 (for historical reasons other JavaScript MIME types may be accepted).


`SyntaxError` `DOMException`

Thrown if *aURL* cannot be parsed.

Examples
--------

The following code snippet shows creation of a `Worker` object using the `Worker()` constructor and subsequent usage of the object:


```js
const myWorker = new Worker("worker.js");

first.onchange = () => {
  myWorker.postMessage([first.value, second.value]);
  console.log("Message posted to worker");
};
```


For a full example, see our Basic dedicated worker example (run dedicated worker).

Specifications
--------------

| Specification |
| --- |
| HTML Standard # dom-worker-dev |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

The `Worker` interface it belongs to.
Worker: error event
===================

The **`error`** event of the `Worker` interface fires when an error occurs in the worker.

Syntax
------

Use the event name in methods like `addEventListener()`, or set an event handler property.


```js
addEventListener("error", (event) => {});

onerror = (event) => {};
```

Event type
----------

A generic `Event`.

Example
-------

The following code snippet creates a `Worker` object using the `Worker()` constructor and sets up an `onerror` handler on the resulting object:


```js
const myWorker = new Worker("worker.js");

myWorker.onerror = (event) => {
  console.log("There is an error with your worker!");
};
```

Specifications
--------------

| Specification |
| --- |
| HTML Standard # handler-abstractworker-onerror |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
Worker: message event
=====================

The `message` event is fired on a `Worker` object when the worker's parent receives a message from its worker (i.e. when the worker sends a message using `DedicatedWorkerGlobalScope.postMessage()`).

This event is not cancellable and does not bubble.

Syntax
------

Use the event name in methods like `addEventListener()`, or set an event handler property.


```js
addEventListener("message", (event) => {});

onmessage = (event) => {};
```

Event type
----------

A `MessageEvent`. Inherits from `Event`.

Event

MessageEventEvent properties
----------------

*This interface also inherits properties from its parent, `Event`.*

`MessageEvent.data` Read only 

The data sent by the message emitter.

`MessageEvent.origin` Read only 

A string representing the origin of the message emitter.

`MessageEvent.lastEventId` Read only 

A string representing a unique ID for the event.

`MessageEvent.source` Read only 

A `MessageEventSource` (which can be a WindowProxy, `MessagePort`, or `ServiceWorker` object) representing the message emitter.

`MessageEvent.ports` Read only 

An array of `MessagePort` objects representing the ports associated with the channel the message is being sent through (where appropriate, e.g. in channel messaging or when sending a message to a shared worker).

Examples
--------

This code creates a new worker and listens to messages from it using `addEventListener()`:


```js
const worker = new Worker("static/scripts/worker.js");

worker.addEventListener("message", (event) => {
  console.log(`Received message from worker: ${event.data}`);
});
```


Alternatively, it could listen using the `onmessage` event handler property:


```js
const worker = new Worker("static/scripts/worker.js");

worker.onmessage = (event) => {
  console.log(`Received message from worker: ${event.data}`);
};
```


The worker posts messages using `self.postMessage()`:


```js
// static/scripts/worker.js

self.postMessage("I'm alive!");
```

Specifications
--------------

| Specification |
| --- |
| HTML Standard # event-message |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* Related events: `messageerror`.
* `DedicatedWorkerGlobalScope.postMessage()`.
Worker: terminate() method
==========================

The **`terminate()`** method of the `Worker` interface immediately terminates the `Worker`. This does not offer the worker an opportunity to finish its operations; it is stopped at once.

Syntax
------


```js
terminate()
```

### Parameters

None.

### Return value

None (`undefined`).

Examples
--------

The following code snippet shows creation of a `Worker` object using the `Worker()` constructor, which is then immediately terminated.


```js
const myWorker = new Worker("worker.js");

myWorker.terminate();
```


**Note:** DedicatedWorkers and SharedWorkers can also be stopped from the `Worker` instance using the `DedicatedWorkerGlobalScope.close()` or `SharedWorkerGlobalScope.close()` methods.

Specifications
--------------

| Specification |
| --- |
| HTML Standard # dom-worker-terminate-dev |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* `Worker` interface
* `DedicatedWorkerGlobalScope.close()`
* `SharedWorkerGlobalScope.close()`
BluetoothRemoteGATTServer: disconnect() method
==============================================

**Experimental:** **This is an experimental technology**  
Check the Browser compatibility table carefully before using this in production.

 The **`BluetoothRemoteGATTServer.disconnect()`** method causes
 the script execution environment to disconnect from `this.device`.

Syntax
------


```js
disconnect()
```

### Parameters

None.

### Return value

None (`undefined`).

Specifications
--------------

| Specification |
| --- |
| Web Bluetooth # dom-bluetoothremotegattserver-disconnect |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
BluetoothRemoteGATTServer: connect() method
===========================================

**Experimental:** **This is an experimental technology**  
Check the Browser compatibility table carefully before using this in production.

 The
 **`BluetoothRemoteGATTServer.connect()`** method causes the
 script execution environment to connect to `this.device`.

Syntax
------


```js
connect()
```

### Parameters

None.

### Return value

A `Promise` that resolves to a `BluetoothRemoteGATTServer`.

Specifications
--------------

| Specification |
| --- |
| Web Bluetooth # dom-bluetoothremotegattserver-connect |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
BluetoothRemoteGATTServer: device property
==========================================

**Experimental:** **This is an experimental technology**  
Check the Browser compatibility table carefully before using this in production.

 The **`BluetoothRemoteGATTServer.device`** read-only property
 returns a reference to the `BluetoothDevice` running the server.

Value
-----

A reference to the `BluetoothDevice`.

Specifications
--------------

| Specification |
| --- |
| Web Bluetooth # dom-bluetoothremotegattserver-device |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.