mirror of
https://github.com/hensm/fx_cast.git
synced 2026-06-11 18:19:58 +00:00
Move endpoints module from lib/ to cast/
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
"use strict";
|
||||
|
||||
import { CAST_LOADER_SCRIPT_URL, CAST_SCRIPT_URLS } from "../lib/endpoints";
|
||||
import { CAST_LOADER_SCRIPT_URL, CAST_SCRIPT_URLS } from "./endpoints";
|
||||
|
||||
const _window = window.wrappedJSObject as any;
|
||||
|
||||
|
||||
43
ext/src/cast/endpoints.ts
Normal file
43
ext/src/cast/endpoints.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Cast Chrome Sender SDK loader script.
|
||||
*
|
||||
* Since the actual SDK script is hosted locally within Chrome,
|
||||
* this script just acts a loader 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";
|
||||
|
||||
/**
|
||||
* Cast Chrome Sender Framework API loader script.
|
||||
*
|
||||
* 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 SDK script.
|
||||
*/
|
||||
export const CAST_FRAMEWORK_LOADER_SCRIPT_URL = `${CAST_LOADER_SCRIPT_URL}?loadCastFramework=1`;
|
||||
|
||||
/**
|
||||
* Cast extension URLs.
|
||||
*
|
||||
* Cast functionality in Chrome was previously provided by
|
||||
* an extension. The cast SDK scripts are 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"
|
||||
];
|
||||
|
||||
/**
|
||||
* Cast Chrome Sender Framework API script.
|
||||
*
|
||||
* The Cast Application Framework (CAF) is implemented as a
|
||||
* wrapper around the base SDK, and ditributed remotely, as
|
||||
* opposed to within the cast extension.
|
||||
*/
|
||||
export const CAST_FRAMEWORK_SCRIPT_URL =
|
||||
"https://www.gstatic.com/cast/sdk/libs/sender/1.0/cast_framework.js";
|
||||
@@ -3,8 +3,8 @@
|
||||
import * as cast from "./api";
|
||||
import logger from "../lib/logger";
|
||||
|
||||
import { CAST_FRAMEWORK_SCRIPT_URL } from "../lib/endpoints";
|
||||
import { loadScript } from "../lib/utils";
|
||||
import { CAST_FRAMEWORK_SCRIPT_URL } from "./endpoints";
|
||||
import { onMessage } from "./eventMessageChannel";
|
||||
|
||||
const _window = window as any;
|
||||
@@ -36,10 +36,10 @@ if (document.currentScript) {
|
||||
}
|
||||
|
||||
// Queue up the framework script load to speed up init
|
||||
frameworkScriptPromise = loadScript(CAST_FRAMEWORK_SCRIPT_URL);
|
||||
frameworkScriptPromise.catch(() => {
|
||||
logger.error("Failed to load CAF script!");
|
||||
});
|
||||
frameworkScriptPromise = loadScript(CAST_FRAMEWORK_SCRIPT_URL);
|
||||
frameworkScriptPromise.catch(() => {
|
||||
logger.error("Failed to load CAF script!");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ onMessage(async message => {
|
||||
if (frameworkScriptPromise) {
|
||||
await frameworkScriptPromise;
|
||||
}
|
||||
|
||||
|
||||
// Call page script/framework API script's init function
|
||||
const initFn = _window.__onGCastApiAvailable;
|
||||
if (initFn && typeof initFn === "function") {
|
||||
|
||||
Reference in New Issue
Block a user