• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

rokucommunity / roku-debug / 26120672946

19 May 2026 07:37PM UTC coverage: 70.727% (+0.7%) from 70.049%
26120672946

Pull #351

github

web-flow
Merge eb0b2e542 into 5bbd82240
Pull Request #351: 0.23.8

3328 of 5046 branches covered (65.95%)

Branch coverage included in aggregate %.

5834 of 7908 relevant lines covered (73.77%)

35.01 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

91.18
/src/debugProtocol/client/ProtocolCapabilities.ts
1
import * as semver from 'semver';
2

2✔
3
/**
2✔
4
 * Encapsulates the version-based capability checks for the BrightScript debug protocol.
2✔
5
 * Used by `DebugProtocolClient` for the live session (version set during the handshake),
6
 * and by `DebugProtocolAdapter` as a standalone fallback seeded from the device-info
7
 * `brightscript-debugger-version` when no client has connected yet.
8
 */
9
export class ProtocolCapabilities {
10
    constructor(protocolVersion: string | undefined, osVersion?: string) {
11
        this.protocolVersion = ProtocolCapabilities.resolveProtocolVersion(protocolVersion, osVersion);
12
    }
13

133✔
14
    public readonly protocolVersion: string;
15

16
    /**
17
     * Roku OS versions that introduced each debug protocol version, ordered newest-first so
18
     * we can pick the highest protocol whose OS floor the device meets.
19
     */
20
    private static readonly osToProtocolVersions: ReadonlyArray<{ os: string; protocol: string }> = [
21
        { os: '14.1.0', protocol: '3.3.0' },
133✔
22
        { os: '12.0.0', protocol: '3.2.0' },
88✔
23
        { os: '11.5.0', protocol: '3.1.0' },
24
        { os: '11.0.0', protocol: '3.0.0' },
45✔
25
        { os: '9.3.0', protocol: '2.0.0' },
45✔
26
        { os: '9.2.0', protocol: '1.0.1' }
2✔
27
    ];
28

43✔
29
    /**
135✔
30
     * Some Roku firmware versions support the debug protocol but omit `brightscript-debugger-version`
42✔
31
     * from device-info, so fall back to deriving the protocol version from the OS version when the
32
     * caller didn't get one from the device.
33
     */
1✔
34
    private static resolveProtocolVersion(protocolVersion: string | undefined, osVersion: string | undefined): string {
35
        if (semver.valid(protocolVersion)) {
36
            return protocolVersion;
37
        }
38
        const coercedOs = osVersion ? semver.coerce(osVersion) : null;
39
        if (!coercedOs) {
40
            return protocolVersion;
19✔
41
        }
42
        for (const entry of ProtocolCapabilities.osToProtocolVersions) {
43
            if (semver.gte(coercedOs, entry.os)) {
44
                return entry.protocol;
45
            }
46
        }
47
        return protocolVersion;
21✔
48
    }
49

50
    /**
51
     * Prior to protocol v3.1.0, the Roku device would regularly set the wrong thread as "active",
52
     * so this flag lets us know if we should use our better-than-nothing workaround
53
     */
15✔
54
    public get enableThreadHoppingWorkaround() {
55
        return semver.satisfies(this.protocolVersion, '<3.1.0');
56
    }
57

58
    /**
59
     * Starting in protocol v3.1.0, component library breakpoints must be added in the format
×
60
     * `lib:/<library_name>/<filepath>`, but prior they didn't require this.
61
     */
62
    public get enableComponentLibrarySpecificBreakpoints() {
34✔
63
        return semver.satisfies(this.protocolVersion, '>=3.1.0');
64
    }
65

12✔
66
    /**
67
     * Starting in protocol v3.1.0, breakpoints can support conditional expressions.
68
     */
24✔
69
    public get supportsConditionalBreakpoints() {
70
        return semver.satisfies(this.protocolVersion, '>=3.1.0');
71
    }
4✔
72

73
    /**
74
     * Starting in protocol v3.1.0, breakpoints can carry a hit count (ignoreCount).
75
     */
76
    public get supportsHitConditionalBreakpoints() {
77
        return semver.satisfies(this.protocolVersion, '>=3.1.0');
78
    }
4✔
79

80
    public get supportsBreakpointRegistrationWhileRunning() {
81
        return semver.satisfies(this.protocolVersion, '>=3.2.0');
82
    }
83

84
    public get supportsBreakpointVerification() {
×
85
        return semver.satisfies(this.protocolVersion, '>=3.2.0');
86
    }
87

88
    public get supportsVirtualVariables() {
89
        return semver.satisfies(this.protocolVersion, '>=3.3.0');
90
    }
×
91

92
    public get supportsExceptionBreakpoints() {
93
        return semver.satisfies(this.protocolVersion, '>=3.3.0');
2✔
94
    }
95

96
    /**
97
     * Due to casing issues with the variables request on older protocols, we first try the
98
     * request in the supplied case and retry in lower case on failure.
2✔
99
     */
100
    public get enableVariablesLowerCaseRetry() {
101
        return semver.satisfies(this.protocolVersion, '<3.1.0');
102
    }
103

104
    /**
105
     * The `execute` command was unreliable before protocol v3.0.0.
106
     */
107
    public get supportsExecuteCommand() {
108
        return semver.satisfies(this.protocolVersion, '>=3.0.0');
109
    }
110

111
    /**
112
     * The device emits compile-error update events starting in protocol v3.1.0.
113
     */
114
    public get supportsCompileErrorReporting() {
115
        return semver.satisfies(this.protocolVersion, '>=3.1.0');
116
    }
117
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc