prism-debugger 0.2.0
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/.env.example +9 -0
- package/README.md +128 -0
- package/bin/prism.js +72 -0
- package/package.json +35 -0
- package/public/app.js +1516 -0
- package/public/index.html +214 -0
- package/public/styles.css +1224 -0
- package/src/broker.js +425 -0
- package/src/config.js +55 -0
- package/src/index.js +100 -0
- package/src/logger.js +72 -0
- package/src/plugins/context-device-event-logger.plugin.js +152 -0
- package/src/plugins/index.js +21 -0
- package/src/plugins/plugin-manager.js +51 -0
- package/src/storage.js +102 -0
package/.env.example
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# Prism Debugger
|
|
2
|
+
|
|
3
|
+
Real-time debugger for Janative (JavaScript + Native) iOS apps.
|
|
4
|
+
WebSocket broker between iOS SDK and Web UI with event console, performance timeline, and reporting.
|
|
5
|
+
|
|
6
|
+
## Quick Start
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
npx prism-debugger
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Or install globally:
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install -g prism-debugger
|
|
16
|
+
prism
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Server starts and prints the config summary:
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
Prism Debugger
|
|
23
|
+
─────────────────────────────────────
|
|
24
|
+
Config: defaults (no .env, run prism init)
|
|
25
|
+
HTTP: http://localhost:8080
|
|
26
|
+
UI: http://192.168.1.10:8080/?token=ui-dev-token
|
|
27
|
+
WS iOS: ws://192.168.1.10:8080/ws/ios
|
|
28
|
+
Plugins: context-device-event-logger
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Open the UI link in your browser — that's it.
|
|
32
|
+
|
|
33
|
+
## Configuration
|
|
34
|
+
|
|
35
|
+
### CLI flags
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
prism -p 8097 # set port
|
|
39
|
+
prism --ios-token my-secret # iOS SDK auth token
|
|
40
|
+
prism --ui-token my-secret # Web UI auth token
|
|
41
|
+
prism --plugins none # disable plugins
|
|
42
|
+
prism --log-dir ./my-logs # context event log directory
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### .env file
|
|
46
|
+
|
|
47
|
+
Generate a config in the current directory:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
prism init
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
This creates a `.env` file with all available options:
|
|
54
|
+
|
|
55
|
+
```env
|
|
56
|
+
PORT=8097
|
|
57
|
+
IOS_AUTH_KEYS=ios-dev-token
|
|
58
|
+
UI_AUTH_KEYS=ui-dev-token
|
|
59
|
+
HEARTBEAT_TIMEOUT_SEC=30
|
|
60
|
+
RATE_LIMIT=30
|
|
61
|
+
MAX_PAYLOAD_BYTES=262144
|
|
62
|
+
RING_BUFFER_SIZE=500
|
|
63
|
+
ENABLED_PLUGINS=context-device-event-logger
|
|
64
|
+
CONTEXT_EVENT_LOG_DIR=./logs/context-events
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Priority: CLI flags > `.env` file > defaults.
|
|
68
|
+
|
|
69
|
+
### Options reference
|
|
70
|
+
|
|
71
|
+
| Option | CLI flag | Env variable | Default | Description |
|
|
72
|
+
|--------|----------|--------------|---------|-------------|
|
|
73
|
+
| Port | `-p, --port` | `PORT` | `8080` | HTTP and WebSocket port |
|
|
74
|
+
| iOS token | `--ios-token` | `IOS_AUTH_KEYS` | `ios-dev-token` | Auth token for iOS SDK (comma-separated for multiple) |
|
|
75
|
+
| UI token | `--ui-token` | `UI_AUTH_KEYS` | `ui-dev-token` | Auth token for Web UI (comma-separated for multiple) |
|
|
76
|
+
| Plugins | `--plugins` | `ENABLED_PLUGINS` | `context-device-event-logger` | Comma-separated list of plugins |
|
|
77
|
+
| Log dir | `--log-dir` | `CONTEXT_EVENT_LOG_DIR` | `./logs/context-events` | Directory for JSONL event logs |
|
|
78
|
+
| Heartbeat | — | `HEARTBEAT_TIMEOUT_SEC` | `30` | Seconds before marking device offline |
|
|
79
|
+
| Rate limit | — | `RATE_LIMIT` | `30` | Max events per second per debugger |
|
|
80
|
+
| Payload size | — | `MAX_PAYLOAD_BYTES` | `262144` | Max message size (bytes) |
|
|
81
|
+
| Ring buffer | — | `RING_BUFFER_SIZE` | `500` | Message history per debugger |
|
|
82
|
+
|
|
83
|
+
## WebSocket endpoints
|
|
84
|
+
|
|
85
|
+
| Endpoint | Purpose |
|
|
86
|
+
|----------|---------|
|
|
87
|
+
| `/ws/ios?token=<IOS_TOKEN>` | iOS SDK connection |
|
|
88
|
+
| `/ws/ui?token=<UI_TOKEN>` | Web UI connection |
|
|
89
|
+
|
|
90
|
+
## HTTP API
|
|
91
|
+
|
|
92
|
+
| Method | Endpoint | Description |
|
|
93
|
+
|--------|----------|-------------|
|
|
94
|
+
| `GET` | `/health` | Health check |
|
|
95
|
+
| `GET` | `/api/connect-info` | Server IP and port for QR connect |
|
|
96
|
+
| `GET` | `/api/debuggers` | List connected debuggers |
|
|
97
|
+
| `GET` | `/api/debuggers/:id/messages` | Message history for a debugger |
|
|
98
|
+
| `POST` | `/api/debuggers/:id/send` | Send command to a debugger |
|
|
99
|
+
|
|
100
|
+
## Web UI
|
|
101
|
+
|
|
102
|
+
Open `http://localhost:<port>/?token=<UI_TOKEN>` in your browser.
|
|
103
|
+
|
|
104
|
+
Features:
|
|
105
|
+
- Live event console with level/category filters
|
|
106
|
+
- Performance timeline (Gantt chart) with badge grouping
|
|
107
|
+
- PerfPoint detail popups with extra data
|
|
108
|
+
- HTML / CSV / JSON report export
|
|
109
|
+
- QR code for quick iOS SDK connection
|
|
110
|
+
- Light and dark themes
|
|
111
|
+
|
|
112
|
+
## Plugins
|
|
113
|
+
|
|
114
|
+
Built-in plugin `context-device-event-logger` writes JSONL logs per context:
|
|
115
|
+
|
|
116
|
+
```
|
|
117
|
+
logs/context-events/{bundleId}/{device}/{sessionId}/{context}.log
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Disable all plugins:
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
prism --plugins none
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## License
|
|
127
|
+
|
|
128
|
+
MIT
|
package/bin/prism.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { parseArgs } from 'node:util';
|
|
4
|
+
import { readFileSync, writeFileSync, existsSync } from 'node:fs';
|
|
5
|
+
import { resolve, dirname } from 'node:path';
|
|
6
|
+
import { fileURLToPath } from 'node:url';
|
|
7
|
+
|
|
8
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
9
|
+
const PKG_ROOT = resolve(__dirname, '..');
|
|
10
|
+
|
|
11
|
+
const HELP = `
|
|
12
|
+
prism — Prism Debugger Server
|
|
13
|
+
|
|
14
|
+
Usage:
|
|
15
|
+
prism [options] Start the server
|
|
16
|
+
prism init Create .env config in current directory
|
|
17
|
+
|
|
18
|
+
Options:
|
|
19
|
+
-p, --port <number> HTTP/WS port (default: 8080)
|
|
20
|
+
--ios-token <string> iOS auth token (default: ios-dev-token)
|
|
21
|
+
--ui-token <string> UI auth token (default: ui-dev-token)
|
|
22
|
+
--plugins <list> Enabled plugins, comma-separated
|
|
23
|
+
--log-dir <path> Context event log directory
|
|
24
|
+
-h, --help Show this help
|
|
25
|
+
-v, --version Show version
|
|
26
|
+
|
|
27
|
+
Config priority: CLI flags > .env file > defaults
|
|
28
|
+
`.trimStart();
|
|
29
|
+
|
|
30
|
+
const { values, positionals } = parseArgs({
|
|
31
|
+
allowPositionals: true,
|
|
32
|
+
options: {
|
|
33
|
+
port: { type: 'string', short: 'p' },
|
|
34
|
+
'ios-token': { type: 'string' },
|
|
35
|
+
'ui-token': { type: 'string' },
|
|
36
|
+
plugins: { type: 'string' },
|
|
37
|
+
'log-dir': { type: 'string' },
|
|
38
|
+
help: { type: 'boolean', short: 'h' },
|
|
39
|
+
version: { type: 'boolean', short: 'v' },
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
if (values.help) {
|
|
44
|
+
process.stdout.write(HELP);
|
|
45
|
+
process.exit(0);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (values.version) {
|
|
49
|
+
const pkg = JSON.parse(readFileSync(resolve(PKG_ROOT, 'package.json'), 'utf8'));
|
|
50
|
+
console.log(pkg.version);
|
|
51
|
+
process.exit(0);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (positionals[0] === 'init') {
|
|
55
|
+
const dest = resolve(process.cwd(), '.env');
|
|
56
|
+
if (existsSync(dest)) {
|
|
57
|
+
console.log('.env уже существует в текущей директории');
|
|
58
|
+
process.exit(1);
|
|
59
|
+
}
|
|
60
|
+
const template = readFileSync(resolve(PKG_ROOT, '.env.example'), 'utf8');
|
|
61
|
+
writeFileSync(dest, template);
|
|
62
|
+
console.log('.env создан. Отредактируй под свои нужды и запусти prism');
|
|
63
|
+
process.exit(0);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (values.port) process.env.PORT = values.port;
|
|
67
|
+
if (values['ios-token']) process.env.IOS_AUTH_KEYS = values['ios-token'];
|
|
68
|
+
if (values['ui-token']) process.env.UI_AUTH_KEYS = values['ui-token'];
|
|
69
|
+
if (values.plugins) process.env.ENABLED_PLUGINS = values.plugins;
|
|
70
|
+
if (values['log-dir']) process.env.CONTEXT_EVENT_LOG_DIR = values['log-dir'];
|
|
71
|
+
|
|
72
|
+
await import('../src/index.js');
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "prism-debugger",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Real-time debugger broker for Janative iOS apps — WebSocket bridge between iOS SDK and Web UI (Prism)",
|
|
5
|
+
"main": "src/index.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"bin": {
|
|
8
|
+
"prism": "bin/prism.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"bin/",
|
|
12
|
+
"src/",
|
|
13
|
+
"public/",
|
|
14
|
+
".env.example"
|
|
15
|
+
],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"start": "node src/index.js",
|
|
18
|
+
"dev": "node --watch src/index.js"
|
|
19
|
+
},
|
|
20
|
+
"keywords": [
|
|
21
|
+
"debugger",
|
|
22
|
+
"ios",
|
|
23
|
+
"janative",
|
|
24
|
+
"websocket",
|
|
25
|
+
"prism"
|
|
26
|
+
],
|
|
27
|
+
"license": "MIT",
|
|
28
|
+
"engines": {
|
|
29
|
+
"node": ">=20.12.0"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"express": "^4.21.2",
|
|
33
|
+
"ws": "^8.18.3"
|
|
34
|
+
}
|
|
35
|
+
}
|