1import { access, readFile } from 'node:fs/promises'2import { createHash } from 'node:crypto'34const hash = async path => createHash('sha256').update(await readFile(new URL(path, import.meta.url))).digest('hex')5const expected = {6 '../dist/js/app.min.js': '34ae0b955b4cd1cf27ab0683665549026ccded7673d2d6c4b3cfaaa839aaf446',7 '../dist/js/export.js': '2dbdaad9adb96af52937f38dfccee03b39f771d621e75f0ae93f40c04f9e3b46',8 '../dist/js/export-init.js': 'cf9b6518b7f34c62ff0cc3f1f049fae340d2e7f8b486b3261ee5bff211a73d58',9 '../dist/js/shapes-14-6-5.min.js': '9c7a0ab5f29ebff9a8caac93219f2cd4b7b9622f9f5aa315bd148387e72848ec',10}11for (const [path, digest] of Object.entries(expected)) {12 if (await hash(path) !== digest) throw new Error(`${path} is not the pinned diagrams.net v29.6.1 export asset.`)13}14for (const path of [15 '../dist/SOURCE.md',16 '../dist/licenses/Apache-2.0.txt',17 '../dist/licenses/ASSET-TERMS.txt',18 '../dist/js/app.min.js',19 '../dist/js/export-init.js',20 '../dist/js/export.js',21 '../dist/js/shapes-14-6-5.min.js',22 '../dist/math4/es5/startup.js',23 '../dist/shapes/mxAWS4.js',24 '../dist/stencils/aws4.xml',25]) await access(new URL(path, import.meta.url))26for (const path of ['../dist/images/', '../dist/mxgraph/src/', '../dist/mxgraph/mxClient.js']) {27 try {28 await access(new URL(path, import.meta.url))29 throw new Error(`Editor-only diagrams.net asset unexpectedly shipped: ${path}`)30 } catch (error) {31 if (error?.code !== 'ENOENT') throw error32 }33}34const frame = await readFile(new URL('../src/frame.js', import.meta.url), 'utf8')35for (const required of ['diagram.zip:renderer:v1', 'LoadingComplete', 'MAX_SOURCE_LENGTH', 'MAX_OUTPUT_LENGTH', 'event.source !== parent']) {36 if (!frame.includes(required)) throw new Error(`Browser Run frame contract is missing ${required}.`)37}38console.log('diagrams.net Browser Run frame asset and protocol checks passed')