Skip to content

Commit

Permalink
Merge pull request #69 from devhubapp/desktop
Browse files Browse the repository at this point in the history
Desktop apps
  • Loading branch information
brunolemos authored Dec 30, 2018
2 parents 913af67 + 8bfd9b0 commit f2394f3
Show file tree
Hide file tree
Showing 152 changed files with 1,834 additions and 840 deletions.
27 changes: 27 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
matrix:
include:
- os: osx
osx_image: xcode9.4
language: node_js
node_js: "10"
env:
- ELECTRON_CACHE=$HOME/.cache/electron
- ELECTRON_BUILDER_CACHE=$HOME/.cache/electron-builder

cache:
directories:
- node_modules
- $HOME/.cache/electron
- $HOME/.cache/electron-builder

script:
- yarn workspace @devhub/desktop build --mac --win --linux

before_cache:
- rm -rf $HOME/.cache/electron-builder/wine

branches:
only:
- master

if: tag IS present
16 changes: 16 additions & 0 deletions @types/electron/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/// <reference path="../../node_modules/electron/electron.d.ts" />

interface Window {
eval: never
ipc: Electron.IpcRenderer
process?: {
type?: string
}
require: NodeRequireFunction
}

declare namespace NodeJS {
interface ProcessVersions {
electron?: boolean
}
}
Binary file added assets/icon-desktop.psd
Binary file not shown.
Binary file added assets/icon-tray.psd
Binary file not shown.
Binary file added assets/logo-circle.psd
Binary file not shown.
Binary file added assets/logo-rounded.psd
Binary file not shown.
Binary file not shown.
Binary file added assets/logo.psd
Binary file not shown.
File renamed without changes.
25 changes: 16 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
"name": "devhub",
"version": "0.40.0",
"private": true,
"author": {
"name": "Bruno Lemos",
"email": "[email protected]",
"url": "https://twitter.com/brunolemos"
},
"description": "TweetDeck for GitHub",
"repository": "https://github.com/devhubapp/devhub",
"workspaces": {
"packages": [
"packages/*"
Expand All @@ -11,16 +18,15 @@
]
},
"scripts": {
"build:desktop": "yarn compile && concurrently --kill-others \"yarn compile -w\" \"yarn workspace @devhub/desktop build\"",
"build:desktop": "yarn workspace @devhub/desktop compile && concurrently --kill-others \"yarn workspace @devhub/desktop compile -w\" \"yarn workspace @devhub/desktop build\"",
"clean": "yarn workspaces run clean",
"compile": "yarn workspace @devhub/components build",
"deploy": "yarn deploy:web",
"deploy:web": "yarn workspace @devhub/web build && yarn now && yarn now alias",
"deploy:www": "pushd packages/www; now && now alias; popd;",
"dev": "yarn compile && concurrently --kill-others \"yarn compile -w\" \"yarn workspace @devhub/web start\" \"yarn workspace @devhub/mobile start\" \"yarn workspace @devhub/desktop start\"",
"dev:desktop": "yarn compile && concurrently --kill-others \"yarn compile -w\" \"yarn workspace @devhub/desktop start\"",
"dev:mobile": "yarn compile && concurrently --kill-others \"yarn compile -w\" \"yarn workspace @devhub/mobile start\"",
"dev:web": "yarn compile && concurrently --kill-others \"yarn compile -w\" \"yarn workspace @devhub/web start\"",
"deploy:www": "pushd \"packages/www\"; now && now alias; popd;",
"dev": "yarn workspace @devhub/desktop compile && concurrently --kill-others \"yarn workspace @devhub/desktop compile -w\" \"yarn workspace @devhub/web start\" \"yarn workspace @devhub/mobile start\" \"wait-on http://localhost:3000 && yarn workspace @devhub/desktop start\"",
"dev:desktop": "cross-env BROWSER=none concurrently \"yarn dev:web\" \"yarn workspace @devhub/desktop compile -w\" \"wait-on http://localhost:3000 && yarn workspace @devhub/desktop start\"",
"dev:mobile": "yarn workspace @devhub/mobile compile && concurrently --kill-others \"yarn workspace @devhub/mobile compile -w\" \"yarn workspace @devhub/mobile start\"",
"dev:web": "yarn workspace @devhub/web compile && concurrently --kill-others \"yarn workspace @devhub/web compile -w\" \"yarn workspace @devhub/web start\"",
"format": "yarn workspaces run format",
"lint": "yarn workspaces run lint",
"now": "npx now",
Expand All @@ -32,16 +38,17 @@
"dependencies": {},
"devDependencies": {
"concurrently": "^4.1.0",
"cross-env": "^5.2.0",
"husky": "^1.2.0",
"lint-staged-offline": "^0.0.1",
"patch-package": "^5.1.1",
"postinstall-prepare": "^1.0.1",
"prettier": "^1.15.3",
"rimraf": "^2.6.2",
"shx": "0.3.2",
"tslint": "^5.11.0",
"tslint-config-prettier": "^1.17.0",
"tslint-react": "^3.6.0",
"typescript": "^3.2.1"
"typescript": "^3.2.2"
},
"resolutions": {
"scheduler": "0.12.0"
Expand Down
Binary file removed packages/components/assets/logo.png
Binary file not shown.
Binary file added packages/components/assets/logo_circle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/components/assets/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/components/assets/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/components/assets/logo_rounded.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/components/assets/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/components/assets/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/components/assets/logo_square.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/components/assets/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/components/assets/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions packages/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"private": false,
"main": "dist",
"scripts": {
"build": "tsc -b",
"clean": "rimraf dist/*",
"compile": "tsc -b",
"clean": "shx rm -rf dist/*",
"format": "prettier --write '{.,src/**}/*.{js,jsx,ts,tsx}'",
"lint": "tslint -p .",
"prepare": "cd .. && yarn patch-package"
Expand Down Expand Up @@ -66,7 +66,7 @@
"tslint-config-airbnb": "^5.11.1",
"tslint-config-prettier": "^1.17.0",
"tslint-react": "^3.6.0",
"typescript": "^3.2.1"
"typescript": "^3.2.2"
},
"resolutions": {
"scheduler": "0.12.0"
Expand Down
5 changes: 3 additions & 2 deletions packages/components/src/components/common/Link.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React, { AnchorHTMLAttributes } from 'react'
import { Animated, Linking, View } from 'react-native'
import { Animated, View } from 'react-native'

import { Omit } from '@devhub/core'
import { Browser } from '../../libs/browser'
import { Linking } from '../../libs/linking'
import { Platform } from '../../libs/platform'
import { AnimatedTouchableOpacity } from '../animated/AnimatedTouchableOpacity'
import { TouchableOpacity, TouchableOpacityProps } from './TouchableOpacity'
Expand Down Expand Up @@ -65,7 +66,7 @@ export function Link(props: LinkProps) {
{...Platform.select({
default: {
onPress: href
? href.includes('http')
? href.startsWith('http')
? () => Browser.openURL(href)
: () => Linking.openURL(href)
: undefined,
Expand Down
3 changes: 1 addition & 2 deletions packages/components/src/components/layout/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { Separator } from '../common/Separator'
import { TouchableOpacity } from '../common/TouchableOpacity'
import { useAppLayout } from '../context/LayoutContext'

const logo = require('@devhub/components/assets/logo.png') // tslint:disable-line
const logo = require('@devhub/components/assets/logo_circle.png') // tslint:disable-line

const styles = StyleSheet.create({
centerContainer: {
Expand Down Expand Up @@ -218,7 +218,6 @@ export const Sidebar = React.memo((props: SidebarProps) => {
style={{
width: sidebarSize / 2,
height: sidebarSize / 2,
borderRadius: sidebarSize / (2 * 2),
}}
/>
</Link>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import _ from 'lodash'
import React, { useState } from 'react'
import { Alert, Animated, Clipboard, Linking, View } from 'react-native'
import { Animated, Clipboard, View } from 'react-native'

import { useAnimatedTheme } from '../../hooks/use-animated-theme'
import { useReduxState } from '../../redux/hooks/use-redux-state'
Expand Down
26 changes: 26 additions & 0 deletions packages/components/src/hooks/use-app-visibility.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useEffect, useState } from 'react'
import { AppState, AppStateStatus } from 'react-native'
import { Platform } from '../libs/platform'

export function useAppVisibility() {
const [isVisible, setIsVisible] = useState<boolean>(
Expand All @@ -20,5 +21,30 @@ export function useAppVisibility() {
[isVisible],
)

useEffect(
() => {
if (!Platform.isElectron) return

const focusHandler = () => {
if (isVisible) return
setIsVisible(true)
}

const blurHandler = () => {
if (!isVisible) return
setIsVisible(false)
}

window.addEventListener('focus', focusHandler)
window.addEventListener('blur', blurHandler)

return () => {
window.removeEventListener('focus', focusHandler)
window.removeEventListener('blur', blurHandler)
}
},
[isVisible],
)

return isVisible
}
15 changes: 15 additions & 0 deletions packages/components/src/libs/browser/index-native.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { BrowserCrossPlatform } from '.'
import { Linking } from '../linking'

export const Browser: BrowserCrossPlatform = {
addEventListener: (e: any, handler: any) => {
if (e === 'url') return Linking.addEventListener(e, handler)
console.debug('[BROWSER] Ignoring addEventListener event', e) // tslint:disable-line no-console
},
removeEventListener: (e: any, handler: any) => {
if (e === 'url') return Linking.removeEventListener(e, handler)
console.debug('[BROWSER] Ignoring removeEventListener event', e) // tslint:disable-line no-console
},
dismiss: () => undefined,
openURL: Linking.openURL,
}
14 changes: 14 additions & 0 deletions packages/components/src/libs/browser/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export interface BrowserCrossPlatform {
addEventListener: {
(event: 'url', handler: ((payload: { url: string }) => void)): void
(event: 'onDismiss', handler: (() => void)): void
}
removeEventListener: {
(event: 'url', handler: ((payload: { url: string }) => void)): void
(event: 'onDismiss', handler: (() => void)): void
}
dismiss(): void
openURL(url: string): void
}

export const Browser: BrowserCrossPlatform
21 changes: 18 additions & 3 deletions packages/components/src/libs/browser/index.ios.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,25 @@
import { Linking, StatusBar } from 'react-native'
import { StatusBar } from 'react-native'
import SafariView, { SafaryOptions } from 'react-native-safari-view'

import { BrowserCrossPlatform } from '.'
import { bugsnag } from '../bugsnag'
import { Linking } from '../linking'

export const Browser = {
...Linking,
export const Browser: BrowserCrossPlatform = {
...SafariView,
addEventListener: (e: any, handler: any) => {
if (e === 'url') return Linking.addEventListener(e, handler)
if (e === 'onShow') return SafariView.addEventListener(e, handler)
if (e === 'onDismiss') return SafariView.addEventListener(e, handler)
console.debug('[BROWSER] Unknown addEventListener event', e) // tslint:disable-line no-console
},
removeEventListener: (e: any, handler: any) => {
if (e === 'url') return Linking.removeEventListener(e, handler)
if (e === 'onShow') return SafariView.removeEventListener(e, handler)
if (e === 'onDismiss') return SafariView.removeEventListener(e, handler)
console.debug('[BROWSER] Unknown removeEventListener event', e) // tslint:disable-line no-console
},
dismiss: SafariView.dismiss,
openURL: (url: string, options?: SafaryOptions) => {
SafariView.isAvailable()
.then(isAvailable => {
Expand Down
4 changes: 4 additions & 0 deletions packages/components/src/libs/browser/index.native.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { BrowserCrossPlatform } from '.'

// tslint:disable-next-line no-var-requires
export const Browser: BrowserCrossPlatform = require('./index-native').Browser
5 changes: 0 additions & 5 deletions packages/components/src/libs/browser/index.ts

This file was deleted.

4 changes: 4 additions & 0 deletions packages/components/src/libs/browser/index.web.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { BrowserCrossPlatform } from '.'

// tslint:disable-next-line no-var-requires
export const Browser: BrowserCrossPlatform = require('./index-native').Browser
40 changes: 40 additions & 0 deletions packages/components/src/libs/linking/index-electron.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Source: https://github.com/PaulLeCam/react-native-electron/blob/master/src/apis/Linking.js

import _ from 'lodash'

import { LinkingCrossPlatform } from './index'
import { Linking as LinkingOriginal } from './index-native'

const eventHandlers = new Map()

export const Linking: LinkingCrossPlatform = {
addEventListener: (type: string, handler: any) => {
if (!(type === 'url' && typeof handler === 'function')) return

const wrapHandler = (_e: any, url: string) => {
handler({ type, url })
}

eventHandlers.set(handler, wrapHandler)
window.ipc.addListener('open-url', wrapHandler)
},
async canOpenURL(url: string) {
return LinkingOriginal.canOpenURL(url)
},
async getInitialURL() {
return ''
},
openURL: (url: string): Promise<void> => {
return LinkingOriginal.openURL(url)
},
removeEventListener: (type: string, handler: any) => {
if (!(type === 'url' && typeof handler === 'function')) return

const wrapHandler = eventHandlers.get(handler)
if (wrapHandler) {
window.ipc.removeListener('open-url', wrapHandler)
}

eventHandlers.delete(handler)
},
}
3 changes: 3 additions & 0 deletions packages/components/src/libs/linking/index-native.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import _ from 'lodash'

export { Linking } from 'react-native'
15 changes: 15 additions & 0 deletions packages/components/src/libs/linking/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export interface LinkingCrossPlatform {
addEventListener: (
event: 'url',
handler: (payload: { url: string }) => void,
) => void
removeEventListener: (
event: 'url',
handler: (payload: { url: string }) => void,
) => void
canOpenURL(url: string): Promise<boolean>
getInitialURL(): Promise<string>
openURL(url: string): void
}

export const Linking: LinkingCrossPlatform
5 changes: 5 additions & 0 deletions packages/components/src/libs/linking/index.native.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import _ from 'lodash'

import { LinkingCrossPlatform } from './index'

export const Linking: LinkingCrossPlatform = require('./index-native').Linking // tslint:disable-line no-var-requires
8 changes: 8 additions & 0 deletions packages/components/src/libs/linking/index.web.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import _ from 'lodash'

import { Platform } from '../platform'
import { LinkingCrossPlatform } from './index'

export const Linking: LinkingCrossPlatform = Platform.isElectron
? require('./index-electron').Linking // tslint:disable-line no-var-requires
: require('./index-native').Linking // tslint:disable-line no-var-requires
Loading

0 comments on commit f2394f3

Please sign in to comment.