From c22c6db1954e4293c4b7c7c4a1289f7d66f843b4 Mon Sep 17 00:00:00 2001 From: Erin Date: Mon, 14 Aug 2023 14:14:59 -0400 Subject: [PATCH] reflect path replacement on proxy as well --- entrypoints.ts | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/entrypoints.ts b/entrypoints.ts index 4e5dcde..6197059 100644 --- a/entrypoints.ts +++ b/entrypoints.ts @@ -42,20 +42,29 @@ export const getScriptEntrypoints = (manifest: chrome.runtime.Manifest): Manifes (script.js ?? []).map((path, i) => ({ type: ManifestEntrypointKind.CONTENT_SCRIPT_JS, path, - replacePath: (newPath: string) => script.js!.splice(i, 1, newPath), + replacePath (newPath: string) { + this.path = newPath; + script.js!.splice(i, 1, newPath); + }, })) ), ...(manifest.manifest_version === 2 ? (manifest.background?.scripts || []).map((path, i) => ({ type: ManifestEntrypointKind.BACKGROUND_SCRIPT, path, - replacePath: (newPath: string) => manifest.background!.scripts!.splice(i, 1, newPath), + replacePath (newPath: string) { + this.path = newPath; + manifest.background!.scripts!.splice(i, 1, newPath); + }, })) : (manifest.background?.service_worker ? [{ type: ManifestEntrypointKind.BACKGROUND_SERVICE_WORKER, path: manifest.background.service_worker, - replacePath: (newPath: string) => manifest.background!.service_worker = newPath, + replacePath (newPath: string) { + this.path = newPath; + manifest.background!.service_worker = newPath; + }, }] : [])), ]; @@ -71,25 +80,37 @@ export const getAssetEntrypoints = (manifest: chrome.runtime.Manifest): Manifest (script.css ?? []).map((path, i) => ({ type: ManifestEntrypointKind.CONTENT_SCRIPT_CSS, path, - replacePath: (newPath: string) => script.css!.splice(i, 1, newPath), + replacePath (newPath: string) { + this.path = newPath; + script.css!.splice(i, 1, newPath); + }, })) ), ...Object.entries(manifest.icons || {}).map(([iconSize, path]) => ({ type: ManifestEntrypointKind.ICON, path, - replacePath: (newPath: string) => manifest.icons![iconSize as unknown as number] = newPath, + replacePath (newPath: string) { + this.path = newPath; + manifest.icons![iconSize as unknown as number] = newPath; + }, })), ...(manifest.manifest_version === 2 ? (manifest.web_accessible_resources ?? []).map((path, i) => ({ type: ManifestEntrypointKind.WEB_ACCESSIBLE_RESOURCE_V2, path, - replacePath: (newPath: string) => manifest.web_accessible_resources![i] = newPath, + replacePath (newPath: string) { + this.path = newPath; + manifest.web_accessible_resources![i] = newPath; + }, })) : (manifest.web_accessible_resources ?? []).flatMap(entry => entry.resources.map((path, i) => ({ type: ManifestEntrypointKind.WEB_ACCESSIBLE_RESOURCE_V3, path, - replacePath: (newPath: string) => entry.resources.splice(i, 1, newPath), + replacePath (newPath: string) { + this.path = newPath; + entry.resources.splice(i, 1, newPath); + }, })) )), ];