Files
fpv-rid-workbench/scripts/package.ps1
T
JiuContinent cd1b717e74 ```
feat(geofences): 新增地理围栏模块并优化地图瓦片缓存

在 rid-shared 中实现二维 WGS84 地理围栏核心逻辑,支持圆形与多边形
两种几何体,包含坐标合法性校验、边界包含判断及自相交检测。
realtime-core 的 Store 新增观察者回调,在观测数据接受后按到达顺序
通知监听器。

前端方面,新增 geofence-map-adapter.js 提供基于 MapLibre 的围栏绘制
与编辑能力,配套 geofences.css 完成响应式布局样式。map-loader.js
增加懒加载入口,仅在实时工作区按需引入围栏地图模块。

同时引入 map-tile-buffer 瓦片缓冲机制,改善地图切换与刷新时的加载
体验;将默认缩放级别从 11 调整为 15,使初始视图更贴近实际监测场景。
```
2026-10-23 13:55:08 +08:00

108 lines
7.2 KiB
PowerShell

param([string]$OutputRoot)
$ErrorActionPreference = 'Stop'
. (Join-Path $PSScriptRoot 'rust-env.ps1')
$ridRepo = Split-Path $PSScriptRoot -Parent
if (-not $OutputRoot) { $OutputRoot = Join-Path $ridRepo 'dist' }
$ridOutputRoot = [IO.Path]::GetFullPath($OutputRoot)
$ridDestination = Join-Path $ridOutputRoot 'FPV-RID-Rust'
$ridWhitelist = @('fpv-rid-registry.exe', 'rid-map-downloader.exe', 'map-downloader-LICENSE.txt', '启动Rust版.cmd', '使用说明.md', 'third-party-licenses.txt', 'dependency-licenses.txt', 'build-info.json', 'SHA256SUMS.txt')
function Assert-CleanDestination {
if (Test-Path -LiteralPath $ridDestination) {
foreach ($ridEntry in Get-ChildItem -LiteralPath $ridDestination -Force) {
if ($ridEntry.PSIsContainer -or ($ridEntry.Name -notin $ridWhitelist -and $ridEntry.Name -ne 'qrcode-LICENSE.txt') -or
($ridEntry.Attributes -band [IO.FileAttributes]::ReparsePoint)) {
throw "发布目录含运行数据或非发布文件,已停止打包并保留原内容:$($ridEntry.FullName)。请通过 -OutputRoot 指定单独的输出目录。"
}
}
}
}
function Get-RidSourceManifest {
$ridInputs = @('Cargo.toml','Cargo.lock','rust-toolchain.toml','build.rs') | ForEach-Object { Get-Item -LiteralPath (Join-Path $ridRepo $_) }
$ridInputs += @('src','crates','xtask','scripts','.cargo') | ForEach-Object { Get-ChildItem -LiteralPath (Join-Path $ridRepo $_) -Recurse -File }
@($ridInputs | Sort-Object FullName | ForEach-Object { [ordered]@{path=$_.FullName.Substring($ridRepo.Length + 1).Replace('\','/');sha256=(Get-FileHash -LiteralPath $_.FullName -Algorithm SHA256).Hash} })
}
# Refuse a used deployment folder before building or changing any published files.
Assert-CleanDestination
& (Join-Path $PSScriptRoot 'build-map-downloader.ps1')
$ridStageRoot = Join-Path $ridOutputRoot ('.package-' + [guid]::NewGuid().ToString('N'))
$ridStage = Join-Path $ridStageRoot 'FPV-RID-Rust'
$ridTemporaryZip = Join-Path $ridStageRoot 'release.zip'
Push-Location $ridRepo
$ridBuildLock = $null
$ridOldBuildOwner = $env:RID_PACKAGE_BUILD
try {
$ridBuildLock = [IO.File]::Open((Join-Path $ridRepo '.build.lock'), [IO.FileMode]::OpenOrCreate, [IO.FileAccess]::ReadWrite, [IO.FileShare]::None)
$env:RID_PACKAGE_BUILD = '1'
$ridInitialManifest = @(Get-RidSourceManifest)
$ridInitialManifestJson = ConvertTo-Json -InputObject $ridInitialManifest -Depth 5 -Compress
cargo xtask web
if ($LASTEXITCODE -ne 0) { throw 'Rust frontend build failed' }
cargo build --release --locked -p fpv-rid-registry
if ($LASTEXITCODE -ne 0) { throw 'Release build failed' }
$ridMetadata = cargo metadata --locked --format-version 1 --no-deps | ConvertFrom-Json
if ($LASTEXITCODE -ne 0) { throw 'Cargo metadata failed' }
New-Item -ItemType Directory -Force -Path $ridStage | Out-Null
Copy-Item -LiteralPath (Join-Path $ridMetadata.target_directory 'release/fpv-rid-registry-fullstack.exe') -Destination (Join-Path $ridStage 'fpv-rid-registry.exe')
Copy-Item -LiteralPath $env:RID_MAP_DOWNLOADER -Destination (Join-Path $ridStage 'rid-map-downloader.exe')
Copy-Item -LiteralPath (Join-Path $PSScriptRoot 'map-downloader/LICENSE-upstream.txt') -Destination (Join-Path $ridStage 'map-downloader-LICENSE.txt')
Copy-Item -LiteralPath (Join-Path $ridRepo '启动Rust版.cmd') -Destination $ridStage
Copy-Item -LiteralPath (Join-Path $ridRepo 'doc/registry/rust/使用说明.md') -Destination $ridStage
Copy-Item -LiteralPath (Join-Path $ridRepo 'crates/web-ui/public/vendor/LICENSE.txt') -Destination (Join-Path $ridStage 'third-party-licenses.txt')
$ridLicenses = cargo tree --workspace --locked --prefix none --format '{p} {l}'
if ($LASTEXITCODE -ne 0) { throw 'Dependency inventory failed' }
$ridLicenses | Set-Content -LiteralPath (Join-Path $ridStage 'dependency-licenses.txt') -Encoding utf8
Get-Content -LiteralPath (Join-Path $ridRepo 'crates/web-ui/public/vendor/LICENSE.txt') | Add-Content -LiteralPath (Join-Path $ridStage 'dependency-licenses.txt') -Encoding utf8
$ridSourceManifest = @(Get-RidSourceManifest)
if ((ConvertTo-Json -InputObject $ridSourceManifest -Depth 5 -Compress) -ne $ridInitialManifestJson) { throw '源码在构建期间发生变化,已停止发布并保留原发布包;请在源码稳定后重新构建。' }
$ridBuildInfo = [ordered]@{
builtAtUtc=[DateTime]::UtcNow.ToString('o')
gitRevision=(git rev-parse HEAD)
workingTreeDirty=[bool](git status --porcelain)
rust=(rustc --version)
trunk='0.22.0'
wasmBindgen='0.2.129'
executableSha256=(Get-FileHash -LiteralPath (Join-Path $ridStage 'fpv-rid-registry.exe') -Algorithm SHA256).Hash
sourceManifest=$ridSourceManifest
}
$ridBuildInfo | ConvertTo-Json -Depth 6 | Set-Content -LiteralPath (Join-Path $ridStage 'build-info.json') -Encoding utf8
$ridWhitelist | Where-Object { $_ -ne 'SHA256SUMS.txt' } | ForEach-Object {
'{0} {1}' -f (Get-FileHash -LiteralPath (Join-Path $ridStage $_) -Algorithm SHA256).Hash, $_
} | Set-Content -LiteralPath (Join-Path $ridStage 'SHA256SUMS.txt') -Encoding utf8
$ridActual = @(Get-ChildItem -LiteralPath $ridStage -Force)
if ($ridActual.Count -ne $ridWhitelist.Count -or @($ridActual | Where-Object { $_.PSIsContainer -or $_.Name -notin $ridWhitelist }).Count) {
throw 'Staging directory does not match the release whitelist'
}
# Only the fresh, checked staging tree is ever compressed.
Compress-Archive -LiteralPath $ridStage -DestinationPath $ridTemporaryZip
Assert-CleanDestination
New-Item -ItemType Directory -Force -Path $ridDestination | Out-Null
foreach ($ridName in $ridWhitelist) {
Copy-Item -LiteralPath (Join-Path $ridStage $ridName) -Destination (Join-Path $ridDestination $ridName)
}
$ridObsoleteLicense = Join-Path $ridDestination 'qrcode-LICENSE.txt'
if (Test-Path -LiteralPath $ridObsoleteLicense -PathType Leaf) { Remove-Item -LiteralPath $ridObsoleteLicense }
$ridZip = Join-Path $ridOutputRoot 'FPV-RID-Rust-Windows-x64.zip'
Move-Item -LiteralPath $ridTemporaryZip -Destination $ridZip -Force
'{0} FPV-RID-Rust-Windows-x64.zip' -f (Get-FileHash -LiteralPath $ridZip -Algorithm SHA256).Hash |
Set-Content -LiteralPath "$ridZip.sha256" -Encoding utf8
Write-Output $ridDestination
Write-Output $ridZip
} finally {
$env:RID_PACKAGE_BUILD = $ridOldBuildOwner
if ($ridBuildLock) { $ridBuildLock.Dispose() }
Pop-Location
# Clean only files this invocation created. Never recursively delete an output directory.
foreach ($ridName in $ridWhitelist) {
$ridOwnedFile = Join-Path $ridStage $ridName
if (Test-Path -LiteralPath $ridOwnedFile -PathType Leaf) { Remove-Item -LiteralPath $ridOwnedFile }
}
if (Test-Path -LiteralPath $ridTemporaryZip -PathType Leaf) { Remove-Item -LiteralPath $ridTemporaryZip }
if ((Test-Path -LiteralPath $ridStage -PathType Container) -and @(Get-ChildItem -LiteralPath $ridStage -Force).Count -eq 0) { Remove-Item -LiteralPath $ridStage }
if ((Test-Path -LiteralPath $ridStageRoot -PathType Container) -and @(Get-ChildItem -LiteralPath $ridStageRoot -Force).Count -eq 0) { Remove-Item -LiteralPath $ridStageRoot }
}