When a tool is invoked, the plugin uses a dispatch shell to match the detected Draw.io version against a COMPAT_MATRIX.
Dispatch Outcomes:
matched: The tool runs the implementation specifically designed for that version range.above-window: The version is newer than the tested window. The tool runs using the newest available implementation, but a warning is emitted via report.ts.below-floor: The version is too old. The tool returns a failure response indicating the required minimum version.no-version: The version could not be detected. The tool returns a failure response.
// Example of the tool wrapper logic used in the plugin
export function import_mermaid(
ui: any,
options: Record<string, unknown>,
) {
const detected = detectDrawioVersion(ui);
const outcome = dispatchTool("import-mermaid", detected, COMPAT_MATRIX);
switch (outcome.kind) {
case "matched":
return outcome.impl(ui, options);
case "above-window":
// run on newest impl, but emit a warn-level mismatch via report.ts
reportMismatch("import-mermaid", outcome);
return COMPAT_MATRIX.versionedTools["import-mermaid"].at(-1)!.impl(ui, options);
case "below-floor":
return Promise.resolve({
success: false,
message: `drawio v${outcome.detected} predates supported floor v${outcome.floor}. Upgrade drawio.`,
});
case "no-version":
return Promise.resolve({
success: false,
message: `cannot detect drawio version (${outcome.reason}); pin a supported drawio build.`,
});
}
}