@getvision/core 0.0.0-develop-20251031183955
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.
- package/README.md +104 -0
- package/dist/index.js +120 -0
- package/dist/ui/assets/index-CVA0UgYl.css +1 -0
- package/dist/ui/assets/index-DIWmJAHA.js +243 -0
- package/dist/ui/index.html +14 -0
- package/dist/ui/typescript.svg +1 -0
- package/dist/ui/vite.svg +1 -0
- package/package.json +46 -0
package/README.md
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# @getvision/core
|
|
2
|
+
|
|
3
|
+
Core package for Vision Dashboard - WebSocket server, JSON-RPC protocol, and distributed tracing engine.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- ✅ **WebSocket Server** - Real-time bidirectional communication
|
|
8
|
+
- ✅ **JSON-RPC 2.0** - Standard protocol for method calls
|
|
9
|
+
- ✅ **Distributed Tracing** - Trace storage and span management
|
|
10
|
+
- ✅ **Event Broadcasting** - Push events to all connected clients
|
|
11
|
+
- ✅ **Type-safe** - Full TypeScript support
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pnpm add @getvision/core
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
import { VisionCore } from '@getvision/core'
|
|
23
|
+
|
|
24
|
+
// Create Vision instance
|
|
25
|
+
const vision = new VisionCore({
|
|
26
|
+
port: 9500,
|
|
27
|
+
maxTraces: 1000,
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
// Set app status
|
|
31
|
+
vision.setAppStatus({
|
|
32
|
+
running: true,
|
|
33
|
+
pid: process.pid,
|
|
34
|
+
metadata: {
|
|
35
|
+
name: 'My App',
|
|
36
|
+
framework: 'hono',
|
|
37
|
+
},
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
// Create and complete traces
|
|
41
|
+
const trace = vision.createTrace('GET', '/api/users')
|
|
42
|
+
// ... handle request ...
|
|
43
|
+
vision.completeTrace(trace.id, 200, 150)
|
|
44
|
+
|
|
45
|
+
// Broadcast events
|
|
46
|
+
vision.broadcast({
|
|
47
|
+
type: 'log.stdout',
|
|
48
|
+
data: { message: 'Server started', timestamp: Date.now() },
|
|
49
|
+
})
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## API
|
|
53
|
+
|
|
54
|
+
### VisionCore
|
|
55
|
+
|
|
56
|
+
Main orchestrator class.
|
|
57
|
+
|
|
58
|
+
#### Constructor
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
new VisionCore(options?: VisionServerOptions)
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
#### Methods
|
|
65
|
+
|
|
66
|
+
- `setAppStatus(status: Partial<AppStatus>)` - Update app status
|
|
67
|
+
- `createTrace(method: string, path: string): Trace` - Create new trace
|
|
68
|
+
- `completeTrace(traceId: string, statusCode: number, duration: number)` - Complete trace
|
|
69
|
+
- `broadcast(event: DashboardEvent)` - Broadcast event to clients
|
|
70
|
+
- `getTracer(): Tracer` - Get tracer instance
|
|
71
|
+
- `getClientCount(): number` - Get connected client count
|
|
72
|
+
- `close(): Promise<void>` - Close server
|
|
73
|
+
|
|
74
|
+
### TraceStore
|
|
75
|
+
|
|
76
|
+
In-memory trace storage with automatic cleanup.
|
|
77
|
+
|
|
78
|
+
### Tracer
|
|
79
|
+
|
|
80
|
+
Span creation and management for distributed tracing.
|
|
81
|
+
|
|
82
|
+
## JSON-RPC Methods
|
|
83
|
+
|
|
84
|
+
Built-in methods available via WebSocket:
|
|
85
|
+
|
|
86
|
+
- `status` - Get app status
|
|
87
|
+
- `traces/list` - List all traces
|
|
88
|
+
- `traces/get` - Get specific trace
|
|
89
|
+
- `traces/clear` - Clear all traces
|
|
90
|
+
- `routes/list` - Get registered routes
|
|
91
|
+
- `version` - Get Vision version
|
|
92
|
+
|
|
93
|
+
## Events
|
|
94
|
+
|
|
95
|
+
Events broadcast to connected clients:
|
|
96
|
+
|
|
97
|
+
- `app.started` - App started
|
|
98
|
+
- `app.stopped` - App stopped
|
|
99
|
+
- `trace.new` - New trace created
|
|
100
|
+
- `log.stdout` - stdout message
|
|
101
|
+
- `log.stderr` - stderr message
|
|
102
|
+
- `compile.start` - Compilation started
|
|
103
|
+
- `compile.success` - Compilation succeeded
|
|
104
|
+
- `compile.error` - Compilation failed
|