partysocket
Advanced tools
Comparing version 0.0.0-abbd784 to 0.0.0-c4bc1f2
import ReconnectingWebSocket from "./ws"; | ||
function generateUUID() { | ||
if (crypto.randomUUID) { | ||
return crypto.randomUUID(); | ||
} | ||
let d = new Date().getTime(); | ||
let d2 = typeof performance !== "undefined" && performance.now && performance.now() * 1e3 || 0; | ||
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) { | ||
let r = Math.random() * 16; | ||
if (d > 0) { | ||
r = (d + r) % 16 | 0; | ||
d = Math.floor(d / 16); | ||
} else { | ||
r = (d2 + r) % 16 | 0; | ||
d2 = Math.floor(d2 / 16); | ||
} | ||
return (c === "x" ? r : r & 3 | 8).toString(16); | ||
}); | ||
} | ||
class PartySocket extends ReconnectingWebSocket { | ||
constructor(partySocketOptions) { | ||
const { host, room, protocol, query, protocols, ...socketOptions } = partySocketOptions; | ||
const _pk = crypto.randomUUID(); | ||
const _pk = generateUUID(); | ||
let url = `${protocol || (host.startsWith("localhost:") || host.startsWith("127.0.0.1:") ? "ws" : "wss")}://${host}/party/${room}`; | ||
@@ -7,0 +25,0 @@ if (query) { |
{ | ||
"name": "partysocket", | ||
"version": "0.0.0-abbd784", | ||
"version": "0.0.0-c4bc1f2", | ||
"description": "party hotline", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
31167
680
0