mirror of
https://github.com/morluto/rea
synced 2026-10-27 06:33:32 -04:00
1c37914306
Share contextBridge argument ownership between direct and wrapped analysis, seed intact isolated-world calls, and preserve dynamic world IDs and conditional metadata as unknown. Keep callee evaluation scoped to each invocation. Validation: 99 focused source tests and bundled isolated-world acceptance through dedicated and generic CLI routes. Removed duplicate literal source regression in favor of public workflow coverage. Fixes #2174.
36 lines
1.1 KiB
TypeScript
36 lines
1.1 KiB
TypeScript
/** One contextBridge exposure method and its API argument positions. */
|
|
export interface JavaScriptContextBridgeExposureArguments<Argument> {
|
|
readonly world: "main" | "isolated";
|
|
readonly worldId: Argument | null | undefined;
|
|
readonly worldIdIndex: number | null;
|
|
readonly apiKey: Argument | undefined;
|
|
readonly api: Argument | undefined;
|
|
}
|
|
|
|
/**
|
|
* Select the semantic arguments for a contextBridge exposure method.
|
|
* Callers retain authority over callee identity and interpretation of values.
|
|
*/
|
|
export const contextBridgeExposureArguments = <Argument>(
|
|
method: string,
|
|
arguments_: readonly Argument[],
|
|
): JavaScriptContextBridgeExposureArguments<Argument> | undefined => {
|
|
if (method === "exposeInMainWorld")
|
|
return {
|
|
world: "main",
|
|
worldId: null,
|
|
worldIdIndex: null,
|
|
apiKey: arguments_[0],
|
|
api: arguments_[1],
|
|
};
|
|
if (method === "exposeInIsolatedWorld")
|
|
return {
|
|
world: "isolated",
|
|
worldId: arguments_[0],
|
|
worldIdIndex: 0,
|
|
apiKey: arguments_[1],
|
|
api: arguments_[2],
|
|
};
|
|
return undefined;
|
|
};
|