Improve script error dialogs #304

- Include the script's directory path #304.
- Exclude Windows-specific instructions on non-Windows OS.
- Standardize language across dialogs for consistency.

Other supporting changes:

- Add script diagnostics data collection from main process.
- Document script file storage and execution tamper protection in
  SECURITY.md.
- Remove redundant comment in `NodeReadbackFileWriter`.
- Centralize error display for uniformity and simplicity.
- Simpify `WindowVariablesValidator` to omit checks when not on the
  renderer process.
- Improve and centralize Electron environment detection.
- Use more emphatic language (don't worry) in error messages.
This commit is contained in:
undergroundwires
2024-01-17 23:59:05 +01:00
parent f03fc24098
commit 6ada8d425c
34 changed files with 1182 additions and 450 deletions

View File

@@ -7,10 +7,10 @@ import { IpcChannelDefinitions } from '../../shared/IpcBridging/IpcChannelDefini
import { createSecureFacade } from './SecureFacadeCreator';
export function provideWindowVariables(
createLogger: LoggerFactory = () => createElectronLogger(),
convertToOs = convertPlatformToOs,
createApiFacade: ApiFacadeFactory = createSecureFacade,
ipcConsumerCreator: IpcConsumerProxyCreator = createIpcConsumerProxy,
convertToOs = convertPlatformToOs,
createLogger: LoggerFactory = () => createElectronLogger(),
): WindowVariables {
// Enforces mandatory variable availability at compile time
const variables: RequiredWindowVariables = {
@@ -19,6 +19,9 @@ export function provideWindowVariables(
os: convertToOs(process.platform),
codeRunner: ipcConsumerCreator(IpcChannelDefinitions.CodeRunner),
dialog: ipcConsumerCreator(IpcChannelDefinitions.Dialog),
scriptDiagnosticsCollector: ipcConsumerCreator(
IpcChannelDefinitions.ScriptDiagnosticsCollector,
),
};
return variables;
}
@@ -26,8 +29,8 @@ export function provideWindowVariables(
type RequiredWindowVariables = PartiallyRequired<WindowVariables, 'os' /* | 'anotherOptionalKey'.. */>;
type PartiallyRequired<T, K extends keyof T> = Required<Omit<T, K>> & Pick<T, K>;
export type LoggerFactory = () => Logger;
export type ApiFacadeFactory = typeof createSecureFacade;
export type IpcConsumerProxyCreator = typeof createIpcConsumerProxy;
export type LoggerFactory = () => Logger;