-
-
Notifications
You must be signed in to change notification settings - Fork 128
Manifest v3 update #528
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Manifest v3 update #528
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,40 @@ | ||
| import angular from 'angular'; | ||
| import { NgModule } from 'angular-ts-decorators'; | ||
| import { WebExtBackgroundModule } from '../../webext-background/webext-background.module'; | ||
| /** | ||
| * Chromium background entry point for MV3 service worker. | ||
| * Replaces the AngularJS bootstrap with a manual DI container. | ||
| */ | ||
|
|
||
| import browser from 'webextension-polyfill'; | ||
| import { WebExtV160UpgradeProviderService } from '../../shared/webext-upgrade/webext-v1.6.0-upgrade-provider.service'; | ||
| import { setupAngularShim } from '../../webext-background/angular-shims'; | ||
| import { createBackgroundContainer } from '../../webext-background/background-container'; | ||
| import { ChromiumBookmarkService } from '../shared/chromium-bookmark/chromium-bookmark.service'; | ||
| import { ChromiumPlatformService } from '../shared/chromium-platform/chromium-platform.service'; | ||
|
|
||
| @NgModule({ | ||
| id: 'ChromiumBackgroundModule', | ||
| imports: [WebExtBackgroundModule], | ||
| providers: [ChromiumBookmarkService, ChromiumPlatformService] | ||
| }) | ||
| class ChromiumBackgroundModule {} | ||
| // Set up angular shim before any service code runs | ||
| setupAngularShim(); | ||
|
|
||
| // Mark this as the background context | ||
| // eslint-disable-next-line no-undef, no-restricted-globals | ||
| (self as any).__xbs_isBackground = true; | ||
|
|
||
| // Create the DI container with Chromium-specific services | ||
| const { backgroundSvc } = createBackgroundContainer({ | ||
| BookmarkServiceClass: ChromiumBookmarkService, | ||
| PlatformServiceClass: ChromiumPlatformService, | ||
| UpgradeProviderServiceClass: WebExtV160UpgradeProviderService | ||
| }); | ||
|
|
||
| // Register event handlers synchronously (required for MV3 service workers) | ||
| let startupInitiated = false; | ||
|
|
||
| browser.runtime.onInstalled.addListener((details) => { | ||
| if (startupInitiated) return; | ||
| startupInitiated = true; | ||
| backgroundSvc.onInstall(details.reason); | ||
| }); | ||
|
|
||
| angular.element(document).ready(() => { | ||
| angular.bootstrap(document, [(ChromiumBackgroundModule as NgModule).module.name]); | ||
| browser.runtime.onStartup.addListener(() => { | ||
| if (startupInitiated) return; | ||
| startupInitiated = true; | ||
| backgroundSvc.init(); | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,37 +1,40 @@ | ||
| import angular from 'angular'; | ||
| import { NgModule } from 'angular-ts-decorators'; | ||
| /** | ||
| * Firefox background entry point for MV3 background scripts. | ||
| * Replaces the AngularJS bootstrap with a manual DI container. | ||
| */ | ||
|
|
||
| import browser from 'webextension-polyfill'; | ||
| import { WebExtBackgroundModule } from '../../webext-background/webext-background.module'; | ||
| import { WebExtV160UpgradeProviderService } from '../../shared/webext-upgrade/webext-v1.6.0-upgrade-provider.service'; | ||
| import { setupAngularShim } from '../../webext-background/angular-shims'; | ||
| import { createBackgroundContainer } from '../../webext-background/background-container'; | ||
| import { FirefoxBookmarkService } from '../shared/firefox-bookmark/firefox-bookmark.service'; | ||
| import { FirefoxPlatformService } from '../shared/firefox-platform/firefox-platform.service'; | ||
|
|
||
| @NgModule({ | ||
| id: 'FirefoxBackgroundModule', | ||
| imports: [WebExtBackgroundModule], | ||
| providers: [FirefoxBookmarkService, FirefoxPlatformService] | ||
| }) | ||
| class FirefoxBackgroundModule {} | ||
| // Set up angular shim before any service code runs | ||
| setupAngularShim(); | ||
|
|
||
|
Comment on lines
+13
to
15
|
||
| (FirefoxBackgroundModule as NgModule).module.config([ | ||
| '$compileProvider', | ||
| '$httpProvider', | ||
| ($compileProvider: ng.ICompileProvider, $httpProvider: ng.IHttpProvider) => { | ||
| $compileProvider.debugInfoEnabled(false); | ||
| $httpProvider.interceptors.push('ApiRequestInterceptorFactory'); | ||
| } | ||
| ]); | ||
| // Mark this as the background context | ||
| // eslint-disable-next-line no-undef, no-restricted-globals | ||
| (self as any).__xbs_isBackground = true; | ||
|
|
||
| angular.element(document).ready(() => { | ||
| angular.bootstrap(document, [(FirefoxBackgroundModule as NgModule).module.name]); | ||
| // Create the DI container with Firefox-specific services | ||
| const { backgroundSvc } = createBackgroundContainer({ | ||
| BookmarkServiceClass: FirefoxBookmarkService, | ||
| PlatformServiceClass: FirefoxPlatformService, | ||
| UpgradeProviderServiceClass: WebExtV160UpgradeProviderService | ||
| }); | ||
|
|
||
| // Set synchronous event handlers | ||
| // Register event handlers synchronously (required for MV3 background scripts) | ||
| let startupInitiated = false; | ||
|
|
||
| browser.runtime.onInstalled.addListener((details) => { | ||
| // Store event details as element data | ||
| const element = document.querySelector('#install'); | ||
| angular.element(element).data('details', details); | ||
| (document.querySelector('#install') as HTMLButtonElement).click(); | ||
| if (startupInitiated) return; | ||
| startupInitiated = true; | ||
| backgroundSvc.onInstall(details.reason); | ||
| }); | ||
|
|
||
| browser.runtime.onStartup.addListener(() => { | ||
| (document.querySelector('#startup') as HTMLButtonElement).click(); | ||
| if (startupInitiated) return; | ||
| startupInitiated = true; | ||
| backgroundSvc.init(); | ||
| }); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setupAngularShim() is called in the module body, but all imports (including services that may reference
angularor import the real AngularJS package) are evaluated before this runs. If the intent is to rely on the shim in the MV3 background context, move shim setup to a side-effect import that executes before other modules, or ensure background dependencies do not importangularat all.This issue also appears on line 27 of the same file.