mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 07:20:43 +00:00
perf: cache browser plugin sdk facades
This commit is contained in:
@@ -227,14 +227,7 @@ describe("plugin activation boundary", () => {
|
||||
loadBundledPluginPublicSurfaceModuleSync.mock.calls.map(
|
||||
([params]) => params.artifactBasename,
|
||||
),
|
||||
).toEqual([
|
||||
"browser-host-inspection.js",
|
||||
"browser-control-auth.js",
|
||||
"browser-profiles.js",
|
||||
"browser-profiles.js",
|
||||
"browser-host-inspection.js",
|
||||
"browser-host-inspection.js",
|
||||
]);
|
||||
).toEqual(["browser-host-inspection.js", "browser-control-auth.js", "browser-profiles.js"]);
|
||||
|
||||
loadBundledPluginPublicSurfaceModuleSync.mockReset();
|
||||
await expect(browser.closeTrackedBrowserTabsForSessions({ sessionKeys: [] })).resolves.toBe(0);
|
||||
|
||||
@@ -24,11 +24,15 @@ type BrowserControlAuthSurface = {
|
||||
) => Promise<EnsureBrowserControlAuthResult>;
|
||||
};
|
||||
|
||||
let cachedBrowserControlAuthSurface: BrowserControlAuthSurface | undefined;
|
||||
|
||||
function loadBrowserControlAuthSurface(): BrowserControlAuthSurface {
|
||||
return loadBundledPluginPublicSurfaceModuleSync<BrowserControlAuthSurface>({
|
||||
dirName: "browser",
|
||||
artifactBasename: "browser-control-auth.js",
|
||||
});
|
||||
cachedBrowserControlAuthSurface ??=
|
||||
loadBundledPluginPublicSurfaceModuleSync<BrowserControlAuthSurface>({
|
||||
dirName: "browser",
|
||||
artifactBasename: "browser-control-auth.js",
|
||||
});
|
||||
return cachedBrowserControlAuthSurface;
|
||||
}
|
||||
|
||||
export function resolveBrowserControlAuth(
|
||||
|
||||
@@ -11,11 +11,15 @@ type BrowserHostInspectionSurface = {
|
||||
parseBrowserMajorVersion: (rawVersion: string | null | undefined) => number | null;
|
||||
};
|
||||
|
||||
let cachedBrowserHostInspectionSurface: BrowserHostInspectionSurface | undefined;
|
||||
|
||||
function loadBrowserHostInspectionSurface(): BrowserHostInspectionSurface {
|
||||
return loadBundledPluginPublicSurfaceModuleSync<BrowserHostInspectionSurface>({
|
||||
dirName: "browser",
|
||||
artifactBasename: "browser-host-inspection.js",
|
||||
});
|
||||
cachedBrowserHostInspectionSurface ??=
|
||||
loadBundledPluginPublicSurfaceModuleSync<BrowserHostInspectionSurface>({
|
||||
dirName: "browser",
|
||||
artifactBasename: "browser-host-inspection.js",
|
||||
});
|
||||
return cachedBrowserHostInspectionSurface;
|
||||
}
|
||||
|
||||
export function resolveGoogleChromeExecutableForPlatform(
|
||||
|
||||
@@ -10,15 +10,19 @@ type BrowserMaintenanceSurface = {
|
||||
closeTrackedBrowserTabsForSessions: (params: CloseTrackedBrowserTabsParams) => Promise<number>;
|
||||
};
|
||||
|
||||
let cachedBrowserMaintenanceSurface: BrowserMaintenanceSurface | undefined;
|
||||
|
||||
function hasRequestedSessionKeys(sessionKeys: Array<string | undefined>): boolean {
|
||||
return sessionKeys.some((key) => Boolean(key?.trim()));
|
||||
}
|
||||
|
||||
function loadBrowserMaintenanceSurface(): BrowserMaintenanceSurface {
|
||||
return loadBundledPluginPublicSurfaceModuleSync<BrowserMaintenanceSurface>({
|
||||
dirName: "browser",
|
||||
artifactBasename: "browser-maintenance.js",
|
||||
});
|
||||
cachedBrowserMaintenanceSurface ??=
|
||||
loadBundledPluginPublicSurfaceModuleSync<BrowserMaintenanceSurface>({
|
||||
dirName: "browser",
|
||||
artifactBasename: "browser-maintenance.js",
|
||||
});
|
||||
return cachedBrowserMaintenanceSurface;
|
||||
}
|
||||
|
||||
export async function closeTrackedBrowserTabsForSessions(
|
||||
|
||||
@@ -57,11 +57,16 @@ type BrowserProfilesSurface = {
|
||||
) => ResolvedBrowserProfile | null;
|
||||
};
|
||||
|
||||
let cachedBrowserProfilesSurface: BrowserProfilesSurface | undefined;
|
||||
|
||||
function loadBrowserProfilesSurface(): BrowserProfilesSurface {
|
||||
return loadBundledPluginPublicSurfaceModuleSync<BrowserProfilesSurface>({
|
||||
dirName: "browser",
|
||||
artifactBasename: "browser-profiles.js",
|
||||
});
|
||||
cachedBrowserProfilesSurface ??= loadBundledPluginPublicSurfaceModuleSync<BrowserProfilesSurface>(
|
||||
{
|
||||
dirName: "browser",
|
||||
artifactBasename: "browser-profiles.js",
|
||||
},
|
||||
);
|
||||
return cachedBrowserProfilesSurface;
|
||||
}
|
||||
|
||||
export function resolveBrowserConfig(
|
||||
|
||||
Reference in New Issue
Block a user