Skip to content

Commit

Permalink
Upgrade dependencies (#817)
Browse files Browse the repository at this point in the history
* Upgrade dependencies

* Upgrade CircleCI macOS version
  • Loading branch information
sindresorhus authored Mar 27, 2020
1 parent 9917c3c commit a2e9b76
Show file tree
Hide file tree
Showing 18 changed files with 1,165 additions and 991 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: 2
jobs:
build:
macos:
xcode: '10.3.0'
xcode: '11.4.0'
steps:
- checkout
- run: yarn
Expand Down
116 changes: 58 additions & 58 deletions main/convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ const speedRegex = /speed=\s*(-?\d+(,\d+)*(\.\d+(e\d+)?)?)/gm;
// https://trac.ffmpeg.org/ticket/309
const makeEven = n => 2 * Math.round(n / 2);

const getConvertFunction = shouldTrack => (outputPath, opts, args) => {
const getConvertFunction = shouldTrack => (outputPath, options, args) => {
if (shouldTrack) {
track(`file/export/fps/${opts.fps}`);
track(`file/export/fps/${options.fps}`);
}

return new PCancelable((resolve, reject, onCancel) => {
const converter = execa(ffmpegPath, args);
const durationMs = moment.duration(opts.endTime - opts.startTime, 'seconds').asMilliseconds();
const durationMs = moment.duration(options.endTime - options.startTime, 'seconds').asMilliseconds();
let speed;

onCancel(() => {
Expand Down Expand Up @@ -61,9 +61,9 @@ const getConvertFunction = shouldTrack => (outputPath, opts, args) => {
// Wait 2 second in the conversion for the speed to be stable
if (processedMs > 2 * 1000) {
const msRemaining = (durationMs - processedMs) / speed;
opts.onProgress(progress, prettyMs(Math.max(msRemaining, 1000), {compact: true}).slice(1));
options.onProgress(progress, prettyMs(Math.max(msRemaining, 1000), {compact: true}).slice(1));
} else {
opts.onProgress(progress);
options.onProgress(progress);
}
}
});
Expand Down Expand Up @@ -110,44 +110,44 @@ const mute = PCancelable.fn(async (inputPath, onCancel) => {

const convert = getConvertFunction(true);

const convertToMp4 = PCancelable.fn(async (opts, onCancel) => {
if (opts.isMuted) {
const muteProcess = mute(opts.inputPath);
const convertToMp4 = PCancelable.fn(async (options, onCancel) => {
if (options.isMuted) {
const muteProcess = mute(options.inputPath);

onCancel(() => {
muteProcess.cancel();
});

opts.inputPath = await muteProcess;
options.inputPath = await muteProcess;
}

return convert(opts.outputPath, opts, [
'-i', opts.inputPath,
'-r', opts.fps,
return convert(options.outputPath, options, [
'-i', options.inputPath,
'-r', options.fps,
...(
opts.shouldCrop ? [
'-s', `${makeEven(opts.width)}x${makeEven(opts.height)}`,
'-ss', opts.startTime,
'-to', opts.endTime
options.shouldCrop ? [
'-s', `${makeEven(options.width)}x${makeEven(options.height)}`,
'-ss', options.startTime,
'-to', options.endTime
] : []
),
opts.outputPath
options.outputPath
]);
});

const convertToWebm = PCancelable.fn(async (opts, onCancel) => {
if (opts.isMuted) {
const muteProcess = mute(opts.inputPath);
const convertToWebm = PCancelable.fn(async (options, onCancel) => {
if (options.isMuted) {
const muteProcess = mute(options.inputPath);

onCancel(() => {
muteProcess.cancel();
});

opts.inputPath = await muteProcess;
options.inputPath = await muteProcess;
}

return convert(opts.outputPath, opts, [
'-i', opts.inputPath,
return convert(options.outputPath, options, [
'-i', options.inputPath,
// http://wiki.webmproject.org/ffmpeg
// https://trac.ffmpeg.org/wiki/Encode/VP9
'-threads', Math.max(os.cpus().length - 1, 1),
Expand All @@ -156,48 +156,48 @@ const convertToWebm = PCancelable.fn(async (opts, onCancel) => {
'-codec:v', 'vp9',
'-codec:a', 'vorbis',
'-strict', '-2', // Needed because `vorbis` is experimental
'-r', opts.fps,
'-r', options.fps,
...(
opts.shouldCrop ? [
'-s', `${opts.width}x${opts.height}`,
'-ss', opts.startTime,
'-to', opts.endTime
options.shouldCrop ? [
'-s', `${options.width}x${options.height}`,
'-ss', options.startTime,
'-to', options.endTime
] : []
),
opts.outputPath
options.outputPath
]);
});

// Should be similiar to the Gif generation
const convertToApng = opts => {
return convert(opts.outputPath, opts, [
'-i', opts.inputPath,
'-vf', `fps=${opts.fps}${opts.shouldCrop ? `,scale=${opts.width}:${opts.height}:flags=lanczos` : ''}`,
const convertToApng = options => {
return convert(options.outputPath, options, [
'-i', options.inputPath,
'-vf', `fps=${options.fps}${options.shouldCrop ? `,scale=${options.width}:${options.height}:flags=lanczos` : ''}`,
// Strange for APNG instead of -loop it uses -plays see: https://stackoverflow.com/questions/43795518/using-ffmpeg-to-create-looping-apng
'-plays', opts.loop === true ? '0' : '1', // 0 == forever; 1 == no loop
'-plays', options.loop === true ? '0' : '1', // 0 == forever; 1 == no loop
...(
opts.shouldCrop ? [
'-ss', opts.startTime,
'-to', opts.endTime
options.shouldCrop ? [
'-ss', options.startTime,
'-to', options.endTime
] : []
),
opts.outputPath
options.outputPath
]);
};

// `time ffmpeg -i original.mp4 -vf fps=30,scale=480:-1::flags=lanczos,palettegen palette.png`
// `time ffmpeg -i original.mp4 -i palette.png -filter_complex 'fps=30,scale=-1:-1:flags=lanczos[x]; [x][1:v]paletteuse' palette.gif`
const convertToGif = PCancelable.fn(async (opts, onCancel) => {
const convertToGif = PCancelable.fn(async (options, onCancel) => {
const palettePath = tmp.tmpNameSync({postfix: '.png'});
const paletteProcessor = execa(ffmpegPath, [
...(
opts.shouldCrop ? [
'-ss', opts.startTime,
'-to', opts.endTime
options.shouldCrop ? [
'-ss', options.startTime,
'-to', options.endTime
] : []
),
'-i', opts.inputPath,
'-vf', `fps=${opts.fps}${opts.shouldCrop ? `,scale=${opts.width}:${opts.height}:flags=lanczos` : ''},palettegen`,
'-i', options.inputPath,
'-vf', `fps=${options.fps}${options.shouldCrop ? `,scale=${options.width}:${options.height}:flags=lanczos` : ''},palettegen`,
palettePath
]);

Expand All @@ -207,18 +207,18 @@ const convertToGif = PCancelable.fn(async (opts, onCancel) => {

await paletteProcessor;

return convert(opts.outputPath, opts, [
'-i', opts.inputPath,
return convert(options.outputPath, options, [
'-i', options.inputPath,
'-i', palettePath,
'-filter_complex', `fps=${opts.fps}${opts.shouldCrop ? `,scale=${opts.width}:${opts.height}:flags=lanczos` : ''}[x]; [x][1:v]paletteuse`,
'-loop', opts.loop === true ? '0' : '-1', // 0 == forever; -1 == no loop
'-filter_complex', `fps=${options.fps}${options.shouldCrop ? `,scale=${options.width}:${options.height}:flags=lanczos` : ''}[x]; [x][1:v]paletteuse`,
'-loop', options.loop === true ? '0' : '-1', // 0 == forever; -1 == no loop
...(
opts.shouldCrop ? [
'-ss', opts.startTime,
'-to', opts.endTime
options.shouldCrop ? [
'-ss', options.startTime,
'-to', options.endTime
] : []
),
opts.outputPath
options.outputPath
]);
});

Expand All @@ -229,22 +229,22 @@ const converters = new Map([
['apng', convertToApng]
]);

const convertTo = (opts, format) => {
const outputPath = path.join(tempy.directory(), opts.defaultFileName);
const convertTo = (options, format) => {
const outputPath = path.join(tempy.directory(), options.defaultFileName);
const converter = converters.get(format);

if (!converter) {
throw new Error(`Unsupported file format: ${format}`);
}

opts.onProgress(0);
options.onProgress(0);
track(`file/export/format/${format}`);

if (opts.editService) {
return convertUsingPlugin({outputPath, format, converter, ...opts});
if (options.editService) {
return convertUsingPlugin({outputPath, format, converter, ...options});
}

return converter({outputPath, ...opts});
return converter({outputPath, ...options});
};

const convertUsingPlugin = PCancelable.fn(async ({editService, converter, ...options}, onCancel) => {
Expand Down
20 changes: 10 additions & 10 deletions main/menus.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ const appMenuItem = appMenu([preferencesItem]);

appMenuItem.submenu[0] = aboutItem;

const applicationMenuTemplate = [
const appMenuTemplate = [
appMenuItem,
{
role: 'fileMenu',
Expand Down Expand Up @@ -206,32 +206,32 @@ const refreshRecordPluginItems = services => {
cogMenu = Menu.buildFromTemplate(getCogMenuTemplate());
};

const applicationMenu = Menu.buildFromTemplate(applicationMenuTemplate);
const applicationExportsItem = applicationMenu.getMenuItemById('exports');
const applicationSaveOriginalItem = applicationMenu.getMenuItemById('saveOriginal');
const appMenu_ = Menu.buildFromTemplate(appMenuTemplate);
const appExportsItem = appMenu_.getMenuItemById('exports');
const appSaveOriginalItem = appMenu_.getMenuItemById('saveOriginal');

const toggleExportMenuItem = enabled => {
cogExportsItem.enabled = enabled;
applicationExportsItem.enabled = enabled;
appExportsItem.enabled = enabled;
};

const setApplicationMenu = () => {
Menu.setApplicationMenu(applicationMenu);
const setAppMenu = () => {
Menu.setApplicationMenu(appMenu_);
};

editorEmitter.on('blur', () => {
applicationSaveOriginalItem.visible = false;
appSaveOriginalItem.visible = false;
});

editorEmitter.on('focus', () => {
applicationSaveOriginalItem.visible = true;
appSaveOriginalItem.visible = true;
});

const getCogMenu = () => cogMenu;

module.exports = {
getCogMenu,
toggleExportMenuItem,
setApplicationMenu,
setApplicationMenu: setAppMenu,
refreshRecordPluginItems
};
4 changes: 2 additions & 2 deletions main/plugins/save-file-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ const {Notification, shell} = require('electron');
const moveFile = require('move-file');

const action = async context => {
const tempFilePath = await context.filePath();
const temporaryFilePath = await context.filePath();

// Execution has been interrupted
if (context.canceled) {
return;
}

await moveFile(tempFilePath, context.targetFilePath);
await moveFile(temporaryFilePath, context.targetFilePath);

const notification = new Notification({
title: 'File saved successfully!',
Expand Down
2 changes: 1 addition & 1 deletion main/utils/ajv.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const Ajv = require('ajv');
const hexColorValidator = () => {
return {
type: 'string',
pattern: /^((0x)|#)([0-9A-Fa-f]{8}|[0-9A-Fa-f]{6})$/.source
pattern: /^((0x)|#)([\dA-Fa-f]{8}|[\dA-Fa-f]{6})$/.source
};
};

Expand Down
41 changes: 21 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,21 @@
},
"dependencies": {
"@ffmpeg-installer/ffmpeg": "^1.0.20",
"@sentry/browser": "^5.12.1",
"@sentry/electron": "^1.2.0",
"@sentry/browser": "^5.15.1",
"@sentry/electron": "^1.3.0",
"@sindresorhus/to-milliseconds": "^1.2.0",
"ajv": "^6.11.0",
"ajv": "^6.12.0",
"aperture": "^5.2.0",
"base64-img": "^1.0.4",
"classnames": "^2.2.6",
"delay": "^4.3.0",
"electron-better-ipc": "^0.8.0",
"electron-log": "^4.0.6",
"electron-log": "^4.1.0",
"electron-next": "^3.1.5",
"electron-notarize": "^0.2.1",
"electron-store": "^5.1.0",
"electron-updater": "^4.2.0",
"electron-util": "^0.13.1",
"electron-store": "^5.1.1",
"electron-updater": "^4.2.5",
"electron-util": "^0.14.0",
"ensure-error": "^2.0.0",
"execa": "4.0.0",
"file-icon": "^3.0.0",
Expand All @@ -64,29 +64,29 @@
"plist": "^3.0.1",
"pretty-ms": "^5.1.0",
"prop-types": "^15.7.2",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-linkify": "^0.2.2",
"read-pkg": "^5.2.0",
"semver": "^7.1.2",
"string-math": "^1.2.1",
"tempy": "^0.3.0",
"tempy": "^0.5.0",
"tildify": "^2.0.0",
"tmp": "^0.1.0",
"unstated": "^1.2.0",
"yarn": "^1.21.1"
"yarn": "^1.22.4"
},
"devDependencies": {
"babel-eslint": "^10.0.3",
"electron": "8.0.0",
"electron-builder": "^22.3.2",
"babel-eslint": "^10.1.0",
"electron": "8.2.0",
"electron-builder": "^22.4.1",
"electron-builder-notarize": "^1.1.2",
"eslint-config-xo-react": "^0.22.0",
"eslint-plugin-react": "^7.18.3",
"eslint-plugin-react-hooks": "^2.3.0",
"eslint-config-xo-react": "^0.23.0",
"eslint-plugin-react": "^7.19.0",
"eslint-plugin-react-hooks": "^2.5.1",
"husky": "^4.2.1",
"next": "^9.2.1",
"xo": "^0.25.3"
"next": "^9.3.1",
"xo": "^0.28.0"
},
"xo": {
"parser": "babel-eslint",
Expand All @@ -103,7 +103,8 @@
"react/require-default-props": "off",
"react/jsx-curly-brace-presence": "off",
"react/static-property-placement": "off",
"react/boolean-prop-naming": "off"
"react/boolean-prop-naming": "off",
"unicorn/string-content": "off"
},
"ignores": [
"dist",
Expand Down
4 changes: 2 additions & 2 deletions renderer/components/action-bar/controls/advanced.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ class Left extends React.Component {

select = React.createRef();

static getDerivedStateFromProps(nextProps, prevState) {
static getDerivedStateFromProps(nextProps, previousState) {
const {ratio, isResizing, setRatio} = nextProps;

if (ratio !== prevState.ratio && !isResizing) {
if (ratio !== previousState.ratio && !isResizing) {
return {
ratio,
menu: buildAspectRatioMenu({setRatio, ratio})
Expand Down
Loading

0 comments on commit a2e9b76

Please sign in to comment.