Replaces all direct usage of browser globals and infrastructure service imports in UI components with dedicated application/state backend hooks. Introduces lint rules to prevent direct access to backend bridges and localStorage from components, promoting a cleaner separation of concerns and improved maintainability. Moves user preferences (e.g., port forwarding form mode) to persistent state hooks, updates port forwarding and SFTP logic to rely on backend hooks, and centralizes logging through a logger utility. Cleans up debug code and removes obsolete scripts from HTML. Improves testability, prepares for alternative backend implementations, and enforces architectural boundaries.
20 lines
429 B
TypeScript
20 lines
429 B
TypeScript
export class BridgeUnavailableError extends Error {
|
|
constructor(message = "Netcatty bridge unavailable") {
|
|
super(message);
|
|
this.name = "BridgeUnavailableError";
|
|
}
|
|
}
|
|
|
|
export const netcattyBridge = {
|
|
get(): NetcattyBridge | undefined {
|
|
return window.netcatty;
|
|
},
|
|
|
|
require(): NetcattyBridge {
|
|
const bridge = window.netcatty;
|
|
if (!bridge) throw new BridgeUnavailableError();
|
|
return bridge;
|
|
},
|
|
};
|
|
|