feat: advance FreeCAD parity and native OCCT history

This commit is contained in:
2026-08-03 08:04:10 -04:00
parent 2ce261b982
commit e5a5d74dbc
32 changed files with 1883 additions and 30 deletions

View File

@@ -22,11 +22,19 @@ export type FcstdEntryMetadata = {
export type FcstdObjectSupport = 'recognized' | 'proxy' | 'blocked'
export type FcstdPropertySummary = {
name: string
typeId: string
element: string
value: string
}
export type FcstdObjectSummary = {
name: string
label: string
typeId: string
propertyCount: number
properties: FcstdPropertySummary[]
support: FcstdObjectSupport
}
@@ -179,6 +187,18 @@ const propertyValue = (property: Record<string, unknown>): string => {
return ''
}
const propertyElement = (property: Record<string, unknown>): string => {
const entry = Object.entries(property).find(([name, value]) => !name.startsWith('@_') && Boolean(value && typeof value === 'object'))
return entry?.[0] || ''
}
const propertySummaries = (properties: Record<string, unknown>[]): FcstdPropertySummary[] => properties.map((property) => ({
name: attribute(property, 'name') || '<unnamed>',
typeId: attribute(property, 'type') || propertyElement(property) || 'unknown',
element: propertyElement(property),
value: propertyValue(property),
}))
const parseDocumentXml = (bytes: Uint8Array) => {
const xml = new TextDecoder('utf-8', { fatal: true }).decode(bytes)
if (/<!DOCTYPE|<!ENTITY/i.test(xml)) throw new Error('FCStd Document.xml declarations and entities are not allowed.')
@@ -202,7 +222,7 @@ const parseDocumentXml = (bytes: Uint8Array) => {
const properties = asArray((((data?.Properties as Record<string, unknown> | undefined)?.Property) as Record<string, unknown> | Record<string, unknown>[] | undefined))
const objectLabelProperty = properties.find((property) => attribute(property, 'name') === 'Label')
const support: FcstdObjectSupport = blockedTypeId(typeId) ? 'blocked' : recognizedTypeIds.has(typeId) ? 'recognized' : 'proxy'
return { name, label: objectLabelProperty ? propertyValue(objectLabelProperty) || name : name, typeId, propertyCount: properties.length, support }
return { name, label: objectLabelProperty ? propertyValue(objectLabelProperty) || name : name, typeId, propertyCount: properties.length, properties: propertySummaries(properties), support }
})
return {
schemaVersion: attribute(root, 'SchemaVersion') || attribute(root, 'schemaVersion') || 'unknown',