Class DataPackageManager

    Managers data packages metadata and exposes name lookup methods.

    Methods

    • Export a DataPackage object for local caching purposes.

      Returns DataPackage

      It is recommended to export/import any data packages ahead of time to reduce unnecessary calls to DataPackageManager.fetchPackage and reduce connection startup time and lighten network overhead. See below for an example.

      import fs from "node:fs";
      import { Client } from "archipelago.js";

      // ... misc client code (connecting and fetching data package).

      // Save data package to a local file.
      const data = client.package.exportPackage();
      fs.writeFileSync("path/to/cache/datapackage_cache.json", JSON.stringify(data), "utf8");
    • Fetches and returns the DataPackage from the server, if the games are not locally cached or checksums do not match.

      Parameters

      • games: string[] = []

        A list of game packages to fetch. If omitted, will fetch all available game packages from the current room.

      • update: boolean = true

        If true, after fetching the data package, any changes will automatically be updated without needing to manually call DataPackageManager.importPackage.

      Returns Promise<DataPackage>

      It is recommended to export and locally cache the data package after fetching, then prior to any future connections, importing the locally cached package to reduce unnecessary network bandwidth.

      Any requested games that do not exist in the current room will be ignored.

    • Import a DataPackage object to prepopulate local cache.

      Parameters

      Returns void

      It is recommended to export/import any data packages ahead of time to reduce unnecessary calls to DataPackageManager.fetchPackage and reduce connection startup time and lighten network overhead. See below for an example.

      import fs from "node:fs";
      import { Client } from "archipelago.js";

      const data = fs.readFileSync("path/to/cache/datapackage_cache.json");
      const client = new Client();

      client.package.importPackage(JSON.parse(data));
      await client.login("wss://archipelago.gg:38281", "Phar", "Clique");
      <script src="archipelago.js" type="module">
      import { Client } from "archipelago.js";

      const data = localStorage.getItem("datapackage_cache");
      const client = new Client();

      client.package.importPackage(JSON.parse(data));
      await client.login("wss://archipelago.gg:38281", "Phar", "Clique");
      </script>
    • Lookup an item name by its integer id.

      Parameters

      • game: string

        The name of the game this item is associated with.

      • id: number

        The id of the item to name lookup.

      • Optionalfallback: true

        If true, returns "Unknown Item {id}" instead of undefined, if id does not exist in package. Defaults to true, if omitted.

      Returns string

    • Lookup an item name by its integer id.

      Parameters

      • game: string

        The name of the game this item is associated with.

      • id: number

        The id of the item to name lookup.

      • fallback: false

        If true, returns "Unknown Item {id}" instead of undefined, if id does not exist in package. Defaults to true, if omitted.

      Returns undefined | string

    • Lookup a location name by its integer id.

      Parameters

      • game: string

        The name of the game this location is associated with.

      • id: number

        The id of the location to name lookup.

      • Optionalfallback: true

        If true, returns "Unknown Location {id}" instead of undefined, if id does not exist in package. Defaults to true, if omitted.

      Returns string

    • Lookup a location name by its integer id.

      Parameters

      • game: string

        The name of the game this location is associated with.

      • id: number

        The id of the location to name lookup.

      • fallback: false

        If true, returns "Unknown Location {id}" instead of undefined, if id does not exist in package. Defaults to true, if omitted.

      Returns undefined | string