Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
ewnd9 committed Jun 30, 2019
1 parent 9bddc0b commit a30522b
Show file tree
Hide file tree
Showing 57 changed files with 4,386 additions and 2,000 deletions.
18 changes: 16 additions & 2 deletions .babelrc
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"
]
}
3 changes: 3 additions & 0 deletions .eslintrc.json
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
Expand Down
14 changes: 7 additions & 7 deletions .gitignore
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
3 changes: 0 additions & 3 deletions cat.sh

This file was deleted.

109 changes: 51 additions & 58 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,29 +1,20 @@
{
"name": "record-desktop",
"version": "0.5.9",
"name": "record-desktop-monorepo",
"private": true,
"description": "Record gifs and take screenshots on linux, built with electron.",
"main": "src/dist/main.js",
"scripts": {
"start": "NODE_ENV=development electron ./src/dist/main.js",
"test": "ava 'src/**/*.spec.js'",
"test:watch": "nodemon --exec ava",
"prebuild": "rm -rf src/dist && mkdir src/dist",
"build": "npm-run-all --parallel build:electron build:frontend",
"build:watch": "npm-run-all --parallel build:electron:watch build:frontend:watch",
"build:electron": "babel -d src/dist src/main",
"build:electron:watch": "babel --watch -d src/dist src/main",
"build:frontend": "NODE_ENV=production webpack",
"build:frontend:watch": "webpack-dev-server",
"precommit": "npm run lint",
"prepublish": "npm run build",
"electron": "NODE_ENV=development electron ./dist/main.js",
"lint": "eslint 'src/main/**/*.js' 'src/frontend/**/*.js'",
"lint": "eslint 'packages/*/src/**/*.js'",
"build:electron-pkg": "npm run build && rm -rf dist-pkg && electron-packager . record-desktop --platform linux --arch x64 --out dist-pkg/",
"build:electron-deb": "npm run build:electron-pkg && electron-installer-debian --src dist-pkg/record-desktop-linux-x64/ --dest dist-pkg/installers/ --arch amd64"
},
"bin": {
"record-desktop": "app.js"
},
"workspaces": [
"packages/*"
],
"ava": {
"require": [
"babel-register",
Expand Down Expand Up @@ -52,55 +43,57 @@
"electron/**/sumchecker": "2.0.2"
},
"dependencies": {
"configstore": "^1.4.0",
"electron": "^1.6.11",
"electron-contextmenu-middleware": "^1.0.1",
"configstore": "^3.1.2",
"electron": "^1.8.4",
"electron-contextmenu-middleware": "^1.0.3",
"electron-image-menu": "^2.0.0",
"electron-input-menu": "^2.1.0",
"electron-localshortcut": "^1.1.1",
"electron-localshortcut": "^3.1.0",
"electron-save-file": "^1.0.2",
"globby": "^4.0.0",
"imgur": "^0.1.7",
"lodash": "^4.5.0",
"globby": "^8.0.1",
"imgur": "^0.2.1",
"lodash": "^4.17.5",
"mkdirp": "^0.5.1",
"node-notifier": "^4.5.0",
"pify": "^2.3.0",
"pretty-bytes": "^3.0.1",
"whereis": "^0.4.0",
"winston": "^2.1.1"
"node-notifier": "^5.2.1",
"pify": "^3.0.0",
"pretty-bytes": "^4.0.2",
"whereis": "^1.0.0",
"winston": "^2.4.1"
},
"devDependencies": {
"ava": "^0.20.0",
"babel-cli": "^6.4.0",
"babel-core": "^6.4.0",
"babel-eslint": "^5.0.0",
"babel-loader": "^6.2.1",
"babel-plugin-lodash": "^1.1.0",
"babel-preset-es2015": "^6.3.13",
"babel-preset-react": "^6.3.13",
"babel-preset-stage-0": "^6.3.13",
"bootstrap": "^3.3.6",
"css-loader": "^0.23.1",
"electron-installer-debian": "0.4.0",
"electron-packager": "8.5.1",
"eslint": "^1.10.3",
"eslint-plugin-react": "^3.16.1",
"file-loader": "^0.8.5",
"husky": "^0.13.1",
"json-loader": "^0.5.4",
"nodemon": "^1.8.1",
"npm-run-all": "^1.4.0",
"proxyquire": "^1.7.11",
"react": "^0.14.6",
"react-component-gallery": "^1.2.1",
"react-dom": "^0.14.6",
"react-router": "^2.0.0",
"style-loader": "^0.13.0",
"url-loader": "^0.5.7",
"webpack": "^1.12.11",
"webpack-dev-server": "^1.14.1",
"webpack-target-electron-renderer": "^0.4.0",
"x11": "^2.0.5"
"ava": "^0.25.0",
"babel-cli": "^6.26.0",
"babel-core": "^6.26.0",
"babel-eslint": "^8.2.2",
"babel-loader": "^7.1.4",
"babel-plugin-lodash": "^3.3.2",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-preset-env": "^1.6.1",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-0": "^6.24.1",
"bootstrap": "3.x",
"css-loader": "^0.28.11",
"electron-installer-debian": "0.8.1",
"electron-packager": "12.0.1",
"eslint": "^4.19.1",
"eslint-plugin-react": "^7.7.0",
"file-loader": "^1.1.11",
"husky": "^0.14.3",
"json-loader": "^0.5.7",
"nodemon": "^1.17.3",
"npm-run-all": "^4.1.2",
"proxyquire": "^2.0.1",
"react": "^16.3.1",
"react-dom": "^16.3.1",
"react-router": "3.x",
"style-loader": "^0.20.3",
"uglifyjs-webpack-plugin": "^1.2.4",
"url-loader": "^1.0.1",
"webpack": "^3.11.0",
"webpack-dev-server": "^2.11.1",
"x11": "^2.3.0"
},
"resolutions": {
"electron/**/sumchecker": "2.0.2"
Expand Down
6 changes: 6 additions & 0 deletions packages/record-desktop-electron/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
## Development

```sh
$ yarn build:watch &
$ yarn start
```
23 changes: 23 additions & 0 deletions packages/record-desktop-electron/package.json
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.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { app, globalShortcut, ipcMain } from 'electron';
import {
OPEN_FILE, COPY_TO_CLIPBOARD, DELETE_FILE,
UPLOAD, NEW_FILE, SET_APP_ICON
} from '../shared/constants';
} from '../src/shared/constants';

import * as registerShortcuts from './shortcuts';
import { copyToClipboard, uploadFile, openFile, deleteFile } from './utils';
Expand Down
96 changes: 96 additions & 0 deletions packages/record-desktop-electron/src/main/record.js
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.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ imgur.setClientId('a9e8e4383e6dfa2');
import { nativeImage, clipboard } from 'electron';
import { notify } from './logger';

export openFile from './unix-utils/wrappers/xdg-open';
export { openFile } from 'record-desktop';

export const selectFolder = () => {
const result = dialog.showOpenDialog({ properties: [ 'openDirectory' ] });
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import React from 'react';
import styles from './style.css';

export default React.createClass({
getInitialState: () => ({ resolution: '' }),
export default class GalleryFile extends React.Component {
state = {
resolution: ''
}

getResolution() {
setTimeout(() => {
if (this.refs.img.naturalWidth === 0) {
Expand All @@ -13,17 +16,20 @@ export default React.createClass({
});
}
}, 100);
},
}

componentDidMount() {
if (this.props.file.visible) {
this.getResolution();
}
},
}

componentWillReceiveProps(nextProps) {
if (!this.state.resolution && nextProps.file.visible) {
this.getResolution();
}
},
}

render() {
const {
file,
Expand Down Expand Up @@ -57,4 +63,4 @@ export default React.createClass({
</div>
);
}
});
};
Loading

0 comments on commit a30522b

Please sign in to comment.