<# .SYNOPSIS Builds MathCAT's WebAssembly braille module in Docker and copies it, with the worker the page talks to, to frontend/vendor/local/mathcat@1/, where the site serves it from /vendor/. Keeps the Cargo.lock the build used beside this script, so later builds use the same crates. Bump the @N (here and MATHCAT_WORKER in src/app/equation-editor/braille.ts) before rebuilding once a version has shipped, then run node scripts/vendor-local-lock.mjs. Nothing is installed on this machine; Docker Desktop must be running. #> $ErrorActionPreference = 'Continue' Set-Location $PSScriptRoot $dist = Join-Path $PSScriptRoot 'dist' if (Test-Path $dist) { Remove-Item -Recurse -Force $dist } & docker build --target export --output "type=local,dest=$dist" . if ($LASTEXITCODE -ne 0) { throw 'docker build failed' } $dest = Join-Path $PSScriptRoot '..\..\vendor\local\mathcat@1' New-Item -ItemType Directory -Force $dest | Out-Null foreach ($f in 'mathcat.js', 'mathcat_bg.wasm', 'LICENSE', 'THIRD-PARTY.txt') { Copy-Item (Join-Path $dist $f) $dest -Force } Copy-Item (Join-Path $PSScriptRoot 'js\worker.mjs') $dest -Force Copy-Item (Join-Path $dist 'Cargo.lock') $PSScriptRoot -Force Get-ChildItem $dest | Format-Table Name, Length