@bloopjs/web 0.0.44 → 0.0.45

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/App.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { type Bloop, type MountOpts, type Sim } from "@bloopjs/bloop";
2
+ import { type RoomEvents } from "./netcode/broker";
2
3
  export type StartOptions = {
3
4
  /** A bloop game instance */
4
5
  game: Bloop<any>;
@@ -10,21 +11,49 @@ export type StartOptions = {
10
11
  startPaused?: boolean;
11
12
  /** Whether the sim should be recording to tape from initialization, defaults to true */
12
13
  startRecording?: boolean;
14
+ /** URL for the WebRTC signaling broker (e.g. "wss://broker.example.com/ws") */
15
+ brokerUrl?: string;
13
16
  };
14
17
  /** Start a bloop game on the web */
15
18
  export declare function start(opts: StartOptions): Promise<App>;
19
+ /**
20
+ * The main application class for running a bloop game in the browser
21
+ *
22
+ * This class handles translating browser events and APIs to bloopjs and the wasm engine.
23
+ *
24
+ * Usually instantiated with the start() function
25
+ */
16
26
  export declare class App {
17
27
  #private;
18
28
  game: Bloop<any>;
19
- constructor(sim: Sim, game: Bloop<any>);
29
+ /** URL for the WebRTC signaling broker */
30
+ readonly brokerUrl: string;
31
+ constructor(sim: Sim, game: Bloop<any>, brokerUrl: string);
32
+ /** The simulation instance associated with this app */
20
33
  get sim(): Sim;
21
34
  set sim(sim: Sim);
35
+ /** Join a multiplayer room via the broker */
36
+ joinRoom(roomId: string, callbacks: RoomEvents): void;
37
+ /** Event listeners for before a frame is processed */
22
38
  beforeFrame: ReturnType<typeof createListener>;
39
+ /** Event listeners for after a frame is processed */
23
40
  afterFrame: ReturnType<typeof createListener>;
24
41
  /** Subscribe to the browser events and start the render loop */
25
42
  subscribe(): void;
26
43
  /** Clean up wasm resources and event listeners */
27
44
  cleanup(): void;
45
+ /**
46
+ * Accept Hot Module Replacement when running in a vite dev server
47
+ *
48
+ * @example
49
+ *
50
+ * ```ts
51
+ * import.meta.hot?.accept("./game", async (newModule) => {
52
+ * await app.acceptHmr(newModule?.game, {
53
+ * wasmUrl: monorepoWasmUrl,
54
+ * });
55
+ * ```
56
+ */
28
57
  acceptHmr(module: any, opts?: Partial<MountOpts>): Promise<void>;
29
58
  }
30
59
  declare function createListener<T extends any[]>(): {
package/dist/App.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../src/App.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,KAAK,EAAE,KAAK,SAAS,EAAS,KAAK,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAI7E,MAAM,MAAM,YAAY,GAAG;IACzB,4BAA4B;IAC5B,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;IACjB,yEAAyE;IACzE,GAAG,CAAC,EAAE,GAAG,CAAC;IACV,sDAAsD;IACtD,aAAa,CAAC,EAAE,GAAG,CAAC;IACpB,qFAAqF;IACrF,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,wFAAwF;IACxF,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B,CAAC;AAEF,oCAAoC;AACpC,wBAAsB,KAAK,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,CAY5D;AAED,qBAAa,GAAG;;IAEd,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;gBAML,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC;IAWtC,IAAI,GAAG,IAAI,GAAG,CAEb;IAED,IAAI,GAAG,CAAC,GAAG,EAAE,GAAG,EAEf;IAED,WAAW,EAAE,UAAU,CAAC,OAAO,cAAc,CAAC,CAA8B;IAC5E,UAAU,EAAE,UAAU,CAAC,OAAO,cAAc,CAAC,CAA8B;IAE3E,gEAAgE;IAChE,SAAS,IAAI,IAAI;IA2GjB,kDAAkD;IAClD,OAAO,IAAI,IAAI;IAOT,SAAS,CAAC,MAAM,EAAE,GAAG,EAAE,I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AG,EAAE,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,EAAE,SAAS,EAAE,MAAM;IAczD,uDAAuD;IACvD,IAAI,GAAG,IAAI,GAAG,CAEb;IAED,IAAI,GAAG,CAAC,GAAG,EAAE,GAAG,EAEf;IAED,6CAA6C;IAC7C,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,GAAG,IAAI;IAIrD,sDAAsD;IACtD,WAAW,EAAE,UAAU,CAAC,OAAO,cAAc,CAAC,CAA8B;IAC5E,qDAAqD;IACrD,UAAU,EAAE,UAAU,CAAC,OAAO,cAAc,CAAC,CAA8B;IAE3E,gEAAgE;IAChE,SAAS,IAAI,IAAI;IA2GjB,kDAAkD;IAClD,OAAO,IAAI,IAAI;IAOf;;;;;;;;;;;OAWG;IACG,SAAS,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;CAoBvE;AAED,iBAAS,cAAc,CAAC,CAAC,SAAS,GAAG,EAAE,KAAK;IAC1C,SAAS,EAAE,CAAC,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,IAAI,KAAK,aAAa,CAAC;IAC7D,MAAM,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,IAAI,CAAC;IAC7B,cAAc,EAAE,aAAa,CAAC;CAC/B,CAuBA;AAED,MAAM,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC"}
package/dist/mod.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export { App, start } from "./App.ts";
2
+ export * from "./netcode/mod.ts";
2
3
  //# sourceMappingURL=mod.d.ts.map
package/dist/mod.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC"}
1
+ {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACtC,cAAc,kBAAkB,CAAC"}