Skip to content

Commit

Permalink
fix: refine host permission
Browse files Browse the repository at this point in the history
  • Loading branch information
pnd280 committed Oct 16, 2024
1 parent aafd322 commit 6f98ddb
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 20 deletions.
1 change: 0 additions & 1 deletion .env.chromium
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
TARGET_BROWSER=chrome
VITE_METADATA_BRANCH=chrome-ext
1 change: 0 additions & 1 deletion .env.gecko
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
TARGET_BROWSER=firefox
VITE_METADATA_BRANCH=moz
7 changes: 6 additions & 1 deletion docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ Consider giving a star ⭐ on [Github](https://github.com/pnd280/complexity).

💖 Support the development via [Ko-fi](https://ko-fi.com/pnd280) or [Paypal](https://paypal.me/pnd280).

## v0.0.3.14

_Release date: 16th Oct, 2024_

- **FIX**: Fixed UI glitch on Collection preview boxes (in Library).

## v0.0.3.13

_Release date: 11th Oct, 2024_
Expand All @@ -14,7 +20,6 @@ _Release date: 11th Oct, 2024_
- **FIX**: Fixed the store url on the Firefox addon.
- **REMOVE**: **Temporarily** removed **Auto-generate thread title** setting.


## v0.0.3.11

_Release date: 8th Oct, 2024_
Expand Down
8 changes: 3 additions & 5 deletions src/app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,14 @@ const envSchema = z.object({
const parsedEnv = envSchema.parse(env);

const appConfig = {
browser: parsedEnv.TARGET_BROWSER,
isDev: Boolean(parsedEnv.DEV) || parsedEnv.NODE_ENV === "development",
BROWSER: parsedEnv.TARGET_BROWSER,
IS_DEV: Boolean(parsedEnv.DEV) || parsedEnv.NODE_ENV === "development",
METADATA_BRANCH: parsedEnv.VITE_METADATA_BRANCH,
"perplexity-ai": {
globalMatches: ["https://*.perplexity.ai/*"],
globalMatches: ["https://www.perplexity.ai/*", "https://perplexity.ai/*"],
globalExcludeMatches: [
"https://*.perplexity.ai/p/api/*",
"https://*.perplexity.ai/hub/*",
"https://*.labs.perplexity.ai/*",
"https://*.docs.perplexity.ai/*",
],
},
};
Expand Down
2 changes: 1 addition & 1 deletion src/content-script/ReactRoot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function Root() {
return (
<>
<QueryBox />
{appConfig.isDev && <Commander />}
{appConfig.IS_DEV && <Commander />}

{location === "home" && <MainPage />}

Expand Down
6 changes: 3 additions & 3 deletions src/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ const defineMozManifest = defineChromeManifest as unknown as (
manifest: MozManifest,
) => MozManifest;

const browser = appConfig.browser;
const browser = appConfig.BROWSER;

const baseManifest: ManifestV3Export = {
name: `${appConfig.isDev ? "[🟡 Dev] " : ""}${packageData.displayName || packageData.name}`,
name: `${appConfig.IS_DEV ? "[🟡 Dev] " : ""}${packageData.displayName || packageData.name}`,
description: packageData.description,
version: packageData.version,
manifest_version: 3,
Expand Down Expand Up @@ -67,7 +67,7 @@ const baseManifest: ManifestV3Export = {
matches: appConfig["perplexity-ai"].globalMatches,
},
],
permissions: ["storage", "scripting"],
permissions: ["storage"],
};

function createManifest(): ManifestV3Export | MozManifest {
Expand Down
4 changes: 2 additions & 2 deletions src/services/CplxApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ export default class CplxApi {
static async fetchVersions() {
return jsonUtils.safeParse(
await fetchResource(
`https://raw.githubusercontent.com/pnd280/complexity/${appConfig.METADATA_BRANCH ?? "alpha"}/package.json`,
`https://raw.githubusercontent.com/pnd280/complexity/release-notes/versions.json`,
),
) as CplxVersionsApiResponse;
}

static async fetchChangelog() {
return await fetchResource(
`https://raw.githubusercontent.com/pnd280/complexity/${appConfig.METADATA_BRANCH ?? "alpha"}/docs/changelog.md`,
`https://raw.githubusercontent.com/pnd280/complexity/release-notes/changelog-${appConfig.BROWSER}.md`,
);
}
}
8 changes: 6 additions & 2 deletions src/shared/hooks/useExtensionUpdate.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useQuery } from "@tanstack/react-query";

import appConfig from "@/app.config";
import CplxApi from "@/services/CplxApi";
import { compareVersions } from "@/utils/utils";
import packageData from "~/package.json";
Expand All @@ -17,7 +18,10 @@ export default function useExtensionUpdate({

const newVersionAvailable =
data &&
compareVersions(data?.version || "0.0.0.0", packageData.version) === 1;
compareVersions(
data?.[appConfig.BROWSER] || "0.0.0.0",
packageData.version,
) === 1;

const { data: changelog, isLoading: isChangelogFetching } = useQuery({
queryKey: ["changelog"],
Expand All @@ -27,7 +31,7 @@ export default function useExtensionUpdate({

return {
newVersionAvailable,
newVersion: data?.version,
newVersion: data?.[appConfig.BROWSER],
changelog,
isChangelogFetching,
};
Expand Down
7 changes: 4 additions & 3 deletions src/types/update.types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import packageData from "~/package.json";

export type CplxVersionsApiResponse = typeof packageData;
export type CplxVersionsApiResponse = {
chrome: string;
firefox: string;
};
2 changes: 1 addition & 1 deletion src/utils/BackgroundScript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default class BackgroundScript {
}

static getOptionsPageUrl() {
const prefix = appConfig.isDev ? "src/options-page/" : "";
const prefix = appConfig.IS_DEV ? "src/options-page/" : "";

return browser.runtime.getURL(`${prefix}options.html`);
}
Expand Down

0 comments on commit 6f98ddb

Please sign in to comment.