mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-21 23:50:45 +00:00
19 lines
472 B
TypeScript
19 lines
472 B
TypeScript
export class BridgeUnavailableError extends Error {
|
|
constructor(message = "Netcatty bridge unavailable") {
|
|
super(message);
|
|
this.name = "BridgeUnavailableError";
|
|
}
|
|
}
|
|
|
|
export const netcattyBridge = {
|
|
get(): NetcattyBridge | undefined {
|
|
return typeof window !== 'undefined' ? window.netcatty : undefined;
|
|
},
|
|
|
|
require(): NetcattyBridge {
|
|
const bridge = window.netcatty;
|
|
if (!bridge) throw new BridgeUnavailableError();
|
|
return bridge;
|
|
},
|
|
};
|