aboutsummaryrefslogtreecommitdiff
path: root/apps/extension/lib/utils.ts
blob: b406ea537fc9d5477c99a7ef89a09fd00289f515 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import { clsx, type ClassValue } from "clsx";
import { twMerge } from "tailwind-merge";

export function cn(...inputs: ClassValue[]) {
  return twMerge(clsx(inputs));
}

// getBaseURL function that checks if we are in dev or prod and returns the correct baseURL
export async function getBaseURL() {
  if (typeof chrome === "undefined") {
    console.error("chrome is undefined: only run in background script");
    throw new Error("chrome is undefined: only run in background script");
  }
  const extensionInfo = await chrome.management.getSelf();
  console.info(`Running in ${extensionInfo.installType} mode`);
  // If we're in development mode, the id will contain 'development'
  return extensionInfo.installType.includes("development")
    ? "http://localhost:3000"
    : "https://supermemory.ai";
}