@hive-p2p/browser 1.0.83 → 1.0.85
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/core/config.mjs +8 -3
- package/core/ice-offer-manager.mjs +0 -7
- package/hive-p2p.min.js +13 -2
- package/package.json +1 -2
- package/services/clock.mjs +32 -5
- package/services/clock-v2.mjs +0 -196
package/core/config.mjs
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
+
if (typeof window === 'undefined' && typeof self !== 'undefined') {
|
|
2
|
+
globalThis.window = self; // PATCH THE WINDOW OBJECT FOR SIMPLEPEER
|
|
3
|
+
//globalThis.document = {};
|
|
4
|
+
}
|
|
5
|
+
|
|
1
6
|
const isNode = typeof self === 'undefined';
|
|
2
|
-
|
|
7
|
+
if (!isNode) (await import('../libs/simplepeer-9.11.1.min.js')).default;
|
|
3
8
|
|
|
4
9
|
// HOLD: GLOBAL CONFIG FOR THE LIBRARY
|
|
5
10
|
// AVOID: CIRCULAR DEPENDENCIES AND TOO MANY FUNCTION/CONSTRUCTOR CONFIG
|
|
@@ -108,8 +113,8 @@ export const TRANSPORTS = {
|
|
|
108
113
|
|
|
109
114
|
WS_CLIENT: WebSocket,
|
|
110
115
|
WS_SERVER: isNode ? (await import('ws')).WebSocketServer : null,
|
|
111
|
-
|
|
112
|
-
PEER: (await import('simple-peer')).default,
|
|
116
|
+
PEER: isNode ? (await import('simple-peer')).default : globalThis.window.SimplePeer
|
|
117
|
+
//PEER: (await import('simple-peer')).default,
|
|
113
118
|
}
|
|
114
119
|
|
|
115
120
|
export const DISCOVERY = {
|
|
@@ -2,13 +2,6 @@ import { CLOCK } from '../services/clock.mjs';
|
|
|
2
2
|
import { NODE, TRANSPORTS, LOG_CSS } from './config.mjs';
|
|
3
3
|
import { xxHash32 } from '../libs/xxhash32.mjs';
|
|
4
4
|
|
|
5
|
-
// WE SHOULD LOAD WRTC ONLY WHEN NEEDED ! => Now done in node.mjs
|
|
6
|
-
/*async function getWrtc() {
|
|
7
|
-
if (typeof globalThis.RTCPeerConnection !== 'undefined') return undefined;
|
|
8
|
-
return (await import('wrtc')).default;
|
|
9
|
-
}
|
|
10
|
-
const wrtc = await getWrtc();*/
|
|
11
|
-
|
|
12
5
|
/** - 'OfferObj' Definition
|
|
13
6
|
* @typedef {Object} OfferObj
|
|
14
7
|
* @property {number} timestamp
|