mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-06-06 20:15:17 +02:00
Move desktop screen capture into modules/screen-capture and align preload build paths and imports.
This commit is contained in:
parent
9cd4daa6b3
commit
d4caae6de9
9 changed files with 23 additions and 16 deletions
|
|
@ -134,14 +134,14 @@ async function buildElectron() {
|
||||||
|
|
||||||
await build({
|
await build({
|
||||||
...shared,
|
...shared,
|
||||||
entryPoints: ['src/screen-region-preload.ts'],
|
entryPoints: ['src/modules/screen-capture/screen-region-preload.ts'],
|
||||||
outfile: 'dist/screen-region-preload.js',
|
outfile: 'dist/modules/screen-capture/screen-region-preload.js',
|
||||||
});
|
});
|
||||||
|
|
||||||
await build({
|
await build({
|
||||||
...shared,
|
...shared,
|
||||||
entryPoints: ['src/window-picker-preload.ts'],
|
entryPoints: ['src/modules/screen-capture/window-picker-preload.ts'],
|
||||||
outfile: 'dist/window-picker-preload.js',
|
outfile: 'dist/modules/screen-capture/window-picker-preload.js',
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log('Electron build complete');
|
console.log('Electron build complete');
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ import {
|
||||||
requestScreenRecording,
|
requestScreenRecording,
|
||||||
restartApp,
|
restartApp,
|
||||||
} from '../modules/permissions';
|
} from '../modules/permissions';
|
||||||
import { pickOpenWindowCapture } from '../modules/window-picker';
|
import { pickOpenWindowCapture } from '../modules/screen-capture';
|
||||||
import {
|
import {
|
||||||
selectFolder,
|
selectFolder,
|
||||||
addWatchedFolder,
|
addWatchedFolder,
|
||||||
|
|
|
||||||
7
surfsense_desktop/src/modules/screen-capture/index.ts
Normal file
7
surfsense_desktop/src/modules/screen-capture/index.ts
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
/**
|
||||||
|
* Window capture for Screenshot Assist and chat fullscreen: single-session
|
||||||
|
* desktopCapturer, region overlay, and shortcut entry point.
|
||||||
|
*/
|
||||||
|
export { pickOpenWindowCapture, type PickedWindowResult } from './window-picker';
|
||||||
|
export { pickScreenRegion, captureCurrentDisplayDataUrl } from './screen-region-picker';
|
||||||
|
export { runScreenshotAssistShortcut } from './screenshot-assist';
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { BrowserWindow, desktopCapturer, nativeImage, screen } from 'electron';
|
import { BrowserWindow, desktopCapturer, nativeImage, screen } from 'electron';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { IPC_CHANNELS } from '../ipc/channels';
|
import { IPC_CHANNELS } from '../../ipc/channels';
|
||||||
function fitNativeImageToWorkArea(img: Electron.NativeImage, display: Electron.Display): Electron.NativeImage {
|
function fitNativeImageToWorkArea(img: Electron.NativeImage, display: Electron.Display): Electron.NativeImage {
|
||||||
const wa = display.workArea;
|
const wa = display.workArea;
|
||||||
const { width: iw, height: ih } = img.getSize();
|
const { width: iw, height: ih } = img.getSize();
|
||||||
|
|
@ -257,7 +257,7 @@ export function pickScreenRegion(opts?: { windowDataUrl?: string }): Promise<str
|
||||||
autoHideMenuBar: true,
|
autoHideMenuBar: true,
|
||||||
backgroundColor: '#00000000',
|
backgroundColor: '#00000000',
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
preload: path.join(__dirname, 'screen-region-preload.js'),
|
preload: path.join(__dirname, 'modules', 'screen-capture', 'screen-region-preload.js'),
|
||||||
contextIsolation: true,
|
contextIsolation: true,
|
||||||
nodeIntegration: false,
|
nodeIntegration: false,
|
||||||
sandbox: true,
|
sandbox: true,
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { contextBridge, ipcRenderer } from 'electron';
|
import { contextBridge, ipcRenderer } from 'electron';
|
||||||
import { IPC_CHANNELS } from './ipc/channels';
|
import { IPC_CHANNELS } from '../../ipc/channels';
|
||||||
|
|
||||||
contextBridge.exposeInMainWorld('surfsenseScreenRegion', {
|
contextBridge.exposeInMainWorld('surfsenseScreenRegion', {
|
||||||
submit: (rect: { x: number; y: number; width: number; height: number }) => {
|
submit: (rect: { x: number; y: number; width: number; height: number }) => {
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
import { IPC_CHANNELS } from '../ipc/channels';
|
import { IPC_CHANNELS } from '../../ipc/channels';
|
||||||
import { trackEvent } from './analytics';
|
import { trackEvent } from '../analytics';
|
||||||
import { pickScreenRegion } from './screen-region-picker';
|
import { pickScreenRegion } from './screen-region-picker';
|
||||||
import { pickOpenWindowCapture } from './window-picker';
|
import { pickOpenWindowCapture } from './window-picker';
|
||||||
import { getMainWindow, showMainWindow } from './window';
|
import { getMainWindow, showMainWindow } from '../window';
|
||||||
import { hasScreenRecordingPermission, requestScreenRecording } from './permissions';
|
import { hasScreenRecordingPermission, requestScreenRecording } from '../permissions';
|
||||||
|
|
||||||
export async function runScreenshotAssistShortcut(): Promise<void> {
|
export async function runScreenshotAssistShortcut(): Promise<void> {
|
||||||
if (!hasScreenRecordingPermission()) {
|
if (!hasScreenRecordingPermission()) {
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { contextBridge, ipcRenderer } from 'electron';
|
import { contextBridge, ipcRenderer } from 'electron';
|
||||||
import { IPC_CHANNELS } from './ipc/channels';
|
import { IPC_CHANNELS } from '../../ipc/channels';
|
||||||
|
|
||||||
contextBridge.exposeInMainWorld('surfsenseWindowPick', {
|
contextBridge.exposeInMainWorld('surfsenseWindowPick', {
|
||||||
list: () =>
|
list: () =>
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { BrowserWindow, desktopCapturer, ipcMain, screen } from 'electron';
|
import { BrowserWindow, desktopCapturer, ipcMain, screen } from 'electron';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { IPC_CHANNELS } from '../ipc/channels';
|
import { IPC_CHANNELS } from '../../ipc/channels';
|
||||||
|
|
||||||
let pickInProgress = false;
|
let pickInProgress = false;
|
||||||
|
|
||||||
|
|
@ -181,7 +181,7 @@ export function pickOpenWindowCapture(): Promise<PickedWindowResult | null> {
|
||||||
autoHideMenuBar: true,
|
autoHideMenuBar: true,
|
||||||
title: 'SurfSense — choose window',
|
title: 'SurfSense — choose window',
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
preload: path.join(__dirname, 'window-picker-preload.js'),
|
preload: path.join(__dirname, 'modules', 'screen-capture', 'window-picker-preload.js'),
|
||||||
contextIsolation: true,
|
contextIsolation: true,
|
||||||
nodeIntegration: false,
|
nodeIntegration: false,
|
||||||
sandbox: true,
|
sandbox: true,
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { app, globalShortcut, Menu, nativeImage, Tray, type NativeImage } from 'electron';
|
import { app, globalShortcut, Menu, nativeImage, Tray, type NativeImage } from 'electron';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { runGeneralAssistShortcut } from './general-assist';
|
import { runGeneralAssistShortcut } from './general-assist';
|
||||||
import { runScreenshotAssistShortcut } from './screenshot-assist';
|
import { runScreenshotAssistShortcut } from './screen-capture';
|
||||||
import { showMainWindow } from './window';
|
import { showMainWindow } from './window';
|
||||||
import { getShortcuts } from './shortcuts';
|
import { getShortcuts } from './shortcuts';
|
||||||
import { trackEvent } from './analytics';
|
import { trackEvent } from './analytics';
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue