Files
Web_FreeCAD_Bitbybit/scripts/check-chrome-native-hole-history.mjs

12 lines
2.4 KiB
JavaScript

import { readFile } from 'node:fs/promises'
import { resolve } from 'node:path'
const root = resolve(new URL('..', import.meta.url).pathname); const report = JSON.parse(await readFile(resolve(root, 'config/chrome-native-hole-history-verification.json'), 'utf8'))
if (report.schemaVersion !== 1 || report.browserId !== 'chrome' || report.executionContext !== 'geometry-and-history-workers' || report.crossOriginIsolated !== true || report.status !== 'pass') throw new Error('Chrome native Hole history evidence is invalid.')
if (report.capabilities?.status !== 'ready' || report.nativeCapabilities?.availability !== 'available' || report.nativeCapabilities?.operations?.includes('hole') !== true) throw new Error('Native OCCT Hole Worker capability evidence is incomplete.')
const stages = report.history?.stages || []
if (!Number.isSafeInteger(report.history?.recordCount) || report.history.recordCount <= 0 || report.history.relations?.modified <= 0 || report.history.relations?.deleted <= 0 || stages.length !== 2 || stages[0]?.operation !== 'hole' || stages[0]?.inputObjectIds?.length !== 0 || stages[0]?.topologyEntries <= 0 || stages[1]?.operation !== 'cut' || JSON.stringify(stages[1]?.inputObjectIds) !== JSON.stringify(['Base', stages[0]?.resultObjectId]) || stages[1]?.topologyEntries <= 0 || JSON.stringify(report.history.sourceObjects) !== JSON.stringify(['Base', stages[0]?.resultObjectId]) || JSON.stringify(report.history.resultStageIds) !== JSON.stringify([stages[1]?.stageId])) throw new Error('Native OCCT Hole staged relation evidence is incomplete.')
if (report.result?.structuralValid !== true || report.result?.solids !== 1 || !(report.result.volume > 0 && report.result.volume < 1000)) throw new Error('Native OCCT Hole result evidence is invalid.')
if (report.opfs?.markerCreated !== true || report.opfs?.markerSuite !== 'hole' || report.opfs?.markerRemoved !== true) throw new Error('Chrome native Hole OPFS evidence is incomplete.')
if (report.afterRelease?.shapeCount !== 0 || report.afterRelease?.kernelReferenceCount !== 0) throw new Error('Chrome native Hole history handles were not released.')
console.log(JSON.stringify({ status: 'chrome-native-hole-history-pass', browserId: report.browserId, occtVersion: report.nativeCapabilities.occtVersion, records: report.history.recordCount, relations: report.history.relations, stages, volume: report.result.volume, opfs: report.opfs, afterRelease: report.afterRelease }, null, 2))