diff --git a/.github/workflows/validate-types.yml b/.github/workflows/validate-types.yml new file mode 100644 index 0000000..7f541c5 --- /dev/null +++ b/.github/workflows/validate-types.yml @@ -0,0 +1,26 @@ +name: Validate Types + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + validate: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '18' + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Run type tests (explicit src tsconfig) + run: npx tsc --noEmit -p src/tsconfig.json diff --git a/src/index.d.ts b/src/index.d.ts index e69de29..fb5c2d0 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -0,0 +1,57 @@ +export class Terminal {} +export class Process {} + +export class BinaryFile { + write(data: ArrayBuffer): Promise; + + read(length: number): Promise; + + getSize(): Promise; + + close(): Promise; +} + +export class TextFile { + write(data: string): Promise; + + read(length: number): Promise; + + getSize(): Promise; + + close(): Promise; +} + + +export class BrowserPod { + static boot(opts: { + nodeVersion?: string; + apiKey: string; + }): Promise; + + run( + executable: string, + args: Array, + opts: { + terminal: Terminal, + env?: Array; + cwd?: string, + echo?: boolean + } + ): Promise; + + onPortal(cb: ( args: { url: string, port: number }) => void): void; + + createDirectory( + path: string, + opts?: { recursive?: boolean } + ): Promise; + + createFile(path: string, mode: string): Promise; + + openFile(path: string, mode: string): Promise; + + createDefaultTerminal( + consoleDiv: HTMLElement, + ): Promise; +} + diff --git a/src/tsconfig.json b/src/tsconfig.json new file mode 100644 index 0000000..1fa7298 --- /dev/null +++ b/src/tsconfig.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "strict": true, + "target": "ES2020", + "module": "ESNext", + "moduleResolution": "bundler", + "lib": ["ES2020", "DOM"] + }, + "include": ["index.d.ts"] +}