opensignalbox-virtualbox 0.1.0__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 (43) hide show
  1. opensignalbox/virtualbox/__init__.py +1 -0
  2. opensignalbox/virtualbox/assets/favicon.ico +0 -0
  3. opensignalbox/virtualbox/main.py +101 -0
  4. opensignalbox/virtualbox/models.py +2 -0
  5. opensignalbox/virtualbox/routes.py +79 -0
  6. opensignalbox/virtualbox/version.py +1 -0
  7. opensignalbox/virtualbox/web_ui/.gitignore +24 -0
  8. opensignalbox/virtualbox/web_ui/.vscode/extensions.json +3 -0
  9. opensignalbox/virtualbox/web_ui/README.md +5 -0
  10. opensignalbox/virtualbox/web_ui/components.json +17 -0
  11. opensignalbox/virtualbox/web_ui/dist/assets/index-CSfJfjeb.css +1755 -0
  12. opensignalbox/virtualbox/web_ui/dist/assets/index-DzorO0tZ.js +10544 -0
  13. opensignalbox/virtualbox/web_ui/dist/favicon.ico +0 -0
  14. opensignalbox/virtualbox/web_ui/dist/index.html +14 -0
  15. opensignalbox/virtualbox/web_ui/dist/svg-loader.min.js +2 -0
  16. opensignalbox/virtualbox/web_ui/dist/virtual_diagram.svg +800 -0
  17. opensignalbox/virtualbox/web_ui/index.html +13 -0
  18. opensignalbox/virtualbox/web_ui/package-lock.json +3428 -0
  19. opensignalbox/virtualbox/web_ui/package.json +39 -0
  20. opensignalbox/virtualbox/web_ui/public/favicon.ico +0 -0
  21. opensignalbox/virtualbox/web_ui/public/svg-loader.min.js +2 -0
  22. opensignalbox/virtualbox/web_ui/public/virtual_diagram.svg +800 -0
  23. opensignalbox/virtualbox/web_ui/src/App.vue +30 -0
  24. opensignalbox/virtualbox/web_ui/src/assets/favicon.ico +0 -0
  25. opensignalbox/virtualbox/web_ui/src/assets/index.css +83 -0
  26. opensignalbox/virtualbox/web_ui/src/components/SharedVariablePicker.vue +112 -0
  27. opensignalbox/virtualbox/web_ui/src/libs/utils.ts +6 -0
  28. opensignalbox/virtualbox/web_ui/src/main.ts +15 -0
  29. opensignalbox/virtualbox/web_ui/src/views/Overview.vue +78 -0
  30. opensignalbox/virtualbox/web_ui/src/vite-env.d.ts +1 -0
  31. opensignalbox/virtualbox/web_ui/tailwind.config.js +94 -0
  32. opensignalbox/virtualbox/web_ui/tsconfig.app.json +27 -0
  33. opensignalbox/virtualbox/web_ui/tsconfig.json +30 -0
  34. opensignalbox/virtualbox/web_ui/tsconfig.node.json +12 -0
  35. opensignalbox/virtualbox/web_ui/tsconfig.tsbuildinfo +1 -0
  36. opensignalbox/virtualbox/web_ui/vite.config.d.ts +2 -0
  37. opensignalbox/virtualbox/web_ui/vite.config.js +39 -0
  38. opensignalbox/virtualbox/web_ui/vite.config.ts +40 -0
  39. opensignalbox_virtualbox-0.1.0.dist-info/METADATA +30 -0
  40. opensignalbox_virtualbox-0.1.0.dist-info/RECORD +43 -0
  41. opensignalbox_virtualbox-0.1.0.dist-info/WHEEL +4 -0
  42. opensignalbox_virtualbox-0.1.0.dist-info/entry_points.txt +2 -0
  43. opensignalbox_virtualbox-0.1.0.dist-info/licenses/LICENSE +619 -0
