pwaOf

tcmts.cli.web.pwaOf · #775yz3qi · term · runs anywhere

The PWA an app has: its namespace's pwa (reminders.pwa for reminders.App), the web app manifest as an object, if there is one.

export function pwaOf(
  cb: {
    lookup(target: string): string[];
    lookupOne(target: string, prefer?: "type" | "value"): string;
  },
  appName: string,
): string | undefined {
  const at = appName.lastIndexOf(".");
  const name = at < 0 ? "pwa" : `${appName.slice(0, at)}.pwa`;
  if (name === appName || !cb.lookup(name).length) return undefined;
  return cb.lookupOne(name, "value");
}

used by