wip: add typechecking to background.js

This commit is contained in:
xwildeyes 2025-01-10 16:37:38 +07:00
commit ac8a0dd069
6 changed files with 584 additions and 208 deletions

1
.gitignore vendored
View file

@ -1,3 +1,4 @@
node_modules
.DS_Store
scratch
fs/tabfs

95
TODO.md Normal file
View file

@ -0,0 +1,95 @@
# TabFS TODO List
## Core Functionality Enhancements
### File System Features
- [ ] Add support for arbitrary files in subtrees (`.git`, Mac extended attrs, editor temp files)
- [ ] Improve persistence handling
- [ ] Address tab lifecycle/disposability differences from regular filesystem
- [ ] Investigate why GUI programs (like Preview) struggle with filesystem access
- [ ] Add more synthetic files for:
- [ ] DOM node viewing
- [ ] Page HTML snapshots
- [ ] Live object inspection
- [ ] Runtime code analysis
- [ ] Make more files writable
### Performance Optimization
- [ ] Optimize browser roundtrips
- [ ] Implement reference counting
- [ ] Cache attachment status to resources
- [ ] Profile and identify performance bottlenecks
- [ ] Address application hanging issues during slow requests
- [ ] Investigate FUSE-specific performance patterns
### Multi-threading
- [ ] Evaluate performance benefits of multi-threading
- [ ] Implement request interleaving for async operations
- [ ] Handle concurrent filesystem operations
- [ ] Optimize screenshot and other slow operations
## Browser Integration
### Browser Management Features
- [ ] Implement comprehensive window management
- [ ] Add tab movement capabilities
- [ ] Create 'merge all windows' functionality
- [ ] Develop history management system
- [ ] Improve tab organization features
## Development Infrastructure
### Type Safety
- [ ] Evaluate TypeScript integration options
- [ ] Consider lightweight type checking alternatives
- [ ] Implement dynamic type checking at filesystem operation boundaries
- [ ] Balance type safety with minimal build requirements
### Tools Development
- [ ] Build additional GUI tools
- [ ] Develop CLI utilities
- [ ] Create debugging tools
- [ ] Add monitoring capabilities
- [ ] Implement diagnostic features
## Documentation & Testing
### Documentation
- [ ] Improve installation guides
- [ ] Create detailed API documentation
- [ ] Add more usage examples
- [ ] Document common issues and solutions
- [ ] Create contribution guidelines
### Testing
- [ ] Add unit tests
- [ ] Implement integration tests
- [ ] Create performance benchmarks
- [ ] Add cross-browser testing
- [ ] Develop filesystem operation tests
## Community & Maintenance
### Community Support
- [ ] Track and list community contributions
- [ ] Create issue templates
- [ ] Implement feature request process
- [ ] Maintain contributor acknowledgments
### Project Management
- [ ] Prioritize feature requests
- [ ] Maintain changelog
- [ ] Version management
- [ ] Release planning
- [ ] Security review process
## Known Issues to Address
- [ ] Fix GUI program compatibility issues
- [ ] Address filesystem hanging during slow operations
- [ ] Resolve tab persistence quirks
- [ ] Improve error handling
- [ ] Handle edge cases in filesystem operations
---
Note: This is a living document. Feel free to add, modify, or reprioritize items as needed. Contributions and suggestions are welcome!

40
extension/.eslintrc.js Normal file
View file

@ -0,0 +1,40 @@
module.exports = {
"env": {
"browser": true,
"es2021": true,
"webextensions": true,
"node": true
},
"extends": [
"eslint:recommended",
"plugin:jsdoc/recommended"
],
"plugins": [
"jsdoc"
],
"parserOptions": {
"ecmaVersion": 2021,
"sourceType": "module"
},
"ignorePatterns": ["fs/mnt/**/*"],
"rules": {
"jsdoc/require-jsdoc": ["warn", {
"require": {
"FunctionDeclaration": true,
"MethodDefinition": true,
"ClassDeclaration": true
}
}],
"jsdoc/require-param-type": "warn",
"jsdoc/require-returns-type": "warn",
"no-unused-vars": "off",
"no-useless-escape": "off",
"no-control-regex": "off",
"jsdoc/require-property-description": "off"
},
"settings": {
"jsdoc": {
"mode": "typescript"
}
}
}

File diff suppressed because it is too large Load diff

23
extension/jsconfig.json Normal file
View file

@ -0,0 +1,23 @@
{
"compilerOptions": {
"checkJs": true,
"strict": false,
"target": "ES2021",
"module": "ES2022",
"moduleResolution": "node",
"allowJs": true,
"typeRoots": [
"."
],
"baseUrl": "."
},
"include": [
"background.js",
"types.d.ts"
],
"exclude": [
"node_modules",
"safari",
"vendor"
]
}

63
extension/types.d.ts vendored Normal file
View file

@ -0,0 +1,63 @@
// add; window.Routes = Routes;
declare interface RouteHandler {
description?: string;
usage?: string | string[];
getattr?: (req: RequestObject) => Promise<StatObject> | StatObject;
readdir?: (req: RequestObject) => Promise<{ entries: string[] }> | { entries: string[] };
read?: (req: RequestObject) => Promise<{ buf: string }> | { buf: string };
write?: (req: RequestObject) => Promise<{ size: number }> | { size: number };
truncate?: (req: RequestObject) => Promise<{}> | {};
readlink?: (req: RequestObject) => Promise<{ buf: string }> | { buf: string };
unlink?: (req: RequestObject) => Promise<{}> | {};
open?: (req: RequestObject) => Promise<{ fh: number }> | { fh: number };
release?: (req: RequestObject) => Promise<{}> | {};
opendir?: (req: RequestObject) => Promise<{ fh: number }> | { fh: number };
releasedir?: (req: RequestObject) => Promise<{}> | {};
__matchVarCount?: number;
__regex?: RegExp;
__match?: (path: string) => Record<string, any> | undefined;
__isInfill?: boolean;
}
declare interface RequestObject {
path: string;
buf?: string;
size?: number;
fh?: number;
offset?: number;
tabId?: number;
windowId?: number;
mode?: number;
expr?: string;
inputId?: string;
extensionId?: string;
}
declare interface StatObject {
st_mode: number;
st_nlink: number;
st_size: number;
}
declare interface UnixConstants {
EPERM: number;
ENOENT: number;
ESRCH: number;
EINTR: number;
EIO: number;
ENXIO: number;
ENOTSUP: number;
ETIMEDOUT: number;
S_IFMT: number;
S_IFIFO: number;
S_IFCHR: number;
S_IFDIR: number;
S_IFBLK: number;
S_IFREG: number;
S_IFLNK: number;
S_IFSOCK: number;
}