-
-
Notifications
You must be signed in to change notification settings - Fork 132
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 2 commits
0d1b213
e056238
3d15e68
69a3ef9
e59869a
bd13796
264cddb
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(); | ||
|
|
||
|
Comment on lines
+13
to
+15
|
||
| // 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(); | ||
| }); | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,4 +1,3 @@ | ||||||
| import angular from 'angular'; | ||||||
| import { boundMethod } from 'autobind-decorator'; | ||||||
| import * as detectBrowser from 'detect-browser'; | ||||||
| import browser, { Tabs } from 'webextension-polyfill'; | ||||||
|
|
@@ -87,7 +86,7 @@ export abstract class WebExtPlatformService implements PlatformService { | |||||
| platformName = ''; | ||||||
|
|
||||||
| get backgroundSvc(): WebExtBackgroundService { | ||||||
| if (angular.isUndefined(this._backgroundSvc)) { | ||||||
| if (this._backgroundSvc === undefined) { | ||||||
| this._backgroundSvc = this.$injector.get('WebExtBackgroundService'); | ||||||
| } | ||||||
| return this._backgroundSvc as WebExtBackgroundService; | ||||||
|
|
@@ -165,7 +164,7 @@ export abstract class WebExtPlatformService implements PlatformService { | |||||
| i18nStr = browser.i18n.getMessage(`${i18nObj.key}_Default`); | ||||||
| } | ||||||
|
|
||||||
| if (angular.isUndefined(i18nStr ?? undefined)) { | ||||||
| if ((i18nStr ?? undefined) === undefined) { | ||||||
| throw new I18nError('I18n string has no value'); | ||||||
| } | ||||||
|
|
||||||
|
|
@@ -308,7 +307,7 @@ export abstract class WebExtPlatformService implements PlatformService { | |||||
| const iconUpdated = this.$q.defer<void>(); | ||||||
| const titleUpdated = this.$q.defer<void>(); | ||||||
|
|
||||||
| browser.browserAction.getTitle({}).then((currentTitle) => { | ||||||
| (browser.action || browser.browserAction).getTitle({}).then((currentTitle) => { | ||||||
| // Don't do anything if browser action title hasn't changed | ||||||
| if (newTitle === currentTitle) { | ||||||
| return resolve(); | ||||||
|
|
@@ -317,14 +316,14 @@ export abstract class WebExtPlatformService implements PlatformService { | |||||
| // Set a delay if finished syncing to prevent flickering when executing many syncs | ||||||
| if (currentTitle.indexOf(syncingTitle) > 0 && newTitle.indexOf(syncedTitle)) { | ||||||
|
||||||
| if (currentTitle.indexOf(syncingTitle) > 0 && newTitle.indexOf(syncedTitle)) { | |
| if (currentTitle.includes(syncingTitle) && newTitle.includes(syncedTitle)) { |
Uh oh!
There was an error while loading. Please reload this page.