@rpgjs/client 5.0.0-alpha.4 → 5.0.0-alpha.6

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.
Files changed (70) hide show
  1. package/dist/components/index.d.ts +2 -1
  2. package/dist/index.js +1 -0
  3. package/dist/index.js.map +1 -1
  4. package/dist/index10.js +1 -1
  5. package/dist/index11.js +2 -2
  6. package/dist/index12.js +1 -1
  7. package/dist/index13.js +1 -1
  8. package/dist/index13.js.map +1 -1
  9. package/dist/index14.js +80 -39
  10. package/dist/index14.js.map +1 -1
  11. package/dist/index15.js +45 -186
  12. package/dist/index15.js.map +1 -1
  13. package/dist/index16.js +187 -5
  14. package/dist/index16.js.map +1 -1
  15. package/dist/index17.js +5 -383
  16. package/dist/index17.js.map +1 -1
  17. package/dist/index18.js +384 -28
  18. package/dist/index18.js.map +1 -1
  19. package/dist/index19.js +24 -17
  20. package/dist/index19.js.map +1 -1
  21. package/dist/index2.js +6 -6
  22. package/dist/index20.js +16 -2413
  23. package/dist/index20.js.map +1 -1
  24. package/dist/index21.js +2395 -88
  25. package/dist/index21.js.map +1 -1
  26. package/dist/index22.js +108 -103
  27. package/dist/index22.js.map +1 -1
  28. package/dist/index23.js +95 -57
  29. package/dist/index23.js.map +1 -1
  30. package/dist/index24.js +62 -12
  31. package/dist/index24.js.map +1 -1
  32. package/dist/index25.js +17 -37
  33. package/dist/index25.js.map +1 -1
  34. package/dist/index26.js +39 -3
  35. package/dist/index26.js.map +1 -1
  36. package/dist/index27.js +1 -318
  37. package/dist/index27.js.map +1 -1
  38. package/dist/index28.js +319 -22
  39. package/dist/index28.js.map +1 -1
  40. package/dist/index29.js +22 -8
  41. package/dist/index29.js.map +1 -1
  42. package/dist/index3.js +2 -2
  43. package/dist/index30.js +3 -3
  44. package/dist/index30.js.map +1 -1
  45. package/dist/index31.js +8 -9
  46. package/dist/index31.js.map +1 -1
  47. package/dist/index32.js +9 -4400
  48. package/dist/index32.js.map +1 -1
  49. package/dist/index33.js +4394 -307
  50. package/dist/index33.js.map +1 -1
  51. package/dist/index34.js +307 -165
  52. package/dist/index34.js.map +1 -1
  53. package/dist/index35.js +162 -489
  54. package/dist/index35.js.map +1 -1
  55. package/dist/index36.js +496 -86
  56. package/dist/index36.js.map +1 -1
  57. package/dist/index37.js.map +1 -1
  58. package/dist/index38.js.map +1 -1
  59. package/dist/index4.js +2 -2
  60. package/dist/index5.js +1 -1
  61. package/dist/index6.js +1 -1
  62. package/dist/index7.js +1 -1
  63. package/dist/index8.js +1 -1
  64. package/dist/index9.js +2 -2
  65. package/package.json +8 -6
  66. package/src/components/index.ts +2 -1
  67. package/src/components/scenes/draw-map.ce +0 -18
  68. package/src/components/scenes/event-layer.ce +1 -1
  69. package/vite.config.ts +1 -1
  70. package/src/components/scenes/element-map.ce +0 -23
