cptr 0.0.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. cptr/__init__.py +1 -0
  2. cptr/app.py +42 -0
  3. cptr/cli.py +30 -0
  4. cptr/frontend/.gitignore +23 -0
  5. cptr/frontend/.npmrc +1 -0
  6. cptr/frontend/README.md +42 -0
  7. cptr/frontend/package-lock.json +2106 -0
  8. cptr/frontend/package.json +44 -0
  9. cptr/frontend/src/app.css +114 -0
  10. cptr/frontend/src/app.d.ts +13 -0
  11. cptr/frontend/src/app.html +12 -0
  12. cptr/frontend/src/lib/assets/favicon.svg +1 -0
  13. cptr/frontend/src/lib/components/DirectoryPicker.svelte +276 -0
  14. cptr/frontend/src/lib/components/FileBrowser.svelte +142 -0
  15. cptr/frontend/src/lib/components/FileEditor.svelte +275 -0
  16. cptr/frontend/src/lib/components/PathBar.svelte +152 -0
  17. cptr/frontend/src/lib/components/Sidebar.svelte +216 -0
  18. cptr/frontend/src/lib/components/Terminal.svelte +147 -0
  19. cptr/frontend/src/lib/components/TerminalDrawer.svelte +175 -0
  20. cptr/frontend/src/lib/components/TopBar.svelte +42 -0
  21. cptr/frontend/src/lib/index.ts +1 -0
  22. cptr/frontend/src/lib/stores.ts +141 -0
  23. cptr/frontend/src/routes/+layout.svelte +31 -0
  24. cptr/frontend/src/routes/+layout.ts +3 -0
  25. cptr/frontend/src/routes/+page.svelte +13 -0
  26. cptr/frontend/static/robots.txt +3 -0
  27. cptr/frontend/svelte.config.js +19 -0
  28. cptr/frontend/tsconfig.json +20 -0
  29. cptr/frontend/vite.config.ts +16 -0
  30. cptr/routers/__init__.py +6 -0
  31. cptr/routers/files.py +206 -0
  32. cptr/routers/terminal.py +98 -0
  33. cptr/utils/__init__.py +1 -0
  34. cptr/utils/terminal.py +149 -0
  35. cptr-0.0.1.dist-info/METADATA +27 -0
  36. cptr-0.0.1.dist-info/RECORD +39 -0
  37. cptr-0.0.1.dist-info/WHEEL +4 -0
  38. cptr-0.0.1.dist-info/entry_points.txt +2 -0
  39. cptr-0.0.1.dist-info/licenses/LICENSE +19 -0
cptr/__init__.py ADDED
@@ -0,0 +1 @@
1
+ """cptr - your computer, from anywhere."""
cptr/app.py ADDED
@@ -0,0 +1,42 @@
1
+ from pathlib import Path
2
+
3
+ from fastapi import FastAPI, Request
4
+ from fastapi.responses import FileResponse
5
+ from fastapi.staticfiles import StaticFiles
6
+
7
+ from cptr.routers import files_router, terminal_router
8
+
9
+ app = FastAPI()
10
+
11
+ FRONTEND_BUILD_DIR = Path(__file__).parent / "frontend" / "build"
12
+
13
+ # API routers - must be registered before the SPA catch-all
14
+ app.include_router(files_router)
15
+ app.include_router(terminal_router)
16
+
17
+
18
+ @app.get("/api/health")
19
+ async def health():
20
+ return {"status": "ok"}
21
+
22
+
23
+ # Serve the built frontend - ships inside the package
24
+ if FRONTEND_BUILD_DIR.exists():
25
+
26
+ # Serve static assets (JS, CSS, images, etc.)
27
+ app.mount(
28
+ "/_app",
29
+ StaticFiles(directory=str(FRONTEND_BUILD_DIR / "_app")),
30
+ name="frontend-assets",
31
+ )
32
+
33
+ # SPA catch-all: serve index.html for all non-API routes
34
+ # so client-side routing works on any path
35
+ @app.get("/{full_path:path}")
36
+ async def serve_spa(request: Request, full_path: str):
37
+ # Try to serve the exact file first (e.g. robots.txt, favicon)
38
+ file_path = FRONTEND_BUILD_DIR / full_path
39
+ if full_path and file_path.is_file():
40
+ return FileResponse(file_path)
41
+ # Otherwise return index.html and let SvelteKit router handle it
42
+ return FileResponse(FRONTEND_BUILD_DIR / "index.html")
cptr/cli.py ADDED
@@ -0,0 +1,30 @@
1
+ import click
2
+ import uvicorn
3
+
4
+
5
+ @click.group()
6
+ def cli():
7
+ """cptr - your computer, from anywhere."""
8
+ pass
9
+
10
+
11
+ @cli.command()
12
+ @click.option("--host", default="0.0.0.0", help="Host to bind to.")
13
+ @click.option("--port", default=8000, type=int, help="Port to bind to.")
14
+ @click.option("--reload", is_flag=True, default=False, help="Enable auto-reload.")
15
+ def run(host: str, port: int, reload: bool):
16
+ """Start the cptr server."""
17
+ uvicorn.run(
18
+ "cptr.app:app",
19
+ host=host,
20
+ port=port,
21
+ reload=reload,
22
+ )
23
+
24
+
25
+ def main():
26
+ cli()
27
+
28
+
29
+ if __name__ == "__main__":
30
+ main()
@@ -0,0 +1,23 @@
1
+ node_modules
2
+
3
+ # Output
4
+ .output
5
+ .vercel
6
+ .netlify
7
+ .wrangler
8
+ /.svelte-kit
9
+ /build
10
+
11
+ # OS
12
+ .DS_Store
13
+ Thumbs.db
14
+
15
+ # Env
16
+ .env
17
+ .env.*
18
+ !.env.example
19
+ !.env.test
20
+
21
+ # Vite
22
+ vite.config.js.timestamp-*
23
+ vite.config.ts.timestamp-*
cptr/frontend/.npmrc ADDED
@@ -0,0 +1 @@
1
+ engine-strict=true
@@ -0,0 +1,42 @@
1
+ # sv
2
+
3
+ Everything you need to build a Svelte project, powered by [`sv`](https://github.com/sveltejs/cli).
4
+
5
+ ## Creating a project
6
+
7
+ If you're seeing this, you've probably already done this step. Congrats!
8
+
9
+ ```sh
10
+ # create a new project
11
+ npx sv create my-app
12
+ ```
13
+
14
+ To recreate this project with the same configuration:
15
+
16
+ ```sh
17
+ # recreate this project
18
+ npx sv@0.15.1 create --template minimal --types ts --no-install frontend
19
+ ```
20
+
21
+ ## Developing
22
+
23
+ Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
24
+
25
+ ```sh
26
+ npm run dev
27
+
28
+ # or start the server and open the app in a new browser tab
29
+ npm run dev -- --open
30
+ ```
31
+
32
+ ## Building
33
+
34
+ To create a production version of your app:
35
+
36
+ ```sh
37
+ npm run build
38
+ ```
39
+
40
+ You can preview the production build with `npm run preview`.
41
+
42
+ > To deploy your app, you may need to install an [adapter](https://svelte.dev/docs/kit/adapters) for your target environment.