import fs from "node:fs/promises"; import path from "node:path"; import { fileURLToPath } from "node:url"; import { describe, expect, it } from "vitest"; import { buildPluginSdkPackageExports } from "../../plugin-sdk/entrypoints.js";
async function collectRuntimeExports(filePath: string, seen = new Set<string>()) { const normalizedPath = path.resolve(filePath); if (seen.has(normalizedPath)) { returnnew Set<string>();
}
seen.add(normalizedPath);
for (const match of source.matchAll(/export\s+(?!type\b)\{([\s\S]*?)\}\s+from\s+"([^"]+)";/g)) { const names = match[1]
.split(",")
.map((part) => part.trim())
.filter(Boolean)
.map((part) => part.split(/\s+as\s+/).at(-1) ?? part); for (const name of names) {
exportNames.add(name);
}
}
for (const match of source.matchAll(/export\s+\*\s+from\s+"([^"]+)";/g)) { const specifier = match[1]; if (!specifier.startsWith(".")) { continue;
} const nestedPath = path.resolve(
path.dirname(normalizedPath),
specifier.replace(/\.js$/, ".ts"),
); const nestedExports = await collectRuntimeExports(nestedPath, seen); for (const name of nestedExports) {
exportNames.add(name);
}
}
return exportNames;
}
async function readIndexRuntimeExports() { return await collectRuntimeExports(pluginSdkIndexPath);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.