-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
57 changed files
with
4,386 additions
and
2,000 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,18 @@ | ||
{ | ||
"presets": ["es2015", "stage-0", "react"], | ||
"plugins": ["lodash"] | ||
"presets": [ | ||
[ | ||
"env", | ||
{ | ||
"targets": { | ||
"electron": "1.8.4" | ||
} | ||
} | ||
], | ||
"react" | ||
], | ||
"plugins": [ | ||
"transform-class-properties", | ||
"transform-object-rest-spread", | ||
"lodash" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
{ | ||
"parser": "babel-eslint", | ||
"globals": { | ||
"Promise": true | ||
}, | ||
"env": { | ||
"browser": true, | ||
"node": true | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
/node_modules/ | ||
/src/dist/ | ||
/packages/record-desktop-electron/dist/ | ||
*.log | ||
play.js | ||
/src/public/* | ||
!/src/public/.keep | ||
!/src/public/index.html | ||
!/src/public/index-dev.html | ||
!/src/public/index-idle.html | ||
!/src/public/images | ||
/packages/record-desktop-electron/public/* | ||
!/packages/record-desktop-electron/public/.keep | ||
!/packages/record-desktop-electron/public/index.html | ||
!/packages/record-desktop-electron/public/index-dev.html | ||
!/packages/record-desktop-electron/public/index-idle.html | ||
!/packages/record-desktop-electron/public/images | ||
t1.js | ||
dist-pkg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
## Development | ||
|
||
```sh | ||
$ yarn build:watch & | ||
$ yarn start | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"name": "record-desktop-electron", | ||
"version": "0.5.9", | ||
"description": "Record gifs and take screenshots on linux, built with electron.", | ||
"main": "dist/main.js", | ||
"dependencies": { | ||
"delay": "^2.0.0", | ||
"record-desktop": "0.5.9" | ||
}, | ||
"scripts": { | ||
"start": "NODE_ENV=development electron ./dist/main.js", | ||
"test": "ava 'src/**/*.spec.js'", | ||
"test:watch": "nodemon --exec ava", | ||
"electron": "NODE_ENV=development electron ./dist/main.js", | ||
"prebuild": "rm -rf src/dist && mkdir src/dist", | ||
"build": "run-p build:electron build:frontend", | ||
"build:watch": "run-p build:electron:watch build:frontend:watch", | ||
"build:electron": "babel -d src/dist src/main", | ||
"build:electron:watch": "babel --watch -d dist src/main", | ||
"build:frontend": "NODE_ENV=production webpack", | ||
"build:frontend:watch": "webpack-dev-server" | ||
} | ||
} |
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import delay from 'delay'; | ||
|
||
import { notify } from './logger'; | ||
import { getFolder, getScreenshotEffect, eventEmitter } from './config'; | ||
import { copyToClipboard, openFile } from './utils'; | ||
import { NEW_FILE, SET_APP_ICON } from '../src/shared/constants'; | ||
|
||
import { recordGifByzanz, selectRegion, takeScreenshot, getActiveWindow } from 'record-desktop'; | ||
|
||
let endFn = null; | ||
let outputFile = null; | ||
|
||
export async function startRecordArea() { | ||
await checkIfRunning(); | ||
const geometry = await selectRegion(); | ||
await takeGif(geometry); | ||
} | ||
|
||
export async function startRecordActive() { | ||
await checkIfRunning(); | ||
const geometry = await getActiveWindow(); | ||
await takeGif(geometry); | ||
} | ||
|
||
export async function stopRecord() { | ||
if (endFn) { | ||
endFn(); | ||
endFn = null; | ||
notify('Finish'); | ||
|
||
delay(500).then(() => openFile(outputFile)); | ||
|
||
eventEmitter.emit(SET_APP_ICON, false); | ||
} else { | ||
notify('Already finished'); | ||
} | ||
|
||
return Promise.resolve(true); | ||
} | ||
|
||
export async function screenArea() { | ||
const geometry = await selectRegion(); | ||
await takeScreen(geometry); | ||
} | ||
|
||
export async function screenActive() { | ||
const geometry = await getActiveWindow(); | ||
await takeScreen(geometry); | ||
} | ||
|
||
async function takeGif({ width, height, x, y }) { | ||
outputFile = getOutputFile('gif'); | ||
const { proc, finish } = recordGifByzanz({ outputFile, width, height, x, y }); | ||
|
||
notify(`Start`); | ||
endFn = finish; | ||
|
||
eventEmitter.emit(SET_APP_ICON, true); | ||
|
||
try { | ||
await proc; | ||
|
||
notify('Generated'); | ||
eventEmitter.emit(NEW_FILE); | ||
} catch (err) { | ||
if (err.killed && err.signal === 'SIGINT') { | ||
notify('Generated'); | ||
eventEmitter.emit(NEW_FILE); | ||
|
||
return; | ||
} | ||
|
||
return Promise.reject(err); | ||
} | ||
} | ||
|
||
async function takeScreen({ x, y, width, height }) { | ||
const outputFile = getOutputFile('png'); | ||
|
||
await takeScreenshot({ width, height, x, y, outputFile, effect: getScreenshotEffect() }); | ||
copyToClipboard(outputFile); | ||
eventEmitter.emit(NEW_FILE); | ||
} | ||
|
||
async function checkIfRunning() { | ||
if (endFn !== null) { | ||
return Promise.reject('Session is in progress'); | ||
} | ||
|
||
endFn = null; | ||
return Promise.resolve(); | ||
} | ||
|
||
function getOutputFile(ext) { | ||
return `${getFolder()}/${new Date().toISOString()}.${ext}`; | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.