mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 17:50:45 +00:00
fix(matrix): align extension-api source aliases
This commit is contained in:
@@ -122,8 +122,10 @@ function buildPluginSdkAliasMap(moduleUrl) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const extensionApi =
|
const extensionApi =
|
||||||
resolveExistingFile(path.join(packageRoot, "src", "extensionAPI"), [".ts", ".js"]) ??
|
resolveExistingFile(
|
||||||
resolveExistingFile(path.join(packageRoot, "dist", "extensionAPI"), [".js"]);
|
path.join(packageRoot, "src", "extensionAPI"),
|
||||||
|
PLUGIN_SDK_SOURCE_EXTENSIONS,
|
||||||
|
) ?? resolveExistingFile(path.join(packageRoot, "dist", "extensionAPI"), [".js"]);
|
||||||
if (extensionApi) {
|
if (extensionApi) {
|
||||||
aliasMap["openclaw/extension-api"] = extensionApi;
|
aliasMap["openclaw/extension-api"] = extensionApi;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -246,6 +246,36 @@ it("builds scoped and unscoped plugin-sdk aliases for the wrapper jiti loader",
|
|||||||
});
|
});
|
||||||
}, 240_000);
|
}, 240_000);
|
||||||
|
|
||||||
|
it("resolves extension-api aliases through the same source extension family", async () => {
|
||||||
|
const fixtureRoot = makeFixtureRoot(".tmp-matrix-runtime-extension-api-");
|
||||||
|
const wrapperSource = fs.readFileSync(
|
||||||
|
path.join(REPO_ROOT, "extensions", "matrix", "src", "plugin-entry.runtime.js"),
|
||||||
|
"utf8",
|
||||||
|
);
|
||||||
|
|
||||||
|
delete matrixWrapperGlobal.__openclawMatrixWrapperJitiOptions;
|
||||||
|
writeOpenClawAliasFixture(fixtureRoot);
|
||||||
|
writeFixtureFile(fixtureRoot, "src/extensionAPI.mts", "export {};\n");
|
||||||
|
writeCapturingJitiFixture(fixtureRoot);
|
||||||
|
writeFixtureFile(fixtureRoot, "extensions/matrix/src/plugin-entry.runtime.js", wrapperSource);
|
||||||
|
writeFixtureFile(
|
||||||
|
fixtureRoot,
|
||||||
|
"extensions/matrix/plugin-entry.handlers.runtime.js",
|
||||||
|
PACKAGED_RUNTIME_STUB,
|
||||||
|
);
|
||||||
|
|
||||||
|
const wrapperUrl = pathToFileURL(
|
||||||
|
path.join(fixtureRoot, "extensions", "matrix", "src", "plugin-entry.runtime.js"),
|
||||||
|
);
|
||||||
|
await import(`${wrapperUrl.href}?t=${Date.now()}`);
|
||||||
|
|
||||||
|
expect(matrixWrapperGlobal.__openclawMatrixWrapperJitiOptions).toMatchObject({
|
||||||
|
alias: {
|
||||||
|
"openclaw/extension-api": path.join(fixtureRoot, "src", "extensionAPI.mts"),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}, 240_000);
|
||||||
|
|
||||||
it("keeps wrapper plugin-sdk aliases deterministic and ignores unsafe subpaths", async () => {
|
it("keeps wrapper plugin-sdk aliases deterministic and ignores unsafe subpaths", async () => {
|
||||||
const fixtureRoot = makeFixtureRoot(".tmp-matrix-runtime-alias-order-");
|
const fixtureRoot = makeFixtureRoot(".tmp-matrix-runtime-alias-order-");
|
||||||
const wrapperSource = fs.readFileSync(
|
const wrapperSource = fs.readFileSync(
|
||||||
|
|||||||
Reference in New Issue
Block a user