Skip to content

Commit 0a1e302

Browse files
changes
1 parent af30f81 commit 0a1e302

File tree

8 files changed

+134
-496
lines changed

8 files changed

+134
-496
lines changed

package-lock.json

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

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,14 @@
3131
"@codebolt/globby": "^1.0.1",
3232
"@codebolt/types": "^1.0.10",
3333
"@modelcontextprotocol/sdk": "^1.4.1",
34+
"@types/pdf-parse": "^1.1.5",
3435
"execa": "^9.5.2",
3536
"file-type": "^19.6.0",
3637
"fuse.js": "^7.0.0",
3738
"js-yaml": "^4.1.0",
3839
"load-esm": "^1.0.1",
3940
"mcp-proxy": "^2.4.0",
41+
"pdf-parse": "^1.1.1",
4042
"strict-event-emitter-types": "^2.0.0",
4143
"timers": "^0.1.1",
4244
"undici": "^7.4.0",

src/modules/docutils.ts

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,42 @@
11
/**
22
* A module for document utility functions.
33
*/
4+
import * as fs from 'fs';
5+
import * as path from 'path';
6+
import pdfParse from 'pdf-parse';
7+
48
const cbdocutils = {
59
/**
610
* Converts a PDF document to text.
711
* @param pdf_path - The file path to the PDF document to be converted.
812
* @returns {Promise<string>} A promise that resolves with the converted text.
913
*/
10-
pdf_to_text: (pdf_path: any): Promise<string> => {
11-
// Implementation would go here
14+
pdf_to_text: (pdf_path: string): Promise<string> => {
1215
return new Promise((resolve, reject) => {
13-
// PDF to text conversion logic
16+
try {
17+
// Check if file exists
18+
if (!fs.existsSync(pdf_path)) {
19+
return reject(new Error(`PDF file not found at path: ${pdf_path}`));
20+
}
21+
22+
// Read the PDF file as buffer
23+
const dataBuffer = fs.readFileSync(pdf_path);
24+
25+
// Parse the PDF document
26+
pdfParse(dataBuffer)
27+
.then((data: { text: string }) => {
28+
resolve(data.text);
29+
})
30+
.catch((error: Error) => {
31+
reject(new Error(`Error parsing PDF: ${error.message}`));
32+
});
33+
} catch (error: unknown) {
34+
if (error instanceof Error) {
35+
reject(new Error(`Error processing PDF: ${error.message}`));
36+
} else {
37+
reject(new Error('Unknown error processing PDF'));
38+
}
39+
}
1440
});
1541
}
1642
};

src/modules/project.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,17 @@ import { GetProjectPathResponse } from '@codebolt/types';
55
*/
66
const cbproject = {
77
/**
8-
* Placeholder for a method to get project settings.
9-
* Currently, this method does not perform any operations.
10-
* @param {any} output - The output where project settings would be stored.
8+
* Retrieves the project settings from the server.
9+
* @returns {Promise<any>} A promise that resolves with the project settings response.
1110
*/
12-
getProjectSettings: (output: any) => {
13-
// Implementation for getting project settings will be added here
11+
getProjectSettings: (): Promise<any> => {
12+
return cbws.messageManager.sendAndWaitForResponse(
13+
{
14+
"type": "settingEvent",
15+
"action": "getProjectSettings"
16+
},
17+
"getProjectSettingsResponse"
18+
);
1419
},
1520
/**
1621
* Retrieves the path of the current project.

testcases/tests/browser-test.js

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ async function testBrowserOperations() {
66

77
try {
88

9-
await codebolt.activate();
109
await codebolt.waitForConnection();
1110

1211
console.log('\n1. Testing new page creation...');
@@ -74,25 +73,25 @@ async function testBrowserOperations() {
7473

7574
// Note: Interactive tests like click and type require specific element IDs
7675
// which may not be available on example.com, so they are commented out
77-
/*
78-
console.log('\n13. Testing click (requires element ID)...');
79-
const clickResult = await codebolt.browser.click('some-element-id');
80-
console.log('✅ Clicked:', clickResult);
8176

82-
console.log('\n14. Testing type (requires element ID)...');
83-
const typeResult = await codebolt.browser.type('some-input-id', 'Test text');
84-
console.log('✅ Typed:', typeResult);
77+
// console.log('\n13. Testing click (requires element ID)...');
78+
// const clickResult = await codebolt.browser.click('some-element-id');
79+
// console.log('✅ Clicked:', clickResult);
8580

86-
console.log('\n15. Testing search (requires element ID)...');
87-
const searchResult = await codebolt.browser.search('search-input-id', 'test query');
88-
console.log('✅ Searched:', searchResult);
89-
*/
81+
// console.log('\n14. Testing type (requires element ID)...');
82+
// const typeResult = await codebolt.browser.type('some-input-id', 'Test text');
83+
// console.log('✅ Typed:', typeResult);
9084

91-
console.log('\n16. Testing enter key...');
92-
const enterResult = await codebolt.browser.enter();
93-
console.log('✅ Enter key pressed:', enterResult);
85+
// console.log('\n15. Testing search (requires element ID)...');
86+
// const searchResult = await codebolt.browser.search('search-input-id', 'test query');
87+
// console.log('✅ Searched:', searchResult);
9488

95-
console.log('\n17. Closing browser...');
89+
90+
// console.log('\n16. Testing enter key...');
91+
// const enterResult = await codebolt.browser.enter();
92+
// console.log('✅ Enter key pressed:', enterResult);
93+
94+
console.log('\n16. Closing browser...');
9695
codebolt.browser.close();
9796
console.log('✅ Browser closed');
9897

0 commit comments

Comments
 (0)