Files
FreeCADWasmDev/web/src/python-api-runtime.ts
wangdequan 9a7c4f0335 Save FreeCAD Web workspace sources and user validation evidence
IFC native binding remains incomplete; preserve accurate test results.
2026-09-15 22:01:58 +08:00

29 lines
1.4 KiB
TypeScript

export type PythonApiDisposition = "exposed" | "restricted" | "nonportable" | "not_implemented" | "planned";
export interface PythonApiRuntimeIndex {
schema: "freecad-web-python-api-runtime-index/v1";
source: { manifest: string; manifestSha256: string };
fields: { modules: string[]; kinds: string[]; families: string[]; tiers: string[]; dispositions: PythonApiDisposition[] };
records: [string, number, number, string, number, number, number, string?, number?][];
}
export interface PythonApiRecord {
id: string;
module: string;
kind: string;
name: string;
family: string;
tier: string;
disposition: PythonApiDisposition;
sourcePath?: string;
sourceLine?: number;
}
export function decodePythonApiRecord(index: PythonApiRuntimeIndex, row: PythonApiRuntimeIndex["records"][number]): PythonApiRecord {
return { id: row[0], module: index.fields.modules[row[1]], kind: index.fields.kinds[row[2]], name: row[3], family: index.fields.families[row[4]], tier: index.fields.tiers[row[5]], disposition: index.fields.dispositions[row[6]], ...(row[7] ? { sourcePath: row[7] } : {}), ...(typeof row[8] === "number" ? { sourceLine: row[8] } : {}) };
}
export function createPythonApiLookup(index: PythonApiRuntimeIndex): Map<string, PythonApiRecord> {
return new Map(index.records.map((row) => { const record = decodePythonApiRecord(index, row); return [record.id, record] as const; }));
}