Skip to content

Commit c602eb9

Browse files
OrKoNdependabot[bot]Piotr Paulski
committed
chore(deps-dev): bump chrome-devtools-frontend from 1.0.1613625 to 1.0.1616061 (#1952)
Closes #1908 --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Piotr Paulski <piotrpaulski@chromium.org>
1 parent 91f2f87 commit c602eb9

11 files changed

Lines changed: 62 additions & 33 deletions

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
"@types/yargs": "^17.0.33",
6464
"@typescript-eslint/eslint-plugin": "^8.43.0",
6565
"@typescript-eslint/parser": "^8.43.0",
66-
"chrome-devtools-frontend": "1.0.1613625",
66+
"chrome-devtools-frontend": "1.0.1618066",
6767
"core-js": "3.49.0",
6868
"debug": "4.4.3",
6969
"eslint": "^9.35.0",

scripts/post-build.ts

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,12 @@ export const LOCAL_FETCH_PATTERN = './locales/@LOCALE@.json';`;
5252
);
5353
fs.mkdirSync(codeMirrorDir, {recursive: true});
5454
const codeMirrorFile = path.join(codeMirrorDir, 'codemirror.next.js');
55-
const codeMirrorContent = `export default {}`;
55+
const codeMirrorContent = `
56+
export default {};
57+
export const cssStreamParser = () => Promise.resolve({ startState: () => ({}) });
58+
export class StringStream { constructor() {} }
59+
export const css = { cssLanguage: { parser: { parse: () => ({ topNode: { getChild: () => null } }) } } };
60+
`;
5661
writeFile(codeMirrorFile, codeMirrorContent);
5762

5863
// Create root mock
@@ -61,7 +66,13 @@ export const LOCAL_FETCH_PATTERN = './locales/@LOCALE@.json';`;
6166
const runtimeFile = path.join(rootDir, 'Runtime.js');
6267
const runtimeContent = `
6368
export function getChromeVersion() { return ''; };
69+
export function getRemoteBase() { return null; };
6470
export const hostConfig = {};
71+
export const GdpProfilesEnterprisePolicyValue = {
72+
ENABLED: 0,
73+
ENABLED_WITHOUT_BADGES: 1,
74+
DISABLED: 2,
75+
};
6576
export const Runtime = {
6677
isDescriptorEnabled: () => true,
6778
queryParam: () => null,
@@ -94,6 +105,33 @@ export const ExperimentName = {
94105
`;
95106
writeFile(runtimeFile, runtimeContent);
96107

108+
// Copy missing CodeMirror .mjs files that tsc ignores due to .d.mts renames
109+
const codemirrorDir = path.join(
110+
BUILD_DIR,
111+
devtoolsThirdPartyPath,
112+
'codemirror',
113+
);
114+
const codemirrorSrcDir = path.join(
115+
process.cwd(),
116+
'node_modules',
117+
'chrome-devtools-frontend',
118+
'front_end',
119+
'third_party',
120+
'codemirror',
121+
);
122+
const filesToCopy = [
123+
'package/addon/runmode/runmode-standalone.mjs',
124+
'package/mode/css/css.mjs',
125+
'package/mode/javascript/javascript.mjs',
126+
'package/mode/xml/xml.mjs',
127+
];
128+
for (const file of filesToCopy) {
129+
const src = path.join(codemirrorSrcDir, file);
130+
const dest = path.join(codemirrorDir, file);
131+
fs.mkdirSync(path.dirname(dest), {recursive: true});
132+
fs.copyFileSync(src, dest);
133+
}
134+
97135
copyDevToolsDescriptionFiles();
98136
}
99137

src/McpContext.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,10 @@ export class McpContext implements Context {
165165
this.#roots = roots;
166166
}
167167

