@rpgjs/client 5.0.0-beta.15 → 5.0.0-beta.17

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.
@@ -534,7 +534,8 @@
534
534
  });
535
535
 
536
536
  const z = computed(() => {
537
- return sprite.y() + sprite.z()
537
+ const box = hitbox?.()
538
+ return sprite.y() + (box?.h ?? 0) + sprite.z()
538
539
  });
539
540
 
540
541
  const realAnimationName = signal(animationName());
@@ -9,8 +9,11 @@ export type SocketUpdateProperties = {
9
9
  host?: string;
10
10
  query?: SocketQuery;
11
11
  };
12
+ export type WebSocketMode = "standalone" | "mmorpg";
12
13
 
13
14
  export abstract class AbstractWebsocket {
15
+ readonly mode?: WebSocketMode;
16
+
14
17
  constructor(protected context: Context) {}
15
18
 
16
19
  abstract connection(listeners?: (data: any) => void): Promise<void>;
@@ -17,6 +17,8 @@ export interface MmorpgOptions {
17
17
  }
18
18
 
19
19
  export class BridgeWebsocket extends AbstractWebsocket {
20
+ readonly mode = "mmorpg" as const;
21
+
20
22
  private socket: any;
21
23
  private privateId: string;
22
24
  private pendingOn: Array<{ event: string; callback: (data: any) => void }> = [];
@@ -1,4 +1,10 @@
1
+ // @vitest-environment jsdom
2
+
1
3
  import { describe, expect, test, vi } from "vitest";
4
+ import { Context } from "@signe/di";
5
+ import { WebSocketToken } from "./AbstractSocket";
6
+ import { provideMmorpg } from "./mmorpg";
7
+ import { provideRpg } from "./standalone";
2
8
  import { normalizeStandaloneMessage } from "./standalone-message";
3
9
 
4
10
  describe("standalone websocket bridge", () => {
@@ -31,4 +37,18 @@ describe("standalone websocket bridge", () => {
31
37
  value: { projectiles: [] },
32
38
  });
33
39
  });
40
+
41
+ test("marks standalone and MMORPG websocket providers with their runtime mode", () => {
42
+ class Server {}
43
+ const context = new Context();
44
+ const standaloneProvider = provideRpg(Server).find(
45
+ (provider: any) => provider.provide === WebSocketToken,
46
+ ) as any;
47
+ const mmorpgProvider = provideMmorpg({ connectionId: "test-client" }).find(
48
+ (provider: any) => provider.provide === WebSocketToken,
49
+ ) as any;
50
+
51
+ expect(standaloneProvider.useFactory(context).mode).toBe("standalone");
52
+ expect(mmorpgProvider.useFactory(context).mode).toBe("mmorpg");
53
+ });
34
54
  });
@@ -17,6 +17,8 @@ interface StandaloneOptions {
17
17
  }
18
18
 
19
19
  class BridgeWebsocket extends AbstractWebsocket {
20
+ readonly mode = "standalone" as const;
21
+
20
22
  private room: ServerIo;
21
23
  private socket: ClientIo;
22
24
  private socketRoom?: ServerIo;