Files
Web_FreeCAD_Bitbybit/scripts/generate-freecad-property-linksubhidden-inventory.mjs
wangdequan 7bd7ff5055
Some checks failed
real-verification / chrome (push) Has been cancelled
real-verification / freecad-oracle (push) Has been cancelled
real-verification / wasm (push) Has been cancelled
feat: close hidden link property evidence
2026-08-17 17:31:34 -04:00

48 lines
4.4 KiB
JavaScript

import { createHash } from 'node:crypto'
import { readFile, writeFile } from 'node:fs/promises'
import { resolve } from 'node:path'
const root = resolve(new URL('..', import.meta.url).pathname)
const runtimePath = '.cache/freecad/reference-desktop.json'
const sourcePaths = [
'.cache/freecad/FreeCAD/src/App/PropertyLinks.h',
'.cache/freecad/FreeCAD/src/App/PropertyLinks.cpp',
'.cache/freecad/FreeCAD/src/App/Link.h',
'.cache/freecad/FreeCAD/src/Mod/Draft/draftobjects/draftlink.py',
]
const outputPath = resolve(root, 'config/freecad-property-linksubhidden-inventory.json')
const [runtimeContent, ...sourceContents] = await Promise.all([readFile(resolve(root, runtimePath)), ...sourcePaths.map((path) => readFile(resolve(root, path)))])
const runtime = JSON.parse(runtimeContent)
const fail = (message) => { throw new Error(`FreeCAD PropertyLinkSubHidden inventory generation failed: ${message}`) }
if (runtime.schemaVersion !== 1 || runtime.freecadVersion !== '1.1.1' || runtime.gitCommit !== '0108fd4b4850cc46e625b60e53cea7a7bbe69f8d') fail('desktop oracle is not the locked FreeCAD baseline')
const records = []
for (const objectType of runtime.runtimeObjects?.types ?? []) for (const property of objectType.properties ?? []) {
if (property.typeId !== 'App::PropertyLinkSubHidden') continue
records.push({
objectTypeId: objectType.typeId,
objectAvailable: objectType.available === true,
probeStatus: objectType.probeStatus,
propertyName: property.name,
group: property.group,
statusRaw: property.status,
statusNames: property.status.map((status) => status === 26 ? 'PropHidden' : status),
defaultRaw: property.default,
valueModel: { kind: 'hidden-document-object-sub-element-reference', inheritedFrom: 'App::PropertyLinkSub', elementType: 'same-document App::DocumentObject plus ordered sub-element names', orderPreserved: true, duplicatesPreserved: false, writable: true },
inputs: { nativeCppSetValues: 'attached same-document DocumentObject plus sub-element string list', emptySubListMeansWholeObject: true, nullObjectClears: true, detachedObjectRejected: true, crossDocumentRejectedWithoutLinkAllowExternal: true, invalidSubElementAcceptedAsReference: true },
dependencies: { linkScope: 'Hidden', createsBacklinks: false, includedByDefaultGetLinks: false, includedByGetLinksAll: true, defaultDagDependency: false },
applicability: { requiredObjectTypeId: objectType.typeId, role: 'Link colored element override lookup', propertyWriteRequiresShape: false, source: 'Link extension and Draft colored element implementation' },
})
}
records.sort((left, right) => `${left.objectTypeId}.${left.propertyName}`.localeCompare(`${right.objectTypeId}.${right.propertyName}`))
if (records.length !== 4 || new Set(records.map(({ objectTypeId }) => objectTypeId)).size !== 4) fail(`expected four native App::PropertyLinkSubHidden records, found ${records.length}`)
const report = {
schemaVersion: 1, status: 'pass', baseline: { freecadVersion: runtime.freecadVersion, commit: runtime.gitCommit }, propertyType: 'App::PropertyLinkSubHidden', recordCount: records.length, objectTypeCount: new Set(records.map(({ objectTypeId }) => objectTypeId)).size, writableRecordCount: records.filter(({ valueModel }) => valueModel.writable).length, records,
typeContract: { inheritedFrom: 'App::PropertyLinkSub', linkScope: 'Hidden', propertyStatus: 'PropHidden', dynamicStatus: 'LockDynamic', propertyStatusPurpose: 'hide the ColoredElements property from the ordinary editor surface', linkScopePurpose: 'exclude ColoredElements from ordinary backlink and dependency traversal', xmlElement: 'LinkSub', xmlChildElement: 'Sub', legacyRestoreType: 'App::PropertyLinkSub', emptySubListMeans: 'whole-object-reference' },
provenance: { runtime: { path: runtimePath, bytes: runtimeContent.length, sha256: createHash('sha256').update(runtimeContent).digest('hex') }, sources: sourcePaths.map((path, index) => ({ path, bytes: sourceContents[index].length, sha256: createHash('sha256').update(sourceContents[index]).digest('hex') })) },
classification: 'opaque-fcstd-proxy', nextPhases: ['B', 'C', 'D', 'E', 'F', 'G', 'H', 'I'],
}
await writeFile(outputPath, `${JSON.stringify(report, null, 2)}\n`)
console.log(JSON.stringify({ status: 'freecad-property-linksubhidden-inventory-generated', output: 'config/freecad-property-linksubhidden-inventory.json', propertyType: report.propertyType, recordCount: report.recordCount, writableRecordCount: report.writableRecordCount }, null, 2))