@rpgjs/client 5.0.0-alpha.43 → 5.0.0-alpha.44
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/Game/AnimationManager.js +25 -24
- package/dist/Game/AnimationManager.js.map +1 -1
- package/dist/Game/Event.js +11 -10
- package/dist/Game/Event.js.map +1 -1
- package/dist/Game/Map.js +78 -94
- package/dist/Game/Map.js.map +1 -1
- package/dist/Game/Object.js +182 -216
- package/dist/Game/Object.js.map +1 -1
- package/dist/Game/Player.js +11 -10
- package/dist/Game/Player.js.map +1 -1
- package/dist/Gui/Gui.js +440 -473
- package/dist/Gui/Gui.js.map +1 -1
- package/dist/Gui/NotificationManager.js +48 -50
- package/dist/Gui/NotificationManager.js.map +1 -1
- package/dist/Resource.js +132 -113
- package/dist/Resource.js.map +1 -1
- package/dist/RpgClientEngine.js +1333 -1486
- package/dist/RpgClientEngine.js.map +1 -1
- package/dist/Sound.js +162 -92
- package/dist/Sound.js.map +1 -1
- package/dist/_virtual/_@oxc-project_runtime@0.115.0/helpers/decorate.js +9 -0
- package/dist/_virtual/_@oxc-project_runtime@0.115.0/helpers/decorateMetadata.js +6 -0
- package/dist/components/animations/animation.ce.js +22 -19
- package/dist/components/animations/animation.ce.js.map +1 -1
- package/dist/components/animations/hit.ce.js +67 -68
- package/dist/components/animations/hit.ce.js.map +1 -1
- package/dist/components/animations/index.js +9 -8
- package/dist/components/animations/index.js.map +1 -1
- package/dist/components/character.ce.js +390 -314
- package/dist/components/character.ce.js.map +1 -1
- package/dist/components/dynamics/parse-value.js +42 -52
- package/dist/components/dynamics/parse-value.js.map +1 -1
- package/dist/components/dynamics/text.ce.js +71 -139
- package/dist/components/dynamics/text.ce.js.map +1 -1
- package/dist/components/gui/box.ce.js +26 -25
- package/dist/components/gui/box.ce.js.map +1 -1
- package/dist/components/gui/dialogbox/index.ce.js +202 -149
- package/dist/components/gui/dialogbox/index.ce.js.map +1 -1
- package/dist/components/gui/gameover.ce.js +190 -138
- package/dist/components/gui/gameover.ce.js.map +1 -1
- package/dist/components/gui/hud/hud.ce.js +90 -33
- package/dist/components/gui/hud/hud.ce.js.map +1 -1
- package/dist/components/gui/index.js +14 -0
- package/dist/components/gui/menu/equip-menu.ce.js +478 -346
- package/dist/components/gui/menu/equip-menu.ce.js.map +1 -1
- package/dist/components/gui/menu/exit-menu.ce.js +52 -33
- package/dist/components/gui/menu/exit-menu.ce.js.map +1 -1
- package/dist/components/gui/menu/items-menu.ce.js +341 -226
- package/dist/components/gui/menu/items-menu.ce.js.map +1 -1
- package/dist/components/gui/menu/main-menu.ce.js +414 -205
- package/dist/components/gui/menu/main-menu.ce.js.map +1 -1
- package/dist/components/gui/menu/options-menu.ce.js +46 -26
- package/dist/components/gui/menu/options-menu.ce.js.map +1 -1
- package/dist/components/gui/menu/skills-menu.ce.js +104 -50
- package/dist/components/gui/menu/skills-menu.ce.js.map +1 -1
- package/dist/components/gui/mobile/index.js +18 -21
- package/dist/components/gui/mobile/index.js.map +1 -1
- package/dist/components/gui/mobile/mobile.ce.js +76 -15
- package/dist/components/gui/mobile/mobile.ce.js.map +1 -1
- package/dist/components/gui/notification/notification.ce.js +62 -36
- package/dist/components/gui/notification/notification.ce.js.map +1 -1
- package/dist/components/gui/save-load.ce.js +386 -239
- package/dist/components/gui/save-load.ce.js.map +1 -1
- package/dist/components/gui/shop/shop.ce.js +649 -319
- package/dist/components/gui/shop/shop.ce.js.map +1 -1
- package/dist/components/gui/title-screen.ce.js +187 -145
- package/dist/components/gui/title-screen.ce.js.map +1 -1
- package/dist/components/index.js +4 -0
- package/dist/components/prebuilt/hp-bar.ce.js +114 -104
- package/dist/components/prebuilt/hp-bar.ce.js.map +1 -1
- package/dist/components/prebuilt/index.js +2 -0
- package/dist/components/prebuilt/light-halo.ce.js +92 -74
- package/dist/components/prebuilt/light-halo.ce.js.map +1 -1
- package/dist/components/scenes/canvas.ce.js +58 -42
- package/dist/components/scenes/canvas.ce.js.map +1 -1
- package/dist/components/scenes/draw-map.ce.js +87 -64
- package/dist/components/scenes/draw-map.ce.js.map +1 -1
- package/dist/components/scenes/event-layer.ce.js +26 -16
- package/dist/components/scenes/event-layer.ce.js.map +1 -1
- package/dist/core/inject.js +11 -10
- package/dist/core/inject.js.map +1 -1
- package/dist/core/setup.js +13 -13
- package/dist/core/setup.js.map +1 -1
- package/dist/index.js +44 -41
- package/dist/module.js +169 -168
- package/dist/module.js.map +1 -1
- package/dist/node_modules/.pnpm/@signe_di@2.8.3/node_modules/@signe/di/dist/index.js +209 -298
- package/dist/node_modules/.pnpm/@signe_di@2.8.3/node_modules/@signe/di/dist/index.js.map +1 -1
- package/dist/node_modules/.pnpm/@signe_reactive@2.8.3/node_modules/@signe/reactive/dist/index.js +430 -507
- package/dist/node_modules/.pnpm/@signe_reactive@2.8.3/node_modules/@signe/reactive/dist/index.js.map +1 -1
- package/dist/node_modules/.pnpm/@signe_room@2.8.3/node_modules/@signe/room/dist/index.js +2062 -2571
- package/dist/node_modules/.pnpm/@signe_room@2.8.3/node_modules/@signe/room/dist/index.js.map +1 -1
- package/dist/node_modules/.pnpm/@signe_sync@2.8.3/node_modules/@signe/sync/dist/chunk-7QVYU63E.js +8 -3
- package/dist/node_modules/.pnpm/@signe_sync@2.8.3/node_modules/@signe/sync/dist/chunk-7QVYU63E.js.map +1 -1
- package/dist/node_modules/.pnpm/@signe_sync@2.8.3/node_modules/@signe/sync/dist/client/index.js +78 -101
- package/dist/node_modules/.pnpm/@signe_sync@2.8.3/node_modules/@signe/sync/dist/client/index.js.map +1 -1
- package/dist/node_modules/.pnpm/@signe_sync@2.8.3/node_modules/@signe/sync/dist/index.js +264 -401
- package/dist/node_modules/.pnpm/@signe_sync@2.8.3/node_modules/@signe/sync/dist/index.js.map +1 -1
- package/dist/node_modules/.pnpm/dset@3.1.4/node_modules/dset/dist/index.js +9 -7
- package/dist/node_modules/.pnpm/dset@3.1.4/node_modules/dset/dist/index.js.map +1 -1
- package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-HAC622V3.js +106 -165
- package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-HAC622V3.js.map +1 -1
- package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-S74YV6PU.js +361 -461
- package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-S74YV6PU.js.map +1 -1
- package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/index.js +2 -0
- package/dist/node_modules/.pnpm/zod@3.24.2/node_modules/zod/lib/index.js +3633 -4280
- package/dist/node_modules/.pnpm/zod@3.24.2/node_modules/zod/lib/index.js.map +1 -1
- package/dist/presets/animation.js +37 -25
- package/dist/presets/animation.js.map +1 -1
- package/dist/presets/faceset.js +49 -22
- package/dist/presets/faceset.js.map +1 -1
- package/dist/presets/icon.js +13 -13
- package/dist/presets/icon.js.map +1 -1
- package/dist/presets/index.js +15 -14
- package/dist/presets/index.js.map +1 -1
- package/dist/presets/lpc.js +96 -93
- package/dist/presets/lpc.js.map +1 -1
- package/dist/presets/rmspritesheet.js +40 -39
- package/dist/presets/rmspritesheet.js.map +1 -1
- package/dist/services/AbstractSocket.js +10 -8
- package/dist/services/AbstractSocket.js.map +1 -1
- package/dist/services/keyboardControls.js +20 -18
- package/dist/services/keyboardControls.js.map +1 -1
- package/dist/services/loadMap.js +120 -36
- package/dist/services/loadMap.js.map +1 -1
- package/dist/services/mmorpg.js +128 -136
- package/dist/services/mmorpg.js.map +1 -1
- package/dist/services/save.js +74 -66
- package/dist/services/save.js.map +1 -1
- package/dist/services/standalone.js +165 -167
- package/dist/services/standalone.js.map +1 -1
- package/dist/utils/getEntityProp.js +49 -51
- package/dist/utils/getEntityProp.js.map +1 -1
- package/package.json +8 -8
- package/src/components/character.ce +1 -1
- package/src/components/scenes/draw-map.ce +3 -1
- package/dist/index.js.map +0 -1
package/dist/node_modules/.pnpm/@signe_sync@2.8.3/node_modules/@signe/sync/dist/chunk-7QVYU63E.js
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
+
//#region ../../node_modules/.pnpm/@signe+sync@2.8.3/node_modules/@signe/sync/dist/chunk-7QVYU63E.js
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", {
|
|
3
|
-
|
|
3
|
+
var __name = (target, value) => __defProp(target, "name", {
|
|
4
|
+
value,
|
|
5
|
+
configurable: true
|
|
6
|
+
});
|
|
7
|
+
//#endregion
|
|
4
8
|
export { __name };
|
|
5
|
-
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=chunk-7QVYU63E.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chunk-7QVYU63E.js","sources":["../../../../../../../../../../node_modules/.pnpm/@signe+sync@2.8.3/node_modules/@signe/sync/dist/chunk-7QVYU63E.js"],"sourcesContent":["var __defProp = Object.defineProperty;\nvar __name = (target, value) => __defProp(target, \"name\", { value, configurable: true });\n\nexport {\n __name\n};\n//# sourceMappingURL=chunk-7QVYU63E.js.map"],"
|
|
1
|
+
{"version":3,"file":"chunk-7QVYU63E.js","names":[],"sources":["../../../../../../../../../../node_modules/.pnpm/@signe+sync@2.8.3/node_modules/@signe/sync/dist/chunk-7QVYU63E.js"],"sourcesContent":["var __defProp = Object.defineProperty;\nvar __name = (target, value) => __defProp(target, \"name\", { value, configurable: true });\n\nexport {\n __name\n};\n//# sourceMappingURL=chunk-7QVYU63E.js.map"],"x_google_ignoreList":[0],"mappings":";AAAA,IAAI,YAAY,OAAO;AACvB,IAAI,UAAU,QAAQ,UAAU,UAAU,QAAQ,QAAQ;CAAE;CAAO,cAAc;CAAM,CAAC"}
|
package/dist/node_modules/.pnpm/@signe_sync@2.8.3/node_modules/@signe/sync/dist/client/index.js
CHANGED
|
@@ -1,114 +1,91 @@
|
|
|
1
|
-
import { __name } from
|
|
2
|
-
import { load } from
|
|
3
|
-
import { PartySocket } from
|
|
4
|
-
import
|
|
5
|
-
|
|
1
|
+
import { __name } from "../chunk-7QVYU63E.js";
|
|
2
|
+
import { load } from "../index.js";
|
|
3
|
+
import { PartySocket } from "../../../../../../partysocket@1.1.3/node_modules/partysocket/dist/chunk-HAC622V3.js";
|
|
4
|
+
import "../../../../../../partysocket@1.1.3/node_modules/partysocket/dist/index.js";
|
|
5
|
+
//#region ../../node_modules/.pnpm/@signe+sync@2.8.3/node_modules/@signe/sync/dist/client/index.js
|
|
6
6
|
function createConnection(options, roomInstance) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}, "off"),
|
|
39
|
-
close: /* @__PURE__ */ __name(() => conn.close(), "close"),
|
|
40
|
-
conn
|
|
41
|
-
};
|
|
7
|
+
const conn = new PartySocket(options);
|
|
8
|
+
conn.addEventListener("message", (event) => {
|
|
9
|
+
const object = JSON.parse(event.data);
|
|
10
|
+
switch (object.type) {
|
|
11
|
+
case "sync":
|
|
12
|
+
load(roomInstance, object.value, true);
|
|
13
|
+
break;
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
return {
|
|
17
|
+
emit: /* @__PURE__ */ __name((key, value) => {
|
|
18
|
+
conn.send(JSON.stringify({
|
|
19
|
+
action: key,
|
|
20
|
+
value
|
|
21
|
+
}));
|
|
22
|
+
}, "emit"),
|
|
23
|
+
on: /* @__PURE__ */ __name((key, cb) => {
|
|
24
|
+
conn.addEventListener("message", (event) => {
|
|
25
|
+
const object = JSON.parse(event.data);
|
|
26
|
+
if (object.type === key) cb(object.value);
|
|
27
|
+
});
|
|
28
|
+
}, "on"),
|
|
29
|
+
off: /* @__PURE__ */ __name((key, cb) => {
|
|
30
|
+
conn.removeEventListener("message", (event) => {
|
|
31
|
+
const object = JSON.parse(event.data);
|
|
32
|
+
if (object.type === key) cb(object.value);
|
|
33
|
+
});
|
|
34
|
+
}, "off"),
|
|
35
|
+
close: /* @__PURE__ */ __name(() => conn.close(), "close"),
|
|
36
|
+
conn
|
|
37
|
+
};
|
|
42
38
|
}
|
|
43
39
|
__name(createConnection, "createConnection");
|
|
44
40
|
async function connectionRoom(options, roomInstance) {
|
|
45
|
-
|
|
41
|
+
return createConnection(options, roomInstance);
|
|
46
42
|
}
|
|
47
43
|
__name(connectionRoom, "connectionRoom");
|
|
48
44
|
async function connectionWorld(options, roomInstance) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
};
|
|
45
|
+
const shardInfo = await getOptimalShard(options);
|
|
46
|
+
return {
|
|
47
|
+
...createConnection({
|
|
48
|
+
...options,
|
|
49
|
+
party: "shard",
|
|
50
|
+
room: shardInfo.url
|
|
51
|
+
}, roomInstance),
|
|
52
|
+
shardInfo
|
|
53
|
+
};
|
|
59
54
|
}
|
|
60
55
|
__name(connectionWorld, "connectionWorld");
|
|
61
56
|
async function getOptimalShard(worldOptions) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
const data = await response.json();
|
|
93
|
-
if (!data.url || !data.shardId) {
|
|
94
|
-
throw new Error("Invalid response from World service: missing url or shardId");
|
|
95
|
-
}
|
|
96
|
-
return {
|
|
97
|
-
shardId: data.shardId,
|
|
98
|
-
url: data.url
|
|
99
|
-
};
|
|
100
|
-
} catch (error) {
|
|
101
|
-
attempts++;
|
|
102
|
-
if (attempts >= retryCount) {
|
|
103
|
-
throw error;
|
|
104
|
-
}
|
|
105
|
-
console.warn(`Failed to get shard (attempt ${attempts}/${retryCount}). Retrying in ${retryDelay}ms...`);
|
|
106
|
-
await new Promise((resolve) => setTimeout(resolve, retryDelay));
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
throw new Error("Failed to get shard after all retry attempts");
|
|
57
|
+
const { host, room, worldId = "world-default", retryCount = 3, retryDelay = 1e3, autoCreate = true } = worldOptions;
|
|
58
|
+
let attempts = 0;
|
|
59
|
+
const requestUrl = new URL(`${host}/parties/world/${encodeURIComponent(worldId)}/connect`).toString();
|
|
60
|
+
while (attempts < retryCount) try {
|
|
61
|
+
const response = await fetch(requestUrl, {
|
|
62
|
+
method: "POST",
|
|
63
|
+
headers: { "Content-Type": "application/json" },
|
|
64
|
+
body: JSON.stringify({
|
|
65
|
+
roomId: room,
|
|
66
|
+
autoCreate
|
|
67
|
+
})
|
|
68
|
+
});
|
|
69
|
+
if (!response.ok) {
|
|
70
|
+
const errorData = await response.json().catch(() => ({ error: "Unknown error" }));
|
|
71
|
+
throw new Error(`World service returned ${response.status}: ${errorData.error || "Unknown error"}`);
|
|
72
|
+
}
|
|
73
|
+
const data = await response.json();
|
|
74
|
+
if (!data.url || !data.shardId) throw new Error("Invalid response from World service: missing url or shardId");
|
|
75
|
+
return {
|
|
76
|
+
shardId: data.shardId,
|
|
77
|
+
url: data.url
|
|
78
|
+
};
|
|
79
|
+
} catch (error) {
|
|
80
|
+
attempts++;
|
|
81
|
+
if (attempts >= retryCount) throw error;
|
|
82
|
+
console.warn(`Failed to get shard (attempt ${attempts}/${retryCount}). Retrying in ${retryDelay}ms...`);
|
|
83
|
+
await new Promise((resolve) => setTimeout(resolve, retryDelay));
|
|
84
|
+
}
|
|
85
|
+
throw new Error("Failed to get shard after all retry attempts");
|
|
110
86
|
}
|
|
111
87
|
__name(getOptimalShard, "getOptimalShard");
|
|
88
|
+
//#endregion
|
|
89
|
+
export { connectionRoom };
|
|
112
90
|
|
|
113
|
-
|
|
114
|
-
//# sourceMappingURL=index.js.map
|
|
91
|
+
//# sourceMappingURL=index.js.map
|
package/dist/node_modules/.pnpm/@signe_sync@2.8.3/node_modules/@signe/sync/dist/client/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../../../../../../../node_modules/.pnpm/@signe+sync@2.8.3/node_modules/@signe/sync/dist/client/index.js"],"sourcesContent":["import {\n __name\n} from \"../chunk-7QVYU63E.js\";\n\n// src/client/index.ts\nimport { load } from \"@signe/sync\";\nimport PartySocket from \"partysocket\";\nfunction createConnection(options, roomInstance) {\n const conn = new PartySocket(options);\n conn.addEventListener(\"message\", (event) => {\n const object = JSON.parse(event.data);\n switch (object.type) {\n case \"sync\":\n load(roomInstance, object.value, true);\n break;\n }\n });\n return {\n emit: /* @__PURE__ */ __name((key, value) => {\n conn.send(JSON.stringify({\n action: key,\n value\n }));\n }, \"emit\"),\n on: /* @__PURE__ */ __name((key, cb) => {\n conn.addEventListener(\"message\", (event) => {\n const object = JSON.parse(event.data);\n if (object.type === key) {\n cb(object.value);\n }\n });\n }, \"on\"),\n off: /* @__PURE__ */ __name((key, cb) => {\n conn.removeEventListener(\"message\", (event) => {\n const object = JSON.parse(event.data);\n if (object.type === key) {\n cb(object.value);\n }\n });\n }, \"off\"),\n close: /* @__PURE__ */ __name(() => conn.close(), \"close\"),\n conn\n };\n}\n__name(createConnection, \"createConnection\");\nasync function connectionRoom(options, roomInstance) {\n return createConnection(options, roomInstance);\n}\n__name(connectionRoom, \"connectionRoom\");\nasync function connectionWorld(options, roomInstance) {\n const shardInfo = await getOptimalShard(options);\n const result = createConnection({\n ...options,\n party: \"shard\",\n room: shardInfo.url\n }, roomInstance);\n return {\n ...result,\n shardInfo\n };\n}\n__name(connectionWorld, \"connectionWorld\");\nasync function getOptimalShard(worldOptions) {\n const {\n host,\n room,\n worldId = \"world-default\",\n retryCount = 3,\n retryDelay = 1e3,\n autoCreate = true\n // Default to true for auto-creation\n } = worldOptions;\n let attempts = 0;\n const url = new URL(`${host}/parties/world/${encodeURIComponent(worldId)}/connect`);\n const requestUrl = url.toString();\n while (attempts < retryCount) {\n try {\n const response = await fetch(requestUrl, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\"\n },\n body: JSON.stringify({\n roomId: room,\n autoCreate\n })\n });\n if (!response.ok) {\n const errorData = await response.json().catch(() => ({\n error: \"Unknown error\"\n }));\n throw new Error(`World service returned ${response.status}: ${errorData.error || \"Unknown error\"}`);\n }\n const data = await response.json();\n if (!data.url || !data.shardId) {\n throw new Error(\"Invalid response from World service: missing url or shardId\");\n }\n return {\n shardId: data.shardId,\n url: data.url\n };\n } catch (error) {\n attempts++;\n if (attempts >= retryCount) {\n throw error;\n }\n console.warn(`Failed to get shard (attempt ${attempts}/${retryCount}). Retrying in ${retryDelay}ms...`);\n await new Promise((resolve) => setTimeout(resolve, retryDelay));\n }\n }\n throw new Error(\"Failed to get shard after all retry attempts\");\n}\n__name(getOptimalShard, \"getOptimalShard\");\nexport {\n PartySocket,\n connectionRoom,\n connectionWorld\n};\n//# sourceMappingURL=index.js.map"],"
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../../../../../../../../node_modules/.pnpm/@signe+sync@2.8.3/node_modules/@signe/sync/dist/client/index.js"],"sourcesContent":["import {\n __name\n} from \"../chunk-7QVYU63E.js\";\n\n// src/client/index.ts\nimport { load } from \"@signe/sync\";\nimport PartySocket from \"partysocket\";\nfunction createConnection(options, roomInstance) {\n const conn = new PartySocket(options);\n conn.addEventListener(\"message\", (event) => {\n const object = JSON.parse(event.data);\n switch (object.type) {\n case \"sync\":\n load(roomInstance, object.value, true);\n break;\n }\n });\n return {\n emit: /* @__PURE__ */ __name((key, value) => {\n conn.send(JSON.stringify({\n action: key,\n value\n }));\n }, \"emit\"),\n on: /* @__PURE__ */ __name((key, cb) => {\n conn.addEventListener(\"message\", (event) => {\n const object = JSON.parse(event.data);\n if (object.type === key) {\n cb(object.value);\n }\n });\n }, \"on\"),\n off: /* @__PURE__ */ __name((key, cb) => {\n conn.removeEventListener(\"message\", (event) => {\n const object = JSON.parse(event.data);\n if (object.type === key) {\n cb(object.value);\n }\n });\n }, \"off\"),\n close: /* @__PURE__ */ __name(() => conn.close(), \"close\"),\n conn\n };\n}\n__name(createConnection, \"createConnection\");\nasync function connectionRoom(options, roomInstance) {\n return createConnection(options, roomInstance);\n}\n__name(connectionRoom, \"connectionRoom\");\nasync function connectionWorld(options, roomInstance) {\n const shardInfo = await getOptimalShard(options);\n const result = createConnection({\n ...options,\n party: \"shard\",\n room: shardInfo.url\n }, roomInstance);\n return {\n ...result,\n shardInfo\n };\n}\n__name(connectionWorld, \"connectionWorld\");\nasync function getOptimalShard(worldOptions) {\n const {\n host,\n room,\n worldId = \"world-default\",\n retryCount = 3,\n retryDelay = 1e3,\n autoCreate = true\n // Default to true for auto-creation\n } = worldOptions;\n let attempts = 0;\n const url = new URL(`${host}/parties/world/${encodeURIComponent(worldId)}/connect`);\n const requestUrl = url.toString();\n while (attempts < retryCount) {\n try {\n const response = await fetch(requestUrl, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\"\n },\n body: JSON.stringify({\n roomId: room,\n autoCreate\n })\n });\n if (!response.ok) {\n const errorData = await response.json().catch(() => ({\n error: \"Unknown error\"\n }));\n throw new Error(`World service returned ${response.status}: ${errorData.error || \"Unknown error\"}`);\n }\n const data = await response.json();\n if (!data.url || !data.shardId) {\n throw new Error(\"Invalid response from World service: missing url or shardId\");\n }\n return {\n shardId: data.shardId,\n url: data.url\n };\n } catch (error) {\n attempts++;\n if (attempts >= retryCount) {\n throw error;\n }\n console.warn(`Failed to get shard (attempt ${attempts}/${retryCount}). Retrying in ${retryDelay}ms...`);\n await new Promise((resolve) => setTimeout(resolve, retryDelay));\n }\n }\n throw new Error(\"Failed to get shard after all retry attempts\");\n}\n__name(getOptimalShard, \"getOptimalShard\");\nexport {\n PartySocket,\n connectionRoom,\n connectionWorld\n};\n//# sourceMappingURL=index.js.map"],"x_google_ignoreList":[0],"mappings":";;;;;AAOA,SAAS,iBAAiB,SAAS,cAAc;CAC/C,MAAM,OAAO,IAAI,YAAY,QAAQ;AACrC,MAAK,iBAAiB,YAAY,UAAU;EAC1C,MAAM,SAAS,KAAK,MAAM,MAAM,KAAK;AACrC,UAAQ,OAAO,MAAf;GACE,KAAK;AACH,SAAK,cAAc,OAAO,OAAO,KAAK;AACtC;;GAEJ;AACF,QAAO;EACL,MAAsB,wBAAQ,KAAK,UAAU;AAC3C,QAAK,KAAK,KAAK,UAAU;IACvB,QAAQ;IACR;IACD,CAAC,CAAC;KACF,OAAO;EACV,IAAoB,wBAAQ,KAAK,OAAO;AACtC,QAAK,iBAAiB,YAAY,UAAU;IAC1C,MAAM,SAAS,KAAK,MAAM,MAAM,KAAK;AACrC,QAAI,OAAO,SAAS,IAClB,IAAG,OAAO,MAAM;KAElB;KACD,KAAK;EACR,KAAqB,wBAAQ,KAAK,OAAO;AACvC,QAAK,oBAAoB,YAAY,UAAU;IAC7C,MAAM,SAAS,KAAK,MAAM,MAAM,KAAK;AACrC,QAAI,OAAO,SAAS,IAClB,IAAG,OAAO,MAAM;KAElB;KACD,MAAM;EACT,OAAuB,6BAAa,KAAK,OAAO,EAAE,QAAQ;EAC1D;EACD;;AAEH,OAAO,kBAAkB,mBAAmB;AAC5C,eAAe,eAAe,SAAS,cAAc;AACnD,QAAO,iBAAiB,SAAS,aAAa;;AAEhD,OAAO,gBAAgB,iBAAiB;AACxC,eAAe,gBAAgB,SAAS,cAAc;CACpD,MAAM,YAAY,MAAM,gBAAgB,QAAQ;AAMhD,QAAO;EACL,GANa,iBAAiB;GAC9B,GAAG;GACH,OAAO;GACP,MAAM,UAAU;GACjB,EAAE,aAAa;EAGd;EACD;;AAEH,OAAO,iBAAiB,kBAAkB;AAC1C,eAAe,gBAAgB,cAAc;CAC3C,MAAM,EACJ,MACA,MACA,UAAU,iBACV,aAAa,GACb,aAAa,KACb,aAAa,SAEX;CACJ,IAAI,WAAW;CAEf,MAAM,aADM,IAAI,IAAI,GAAG,KAAK,iBAAiB,mBAAmB,QAAQ,CAAC,UAAU,CAC5D,UAAU;AACjC,QAAO,WAAW,WAChB,KAAI;EACF,MAAM,WAAW,MAAM,MAAM,YAAY;GACvC,QAAQ;GACR,SAAS,EACP,gBAAgB,oBACjB;GACD,MAAM,KAAK,UAAU;IACnB,QAAQ;IACR;IACD,CAAC;GACH,CAAC;AACF,MAAI,CAAC,SAAS,IAAI;GAChB,MAAM,YAAY,MAAM,SAAS,MAAM,CAAC,aAAa,EACnD,OAAO,iBACR,EAAE;AACH,SAAM,IAAI,MAAM,0BAA0B,SAAS,OAAO,IAAI,UAAU,SAAS,kBAAkB;;EAErG,MAAM,OAAO,MAAM,SAAS,MAAM;AAClC,MAAI,CAAC,KAAK,OAAO,CAAC,KAAK,QACrB,OAAM,IAAI,MAAM,8DAA8D;AAEhF,SAAO;GACL,SAAS,KAAK;GACd,KAAK,KAAK;GACX;UACM,OAAO;AACd;AACA,MAAI,YAAY,WACd,OAAM;AAER,UAAQ,KAAK,gCAAgC,SAAS,GAAG,WAAW,iBAAiB,WAAW,OAAO;AACvG,QAAM,IAAI,SAAS,YAAY,WAAW,SAAS,WAAW,CAAC;;AAGnE,OAAM,IAAI,MAAM,+CAA+C;;AAEjE,OAAO,iBAAiB,kBAAkB"}
|