Move some background modules to a separate folder and fix init order

This commit is contained in:
hensm
2019-07-28 06:07:57 +01:00
parent 36b391606a
commit 8c9ac7b1d5
20 changed files with 412 additions and 390 deletions

View File

@@ -3,7 +3,7 @@
import { stringify } from "./utils";
import { ReceiverSelection
, ReceiverSelectorMediaType } from "../receiver_selectors";
, ReceiverSelectorMediaType } from "../background/receiverSelector";
interface LoadSenderOptions {

View File

@@ -6,7 +6,7 @@ import { Message } from "../types";
const WEBSOCKET_DAEMON_URL = "ws://localhost:9556";
type DisconnectListener = (port: browser.runtime.Port) => void;;
type DisconnectListener = (port: browser.runtime.Port) => void;
type MessageListener = (message: any) => void;
function connectNative (application: string) {

View File

@@ -2,7 +2,7 @@
import defaultOptions from "../defaultOptions";
import { ReceiverSelectorType } from "../receiver_selectors/";
import { ReceiverSelectorType } from "../background/receiverSelector";
import { Message } from "../types";
import { TypedEventTarget } from "./typedEvents";
@@ -16,13 +16,13 @@ export interface Options {
localMediaServerPort: number;
mirroringEnabled: boolean;
mirroringAppId: string;
receiverSelectorType: ReceiverSelectorType.Popup;
receiverSelectorType: ReceiverSelectorType;
receiverSelectorCloseIfFocusLost: boolean;
receiverSelectorWaitForConnection: boolean;
userAgentWhitelistEnabled: boolean;
userAgentWhitelist: string[];
[key: string]: Options[keyof Options]
[key: string]: Options[keyof Options];
}
@@ -49,28 +49,30 @@ export default new class extends TypedEventTarget<EventMap> {
const { oldValue, newValue } = _changes.options;
const changedKeys = [];
for (const key in newValue) {
// Don't track added keys
if (!(key in oldValue)) {
continue;
}
const oldKeyValue = oldValue[key];
const newKeyValue = newValue[key];
// Equality comparison
if (oldKeyValue === newKeyValue) {
continue;
}
// Array comparison
if (oldKeyValue instanceof Array
&& newKeyValue instanceof Array) {
if (oldKeyValue.length === newKeyValue.length
&& oldKeyValue.every((value, index) =>
value === newKeyValue[index])) {
for (const key of Object.keys(newValue)) {
if (oldValue) {
// Don't track added keys
if (!(key in oldValue)) {
continue;
}
const oldKeyValue = oldValue[key];
const newKeyValue = newValue[key];
// Equality comparison
if (oldKeyValue === newKeyValue) {
continue;
}
// Array comparison
if (oldKeyValue instanceof Array
&& newKeyValue instanceof Array) {
if (oldKeyValue.length === newKeyValue.length
&& oldKeyValue.every((value, index) =>
value === newKeyValue[index])) {
continue;
}
}
}
changedKeys.push(key);