@@ -0,0 +1 @@
1
+ __doc__ = "openSignalBox virtual_box module."
@@ -0,0 +1,101 @@
1
+ import logging
2
+
3
+ from anyio import run
4
+ from opensignalbox.common.messaging import get_messager
5
+ from opensignalbox.common.modules import (
6
+ BaseModule,
7
+ ModuleInfo,
8
+ UIEntry,
9
+ module_argparser,
10
+ )
11
+
12
+ from .routes import virtual_box_router
13
+ from .version import __version__
14
+
15
+ logger = logging.getLogger(__name__)
16
+
17
+
18
+ messager = get_messager()
19
+
20
+ messager._buffer_subs = False
21
+
22
+
23
+ class Module(BaseModule):
24
+ module_name = "opensignalbox-virtualbox"
25
+ module_file = __file__
26
+
27
+ def __init__(
28
+ self,
29
+ module_info: ModuleInfo,
30
+ ui_entries: list[UIEntry] | None = None,
31
+ ) -> None:
32
+ if ui_entries is None:
33
+ ui_entries = []
34
+ super().__init__(
35
+ module_info=module_info,
36
+ ui_entries=ui_entries
37
+ )
38
+ self.fastapi_app.state.components_dir = self.module_info.config_path / "web_components"
39
+ self.fastapi_app.include_router(
40
+ virtual_box_router, prefix="/api"
41
+ )
42
+
43
+ def setup(self) -> None:
44
+ """
45
+ Module startup code goes here after the super call.
46
+ """
47
+ super().setup()
48
+ self.fastapi_app.state.components_dir.mkdir(exist_ok=True)
49
+
50
+ def systick_update(self, tick_json: str) -> None:
51
+ """
52
+ Module update logic goes here, executed once per clock tick.
53
+ """
54
+ super().systick_update(tick_json)
55
+
56
+ async def user_task(self) -> None:
57
+ pass
58
+
59
+ def teardown(self) -> None:
60
+ """
61
+ Module teardown code goes here.
62
+ """
63
+ pass
64
+
65
+ def load_state(self) -> None:
66
+ return super().load_state()
67
+
68
+ def save_state(self) -> None:
69
+ return super().save_state()
70
+
71
+
72
+ args = module_argparser()
73
+ instance_name: str = args.name
74
+
75
+ ui_entries = [
76
+ UIEntry(category="operations", name="Virtual Boxes", path="/"),
77
+ UIEntry(category="configuration", name="Virtual Box Settings", path="/settings"),
78
+ ]
79
+ module_info = ModuleInfo(
80
+ instance_name=args.name,
81
+ module_name=Module.module_name,
82
+ version=__version__,
83
+ address=args.address,
84
+ port=args.port,
85
+ session_id=args.session_id,
86
+ framework_address=args.framework_address,
87
+ config_path=args.configdir,
88
+ )
89
+ module = Module(
90
+ module_info=module_info,
91
+ ui_entries=ui_entries,
92
+ )
93
+ module.setup()
94
+
95
+
96
+ def entry_point():
97
+ run(module.run, backend="trio") # type: ignore
98
+
99
+
100
+ if __name__ == "__main__":
101
+ entry_point()
@@ -0,0 +1,2 @@
1
+
2
+
@@ -0,0 +1,79 @@
1
+ import logging
2
+ from pathlib import Path
3
+ from typing import Annotated
4
+
5
+ import aiohttp
6
+ from fastapi import Depends, HTTPException, Query, Request
7
+ from fastapi.responses import JSONResponse
8
+ from fastapi.routing import APIRouter
9
+ from opensignalbox.common.variables import SharedVariableCollection
10
+ from requests import codes as http_codes
11
+
12
+ logger = logging.getLogger(__name__)
13
+
14
+ def get_shared_variables(request: Request) -> SharedVariableCollection:
15
+ return request.app.state.shared_variables
16
+
17
+ SharedVariablesDependency = Annotated[SharedVariableCollection, Depends(get_shared_variables)]
18
+
19
+ def get_components_dir(request: Request) -> Path:
20
+ return request.app.state.components_dir
21
+
22
+ ComponentsDirDependency = Annotated[Path, Depends(get_components_dir)]
23
+
24
+ virtual_box_router = APIRouter()
25
+
26
+ @virtual_box_router.get("/components")
27
+ async def get_components(names: list[str] = Query(...), components_dir: Path = Depends(get_components_dir)):
28
+ """Serve multiple web components from local storage"""
29
+ components = {}
30
+ for name in names:
31
+ file_path = components_dir / f"{name}.js"
32
+ if not file_path.exists():
33
+ raise HTTPException(
34
+ status_code=404, detail=f"Component {name} not found"
35
+ )
36
+ with open(file_path, "r") as f:
37
+ components[name] = f.read()
38
+ return JSONResponse(content=components)
39
+
40
+ @virtual_box_router.post("/components/download")
41
+ async def download_components(manifest_url: str, components_dir: Path = Depends(get_components_dir)):
42
+ """Download web components from a GitHub manifest"""
43
+ async with aiohttp.ClientSession() as session:
44
+ try:
45
+ # Download manifest
46
+ async with session.get(manifest_url) as response:
47
+ if response.status != http_codes.ok:
48
+ raise HTTPException(
49
+ status_code=400, detail="Failed to fetch manifest"
50
+ )
51
+ manifest = await response.json()
52
+
53
+ # Download each component
54
+ downloaded = []
55
+ base_url = manifest.get("base_url", "")
56
+ components = manifest.get("components", [])
57
+
58
+ for component in components:
59
+ name = component.get("name")
60
+ path = component.get("path")
61
+ if not name or not path:
62
+ continue
63
+
64
+ url = f"{base_url.rstrip('/')}/{path.lstrip('/')}"
65
+ async with session.get(url) as resp:
66
+ if resp.status == http_codes.ok:
67
+ content = await resp.text()
68
+ file_path = components_dir / f"{name}.js"
69
+ with open(file_path, "w") as f:
70
+ f.write(content)
71
+ downloaded.append(name)
72
+
73
+ return {"status": "success", "downloaded": downloaded}
74
+
75
+ except Exception as exc:
76
+ raise HTTPException(
77
+ status_code=500,
78
+ detail=f"Failed to download components: {str(exc)}",
79
+ ) from exc
@@ -0,0 +1 @@
1
+ __version__ = "0.1.0"
@@ -0,0 +1,24 @@
1
+ # Logs
2
+ logs
3
+ *.log
4
+ npm-debug.log*
5
+ yarn-debug.log*
6
+ yarn-error.log*
7
+ pnpm-debug.log*
8
+ lerna-debug.log*
9
+
10
+ node_modules
11
+ #dist
12
+ #dist-ssr
13
+ *.local
14
+
15
+ # Editor directories and files
16
+ .vscode/*
17
+ !.vscode/extensions.json
18
+ .idea
19
+ .DS_Store
20
+ *.suo
21
+ *.ntvs*
22
+ *.njsproj
23
+ *.sln
24
+ *.sw?
@@ -0,0 +1,3 @@
1
+ {
2
+ "recommendations": ["Vue.volar"]
3
+ }
@@ -0,0 +1,5 @@
1
+ # Vue 3 + TypeScript + Vite
2
+
3
+ This template should help get you started developing with Vue 3 and TypeScript in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more.
4
+
5
+ Learn more about the recommended Project Setup and IDE Support in the [Vue Docs TypeScript Guide](https://vuejs.org/guide/typescript/overview.html#project-setup).
@@ -0,0 +1,17 @@
1
+ {
2
+ "$schema": "https://shadcn-vue.com/schema.json",
3
+ "style": "default",
4
+ "typescript": true,
5
+ "tsConfigPath": "./tsconfig.json",
6
+ "tailwind": {
7
+ "config": "tailwind.config.js",
8
+ "css": "src/assets/index.css",
9
+ "baseColor": "slate",
10
+ "cssVariables": true
11
+ },
12
+ "framework": "vite",
13
+ "aliases": {
14
+ "components": "@/components",
15
+ "utils": "@/libs/utils"
16
+ }
17
+ }