chore: introduce response type (#738)
This commit is contained in:
parent
c2b98dc70b
commit
601a74305c
32 changed files with 443 additions and 526 deletions
|
|
@ -35,20 +35,12 @@ const pdf = defineTabTool({
|
|||
type: 'readOnly',
|
||||
},
|
||||
|
||||
handle: async (tab, params) => {
|
||||
handle: async (tab, params, response) => {
|
||||
const fileName = await outputFile(tab.context.config, params.filename ?? `page-${new Date().toISOString()}.pdf`);
|
||||
|
||||
const code = [
|
||||
`// Save page as ${fileName}`,
|
||||
`await page.pdf(${javascript.formatObject({ path: fileName })});`,
|
||||
];
|
||||
|
||||
return {
|
||||
code,
|
||||
action: async () => tab.page.pdf({ path: fileName }).then(() => {}),
|
||||
captureSnapshot: false,
|
||||
waitForNetwork: false,
|
||||
};
|
||||
response.addCode(`// Save page as ${fileName}`);
|
||||
response.addCode(`await page.pdf(${javascript.formatObject({ path: fileName })});`);
|
||||
response.addResult(`Saved page as ${fileName}`);
|
||||
await tab.page.pdf({ path: fileName });
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue