|
| 1 | +'use strict'; |
| 2 | + |
| 3 | +/** |
| 4 | + * This file exposes web interfaces that is defined with the WebIDL |
| 5 | + * [Exposed=*] extended attribute. |
| 6 | + * See more details at https://webidl.spec.whatwg.org/#Exposed. |
| 7 | + */ |
| 8 | + |
| 9 | +const { |
| 10 | + globalThis, |
| 11 | +} = primordials; |
| 12 | + |
| 13 | +const { |
| 14 | + exposeInterface, |
| 15 | + lazyDOMExceptionClass, |
| 16 | + exposeLazyInterfaces, |
| 17 | + exposeGetterAndSetter, |
| 18 | +} = require('internal/util'); |
| 19 | + |
| 20 | +const { URL, URLSearchParams } = require('internal/url'); |
| 21 | +// https://url.spec.whatwg.org/#url |
| 22 | +exposeInterface(globalThis, 'URL', URL); |
| 23 | +// https://url.spec.whatwg.org/#urlsearchparams |
| 24 | +exposeInterface(globalThis, 'URLSearchParams', URLSearchParams); |
| 25 | +exposeGetterAndSetter(globalThis, |
| 26 | + 'DOMException', |
| 27 | + lazyDOMExceptionClass, |
| 28 | + (value) => { |
| 29 | + exposeInterface(globalThis, 'DOMException', value); |
| 30 | + }); |
| 31 | + |
| 32 | +// https://dom.spec.whatwg.org/#interface-abortcontroller |
| 33 | +// Lazy ones. |
| 34 | +exposeLazyInterfaces(globalThis, 'internal/abort_controller', [ |
| 35 | + 'AbortController', 'AbortSignal', |
| 36 | +]); |
| 37 | +// https://dom.spec.whatwg.org/#interface-eventtarget |
| 38 | +const { |
| 39 | + EventTarget, Event, |
| 40 | +} = require('internal/event_target'); |
| 41 | +exposeInterface(globalThis, 'Event', Event); |
| 42 | +exposeInterface(globalThis, 'EventTarget', EventTarget); |
| 43 | + |
| 44 | +// https://encoding.spec.whatwg.org/#textencoder |
| 45 | +// https://encoding.spec.whatwg.org/#textdecoder |
| 46 | +exposeLazyInterfaces(globalThis, |
| 47 | + 'internal/encoding', |
| 48 | + ['TextEncoder', 'TextDecoder']); |
| 49 | + |
| 50 | +// Web Streams API |
| 51 | +exposeLazyInterfaces( |
| 52 | + globalThis, |
| 53 | + 'internal/webstreams/transformstream', |
| 54 | + ['TransformStream', 'TransformStreamDefaultController']); |
| 55 | + |
| 56 | +exposeLazyInterfaces( |
| 57 | + globalThis, |
| 58 | + 'internal/webstreams/writablestream', |
| 59 | + ['WritableStream', 'WritableStreamDefaultController', 'WritableStreamDefaultWriter']); |
| 60 | + |
| 61 | +exposeLazyInterfaces( |
| 62 | + globalThis, |
| 63 | + 'internal/webstreams/readablestream', |
| 64 | + [ |
| 65 | + 'ReadableStream', 'ReadableStreamDefaultReader', |
| 66 | + 'ReadableStreamBYOBReader', 'ReadableStreamBYOBRequest', |
| 67 | + 'ReadableByteStreamController', 'ReadableStreamDefaultController', |
| 68 | + ]); |
| 69 | + |
| 70 | +exposeLazyInterfaces( |
| 71 | + globalThis, |
| 72 | + 'internal/webstreams/queuingstrategies', |
| 73 | + [ |
| 74 | + 'ByteLengthQueuingStrategy', 'CountQueuingStrategy', |
| 75 | + ]); |
| 76 | + |
| 77 | +exposeLazyInterfaces( |
| 78 | + globalThis, |
| 79 | + 'internal/webstreams/encoding', |
| 80 | + [ |
| 81 | + 'TextEncoderStream', 'TextDecoderStream', |
| 82 | + ]); |
| 83 | + |
| 84 | +exposeLazyInterfaces( |
| 85 | + globalThis, |
| 86 | + 'internal/webstreams/compression', |
| 87 | + [ |
| 88 | + 'CompressionStream', 'DecompressionStream', |
| 89 | + ]); |
0 commit comments