Back to Browser Side Quest
SOURCE / PINNED RELEASE

Made of little things.

Browser Side Quest

Release
b9d42f5768e4…
Author-recorded commit
c267690145fa…
License
LICENSE
Author’s source reference
nostr://npub1ye5ptcxfyyxl5vjvdjar2ua3f0hynkjzpx552mu5snj3qmx5pzjscpknpr/wss%3A%2F%2Fgit.shakespeare.diy%2F/browser-side-quest

Archive hash verified: 6d4b90b8a5f328f7…. The source-to-build association is the author’s claim; it has not been independently rebuilt.

src/net/solo.ts
import { serverMapData } from '../client/assets.js';
import type { WorldProvider } from '../client/app.js';
import { World } from '../sim/world.js';
import { LocalTransport } from './local.js';
import type { Transport } from './transport.js';

/** A private world simulated in this tab: the offline / no-WebRTC fallback. */
export class SoloWorlds implements WorldProvider {
  private world: World | null = null;

  constructor(private readonly reason = 'Solo world') {}

  async join(): Promise<Transport> {
    if (!this.world) {
      this.world = new World(serverMapData);
      this.world.run();
    }
    return new LocalTransport(this.world);
  }

  label(): string {
    return this.reason;
  }

  dispose(): void {
    this.world?.dispose();
    this.world = null;
  }
}