reflect path replacement on proxy as well
This commit is contained in:
parent
f01d6c466e
commit
c22c6db195
|
@ -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);
|
||||
},
|
||||
}))
|
||||
)),
|
||||
];
|
||||
|
|
Loading…
Reference in a new issue