Files
Web_FreeCAD_Bitbybit/public/chrome-native-pad-history-harness.html

39 lines
2.8 KiB
HTML

<!doctype html>
<meta charset="utf-8">
<title>Chrome native Pad history harness</title>
<pre id="status">loading</pre>
<script type="module">
import { NativeOcctHistoryCoordinator } from '/src/facade/nativeHistoryProtocol.ts'
import { NativeOcctHistoryWorkerProvider } from '/src/facade/nativeHistoryWorkerClient.ts'
const report = { schemaVersion: 1, browserId: 'chrome', executionContext: 'dedicated-worker', crossOriginIsolated, status: 'failed' }
let provider
try {
const profileStep = await fetch('/native-pad-profile.step').then((response) => response.ok ? response.text() : Promise.reject(new Error(`Pad profile fixture failed: ${response.status}`)))
provider = new NativeOcctHistoryWorkerProvider()
const capabilities = await provider.initialize()
const execution = await new NativeOcctHistoryCoordinator(() => 1).capture(provider, {
documentId: 'chrome-native-pad', documentVersion: 1, operationId: 'pad-history', operation: 'pad', objectStep: profileStep, direction: [0, 0, 5],
})
const history = execution.response?.history
const records = history?.records || []
const crossKind = records.filter((record) => record.resultKind && record.resultKind !== record.kind)
const summary = history?.summary
const validRelations = records.every((record) => ['modified', 'generated', 'deleted'].includes(record.relation) && Number.isSafeInteger(record.sourceIndex) && record.sourceIndex >= 0)
const profileKinds = new Set(records.map((record) => record.kind))
const shapeSummary = summary && typeof summary === 'object' ? summary : null
Object.assign(report, {
status: capabilities.availability === 'available' && capabilities.operations.includes('pad') && execution.status === 'completed' && records.length > 0 && validRelations && crossKind.length > 0 && profileKinds.has('vertex') && profileKinds.has('edge') && profileKinds.has('face') && shapeSummary?.isValid === true && shapeSummary?.solids === 1 && Math.abs(shapeSummary.volume - 30) <= 1e-7 ? 'pass' : 'failed',
nativeCapabilities: capabilities,
execution: { status: execution.status, recordCount: records.length, crossKindRecords: crossKind.length, relations: { modified: records.filter((record) => record.relation === 'modified').length, generated: records.filter((record) => record.relation === 'generated').length, deleted: records.filter((record) => record.relation === 'deleted').length }, profileKinds: [...profileKinds], summary: shapeSummary },
})
} catch (error) {
report.error = error instanceof Error ? `${error.name}: ${error.message}` : String(error)
} finally {
provider?.dispose()
report.workerDisposed = true
}
document.querySelector('#status').textContent = JSON.stringify(report, null, 2)
await fetch('/__native-pad-history-report', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify(report) })
</script>