package/dist/index35.js CHANGED
@@ -1,501 +1,174 @@
1
- // src/ws.ts
2
- if (!globalThis.EventTarget || !globalThis.Event) {
3
- console.error(`
4
- PartySocket requires a global 'EventTarget' class to be available!
5
- You can polyfill this global by adding this to your code before any partysocket imports:
6
-
7
- \`\`\`
8
- import 'partysocket/event-target-polyfill';
9
- \`\`\`
10
- Please file an issue at https://github.com/partykit/partykit if you're still having trouble.
11
- `);
12
- }
13
- var ErrorEvent = class extends Event {
14
- message;
15
- error;
16
- // biome-ignore lint/suspicious/noExplicitAny: vibes
17
- constructor(error, target) {
18
- super("error", target);
19
- this.message = error.message;
20
- this.error = error;
21
- }
22
- };
23
- var CloseEvent = class extends Event {
24
- code;
25
- reason;
26
- wasClean = true;
27
- // biome-ignore lint/style/useDefaultParameterLast: legacy
28
- // biome-ignore lint/suspicious/noExplicitAny: legacy
29
- constructor(code = 1e3, reason = "", target) {
30
- super("close", target);
31
- this.code = code;
32
- this.reason = reason;
33
- }
34
- };
35
- var Events = {
36
- Event,
37
- ErrorEvent,
38
- CloseEvent
39
- };
40
- function assert(condition, msg) {
41
- if (!condition) {
42
- throw new Error(msg);
43
- }
44
- }
45
- function cloneEventBrowser(e) {
46
- return new e.constructor(e.type, e);
1
+ import { ReconnectingWebSocket } from './index36.js';
2
+
3
+ // src/index.ts
4
+ var valueIsNotNil = (keyValuePair) =>
5
+ keyValuePair[1] !== null && keyValuePair[1] !== void 0;
6
+ function generateUUID() {
7
+ if (typeof crypto !== "undefined" && crypto.randomUUID) {
8
+ return crypto.randomUUID();
9
+ }
10
+ let d = /* @__PURE__ */ new Date().getTime();
11
+ let d2 =
12
+ (typeof performance !== "undefined" &&
13
+ performance.now &&
14
+ performance.now() * 1e3) ||
15
+ 0;
16
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) {
17
+ let r = Math.random() * 16;
18
+ if (d > 0) {
19
+ r = (d + r) % 16 | 0;
20
+ d = Math.floor(d / 16);
21
+ } else {
22
+ r = (d2 + r) % 16 | 0;
23
+ d2 = Math.floor(d2 / 16);
24
+ }
25
+ return (c === "x" ? r : (r & 3) | 8).toString(16);
26
+ });
47
27
  }
