UNPKG

@mertushka/node-datachannel

Version:

WebRTC For Node.js and Electron. libdatachannel node bindings.

1 lines 4.76 kB
{"version":3,"file":"Events.mjs","sources":["../../../src/polyfill/Events.ts"],"sourcesContent":["import RTCDataChannel from './RTCDataChannel';\nimport RTCError from './RTCError';\n\nexport class RTCPeerConnectionIceEvent\n extends Event\n implements globalThis.RTCPeerConnectionIceEvent\n{\n #candidate: globalThis.RTCIceCandidate;\n\n constructor(candidate: globalThis.RTCIceCandidate) {\n super('icecandidate');\n\n this.#candidate = candidate;\n }\n\n get candidate(): globalThis.RTCIceCandidate {\n return this.#candidate;\n }\n\n get url(): string {\n return '';\n }\n}\n\nexport class RTCDataChannelEvent extends Event implements globalThis.RTCDataChannelEvent {\n #channel: RTCDataChannel;\n\n constructor(type: string = 'datachannel', eventInitDict: globalThis.RTCDataChannelEventInit) {\n super(type);\n\n if (arguments.length === 0)\n throw new TypeError(\n `Failed to construct 'RTCDataChannelEvent': 2 arguments required, but only ${arguments.length} present.`,\n );\n if (typeof eventInitDict !== 'object')\n throw new TypeError(\n \"Failed to construct 'RTCDataChannelEvent': The provided value is not of type 'RTCDataChannelEventInit'.\",\n );\n if (!eventInitDict.channel)\n throw new TypeError(\n \"Failed to construct 'RTCDataChannelEvent': Failed to read the 'channel' property from 'RTCDataChannelEventInit': Required member is undefined.\",\n );\n if (eventInitDict.channel.constructor !== RTCDataChannel)\n throw new TypeError(\n \"Failed to construct 'RTCDataChannelEvent': Failed to read the 'channel' property from 'RTCDataChannelEventInit': Failed to convert value to 'RTCDataChannel'.\",\n );\n\n this.#channel = eventInitDict?.channel;\n }\n\n get channel(): RTCDataChannel {\n return this.#channel;\n }\n}\n\nexport class RTCErrorEvent extends Event implements globalThis.RTCErrorEvent {\n #error: RTCError;\n constructor(type: string, init: globalThis.RTCErrorEventInit) {\n if (arguments.length < 2)\n throw new TypeError(\n `Failed to construct 'RTCErrorEvent': 2 arguments required, but only ${arguments.length} present.`,\n );\n if (typeof init !== 'object')\n throw new TypeError(\n \"Failed to construct 'RTCErrorEvent': The provided value is not of type 'RTCErrorEventInit'.\",\n );\n if (!init.error)\n throw new TypeError(\n \"Failed to construct 'RTCErrorEvent': Failed to read the 'error' property from 'RTCErrorEventInit': Required member is undefined.\",\n );\n if (init.error.constructor !== RTCError)\n throw new TypeError(\n \"Failed to construct 'RTCErrorEvent': Failed to read the 'error' property from 'RTCErrorEventInit': Failed to convert value to 'RTCError'.\",\n );\n super(type || 'error');\n this.#error = init.error;\n }\n\n get error(): RTCError {\n return this.#error;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;AAAA,IAAA,UAAA,EAAA,QAAA,EAAA,MAAA;AAGO,MAAM,kCACH,KAAA,CAEV;AAAA,EAGE,YAAY,SAAA,EAAuC;AACjD,IAAA,KAAA,CAAM,cAAc,CAAA;AAHtB,IAAA,YAAA,CAAA,IAAA,EAAA,UAAA,CAAA;AAKE,IAAA,YAAA,CAAA,IAAA,EAAK,UAAA,EAAa,SAAA,CAAA;AAAA;AACpB,EAEA,IAAI,SAAA,GAAwC;AAC1C,IAAA,OAAO,YAAA,CAAA,IAAA,EAAK,UAAA,CAAA;AAAA;AACd,EAEA,IAAI,GAAA,GAAc;AAChB,IAAA,OAAO,EAAA;AAAA;AAEX;AAfE,UAAA,GAAA,IAAA,OAAA,EAAA;AAiBK,MAAM,4BAA4B,KAAA,CAAgD;AAAA,EAGvF,WAAA,CAAY,IAAA,GAAe,aAAA,EAAe,aAAA,EAAmD;AAC3F,IAAA,KAAA,CAAM,IAAI,CAAA;AAHZ,IAAA,YAAA,CAAA,IAAA,EAAA,QAAA,CAAA;AAKE,IAAA,IAAI,UAAU,MAAA,KAAW,CAAA;AACvB,MAAA,MAAM,IAAI,SAAA;AAAA,QACR,CAAA,0EAAA,EAA6E,UAAU,MAAM,CAAA,SAAA;AAAA,OAC/F;AACF,IAAA,IAAI,OAAO,aAAA,KAAkB,QAAA;AAC3B,MAAA,MAAM,IAAI,SAAA;AAAA,QACR;AAAA,OAC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