Rename directory: ext -> extension

This commit is contained in:
hensm
2023-02-26 18:21:59 +00:00
parent 33bcbc0dca
commit a9406fde11
119 changed files with 40 additions and 42 deletions

View File

@@ -27,14 +27,14 @@
} }
}, },
{ {
"files": ["ext/**/*.svelte"], "files": ["extension/**/*.svelte"],
"processor": "svelte3/svelte3", "processor": "svelte3/svelte3",
"rules": { "rules": {
"no-undef": "off" "no-undef": "off"
} }
}, },
{ {
"files": ["**/*.ts", "ext/**/*.svelte"], "files": ["**/*.ts", "extension/**/*.svelte"],
"extends": "plugin:@typescript-eslint/recommended", "extends": "plugin:@typescript-eslint/recommended",
"rules": { "rules": {
"@typescript-eslint/no-empty-interface": "error", "@typescript-eslint/no-empty-interface": "error",

2
.gitignore vendored
View File

@@ -2,7 +2,7 @@ node_modules/
dist/ dist/
bridge/node_modules/ bridge/node_modules/
bridge/build bridge/build
ext/node_modules/ extension/node_modules/
test/ChromeProfile/ test/ChromeProfile/
.idea/ .idea/
*.iml *.iml

View File

@@ -13,11 +13,11 @@ interface Message {
} }
``` ```
The message payloads are all fully-typed and defined in [`ext/src/messaging.ts`](./ext/src/messaging.ts). Wrappers around both WebExtension messaging and MessagePort APIs are used to provide type checking based on these message definitions. Almost all messages are sent via messaging connections, rather than one-off `sendMessage`/`postMessage` calls. The message payloads are all fully-typed and defined in [`extension/src/messaging.ts`](./extension/src/messaging.ts). Wrappers around both WebExtension messaging and MessagePort APIs are used to provide type checking based on these message definitions. Almost all messages are sent via messaging connections, rather than one-off `sendMessage`/`postMessage` calls.
## Cast Instances ## Cast Instances
A cast instance is an initialized Web Sender SDK instance with the extension components that handle communication with receiver devices and other required functionality (like receiver selection) and is managed by the [Cast Manager](./ext/src/background/castManager.ts) background script module. A cast instance is an initialized Web Sender SDK instance with the extension components that handle communication with receiver devices and other required functionality (like receiver selection) and is managed by the [Cast Manager](./extension/src/background/castManager.ts) background script module.
Only the [Base API](https://web.archive.org/web/20150318065431/https://developers.google.com/cast/docs/chrome_sender) (`chrome.cast`) is implemented, since the Framework API (`chrome.cast.framework`) is a wrapper around the Base API and doesn't require any extra functionality on the extension-side. Only the [Base API](https://web.archive.org/web/20150318065431/https://developers.google.com/cast/docs/chrome_sender) (`chrome.cast`) is implemented, since the Framework API (`chrome.cast.framework`) is a wrapper around the Base API and doesn't require any extra functionality on the extension-side.
@@ -25,7 +25,7 @@ For some background, see [Cast SDK terminology](https://developers.google.com/ca
### Communication ### Communication
SDK instances send messages through a MessageChannel managed by the [`pageMessaging`](./ext/src/cast/pageMessaging.ts) module. One side listens for an initialization message containing a MessagePort, then receives messages from the SDK on that port and calls its message listeners so that they can be forwarded to the Cast Manager. The other side sends that initialization message and handles responses back from the Cast Manager. SDK instances send messages through a MessageChannel managed by the [`pageMessaging`](./extension/src/cast/pageMessaging.ts) module. One side listens for an initialization message containing a MessagePort, then receives messages from the SDK on that port and calls its message listeners so that they can be forwarded to the Cast Manager. The other side sends that initialization message and handles responses back from the Cast Manager.
### Initialization ### Initialization
@@ -40,9 +40,9 @@ This points to a loader script that checks the user agent string before injectin
For an instance created for a page script SDK: For an instance created for a page script SDK:
1. The [`contentInitial.ts`](./ext/src/cast/contentInitial.ts) content script is run at document start and handles some compatibility issues that can't be addressed via extension APIs (like SDK scripts directly loaded from `chrome-extension://` URLs). 1. The [`contentInitial.ts`](./extension/src/cast/contentInitial.ts) content script is run at document start and handles some compatibility issues that can't be addressed via extension APIs (like SDK scripts directly loaded from `chrome-extension://` URLs).
2. The page loads the SDK via the usual Google-hosted `cast_sender.js` loader script. 2. The page loads the SDK via the usual Google-hosted `cast_sender.js` loader script.
3. The extension intercepts this script load, injects the [`contentBridge.ts`](./ext/src/cast/contentBridge.ts) script that creates a messaging connection to the Cast Manager (via extension messaging) that registers an instance for that context, and waits for a page messaging connection to forward messages through (as described [here](#communication)). The initial request is then transparently redirected to the extension-hosted SDK page script at [`src/cast/content.ts`](./src/cast/content.ts). 3. The extension intercepts this script load, injects the [`contentBridge.ts`](./extension/src/cast/contentBridge.ts) script that creates a messaging connection to the Cast Manager (via extension messaging) that registers an instance for that context, and waits for a page messaging connection to forward messages through (as described [here](#communication)). The initial request is then transparently redirected to the extension-hosted SDK page script at [`src/cast/content.ts`](./src/cast/content.ts).
4. The SDK page script then creates the SDK objects ([`window.chrome.cast`](https://developers.google.com/cast/docs/reference/web_sender/chrome.cast)), handles loading the Framework API (if requested) and adds a page messaging listener for `cast:instanceCreated` events. 4. The SDK page script then creates the SDK objects ([`window.chrome.cast`](https://developers.google.com/cast/docs/reference/web_sender/chrome.cast)), handles loading the Framework API (if requested) and adds a page messaging listener for `cast:instanceCreated` events.
5. The Cast Manager sends a `cast:instanceCreated` message to the SDK, which then calls the sender app's entry handler ([`window.__onGCastApiAvailable`](https://developers.google.com/cast/docs/web_sender/integrate#initialization)). 5. The Cast Manager sends a `cast:instanceCreated` message to the SDK, which then calls the sender app's entry handler ([`window.__onGCastApiAvailable`](https://developers.google.com/cast/docs/web_sender/integrate#initialization)).
@@ -50,7 +50,7 @@ For an instance created for a page script SDK:
For an instance created for an extension script: For an instance created for an extension script:
1. The extension script imports the [`cast/export.ts`](./ext/src/cast/export.ts) module which creates an SDK instance. Page messaging is still used to communicate with the SDK, despite the lack of a script context boundary to avoid complicating the SDK implementation. 1. The extension script imports the [`cast/export.ts`](./extension/src/cast/export.ts) module which creates an SDK instance. Page messaging is still used to communicate with the SDK, despite the lack of a script context boundary to avoid complicating the SDK implementation.
2. The extension script calls the exported `ensureInit` async function. 2. The extension script calls the exported `ensureInit` async function.
Depending on the extension script context: Depending on the extension script context:
- If **background**: The Cast Manager is called directly, registering a new cast instance, providing it with a port for a newly-created message channel (since extension messaging is only supported between contexts). Page messaging is hooked up such that messages from the SDK are sent to the Cast Manager through this channel and vice versa. - If **background**: The Cast Manager is called directly, registering a new cast instance, providing it with a port for a newly-created message channel (since extension messaging is only supported between contexts). Page messaging is hooked up such that messages from the SDK are sent to the Cast Manager through this channel and vice versa.

View File

@@ -97,19 +97,19 @@ This will build the extension and bridge, outputting to `dist/`:
- `dist/bridge/` - `dist/bridge/`
... contains the built bridge with launcher script and manifest (with the path pointing that script). The `install-manifest` npm script copies this manifest to the proper location (or adds its current location to the registry on Windows). ... contains the built bridge with launcher script and manifest (with the path pointing that script). The `install-manifest` npm script copies this manifest to the proper location (or adds its current location to the registry on Windows).
- `dist/ext/` - `dist/extension/`
... contains the unpacked extension. ... contains the unpacked extension.
Watching ext changes: Watching extension changes:
```sh ```sh
$ npm run watch:ext $ npm run watch:extension
``` ```
Launch Firefox with built extension (run in separate terminal): Launch Firefox with built extension (run in separate terminal):
```sh ```sh
$ npm run start:ext $ npm run start:extension
``` ```
#### 32-bit on Windows #### 32-bit on Windows
@@ -128,7 +128,7 @@ $ npm run package:bridge -- -- --arch=x86
### Build scripts ### Build scripts
Extension build script (`build:ext`) arguments: Extension build script (`build:extension`) arguments:
- `--watch` - `--watch`
Rebuild on changes. Incompatible with `--package`. Rebuild on changes. Incompatible with `--package`.
@@ -164,13 +164,13 @@ $ npm run package
- `dist/bridge/` - `dist/bridge/`
... contains the installer package: `fx_cast_bridge-<version>-<arch>.(pkg|deb|rpm|exe)` ... contains the installer package: `fx_cast_bridge-<version>-<arch>.(pkg|deb|rpm|exe)`
- `dist/ext/` - `dist/extension/`
... contains the built extension archive: `fx_cast-<version>.xpi`. ... contains the built extension archive: `fx_cast-<version>.xpi`.
Packaging examples: Packaging examples:
```sh ```sh
$ npm run package:ext # Packaging extension $ npm run package:extension # Packaging extension
$ npm run package:bridge # Packaging bridge application $ npm run package:bridge # Packaging bridge application
# Linux platforms # Linux platforms
@@ -182,14 +182,14 @@ $ npm run package:bridge -- -- --package-type=rpm
Testing requires geckodriver (or chromedriver for Chrome parity testing). See [selenium-webdriver](https://www.npmjs.com/package/selenium-webdriver#installation) installation instructions (ignore `npm install`). Testing requires geckodriver (or chromedriver for Chrome parity testing). See [selenium-webdriver](https://www.npmjs.com/package/selenium-webdriver#installation) installation instructions (ignore `npm install`).
The test script expects a compatible installed bridge version and a packaged extension archive at `dist/ext/`. The test script expects a compatible installed bridge version and a packaged extension archive at `dist/extension/`.
Test results will be displayed in the terminal and within the opened browser tab. Chrome may take some time to initialize the media router component before the cast API is available for testing. Test results will be displayed in the terminal and within the opened browser tab. Chrome may take some time to initialize the media router component before the cast API is available for testing.
```sh ```sh
$ npm run build:bridge $ npm run build:bridge
$ npm run install-manifest $ npm run install-manifest
$ npm run package:ext $ npm run package:extension
$ npm test $ npm test
# Or if testing in Chrome # Or if testing in Chrome
@@ -207,9 +207,9 @@ These are somewhat outdated now, but show the basic function of the extension:
- [electron-chromecast](https://github.com/GPMDP/electron-chromecast)[^electron] - [electron-chromecast](https://github.com/GPMDP/electron-chromecast)[^electron]
- Icons by [icons8](https://icons8.com/): - Icons by [icons8](https://icons8.com/):
- `ext/src/ui/options/assets/icons8-cancel-120.png` - `extension/src/ui/options/assets/icons8-cancel-120.png`
- `ext/src/ui/options/assets/icons8-ok-120.png` - `extension/src/ui/options/assets/icons8-ok-120.png`
- `ext/src/ui/options/assets/icons8-warn-120.png` - `extension/src/ui/options/assets/icons8-warn-120.png`
## Donations ## Donations

View File

@@ -19,7 +19,7 @@ import type {
* IMPORTANT: * IMPORTANT:
* Messages that cross the native messaging channel. MUST keep * Messages that cross the native messaging channel. MUST keep
* in-sync with the extension's version at: * in-sync with the extension's version at:
* ext/src/messaging.ts > AppMessageDefinitions * extension/src/messaging.ts > AppMessageDefinitions
*/ */
type MessageDefinitions = { type MessageDefinitions = {
/** /**

View File

@@ -47,7 +47,7 @@ const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
const rootPath = path.join(__dirname, "../"); const rootPath = path.join(__dirname, "../");
const srcPath = path.join(rootPath, "src"); const srcPath = path.join(rootPath, "src");
const distPath = path.join(rootPath, "../dist/ext/"); const distPath = path.join(rootPath, "../dist/extension/");
const unpackedPath = path.join(distPath, "unpacked"); const unpackedPath = path.join(distPath, "unpacked");
const outPath = argv.package ? unpackedPath : distPath; const outPath = argv.package ? unpackedPath : distPath;

View File

@@ -1,5 +1,5 @@
{ {
"name": "ext", "name": "extension",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {

View File

@@ -4,7 +4,7 @@
"build": "node bin/build.js", "build": "node bin/build.js",
"package": "node bin/build.js --package", "package": "node bin/build.js --package",
"watch": "node bin/build.js --watch", "watch": "node bin/build.js --watch",
"start": "web-ext run -s ../dist/ext/", "start": "web-ext run -s ../dist/extension/",
"lint": "eslint src --ext .ts,.tsx" "lint": "eslint src --ext .ts,.tsx"
}, },
"devDependencies": { "devDependencies": {

View File

Before

Width:  |  Height:  |  Size: 1016 B

After

Width:  |  Height:  |  Size: 1016 B

View File

Before

Width:  |  Height:  |  Size: 749 B

After

Width:  |  Height:  |  Size: 749 B

View File

Before

Width:  |  Height:  |  Size: 570 B

After

Width:  |  Height:  |  Size: 570 B

View File

Before

Width:  |  Height:  |  Size: 994 B

After

Width:  |  Height:  |  Size: 994 B

View File

Before

Width:  |  Height:  |  Size: 996 B

After

Width:  |  Height:  |  Size: 996 B

View File

Before

Width:  |  Height:  |  Size: 480 B

After

Width:  |  Height:  |  Size: 480 B

View File

Before

Width:  |  Height:  |  Size: 482 B

After

Width:  |  Height:  |  Size: 482 B

View File

Before

Width:  |  Height:  |  Size: 471 B

After

Width:  |  Height:  |  Size: 471 B

View File

@@ -41,7 +41,7 @@ import type { ReceiverAction } from "./cast/sdk/enums";
* Messages exclusively used internally between extension * Messages exclusively used internally between extension
* components. * components.
*/ */
type ExtMessageDefinitions = { type ExtensionMessageDefinitions = {
/** Initial data to send to selector popup. */ /** Initial data to send to selector popup. */
"popup:init": { "popup:init": {
appInfo?: ReceiverSelectorAppInfo; appInfo?: ReceiverSelectorAppInfo;
@@ -125,7 +125,7 @@ type ExtMessageDefinitions = {
* in-sync with the bridge's version at: * in-sync with the bridge's version at:
* app/src/bridge/messaging.ts > MessageDefinitions * app/src/bridge/messaging.ts > MessageDefinitions
*/ */
type AppMessageDefinitions = { type BridgeMessageDefinitions = {
/** /**
* First message sent by the extension to the bridge. * First message sent by the extension to the bridge.
* Includes extension version string. Responds directly with version * Includes extension version string. Responds directly with version
@@ -297,7 +297,8 @@ type AppMessageDefinitions = {
"mediaCast:mediaServerError": string; "mediaCast:mediaServerError": string;
}; };
type MessageDefinitions = ExtMessageDefinitions & AppMessageDefinitions; type MessageDefinitions = ExtensionMessageDefinitions &
BridgeMessageDefinitions;
interface MessageBase<K extends keyof MessageDefinitions> { interface MessageBase<K extends keyof MessageDefinitions> {
subject: K; subject: K;

View File

Before

Width:  |  Height:  |  Size: 666 B

After

Width:  |  Height:  |  Size: 666 B

View File

Before

Width:  |  Height:  |  Size: 663 B

After

Width:  |  Height:  |  Size: 663 B

View File

Before

Width:  |  Height:  |  Size: 761 B

After

Width:  |  Height:  |  Size: 761 B

View File

Before

Width:  |  Height:  |  Size: 746 B

After

Width:  |  Height:  |  Size: 746 B

View File

Before

Width:  |  Height:  |  Size: 741 B

After

Width:  |  Height:  |  Size: 741 B

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

Before

Width:  |  Height:  |  Size: 951 B

After

Width:  |  Height:  |  Size: 951 B

View File

Before

Width:  |  Height:  |  Size: 992 B

After

Width:  |  Height:  |  Size: 992 B

View File

Before

Width:  |  Height:  |  Size: 629 B

After

Width:  |  Height:  |  Size: 629 B

View File

Before

Width:  |  Height:  |  Size: 726 B

After

Width:  |  Height:  |  Size: 726 B

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 788 B

After

Width:  |  Height:  |  Size: 788 B

Some files were not shown because too many files have changed in this diff Show More