parent
393cad7ce1
commit
55c77395bb
@ -0,0 +1,69 @@ |
||||
/* |
||||
* SPDX-License-Identifier: GPL-3.0 |
||||
* Aerocord, a vesktop fork for older microsoft NT releases such as NT 6.0, 6.1, 6.2 and 6.3.
|
||||
* Credits to vendicated and the rest of the vesktop contribuitors for making Vesktop! |
||||
*/ |
||||
|
||||
import { Logger } from "@vencord/types/utils"; |
||||
import { currentSettings } from "renderer/components/ScreenSharePicker"; |
||||
import { isLinux } from "renderer/utils"; |
||||
|
||||
const logger = new Logger("VesktopStreamFixes"); |
||||
|
||||
if (isLinux) { |
||||
const original = navigator.mediaDevices.getDisplayMedia; |
||||
|
||||
async function getVirtmic() { |
||||
try { |
||||
const devices = await navigator.mediaDevices.enumerateDevices(); |
||||
const audioDevice = devices.find(({ label }) => label === "vencord-screen-share"); |
||||
return audioDevice?.deviceId; |
||||
} catch (error) { |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
navigator.mediaDevices.getDisplayMedia = async function (opts) { |
||||
const stream = await original.call(this, opts); |
||||
const id = await getVirtmic(); |
||||
|
||||
const frameRate = Number(currentSettings?.fps); |
||||
const height = Number(currentSettings?.resolution); |
||||
const width = Math.round(height * (16 / 9)); |
||||
const track = stream.getVideoTracks()[0]; |
||||
|
||||
track.contentHint = String(currentSettings?.contentHint); |
||||
|
||||
const constraints = { |
||||
...track.getConstraints(), |
||||
frameRate, |
||||
width: { min: 640, ideal: width, max: width }, |
||||
height: { min: 480, ideal: height, max: height }, |
||||
advanced: [{ width: width, height: height }], |
||||
resizeMode: "none" |
||||
}; |
||||
|
||||
track |
||||
.applyConstraints(constraints) |
||||
.then(() => { |
||||
logger.info("Applied constraints successfully. New constraints: ", track.getConstraints()); |
||||
}) |
||||
.catch(e => logger.error("Failed to apply constraints.", e)); |
||||
|
||||
if (id) { |
||||
const audio = await navigator.mediaDevices.getUserMedia({ |
||||
audio: { |
||||
deviceId: { |
||||
exact: id |
||||
}, |
||||
autoGainControl: false, |
||||
echoCancellation: false, |
||||
noiseSuppression: false |
||||
} |
||||
}); |
||||
audio.getAudioTracks().forEach(t => stream.addTrack(t)); |
||||
} |
||||
|
||||
return stream; |
||||
}; |
||||
} |
@ -0,0 +1,30 @@ |
||||
/* |
||||
* SPDX-License-Identifier: GPL-3.0 |
||||
* Aerocord, a vesktop fork for older microsoft NT releases such as NT 6.0, 6.1, 6.2 and 6.3.
|
||||
* Credits to vendicated and the rest of the vesktop contribuitors for making Vesktop! |
||||
*/ |
||||
|
||||
import { Patch } from "@vencord/types/utils/types"; |
||||
|
||||
window.VCDP = {}; |
||||
|
||||
interface PatchData { |
||||
patches: Omit<Patch, "plugin">[]; |
||||
[key: string]: any; |
||||
} |
||||
|
||||
export function addPatch<P extends PatchData>(p: P) { |
||||
const { patches, ...globals } = p; |
||||
|
||||
for (const patch of patches as Patch[]) { |
||||
if (!Array.isArray(patch.replacement)) patch.replacement = [patch.replacement]; |
||||
for (const r of patch.replacement) { |
||||
if (typeof r.replace === "string") r.replace = r.replace.replaceAll("$self", "VCDP"); |
||||
} |
||||
|
||||
patch.plugin = "Vesktop"; |
||||
Vencord.Plugins.patches.push(patch); |
||||
} |
||||
|
||||
Object.assign(VCDP, globals); |
||||
} |
@ -0,0 +1,82 @@ |
||||
/* |
||||
* SPDX-License-Identifier: GPL-3.0 |
||||
* Aerocord, a vesktop fork for older microsoft NT releases such as NT 6.0, 6.1, 6.2 and 6.3.
|
||||
* Credits to vendicated and the rest of the vesktop contribuitors for making Vesktop! |
||||
*/ |
||||
|
||||
import { addContextMenuPatch } from "@vencord/types/api/ContextMenu"; |
||||
import { findStoreLazy } from "@vencord/types/webpack"; |
||||
import { FluxDispatcher, Menu, useStateFromStores } from "@vencord/types/webpack/common"; |
||||
|
||||
import { addPatch } from "./shared"; |
||||
|
||||
let word: string; |
||||
let corrections: string[]; |
||||
|
||||
const SpellCheckStore = findStoreLazy("SpellcheckStore"); |
||||
|
||||
// Make spellcheck suggestions work
|
||||
addPatch({ |
||||
patches: [ |
||||
{ |
||||
find: ".enableSpellCheck)", |
||||
replacement: { |
||||
// if (isDesktop) { DiscordNative.onSpellcheck(openMenu(props)) } else { e.preventDefault(); openMenu(props) }
|
||||
match: /else (.{1,3})\.preventDefault\(\),(.{1,3}\(.{1,3}\))(?<=:(.{1,3})\.enableSpellCheck\).+?)/, |
||||
// ... else { $self.onSlateContext(() => openMenu(props)) }
|
||||
replace: "else {$self.onSlateContext($1, $3?.enableSpellCheck, () => $2)}" |
||||
} |
||||
} |
||||
], |
||||
|
||||
onSlateContext(e: MouseEvent, hasSpellcheck: boolean | undefined, openMenu: () => void) { |
||||
if (!hasSpellcheck) { |
||||
e.preventDefault(); |
||||
openMenu(); |
||||
return; |
||||
} |
||||
|
||||
const cb = (w: string, c: string[]) => { |
||||
VesktopNative.spellcheck.offSpellcheckResult(cb); |
||||
word = w; |
||||
corrections = c; |
||||
openMenu(); |
||||
}; |
||||
VesktopNative.spellcheck.onSpellcheckResult(cb); |
||||
} |
||||
}); |
||||
|
||||
addContextMenuPatch("textarea-context", children => { |
||||
const spellCheckEnabled = useStateFromStores([SpellCheckStore], () => SpellCheckStore.isEnabled()); |
||||
const hasCorrections = Boolean(word && corrections?.length); |
||||
|
||||
children.push( |
||||
<Menu.MenuGroup> |
||||
{hasCorrections && ( |
||||
<> |
||||
{corrections.map(c => ( |
||||
<Menu.MenuItem |
||||
id={"vcd-spellcheck-suggestion-" + c} |
||||
label={c} |
||||
action={() => VesktopNative.spellcheck.replaceMisspelling(c)} |
||||
/> |
||||
))} |
||||
<Menu.MenuSeparator /> |
||||
<Menu.MenuItem |
||||
id="vcd-spellcheck-learn" |
||||
label={`Add ${word} to dictionary`} |
||||
action={() => VesktopNative.spellcheck.addToDictionary(word)} |
||||
/> |
||||
</> |
||||
)} |
||||
<Menu.MenuCheckboxItem |
||||
id="vcd-spellcheck-enabled" |
||||
label="Enable Spellcheck" |
||||
checked={spellCheckEnabled} |
||||
action={() => { |
||||
FluxDispatcher.dispatch({ type: "SPELLCHECK_TOGGLE" }); |
||||
}} |
||||
/> |
||||
</Menu.MenuGroup> |
||||
); |
||||
}); |
@ -0,0 +1,30 @@ |
||||
/* |
||||
* SPDX-License-Identifier: GPL-3.0 |
||||
* Aerocord, a vesktop fork for older microsoft NT releases such as NT 6.0, 6.1, 6.2 and 6.3.
|
||||
* Credits to vendicated and the rest of the vesktop contribuitors for making Vesktop! |
||||
*/ |
||||
|
||||
import { Settings } from "renderer/settings"; |
||||
|
||||
import { addPatch } from "./shared"; |
||||
|
||||
if (Settings.store.customTitleBar) |
||||
addPatch({ |
||||
patches: [ |
||||
{ |
||||
find: ".wordmarkWindows", |
||||
replacement: [ |
||||
{ |
||||
// TODO: Fix eslint rule
|
||||
// eslint-disable-next-line no-useless-escape
|
||||
match: /case \i\.\i\.WINDOWS:/, |
||||
replace: 'case "WEB":' |
||||
}, |
||||
...["close", "minimize", "maximize"].map(op => ({ |
||||
match: new RegExp(String.raw`\i\.\i\.${op}\b`), |
||||
replace: `VesktopNative.win.${op}` |
||||
})) |
||||
] |
||||
} |
||||
] |
||||
}); |
Loading…
Reference in new issue