mirror of
https://github.com/hensm/fx_cast.git
synced 2026-06-11 18:19:58 +00:00
Convert shim to Typescript (#32)
This commit is contained in:
33
ext/src/shim/index.ts
Executable file
33
ext/src/shim/index.ts
Executable file
@@ -0,0 +1,33 @@
|
||||
"use strict";
|
||||
|
||||
import cast from "./cast";
|
||||
import media from "./media";
|
||||
|
||||
import { onMessage } from "./messageBridge";
|
||||
|
||||
|
||||
const global = (window as any);
|
||||
|
||||
if (!global.chrome) {
|
||||
global.chrome = {};
|
||||
}
|
||||
|
||||
global.chrome.cast = cast;
|
||||
global.chrome.cast.media = media;
|
||||
|
||||
|
||||
onMessage(message => {
|
||||
switch (message.subject) {
|
||||
case "shim:/initialized": {
|
||||
const bridgeInfo = message.data;
|
||||
|
||||
// Call page's API loaded function if defined
|
||||
const readyFunction = global.__onGCastApiAvailable;
|
||||
if (readyFunction && typeof readyFunction === "function") {
|
||||
readyFunction(bridgeInfo && bridgeInfo.isVersionCompatible);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user