8000 Updating fork with 0.0.4 by RAVMN · Pull Request #2 · RAVMN/fx_cast · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Updating fork with 0.0.4 #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 38 commits into from
Aug 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
d8d8f01
Spanish translation (#72)
RAVMN Jul 10, 2019
f2907cd
Set window position in native selector based on data from extension
hensm Jul 12, 2019
a62cb01
Update blank metadata values from null to undefined to match Chrome
hensm Jul 14, 2019
b6f6bd7
Rename test/lib/ to test/vendor/
hensm Jul 18, 2019
2fe72ed
Add receiver selector options + misc options page improvements
hensm Jul 19, 2019
ba8c28b
Restructure background script (#70)
hensm Jul 25, 2019
b213a8d
Fix missing options
hensm Jul 25, 2019
6204e7d
Update site preview images
hensm Jul 26, 2019
c53a210
Fix site GitHub logo margin
hensm Jul 26, 2019
a046ba9
Add options checks for waitForConnection and closeIfFocusLost
hensm Jul 26, 2019
c15e719
Remove duplicate interface
hensm Jul 26, 2019
a275354
Set fixed site header size
hensm Jul 26, 2019
2dd2990
Optimize site images
hensm Jul 26, 2019
79fd720
Add responsive site design
hensm Jul 26, 2019
9e19646
Allow mediaCast sender to run in background context
hensm Jul 27, 2019
36b3916
Update all dependencies
hensm Jul 28, 2019
8c9ac7b
Move some background modules to a separate folder and fix init order
hensm Jul 28, 2019
e8ef099
Disable browser action unless there are available receivers
hensm Jul 29, 2019
0fa1f63
Only import ShimManager into shim/export.ts if run from background
hensm Jul 29, 2019
8ac3cf4
Use receiver application statusText instead of host:port when not idle
hensm Aug 4, 2019
487df78
Truncate receiver application status text
hensm Aug 4, 2019
53e0f86
Rename executable (bridge -> fx_cast_bridge)
hensm Aug 5, 2019
8000
cec5db5
Misc formatting/import changes
hensm Aug 5, 2019
a122047
Fix CPU usage issue with 0-interval timer (fixes #73)
hensm Aug 11, 2019
0ca39af
Handle missing volume in status messages
hensm Aug 16, 2019
a8721d8
Move main.ts -> background/background.ts
hensm Aug 16, 2019
fa966ca
Simplify stringify util function
hensm Aug 16, 2019
082436c
Move menu code back into main background script
hensm Aug 16, 2019
87e92d8
Fix menu boolean check
hensm Aug 16, 2019
1c67354
TSLint compliance
hensm Aug 16, 2019
e2eca07
Fix unused locals and better receiver selector available media checking
hensm Aug 16, 2019
14d3b2c
Fix unused parameters
hensm Aug 16, 2019
be7544c
Move media type checking to receiver selectors
hensm Aug 16, 2019
539548e
Fix options page bridge styling
hensm Aug 18, 2019
b1c1620
Bump version numbers
hensm Aug 18, 2019
adf62df
Fix naming workaround breaking packaging builds
hensm Aug 18, 2019
d2d7fd9
Update outdated site info
hensm Aug 18, 2019
ac890cf
Update README/IMPLEMENTATION docs
hensm Aug 18, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 38 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,43 @@ issues if you're going to work on something to avoid duplication of effort.
Submit an issue for new features before submitting a PR.


## Compatibility Report
## Compatibility Reports

Compatibility reports are always helpful. Use the "Compatibility Report" issue template. Ensure you have a working environment and that the site is in the whitelist (check options page).


## Localizations

Missing strings:

* `es`
* `optionsMediaSyncElementDescription`
* `optionsReceiverSelectorCategoryName`
* `optionsReceiverSelectorCategoryDescription`
* `optionsReceiverSelectorType`
* `optionsReceiverSelectorTypeBrowser`
* `optionsReceiverSelectorTypeNative`
* `optionsReceiverSelectorWaitForConnection`
* `optionsReceiverSelectorWaitForConnectionDescription`
* `optionsReceiverSelectorCloseIfFocusLost`
* `optionsMirroringAppIdDescription`
* `nl`
* `popupMediaTypeApp`
* `popupMediaTypeTab`
* `popupMediaTypeScreen`
* `popupMediaTypeFile`
* `popupMediaSelectCastLabel`
* `popupMediaSelectToLabel`
* `contextAddToWhitelist`
* `contextAddToWhitelistRecommended`
* `contextAddToWhitelistAdvancedAdd`
* `optionsMediaSyncElementDescription`
* `optionsReceiverSelectorCategoryName`
* `optionsReceiverSelectorCategoryDescription`
* `optionsReceiverSelectorType`
* `optionsReceiverSelectorTypeBrowser`
* `optionsReceiverSelectorTypeNative`
* `optionsReceiverSelectorWaitForConnection`
* `optionsReceiverSelectorWaitForConnectionDescription`
* `optionsReceiverSelectorCloseIfFocusLost`
* `optionsMirroringAppIdDescription`
2 changes: 2 additions & 0 deletions IMPLEMENTATION.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# SOMEWHAT OUTDATED (again)!

# Extension Lifetime

A bridge application instance (`statusBridge`) is created to keep track of receivers’ statuses. This is expected to exist throughout the lifetime of the extension and will automatically reconnect if unexpectedly disconnected.
Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<img src="docs/images/preview-fg_macOS@2x.png"
<img src="docs/images/preview-fg_macOS_dark@2x.png"
alt="Preview of cast device selection popup"
align="right"
width="396">
width="462">

# fx_cast

Expand Down Expand Up @@ -41,7 +41,6 @@ sudo dnf install fx_cast_bridge-<version>-<arch>.rpm

### Requirements

* Node.js 10.x (https://git.io/fjmgL)
* dpkg (for building deb packages)
* rpm (for building rpm packages)
* macOS (for building macOS installer packages)
Expand Down
32 changes: 30 additions & 2 deletions app/NativeMacReceiverSelector/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,47 @@ import Cocoa


class AppDelegate : NSObject, NSApplicationDelegate {
var initData: InitData!

var mainWindow: NSWindow?
var mainWindowController: NSWindowController?
var mainWindowViewController: ViewController?


func applicationDidFinishLaunching (_ aNotification: Notification) {
if CommandLine.argc < 2 {
fputs("Error: Not enough args\n", stderr)
exit(1)
}

guard let data = CommandLine.arguments[1].data(using: .utf8) else {
fputs("Error: Failed to convert input to data\n", stderr)
exit(1)
}

do {
// Decode and store initialization JSON data
self.initData = try JSONDecoder().decode(InitData.self, from: data)
} catch {
fputs("Error: Failed to parse input data\n (\(error))", stderr)
exit(1)
}


let window = NSWindow(
contentRect: NSZeroRect
, styleMask: [ .titled, .closable ]
, backing: .buffered
, defer: false)

let screenHeight = NSScreen.main!.frame.height

window.titleVisibility = .hidden
window.isMovableByWindowBackground = true
window.orderFrontRegardless()
window.center()
window.setFrameTopLeftPoint(NSPoint(
x: self.initData.windowPositionX
, y: Int(screenHeight - CGFloat(self.initData.windowPositionY))))

let windowController = NSWindowController(window: window)
windowController.showWindow(window)
Expand All @@ -33,7 +59,9 @@ class AppDelegate : NSObject, NSApplicationDelegate {
}

func applicationDidResignActive (_ aNotification: Notification) {
self.mainWindow?.performClose(aNotification)
if self.initData.closeIfFocusLost {
self.mainWindow?.performClose(aNotification)
}
}

func applicationShouldTerminateAfterLastWindowClosed (
Expand Down
19 changes: 16 additions & 3 deletions app/NativeMacReceiverSelector/ReceiverView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,24 @@ class ReceiverView : NSStackView {

self.receiver = receiver


let statusText = receiver.status.application.isIdleScreen
? "\(receiver.host):\(receiver.port)"
: receiver.status.application.statusText

let addressLabel = makeLabel(statusText
, size: NSFont.smallSystemFontSize
, color: .secondaryLabelColor)

// Truncate long status text
addressLabel.toolTip = statusText
addressLabel.cell?.lineBreakMode = .byTruncatingTail
addressLabel.setContentCompressionResistancePriority(
.defaultLow, for: .horizontal)

let metaStackView = NSStackView(views: [
makeLabel(receiver.friendlyName, size: 14)
, makeLabel("\(receiver.host):\(receiver.port)"
, size: NSFont.smallSystemFontSize
, color: .secondaryLabelColor)
, addressLabel
])

metaStackView.alignment = .leading
Expand Down
31 changes: 13 additions & 18 deletions app/NativeMacReceiverSelector/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,7 @@ class ViewController : NSViewController {
override func viewDidLoad () {
super.viewDidLoad()

if (CommandLine.argc < 2) {
fputs("Error: Not enough args\n", stderr)
exit(1)
}

guard let data = CommandLine.arguments[1].data(using: .utf8) else {
fputs("Error: Failed to convert input to data\n", stderr)
exit(1)
}

do {
// Decode and store initialization JSON data
self.initData = try JSONDecoder().decode(InitData.self, from: data)
} catch {
fputs("Error: Failed to parse input data\n", stderr)
exit(1)
}

self.initData = (NSApplication.shared.delegate as! AppDelegate).initData

/**
* View Hierarchy
Expand Down Expand Up @@ -136,6 +119,12 @@ class ViewController : NSViewController {

receiverView.receiverViewDelegate = self

if UInt(initData!.availableMediaTypes) == 0
|| (initData!.availableMediaTypes
& initData!.defaultMediaType.rawValue) == 0 {
receiverView.isEnabled = false
}


self.receiverViews.append(receiverView)

Expand Down Expand Up @@ -163,6 +152,12 @@ extension ViewController : NSMenuDelegate {
let mediaType = MediaType(
rawValue: self.mediaTypePopUpButton.selectedItem!.tag)!

if self.initData.availableMediaTypes & mediaType.rawValue != 0 {
for receiverView in self.receiverViews {
receiverView.isEnabled = true
}
}

let fileItem = self.mediaTypePopUpButton
.item(at: self.mediaTypePopUpButton.indexOfItem(
withTag: MediaType.file.rawValue))!
Expand Down
5 changes: 5 additions & 0 deletions app/NativeMacReceiverSelector/models/InitData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ struct InitData : Codable {
let defaultMediaType: MediaType
let availableMediaTypes: Int

let closeIfFocusLost: Bool

let windowPositionX: Int
let windowPositionY: Int

let i18n_extensionName: String
let i18n_castButtonTitle: String
let i18n_mediaTypeApp: String
Expand Down
17 changes: 17 additions & 0 deletions app/NativeMacReceiverSelector/models/Receiver.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
struct Receiver : Codable {
struct Status: Codable {
let application: Application
let volume: Volume
}

struct Application: Codable {
let displayName: String
let isIdleScreen: Bool
let statusText: String
}

struct Volume: Codable {
let level: Double
let muted: Bool
}

let friendlyName: String
let host: String
let id: String
let port: Int
let status: Status
}
12 changes: 3 additions & 9 deletions app/bin/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,17 +180,11 @@ async function build () {
fs.writeFileSync(path.join(BUILD_PATH, "package.json")
, JSON.stringify(pkgManifest))

/**
* With the BUILD_PATH/bridge dir, cannot build to
* BUILD_PATH/bridge file.
*/
const tempExecutableName = `_${executableName[argv.platform]}`;

// Run pkg to create a single executable
await pkg.exec([
BUILD_PATH
, "--target", `${pkgPlatform[argv.platform]}-${argv.arch}`
, "--output", path.join(BUILD_PATH, tempExecutableName)
, "--output", path.join(BUILD_PATH, executableName[argv.platform])
]);

// Build NativeMacReceiverSelector
Expand Down Expand Up @@ -238,7 +232,7 @@ async function build () {
, path.join(DIST_PATH, manifestName)
, { overwrite: true });
fs.moveSync(
path.join(BUILD_PATH, tempExecutableName)
path.join(BUILD_PATH, executableName[argv.platform])
, path.join(DIST_PATH, executableName[argv.platform])
, { overwrite: true });

Expand Down Expand Up @@ -329,7 +323,7 @@ function packageDarwin (
fs.ensureDirSync(rootManifestPath, { recursive: true });

// Move files to root
fs.moveSync(path.join(BUILD_PATH, `_${platformExecutableName}`)
fs.moveSync(path.join(BUILD_PATH, platformExecutableName)
, path.join(rootExecutablePath, platformExecutableName));
fs.moveSync(path.join(BUILD_PATH, manifestName)
, path.join(rootManifestPath, manifestName));
Expand Down
Loading
0