| 102 | } |
| 103 | |
| 104 | function parseTsUint32Array(tsText, exportName) { |
| 105 | const marker = `export const ${exportName} = new Uint32Array([`; |
| 106 | const start = tsText.indexOf(marker); |
| 107 | if (start < 0) throw new Error(`missing export Uint32Array: ${exportName}`); |
| 108 | const bodyStart = start + marker.length; |
| 109 | const end = tsText.indexOf("]);", bodyStart); |
| 110 | if (end < 0) throw new Error(`missing array terminator for export: ${exportName}`); |
| 111 | const body = tsText.slice(bodyStart, end); |
| 112 | const nums = body.match(/0x[0-9A-Fa-f]+|\d+/g) ?? []; |
| 113 | if (nums.length === 0) throw new Error(`parsed 0 numbers from TS array: ${exportName}`); |
| 114 | return nums.map((t) => (t.startsWith("0x") ? Number.parseInt(t, 16) : Number.parseInt(t, 10))); |
| 115 | } |
| 116 | |
| 117 | function assertEqualArray(a, b, label) { |
| 118 | if (a.length !== b.length) { |