-
Notifications
You must be signed in to change notification settings - Fork 833
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
Move to TypeScript #955
Move to TypeScript #955
Changes from 4 commits
3289337
79aafe2
b73a37a
f2a05ca
a2d0d65
5b84c16
ac3900f
d1b21fc
c8e29ff
a9af816
2e35370
c4d2902
8379df2
bbfe28d
c9098eb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ node_modules | |
/renderer/.next | ||
/app/dist | ||
/dist | ||
/dist-js |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import {Format} from './types'; | ||
|
||
export const supportedVideoExtensions = ['mp4', 'mov', 'm4v']; | ||
|
||
const formatExtensions = new Map([ | ||
['av1', 'mp4'] | ||
]); | ||
|
||
export const formats = [Format.mp4, Format.av1, Format.gif, Format.apng, Format.webm]; | ||
|
||
export const getFormatExtension = (format: Format) => formatExtensions.get(format) ?? format; | ||
|
||
export const defaultInputDeviceId = 'SYSTEM_DEFAULT'; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,48 @@ | ||
'use strict'; | ||
|
||
const {homedir} = require('os'); | ||
const Store = require('electron-store'); | ||
import {homedir} from 'os'; | ||
import Store from 'electron-store'; | ||
|
||
const {defaultInputDeviceId} = require('./constants'); | ||
const {hasMicrophoneAccess} = require('./system-permissions'); | ||
const {getAudioDevices, getDefaultInputDevice} = require('../utils/devices'); | ||
const shortcutToAccelerator = require('../utils/shortcut-to-accelerator'); | ||
|
||
const shortcuts = { | ||
triggerCropper: 'Toggle Kap' | ||
export const shortcuts = { | ||
triggerCropper: 'Toggle Kap', | ||
}; | ||
|
||
const shortcutSchema = { | ||
type: 'string', | ||
default: '' | ||
}; | ||
|
||
const store = new Store({ | ||
interface Settings { | ||
kapturesDir: string; | ||
allowAnalytics: boolean; | ||
showCursor: boolean; | ||
highlightClicks: boolean; | ||
record60fps: boolean; | ||
loopExports: boolean; | ||
recordKeyboardShortcut: boolean; | ||
recordAudio: boolean; | ||
audioInputDeviceId?: string; | ||
cropperShortcut: { | ||
metaKey: boolean, | ||
altKey: boolean, | ||
ctrlKey: boolean, | ||
shiftKey: boolean, | ||
character: string | ||
}; | ||
lossyCompression: boolean; | ||
enableShortcuts: boolean; | ||
shortcuts: { | ||
[key in keyof typeof shortcuts]: string | ||
}, | ||
version: string; | ||
} | ||
|
||
const store = new Store<Settings>({ | ||
schema: { | ||
kapturesDir: { | ||
type: 'string', | ||
|
@@ -103,8 +128,7 @@ const store = new Store({ | |
} | ||
}); | ||
|
||
module.exports = store; | ||
module.exports.shortcuts = shortcuts; | ||
export default store; | ||
|
||
// TODO: Remove this when we feel like everyone has migrated | ||
if (store.has('recordKeyboardShortcut')) { | ||
|
@@ -114,26 +138,27 @@ if (store.has('recordKeyboardShortcut')) { | |
|
||
// TODO: Remove this when we feel like everyone has migrated | ||
if (store.has('cropperShortcut')) { | ||
store.set('shortcuts.triggerCropper', shortcutToAccelerator(store.get('cropperShortcut'))); | ||
// TODO: Investigate type for dot notation | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not yet possible, AFAIK. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought I saw something like this on Twitter a few months ago. It might have been something that hadn't landed in a stable version yet. It's not a big deal for us, but figured we could look into it |
||
store.set('shortcuts.triggerCropper' as any, shortcutToAccelerator(store.get('cropperShortcut'))); | ||
store.delete('cropperShortcut'); | ||
} | ||
|
||
store.set('cropper', {}); | ||
store.set('actionBar', {}); | ||
store.set('cropper' as any, {}); | ||
store.set('actionBar' as any, {}); | ||
|
||
const audioInputDeviceId = store.get('audioInputDeviceId'); | ||
|
||
if (hasMicrophoneAccess()) { | ||
(async () => { | ||
const devices = await getAudioDevices(); | ||
|
||
if (!devices.some(device => device.id === audioInputDeviceId)) { | ||
if (!devices.some((device: any) => device.id === audioInputDeviceId)) { | ||
store.set('audioInputDeviceId', defaultInputDeviceId); | ||
} | ||
})(); | ||
} | ||
|
||
module.exports.getSelectedInputDeviceId = () => { | ||
export const getSelectedInputDeviceId = () => { | ||
const audioInputDeviceId = store.get('audioInputDeviceId', defaultInputDeviceId); | ||
|
||
if (audioInputDeviceId === defaultInputDeviceId) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
export enum Format { | ||
gif = 'gif', | ||
mp4 = 'mp4', | ||
webm = 'webm', | ||
apng = 'apng', | ||
av1 = 'av1' | ||
} | ||
|
||
export enum Encoding { | ||
h264 = 'h264', | ||
hevc = 'hevc', | ||
proRes422 = 'proRes422', | ||
proRes4444 = 'proRes4444' | ||
} | ||
|
||
export type App = { | ||
url: string; | ||
isDefault: boolean; | ||
icon: string; | ||
name: string; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import {App, Format} from './base' | ||
|
||
export type CreateConversionOptions = { | ||
filePath: string; | ||
options: ConversionOptions; | ||
format: Format; | ||
plugins: { | ||
share: { | ||
pluginName: string; | ||
serviceTitle: string; | ||
app?: App | ||
} | ||
} | ||
} | ||
|
||
export type EditServiceInfo = { | ||
pluginName: string; | ||
serviceTitle: string; | ||
} | ||
|
||
export type ConversionOptions = { | ||
startTime: number; | ||
endTime: number; | ||
width: number; | ||
height: number; | ||
fps: number; | ||
shouldCrop: boolean; | ||
shouldMute: boolean; | ||
editService?: EditServiceInfo; | ||
} | ||
|
||
export enum ConversionStatus { | ||
idle = 'idle', | ||
inProgress = 'inProgress', | ||
failed = 'failed', | ||
canceled = 'canceled', | ||
completed = 'completed' | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export * from './base'; | ||
export * from './remote-states'; | ||
export * from './conversion-options'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Disabling this so I can still get PR builds until I go back and clean up linting and tests