mirror of
https://github.com/hensm/fx_cast.git
synced 2026-06-10 17:49:58 +00:00
Install scripts, build app with rollup & configurable mirror app id
This commit is contained in:
20
ext/build.js
Normal file
20
ext/build.js
Normal file
@@ -0,0 +1,20 @@
|
||||
const spawn = require('child_process').spawn;
|
||||
const argv = require('minimist')(process.argv.slice(2));
|
||||
|
||||
const appId = argv.appId || "19A6F4AE";
|
||||
|
||||
const child = spawn(
|
||||
`webpack --env.appId=${appId} `
|
||||
+ '&& web-ext build '
|
||||
+ '--overwrite-dest '
|
||||
+ '--source-dir '
|
||||
+ '../dist/ext/unpacked '
|
||||
+ '--artifacts-dir '
|
||||
+ '../dist/ext '
|
||||
+ '&& mv ../dist/ext/*.zip ../dist/ext/ext.xpi'
|
||||
, {
|
||||
shell: true
|
||||
}
|
||||
);
|
||||
child.stdout.pipe(process.stdout);
|
||||
child.stderr.pipe(process.stderr);
|
||||
10776
ext/package-lock.json
generated
Normal file
10776
ext/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"scripts": {
|
||||
"build": "webpack && web-ext build --overwrite-dest --source-dir ../dist/unpacked --artifacts-dir ../dist && mv ../dist/*.zip ../dist/ext.xpi",
|
||||
"build": "node build.js",
|
||||
"watch": "webpack -d --watch"
|
||||
},
|
||||
"devDependencies": {
|
||||
@@ -12,6 +12,7 @@
|
||||
"babel-preset-env": "^1.6.1",
|
||||
"babel-preset-react": "^6.24.1",
|
||||
"copy-webpack-plugin": "^4.3.1",
|
||||
"minimist": "^1.2.0",
|
||||
"react": "^16.2.0",
|
||||
"react-dom": "^16.2.0",
|
||||
"web-ext": "^2.7.0",
|
||||
|
||||
@@ -70,7 +70,7 @@ browser.webRequest.onBeforeRequest.addListener(
|
||||
, frameId: details.frameId
|
||||
, runAt: "document_start"
|
||||
});
|
||||
|
||||
|
||||
return {
|
||||
redirectUrl: browser.runtime.getURL("shim/bundle.js")
|
||||
};
|
||||
@@ -148,7 +148,7 @@ browser.menus.onClicked.addListener(async (info, tab) => {
|
||||
mirrorCastFrameId = frameId;
|
||||
|
||||
await browser.tabs.executeScript(tab.id, {
|
||||
code: `const selectedMedia = "${info.pageUrl ? "tab" : "screen"}";`
|
||||
code: `let selectedMedia = "${info.pageUrl ? "tab" : "screen"}";`
|
||||
, frameId
|
||||
});
|
||||
|
||||
@@ -192,8 +192,30 @@ const bridgeMap = new Map();
|
||||
* forwarding.
|
||||
*/
|
||||
function initBridge (tabId, frameId) {
|
||||
const existingPort = bridgeMap.get(tabId);
|
||||
|
||||
if (existingPort) {
|
||||
existingPort.disconnect();
|
||||
bridgeMap.delete(tabId);
|
||||
}
|
||||
|
||||
const port = browser.runtime.connectNative("fx_cast_bridge");
|
||||
bridgeMap.set(tabId, port);
|
||||
|
||||
if (port.error) {
|
||||
console.error("Failed connect to fx_cast_bridge:", port.error.message);
|
||||
} else {
|
||||
bridgeMap.set(tabId, port);
|
||||
}
|
||||
|
||||
port.onDisconnect.addListener(p => {
|
||||
if (p.error) {
|
||||
console.error("fx_cast_bridge disconnected:", p.error.message);
|
||||
} else {
|
||||
console.log("fx_cast_bridge disconnected");
|
||||
}
|
||||
|
||||
bridgeMap.delete(tabId);
|
||||
});
|
||||
|
||||
port.onMessage.addListener(message => {
|
||||
// Forward shim: messages
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
let chrome;
|
||||
let logMessage;
|
||||
|
||||
const FX_CAST_RECEIVER_APP_ID = "19A6F4AE";
|
||||
const FX_CAST_RECEIVER_APP_ID = typeof MIRROR_CAST_APP_ID !== "undefined"
|
||||
? MIRROR_CAST_APP_ID
|
||||
: "19A6F4AE";
|
||||
const FX_CAST_NAMESPACE = "urn:x-cast:fx_cast";
|
||||
|
||||
let session;
|
||||
|
||||
@@ -6,9 +6,9 @@ const webpack_copy = require("copy-webpack-plugin");
|
||||
|
||||
|
||||
const include_path = path.resolve(__dirname, "src");
|
||||
const output_path = path.resolve(__dirname, "../dist/unpacked");
|
||||
const output_path = path.resolve(__dirname, "../dist/ext/unpacked");
|
||||
|
||||
module.exports = {
|
||||
module.exports = (env) => ({
|
||||
entry: {
|
||||
"main" : `${include_path}/main.js`
|
||||
, "popup/bundle" : `${include_path}/popup/index.js`
|
||||
@@ -28,6 +28,7 @@ module.exports = {
|
||||
//, new webpack.optimize.CommonsChunkPlugin("lib/init.bundle")
|
||||
new webpack.DefinePlugin({
|
||||
"process.env.NODE_ENV": `"production"`
|
||||
, "MIRROR_CAST_APP_ID": JSON.stringify(env.appId.toString() || "19A6F4AE")
|
||||
})
|
||||
|
||||
// Ext copy assets
|
||||
@@ -37,7 +38,7 @@ module.exports = {
|
||||
, ignore: [ "*.js" ]
|
||||
}])
|
||||
]
|
||||
, devtool: "source-map"
|
||||
, devtool: "eval-source-map"
|
||||
, module: {
|
||||
loaders: [
|
||||
{
|
||||
@@ -55,4 +56,4 @@ module.exports = {
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user