@rpgjs/client 5.0.0-alpha.5 → 5.0.0-alpha.7
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/index22.js +2 -2
- package/dist/index23.js +1 -1
- package/dist/index29.js +4 -2
- package/dist/index29.js.map +1 -1
- package/dist/index35.js +169 -56
- package/dist/index35.js.map +1 -1
- package/dist/index36.js +489 -162
- package/dist/index36.js.map +1 -1
- package/dist/index37.js +56 -496
- package/dist/index37.js.map +1 -1
- package/package.json +5 -5
- package/src/components/index.ts +1 -1
- package/src/components/scenes/draw-map.ce +2 -1
package/dist/index22.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __name } from './index27.js';
|
|
2
2
|
import { load } from './index18.js';
|
|
3
|
-
import { PartySocket } from './
|
|
4
|
-
import './
|
|
3
|
+
import { PartySocket } from './index35.js';
|
|
4
|
+
import './index36.js';
|
|
5
5
|
|
|
6
6
|
function createConnection(options, roomInstance) {
|
|
7
7
|
const conn = new PartySocket(options);
|
package/dist/index23.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useProps, useDefineProps, signal, animatedSignal, computed, trigger, mount, effect, h, Container, Rect, cond, Text } from 'canvasengine';
|
|
2
|
-
import component$1 from './
|
|
2
|
+
import component$1 from './index37.js';
|
|
3
3
|
import { inject } from './index6.js';
|
|
4
4
|
import { RpgClientEngine } from './index2.js';
|
|
5
5
|
|
package/dist/index29.js
CHANGED
|
@@ -5,10 +5,12 @@ import { RpgClientEngine } from './index2.js';
|
|
|
5
5
|
function component($$props) {
|
|
6
6
|
useProps($$props);
|
|
7
7
|
useDefineProps($$props);
|
|
8
|
-
var
|
|
8
|
+
var _a;
|
|
9
|
+
var engine = inject(RpgClientEngine);
|
|
9
10
|
var effects = engine.effects;
|
|
10
11
|
var map = engine.sceneMap.data;
|
|
11
12
|
var sceneComponent = computed(function () { var _a; return (_a = map()) === null || _a === void 0 ? void 0 : _a.component; });
|
|
13
|
+
(_a = map()) === null || _a === void 0 ? void 0 : _a.params;
|
|
12
14
|
var mapParams = map().params;
|
|
13
15
|
engine.sceneMap.animations;
|
|
14
16
|
var backgroundMusic = { src: mapParams === null || mapParams === void 0 ? void 0 : mapParams.backgroundMusic, autoplay: true, loop: true };
|
|
@@ -17,7 +19,7 @@ signal(map().data);
|
|
|
17
19
|
var scale = (mapParams === null || mapParams === void 0 ? void 0 : mapParams.scale) || 1;
|
|
18
20
|
((mapParams === null || mapParams === void 0 ? void 0 : mapParams.width) || 2048) * scale;
|
|
19
21
|
((mapParams === null || mapParams === void 0 ? void 0 : mapParams.height) || 2048) * scale;
|
|
20
|
-
let $this = h(Container, { sound: backgroundMusic }, [h(Container, { sound: backgroundAmbientSound }), h(sceneComponent(), { data: computed(() => map().data) }), loop(effects, effect => h(Container, null, loop(effect.current, animation => h(effect.component, animation))))]);
|
|
22
|
+
let $this = h(Container, { sound: backgroundMusic }, [h(Container, { sound: backgroundAmbientSound }), h(sceneComponent(), { data: computed(() => map().data), params: computed(() => map().params) }), loop(effects, effect => h(Container, null, loop(effect.current, animation => h(effect.component, animation))))]);
|
|
21
23
|
return $this
|
|
22
24
|
}
|
|
23
25
|
|
package/dist/index29.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index29.js","sources":["../src/components/scenes/draw-map.ce"],"sourcesContent":["<Container sound={backgroundMusic} >\n <Container sound={backgroundAmbientSound} />\n\n <sceneComponent() data={map.@data} />\n \n @for (effect of effects) {\n <Container>\n @for (animation of effect.current) {\n <effect.component ...animation />\n }\n </Container>\n }\n</Container>\n\n<script>\n import { effect, signal, computed, mount } from 'canvasengine'\n import { inject } from \"../../core/inject\";\n import { RpgClientEngine } from \"../../RpgClientEngine\";\n\n const engine = inject(RpgClientEngine);\n const effects = engine.effects\n const map = engine.sceneMap.data\n const sceneComponent = computed(() => map()?.component)\n const mapParams = map().params\n const animations = engine.sceneMap.animations\n const backgroundMusic = { src: mapParams?.backgroundMusic, autoplay: true, loop: true }\n const backgroundAmbientSound = { src: mapParams?.backgroundAmbientSound, autoplay: true, loop: true }\n \n const data = signal(map().data)\n\n const scale = mapParams?.scale || 1\n const worldWidth = (mapParams?.width || 2048) * scale\n const worldHeight = (mapParams?.height || 2048) * scale\n \n const clamp = {\n direction: \"all\"\n }\n</script>"],"names":[],"mappings":";;;;AAQqB,SAAS,SAAS,CAAC,OAAO,EAAE;AACjD,QAAuB,QAAQ,CAAC,OAAO;AACvC,QAA4B,cAAc,CAAC,OAAO;AAClD,QAAQ,IAAI,MAAM,GAAG,MAAM,CAAC,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"index29.js","sources":["../src/components/scenes/draw-map.ce"],"sourcesContent":["<Container sound={backgroundMusic} >\n <Container sound={backgroundAmbientSound} />\n\n <sceneComponent() data={map.@data} params={map.@params} />\n \n @for (effect of effects) {\n <Container>\n @for (animation of effect.current) {\n <effect.component ...animation />\n }\n </Container>\n }\n</Container>\n\n<script>\n import { effect, signal, computed, mount } from 'canvasengine'\n import { inject } from \"../../core/inject\";\n import { RpgClientEngine } from \"../../RpgClientEngine\";\n\n const engine = inject(RpgClientEngine);\n const effects = engine.effects\n const map = engine.sceneMap.data\n const sceneComponent = computed(() => map()?.component)\n const sceneParams = map()?.params\n const mapParams = map().params\n const animations = engine.sceneMap.animations\n const backgroundMusic = { src: mapParams?.backgroundMusic, autoplay: true, loop: true }\n const backgroundAmbientSound = { src: mapParams?.backgroundAmbientSound, autoplay: true, loop: true }\n \n const data = signal(map().data)\n\n const scale = mapParams?.scale || 1\n const worldWidth = (mapParams?.width || 2048) * scale\n const worldHeight = (mapParams?.height || 2048) * scale\n \n const clamp = {\n direction: \"all\"\n }\n</script>"],"names":[],"mappings":";;;;AAQqB,SAAS,SAAS,CAAC,OAAO,EAAE;AACjD,QAAuB,QAAQ,CAAC,OAAO;AACvC,QAA4B,cAAc,CAAC,OAAO;AAClD,QAAQ,IAAI,EAAE;AACd,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GAAG,SAAS,CAAC,MAAM,KAAK,IAAI,IAAI;AAIvG,QAAQ,IAAI,KAAK,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,KAAK,EAAE,eAAe,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,EAAE,EAAE,KAAK,EAAE,sBAAsB,EAAE,CAAC,EAAE,CAAC,CAAC,cAAc,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,CAAC,MAAM,GAAG,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,GAAG,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,OAAO,EAAE,MAAM,IAAI,CAAC,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,SAAS,IAAI,CAAC,CAAC,MAAM,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;AAC/T,QAAQ,OAAO;AACf;;;;"}
|
package/dist/index35.js
CHANGED
|
@@ -1,61 +1,174 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import component$1 from './index39.js';
|
|
3
|
-
import { RpgClientEngine } from './index2.js';
|
|
4
|
-
import { inject } from './index6.js';
|
|
1
|
+
import { ReconnectingWebSocket } from './index36.js';
|
|
5
2
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
+
});
|
|
27
|
+
}
|
|
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
|
+
};
|
|
81
|
+
}
|
|
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
|
|
15
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;
|
|
116
|
+
}
|
|
117
|
+
reconnect(code, reason) {
|
|
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
|
+
);
|
|
122
|
+
}
|
|
123
|
+
super.reconnect(code, reason);
|
|
124
|
+
}
|
|
125
|
+
get id() {
|
|
126
|
+
return this._pk;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Exposes the static PartyKit room URL without applying query parameters.
|
|
130
|
+
* To access the currently connected WebSocket url, use PartySocket#url.
|
|
131
|
+
*/
|
|
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);
|
|
144
|
+
}
|
|
16
145
|
};
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
else {
|
|
44
|
-
return Math.max(currentIndex - 1, 0);
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
enter: {
|
|
50
|
-
bind: keyboardControls.action,
|
|
51
|
-
keyDown: function () {
|
|
52
|
-
onSelect === null || onSelect === void 0 ? void 0 : onSelect(selectedIndex());
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
});
|
|
56
|
-
let $this = h(Container, { controls, flexDirection: 'column', margin: [0, 0, 0, 50] }, loop(items, (item, index) => h(component$1, { text: item.text, isSelected: selected(index) })));
|
|
57
|
-
return $this
|
|
58
|
-
}
|
|
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
|
+
}
|
|
59
172
|
|
|
60
|
-
export {
|
|
173
|
+
export { PartySocket };
|
|
61
174
|
//# sourceMappingURL=index35.js.map
|
package/dist/index35.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index35.js","sources":["../src/components/gui/dialogbox/selection.ce"],"sourcesContent":["<Container controls flexDirection=\"column\" margin={[0, 0, 0, 50]}>\n @for ((item,index) of items) { \n <ItemMenu text={@item.@text} isSelected={@selected(@index)} /> \n }\n</Container>\n\n<script>\n import { signal, computed, mount } from \"canvasengine\";\n import ItemMenu from \"./itemMenu.ce\";\n import { RpgClientEngine } from \"../../../RpgClientEngine\";\n import { inject } from \"../../../core/inject\";\n\n const {\n items,\n wrapAround,\n onSelect,\n selectedIndex,\n } = defineProps();\n\n const client = inject(RpgClientEngine);\n const keyboardControls = client.globalConfig.keyboardControls;\n\n const selected = (index) => {\n return computed(() => {\n return index === selectedIndex();\n })\n }\n\n mount((element) => {\n return () => {\n element.directives.controls.onDestroy()\n }\n })\n\n const controls = signal({\n down: {\n bind: keyboardControls.down,\n keyDown() {\n selectedIndex.update((currentIndex) => {\n if (wrapAround) {\n return (currentIndex + 1) % items().length;\n } else {\n return Math.min(currentIndex + 1, items().length - 1);\n }\n });\n },\n },\n up: {\n bind: keyboardControls.up,\n keyDown() {\n selectedIndex.update((currentIndex) => {\n if (wrapAround) {\n return (currentIndex - 1 + items().length) % items().length;\n } else {\n return Math.max(currentIndex - 1, 0);\n }\n });\n },\n },\n enter: {\n bind: keyboardControls.action,\n keyDown() {\n onSelect?.(selectedIndex());\n },\n },\n });\n</script>\n"],"names":["ItemMenu"],"mappings":";;;;;AASqB,SAAS,SAAS,CAAC,OAAO,EAAE;AACjD,QAAuB,QAAQ,CAAC,OAAO;AACvC,QAAQ,MAAM,WAAW,GAAG,cAAc,CAAC,OAAO;AAClD,QAAQ,IAAI,EAAE,GAAG,WAAW,EAAE,EAAE,KAAK,GAAG,EAAE,CAAC,KAAK,EAAE,UAAU,GAAG,EAAE,CAAC,UAAU,EAAE,QAAQ,GAAG,EAAE,CAAC,QAAQ,EAAE,aAAa,GAAG,EAAE,CAAC,aAAa;AACtI,IAAI,MAAM,GAAG,MAAM,CAAC,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AAC,CAAC;AACxD;AACA,aAAa,CAAC;AACd,SAAS;AACT,KAAK;AACL,IAAI,KAAK,EAAE;AACX,QAAQ,IAAI,EAAE,gBAAgB,CAAC,MAAM;AACrC,QAAQ,OAAO,EAAE,YAAY;AAC7B,YAAY,QAAQ,KAAK,IAAI,IAAI,QAAQ,KAAK,MAAM,GAAG,MAAM,GAAG,QAAQ,CAAC,aAAa,EAAE,CAAC;AACzF,SAAS;AACT,KAAK;AACL,CAAC,CAAC;AACF,QAAQ,IAAI,KAAK,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,QAAQ,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,KAAK,KAAK,CAAC,CAACA,WAAQ,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;AAC1L,QAAQ,OAAO;AACf;;;;"}
|
|
1
|
+
{"version":3,"file":"index35.js","sources":["../../../node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-HAC622V3.mjs"],"sourcesContent":["import { ReconnectingWebSocket } from \"./chunk-S74YV6PU.mjs\";\n\n// src/index.ts\nvar valueIsNotNil = (keyValuePair) =>\n keyValuePair[1] !== null && keyValuePair[1] !== void 0;\nfunction generateUUID() {\n if (typeof crypto !== \"undefined\" && crypto.randomUUID) {\n return crypto.randomUUID();\n }\n let d = /* @__PURE__ */ new Date().getTime();\n let d2 =\n (typeof performance !== \"undefined\" &&\n performance.now &&\n performance.now() * 1e3) ||\n 0;\n return \"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx\".replace(/[xy]/g, function (c) {\n let r = Math.random() * 16;\n if (d > 0) {\n r = (d + r) % 16 | 0;\n d = Math.floor(d / 16);\n } else {\n r = (d2 + r) % 16 | 0;\n d2 = Math.floor(d2 / 16);\n }\n return (c === \"x\" ? r : (r & 3) | 8).toString(16);\n });\n}\nfunction getPartyInfo(partySocketOptions, defaultProtocol, defaultParams = {}) {\n const {\n host: rawHost,\n path: rawPath,\n protocol: rawProtocol,\n room,\n party,\n basePath,\n prefix,\n query\n } = partySocketOptions;\n let host = rawHost.replace(/^(http|https|ws|wss):\\/\\//, \"\");\n if (host.endsWith(\"/\")) {\n host = host.slice(0, -1);\n }\n if (rawPath == null ? void 0 : rawPath.startsWith(\"/\")) {\n throw new Error(\"path must not start with a slash\");\n }\n const name = party ?? \"main\";\n const path = rawPath ? `/${rawPath}` : \"\";\n const protocol =\n rawProtocol ||\n (host.startsWith(\"localhost:\") ||\n host.startsWith(\"127.0.0.1:\") ||\n host.startsWith(\"192.168.\") ||\n host.startsWith(\"10.\") ||\n (host.startsWith(\"172.\") &&\n host.split(\".\")[1] >= \"16\" &&\n host.split(\".\")[1] <= \"31\") ||\n host.startsWith(\"[::ffff:7f00:1]:\")\n ? // http / ws\n defaultProtocol\n : // https / wss\n `${defaultProtocol}s`);\n const baseUrl = `${protocol}://${host}/${basePath || `${prefix || \"parties\"}/${name}/${room}`}${path}`;\n const makeUrl = (query2 = {}) =>\n `${baseUrl}?${new URLSearchParams([\n ...Object.entries(defaultParams),\n ...Object.entries(query2).filter(valueIsNotNil)\n ])}`;\n const urlProvider =\n typeof query === \"function\"\n ? async () => makeUrl(await query())\n : makeUrl(query);\n return {\n host,\n path,\n room,\n name,\n protocol,\n partyUrl: baseUrl,\n urlProvider\n };\n}\nvar PartySocket = class extends ReconnectingWebSocket {\n constructor(partySocketOptions) {\n const wsOptions = getWSOptions(partySocketOptions);\n super(wsOptions.urlProvider, wsOptions.protocols, wsOptions.socketOptions);\n this.partySocketOptions = partySocketOptions;\n this.setWSProperties(wsOptions);\n }\n _pk;\n _pkurl;\n name;\n room;\n host;\n path;\n updateProperties(partySocketOptions) {\n const wsOptions = getWSOptions({\n ...this.partySocketOptions,\n ...partySocketOptions,\n host: partySocketOptions.host ?? this.host,\n room: partySocketOptions.room ?? this.room,\n path: partySocketOptions.path ?? this.path\n });\n this._url = wsOptions.urlProvider;\n this._protocols = wsOptions.protocols;\n this._options = wsOptions.socketOptions;\n this.setWSProperties(wsOptions);\n }\n setWSProperties(wsOptions) {\n const { _pk, _pkurl, name, room, host, path } = wsOptions;\n this._pk = _pk;\n this._pkurl = _pkurl;\n this.name = name;\n this.room = room;\n this.host = host;\n this.path = path;\n }\n reconnect(code, reason) {\n if (!this.room || !this.host) {\n throw new Error(\n \"The room and host must be set before connecting, use `updateProperties` method to set them or pass them to the constructor.\"\n );\n }\n super.reconnect(code, reason);\n }\n get id() {\n return this._pk;\n }\n /**\n * Exposes the static PartyKit room URL without applying query parameters.\n * To access the currently connected WebSocket url, use PartySocket#url.\n */\n get roomUrl() {\n return this._pkurl;\n }\n // a `fetch` method that uses (almost) the same options as `PartySocket`\n static async fetch(options, init) {\n const party = getPartyInfo(options, \"http\");\n const url =\n typeof party.urlProvider === \"string\"\n ? party.urlProvider\n : await party.urlProvider();\n const doFetch = options.fetch ?? fetch;\n return doFetch(url, init);\n }\n};\nfunction getWSOptions(partySocketOptions) {\n const {\n id,\n host: _host,\n path: _path,\n party: _party,\n room: _room,\n protocol: _protocol,\n query: _query,\n protocols,\n ...socketOptions\n } = partySocketOptions;\n const _pk = id || generateUUID();\n const party = getPartyInfo(partySocketOptions, \"ws\", { _pk });\n return {\n _pk,\n _pkurl: party.partyUrl,\n name: party.name,\n room: party.room,\n host: party.host,\n path: party.path,\n protocols,\n socketOptions,\n urlProvider: party.urlProvider\n };\n}\n\nexport { PartySocket };\n//# sourceMappingURL=chunk-HAC622V3.mjs.map\n"],"names":[],"mappings":";;AAEA;AACA,IAAI,aAAa,GAAG,CAAC,YAAY;AACjC,EAAE,YAAY,CAAC,CAAC,CAAC,KAAK,IAAI,IAAI,YAAY,CAAC,CAAC,CAAC,KAAK,MAAM;AACxD,SAA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