Modules/businessdev.ALbuild.Containers/Private/Get-BcCaptureResource.ps1

function Get-BcCaptureResource {
    <#
    .SYNOPSIS
        Locates the capture engine resources shipped inside the module and the browser version they pin.
 
    .DESCRIPTION
        The capture engine ('albuild screenshot') drives a headless browser through Playwright. The
        module ships the engine and a package.json that PINS an exact Playwright version; it does NOT
        ship the browser - that is installed on demand by Install-BcCaptureBrowser.
 
        The pin lives in ONE place, that package.json, and both the status check and the installer read
        it from here. A version duplicated between a PowerShell constant and an npm manifest drifts, and
        the symptom of drift is a status check that reports ready against a folder holding a different
        browser than the one the engine will actually launch.
 
        The pin is EXACT (no caret, no range) on purpose. A Chromium build change moves rendering and
        accessible names, which is exactly what the capture engine matches on - a floating version makes
        two screenshot runs incomparable without anything saying so.
 
    .OUTPUTS
        PSCustomObject with Folder, ManifestPath and PlaywrightVersion.
    #>

    [CmdletBinding()]
    [OutputType([PSCustomObject])]
    param()

    # $script:ModuleRoot is set by the nested module's psm1; the $PSScriptRoot fallback keeps this
    # working when the file is dot-sourced directly (which the unit tests do).
    $root = $null
    if (Get-Variable -Name ModuleRoot -Scope Script -ErrorAction SilentlyContinue) { $root = $script:ModuleRoot }
    if (-not $root) { $root = Split-Path -Path $PSScriptRoot -Parent }

    $folder = Join-Path -Path (Join-Path -Path $root -ChildPath 'Resources') -ChildPath 'capture'
    $manifestPath = Join-Path -Path $folder -ChildPath 'package.json'

    if (-not (Test-Path -LiteralPath $manifestPath)) {
        throw ("The capture engine resources are missing from the module (expected '$manifestPath'). " +
            'Reinstall businessdev.ALbuild, or run Repair-ALbuildModule.')
    }

    $manifest = Get-Content -LiteralPath $manifestPath -Raw | ConvertFrom-Json

    $version = ''
    if ($manifest.PSObject.Properties['dependencies'] -and
        $manifest.dependencies.PSObject.Properties['playwright']) {
        $version = "$($manifest.dependencies.playwright)".Trim()
    }
    if ($version -notmatch '^\d+\.\d+\.\d+$') {
        throw ("'$manifestPath' must pin an exact Playwright version in dependencies.playwright " +
            "(found '$version'). A range would let the browser change under a capture run.")
    }

    [PSCustomObject]@{
        Folder            = $folder
        ManifestPath      = $manifestPath
        PlaywrightVersion = $version
    }
}