mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-10 20:50:52 +08:00
同时收敛启动与运维脚本默认行为(含 wiki worker)、更新 Admin 可观测性与相关测试,降低首轮时延并提高运行稳定性。 Made-with: Cursor
40 lines
1.3 KiB
TypeScript
40 lines
1.3 KiB
TypeScript
import { loadBundledPluginContractApiSync } from "../../../src/test-utils/bundled-plugin-public-surface.js";
|
|
|
|
type MatrixContractSurface = {
|
|
matrixSetupAdapter: Record<string, unknown>;
|
|
matrixSetupWizard: Record<string, unknown>;
|
|
};
|
|
|
|
let matrixContractSurface: MatrixContractSurface | undefined;
|
|
|
|
function createLazyObjectSurface<T extends object>(loadSurface: () => T): T {
|
|
return new Proxy({} as T, {
|
|
get(_target, property) {
|
|
const surface = loadSurface();
|
|
const value = Reflect.get(surface, property, surface);
|
|
return typeof value === "function" ? value.bind(surface) : value;
|
|
},
|
|
has(_target, property) {
|
|
return property in loadSurface();
|
|
},
|
|
ownKeys() {
|
|
return Reflect.ownKeys(loadSurface());
|
|
},
|
|
getOwnPropertyDescriptor(_target, property) {
|
|
return Reflect.getOwnPropertyDescriptor(loadSurface(), property);
|
|
},
|
|
});
|
|
}
|
|
|
|
function getMatrixContractSurface(): MatrixContractSurface {
|
|
matrixContractSurface ??= loadBundledPluginContractApiSync<MatrixContractSurface>("matrix");
|
|
return matrixContractSurface;
|
|
}
|
|
|
|
export const matrixSetupAdapter = createLazyObjectSurface(
|
|
() => getMatrixContractSurface().matrixSetupAdapter,
|
|
);
|
|
|
|
export const matrixSetupWizard = createLazyObjectSurface(
|
|
() => getMatrixContractSurface().matrixSetupWizard,
|
|
);
|