feat: update TypeScript config for platform services

- Add useDefineForClassFields for class field initialization
- Remove test-playwright from includes
- Add tsconfig.node.json reference
- Remove redundant node_modules exclude
This commit is contained in:
Matthew Raymer
2025-04-06 06:58:25 +00:00
parent e7e9b4d27c
commit 2c6bfc30bc
7 changed files with 327 additions and 0 deletions

View File

@@ -0,0 +1,87 @@
import { PlatformService } from "../PlatformService";
export class WebPlatformService implements PlatformService {
async readFile(path: string): Promise<string> {
throw new Error("File system access not available in web platform");
}
async writeFile(path: string, content: string): Promise<void> {
throw new Error("File system access not available in web platform");
}
async deleteFile(path: string): Promise<void> {
throw new Error("File system access not available in web platform");
}
async listFiles(directory: string): Promise<string[]> {
throw new Error("File system access not available in web platform");
}
async takePicture(): Promise<string> {
return new Promise((resolve, reject) => {
const input = document.createElement("input");
input.type = "file";
input.accept = "image/*";
input.capture = "environment";
input.onchange = (e) => {
const file = (e.target as HTMLInputElement).files?.[0];
if (file) {
const reader = new FileReader();
reader.onload = (event) => {
resolve(event.target?.result as string);
};
reader.readAsDataURL(file);
} else {
reject(new Error("No file selected"));
}
};
input.click();
});
}
async pickImage(): Promise<string> {
return new Promise((resolve, reject) => {
const input = document.createElement("input");
input.type = "file";
input.accept = "image/*";
input.onchange = (e) => {
const file = (e.target as HTMLInputElement).files?.[0];
if (file) {
const reader = new FileReader();
reader.onload = (event) => {
resolve(event.target?.result as string);
};
reader.readAsDataURL(file);
} else {
reject(new Error("No file selected"));
}
};
input.click();
});
}
isCapacitor(): boolean {
return false;
}
isElectron(): boolean {
return false;
}
isPyWebView(): boolean {
return false;
}
isWeb(): boolean {
return true;
}
async handleDeepLink(url: string): Promise<void> {
// Web platform can handle deep links through URL parameters
return Promise.resolve();
}
}