168-
validatePath(filePath: string): void {
168+
validatePath(filePath?: string): void {
169+
if (filePath === undefined) {
170+
return;
171+
}
169172
const roots = this.roots();
170173
if (roots === undefined) {
171174
return;
@@ -676,7 +679,11 @@ export class McpContext implements Context {
676679
): Promise<{filepath: string}> {
677680
const filepath = await getTempFilePath(filename);
678681
this.validatePath(filepath);
679-
await fs.writeFile(filepath, data);
682+
try {
683+
await fs.writeFile(filepath, data);
684+
} catch (err) {
685+
throw new Error('Could not save a file', {cause: err});
686+
}
680687
return {filepath};
681688
}
682689

src/tools/ToolDefinition.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ export type SupportedExtensions =
170170
* Only add methods used by tools/*.
171171
*/
172172
export type Context = Readonly<{
173-
validatePath(filePath: string): void;
173+
validatePath(filePath?: string): void;
174174
isRunningPerformanceTrace(): boolean;
175175
setIsRunningPerformanceTrace(x: boolean): void;
176176
isCruxEnabled(): boolean;

src/tools/lighthouse.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,7 @@ export const lighthouseAudit = definePageTool({
5353
outputDirPath,
5454
} = request.params;
5555

56-
if (outputDirPath) {
57-
context.validatePath(outputDirPath);
58-
}
56+
context.validatePath(outputDirPath);
5957

6058
const flags: Flags = {
6159
onlyCategories: categories,

src/tools/network.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,8 @@ export const getNetworkRequest = definePageTool({
114114
),
115115
},
116116
handler: async (request, response, context) => {
117-
if (request.params.requestFilePath) {
118-
context.validatePath(request.params.requestFilePath);
119-
}
120-
if (request.params.responseFilePath) {
121-
context.validatePath(request.params.responseFilePath);
122-
}
117+
context.validatePath(request.params.requestFilePath);
118+
context.validatePath(request.params.responseFilePath);
123119
if (request.params.reqid) {
124120
response.attachNetworkRequest(request.params.reqid, {
125121
requestFilePath: request.params.requestFilePath,

src/tools/performance.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@ export const startTrace = definePageTool({
4949
filePath: filePathSchema,
5050
},
5151
handler: async (request, response, context) => {
52-
if (request.params.filePath) {
53-
context.validatePath(request.params.filePath);
54-
}
52+
context.validatePath(request.params.filePath);
5553
if (context.isRunningPerformanceTrace()) {
5654
response.appendResponseLine(
5755
'Error: a performance trace is already running. Use performance_stop_trace to stop it. Only one trace can be running at any given time.',
@@ -129,9 +127,7 @@ export const stopTrace = definePageTool({
129127
filePath: filePathSchema,
130128
},
131129
handler: async (request, response, context) => {
132-
if (request.params.filePath) {
133-
context.validatePath(request.params.filePath);
134-
}
130+
context.validatePath(request.params.filePath);
135131
if (!context.isRunningPerformanceTrace()) {
136132
return;
137133
}

src/tools/screencast.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@ export const startScreencast = definePageTool(args => ({
4040
),
4141
},
4242
handler: async (request, response, context) => {
43-
if (request.params.filePath) {
44-
context.validatePath(request.params.filePath);
45-
}
43+
context.validatePath(request.params.filePath);
4644
if (context.getScreenRecorder() !== null) {
4745
response.appendResponseLine(
4846
'Error: a screencast recording is already in progress. Use screencast_stop to stop it before starting a new one.',

src/tools/screenshot.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,7 @@ export const screenshot = definePageTool({
5151
),
5252
},
5353
handler: async (request, response, context) => {
54-
if (request.params.filePath) {
55-
context.validatePath(request.params.filePath);
56-
}
54+
context.validatePath(request.params.filePath);
5755
if (request.params.uid && request.params.fullPage) {
5856
throw new Error('Providing both "uid" and "fullPage" is not allowed.');
5957
}

0 commit comments

Comments
 (0)