48
- function cloneEventNode(e) {
49
- if ("data" in e) {
50
- const evt2 = new MessageEvent(e.type, e);
51
- return evt2;
52
- }
53
- if ("code" in e || "reason" in e) {
54
- const evt2 = new CloseEvent(
55
- // @ts-expect-error we need to fix event/listener types
56
- e.code || 1999,
57
- // @ts-expect-error we need to fix event/listener types
58
- e.reason || "unknown reason",
59
- e
60
- );
61
- return evt2;
62
- }
63
- if ("error" in e) {
64
- const evt2 = new ErrorEvent(e.error, e);
65
- return evt2;
66
- }
67
- const evt = new Event(e.type, e);
68
- return evt;
28
+ function getPartyInfo(partySocketOptions, defaultProtocol, defaultParams = {}) {
29
+ const {
30
+ host: rawHost,
31
+ path: rawPath,
32
+ protocol: rawProtocol,
33
+ room,
34
+ party,
35
+ basePath,
36
+ prefix,
37
+ query
38
+ } = partySocketOptions;
39
+ let host = rawHost.replace(/^(http|https|ws|wss):\/\//, "");
40
+ if (host.endsWith("/")) {
41
+ host = host.slice(0, -1);
42
+ }
43
+ if (rawPath == null ? void 0 : rawPath.startsWith("/")) {
44
+ throw new Error("path must not start with a slash");
45
+ }
46
+ const name = party ?? "main";
47
+ const path = rawPath ? `/${rawPath}` : "";
48
+ const protocol =
49
+ rawProtocol ||
50
+ (host.startsWith("localhost:") ||
51
+ host.startsWith("127.0.0.1:") ||
52
+ host.startsWith("192.168.") ||
53
+ host.startsWith("10.") ||
54
+ (host.startsWith("172.") &&
55
+ host.split(".")[1] >= "16" &&
56
+ host.split(".")[1] <= "31") ||
57
+ host.startsWith("[::ffff:7f00:1]:")
58
+ ? // http / ws
59
+ defaultProtocol
60
+ : // https / wss
61
+ `${defaultProtocol}s`);
62
+ const baseUrl = `${protocol}://${host}/${basePath || `${prefix || "parties"}/${name}/${room}`}${path}`;
63
+ const makeUrl = (query2 = {}) =>
64
+ `${baseUrl}?${new URLSearchParams([
65
+ ...Object.entries(defaultParams),
66
+ ...Object.entries(query2).filter(valueIsNotNil)
67
+ ])}`;
68
+ const urlProvider =
69
+ typeof query === "function"
70
+ ? async () => makeUrl(await query())
71
+ : makeUrl(query);
72
+ return {
73
+ host,
74
+ path,
75
+ room,
76
+ name,
77
+ protocol,
78
+ partyUrl: baseUrl,
79
+ urlProvider
80
+ };
69
81
  }
70
- var _a;
71
- var isNode =
72
- typeof process !== "undefined" &&
73
- typeof ((_a = process.versions) == null ? void 0 : _a.node) !== "undefined" &&
74
- typeof document === "undefined";
75
- var cloneEvent = isNode ? cloneEventNode : cloneEventBrowser;
76
- var DEFAULT = {
77
- maxReconnectionDelay: 1e4,
78
- minReconnectionDelay: 1e3 + Math.random() * 4e3,
79
- minUptime: 5e3,
80
- reconnectionDelayGrowFactor: 1.3,
81
- connectionTimeout: 4e3,
82
- maxRetries: Number.POSITIVE_INFINITY,
83
- maxEnqueuedMessages: Number.POSITIVE_INFINITY};
84
- var didWarnAboutMissingWebSocket = false;
85
- var ReconnectingWebSocket = class _ReconnectingWebSocket extends EventTarget {
86
- _ws;
87
- _retryCount = -1;
88
- _uptimeTimeout;
89
- _connectTimeout;
90
- _shouldReconnect = true;
91
- _connectLock = false;
92
- _binaryType = "blob";
93
- _closeCalled = false;
94
- _messageQueue = [];
95
- _debugLogger = console.log.bind(console);
96
- _url;
97
- _protocols;
98
- _options;
99
- constructor(url, protocols, options = {}) {
100
- super();
101
- this._url = url;
102
- this._protocols = protocols;
103
- this._options = options;
104
- if (this._options.startClosed) {
105
- this._shouldReconnect = false;
106
- }
107
- if (this._options.debugLogger) {
108
- this._debugLogger = this._options.debugLogger;
109
- }
110
- this._connect();
111
- }
112
- static get CONNECTING() {
113
- return 0;
114
- }
115
- static get OPEN() {
116
- return 1;
117
- }
118
- static get CLOSING() {
119
- return 2;
120
- }
121
- static get CLOSED() {
122
- return 3;
123
- }
124
- get CONNECTING() {
125
- return _ReconnectingWebSocket.CONNECTING;
126
- }
127
- get OPEN() {
128
- return _ReconnectingWebSocket.OPEN;
129
- }
130
- get CLOSING() {
131
- return _ReconnectingWebSocket.CLOSING;
132
- }
133
- get CLOSED() {
134
- return _ReconnectingWebSocket.CLOSED;
135
- }
136
- get binaryType() {
137
- return this._ws ? this._ws.binaryType : this._binaryType;
138
- }
139
- set binaryType(value) {
140
- this._binaryType = value;
141
- if (this._ws) {
142
- this._ws.binaryType = value;
143
- }
144
- }
145
- /**
146
- * Returns the number or connection retries
147
- */
148
- get retryCount() {
149
- return Math.max(this._retryCount, 0);
150
- }
151
- /**
152
- * The number of bytes of data that have been queued using calls to send() but not yet
153
- * transmitted to the network. This value resets to zero once all queued data has been sent.
154
- * This value does not reset to zero when the connection is closed; if you keep calling send(),
155
- * this will continue to climb. Read only
156
- */
157
- get bufferedAmount() {
158
- const bytes = this._messageQueue.reduce((acc, message) => {
159
- if (typeof message === "string") {
160
- acc += message.length;
161
- } else if (message instanceof Blob) {
162
- acc += message.size;
163
- } else {
164
- acc += message.byteLength;
165
- }
166
- return acc;
167
- }, 0);
168
- return bytes + (this._ws ? this._ws.bufferedAmount : 0);
169
- }
170
- /**
171
- * The extensions selected by the server. This is currently only the empty string or a list of
172
- * extensions as negotiated by the connection
173
- */
174
- get extensions() {
175
- return this._ws ? this._ws.extensions : "";
176
- }
177
- /**
178
- * A string indicating the name of the sub-protocol the server selected;
179
- * this will be one of the strings specified in the protocols parameter when creating the
180
- * WebSocket object
181
- */
182
- get protocol() {
183
- return this._ws ? this._ws.protocol : "";
184
- }
185
- /**
186
- * The current state of the connection; this is one of the Ready state constants
187
- */
188
- get readyState() {
189
- if (this._ws) {
190
- return this._ws.readyState;
191
- }
192
- return this._options.startClosed
193
- ? _ReconnectingWebSocket.CLOSED
194
- : _ReconnectingWebSocket.CONNECTING;
195
- }
196
- /**
197
- * The URL as resolved by the constructor
198
- */
199
- get url() {
200
- return this._ws ? this._ws.url : "";
201
- }
202
- /**
203
- * Whether the websocket object is now in reconnectable state
204
- */
205
- get shouldReconnect() {
206
- return this._shouldReconnect;
207
- }
208
- /**
209
- * An event listener to be called when the WebSocket connection's readyState changes to CLOSED
210
- */
211
- onclose = null;
212
- /**
213
- * An event listener to be called when an error occurs
214
- */
215
- onerror = null;
216
- /**
217
- * An event listener to be called when a message is received from the server
218
- */
219
- onmessage = null;
220
- /**
221
- * An event listener to be called when the WebSocket connection's readyState changes to OPEN;
222
- * this indicates that the connection is ready to send and receive data
223
- */
224
- onopen = null;
225
- /**
226
- * Closes the WebSocket connection or connection attempt, if any. If the connection is already
227
- * CLOSED, this method does nothing
228
- */
229
- close(code = 1e3, reason) {
230
- this._closeCalled = true;
231
- this._shouldReconnect = false;
232
- this._clearTimeouts();
233
- if (!this._ws) {
234
- this._debug("close enqueued: no ws instance");
235
- return;
236
- }
237
- if (this._ws.readyState === this.CLOSED) {
238
- this._debug("close: already closed");
239
- return;
240
- }
241
- this._ws.close(code, reason);
82
+ var PartySocket = class extends ReconnectingWebSocket {
83
+ constructor(partySocketOptions) {
84
+ const wsOptions = getWSOptions(partySocketOptions);
85
+ super(wsOptions.urlProvider, wsOptions.protocols, wsOptions.socketOptions);
86
+ this.partySocketOptions = partySocketOptions;
87
+ this.setWSProperties(wsOptions);
88
+ }
89
+ _pk;
90
+ _pkurl;
91
+ name;
92
+ room;
93
+ host;
94
+ path;
95
+ updateProperties(partySocketOptions) {
96
+ const wsOptions = getWSOptions({
97
+ ...this.partySocketOptions,
98
+ ...partySocketOptions,
99
+ host: partySocketOptions.host ?? this.host,
100
+ room: partySocketOptions.room ?? this.room,
101
+ path: partySocketOptions.path ?? this.path
102
+ });
103
+ this._url = wsOptions.urlProvider;
104
+ this._protocols = wsOptions.protocols;
105
+ this._options = wsOptions.socketOptions;
106
+ this.setWSProperties(wsOptions);
107
+ }
108
+ setWSProperties(wsOptions) {
109
+ const { _pk, _pkurl, name, room, host, path } = wsOptions;
110
+ this._pk = _pk;
111
+ this._pkurl = _pkurl;
112
+ this.name = name;
113
+ this.room = room;
114
+ this.host = host;
115
+ this.path = path;
242
116
  }
243
- /**
244
- * Closes the WebSocket connection or connection attempt and connects again.
245
- * Resets retry counter;
246
- */
247
117
  reconnect(code, reason) {
248
- this._shouldReconnect = true;
249
- this._closeCalled = false;
250
- this._retryCount = -1;
251
- if (!this._ws || this._ws.readyState === this.CLOSED) {
252
- this._connect();
253
- } else {
254
- this._disconnect(code, reason);
255
- this._connect();
118
+ if (!this.room || !this.host) {
119
+ throw new Error(
120
+ "The room and host must be set before connecting, use `updateProperties` method to set them or pass them to the constructor."
121
+ );
256
122
  }
123
+ super.reconnect(code, reason);
124
+ }
125
+ get id() {
126
+ return this._pk;
257
127
  }
258
128
  /**
259
- * Enqueue specified data to be transmitted to the server over the WebSocket connection
129
+ * Exposes the static PartyKit room URL without applying query parameters.
130
+ * To access the currently connected WebSocket url, use PartySocket#url.
260
131
  */
261
- send(data) {
262
- if (this._ws && this._ws.readyState === this.OPEN) {
263
- this._debug("send", data);
264
- this._ws.send(data);
265
- } else {
266
- const { maxEnqueuedMessages = DEFAULT.maxEnqueuedMessages } =
267
- this._options;
268
- if (this._messageQueue.length < maxEnqueuedMessages) {
269
- this._debug("enqueue", data);
270
- this._messageQueue.push(data);
271
- }
272
- }
273
- }
274
- _debug(...args) {
275
- if (this._options.debug) {
276
- this._debugLogger("RWS>", ...args);
277
- }
278
- }
279
- _getNextDelay() {
280
- const {
281
- reconnectionDelayGrowFactor = DEFAULT.reconnectionDelayGrowFactor,
282
- minReconnectionDelay = DEFAULT.minReconnectionDelay,
283
- maxReconnectionDelay = DEFAULT.maxReconnectionDelay
284
- } = this._options;
285
- let delay = 0;
286
- if (this._retryCount > 0) {
287
- delay =
288
- minReconnectionDelay *
289
- reconnectionDelayGrowFactor ** (this._retryCount - 1);
290
- if (delay > maxReconnectionDelay) {
291
- delay = maxReconnectionDelay;
292
- }
293
- }
294
- this._debug("next delay", delay);
295
- return delay;
296
- }
297
- _wait() {
298
- return new Promise((resolve) => {
299
- setTimeout(resolve, this._getNextDelay());
300
- });
301
- }
302
- _getNextProtocols(protocolsProvider) {
303
- if (!protocolsProvider) return Promise.resolve(null);
304
- if (
305
- typeof protocolsProvider === "string" ||
306
- Array.isArray(protocolsProvider)
307
- ) {
308
- return Promise.resolve(protocolsProvider);
309
- }
310
- if (typeof protocolsProvider === "function") {
311
- const protocols = protocolsProvider();
312
- if (!protocols) return Promise.resolve(null);
313
- if (typeof protocols === "string" || Array.isArray(protocols)) {
314
- return Promise.resolve(protocols);
315
- }
316
- if (protocols.then) {
317
- return protocols;
318
- }
319
- }
320
- throw Error("Invalid protocols");
321
- }
322
- _getNextUrl(urlProvider) {
323
- if (typeof urlProvider === "string") {
324
- return Promise.resolve(urlProvider);
325
- }
326
- if (typeof urlProvider === "function") {
327
- const url = urlProvider();
328
- if (typeof url === "string") {
329
- return Promise.resolve(url);
330
- }
331
- if (url.then) {
332
- return url;
333
- }
334
- }
335
- throw Error("Invalid URL");
336
- }
337
- _connect() {
338
- if (this._connectLock || !this._shouldReconnect) {
339
- return;
340
- }
341
- this._connectLock = true;
342
- const {
343
- maxRetries = DEFAULT.maxRetries,
344
- connectionTimeout = DEFAULT.connectionTimeout
345
- } = this._options;
346
- if (this._retryCount >= maxRetries) {
347
- this._debug("max retries reached", this._retryCount, ">=", maxRetries);
348
- return;
349
- }
350
- this._retryCount++;
351
- this._debug("connect", this._retryCount);
352
- this._removeListeners();
353
- this._wait()
354
- .then(() =>
355
- Promise.all([
356
- this._getNextUrl(this._url),
357
- this._getNextProtocols(this._protocols || null)
358
- ])
359
- )
360
- .then(([url, protocols]) => {
361
- if (this._closeCalled) {
362
- this._connectLock = false;
363
- return;
364
- }
365
- if (
366
- !this._options.WebSocket &&
367
- typeof WebSocket === "undefined" &&
368
- !didWarnAboutMissingWebSocket
369
- ) {
370
- console.error(`\u203C\uFE0F No WebSocket implementation available. You should define options.WebSocket.
371
-
372
- For example, if you're using node.js, run \`npm install ws\`, and then in your code:
373
-
374
- import PartySocket from 'partysocket';
375
- import WS from 'ws';
376
-
377
- const partysocket = new PartySocket({
378
- host: "127.0.0.1:1999",
379
- room: "test-room",
380
- WebSocket: WS
381
- });
382
-
383
- `);
384
- didWarnAboutMissingWebSocket = true;
385
- }
386
- const WS = this._options.WebSocket || WebSocket;
387
- this._debug("connect", { url, protocols });
388
- this._ws = protocols ? new WS(url, protocols) : new WS(url);
389
- this._ws.binaryType = this._binaryType;
390
- this._connectLock = false;
391
- this._addListeners();
392
- this._connectTimeout = setTimeout(
393
- () => this._handleTimeout(),
394
- connectionTimeout
395
- );
396
- })
397
- .catch((err) => {
398
- this._connectLock = false;
399
- this._handleError(new Events.ErrorEvent(Error(err.message), this));
400
- });
401
- }
402
- _handleTimeout() {
403
- this._debug("timeout event");
404
- this._handleError(new Events.ErrorEvent(Error("TIMEOUT"), this));
405
- }
406
- _disconnect(code = 1e3, reason) {
407
- this._clearTimeouts();
408
- if (!this._ws) {
409
- return;
410
- }
411
- this._removeListeners();
412
- try {
413
- if (this._ws.readyState === this.OPEN) {
414
- this._ws.close(code, reason);
415
- }
416
- this._handleClose(new Events.CloseEvent(code, reason, this));
417
- } catch (error) {}
418
- }
419
- _acceptOpen() {
420
- this._debug("accept open");
421
- this._retryCount = 0;
422
- }
423
- _handleOpen = (event) => {
424
- this._debug("open event");
425
- const { minUptime = DEFAULT.minUptime } = this._options;
426
- clearTimeout(this._connectTimeout);
427
- this._uptimeTimeout = setTimeout(() => this._acceptOpen(), minUptime);
428
- assert(this._ws, "WebSocket is not defined");
429
- this._ws.binaryType = this._binaryType;
430
- this._messageQueue.forEach((message) => {
431
- var _a2;
432
- return (_a2 = this._ws) == null ? void 0 : _a2.send(message);
433
- });
434
- this._messageQueue = [];
435
- if (this.onopen) {
436
- this.onopen(event);
437
- }
438
- this.dispatchEvent(cloneEvent(event));
439
- };
440
- _handleMessage = (event) => {
441
- this._debug("message event");
442
- if (this.onmessage) {
443
- this.onmessage(event);
444
- }
445
- this.dispatchEvent(cloneEvent(event));
446
- };
447
- _handleError = (event) => {
448
- this._debug("error event", event.message);
449
- this._disconnect(void 0, event.message === "TIMEOUT" ? "timeout" : void 0);
450
- if (this.onerror) {
451
- this.onerror(event);
452
- }
453
- this._debug("exec error listeners");
454
- this.dispatchEvent(cloneEvent(event));
455
- this._connect();
456
- };
457
- _handleClose = (event) => {
458
- this._debug("close event");
459
- this._clearTimeouts();
460
- if (this._shouldReconnect) {
461
- this._connect();
462
- }
463
- if (this.onclose) {
464
- this.onclose(event);
465
- }
466
- this.dispatchEvent(cloneEvent(event));
467
- };
468
- _removeListeners() {
469
- if (!this._ws) {
470
- return;
471
- }
472
- this._debug("removeListeners");
473
- this._ws.removeEventListener("open", this._handleOpen);
474
- this._ws.removeEventListener("close", this._handleClose);
475
- this._ws.removeEventListener("message", this._handleMessage);
476
- this._ws.removeEventListener("error", this._handleError);
477
- }
478
- _addListeners() {
479
- if (!this._ws) {
480
- return;
481
- }
482
- this._debug("addListeners");
483
- this._ws.addEventListener("open", this._handleOpen);
484
- this._ws.addEventListener("close", this._handleClose);
485
- this._ws.addEventListener("message", this._handleMessage);
486
- this._ws.addEventListener("error", this._handleError);
487
- }
488
- _clearTimeouts() {
489
- clearTimeout(this._connectTimeout);
490
- clearTimeout(this._uptimeTimeout);
132
+ get roomUrl() {
133
+ return this._pkurl;
134
+ }
135
+ // a `fetch` method that uses (almost) the same options as `PartySocket`
136
+ static async fetch(options, init) {
137
+ const party = getPartyInfo(options, "http");
138
+ const url =
139
+ typeof party.urlProvider === "string"
140
+ ? party.urlProvider
141
+ : await party.urlProvider();
142
+ const doFetch = options.fetch ?? fetch;
143
+ return doFetch(url, init);
491
144
  }
492
145
  };
493
- /*!
494
- * Reconnecting WebSocket
495
- * by Pedro Ladaria <pedro.ladaria@gmail.com>
496
- * https://github.com/pladaria/reconnecting-websocket
497
- * License MIT
498
- */
146
+ function getWSOptions(partySocketOptions) {
147
+ const {
148
+ id,
149
+ host: _host,
150
+ path: _path,
151
+ party: _party,
152
+ room: _room,
153
+ protocol: _protocol,
154
+ query: _query,
155
+ protocols,
156
+ ...socketOptions
157
+ } = partySocketOptions;
158
+ const _pk = id || generateUUID();
159
+ const party = getPartyInfo(partySocketOptions, "ws", { _pk });
160
+ return {
161
+ _pk,
162
+ _pkurl: party.partyUrl,
163
+ name: party.name,
164
+ room: party.room,
165
+ host: party.host,
166
+ path: party.path,
167
+ protocols,
168
+ socketOptions,
169
+ urlProvider: party.urlProvider
170
+ };
171
+ }
499
172
 
500
- export { CloseEvent, ErrorEvent, ReconnectingWebSocket };
173
+ export { PartySocket };
501
174
  //# sourceMappingURL=index35.js.map