Interactive Tools Enhancements Support (#5115)

* added `useInteractive` hook and exposed to `PluginApi`
* made `SceneFileInfoPanel` patchable
This commit is contained in:
blackx69
2024-08-05 19:34:27 -05:00
committed by GitHub
parent c79f299d1a
commit c8d4dacffd
4 changed files with 60 additions and 5 deletions

View File

@@ -687,7 +687,9 @@ declare namespace PluginApi {
NumberSetting: React.FC<any>;
StringListSetting: React.FC<any>;
ConstantSetting: React.FC<any>;
SceneFileInfoPanel: React.FC<any>;
};
type PatchableComponentNames = keyof typeof components | string;
namespace utils {
namespace NavUtils {
function makePerformerScenesUrl(...args: any[]): any;
@@ -955,11 +957,54 @@ declare namespace PluginApi {
refetch: () => void;
};
export enum ConnectionState {
Missing,
Disconnected,
Error,
Connecting,
Syncing,
Uploading,
Ready,
}
type Handy = typeof import("thehandy").default;
export type InteractiveAPI = {
readonly _connected: boolean;
readonly _playing: boolean;
readonly _scriptOffset: number;
readonly _handy: Handy;
readonly _useStashHostedFunscript: boolean;
connect(): Promise<void>;
set handyKey(key: string);
get handyKey(): string;
set useStashHostedFunscript(useStashHostedFunscript: boolean);
get useStashHostedFunscript(): boolean;
set scriptOffset(offset: number);
uploadScript(funscriptPath: string, apiKey?: string): Promise<void>;
sync(): Promise<number>;
setServerTimeOffset(offset: number): void;
play(position: number): Promise<void>;
pause(): Promise<void>;
ensurePlaying(position: number): Promise<void>;
setLooping(looping: boolean): Promise<void>;
};
function useInteractive(): {
interactive: InteractiveAPI;
state: ConnectionState;
serverOffset: number;
initialised: boolean;
currentScript?: string;
error?: string;
initialise: () => Promise<void>;
uploadScript: (funscriptPath: string) => Promise<void>;
sync: () => Promise<void>;
};
}
namespace patch {
function before(target: string, fn: Function): void;
function instead(target: string, fn: Function): void;
function after(target: string, fn: Function): void;
function before(target: PatchableComponentNames, fn: Function): void;
function instead(target: PatchableComponentNames, fn: Function): void;
function after(target: PatchableComponentNames, fn: Function): void;
}
namespace register {
function route(path: string, component: React.FC<any>): void;