mirror of
https://github.com/ChromeDevTools/chrome-devtools-mcp.git
synced 2026-11-04 05:02:31 +00:00
refactor: use #private names instead of the private modifier (#3301)
Stacked on #3300. Converts the two remaining `private` members to ECMAScript private names: `TextSnapshot.insertExtraNodes()` and `Result.nextCallIndex` in `scripts/eval_result.ts`. The rest of the code already uses `#`. This matches the DevTools [`prefer-private-class-members`](https://source.chromium.org/chromium/chromium/src/+/main:third_party/devtools-frontend/src/scripts/eslint_rules/lib/prefer-private-class-members.ts) ESLint rule. ## User-visible changes None. ## Testing - `npm run format` - `npm run test`
This commit is contained in:
1 parent
3da5985b34
commit
2e13311bb3
2 files changed
+14
-14
No files matched your search
+12
-12
@@ -12,7 +12,7 @@ export interface CapturedFunctionCall {
|
||||
}
|
||||
|
||||
export class Result {
|
||||
private nextCallIndex = 0;
|
||||
#nextCallIndex = 0;
|
||||
readonly calls: CapturedFunctionCall[];
|
||||
readonly serverArgs: string[];
|
||||
/** The model's final response text. */
|
||||
@@ -29,7 +29,7 @@ export class Result {
|
||||
}
|
||||
|
||||
get remainingCalls(): CapturedFunctionCall[] {
|
||||
return this.calls.slice(this.nextCallIndex);
|
||||
return this.calls.slice(this.#nextCallIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -40,20 +40,20 @@ export class Result {
|
||||
* - Returns the active pageId.
|
||||
*/
|
||||
consumePageNavigation(): number | undefined {
|
||||
if (this.calls[this.nextCallIndex]?.name === 'list_pages') {
|
||||
this.nextCallIndex++;
|
||||
if (this.calls[this.#nextCallIndex]?.name === 'list_pages') {
|
||||
this.#nextCallIndex++;
|
||||
}
|
||||
|
||||
const navCall = this.calls[this.nextCallIndex];
|
||||
const navCall = this.calls[this.#nextCallIndex];
|
||||
assert.ok(
|
||||
navCall &&
|
||||
(navCall.name === 'new_page' || navCall.name === 'navigate_page'),
|
||||
`Expected navigation call (new_page or navigate_page), but got: ${navCall?.name || 'none'}`,
|
||||
);
|
||||
this.nextCallIndex++;
|
||||
this.#nextCallIndex++;
|
||||
|
||||
if (this.calls[this.nextCallIndex]?.name === 'list_pages') {
|
||||
this.nextCallIndex++;
|
||||
if (this.calls[this.#nextCallIndex]?.name === 'list_pages') {
|
||||
this.#nextCallIndex++;
|
||||
}
|
||||
|
||||
const isNewPage = navCall.name === 'new_page';
|
||||
@@ -73,15 +73,15 @@ export class Result {
|
||||
name: string,
|
||||
expectedArgs?: Record<string, unknown>,
|
||||
): CapturedFunctionCall {
|
||||
const call = this.calls[this.nextCallIndex];
|
||||
const call = this.calls[this.#nextCallIndex];
|
||||
assert.ok(
|
||||
call,
|
||||
`Expected call at index ${this.nextCallIndex} (name: '${name}') to exist`,
|
||||
`Expected call at index ${this.#nextCallIndex} (name: '${name}') to exist`,
|
||||
);
|
||||
assert.strictEqual(
|
||||
call.name,
|
||||
name,
|
||||
`Expected call at index ${this.nextCallIndex} to be '${name}', but got '${call.name}'`,
|
||||
`Expected call at index ${this.#nextCallIndex} to be '${name}', but got '${call.name}'`,
|
||||
);
|
||||
|
||||
if (expectedArgs) {
|
||||
@@ -96,7 +96,7 @@ export class Result {
|
||||
}
|
||||
}
|
||||
|
||||
this.nextCallIndex++;
|
||||
this.#nextCallIndex++;
|
||||
return call;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -135,7 +135,7 @@ export class TextSnapshot {
|
||||
|
||||
const rootNodeWithId = assignIds(rootNode);
|
||||
|
||||
await TextSnapshot.insertExtraNodes(
|
||||
await TextSnapshot.#insertExtraNodes(
|
||||
page,
|
||||
idToNode,
|
||||
seenUniqueIds,
|
||||
@@ -195,7 +195,7 @@ export class TextSnapshot {
|
||||
// ExtraHandles represent DOM nodes which might not be part of the accessibility tree, e.g. DOM nodes
|
||||
// returned by third-party developer tools. We insert them into the tree by finding the closest ancestor
|
||||
// in the tree and inserting the node as a child. The ancestor's child nodes are re-parented if necessary.
|
||||
private static async insertExtraNodes(
|
||||
static async #insertExtraNodes(
|
||||
page: McpPage,
|
||||
idToNode: Map<string, TextSnapshotNode>,
|
||||
seenUniqueIds: Set<string>,
|
||||
|
||||
Reference in new issue
Block a user