Restructure background script (#70)

Splits some background script functionality into separate modules:
 - Receiver selector handling is moved to ./SelectorManager.
 - Status bridge handling is moved to ./StatusManager.
 - Menu creation and updates are handled in ./createMenus.
 - Shim creation is handled in ./createShim.

TypedEventTarget allows EventTarget-derived classes to export typed events.

Options type definition is moved to ./lib/options, module assumes more responsibility for update handling and provides a "changed" event.

Private cast._requestSession method allows bypassing receiver selector.
This commit is contained in:
Matt Hensman
2019-07-26 00:09:51 +01:00
committed by GitHub
parent 2fe72ed24c
commit ba8c28bf39
40 changed files with 1751 additions and 1241 deletions

45
ext/src/lib/endpoints.ts Normal file
View File

@@ -0,0 +1,45 @@
"use strict";
/**
* Cast sender API loader script URL.
*
* Since the actual cast sender API script is hosted locally
* within Chrome, this script just acts a loader script for
* the real script whilst also doing some UA string
* checking.
*/
export const CAST_LOADER_SCRIPT_URL =
"https://www.gstatic.com/cv/js/sender/v1/cast_sender.js";
/**
* Framework API loader script URL.
*
* Same URL as the usual loader script, but the additional
* search parameter is checked from within the script and
* the framework API script is conditionally loaded in
* addition to the regular API script.
*/
export const CAST_FRAMEWORK_LOADER_SCRIPT_URL =
`${CAST_LOADER_SCRIPT_URL}?loadCastFramework=1`;
/**
* Cast API script URLs.
*
* Cast functionality in Chrome was previously provided by
* an extension. The cast API script is still provided via
* chrome-extension URLs for compatibility reasons.
*/
export const CAST_SCRIPT_URLS = [
"chrome-extension://pkedcjkdefgpdelpbcmbmeomcjbeemfm/cast_sender.js"
, "chrome-extension://enhhojjnijigcajfphajepfemndkmdlo/cast_sender.js"
];
/**
* Framework API script URL.
*
* Unlike the basic cast sender API, the framework API is
* not hosted locally within Chrome and is the only script
* fetched directly from Google servers.
*/
export const CAST_FRAMEWORK_SCRIPT_URL =
"https://www.gstatic.com/cast/sdk/libs/sender/1.0/cast_framework.js";