@s21g/peerjs 1.5.4-15 → 1.5.4-17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundler.cjs +96 -10
- package/dist/bundler.cjs.map +1 -1
- package/dist/bundler.mjs +96 -10
- package/dist/bundler.mjs.map +1 -1
- package/dist/peerjs.js +42 -2
- package/dist/peerjs.js.map +1 -1
- package/dist/peerjs.min.js +2 -2
- package/dist/peerjs.min.js.map +1 -1
- package/dist/serializer.msgpack.mjs +1 -1
- package/dist/serializer.msgpack.mjs.map +1 -1
- package/dist/types.d.ts +5 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/bundler.cjs
CHANGED
|
@@ -154,6 +154,40 @@ const $07e4f6a369d1179a$export$25be9502477c137d = new class {
|
|
|
154
154
|
}();
|
|
155
155
|
|
|
156
156
|
|
|
157
|
+
let $19f5ce13ac90d2b8$var$active = 0;
|
|
158
|
+
let $19f5ce13ac90d2b8$var$maxActive = 0;
|
|
159
|
+
let $19f5ce13ac90d2b8$var$created = 0;
|
|
160
|
+
let $19f5ce13ac90d2b8$var$closed = 0;
|
|
161
|
+
const $19f5ce13ac90d2b8$var$tracked = new WeakSet();
|
|
162
|
+
const $19f5ce13ac90d2b8$var$untracked = new WeakSet();
|
|
163
|
+
const $19f5ce13ac90d2b8$export$1c7f507bb1de34ed = (pc)=>{
|
|
164
|
+
if ($19f5ce13ac90d2b8$var$tracked.has(pc)) return;
|
|
165
|
+
$19f5ce13ac90d2b8$var$tracked.add(pc);
|
|
166
|
+
$19f5ce13ac90d2b8$var$active++;
|
|
167
|
+
$19f5ce13ac90d2b8$var$created++;
|
|
168
|
+
$19f5ce13ac90d2b8$var$maxActive = Math.max($19f5ce13ac90d2b8$var$maxActive, $19f5ce13ac90d2b8$var$active);
|
|
169
|
+
};
|
|
170
|
+
const $19f5ce13ac90d2b8$export$54087db615a4d59c = (pc)=>{
|
|
171
|
+
if (!$19f5ce13ac90d2b8$var$tracked.has(pc)) return;
|
|
172
|
+
if ($19f5ce13ac90d2b8$var$untracked.has(pc)) return;
|
|
173
|
+
$19f5ce13ac90d2b8$var$untracked.add(pc);
|
|
174
|
+
$19f5ce13ac90d2b8$var$active = Math.max(0, $19f5ce13ac90d2b8$var$active - 1);
|
|
175
|
+
$19f5ce13ac90d2b8$var$closed++;
|
|
176
|
+
};
|
|
177
|
+
const $19f5ce13ac90d2b8$export$1d3a6fe3d6a85616 = ()=>({
|
|
178
|
+
active: $19f5ce13ac90d2b8$var$active,
|
|
179
|
+
maxActive: $19f5ce13ac90d2b8$var$maxActive,
|
|
180
|
+
created: $19f5ce13ac90d2b8$var$created,
|
|
181
|
+
closed: $19f5ce13ac90d2b8$var$closed
|
|
182
|
+
});
|
|
183
|
+
const $19f5ce13ac90d2b8$export$7feb54d388628e97 = ()=>{
|
|
184
|
+
$19f5ce13ac90d2b8$var$active = 0;
|
|
185
|
+
$19f5ce13ac90d2b8$var$maxActive = 0;
|
|
186
|
+
$19f5ce13ac90d2b8$var$created = 0;
|
|
187
|
+
$19f5ce13ac90d2b8$var$closed = 0;
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
|
|
157
191
|
const $706cd7d90eca90d6$export$f35f128fd59ea256 = (id)=>{
|
|
158
192
|
// Allow empty ids
|
|
159
193
|
return !id || /^[A-Za-z0-9]+(?:[ _-][A-Za-z0-9]+)*$/.test(id);
|
|
@@ -212,6 +246,8 @@ class $b83e6a166cc3008f$export$f8f26dd395d7e1bd extends (0, $7ce5389b504cc06c$ex
|
|
|
212
246
|
this.browserVersion = (0, $07e4f6a369d1179a$export$25be9502477c137d).getVersion();
|
|
213
247
|
this.pack = $2QID2$peerjsjsbinarypack.pack;
|
|
214
248
|
this.unpack = $2QID2$peerjsjsbinarypack.unpack;
|
|
249
|
+
this.rtcPeerConnectionStats = (0, $19f5ce13ac90d2b8$export$1d3a6fe3d6a85616);
|
|
250
|
+
this.resetRtcPeerConnectionStats = (0, $19f5ce13ac90d2b8$export$7feb54d388628e97);
|
|
215
251
|
/**
|
|
216
252
|
* A hash of WebRTC features mapped to booleans that correspond to whether the feature is supported by the current browser.
|
|
217
253
|
*
|
|
@@ -414,7 +450,7 @@ var $1a7e7edd560505fc$export$adb4a1754da6f10d;
|
|
|
414
450
|
|
|
415
451
|
|
|
416
452
|
var $9ce0019dcc6afe7d$exports = {};
|
|
417
|
-
$9ce0019dcc6afe7d$exports = JSON.parse('{"name":"@s21g/peerjs","version":"1.5.4-
|
|
453
|
+
$9ce0019dcc6afe7d$exports = JSON.parse('{"name":"@s21g/peerjs","version":"1.5.4-17","keywords":["peerjs","webrtc","p2p","rtc"],"description":"PeerJS client","homepage":"https://peerjs.com","bugs":{"url":"https://github.com/peers/peerjs/issues"},"repository":{"type":"git","url":"https://github.com/genki/peerjs"},"license":"MIT","contributors":["Michelle Bu <michelle@michellebu.com>","afrokick <devbyru@gmail.com>","ericz <really.ez@gmail.com>","Jairo <kidandcat@gmail.com>","Jonas Gloning <34194370+jonasgloning@users.noreply.github.com>","Jairo Caro-Accino Viciana <jairo@galax.be>","Carlos Caballero <carlos.caballero.gonzalez@gmail.com>","hc <hheennrryy@gmail.com>","Muhammad Asif <capripio@gmail.com>","PrashoonB <prashoonbhattacharjee@gmail.com>","Harsh Bardhan Mishra <47351025+HarshCasper@users.noreply.github.com>","akotynski <aleksanderkotbury@gmail.com>","lmb <i@lmb.io>","Jairooo <jairocaro@msn.com>","Moritz St\xfcckler <moritz.stueckler@gmail.com>","Simon <crydotsnakegithub@gmail.com>","Denis Lukov <denismassters@gmail.com>","Philipp Hancke <fippo@andyet.net>","Hans Oksendahl <hansoksendahl@gmail.com>","Jess <jessachandler@gmail.com>","khankuan <khankuan@gmail.com>","DUODVK <kurmanov.work@gmail.com>","XiZhao <kwang1imsa@gmail.com>","Matthias Lohr <matthias@lohr.me>","=frank tree <=frnktrb@googlemail.com>","Andre Eckardt <aeckardt@outlook.com>","Chris Cowan <agentme49@gmail.com>","Alex Chuev <alex@chuev.com>","alxnull <alxnull@e.mail.de>","Yemel Jardi <angel.jardi@gmail.com>","Ben Parnell <benjaminparnell.94@gmail.com>","Benny Lichtner <bennlich@gmail.com>","fresheneesz <bitetrudpublic@gmail.com>","bob.barstead@exaptive.com <bob.barstead@exaptive.com>","chandika <chandika@gmail.com>","emersion <contact@emersion.fr>","Christopher Van <cvan@users.noreply.github.com>","eddieherm <edhermoso@gmail.com>","Eduardo Pinho <enet4mikeenet@gmail.com>","Evandro Zanatta <ezanatta@tray.net.br>","Gardner Bickford <gardner@users.noreply.github.com>","Gian Luca <gianluca.cecchi@cynny.com>","PatrickJS <github@gdi2290.com>","jonnyf <github@jonathanfoss.co.uk>","Hizkia Felix <hizkifw@gmail.com>","Hristo Oskov <hristo.oskov@gmail.com>","Isaac Madwed <i.madwed@gmail.com>","Ilya Konanykhin <ilya.konanykhin@gmail.com>","jasonbarry <jasbarry@me.com>","Jonathan Burke <jonathan.burke.1311@googlemail.com>","Josh Hamit <josh.hamit@gmail.com>","Jordan Austin <jrax86@gmail.com>","Joel Wetzell <jwetzell@yahoo.com>","xizhao <kevin.wang@cloudera.com>","Alberto Torres <kungfoobar@gmail.com>","Jonathan Mayol <mayoljonathan@gmail.com>","Jefferson Felix <me@jsfelix.dev>","Rolf Erik Lekang <me@rolflekang.com>","Kevin Mai-Husan Chia <mhchia@users.noreply.github.com>","Pepijn de Vos <pepijndevos@gmail.com>","JooYoung <qkdlql@naver.com>","Tobias Speicher <rootcommander@gmail.com>","Steve Blaurock <sblaurock@gmail.com>","Kyrylo Shegeda <shegeda@ualberta.ca>","Diwank Singh Tomer <singh@diwank.name>","So\u0308ren Balko <Soeren.Balko@gmail.com>","Arpit Solanki <solankiarpit1997@gmail.com>","Yuki Ito <yuki@gnnk.net>","Artur Zayats <zag2art@gmail.com>"],"funding":{"type":"opencollective","url":"https://opencollective.com/peer"},"collective":{"type":"opencollective","url":"https://opencollective.com/peer"},"files":["dist/*"],"sideEffects":["lib/global.ts","lib/supports.ts"],"main":"dist/bundler.cjs","module":"dist/bundler.mjs","browser-minified":"dist/peerjs.min.js","browser-unminified":"dist/peerjs.js","browser-minified-msgpack":"dist/serializer.msgpack.mjs","types":"dist/types.d.ts","engines":{"node":">= 14"},"targets":{"types":{"source":"lib/exports.ts"},"main":{"source":"lib/exports.ts","sourceMap":{"inlineSources":true}},"module":{"source":"lib/exports.ts","includeNodeModules":["eventemitter3"],"sourceMap":{"inlineSources":true}},"browser-minified":{"context":"browser","outputFormat":"global","optimize":true,"engines":{"browsers":"chrome >= 83, edge >= 83, firefox >= 80, safari >= 15"},"source":"lib/global.ts"},"browser-unminified":{"context":"browser","outputFormat":"global","optimize":false,"engines":{"browsers":"chrome >= 83, edge >= 83, firefox >= 80, safari >= 15"},"source":"lib/global.ts"},"browser-minified-msgpack":{"context":"browser","outputFormat":"esmodule","isLibrary":true,"optimize":true,"engines":{"browsers":"chrome >= 83, edge >= 83, firefox >= 102, safari >= 15"},"source":"lib/dataconnection/StreamConnection/MsgPack.ts"}},"scripts":{"contributors":"git-authors-cli --print=false && prettier --write package.json && git add package.json package-lock.json && git commit -m \\"chore(contributors): update and sort contributors list\\"","check":"tsc --noEmit && tsc -p e2e/tsconfig.json --noEmit","watch":"parcel watch","build":"rm -rf dist && parcel build","build:jotter":"npm run build && node tools/jotter/patch-dist.mjs","prepublishOnly":"npm run build:jotter","test":"jest","test:watch":"jest --watch","coverage":"jest --coverage --collectCoverageFrom=\\"./lib/**\\"","format":"prettier --write .","format:check":"prettier --check .","semantic-release":"semantic-release","e2e":"wdio run e2e/wdio.local.conf.ts","e2e:bstack":"wdio run e2e/wdio.bstack.conf.ts"},"devDependencies":{"@parcel/config-default":"^2.9.3","@parcel/packager-ts":"^2.9.3","@parcel/transformer-typescript-tsc":"^2.9.3","@parcel/transformer-typescript-types":"^2.9.3","@semantic-release/changelog":"^6.0.1","@semantic-release/git":"^10.0.1","@swc/core":"^1.3.27","@swc/jest":"^0.2.24","@types/jasmine":"^4.3.4","@wdio/browserstack-service":"^8.11.2","@wdio/cli":"^8.11.2","@wdio/globals":"^8.11.2","@wdio/jasmine-framework":"^8.11.2","@wdio/local-runner":"^8.11.2","@wdio/spec-reporter":"^8.11.2","@wdio/types":"^8.10.4","http-server":"^14.1.1","jest":"^29.3.1","jest-environment-jsdom":"^29.3.1","mock-socket":"^9.0.0","parcel":"^2.9.3","prettier":"^3.0.0","semantic-release":"^21.0.0","ts-node":"^10.9.1","typescript":"^5.0.0","wdio-geckodriver-service":"^5.0.1"},"dependencies":{"@msgpack/msgpack":"^2.8.0","eventemitter3":"^4.0.7","peerjs-js-binarypack":"^2.1.0","webrtc-adapter":"^9.0.0"},"alias":{"process":false,"buffer":false}}');
|
|
418
454
|
|
|
419
455
|
|
|
420
456
|
class $e5e868bf3ea73e5b$export$4798917dbf149b79 extends (0, $2QID2$eventemitter3.EventEmitter) {
|
|
@@ -523,6 +559,7 @@ class $e5e868bf3ea73e5b$export$4798917dbf149b79 extends (0, $2QID2$eventemitter3
|
|
|
523
559
|
|
|
524
560
|
|
|
525
561
|
|
|
562
|
+
|
|
526
563
|
class $a8347a6741c5df8a$export$89e6bb5ad64bf4a {
|
|
527
564
|
constructor(connection){
|
|
528
565
|
this.connection = connection;
|
|
@@ -546,6 +583,7 @@ class $a8347a6741c5df8a$export$89e6bb5ad64bf4a {
|
|
|
546
583
|
/** Start a PC. */ _startPeerConnection() {
|
|
547
584
|
(0, $df9d8b89ee908b8b$export$2e2bcd8739ae039).log("Creating RTCPeerConnection.");
|
|
548
585
|
const peerConnection = new RTCPeerConnection(this.connection.provider.options.config);
|
|
586
|
+
(0, $19f5ce13ac90d2b8$export$1c7f507bb1de34ed)(peerConnection);
|
|
549
587
|
this._setupListeners(peerConnection);
|
|
550
588
|
return peerConnection;
|
|
551
589
|
}
|
|
@@ -624,6 +662,7 @@ class $a8347a6741c5df8a$export$89e6bb5ad64bf4a {
|
|
|
624
662
|
const dataChannel = this.connection.dataChannel;
|
|
625
663
|
if (dataChannel) dataChannelNotClosed = !!dataChannel.readyState && dataChannel.readyState !== "closed";
|
|
626
664
|
if (peerConnectionNotClosed || dataChannelNotClosed) peerConnection.close();
|
|
665
|
+
(0, $19f5ce13ac90d2b8$export$54087db615a4d59c)(peerConnection);
|
|
627
666
|
}
|
|
628
667
|
async _makeOffer() {
|
|
629
668
|
const peerConnection = this.connection.peerConnection;
|
|
@@ -1041,7 +1080,8 @@ class $8d5124d0cf36ebe0$export$ff7c9d4c11d94e8b extends (0, $f188f8cb0f63b180$ex
|
|
|
1041
1080
|
_initializeDataChannel(dc) {
|
|
1042
1081
|
super._initializeDataChannel(dc);
|
|
1043
1082
|
this.dataChannel.binaryType = "arraybuffer";
|
|
1044
|
-
|
|
1083
|
+
// DataConnection.closeで確実に解除できるようonmessageを使う。
|
|
1084
|
+
this.dataChannel.onmessage = (e)=>this._handleDataMessage(e);
|
|
1045
1085
|
}
|
|
1046
1086
|
_bufferedSend(msg) {
|
|
1047
1087
|
if (this._buffering || !this._trySend(msg)) {
|
|
@@ -1631,6 +1671,8 @@ class $544799118fa637e6$export$72aa44612e2200cd extends (0, $f188f8cb0f63b180$ex
|
|
|
1631
1671
|
});
|
|
1632
1672
|
this._CHUNK_SIZE = 32768;
|
|
1633
1673
|
this._bufferedAmountLowWait = null;
|
|
1674
|
+
this._rawReadController = null;
|
|
1675
|
+
this._rawReadOnOpen = null;
|
|
1634
1676
|
this._splitStream = new TransformStream({
|
|
1635
1677
|
transform: (chunk, controller)=>{
|
|
1636
1678
|
for(let split = 0; split < chunk.length; split += this._CHUNK_SIZE)controller.enqueue(chunk.subarray(split, split + this._CHUNK_SIZE));
|
|
@@ -1638,13 +1680,25 @@ class $544799118fa637e6$export$72aa44612e2200cd extends (0, $f188f8cb0f63b180$ex
|
|
|
1638
1680
|
});
|
|
1639
1681
|
this._rawSendStream = new WritableStream({
|
|
1640
1682
|
write: async (chunk, controller)=>{
|
|
1683
|
+
const dc = this.dataChannel;
|
|
1684
|
+
if (!dc) {
|
|
1685
|
+
controller.error(new Error("DataChannel is closed"));
|
|
1686
|
+
this.close();
|
|
1687
|
+
return;
|
|
1688
|
+
}
|
|
1641
1689
|
// if we can send the chunk now, send it
|
|
1642
1690
|
// if not, we wait until at least half of the sending buffer is free again
|
|
1643
|
-
const needWait =
|
|
1691
|
+
const needWait = dc.bufferedAmount > (0, $f188f8cb0f63b180$export$d365f7ad9d7df9c9).MAX_BUFFERED_AMOUNT - chunk.byteLength;
|
|
1644
1692
|
if (needWait) await this._waitForBufferedAmountLow();
|
|
1693
|
+
const dc2 = this.dataChannel;
|
|
1694
|
+
if (!dc2) {
|
|
1695
|
+
controller.error(new Error("DataChannel is closed"));
|
|
1696
|
+
this.close();
|
|
1697
|
+
return;
|
|
1698
|
+
}
|
|
1645
1699
|
// TODO: what can go wrong here?
|
|
1646
1700
|
try {
|
|
1647
|
-
|
|
1701
|
+
dc2.send(chunk);
|
|
1648
1702
|
} catch (e) {
|
|
1649
1703
|
(0, $df9d8b89ee908b8b$export$2e2bcd8739ae039).error(`DC#:${this.connectionId} Error when sending:`, e);
|
|
1650
1704
|
controller.error(e);
|
|
@@ -1655,18 +1709,31 @@ class $544799118fa637e6$export$72aa44612e2200cd extends (0, $f188f8cb0f63b180$ex
|
|
|
1655
1709
|
this.writer = this._splitStream.writable.getWriter();
|
|
1656
1710
|
this._rawReadStream = new ReadableStream({
|
|
1657
1711
|
start: (controller)=>{
|
|
1658
|
-
this.
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1712
|
+
this._rawReadController = controller;
|
|
1713
|
+
const onOpen = ()=>{
|
|
1714
|
+
const dc = this.dataChannel;
|
|
1715
|
+
if (!dc) return;
|
|
1716
|
+
dc.onmessage = (e)=>{
|
|
1717
|
+
try {
|
|
1718
|
+
controller.enqueue(e.data);
|
|
1719
|
+
} catch {
|
|
1720
|
+
// 無視する。
|
|
1721
|
+
}
|
|
1722
|
+
};
|
|
1723
|
+
};
|
|
1724
|
+
this._rawReadOnOpen = onOpen;
|
|
1725
|
+
this.once("open", onOpen);
|
|
1726
|
+
},
|
|
1727
|
+
cancel: ()=>{
|
|
1728
|
+
this._rawReadController = null;
|
|
1663
1729
|
}
|
|
1664
1730
|
});
|
|
1665
|
-
this._splitStream.readable.pipeTo(this._rawSendStream);
|
|
1731
|
+
this._splitStream.readable.pipeTo(this._rawSendStream).catch(()=>{});
|
|
1666
1732
|
}
|
|
1667
1733
|
_waitForBufferedAmountLow() {
|
|
1668
1734
|
if (this._bufferedAmountLowWait) return this._bufferedAmountLowWait;
|
|
1669
1735
|
const dc = this.dataChannel;
|
|
1736
|
+
if (!dc) return Promise.resolve();
|
|
1670
1737
|
this._bufferedAmountLowWait = new Promise((resolve)=>{
|
|
1671
1738
|
let done = false;
|
|
1672
1739
|
const finish = ()=>{
|
|
@@ -1695,6 +1762,25 @@ class $544799118fa637e6$export$72aa44612e2200cd extends (0, $f188f8cb0f63b180$ex
|
|
|
1695
1762
|
this.dataChannel.binaryType = "arraybuffer";
|
|
1696
1763
|
this.dataChannel.bufferedAmountLowThreshold = (0, $f188f8cb0f63b180$export$d365f7ad9d7df9c9).MAX_BUFFERED_AMOUNT / 2;
|
|
1697
1764
|
}
|
|
1765
|
+
close(options) {
|
|
1766
|
+
if (options?.flush) {
|
|
1767
|
+
super.close(options);
|
|
1768
|
+
return;
|
|
1769
|
+
}
|
|
1770
|
+
super.close(options);
|
|
1771
|
+
if (this._rawReadOnOpen) {
|
|
1772
|
+
this.off("open", this._rawReadOnOpen);
|
|
1773
|
+
this._rawReadOnOpen = null;
|
|
1774
|
+
}
|
|
1775
|
+
const c = this._rawReadController;
|
|
1776
|
+
if (!c) return;
|
|
1777
|
+
this._rawReadController = null;
|
|
1778
|
+
try {
|
|
1779
|
+
c.close();
|
|
1780
|
+
} catch {
|
|
1781
|
+
// 無視する。
|
|
1782
|
+
}
|
|
1783
|
+
}
|
|
1698
1784
|
}
|
|
1699
1785
|
|
|
1700
1786
|
|