Class MapeoManager

Hierarchy

  • TypedEmitter
    • MapeoManager

Constructors

  • Parameters

    • opts: {
          clientMigrationsFolder: string;
          coreStorage: string | CoreStorage;
          customMapPath: undefined | string;
          dbFolder: string;
          defaultConfigPath: undefined | string;
          defaultOnlineStyleUrl: undefined | string;
          fallbackMapPath: undefined | string;
          fastify: FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault>;
          projectMigrationsFolder: string;
          rootKey: Buffer;
      }
      • clientMigrationsFolder: string

        path for drizzle migrations folder for client database

      • coreStorage: string | CoreStorage

        Folder for hypercore storage or a function that returns a RandomAccessStorage instance

      • customMapPath: undefined | string

        File path to a locally stored Styled Map Package (SMP).

      • dbFolder: string

        Folder for sqlite Dbs. Folder must exist. Use ':memory:' to store everything in-memory

      • defaultConfigPath: undefined | string
      • defaultOnlineStyleUrl: undefined | string

        URL for an online-hosted StyleJSON asset.

      • fallbackMapPath: undefined | string

        File path to a locally stored Styled Map Package (SMP)

      • fastify: FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault>

        Fastify server instance

      • projectMigrationsFolder: string

        path for drizzle migrations folder for project database

      • rootKey: Buffer

        16-bytes of random data that uniquely identify the device, used to derive a 32-byte master key, which is used to derive all the keypairs used for Mapeo

    Returns MapeoManager

Accessors

  • get deviceId(): string
  • Returns string

Methods

  • Add a project to this device. After adding a project the client should await project.$waitForInitialSync() to ensure that the device has downloaded their proof of project membership and the project config.

    Parameters

    • projectJoinDetails: Pick<ProjectJoinDetails, "projectKey" | "encryptionKeys"> & {
          projectName: string;
      }
    • Optionalopts: {
          waitForSync?: boolean;
      } = {}

      Set opts.waitForSync = false to not wait for sync during addProject()

      • OptionalwaitForSync?: boolean

    Returns Promise<string>

  • Parameters

    • peer: {
          address: string;
          name: string;
          port: number;
      }
      • address: string
      • name: string
      • port: number

    Returns void

  • Create a new project.

    Parameters

    • Optionaloptions: {
          configPath?: string;
      } = {}
      • OptionalconfigPath?: string

    Returns Promise<string>

    Project public id

  • Returns {
        deviceId: string;
        deviceType:
            | "UNRECOGNIZED"
            | "device_type_unspecified"
            | "mobile"
            | "tablet"
            | "desktop"
            | "selfHostedServer";
    } & Partial<DeviceInfoParam>

  • Get whether this device is an archive device. Archive devices will download all media during sync, where-as non-archive devices will not download media original variants, and only download preview and thumbnail variants.

    Returns boolean

    isArchiveDevice

  • Returns Promise<string>

  • Parameters

    • projectPublicId: string

    Returns Promise<void>

  • Returns Promise<(Pick<{}, "name"> & {
        createdAt?: string;
        projectId: string;
        updatedAt?: string;
    })[]>

  • Call this when the app goes into the background.

    Will gracefully shut down sync.

    Returns void

  • Call this when the app goes into the foreground.

    Will undo the effects of onBackgrounded.

    Returns void

  • Type Parameters

    • T extends DeviceInfoParam & {
          deviceType?:
              | "UNRECOGNIZED"
              | "device_type_unspecified"
              | "mobile"
              | "tablet"
              | "desktop"
              | "selfHostedServer";
      } | ExactObject<DeviceInfoParam & {
          deviceType?:
              | "UNRECOGNIZED"
              | "device_type_unspecified"
              | "mobile"
              | "tablet"
              | "desktop"
              | "selfHostedServer";
      }, T>

    Parameters

    • deviceInfo: T

    Returns Promise<void>

  • Set whether this device is an archive device. Archive devices will download all media during sync, where-as non-archive devices will not download media original variants, and only download preview and thumbnail variants.

    Parameters

    • isArchiveDevice: boolean

    Returns void

  • Returns Promise<{
        name: string;
        port: number;
    }>

  • Close all servers and stop multicast advertising and browsing. Will wait for open sockets to close unless opts.force=true in which case open sockets are force-closed after opts.timeout milliseconds

    Parameters

    • Optionalopts: {
          force: undefined | boolean;
          timeout: undefined | number;
      }
      • force: undefined | boolean

        Force-close open sockets after timeout milliseconds

      • timeout: undefined | number

        Optional timeout when calling stop() with force=true

    Returns Promise<void>