@pixelbyte-software/pixcode 1.33.10 → 1.34.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/dist/api-docs.html +395 -395
- package/dist/assets/{index-B_dU5AHA.js → index-BvClqlMf.js} +134 -134
- package/dist/favicon.svg +8 -8
- package/dist/icons/icon-128x128.svg +9 -9
- package/dist/icons/icon-144x144.svg +9 -9
- package/dist/icons/icon-152x152.svg +9 -9
- package/dist/icons/icon-192x192.svg +9 -9
- package/dist/icons/icon-384x384.svg +9 -9
- package/dist/icons/icon-512x512.svg +9 -9
- package/dist/icons/icon-72x72.svg +9 -9
- package/dist/icons/icon-96x96.svg +9 -9
- package/dist/icons/icon-template.svg +9 -9
- package/dist/index.html +1 -1
- package/dist/logo.svg +12 -12
- package/dist/openapi.yaml +1311 -1311
- package/dist-server/server/index.js +4 -0
- package/dist-server/server/index.js.map +1 -1
- package/dist-server/server/modules/orchestration/a2a/adapter-registry.js +47 -0
- package/dist-server/server/modules/orchestration/a2a/adapter-registry.js.map +1 -0
- package/dist-server/server/modules/orchestration/a2a/adapters/abstract-a2a.adapter.js +17 -0
- package/dist-server/server/modules/orchestration/a2a/adapters/abstract-a2a.adapter.js.map +1 -0
- package/dist-server/server/modules/orchestration/a2a/adapters/claude-code.adapter.js +233 -0
- package/dist-server/server/modules/orchestration/a2a/adapters/claude-code.adapter.js.map +1 -0
- package/dist-server/server/modules/orchestration/a2a/agent-card.js +50 -0
- package/dist-server/server/modules/orchestration/a2a/agent-card.js.map +1 -0
- package/dist-server/server/modules/orchestration/a2a/auth.middleware.js +25 -0
- package/dist-server/server/modules/orchestration/a2a/auth.middleware.js.map +1 -0
- package/dist-server/server/modules/orchestration/a2a/bus.js +34 -0
- package/dist-server/server/modules/orchestration/a2a/bus.js.map +1 -0
- package/dist-server/server/modules/orchestration/a2a/routes.js +233 -0
- package/dist-server/server/modules/orchestration/a2a/routes.js.map +1 -0
- package/dist-server/server/modules/orchestration/a2a/types.js +6 -0
- package/dist-server/server/modules/orchestration/a2a/types.js.map +1 -0
- package/dist-server/server/modules/orchestration/a2a/validator.js +85 -0
- package/dist-server/server/modules/orchestration/a2a/validator.js.map +1 -0
- package/dist-server/server/modules/orchestration/index.js +10 -0
- package/dist-server/server/modules/orchestration/index.js.map +1 -0
- package/dist-server/server/opencode-cli.js +4 -1
- package/dist-server/server/opencode-cli.js.map +1 -1
- package/package.json +178 -178
- package/scripts/smoke/a2a-roundtrip.mjs +98 -0
- package/server/database/db.js +794 -794
- package/server/database/json-store.js +194 -194
- package/server/index.js +9 -0
- package/server/modules/orchestration/a2a/adapter-registry.ts +58 -0
- package/server/modules/orchestration/a2a/adapters/abstract-a2a.adapter.ts +49 -0
- package/server/modules/orchestration/a2a/adapters/claude-code.adapter.ts +283 -0
- package/server/modules/orchestration/a2a/agent-card.ts +55 -0
- package/server/modules/orchestration/a2a/auth.middleware.ts +29 -0
- package/server/modules/orchestration/a2a/bus.ts +46 -0
- package/server/modules/orchestration/a2a/routes.ts +264 -0
- package/server/modules/orchestration/a2a/types.ts +111 -0
- package/server/modules/orchestration/a2a/validator.ts +90 -0
- package/server/modules/orchestration/index.ts +26 -0
- package/server/modules/providers/list/opencode/opencode-auth.provider.ts +130 -130
- package/server/modules/providers/list/opencode/opencode-mcp.provider.ts +126 -126
- package/server/modules/providers/list/opencode/opencode-sessions.provider.ts +232 -232
- package/server/modules/providers/list/opencode/opencode.provider.ts +29 -29
- package/server/modules/providers/list/qwen/qwen-auth.provider.ts +145 -145
- package/server/modules/providers/list/qwen/qwen-mcp.provider.ts +114 -114
- package/server/modules/providers/list/qwen/qwen-sessions.provider.ts +265 -265
- package/server/modules/providers/list/qwen/qwen.provider.ts +21 -21
- package/server/modules/providers/shared/provider-configs.ts +142 -142
- package/server/opencode-cli.js +4 -1
- package/server/opencode-response-handler.js +107 -107
- package/server/qwen-code-cli.js +395 -395
- package/server/qwen-response-handler.js +73 -73
- package/server/routes/qwen.js +27 -27
- package/server/services/external-access.js +171 -171
- package/server/services/provider-credentials.js +189 -189
- package/server/services/provider-models.js +381 -381
- package/server/services/telegram/telegram-http-client.js +130 -130
- package/server/services/vapid-keys.js +36 -36
- package/server/utils/port-access.js +209 -209
- package/scripts/rest-sweep.mjs +0 -93
package/dist/api-docs.html
CHANGED
|
@@ -1,395 +1,395 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8" />
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
|
|
6
|
-
<title>Pixcode — API Documentation</title>
|
|
7
|
-
<meta name="description" content="REST API reference for Pixcode — the multi-CLI web UI for Claude Code, Cursor, Codex, Gemini, Qwen, and OpenCode." />
|
|
8
|
-
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
|
9
|
-
<link rel="icon" type="image/png" href="/favicon.png" />
|
|
10
|
-
<style>
|
|
11
|
-
:root {
|
|
12
|
-
--bg: #0b0d10;
|
|
13
|
-
--bg-soft: #11151b;
|
|
14
|
-
--bg-card: #161b22;
|
|
15
|
-
--border: #232a33;
|
|
16
|
-
--fg: #e6edf3;
|
|
17
|
-
--fg-muted: #8b949e;
|
|
18
|
-
--primary: #2563eb;
|
|
19
|
-
--primary-hover: #1d4ed8;
|
|
20
|
-
--accent: #10b981;
|
|
21
|
-
--warn: #f59e0b;
|
|
22
|
-
}
|
|
23
|
-
@media (prefers-color-scheme: light) {
|
|
24
|
-
:root {
|
|
25
|
-
--bg: #ffffff;
|
|
26
|
-
--bg-soft: #f6f8fa;
|
|
27
|
-
--bg-card: #ffffff;
|
|
28
|
-
--border: #d0d7de;
|
|
29
|
-
--fg: #1f2328;
|
|
30
|
-
--fg-muted: #656d76;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
* { box-sizing: border-box; }
|
|
35
|
-
html, body { margin: 0; padding: 0; }
|
|
36
|
-
body {
|
|
37
|
-
background: var(--bg);
|
|
38
|
-
color: var(--fg);
|
|
39
|
-
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Inter, sans-serif;
|
|
40
|
-
min-height: 100vh;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/* ── Top bar ─────────────────────────────────────────────────── */
|
|
44
|
-
.topbar {
|
|
45
|
-
position: sticky; top: 0; z-index: 50;
|
|
46
|
-
display: flex; align-items: center; gap: 12px;
|
|
47
|
-
padding: 10px 16px;
|
|
48
|
-
background: var(--bg-soft);
|
|
49
|
-
border-bottom: 1px solid var(--border);
|
|
50
|
-
backdrop-filter: blur(8px);
|
|
51
|
-
}
|
|
52
|
-
.topbar-brand {
|
|
53
|
-
display: flex; align-items: center; gap: 10px;
|
|
54
|
-
font-weight: 700; font-size: 15px; letter-spacing: -0.01em;
|
|
55
|
-
color: var(--fg); text-decoration: none;
|
|
56
|
-
}
|
|
57
|
-
.topbar-brand img { width: 24px; height: 24px; border-radius: 6px; }
|
|
58
|
-
.topbar-brand .badge {
|
|
59
|
-
font-size: 10px; font-weight: 600;
|
|
60
|
-
padding: 2px 6px; border-radius: 4px;
|
|
61
|
-
background: var(--primary); color: white;
|
|
62
|
-
letter-spacing: 0.04em; text-transform: uppercase;
|
|
63
|
-
}
|
|
64
|
-
.topbar-spacer { flex: 1; }
|
|
65
|
-
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
|
|
66
|
-
.topbar select, .topbar a.btn, .topbar button.btn {
|
|
67
|
-
height: 32px;
|
|
68
|
-
padding: 0 12px;
|
|
69
|
-
border-radius: 6px;
|
|
70
|
-
border: 1px solid var(--border);
|
|
71
|
-
background: var(--bg-card);
|
|
72
|
-
color: var(--fg);
|
|
73
|
-
font-size: 13px;
|
|
74
|
-
cursor: pointer;
|
|
75
|
-
text-decoration: none;
|
|
76
|
-
display: inline-flex; align-items: center; gap: 6px;
|
|
77
|
-
}
|
|
78
|
-
.topbar a.btn:hover, .topbar button.btn:hover { border-color: var(--primary); }
|
|
79
|
-
.topbar a.btn.primary, .topbar button.btn.primary {
|
|
80
|
-
background: var(--primary); border-color: var(--primary); color: white;
|
|
81
|
-
}
|
|
82
|
-
.topbar a.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
|
|
83
|
-
|
|
84
|
-
/* ── API key bar ──────────────────────────────────────────────── */
|
|
85
|
-
.apikey-bar {
|
|
86
|
-
display: flex; align-items: center; gap: 10px;
|
|
87
|
-
padding: 10px 16px;
|
|
88
|
-
background: var(--bg-card);
|
|
89
|
-
border-bottom: 1px solid var(--border);
|
|
90
|
-
flex-wrap: wrap;
|
|
91
|
-
}
|
|
92
|
-
.apikey-bar label {
|
|
93
|
-
font-size: 12px; font-weight: 600; color: var(--fg-muted);
|
|
94
|
-
letter-spacing: 0.02em; text-transform: uppercase;
|
|
95
|
-
}
|
|
96
|
-
.apikey-bar input {
|
|
97
|
-
flex: 1; min-width: 220px;
|
|
98
|
-
height: 34px; padding: 0 12px;
|
|
99
|
-
background: var(--bg-soft);
|
|
100
|
-
border: 1px solid var(--border);
|
|
101
|
-
border-radius: 6px;
|
|
102
|
-
color: var(--fg);
|
|
103
|
-
font-family: 'SF Mono', ui-monospace, monospace;
|
|
104
|
-
font-size: 13px;
|
|
105
|
-
}
|
|
106
|
-
.apikey-bar input:focus { outline: none; border-color: var(--primary); }
|
|
107
|
-
.apikey-bar .hint { font-size: 12px; color: var(--fg-muted); }
|
|
108
|
-
.apikey-bar .status {
|
|
109
|
-
font-size: 11px; padding: 3px 8px; border-radius: 999px;
|
|
110
|
-
background: var(--bg-soft); color: var(--fg-muted);
|
|
111
|
-
border: 1px solid var(--border);
|
|
112
|
-
}
|
|
113
|
-
.apikey-bar .status.ok { color: var(--accent); border-color: var(--accent); }
|
|
114
|
-
|
|
115
|
-
/* ── Scalar host ──────────────────────────────────────────────── */
|
|
116
|
-
#scalar-host { min-height: calc(100vh - 130px); }
|
|
117
|
-
|
|
118
|
-
/* ── Mobile tweaks ────────────────────────────────────────────── */
|
|
119
|
-
@media (max-width: 640px) {
|
|
120
|
-
.topbar { padding: 8px 10px; gap: 8px; }
|
|
121
|
-
.topbar-brand .subtitle { display: none; }
|
|
122
|
-
.topbar-actions a.btn span:not(.icon) { display: none; }
|
|
123
|
-
.apikey-bar { padding: 8px 10px; }
|
|
124
|
-
.apikey-bar .hint { display: none; }
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
/* ── Loading state ────────────────────────────────────────────── */
|
|
128
|
-
.loader {
|
|
129
|
-
display: flex; align-items: center; justify-content: center;
|
|
130
|
-
height: calc(100vh - 130px);
|
|
131
|
-
color: var(--fg-muted);
|
|
132
|
-
font-size: 14px;
|
|
133
|
-
gap: 10px;
|
|
134
|
-
}
|
|
135
|
-
.loader .spinner {
|
|
136
|
-
width: 18px; height: 18px;
|
|
137
|
-
border: 2px solid var(--border);
|
|
138
|
-
border-top-color: var(--primary);
|
|
139
|
-
border-radius: 50%;
|
|
140
|
-
animation: spin 0.8s linear infinite;
|
|
141
|
-
}
|
|
142
|
-
@keyframes spin { to { transform: rotate(360deg); } }
|
|
143
|
-
</style>
|
|
144
|
-
</head>
|
|
145
|
-
<body>
|
|
146
|
-
|
|
147
|
-
<header class="topbar">
|
|
148
|
-
<a href="/" class="topbar-brand">
|
|
149
|
-
<img src="/logo.svg" alt="Pixcode" />
|
|
150
|
-
<span data-i18n="title">Pixcode API</span>
|
|
151
|
-
<span class="badge" data-i18n="badge">v1.33</span>
|
|
152
|
-
</a>
|
|
153
|
-
<div class="topbar-spacer"></div>
|
|
154
|
-
<div class="topbar-actions">
|
|
155
|
-
<select id="lang-select" aria-label="Language" title="Language">
|
|
156
|
-
<option value="en">English</option>
|
|
157
|
-
<option value="tr">Türkçe</option>
|
|
158
|
-
<option value="de">Deutsch</option>
|
|
159
|
-
<option value="it">Italiano</option>
|
|
160
|
-
<option value="ja">日本語</option>
|
|
161
|
-
<option value="ko">한국어</option>
|
|
162
|
-
<option value="ru">Русский</option>
|
|
163
|
-
<option value="zh-CN">中文</option>
|
|
164
|
-
</select>
|
|
165
|
-
<a href="/openapi.yaml" class="btn" download>
|
|
166
|
-
<span class="icon" aria-hidden="true">⬇</span><span data-i18n="downloadSpec">Download spec</span>
|
|
167
|
-
</a>
|
|
168
|
-
<a href="/" class="btn primary">
|
|
169
|
-
<span class="icon" aria-hidden="true">←</span><span data-i18n="backToApp">Back to app</span>
|
|
170
|
-
</a>
|
|
171
|
-
</div>
|
|
172
|
-
</header>
|
|
173
|
-
|
|
174
|
-
<div class="apikey-bar">
|
|
175
|
-
<label for="api-key-input" data-i18n="apiKey.label">API key</label>
|
|
176
|
-
<input
|
|
177
|
-
id="api-key-input"
|
|
178
|
-
type="password"
|
|
179
|
-
placeholder="ck_..."
|
|
180
|
-
autocomplete="off"
|
|
181
|
-
spellcheck="false"
|
|
182
|
-
/>
|
|
183
|
-
<span id="api-key-status" class="status" data-i18n="apiKey.notSet">Not set</span>
|
|
184
|
-
<span class="hint" data-i18n="apiKey.hint">Generate one under Settings → API. Stored locally only.</span>
|
|
185
|
-
</div>
|
|
186
|
-
|
|
187
|
-
<div id="scalar-host">
|
|
188
|
-
<div class="loader">
|
|
189
|
-
<div class="spinner"></div>
|
|
190
|
-
<span data-i18n="loading">Loading API reference…</span>
|
|
191
|
-
</div>
|
|
192
|
-
</div>
|
|
193
|
-
|
|
194
|
-
<script>
|
|
195
|
-
// ── i18n: UI chrome only (the OpenAPI spec itself stays in English) ──
|
|
196
|
-
// OpenAPI specs are conventionally English (industry standard). The UI
|
|
197
|
-
// labels above DO change with the language picker — endpoint descriptions
|
|
198
|
-
// do not. Future work: x-translations extension on each operation.
|
|
199
|
-
const I18N = {
|
|
200
|
-
en: {
|
|
201
|
-
title: 'Pixcode API',
|
|
202
|
-
badge: 'v1.33',
|
|
203
|
-
downloadSpec: 'Download spec',
|
|
204
|
-
backToApp: 'Back to app',
|
|
205
|
-
'apiKey.label': 'API key',
|
|
206
|
-
'apiKey.notSet': 'Not set',
|
|
207
|
-
'apiKey.set': 'Saved',
|
|
208
|
-
'apiKey.hint': 'Generate one under Settings → API. Stored locally only.',
|
|
209
|
-
loading: 'Loading API reference…',
|
|
210
|
-
},
|
|
211
|
-
tr: {
|
|
212
|
-
title: 'Pixcode API',
|
|
213
|
-
badge: 'v1.33',
|
|
214
|
-
downloadSpec: 'Spec\'i indir',
|
|
215
|
-
backToApp: 'Uygulamaya dön',
|
|
216
|
-
'apiKey.label': 'API anahtarı',
|
|
217
|
-
'apiKey.notSet': 'Boş',
|
|
218
|
-
'apiKey.set': 'Kaydedildi',
|
|
219
|
-
'apiKey.hint': 'Ayarlar → API\'den oluşturun. Sadece bu cihazda saklanır.',
|
|
220
|
-
loading: 'API referansı yükleniyor…',
|
|
221
|
-
},
|
|
222
|
-
de: {
|
|
223
|
-
title: 'Pixcode API',
|
|
224
|
-
badge: 'v1.33',
|
|
225
|
-
downloadSpec: 'Spezifikation laden',
|
|
226
|
-
backToApp: 'Zurück zur App',
|
|
227
|
-
'apiKey.label': 'API-Schlüssel',
|
|
228
|
-
'apiKey.notSet': 'Nicht gesetzt',
|
|
229
|
-
'apiKey.set': 'Gespeichert',
|
|
230
|
-
'apiKey.hint': 'Unter Einstellungen → API erstellen. Nur lokal gespeichert.',
|
|
231
|
-
loading: 'API-Referenz wird geladen…',
|
|
232
|
-
},
|
|
233
|
-
it: {
|
|
234
|
-
title: 'Pixcode API',
|
|
235
|
-
badge: 'v1.33',
|
|
236
|
-
downloadSpec: 'Scarica specifica',
|
|
237
|
-
backToApp: "Torna all'app",
|
|
238
|
-
'apiKey.label': 'Chiave API',
|
|
239
|
-
'apiKey.notSet': 'Non impostata',
|
|
240
|
-
'apiKey.set': 'Salvata',
|
|
241
|
-
'apiKey.hint': 'Generala in Impostazioni → API. Memorizzata solo localmente.',
|
|
242
|
-
loading: 'Caricamento riferimento API…',
|
|
243
|
-
},
|
|
244
|
-
ja: {
|
|
245
|
-
title: 'Pixcode API',
|
|
246
|
-
badge: 'v1.33',
|
|
247
|
-
downloadSpec: '仕様をダウンロード',
|
|
248
|
-
backToApp: 'アプリに戻る',
|
|
249
|
-
'apiKey.label': 'API キー',
|
|
250
|
-
'apiKey.notSet': '未設定',
|
|
251
|
-
'apiKey.set': '保存済み',
|
|
252
|
-
'apiKey.hint': '設定 → API で生成してください。このデバイスのみに保存されます。',
|
|
253
|
-
loading: 'API リファレンスを読み込み中…',
|
|
254
|
-
},
|
|
255
|
-
ko: {
|
|
256
|
-
title: 'Pixcode API',
|
|
257
|
-
badge: 'v1.33',
|
|
258
|
-
downloadSpec: '스펙 다운로드',
|
|
259
|
-
backToApp: '앱으로 돌아가기',
|
|
260
|
-
'apiKey.label': 'API 키',
|
|
261
|
-
'apiKey.notSet': '미설정',
|
|
262
|
-
'apiKey.set': '저장됨',
|
|
263
|
-
'apiKey.hint': '설정 → API에서 생성하세요. 이 기기에만 저장됩니다.',
|
|
264
|
-
loading: 'API 참조 로드 중…',
|
|
265
|
-
},
|
|
266
|
-
ru: {
|
|
267
|
-
title: 'Pixcode API',
|
|
268
|
-
badge: 'v1.33',
|
|
269
|
-
downloadSpec: 'Скачать спецификацию',
|
|
270
|
-
backToApp: 'Вернуться в приложение',
|
|
271
|
-
'apiKey.label': 'API-ключ',
|
|
272
|
-
'apiKey.notSet': 'Не задан',
|
|
273
|
-
'apiKey.set': 'Сохранён',
|
|
274
|
-
'apiKey.hint': 'Создайте в Настройки → API. Хранится только локально.',
|
|
275
|
-
loading: 'Загрузка справочника API…',
|
|
276
|
-
},
|
|
277
|
-
'zh-CN': {
|
|
278
|
-
title: 'Pixcode API',
|
|
279
|
-
badge: 'v1.33',
|
|
280
|
-
downloadSpec: '下载规范',
|
|
281
|
-
backToApp: '返回应用',
|
|
282
|
-
'apiKey.label': 'API 密钥',
|
|
283
|
-
'apiKey.notSet': '未设置',
|
|
284
|
-
'apiKey.set': '已保存',
|
|
285
|
-
'apiKey.hint': '在 设置 → API 生成。仅本地存储。',
|
|
286
|
-
loading: '正在加载 API 参考…',
|
|
287
|
-
},
|
|
288
|
-
};
|
|
289
|
-
|
|
290
|
-
function detectLang() {
|
|
291
|
-
const stored = localStorage.getItem('pixcode-api-docs-lang');
|
|
292
|
-
if (stored && I18N[stored]) return stored;
|
|
293
|
-
const navLang = (navigator.language || 'en').toLowerCase();
|
|
294
|
-
if (navLang.startsWith('zh')) return 'zh-CN';
|
|
295
|
-
const short = navLang.split('-')[0];
|
|
296
|
-
return I18N[short] ? short : 'en';
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
function applyI18n(lang) {
|
|
300
|
-
const dict = I18N[lang] || I18N.en;
|
|
301
|
-
document.documentElement.lang = lang;
|
|
302
|
-
document.querySelectorAll('[data-i18n]').forEach((el) => {
|
|
303
|
-
const key = el.getAttribute('data-i18n');
|
|
304
|
-
if (dict[key]) el.textContent = dict[key];
|
|
305
|
-
});
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
// ── API key persistence + Scalar prefill ──────────────────────────
|
|
309
|
-
const apiKeyInput = document.getElementById('api-key-input');
|
|
310
|
-
const apiKeyStatus = document.getElementById('api-key-status');
|
|
311
|
-
const STORAGE_KEY = 'pixcode-api-docs-key';
|
|
312
|
-
|
|
313
|
-
function setStatus(set) {
|
|
314
|
-
const lang = document.documentElement.lang || 'en';
|
|
315
|
-
const dict = I18N[lang] || I18N.en;
|
|
316
|
-
apiKeyStatus.textContent = set ? dict['apiKey.set'] : dict['apiKey.notSet'];
|
|
317
|
-
apiKeyStatus.classList.toggle('ok', set);
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
// Restore on load.
|
|
321
|
-
const savedKey = localStorage.getItem(STORAGE_KEY) || '';
|
|
322
|
-
if (savedKey) {
|
|
323
|
-
apiKeyInput.value = savedKey;
|
|
324
|
-
setStatus(true);
|
|
325
|
-
} else {
|
|
326
|
-
setStatus(false);
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
apiKeyInput.addEventListener('input', () => {
|
|
330
|
-
const v = apiKeyInput.value.trim();
|
|
331
|
-
if (v) {
|
|
332
|
-
localStorage.setItem(STORAGE_KEY, v);
|
|
333
|
-
setStatus(true);
|
|
334
|
-
} else {
|
|
335
|
-
localStorage.removeItem(STORAGE_KEY);
|
|
336
|
-
setStatus(false);
|
|
337
|
-
}
|
|
338
|
-
// Re-render Scalar so the new key is prefilled in "Try it" panels.
|
|
339
|
-
renderScalar();
|
|
340
|
-
});
|
|
341
|
-
|
|
342
|
-
// ── Language picker ───────────────────────────────────────────────
|
|
343
|
-
const langSelect = document.getElementById('lang-select');
|
|
344
|
-
langSelect.value = detectLang();
|
|
345
|
-
applyI18n(langSelect.value);
|
|
346
|
-
langSelect.addEventListener('change', () => {
|
|
347
|
-
localStorage.setItem('pixcode-api-docs-lang', langSelect.value);
|
|
348
|
-
applyI18n(langSelect.value);
|
|
349
|
-
setStatus(Boolean(localStorage.getItem(STORAGE_KEY)));
|
|
350
|
-
});
|
|
351
|
-
|
|
352
|
-
// ── Scalar mount ──────────────────────────────────────────────────
|
|
353
|
-
// Scalar API Reference: lightweight, modern, mobile-friendly, built-in
|
|
354
|
-
// try-it panel with auth header support. Loaded from CDN as a single
|
|
355
|
-
// global; no build step required.
|
|
356
|
-
function getCurrentApiKey() {
|
|
357
|
-
return apiKeyInput.value.trim();
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
function renderScalar() {
|
|
361
|
-
if (!window.Scalar || typeof window.Scalar.createApiReference !== 'function') return;
|
|
362
|
-
const host = document.getElementById('scalar-host');
|
|
363
|
-
host.innerHTML = '';
|
|
364
|
-
window.Scalar.createApiReference(host, {
|
|
365
|
-
url: '/openapi.yaml',
|
|
366
|
-
theme: 'default',
|
|
367
|
-
darkMode: window.matchMedia('(prefers-color-scheme: dark)').matches,
|
|
368
|
-
hideClientButton: true,
|
|
369
|
-
hideDarkModeToggle: false,
|
|
370
|
-
authentication: getCurrentApiKey()
|
|
371
|
-
? {
|
|
372
|
-
preferredSecurityScheme: 'bearerAuth',
|
|
373
|
-
http: { bearer: { token: getCurrentApiKey() } },
|
|
374
|
-
}
|
|
375
|
-
: undefined,
|
|
376
|
-
defaultHttpClient: { targetKey: 'shell', clientKey: 'curl' },
|
|
377
|
-
// Pixcode's app shell uses absolute /api paths against the same host;
|
|
378
|
-
// Scalar's "Try it" sends to the OpenAPI `servers[0]`. We override to
|
|
379
|
-
// the document origin so the user doesn't need to pick a server.
|
|
380
|
-
servers: [{ url: window.location.origin }],
|
|
381
|
-
});
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
const scalarScript = document.createElement('script');
|
|
385
|
-
scalarScript.src = 'https://cdn.jsdelivr.net/npm/@scalar/api-reference@1';
|
|
386
|
-
scalarScript.onload = renderScalar;
|
|
387
|
-
scalarScript.onerror = () => {
|
|
388
|
-
document.getElementById('scalar-host').innerHTML =
|
|
389
|
-
'<div class="loader"><span>⚠ Scalar CDN unreachable. <a href="/openapi.yaml" style="color:var(--primary)">Download the OpenAPI spec</a> and load it in your own viewer.</span></div>';
|
|
390
|
-
};
|
|
391
|
-
document.head.appendChild(scalarScript);
|
|
392
|
-
</script>
|
|
393
|
-
|
|
394
|
-
</body>
|
|
395
|
-
</html>
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
|
|
6
|
+
<title>Pixcode — API Documentation</title>
|
|
7
|
+
<meta name="description" content="REST API reference for Pixcode — the multi-CLI web UI for Claude Code, Cursor, Codex, Gemini, Qwen, and OpenCode." />
|
|
8
|
+
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
|
9
|
+
<link rel="icon" type="image/png" href="/favicon.png" />
|
|
10
|
+
<style>
|
|
11
|
+
:root {
|
|
12
|
+
--bg: #0b0d10;
|
|
13
|
+
--bg-soft: #11151b;
|
|
14
|
+
--bg-card: #161b22;
|
|
15
|
+
--border: #232a33;
|
|
16
|
+
--fg: #e6edf3;
|
|
17
|
+
--fg-muted: #8b949e;
|
|
18
|
+
--primary: #2563eb;
|
|
19
|
+
--primary-hover: #1d4ed8;
|
|
20
|
+
--accent: #10b981;
|
|
21
|
+
--warn: #f59e0b;
|
|
22
|
+
}
|
|
23
|
+
@media (prefers-color-scheme: light) {
|
|
24
|
+
:root {
|
|
25
|
+
--bg: #ffffff;
|
|
26
|
+
--bg-soft: #f6f8fa;
|
|
27
|
+
--bg-card: #ffffff;
|
|
28
|
+
--border: #d0d7de;
|
|
29
|
+
--fg: #1f2328;
|
|
30
|
+
--fg-muted: #656d76;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
* { box-sizing: border-box; }
|
|
35
|
+
html, body { margin: 0; padding: 0; }
|
|
36
|
+
body {
|
|
37
|
+
background: var(--bg);
|
|
38
|
+
color: var(--fg);
|
|
39
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Inter, sans-serif;
|
|
40
|
+
min-height: 100vh;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/* ── Top bar ─────────────────────────────────────────────────── */
|
|
44
|
+
.topbar {
|
|
45
|
+
position: sticky; top: 0; z-index: 50;
|
|
46
|
+
display: flex; align-items: center; gap: 12px;
|
|
47
|
+
padding: 10px 16px;
|
|
48
|
+
background: var(--bg-soft);
|
|
49
|
+
border-bottom: 1px solid var(--border);
|
|
50
|
+
backdrop-filter: blur(8px);
|
|
51
|
+
}
|
|
52
|
+
.topbar-brand {
|
|
53
|
+
display: flex; align-items: center; gap: 10px;
|
|
54
|
+
font-weight: 700; font-size: 15px; letter-spacing: -0.01em;
|
|
55
|
+
color: var(--fg); text-decoration: none;
|
|
56
|
+
}
|
|
57
|
+
.topbar-brand img { width: 24px; height: 24px; border-radius: 6px; }
|
|
58
|
+
.topbar-brand .badge {
|
|
59
|
+
font-size: 10px; font-weight: 600;
|
|
60
|
+
padding: 2px 6px; border-radius: 4px;
|
|
61
|
+
background: var(--primary); color: white;
|
|
62
|
+
letter-spacing: 0.04em; text-transform: uppercase;
|
|
63
|
+
}
|
|
64
|
+
.topbar-spacer { flex: 1; }
|
|
65
|
+
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
|
|
66
|
+
.topbar select, .topbar a.btn, .topbar button.btn {
|
|
67
|
+
height: 32px;
|
|
68
|
+
padding: 0 12px;
|
|
69
|
+
border-radius: 6px;
|
|
70
|
+
border: 1px solid var(--border);
|
|
71
|
+
background: var(--bg-card);
|
|
72
|
+
color: var(--fg);
|
|
73
|
+
font-size: 13px;
|
|
74
|
+
cursor: pointer;
|
|
75
|
+
text-decoration: none;
|
|
76
|
+
display: inline-flex; align-items: center; gap: 6px;
|
|
77
|
+
}
|
|
78
|
+
.topbar a.btn:hover, .topbar button.btn:hover { border-color: var(--primary); }
|
|
79
|
+
.topbar a.btn.primary, .topbar button.btn.primary {
|
|
80
|
+
background: var(--primary); border-color: var(--primary); color: white;
|
|
81
|
+
}
|
|
82
|
+
.topbar a.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
|
|
83
|
+
|
|
84
|
+
/* ── API key bar ──────────────────────────────────────────────── */
|
|
85
|
+
.apikey-bar {
|
|
86
|
+
display: flex; align-items: center; gap: 10px;
|
|
87
|
+
padding: 10px 16px;
|
|
88
|
+
background: var(--bg-card);
|
|
89
|
+
border-bottom: 1px solid var(--border);
|
|
90
|
+
flex-wrap: wrap;
|
|
91
|
+
}
|
|
92
|
+
.apikey-bar label {
|
|
93
|
+
font-size: 12px; font-weight: 600; color: var(--fg-muted);
|
|
94
|
+
letter-spacing: 0.02em; text-transform: uppercase;
|
|
95
|
+
}
|
|
96
|
+
.apikey-bar input {
|
|
97
|
+
flex: 1; min-width: 220px;
|
|
98
|
+
height: 34px; padding: 0 12px;
|
|
99
|
+
background: var(--bg-soft);
|
|
100
|
+
border: 1px solid var(--border);
|
|
101
|
+
border-radius: 6px;
|
|
102
|
+
color: var(--fg);
|
|
103
|
+
font-family: 'SF Mono', ui-monospace, monospace;
|
|
104
|
+
font-size: 13px;
|
|
105
|
+
}
|
|
106
|
+
.apikey-bar input:focus { outline: none; border-color: var(--primary); }
|
|
107
|
+
.apikey-bar .hint { font-size: 12px; color: var(--fg-muted); }
|
|
108
|
+
.apikey-bar .status {
|
|
109
|
+
font-size: 11px; padding: 3px 8px; border-radius: 999px;
|
|
110
|
+
background: var(--bg-soft); color: var(--fg-muted);
|
|
111
|
+
border: 1px solid var(--border);
|
|
112
|
+
}
|
|
113
|
+
.apikey-bar .status.ok { color: var(--accent); border-color: var(--accent); }
|
|
114
|
+
|
|
115
|
+
/* ── Scalar host ──────────────────────────────────────────────── */
|
|
116
|
+
#scalar-host { min-height: calc(100vh - 130px); }
|
|
117
|
+
|
|
118
|
+
/* ── Mobile tweaks ────────────────────────────────────────────── */
|
|
119
|
+
@media (max-width: 640px) {
|
|
120
|
+
.topbar { padding: 8px 10px; gap: 8px; }
|
|
121
|
+
.topbar-brand .subtitle { display: none; }
|
|
122
|
+
.topbar-actions a.btn span:not(.icon) { display: none; }
|
|
123
|
+
.apikey-bar { padding: 8px 10px; }
|
|
124
|
+
.apikey-bar .hint { display: none; }
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/* ── Loading state ────────────────────────────────────────────── */
|
|
128
|
+
.loader {
|
|
129
|
+
display: flex; align-items: center; justify-content: center;
|
|
130
|
+
height: calc(100vh - 130px);
|
|
131
|
+
color: var(--fg-muted);
|
|
132
|
+
font-size: 14px;
|
|
133
|
+
gap: 10px;
|
|
134
|
+
}
|
|
135
|
+
.loader .spinner {
|
|
136
|
+
width: 18px; height: 18px;
|
|
137
|
+
border: 2px solid var(--border);
|
|
138
|
+
border-top-color: var(--primary);
|
|
139
|
+
border-radius: 50%;
|
|
140
|
+
animation: spin 0.8s linear infinite;
|
|
141
|
+
}
|
|
142
|
+
@keyframes spin { to { transform: rotate(360deg); } }
|
|
143
|
+
</style>
|
|
144
|
+
</head>
|
|
145
|
+
<body>
|
|
146
|
+
|
|
147
|
+
<header class="topbar">
|
|
148
|
+
<a href="/" class="topbar-brand">
|
|
149
|
+
<img src="/logo.svg" alt="Pixcode" />
|
|
150
|
+
<span data-i18n="title">Pixcode API</span>
|
|
151
|
+
<span class="badge" data-i18n="badge">v1.33</span>
|
|
152
|
+
</a>
|
|
153
|
+
<div class="topbar-spacer"></div>
|
|
154
|
+
<div class="topbar-actions">
|
|
155
|
+
<select id="lang-select" aria-label="Language" title="Language">
|
|
156
|
+
<option value="en">English</option>
|
|
157
|
+
<option value="tr">Türkçe</option>
|
|
158
|
+
<option value="de">Deutsch</option>
|
|
159
|
+
<option value="it">Italiano</option>
|
|
160
|
+
<option value="ja">日本語</option>
|
|
161
|
+
<option value="ko">한국어</option>
|
|
162
|
+
<option value="ru">Русский</option>
|
|
163
|
+
<option value="zh-CN">中文</option>
|
|
164
|
+
</select>
|
|
165
|
+
<a href="/openapi.yaml" class="btn" download>
|
|
166
|
+
<span class="icon" aria-hidden="true">⬇</span><span data-i18n="downloadSpec">Download spec</span>
|
|
167
|
+
</a>
|
|
168
|
+
<a href="/" class="btn primary">
|
|
169
|
+
<span class="icon" aria-hidden="true">←</span><span data-i18n="backToApp">Back to app</span>
|
|
170
|
+
</a>
|
|
171
|
+
</div>
|
|
172
|
+
</header>
|
|
173
|
+
|
|
174
|
+
<div class="apikey-bar">
|
|
175
|
+
<label for="api-key-input" data-i18n="apiKey.label">API key</label>
|
|
176
|
+
<input
|
|
177
|
+
id="api-key-input"
|
|
178
|
+
type="password"
|
|
179
|
+
placeholder="ck_..."
|
|
180
|
+
autocomplete="off"
|
|
181
|
+
spellcheck="false"
|
|
182
|
+
/>
|
|
183
|
+
<span id="api-key-status" class="status" data-i18n="apiKey.notSet">Not set</span>
|
|
184
|
+
<span class="hint" data-i18n="apiKey.hint">Generate one under Settings → API. Stored locally only.</span>
|
|
185
|
+
</div>
|
|
186
|
+
|
|
187
|
+
<div id="scalar-host">
|
|
188
|
+
<div class="loader">
|
|
189
|
+
<div class="spinner"></div>
|
|
190
|
+
<span data-i18n="loading">Loading API reference…</span>
|
|
191
|
+
</div>
|
|
192
|
+
</div>
|
|
193
|
+
|
|
194
|
+
<script>
|
|
195
|
+
// ── i18n: UI chrome only (the OpenAPI spec itself stays in English) ──
|
|
196
|
+
// OpenAPI specs are conventionally English (industry standard). The UI
|
|
197
|
+
// labels above DO change with the language picker — endpoint descriptions
|
|
198
|
+
// do not. Future work: x-translations extension on each operation.
|
|
199
|
+
const I18N = {
|
|
200
|
+
en: {
|
|
201
|
+
title: 'Pixcode API',
|
|
202
|
+
badge: 'v1.33',
|
|
203
|
+
downloadSpec: 'Download spec',
|
|
204
|
+
backToApp: 'Back to app',
|
|
205
|
+
'apiKey.label': 'API key',
|
|
206
|
+
'apiKey.notSet': 'Not set',
|
|
207
|
+
'apiKey.set': 'Saved',
|
|
208
|
+
'apiKey.hint': 'Generate one under Settings → API. Stored locally only.',
|
|
209
|
+
loading: 'Loading API reference…',
|
|
210
|
+
},
|
|
211
|
+
tr: {
|
|
212
|
+
title: 'Pixcode API',
|
|
213
|
+
badge: 'v1.33',
|
|
214
|
+
downloadSpec: 'Spec\'i indir',
|
|
215
|
+
backToApp: 'Uygulamaya dön',
|
|
216
|
+
'apiKey.label': 'API anahtarı',
|
|
217
|
+
'apiKey.notSet': 'Boş',
|
|
218
|
+
'apiKey.set': 'Kaydedildi',
|
|
219
|
+
'apiKey.hint': 'Ayarlar → API\'den oluşturun. Sadece bu cihazda saklanır.',
|
|
220
|
+
loading: 'API referansı yükleniyor…',
|
|
221
|
+
},
|
|
222
|
+
de: {
|
|
223
|
+
title: 'Pixcode API',
|
|
224
|
+
badge: 'v1.33',
|
|
225
|
+
downloadSpec: 'Spezifikation laden',
|
|
226
|
+
backToApp: 'Zurück zur App',
|
|
227
|
+
'apiKey.label': 'API-Schlüssel',
|
|
228
|
+
'apiKey.notSet': 'Nicht gesetzt',
|
|
229
|
+
'apiKey.set': 'Gespeichert',
|
|
230
|
+
'apiKey.hint': 'Unter Einstellungen → API erstellen. Nur lokal gespeichert.',
|
|
231
|
+
loading: 'API-Referenz wird geladen…',
|
|
232
|
+
},
|
|
233
|
+
it: {
|
|
234
|
+
title: 'Pixcode API',
|
|
235
|
+
badge: 'v1.33',
|
|
236
|
+
downloadSpec: 'Scarica specifica',
|
|
237
|
+
backToApp: "Torna all'app",
|
|
238
|
+
'apiKey.label': 'Chiave API',
|
|
239
|
+
'apiKey.notSet': 'Non impostata',
|
|
240
|
+
'apiKey.set': 'Salvata',
|
|
241
|
+
'apiKey.hint': 'Generala in Impostazioni → API. Memorizzata solo localmente.',
|
|
242
|
+
loading: 'Caricamento riferimento API…',
|
|
243
|
+
},
|
|
244
|
+
ja: {
|
|
245
|
+
title: 'Pixcode API',
|
|
246
|
+
badge: 'v1.33',
|
|
247
|
+
downloadSpec: '仕様をダウンロード',
|
|
248
|
+
backToApp: 'アプリに戻る',
|
|
249
|
+
'apiKey.label': 'API キー',
|
|
250
|
+
'apiKey.notSet': '未設定',
|
|
251
|
+
'apiKey.set': '保存済み',
|
|
252
|
+
'apiKey.hint': '設定 → API で生成してください。このデバイスのみに保存されます。',
|
|
253
|
+
loading: 'API リファレンスを読み込み中…',
|
|
254
|
+
},
|
|
255
|
+
ko: {
|
|
256
|
+
title: 'Pixcode API',
|
|
257
|
+
badge: 'v1.33',
|
|
258
|
+
downloadSpec: '스펙 다운로드',
|
|
259
|
+
backToApp: '앱으로 돌아가기',
|
|
260
|
+
'apiKey.label': 'API 키',
|
|
261
|
+
'apiKey.notSet': '미설정',
|
|
262
|
+
'apiKey.set': '저장됨',
|
|
263
|
+
'apiKey.hint': '설정 → API에서 생성하세요. 이 기기에만 저장됩니다.',
|
|
264
|
+
loading: 'API 참조 로드 중…',
|
|
265
|
+
},
|
|
266
|
+
ru: {
|
|
267
|
+
title: 'Pixcode API',
|
|
268
|
+
badge: 'v1.33',
|
|
269
|
+
downloadSpec: 'Скачать спецификацию',
|
|
270
|
+
backToApp: 'Вернуться в приложение',
|
|
271
|
+
'apiKey.label': 'API-ключ',
|
|
272
|
+
'apiKey.notSet': 'Не задан',
|
|
273
|
+
'apiKey.set': 'Сохранён',
|
|
274
|
+
'apiKey.hint': 'Создайте в Настройки → API. Хранится только локально.',
|
|
275
|
+
loading: 'Загрузка справочника API…',
|
|
276
|
+
},
|
|
277
|
+
'zh-CN': {
|
|
278
|
+
title: 'Pixcode API',
|
|
279
|
+
badge: 'v1.33',
|
|
280
|
+
downloadSpec: '下载规范',
|
|
281
|
+
backToApp: '返回应用',
|
|
282
|
+
'apiKey.label': 'API 密钥',
|
|
283
|
+
'apiKey.notSet': '未设置',
|
|
284
|
+
'apiKey.set': '已保存',
|
|
285
|
+
'apiKey.hint': '在 设置 → API 生成。仅本地存储。',
|
|
286
|
+
loading: '正在加载 API 参考…',
|
|
287
|
+
},
|
|
288
|
+
};
|
|
289
|
+
|
|
290
|
+
function detectLang() {
|
|
291
|
+
const stored = localStorage.getItem('pixcode-api-docs-lang');
|
|
292
|
+
if (stored && I18N[stored]) return stored;
|
|
293
|
+
const navLang = (navigator.language || 'en').toLowerCase();
|
|
294
|
+
if (navLang.startsWith('zh')) return 'zh-CN';
|
|
295
|
+
const short = navLang.split('-')[0];
|
|
296
|
+
return I18N[short] ? short : 'en';
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
function applyI18n(lang) {
|
|
300
|
+
const dict = I18N[lang] || I18N.en;
|
|
301
|
+
document.documentElement.lang = lang;
|
|
302
|
+
document.querySelectorAll('[data-i18n]').forEach((el) => {
|
|
303
|
+
const key = el.getAttribute('data-i18n');
|
|
304
|
+
if (dict[key]) el.textContent = dict[key];
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
// ── API key persistence + Scalar prefill ──────────────────────────
|
|
309
|
+
const apiKeyInput = document.getElementById('api-key-input');
|
|
310
|
+
const apiKeyStatus = document.getElementById('api-key-status');
|
|
311
|
+
const STORAGE_KEY = 'pixcode-api-docs-key';
|
|
312
|
+
|
|
313
|
+
function setStatus(set) {
|
|
314
|
+
const lang = document.documentElement.lang || 'en';
|
|
315
|
+
const dict = I18N[lang] || I18N.en;
|
|
316
|
+
apiKeyStatus.textContent = set ? dict['apiKey.set'] : dict['apiKey.notSet'];
|
|
317
|
+
apiKeyStatus.classList.toggle('ok', set);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
// Restore on load.
|
|
321
|
+
const savedKey = localStorage.getItem(STORAGE_KEY) || '';
|
|
322
|
+
if (savedKey) {
|
|
323
|
+
apiKeyInput.value = savedKey;
|
|
324
|
+
setStatus(true);
|
|
325
|
+
} else {
|
|
326
|
+
setStatus(false);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
apiKeyInput.addEventListener('input', () => {
|
|
330
|
+
const v = apiKeyInput.value.trim();
|
|
331
|
+
if (v) {
|
|
332
|
+
localStorage.setItem(STORAGE_KEY, v);
|
|
333
|
+
setStatus(true);
|
|
334
|
+
} else {
|
|
335
|
+
localStorage.removeItem(STORAGE_KEY);
|
|
336
|
+
setStatus(false);
|
|
337
|
+
}
|
|
338
|
+
// Re-render Scalar so the new key is prefilled in "Try it" panels.
|
|
339
|
+
renderScalar();
|
|
340
|
+
});
|
|
341
|
+
|
|
342
|
+
// ── Language picker ───────────────────────────────────────────────
|
|
343
|
+
const langSelect = document.getElementById('lang-select');
|
|
344
|
+
langSelect.value = detectLang();
|
|
345
|
+
applyI18n(langSelect.value);
|
|
346
|
+
langSelect.addEventListener('change', () => {
|
|
347
|
+
localStorage.setItem('pixcode-api-docs-lang', langSelect.value);
|
|
348
|
+
applyI18n(langSelect.value);
|
|
349
|
+
setStatus(Boolean(localStorage.getItem(STORAGE_KEY)));
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
// ── Scalar mount ──────────────────────────────────────────────────
|
|
353
|
+
// Scalar API Reference: lightweight, modern, mobile-friendly, built-in
|
|
354
|
+
// try-it panel with auth header support. Loaded from CDN as a single
|
|
355
|
+
// global; no build step required.
|
|
356
|
+
function getCurrentApiKey() {
|
|
357
|
+
return apiKeyInput.value.trim();
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
function renderScalar() {
|
|
361
|
+
if (!window.Scalar || typeof window.Scalar.createApiReference !== 'function') return;
|
|
362
|
+
const host = document.getElementById('scalar-host');
|
|
363
|
+
host.innerHTML = '';
|
|
364
|
+
window.Scalar.createApiReference(host, {
|
|
365
|
+
url: '/openapi.yaml',
|
|
366
|
+
theme: 'default',
|
|
367
|
+
darkMode: window.matchMedia('(prefers-color-scheme: dark)').matches,
|
|
368
|
+
hideClientButton: true,
|
|
369
|
+
hideDarkModeToggle: false,
|
|
370
|
+
authentication: getCurrentApiKey()
|
|
371
|
+
? {
|
|
372
|
+
preferredSecurityScheme: 'bearerAuth',
|
|
373
|
+
http: { bearer: { token: getCurrentApiKey() } },
|
|
374
|
+
}
|
|
375
|
+
: undefined,
|
|
376
|
+
defaultHttpClient: { targetKey: 'shell', clientKey: 'curl' },
|
|
377
|
+
// Pixcode's app shell uses absolute /api paths against the same host;
|
|
378
|
+
// Scalar's "Try it" sends to the OpenAPI `servers[0]`. We override to
|
|
379
|
+
// the document origin so the user doesn't need to pick a server.
|
|
380
|
+
servers: [{ url: window.location.origin }],
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
const scalarScript = document.createElement('script');
|
|
385
|
+
scalarScript.src = 'https://cdn.jsdelivr.net/npm/@scalar/api-reference@1';
|
|
386
|
+
scalarScript.onload = renderScalar;
|
|
387
|
+
scalarScript.onerror = () => {
|
|
388
|
+
document.getElementById('scalar-host').innerHTML =
|
|
389
|
+
'<div class="loader"><span>⚠ Scalar CDN unreachable. <a href="/openapi.yaml" style="color:var(--primary)">Download the OpenAPI spec</a> and load it in your own viewer.</span></div>';
|
|
390
|
+
};
|
|
391
|
+
document.head.appendChild(scalarScript);
|
|
392
|
+
</script>
|
|
393
|
+
|
|
394
|
+
</body>
|
|
395
|
+
</html>
|