@flash-debug/silkworm 0.0.0 → 0.5.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/.output/nitro.json +18 -0
- package/.output/public/assets/index-Bw-GBuTw.css +1 -0
- package/.output/public/assets/index-CHthEL3v.js +6 -0
- package/.output/public/icons/silkworm/favicon-16.png +0 -0
- package/.output/public/icons/silkworm/favicon-32.png +0 -0
- package/.output/public/icons/silkworm/icon-128.png +0 -0
- package/.output/public/icons/silkworm/icon-512.png +0 -0
- package/.output/public/index.html +14 -0
- package/.output/server/_chunks/renderer-template.mjs +8 -0
- package/.output/server/_chunks/state.mjs +568 -0
- package/.output/server/_libs/h3+rou3+srvx.mjs +1597 -0
- package/.output/server/_libs/h3.mjs +139 -0
- package/.output/server/_libs/h32.mjs +48 -0
- package/.output/server/_routes/api/silkworm/auto/pause.mjs +8 -0
- package/.output/server/_routes/api/silkworm/auto/start.mjs +17 -0
- package/.output/server/_routes/api/silkworm/auto/stop.mjs +8 -0
- package/.output/server/_routes/api/silkworm/connect.mjs +21 -0
- package/.output/server/_routes/api/silkworm/history/clear.mjs +8 -0
- package/.output/server/_routes/api/silkworm/manual/send.mjs +23 -0
- package/.output/server/_routes/api/silkworm/state.mjs +5 -0
- package/.output/server/_routes/api/silkworm/stream.mjs +41 -0
- package/.output/server/_routes/api/silkworm/test.mjs +18 -0
- package/.output/server/index.mjs +542 -0
- package/dist/assets/index-Bw-GBuTw.css +1 -0
- package/dist/assets/index-CHthEL3v.js +6 -0
- package/dist/icons/silkworm/favicon-16.png +0 -0
- package/dist/icons/silkworm/favicon-32.png +0 -0
- package/dist/icons/silkworm/icon-128.png +0 -0
- package/dist/icons/silkworm/icon-512.png +0 -0
- package/dist/index.html +14 -0
- package/index.html +13 -0
- package/nitro.config.ts +12 -0
- package/package.json +42 -8
- package/public/icons/silkworm/favicon-16.png +0 -0
- package/public/icons/silkworm/favicon-32.png +0 -0
- package/public/icons/silkworm/icon-128.png +0 -0
- package/public/icons/silkworm/icon-512.png +0 -0
- package/scripts/dev.ts +56 -0
- package/server/routes/api/silkworm/auto/pause.post.ts +7 -0
- package/server/routes/api/silkworm/auto/start.post.ts +18 -0
- package/server/routes/api/silkworm/auto/stop.post.ts +7 -0
- package/server/routes/api/silkworm/connect.post.ts +28 -0
- package/server/routes/api/silkworm/history/clear.post.ts +7 -0
- package/server/routes/api/silkworm/manual/send.post.ts +38 -0
- package/server/routes/api/silkworm/state.get.ts +4 -0
- package/server/routes/api/silkworm/stream.get.ts +59 -0
- package/server/routes/api/silkworm/test.post.ts +18 -0
- package/server/state.ts +3 -0
- package/src/App.vue +418 -0
- package/src/IconGlyph.vue +33 -0
- package/src/main.ts +5 -0
- package/src/runner/random.ts +29 -0
- package/src/runner/runtime.ts +396 -0
- package/src/runner/transport.ts +109 -0
- package/src/runner/types.ts +118 -0
- package/src/scenarios/index.ts +187 -0
- package/src/styles.css +172 -0
- package/tsconfig.json +9 -0
- package/vite.config.ts +17 -0
- package/index.js +0 -1
package/src/App.vue
ADDED
|
@@ -0,0 +1,418 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { DebugLogLevel, DebugLogSource, DebugLogType } from '@flash-debug/types'
|
|
3
|
+
import { DEFAULT_DEBUG_PORT } from '@flash-debug/config/constants'
|
|
4
|
+
import { computed, onBeforeUnmount, onMounted, reactive, ref } from 'vue'
|
|
5
|
+
import type { AutoConfig, ConnectionConfig, ManualEventInput, RunnerSnapshot, SilkwormScenario } from './runner/types'
|
|
6
|
+
import IconGlyph from './IconGlyph.vue'
|
|
7
|
+
|
|
8
|
+
const scenarios: readonly SilkwormScenario[] = ['normal', 'mixed-sources', 'content-formats', 'network', 'exceptions', 'burst', 'duplicates', 'invalid', 'multi-device', 'long-run']
|
|
9
|
+
const levels: readonly DebugLogLevel[] = ['debug', 'info', 'warning', 'error']
|
|
10
|
+
const types: readonly DebugLogType[] = ['log', 'network', 'exception', 'performance', 'event']
|
|
11
|
+
const sources: readonly DebugLogSource[] = ['flutter', 'adb', 'server', 'unknown']
|
|
12
|
+
const formats = ['json', 'jsonl', 'yaml', 'ansi', 'text'] as const
|
|
13
|
+
|
|
14
|
+
const connection = reactive<ConnectionConfig>({
|
|
15
|
+
baseUrl: `http://127.0.0.1:${DEFAULT_DEBUG_PORT}`,
|
|
16
|
+
token: '',
|
|
17
|
+
clientId: 'silkworm-01',
|
|
18
|
+
deviceId: 'silkworm-device',
|
|
19
|
+
source: 'flutter',
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
const auto = reactive<AutoConfig>({
|
|
23
|
+
scenario: 'normal',
|
|
24
|
+
rate: 2,
|
|
25
|
+
batchSize: 1,
|
|
26
|
+
durationSeconds: 0,
|
|
27
|
+
seed: 'silkworm',
|
|
28
|
+
clientId: 'silkworm-01',
|
|
29
|
+
deviceId: 'silkworm-device',
|
|
30
|
+
flushErrors: true,
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
const manual = reactive<ManualEventInput>({
|
|
34
|
+
id: 'manual-1',
|
|
35
|
+
timestamp: new Date().toISOString(),
|
|
36
|
+
level: 'info',
|
|
37
|
+
type: 'log',
|
|
38
|
+
source: 'flutter',
|
|
39
|
+
tag: 'Silkworm',
|
|
40
|
+
clientId: 'silkworm-01',
|
|
41
|
+
deviceId: 'silkworm-device',
|
|
42
|
+
contentFormat: 'text',
|
|
43
|
+
message: 'Manual test event',
|
|
44
|
+
content: 'Hello from Silkworm',
|
|
45
|
+
error: '',
|
|
46
|
+
stackTrace: '',
|
|
47
|
+
metadata: '{\n "source": "manual"\n}',
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
const snapshot = ref<RunnerSnapshot>({
|
|
51
|
+
connection: { baseUrl: connection.baseUrl, clientId: connection.clientId, deviceId: connection.deviceId, source: connection.source, connected: false, hasToken: false },
|
|
52
|
+
auto: { status: 'idle', sequence: 0, config: { ...auto } },
|
|
53
|
+
stats: { generated: 0, queued: 0, accepted: 0, failed: 0, duplicate: 0, retrying: 0, queueLength: 0 },
|
|
54
|
+
history: [],
|
|
55
|
+
})
|
|
56
|
+
const notice = ref<{ kind: 'success' | 'error', text: string } | null>(null)
|
|
57
|
+
const busy = ref(false)
|
|
58
|
+
const manualBatchSize = ref(1)
|
|
59
|
+
const duplicateManualId = ref(false)
|
|
60
|
+
const connectionSettingsOpen = ref(false)
|
|
61
|
+
const autoSettingsOpen = ref(false)
|
|
62
|
+
const manualDetailsOpen = ref(false)
|
|
63
|
+
const historyDrawerOpen = ref(false)
|
|
64
|
+
const previewOpen = ref(false)
|
|
65
|
+
let stream: EventSource | undefined
|
|
66
|
+
let noticeTimer: ReturnType<typeof setTimeout> | undefined
|
|
67
|
+
|
|
68
|
+
const autoRunning = computed(() => snapshot.value.auto.status === 'running' || snapshot.value.auto.status === 'starting')
|
|
69
|
+
const autoPaused = computed(() => snapshot.value.auto.status === 'paused')
|
|
70
|
+
const connected = computed(() => snapshot.value.connection.connected)
|
|
71
|
+
const previewPayload = computed(() => {
|
|
72
|
+
try {
|
|
73
|
+
return JSON.stringify(buildManualEvent(), null, 2)
|
|
74
|
+
}
|
|
75
|
+
catch (cause) {
|
|
76
|
+
return cause instanceof Error ? cause.message : String(cause)
|
|
77
|
+
}
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
function applySnapshot(next: RunnerSnapshot): void {
|
|
81
|
+
snapshot.value = next
|
|
82
|
+
Object.assign(auto, next.auto.config)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function showNotice(text: string, kind: 'success' | 'error' = 'success'): void {
|
|
86
|
+
notice.value = { kind, text }
|
|
87
|
+
if (noticeTimer) {
|
|
88
|
+
clearTimeout(noticeTimer)
|
|
89
|
+
}
|
|
90
|
+
noticeTimer = setTimeout(() => {
|
|
91
|
+
notice.value = null
|
|
92
|
+
noticeTimer = undefined
|
|
93
|
+
}, 3200)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
async function request<T extends { snapshot?: RunnerSnapshot }>(path: string, body?: unknown, method?: 'GET' | 'POST'): Promise<T> {
|
|
97
|
+
const response = await fetch(path, {
|
|
98
|
+
method: method ?? (body === undefined ? 'GET' : 'POST'),
|
|
99
|
+
headers: body === undefined ? undefined : { 'Content-Type': 'application/json' },
|
|
100
|
+
body: body === undefined ? undefined : JSON.stringify(body),
|
|
101
|
+
})
|
|
102
|
+
const payload = await response.json() as T & { error?: string }
|
|
103
|
+
if (!response.ok) {
|
|
104
|
+
throw new Error(payload.error ?? `HTTP ${response.status}`)
|
|
105
|
+
}
|
|
106
|
+
if (payload.snapshot) {
|
|
107
|
+
applySnapshot(payload.snapshot)
|
|
108
|
+
}
|
|
109
|
+
return payload
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
async function connect(): Promise<void> {
|
|
113
|
+
await runAction(async () => {
|
|
114
|
+
const payload = await request<{ ok: boolean, snapshot: RunnerSnapshot, error?: string }>('/api/silkworm/connect', connection)
|
|
115
|
+
if (!payload.ok) {
|
|
116
|
+
throw new Error(payload.error ?? 'Target is unavailable')
|
|
117
|
+
}
|
|
118
|
+
showNotice('Connected to target')
|
|
119
|
+
})
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
async function testConnection(): Promise<void> {
|
|
123
|
+
await runAction(async () => {
|
|
124
|
+
const payload = await request<{ ok: boolean, snapshot: RunnerSnapshot, error?: string }>('/api/silkworm/test', undefined, 'POST')
|
|
125
|
+
if (!payload.ok) {
|
|
126
|
+
throw new Error(payload.error ?? 'Health check failed')
|
|
127
|
+
}
|
|
128
|
+
showNotice(`Health check passed in ${payload.snapshot.connection.lastLatencyMs ?? 0}ms`)
|
|
129
|
+
})
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
async function startAuto(): Promise<void> {
|
|
133
|
+
await runAction(async () => {
|
|
134
|
+
await request('/api/silkworm/auto/start', { ...auto })
|
|
135
|
+
showNotice(`Auto mode ${auto.scenario} started`)
|
|
136
|
+
})
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
async function pauseAuto(): Promise<void> {
|
|
140
|
+
await runAction(async () => {
|
|
141
|
+
await request('/api/silkworm/auto/pause', undefined, 'POST')
|
|
142
|
+
showNotice('Auto mode paused')
|
|
143
|
+
})
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
async function stopAuto(): Promise<void> {
|
|
147
|
+
await runAction(async () => {
|
|
148
|
+
await request('/api/silkworm/auto/stop', undefined, 'POST')
|
|
149
|
+
showNotice('Auto mode stopped')
|
|
150
|
+
})
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function buildManualEvent(): Record<string, unknown> {
|
|
154
|
+
let metadata: unknown
|
|
155
|
+
if (manual.metadata.trim()) {
|
|
156
|
+
metadata = JSON.parse(manual.metadata)
|
|
157
|
+
}
|
|
158
|
+
return {
|
|
159
|
+
id: manual.id.trim() || `manual-${Date.now().toString(36)}`,
|
|
160
|
+
timestamp: manual.timestamp || new Date().toISOString(),
|
|
161
|
+
level: manual.level,
|
|
162
|
+
type: manual.type,
|
|
163
|
+
source: manual.source,
|
|
164
|
+
tag: manual.tag.trim() || undefined,
|
|
165
|
+
clientId: manual.clientId.trim() || connection.clientId,
|
|
166
|
+
deviceId: manual.deviceId.trim() || connection.deviceId,
|
|
167
|
+
contentFormat: manual.contentFormat,
|
|
168
|
+
message: manual.message,
|
|
169
|
+
content: manual.content,
|
|
170
|
+
error: manual.error.trim() || undefined,
|
|
171
|
+
stackTrace: manual.stackTrace.trim() || undefined,
|
|
172
|
+
metadata,
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
async function sendManual(): Promise<void> {
|
|
177
|
+
await runAction(async () => {
|
|
178
|
+
const event = buildManualEvent()
|
|
179
|
+
await request('/api/silkworm/manual/send', {
|
|
180
|
+
event,
|
|
181
|
+
batchSize: Math.min(100, Math.max(1, Number(manualBatchSize.value))),
|
|
182
|
+
duplicate: duplicateManualId.value,
|
|
183
|
+
})
|
|
184
|
+
showNotice('Manual payload queued')
|
|
185
|
+
})
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function resetManual(): void {
|
|
189
|
+
manual.id = 'manual-1'
|
|
190
|
+
manual.timestamp = new Date().toISOString()
|
|
191
|
+
manual.level = 'info'
|
|
192
|
+
manual.type = 'log'
|
|
193
|
+
manual.source = connection.source
|
|
194
|
+
manual.tag = 'Silkworm'
|
|
195
|
+
manual.clientId = connection.clientId
|
|
196
|
+
manual.deviceId = connection.deviceId
|
|
197
|
+
manual.contentFormat = 'text'
|
|
198
|
+
manual.message = 'Manual test event'
|
|
199
|
+
manual.content = 'Hello from Silkworm'
|
|
200
|
+
manual.error = ''
|
|
201
|
+
manual.stackTrace = ''
|
|
202
|
+
manual.metadata = '{\n "source": "manual"\n}'
|
|
203
|
+
manualBatchSize.value = 1
|
|
204
|
+
duplicateManualId.value = false
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
async function clearHistory(): Promise<void> {
|
|
208
|
+
await runAction(async () => {
|
|
209
|
+
await request('/api/silkworm/history/clear', undefined, 'POST')
|
|
210
|
+
showNotice('History cleared')
|
|
211
|
+
})
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
async function runAction(action: () => Promise<void>): Promise<void> {
|
|
215
|
+
notice.value = null
|
|
216
|
+
busy.value = true
|
|
217
|
+
try {
|
|
218
|
+
await action()
|
|
219
|
+
}
|
|
220
|
+
catch (cause) {
|
|
221
|
+
showNotice(cause instanceof Error ? cause.message : String(cause), 'error')
|
|
222
|
+
}
|
|
223
|
+
finally {
|
|
224
|
+
busy.value = false
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function formatTime(value: string): string {
|
|
229
|
+
return new Date(value).toLocaleTimeString()
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
function statusClass(status: string): string {
|
|
233
|
+
return `status-${status}`
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
onMounted(async () => {
|
|
237
|
+
await runAction(async () => {
|
|
238
|
+
await request('/api/silkworm/state')
|
|
239
|
+
})
|
|
240
|
+
stream = new EventSource('/api/silkworm/stream')
|
|
241
|
+
stream.addEventListener('state', (event) => {
|
|
242
|
+
applySnapshot(JSON.parse((event as MessageEvent).data) as RunnerSnapshot)
|
|
243
|
+
})
|
|
244
|
+
stream.addEventListener('error', () => {
|
|
245
|
+
showNotice('Control stream interrupted · retrying', 'error')
|
|
246
|
+
})
|
|
247
|
+
})
|
|
248
|
+
|
|
249
|
+
onBeforeUnmount(() => {
|
|
250
|
+
stream?.close()
|
|
251
|
+
if (noticeTimer) {
|
|
252
|
+
clearTimeout(noticeTimer)
|
|
253
|
+
}
|
|
254
|
+
})
|
|
255
|
+
</script>
|
|
256
|
+
|
|
257
|
+
<template>
|
|
258
|
+
<main class="app-shell">
|
|
259
|
+
<header class="topbar panel">
|
|
260
|
+
<div class="brand">
|
|
261
|
+
<img class="brand-mark" src="/icons/silkworm/icon-128.png" alt="" aria-hidden="true" />
|
|
262
|
+
<div><strong>Flash Debug</strong><span>Silkworm</span></div>
|
|
263
|
+
</div>
|
|
264
|
+
<div class="target-status" :class="{ online: connected }">
|
|
265
|
+
<span class="status-dot" />
|
|
266
|
+
<span>{{ connected ? 'Connected' : 'Not connected' }}</span>
|
|
267
|
+
<small>{{ connection.baseUrl }}</small>
|
|
268
|
+
</div>
|
|
269
|
+
<div class="top-actions">
|
|
270
|
+
<button class="button secondary" type="button" :disabled="busy" @click="testConnection">{{ busy ? 'Working…' : 'Test request' }}</button>
|
|
271
|
+
<button class="button primary" type="button" :disabled="busy" @click="connect">Connect</button>
|
|
272
|
+
</div>
|
|
273
|
+
</header>
|
|
274
|
+
|
|
275
|
+
<Transition name="silkworm-notice">
|
|
276
|
+
<div v-if="notice" class="notice" :class="`notice-${notice.kind}`" role="status" aria-live="polite">
|
|
277
|
+
{{ notice.text }}
|
|
278
|
+
</div>
|
|
279
|
+
</Transition>
|
|
280
|
+
|
|
281
|
+
<section class="connection panel">
|
|
282
|
+
<div class="connection-inline">
|
|
283
|
+
<label class="field"><span>Target Base URL</span><input v-model="connection.baseUrl" type="url" placeholder="https://xxx.trycloudflare.com" /></label>
|
|
284
|
+
<button class="link-button" type="button" @click="connectionSettingsOpen = true">Connection settings</button>
|
|
285
|
+
</div>
|
|
286
|
+
</section>
|
|
287
|
+
|
|
288
|
+
<section class="control-grid">
|
|
289
|
+
<article class="panel mode-panel">
|
|
290
|
+
<div class="section-title"><div><strong>Auto Mode</strong><span>{{ auto.scenario }} · {{ auto.rate }} events / second</span></div><span class="mode-state" :class="statusClass(snapshot.auto.status)">{{ snapshot.auto.status }}</span></div>
|
|
291
|
+
<div class="quick-form-grid">
|
|
292
|
+
<label class="field"><span>Scenario</span><select v-model="auto.scenario"><option v-for="item in scenarios" :key="item" :value="item">{{ item }}</option></select></label>
|
|
293
|
+
<label class="field"><span>Events / second</span><input v-model.number="auto.rate" type="number" min="0.1" max="100" step="0.1" /></label>
|
|
294
|
+
</div>
|
|
295
|
+
<div class="button-row">
|
|
296
|
+
<button class="button primary" type="button" :disabled="busy || !connected || autoRunning" @click="startAuto">{{ autoPaused ? 'Resume' : 'Start' }}</button>
|
|
297
|
+
<button class="button secondary" type="button" :disabled="busy || !autoRunning" @click="pauseAuto">Pause</button>
|
|
298
|
+
<button class="button danger" type="button" :disabled="busy || snapshot.auto.status === 'idle'" @click="stopAuto">Stop</button>
|
|
299
|
+
<button class="link-button" type="button" @click="autoSettingsOpen = true">Advanced settings</button>
|
|
300
|
+
<span v-if="!connected" class="control-hint">Connect to a target before starting</span>
|
|
301
|
+
</div>
|
|
302
|
+
</article>
|
|
303
|
+
|
|
304
|
+
<article class="panel mode-panel">
|
|
305
|
+
<div class="section-title"><div><strong>Manual Send</strong><span>Send one event with the common fields</span></div><button class="link-button" type="button" @click="manualDetailsOpen = true">Advanced details</button></div>
|
|
306
|
+
<div class="quick-form-grid manual-quick-grid">
|
|
307
|
+
<label class="field"><span>Level</span><select v-model="manual.level"><option v-for="item in levels" :key="item" :value="item">{{ item }}</option></select></label>
|
|
308
|
+
<label class="field"><span>Type</span><select v-model="manual.type"><option v-for="item in types" :key="item" :value="item">{{ item }}</option></select></label>
|
|
309
|
+
<label class="field wide"><span>Message</span><input v-model="manual.message" type="text" /></label>
|
|
310
|
+
<label class="field wide"><span>Content</span><textarea v-model="manual.content" rows="2" spellcheck="false" /></label>
|
|
311
|
+
</div>
|
|
312
|
+
<div class="button-row">
|
|
313
|
+
<button class="button primary" type="button" @click="sendManual">Send</button>
|
|
314
|
+
<button class="button secondary" type="button" @click="previewOpen = true">Preview payload</button>
|
|
315
|
+
<button class="link-button" type="button" @click="resetManual">Reset</button>
|
|
316
|
+
</div>
|
|
317
|
+
</article>
|
|
318
|
+
</section>
|
|
319
|
+
|
|
320
|
+
<button class="stats-strip panel" type="button" :aria-expanded="historyDrawerOpen" @click="historyDrawerOpen = true">
|
|
321
|
+
<span><small>Generated</small><strong>{{ snapshot.stats.generated }}</strong></span>
|
|
322
|
+
<span><small>Accepted</small><strong class="success-text">{{ snapshot.stats.accepted }}</strong></span>
|
|
323
|
+
<span><small>Failed</small><strong class="error-text">{{ snapshot.stats.failed }}</strong></span>
|
|
324
|
+
<span><small>Duplicate</small><strong>{{ snapshot.stats.duplicate }}</strong></span>
|
|
325
|
+
<span><small>Queue</small><strong>{{ snapshot.stats.queueLength }}</strong></span>
|
|
326
|
+
<span class="stats-strip-hint">History</span>
|
|
327
|
+
</button>
|
|
328
|
+
|
|
329
|
+
<Transition name="silkworm-drawer">
|
|
330
|
+
<div v-if="historyDrawerOpen" class="history-drawer-backdrop" @click.self="historyDrawerOpen = false">
|
|
331
|
+
<section class="history-drawer panel">
|
|
332
|
+
<div class="section-title"><div><strong>Run history</strong><span>Latest 500 attempts</span></div><div class="history-actions"><button class="icon-button" type="button" aria-label="Clear history" title="Clear history" @click="clearHistory"><IconGlyph name="trash" /></button><button class="icon-button" type="button" aria-label="Close history" title="Close history" @click="historyDrawerOpen = false"><IconGlyph name="close" /></button></div></div>
|
|
333
|
+
<div class="stats-row drawer-stats">
|
|
334
|
+
<div class="stat panel"><span>Generated</span><strong>{{ snapshot.stats.generated }}</strong></div>
|
|
335
|
+
<div class="stat panel"><span>Accepted</span><strong class="success-text">{{ snapshot.stats.accepted }}</strong></div>
|
|
336
|
+
<div class="stat panel"><span>Failed</span><strong class="error-text">{{ snapshot.stats.failed }}</strong></div>
|
|
337
|
+
<div class="stat panel"><span>Duplicate</span><strong>{{ snapshot.stats.duplicate }}</strong></div>
|
|
338
|
+
<div class="stat panel"><span>Queue</span><strong>{{ snapshot.stats.queueLength }}</strong></div>
|
|
339
|
+
</div>
|
|
340
|
+
<div v-if="!snapshot.history.length" class="empty-state"><strong>No send attempts yet</strong><span>Connect a target, then start Auto Mode or send a manual event.</span></div>
|
|
341
|
+
<div v-else class="history-list">
|
|
342
|
+
<div v-for="attempt in snapshot.history" :key="attempt.id" class="history-row">
|
|
343
|
+
<time>{{ formatTime(attempt.startedAt) }}</time>
|
|
344
|
+
<span class="mode-pill">{{ attempt.mode }}</span>
|
|
345
|
+
<span class="history-summary">{{ attempt.summary }}</span>
|
|
346
|
+
<span class="attempt-count">{{ attempt.eventIds.length }} events</span>
|
|
347
|
+
<span class="status-pill" :class="statusClass(attempt.status)">{{ attempt.status }}</span>
|
|
348
|
+
<span class="history-error">{{ attempt.error ?? '' }}</span>
|
|
349
|
+
</div>
|
|
350
|
+
</div>
|
|
351
|
+
</section>
|
|
352
|
+
</div>
|
|
353
|
+
</Transition>
|
|
354
|
+
|
|
355
|
+
<Transition name="silkworm-modal">
|
|
356
|
+
<div v-if="connectionSettingsOpen" class="modal-backdrop" @click.self="connectionSettingsOpen = false">
|
|
357
|
+
<section class="modal-card panel">
|
|
358
|
+
<div class="section-title"><div><strong>Connection settings</strong><span>Advanced target options</span></div><button class="icon-button" type="button" aria-label="Close connection settings" title="Close" @click="connectionSettingsOpen = false"><IconGlyph name="close" /></button></div>
|
|
359
|
+
<div class="form-grid connection-grid">
|
|
360
|
+
<label class="field wide"><span>Ingest token</span><input v-model="connection.token" type="password" placeholder="Optional bearer token" /></label>
|
|
361
|
+
<label class="field"><span>Client ID</span><input v-model="connection.clientId" type="text" /></label>
|
|
362
|
+
<label class="field"><span>Device ID</span><input v-model="connection.deviceId" type="text" /></label>
|
|
363
|
+
<label class="field"><span>Default source</span><select v-model="connection.source"><option v-for="item in sources" :key="item" :value="item">{{ item }}</option></select></label>
|
|
364
|
+
</div>
|
|
365
|
+
</section>
|
|
366
|
+
</div>
|
|
367
|
+
</Transition>
|
|
368
|
+
|
|
369
|
+
<Transition name="silkworm-modal">
|
|
370
|
+
<div v-if="autoSettingsOpen" class="modal-backdrop" @click.self="autoSettingsOpen = false">
|
|
371
|
+
<section class="modal-card panel">
|
|
372
|
+
<div class="section-title"><div><strong>Auto settings</strong><span>Advanced generation options</span></div><button class="icon-button" type="button" aria-label="Close auto settings" title="Close" @click="autoSettingsOpen = false"><IconGlyph name="close" /></button></div>
|
|
373
|
+
<div class="form-grid">
|
|
374
|
+
<label class="field"><span>Batch size</span><input v-model.number="auto.batchSize" type="number" min="1" max="100" /></label>
|
|
375
|
+
<label class="field"><span>Duration seconds</span><input v-model.number="auto.durationSeconds" type="number" min="0" placeholder="0 = forever" /></label>
|
|
376
|
+
<label class="field wide"><span>Seed</span><input v-model="auto.seed" type="text" /></label>
|
|
377
|
+
<label class="field"><span>Auto client ID</span><input v-model="auto.clientId" type="text" /></label>
|
|
378
|
+
<label class="field"><span>Auto device ID</span><input v-model="auto.deviceId" type="text" /></label>
|
|
379
|
+
</div>
|
|
380
|
+
<label class="check-row"><input v-model="auto.flushErrors" type="checkbox" /><span>Flush error events immediately</span></label>
|
|
381
|
+
</section>
|
|
382
|
+
</div>
|
|
383
|
+
</Transition>
|
|
384
|
+
|
|
385
|
+
<Transition name="silkworm-modal">
|
|
386
|
+
<div v-if="manualDetailsOpen" class="modal-backdrop" @click.self="manualDetailsOpen = false">
|
|
387
|
+
<section class="modal-card panel modal-wide">
|
|
388
|
+
<div class="section-title"><div><strong>Manual event details</strong><span>Optional fields for the payload</span></div><button class="icon-button" type="button" aria-label="Close manual event details" title="Close" @click="manualDetailsOpen = false"><IconGlyph name="close" /></button></div>
|
|
389
|
+
<div class="form-grid">
|
|
390
|
+
<label class="field wide"><span>Event ID</span><input v-model="manual.id" type="text" /></label>
|
|
391
|
+
<label class="field wide"><span>Timestamp</span><input v-model="manual.timestamp" type="text" /></label>
|
|
392
|
+
<label class="field"><span>Source</span><select v-model="manual.source"><option v-for="item in sources" :key="item" :value="item">{{ item }}</option></select></label>
|
|
393
|
+
<label class="field"><span>Content format</span><select v-model="manual.contentFormat"><option v-for="item in formats" :key="item" :value="item">{{ item }}</option></select></label>
|
|
394
|
+
<label class="field"><span>Tag</span><input v-model="manual.tag" type="text" /></label>
|
|
395
|
+
<label class="field"><span>Client ID</span><input v-model="manual.clientId" type="text" /></label>
|
|
396
|
+
<label class="field"><span>Device ID</span><input v-model="manual.deviceId" type="text" /></label>
|
|
397
|
+
<label class="field wide"><span>Error</span><input v-model="manual.error" type="text" /></label>
|
|
398
|
+
<label class="field wide"><span>Stack trace</span><textarea v-model="manual.stackTrace" rows="3" spellcheck="false" /></label>
|
|
399
|
+
<label class="field wide"><span>Metadata JSON</span><textarea v-model="manual.metadata" rows="3" spellcheck="false" /></label>
|
|
400
|
+
</div>
|
|
401
|
+
<div class="manual-options">
|
|
402
|
+
<label class="field compact"><span>Batch count</span><input v-model.number="manualBatchSize" type="number" min="1" max="100" /></label>
|
|
403
|
+
<label class="check-row"><input v-model="duplicateManualId" type="checkbox" /><span>Duplicate event ID</span></label>
|
|
404
|
+
</div>
|
|
405
|
+
</section>
|
|
406
|
+
</div>
|
|
407
|
+
</Transition>
|
|
408
|
+
|
|
409
|
+
<Transition name="silkworm-modal">
|
|
410
|
+
<div v-if="previewOpen" class="modal-backdrop" @click.self="previewOpen = false">
|
|
411
|
+
<section class="preview-modal panel">
|
|
412
|
+
<div class="section-title"><div><strong>Payload preview</strong><span>Authorization is never included here</span></div><button class="icon-button" type="button" aria-label="Close payload preview" title="Close" @click="previewOpen = false"><IconGlyph name="close" /></button></div>
|
|
413
|
+
<pre>{{ previewPayload }}</pre>
|
|
414
|
+
</section>
|
|
415
|
+
</div>
|
|
416
|
+
</Transition>
|
|
417
|
+
</main>
|
|
418
|
+
</template>
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
export type SilkwormIconName = 'close' | 'trash'
|
|
3
|
+
|
|
4
|
+
withDefaults(defineProps<{
|
|
5
|
+
name: SilkwormIconName
|
|
6
|
+
size?: number
|
|
7
|
+
}>(), {
|
|
8
|
+
size: 15,
|
|
9
|
+
})
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<template>
|
|
13
|
+
<svg
|
|
14
|
+
class="icon-glyph"
|
|
15
|
+
:width="size"
|
|
16
|
+
:height="size"
|
|
17
|
+
viewBox="0 0 24 24"
|
|
18
|
+
fill="none"
|
|
19
|
+
stroke="currentColor"
|
|
20
|
+
stroke-width="1.8"
|
|
21
|
+
stroke-linecap="round"
|
|
22
|
+
stroke-linejoin="round"
|
|
23
|
+
aria-hidden="true"
|
|
24
|
+
>
|
|
25
|
+
<template v-if="name === 'close'">
|
|
26
|
+
<path d="m6 6 12 12M18 6 6 18" />
|
|
27
|
+
</template>
|
|
28
|
+
<template v-else>
|
|
29
|
+
<path d="M4 7h16M10 11v6M14 11v6" />
|
|
30
|
+
<path d="M6 7l1 13h10l1-13M9 7V4h6v3" />
|
|
31
|
+
</template>
|
|
32
|
+
</svg>
|
|
33
|
+
</template>
|
package/src/main.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export class SeededRandom {
|
|
2
|
+
private state: number
|
|
3
|
+
|
|
4
|
+
constructor(seed: string) {
|
|
5
|
+
let hash = 2166136261
|
|
6
|
+
for (const character of seed || 'silkworm') {
|
|
7
|
+
hash ^= character.charCodeAt(0)
|
|
8
|
+
hash = Math.imul(hash, 16777619)
|
|
9
|
+
}
|
|
10
|
+
this.state = hash >>> 0
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
next(): number {
|
|
14
|
+
this.state = (Math.imul(1664525, this.state) + 1013904223) >>> 0
|
|
15
|
+
return this.state / 4294967296
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
int(min: number, max: number): number {
|
|
19
|
+
return Math.floor(this.next() * (max - min + 1)) + min
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
pick<T>(items: readonly T[]): T {
|
|
23
|
+
return items[this.int(0, items.length - 1)] as T
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
bool(probability = 0.5): boolean {
|
|
27
|
+
return this.next() < probability
|
|
28
|
+
}
|
|
29
|
+
}
|