dsh-remote-plugin 0.8.1 → 0.8.3
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 +1 -1
- package/apk/dsh-remote.apk +0 -0
- package/cordis.patch.yml +2 -1
- package/gateway.cjs +323 -64
- package/index.mjs +2 -2
- package/insights.mjs +5 -3
- package/market.mjs +4 -1
- package/package.json +1 -1
- package/plugin-center.mjs +120 -7
- package/plugin-transaction.mjs +10 -3
- package/public/admin.html +19 -14
- package/public/admin.js +71 -23
- package/public/announcements.json +192 -0
- package/public/app.js +192 -60
- package/public/build.json +2 -2
- package/public/chat-copy.js +46 -0
- package/public/desktop/desktop.css +10 -0
- package/public/desktop/desktop.html +28 -15
- package/public/desktop/desktop.js +74 -22
- package/public/diagnostics.js +115 -21
- package/public/history.js +45 -9
- package/public/image-cache.js +141 -0
- package/public/image-preview.js +48 -5
- package/public/index.html +39 -34
- package/public/lan-discovery.js +94 -0
- package/public/md.js +8 -2
- package/public/plugin-center.js +1 -1
- package/public/plugin.html +8 -2
- package/public/relay-settings.js +7 -6
- package/public/skins/blue-fish/DESIGN.md +24 -0
- package/public/skins/blue-fish/preview.html +11 -289
- package/public/skins/blue-fish/skin.css +95 -585
- package/public/skins/blue-fish/sparkles.svg +18 -0
- package/public/skins/bocchi/DESIGN.md +99 -0
- package/public/skins/bocchi/face.png +0 -0
- package/public/skins/bocchi/grain.png +0 -0
- package/public/skins/bocchi/icon-blush.png +0 -0
- package/public/skins/bocchi/icon-sleep.png +0 -0
- package/public/skins/bocchi/icon-smile.png +0 -0
- package/public/skins/bocchi/icon-star.png +0 -0
- package/public/skins/bocchi/icon-wink.png +0 -0
- package/public/skins/bocchi/icon.png +0 -0
- package/public/skins/bocchi/pattern-soft.png +0 -0
- package/public/skins/bocchi/pattern.png +0 -0
- package/public/skins/bocchi/preview.html +54 -0
- package/public/skins/bocchi/skin.css +233 -0
- package/public/skins/bocchi/stage-bg.png +0 -0
- package/public/skins/bocchi/stage-soft.png +0 -0
- package/public/skins/bocchi/stand.png +0 -0
- package/public/skins/bocchi/sticker-guitar.png +0 -0
- package/public/skins/kessoku/DESIGN.md +38 -0
- package/public/skins/kessoku/grain.png +0 -0
- package/public/skins/kessoku/skin.css +212 -0
- package/public/skins/kita/SOURCES.json +51 -0
- package/public/skins/kita/face.png +0 -0
- package/public/skins/kita/icon-live.png +0 -0
- package/public/skins/kita/icon-reddress.png +0 -0
- package/public/skins/kita/icon-seifuku.png +0 -0
- package/public/skins/kita/pattern.png +0 -0
- package/public/skins/kita/preview.html +55 -0
- package/public/skins/kita/skin.css +26 -0
- package/public/skins/kita/stand.png +0 -0
- package/public/skins/kita/sticker-live.png +0 -0
- package/public/skins/nijika/SOURCES.json +51 -0
- package/public/skins/nijika/face.png +0 -0
- package/public/skins/nijika/icon-live.png +0 -0
- package/public/skins/nijika/icon-reddress.png +0 -0
- package/public/skins/nijika/icon-seifuku.png +0 -0
- package/public/skins/nijika/pattern.png +0 -0
- package/public/skins/nijika/preview.html +55 -0
- package/public/skins/nijika/skin.css +25 -0
- package/public/skins/nijika/stand.png +0 -0
- package/public/skins/nijika/sticker-live.png +0 -0
- package/public/skins/penguin/DESIGN.md +33 -0
- package/public/skins/penguin/SOURCES.json +22 -0
- package/public/skins/penguin/aic-blueprint.svg +24 -0
- package/public/skins/penguin/endfield-triangles.svg +4 -0
- package/public/skins/penguin/face.png +0 -0
- package/public/skins/penguin/icon-blush.png +0 -0
- package/public/skins/penguin/icon-dizzy.png +0 -0
- package/public/skins/penguin/icon-laugh.png +0 -0
- package/public/skins/penguin/icon-sleep.png +0 -0
- package/public/skins/penguin/icon-smile.png +0 -0
- package/public/skins/penguin/icon-star.png +0 -0
- package/public/skins/penguin/icon-wink.png +0 -0
- package/public/skins/penguin/icon.png +0 -0
- package/public/skins/penguin/mascot.png +0 -0
- package/public/skins/penguin/pattern-night.png +0 -0
- package/public/skins/penguin/pattern.png +0 -0
- package/public/skins/penguin/preview.html +11 -0
- package/public/skins/penguin/skin.css +212 -0
- package/public/skins/ryo/SOURCES.json +51 -0
- package/public/skins/ryo/face.png +0 -0
- package/public/skins/ryo/icon-live.png +0 -0
- package/public/skins/ryo/icon-reddress.png +0 -0
- package/public/skins/ryo/icon-seifuku.png +0 -0
- package/public/skins/ryo/pattern.png +0 -0
- package/public/skins/ryo/preview.html +55 -0
- package/public/skins/ryo/skin.css +25 -0
- package/public/skins/ryo/stand.png +0 -0
- package/public/skins/ryo/sticker-live.png +0 -0
- package/public/sponsor-entry.js +22 -0
- package/public/styles.css +13 -0
- package/public/theme-picker.css +58 -0
- package/public/theme-vars.css +532 -5
- package/public/theme.js +111 -3
- package/public/update.json +12 -12
- package/public/version.json +1 -1
- package/public/workflow.css +2 -1
- package/public/workflow.js +24 -1
- package/skills/dsh-remote-doctor/references/wiki/notifications.md +4 -0
package/index.mjs
CHANGED
|
@@ -1415,10 +1415,10 @@ async function serveStatic(req, res, ctx) {
|
|
|
1415
1415
|
[`${MOUNT}/admin/api/device-keys/rotate`, '/device-keys/rotate'],
|
|
1416
1416
|
[`${MOUNT}/admin/api/device-keys/revoke`, '/device-keys/revoke'],
|
|
1417
1417
|
])
|
|
1418
|
-
if (pathname === `${MOUNT}/admin/api/relay` || pathname === `${MOUNT}/admin/api/autostart`) {
|
|
1418
|
+
if (pathname === `${MOUNT}/admin/api/relay` || pathname === `${MOUNT}/admin/api/autostart` || pathname === `${MOUNT}/admin/api/lan`) {
|
|
1419
1419
|
if (!['GET', 'POST'].includes(req.method)) { res.writeHead(405, { allow: 'GET, POST' }); res.end(); return }
|
|
1420
1420
|
const body = req.method === 'POST' ? await readBody(req, 4096) : undefined
|
|
1421
|
-
const proxied = await proxyGateway(
|
|
1421
|
+
const proxied = await proxyGateway('/admin/api/' + pathname.split('/').pop(), req.method, body)
|
|
1422
1422
|
sendJson(res, proxied?.status || 502, proxied?.json || { error: 'GATEWAY_UNAVAILABLE' })
|
|
1423
1423
|
return
|
|
1424
1424
|
}
|
package/insights.mjs
CHANGED
|
@@ -98,9 +98,11 @@ export async function readCostInsights(ctx, sessionId = '') {
|
|
|
98
98
|
cache.value = value; cache.at = Date.now(); return value
|
|
99
99
|
}).finally(() => { cache.task = null })
|
|
100
100
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
101
|
+
// Independent reads share one wait window; serial 20s waits can exceed both
|
|
102
|
+
// the gateway's 30s and the insights client's 25s request budgets.
|
|
103
|
+
const [raw, session] = await Promise.all([cache.task || cache.value,
|
|
104
|
+
sessionId && typeof service.getSessionCost === 'function'
|
|
105
|
+
? bounded(Promise.resolve().then(() => service.getSessionCost(sessionId))) : null])
|
|
104
106
|
return { status: 200, body: { ok: true, ...summarizeCost(raw, session, sessionId) } }
|
|
105
107
|
} catch {
|
|
106
108
|
// Plugin failures may mention credentials, URLs or paths. Return a fixed code.
|
package/market.mjs
CHANGED
|
@@ -42,13 +42,16 @@ export function createMarketAdapter(ctx, { timeoutMs = 20000 } = {}) {
|
|
|
42
42
|
async function search(url, query) {
|
|
43
43
|
const empty = { ok: true, available: false, source: 'official', items: [], total: 0, nextOffset: null }
|
|
44
44
|
if (!validQuery(query)) return { ...empty, ok: false, code: 'invalid-query' }
|
|
45
|
+
const deadline = Date.now() + timeoutMs
|
|
45
46
|
const state = await indexes()
|
|
46
47
|
if (!state.available) return { ...empty, code: state.code }
|
|
47
48
|
const index = url ? state.indexes.find(row => row.url === url) : state.indexes.find(row => !row.code)
|
|
48
49
|
if (!index) return { ...empty, code: state.indexes.length ? 'unknown-index' : 'no-indexes' }
|
|
49
50
|
if (index.code) return { ...empty, code: 'index-unavailable' }
|
|
50
51
|
try {
|
|
51
|
-
const
|
|
52
|
+
const remaining = deadline - Date.now()
|
|
53
|
+
if (remaining <= 0) return { ...empty, code: 'market-unavailable' }
|
|
54
|
+
const result = await bounded(Promise.resolve().then(() => service().search(index.url, query)), remaining)
|
|
52
55
|
if (!Array.isArray(result.entries)) throw Error('invalid response')
|
|
53
56
|
const categories = Object.entries(result.metadata?.categories || {}).slice(0, 100).map(([id, row]) => ({ id: text(id, 100), title: localized(row.title) }))
|
|
54
57
|
const items = result.entries.slice(0, query.limit).filter(row => packageName.test(row.name)).map(row => {
|
package/package.json
CHANGED
package/plugin-center.mjs
CHANGED
|
@@ -174,12 +174,12 @@ export function detectProfile(ctx, cli = process.argv[1], runtime = process) {
|
|
|
174
174
|
|
|
175
175
|
async function registryJson(path, signal = AbortSignal.timeout(20000)) {
|
|
176
176
|
const response = await fetch(REGISTRY + path, { signal, redirect: 'error' })
|
|
177
|
-
if (!response.ok) throw fail('npm registry: HTTP ' + response.status, 502)
|
|
177
|
+
if (!response.ok) { await response.body?.cancel(); throw fail('npm registry ' + path + ': HTTP ' + response.status, 502) }
|
|
178
178
|
let raw = '', bytes = 0
|
|
179
179
|
const decoder = new TextDecoder()
|
|
180
180
|
for await (const chunk of response.body) {
|
|
181
181
|
bytes += chunk.length
|
|
182
|
-
if (bytes > 8 * 1024 * 1024) throw fail('Registry response too large', 502)
|
|
182
|
+
if (bytes > 8 * 1024 * 1024) throw fail('Registry response too large: ' + path + ' (' + bytes + ' bytes; limit ' + 8 * 1024 * 1024 + ')', 502)
|
|
183
183
|
raw += decoder.decode(chunk, { stream: true })
|
|
184
184
|
}
|
|
185
185
|
raw += decoder.decode()
|
|
@@ -201,18 +201,131 @@ export async function pluginDetails(name, version = 'latest') {
|
|
|
201
201
|
}
|
|
202
202
|
|
|
203
203
|
const publicationCache = new Map()
|
|
204
|
-
|
|
204
|
+
// Validate full package JSON without accumulating all-version manifests. Only
|
|
205
|
+
// requested string/string-map fields are retained; unrelated content is skipped.
|
|
206
|
+
function registryProjection(fields) {
|
|
207
|
+
const stack = [], result = Object.create(null)
|
|
208
|
+
let root = false, done = false, token = '', mode = '', escaped = false, unicode = 0, capture = false, retained = 0
|
|
209
|
+
let prefixLimit = Infinity, decodedChars = 0, truncatedString = false
|
|
210
|
+
const invalid = () => { throw fail('Invalid npm publication metadata', 502) }
|
|
211
|
+
const wanted = frame => frame.keep || stack.length === 1 && Object.hasOwn(fields, frame.key)
|
|
212
|
+
function accept(kind, value) {
|
|
213
|
+
const frame = stack.at(-1)
|
|
214
|
+
if (kind === '}' || kind === ']') {
|
|
215
|
+
if (!frame || frame.kind !== (kind === '}' ? '{' : '[') || !['first', 'end'].includes(frame.state)) invalid()
|
|
216
|
+
stack.pop(); if (!stack.length) done = true
|
|
217
|
+
return
|
|
218
|
+
}
|
|
219
|
+
if (kind === ':') { if (frame?.state !== 'colon') invalid(); frame.state = 'value'; return }
|
|
220
|
+
if (kind === ',') { if (frame?.state !== 'end') invalid(); frame.state = frame.kind === '{' ? 'key' : 'value'; return }
|
|
221
|
+
if (frame?.kind === '{' && ['first', 'key'].includes(frame.state)) {
|
|
222
|
+
if (kind !== 'string') invalid()
|
|
223
|
+
frame.key = value; frame.state = 'colon'; return
|
|
224
|
+
}
|
|
225
|
+
if (frame && !(frame.state === 'value' || frame.kind === '[' && frame.state === 'first')) invalid()
|
|
226
|
+
if (!frame && (root || kind !== '{')) invalid()
|
|
227
|
+
const keep = frame ? wanted(frame) : false
|
|
228
|
+
if (keep && (stack.length === 1 && fields[frame.key] === 'map' ? kind !== '{' : kind !== 'string')) invalid()
|
|
229
|
+
const container = kind === '{' || kind === '['
|
|
230
|
+
const next = container ? kind === '{' ? Object.create(null) : [] : value
|
|
231
|
+
if (!frame) root = true
|
|
232
|
+
else {
|
|
233
|
+
if (keep) {
|
|
234
|
+
const target = stack.length === 1 ? result : frame.value
|
|
235
|
+
if (frame.kind === '[') target.push(next)
|
|
236
|
+
else { if (Object.hasOwn(target, frame.key)) invalid(); target[frame.key] = next }
|
|
237
|
+
}
|
|
238
|
+
frame.state = 'end'
|
|
239
|
+
}
|
|
240
|
+
if (container) {
|
|
241
|
+
if (stack.length >= 64) invalid()
|
|
242
|
+
stack.push({ kind, state: 'first', keep, value: next, key: '' })
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
function append(char) {
|
|
246
|
+
if (capture) {
|
|
247
|
+
if (++retained > 1024 * 1024) throw fail('npm publication fields exceed 1048576 characters', 502)
|
|
248
|
+
token += char
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
function stringUnit() {
|
|
252
|
+
// Stop at a complete decoded UTF-16 unit, never in a JSON escape. Keep one
|
|
253
|
+
// extra character so the existing README adapter reports truncation.
|
|
254
|
+
if (capture && ++decodedChars >= prefixLimit) { capture = false; truncatedString = true }
|
|
255
|
+
}
|
|
256
|
+
function push(raw) {
|
|
257
|
+
for (let i = 0; i < raw.length; i++) {
|
|
258
|
+
const char = raw[i]
|
|
259
|
+
if (mode === 'string') {
|
|
260
|
+
append(char)
|
|
261
|
+
if (unicode) { if (!/[a-fA-F0-9]/.test(char)) invalid(); unicode--; if (!unicode) stringUnit(); continue }
|
|
262
|
+
if (escaped) { if (char === 'u') unicode = 4; else if (!'"\\/bfnrt'.includes(char)) invalid(); escaped = false; if (char !== 'u') stringUnit(); continue }
|
|
263
|
+
if (char === '\\') { escaped = true; continue }
|
|
264
|
+
if (char === '"') { accept('string', capture ? JSON.parse(token) : truncatedString ? JSON.parse(token + '"') : undefined); mode = ''; token = ''; continue }
|
|
265
|
+
if (char.charCodeAt(0) < 32) invalid()
|
|
266
|
+
stringUnit()
|
|
267
|
+
continue
|
|
268
|
+
}
|
|
269
|
+
if (mode === 'scalar') {
|
|
270
|
+
if (!/[\s,}\]]/.test(char)) { if (token.length >= 128) invalid(); token += char; continue }
|
|
271
|
+
if (!/^(?:true|false|null|-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?)$/.test(token)) invalid()
|
|
272
|
+
accept('scalar', JSON.parse(token)); mode = ''; token = ''; i--; continue
|
|
273
|
+
}
|
|
274
|
+
if (/^[ \r\n\t]$/.test(char)) continue
|
|
275
|
+
if (done) invalid()
|
|
276
|
+
if ('{}[]:,'.includes(char)) { accept(char); continue }
|
|
277
|
+
if (char === '"') {
|
|
278
|
+
const frame = stack.at(-1)
|
|
279
|
+
capture = !!frame && (frame.kind === '{' && ['first', 'key'].includes(frame.state) ? frame.keep || stack.length === 1 : wanted(frame))
|
|
280
|
+
prefixLimit = stack.length === 1 && frame?.state === 'value' && frame.key === 'readme' ? 100001 : Infinity
|
|
281
|
+
decodedChars = 0; truncatedString = false
|
|
282
|
+
token = ''; mode = 'string'; append(char); continue
|
|
283
|
+
}
|
|
284
|
+
if (!/[tfn\d-]/.test(char)) invalid()
|
|
285
|
+
token = char; mode = 'scalar'
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
return { push, finish() { if (!done || mode || stack.length) invalid(); return result } }
|
|
289
|
+
}
|
|
290
|
+
async function registryMetadata(name, signal, fields) {
|
|
291
|
+
if (!packagePattern.test(name)) throw fail('Invalid package')
|
|
292
|
+
const requestSignal = signal ? AbortSignal.any([signal, AbortSignal.timeout(20000)]) : AbortSignal.timeout(20000)
|
|
293
|
+
let data, bytes = 0
|
|
294
|
+
try {
|
|
295
|
+
const response = await fetch(REGISTRY + '/' + encodeURIComponent(name), { signal: requestSignal, redirect: 'error', headers: { accept: 'application/json' } })
|
|
296
|
+
if (!response.ok) { await response.body?.cancel(); throw fail('HTTP ' + response.status, 502) }
|
|
297
|
+
const projection = registryProjection(fields), decoder = new TextDecoder('utf-8', { fatal: true })
|
|
298
|
+
for await (const chunk of response.body) {
|
|
299
|
+
bytes += chunk.length
|
|
300
|
+
if (bytes > 64 * 1024 * 1024) throw fail('Registry response too large (' + bytes + ' bytes; limit 67108864)', 502)
|
|
301
|
+
projection.push(decoder.decode(chunk, { stream: true }))
|
|
302
|
+
}
|
|
303
|
+
projection.push(decoder.decode()); data = projection.finish()
|
|
304
|
+
if (data.name !== name) throw fail('Invalid npm package identity', 502)
|
|
305
|
+
} catch (error) {
|
|
306
|
+
const reason = requestSignal.aborted ? 'npm 元数据读取超时或已取消' : error.status ? error.message : 'Registry response failed or invalid'
|
|
307
|
+
throw fail('npm ' + name + ': ' + reason + ' (received ' + bytes + ' bytes)', 502)
|
|
308
|
+
}
|
|
309
|
+
return data
|
|
310
|
+
}
|
|
311
|
+
// install-v1 metadata omits `time`; keep full-format publication evidence.
|
|
312
|
+
export async function publicationTimes(name, signal, versions = []) {
|
|
313
|
+
if (!packagePattern.test(name)) throw fail('Invalid package')
|
|
205
314
|
const cached = publicationCache.get(name)
|
|
206
|
-
if (cached?.until > Date.now()) return cached.value
|
|
207
|
-
const data = await
|
|
208
|
-
if (
|
|
315
|
+
if (cached?.until > Date.now() && versions.every(version => Object.hasOwn(cached.value, version))) return cached.value
|
|
316
|
+
const data = await registryMetadata(name, signal, { name: 'string', time: 'map' })
|
|
317
|
+
if (!data.time) throw fail('npm ' + name + ': npm 未提供可核验的发布时间', 502)
|
|
209
318
|
publicationCache.set(name, { value: data.time, until: Date.now() + 5 * 60000 })
|
|
210
319
|
if (publicationCache.size > 1500) publicationCache.delete(publicationCache.keys().next().value)
|
|
211
320
|
return data.time
|
|
212
321
|
}
|
|
322
|
+
async function readmeRegistryJson(path, signal) {
|
|
323
|
+
const name = decodeURIComponent(path.slice(1))
|
|
324
|
+
return registryMetadata(name, signal, { name: 'string', readme: 'string', 'dist-tags': 'map' })
|
|
325
|
+
}
|
|
213
326
|
|
|
214
327
|
export function createPluginCenter(ctx, options = {}) {
|
|
215
|
-
const market = createMarketAdapter(ctx), readme = createReadmeReader(options.registryJson ||
|
|
328
|
+
const market = createMarketAdapter(ctx), readme = createReadmeReader(options.registryJson || readmeRegistryJson)
|
|
216
329
|
const profile = options.profile === undefined ? detectProfile(ctx) : options.profile
|
|
217
330
|
const details = options.details || pluginDetails
|
|
218
331
|
const probe = options.probeProcesses || probeProcesses
|
package/plugin-transaction.mjs
CHANGED
|
@@ -119,7 +119,9 @@ export async function prepareReleasePlan(dir, operation, publishedTimes, env = p
|
|
|
119
119
|
const pairs = [...new Map(packages.map(row => [row.name + '@' + row.version, row])).values()]
|
|
120
120
|
const blockers = [], now = Date.now(), names = [...new Set(pairs.map(row => row.name))]
|
|
121
121
|
let cursor = 0
|
|
122
|
-
|
|
122
|
+
// Give large lockfiles multiple request batches, within the client/proxy budget.
|
|
123
|
+
const budget = Math.min(120000, Math.max(20000, Math.ceil(names.length / 6) * 20000))
|
|
124
|
+
const controller = new AbortController(), timeout = setTimeout(() => controller.abort(), budget)
|
|
123
125
|
try { if (policy.minutes > 0) await Promise.all(Array.from({ length: Math.min(6, names.length) }, async () => {
|
|
124
126
|
while (cursor < names.length) {
|
|
125
127
|
if (controller.signal.aborted) throw error('发布时间预检超时,请重试;不会执行安装。')
|
|
@@ -128,14 +130,19 @@ export async function prepareReleasePlan(dir, operation, publishedTimes, env = p
|
|
|
128
130
|
const first = policy.entries.find(rule => rule.name === name)
|
|
129
131
|
const checked = pairs.filter(row => row.name === name && !(first && (!first.versions.length || first.versions.includes(row.version))))
|
|
130
132
|
if (!checked.length) continue
|
|
131
|
-
const times = await publishedTimes(name, controller.signal)
|
|
133
|
+
const times = await publishedTimes(name, controller.signal, checked.map(row => row.version))
|
|
132
134
|
for (const row of checked) {
|
|
133
135
|
const at = Date.parse(times[row.version])
|
|
134
136
|
if (!Number.isFinite(at) || at > now + 60000) throw error('无法核实 ' + name + '@' + row.version + ' 的发布时间,未放行;请稍后重试。')
|
|
135
137
|
if (at + policy.minutes * 60000 > now) blockers.push({ ...row, publishedAt: new Date(at).toISOString(), eligibleAt: new Date(at + policy.minutes * 60000).toISOString() })
|
|
136
138
|
}
|
|
137
139
|
}
|
|
138
|
-
})) } catch (failure) {
|
|
140
|
+
})) } catch (failure) {
|
|
141
|
+
const timedOut = controller.signal.aborted
|
|
142
|
+
controller.abort()
|
|
143
|
+
if (timedOut) throw error('发布时间预检超时(' + budget / 1000 + ' 秒,' + names.length + ' 个包),不会执行安装;请重试。')
|
|
144
|
+
throw failure
|
|
145
|
+
} finally { clearTimeout(timeout) }
|
|
139
146
|
blockers.sort((a, b) => (a.name + '@' + a.version).localeCompare(b.name + '@' + b.version))
|
|
140
147
|
const merged = mergeReleaseRules(workspace, blockers)
|
|
141
148
|
if (profileRevision(dir) !== before) throw error('预检期间主机配置已变化,请重新预检。')
|
package/public/admin.html
CHANGED
|
@@ -5,13 +5,19 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
|
|
6
6
|
<meta name="theme-color" content="#0D1117">
|
|
7
7
|
<title>DSH Remote · 管理</title>
|
|
8
|
-
<script>/* 首帧前应用皮肤 */ (function(){try{var t=localStorage.getItem('dshTheme');if(t!=='default'&&t!=='dark'&&t!=='light'&&t!=='neutral'&&t!=='mono'&&t!=='fish'){t='fish'}}catch(e){t='fish'}document.documentElement.setAttribute('data-theme',t)})()</script>
|
|
8
|
+
<script>/* 首帧前应用皮肤 */ (function(){try{var t=localStorage.getItem('dshTheme');if(t!=='default'&&t!=='dark'&&t!=='light'&&t!=='neutral'&&t!=='mono'&&t!=='fish'&&t!=='penguin'&&t!=='penguin-night'&&t!=='bocchi'&&t!=='nijika'&&t!=='ryo'&&t!=='kita'){t='fish'}}catch(e){t='fish'}document.documentElement.setAttribute('data-theme',t)})()</script>
|
|
9
9
|
<link rel="stylesheet" href="../styles.css">
|
|
10
10
|
<link rel="stylesheet" href="../relay-settings.css">
|
|
11
11
|
<link rel="stylesheet" href="../insights.css">
|
|
12
12
|
<link rel="stylesheet" href="../setup.css">
|
|
13
13
|
<link rel="stylesheet" href="../doctor.css">
|
|
14
14
|
<link rel="stylesheet" href="../skins/blue-fish/skin.css">
|
|
15
|
+
<link rel="stylesheet" href="../skins/penguin/skin.css">
|
|
16
|
+
<link rel="stylesheet" href="../skins/bocchi/skin.css">
|
|
17
|
+
<link rel="stylesheet" href="../skins/kessoku/skin.css">
|
|
18
|
+
<link rel="stylesheet" href="../skins/nijika/skin.css">
|
|
19
|
+
<link rel="stylesheet" href="../skins/ryo/skin.css">
|
|
20
|
+
<link rel="stylesheet" href="../skins/kita/skin.css">
|
|
15
21
|
<style>
|
|
16
22
|
.admin-wrap { max-width: 1180px; margin: 0 auto; padding: calc(env(safe-area-inset-top, 0px) + 14px) 14px 40px; }
|
|
17
23
|
.admin-title {
|
|
@@ -342,6 +348,7 @@
|
|
|
342
348
|
}
|
|
343
349
|
</style>
|
|
344
350
|
<link rel="stylesheet" href="../remote-ui.css">
|
|
351
|
+
<link rel="stylesheet" href="../theme-picker.css">
|
|
345
352
|
</head>
|
|
346
353
|
<body>
|
|
347
354
|
<div class="admin-wrap">
|
|
@@ -510,6 +517,14 @@
|
|
|
510
517
|
<div class="muted" id="pair-hint"></div>
|
|
511
518
|
</div>
|
|
512
519
|
|
|
520
|
+
<section class="host-ip-card" id="lan-pairing-panel" aria-labelledby="lan-pairing-title">
|
|
521
|
+
<div class="host-ip-title" id="lan-pairing-title">局域网发现与配对</div>
|
|
522
|
+
<p class="muted" id="lan-pairing-hint"></p>
|
|
523
|
+
<p class="muted" id="lan-pairing-status" role="status"></p>
|
|
524
|
+
<p><code id="lan-pairing-code" hidden></code></p>
|
|
525
|
+
<button id="btn-lan-open" class="mini-btn" type="button" disabled>开放 10 分钟配对</button>
|
|
526
|
+
<button id="btn-lan-close" class="mini-btn" type="button" disabled>关闭配对</button>
|
|
527
|
+
</section>
|
|
513
528
|
<div class="stat-grid" id="stats"></div>
|
|
514
529
|
|
|
515
530
|
<div class="section-head"><span data-i18n="devices">已连接设备</span><span id="device-summary" class="muted"></span></div>
|
|
@@ -528,18 +543,8 @@
|
|
|
528
543
|
</div>
|
|
529
544
|
</div>
|
|
530
545
|
|
|
531
|
-
<!-- 皮肤选择模态 -->
|
|
532
|
-
<div id="modal-theme" class="modal hidden" role="dialog" aria-modal="true">
|
|
533
|
-
<div class="modal-card">
|
|
534
|
-
<div class="modal-title" data-i18n="theme.panelTitle">选择配色</div>
|
|
535
|
-
<div id="theme-options" class="theme-panel-list"></div>
|
|
536
|
-
<div class="modal-actions">
|
|
537
|
-
<button id="theme-close" class="btn subtle" data-i18n="theme.close">关闭</button>
|
|
538
|
-
</div>
|
|
539
|
-
</div>
|
|
540
|
-
</div>
|
|
541
|
-
|
|
542
546
|
<!-- 赞赏支持模态 -->
|
|
547
|
+
<script src="../sponsor-entry.js" defer></script>
|
|
543
548
|
<div id="modal-donate" class="modal hidden" role="dialog" aria-modal="true">
|
|
544
549
|
<div class="modal-card">
|
|
545
550
|
<div class="modal-title" data-i18n="donateTitle">赞赏支持</div>
|
|
@@ -575,7 +580,7 @@
|
|
|
575
580
|
'doctor.realtime': '实时消息通道', 'doctor.realtimePass': 'mux 与 host 通道均已连接', 'doctor.realtimeFail': '实时通道未全部建立;可先使用轮询,检查 DSH 后会自动恢复',
|
|
576
581
|
'doctor.start': '启动', 'doctor.showQr': '显示二维码', 'doctor.copyAddress': '复制地址', 'doctor.copyCommand': '复制命令',
|
|
577
582
|
'doctor.reportCopied': '诊断报告已复制', 'doctor.commandCopied': '防火墙命令已复制,请确认网络范围后手动执行', 'doctor.addressCopied': '服务器地址已复制',
|
|
578
|
-
'theme.default': '默认深空', 'theme.dark': '落日', 'theme.light': '易北爱乐厅', 'theme.neutral': '草原孤塔', 'theme.mono': '黑曜白', 'theme.fish': '蓝色大肥鱼',
|
|
583
|
+
'theme.default': '默认深空', 'theme.dark': '落日', 'theme.light': '易北爱乐厅', 'theme.neutral': '草原孤塔', 'theme.mono': '黑曜白', 'theme.fish': '蓝色大肥鱼', 'theme.penguin': '企鹅女管·白昼', 'theme.penguin-night': '企鹅女管·极夜', 'theme.bocchi': '波奇酱', 'theme.nijika': '伊地知虹夏', 'theme.ryo': '山田凉', 'theme.kita': '喜多郁代',
|
|
579
584
|
'theme.panelTitle': '选择配色', 'theme.close': '关闭',
|
|
580
585
|
'repo': '仓库',
|
|
581
586
|
'donateTitle': '赞赏支持', 'donateThanks': '感谢你的支持 ☕',
|
|
@@ -694,7 +699,7 @@
|
|
|
694
699
|
'doctor.realtime': 'Realtime channels', 'doctor.realtimePass': 'Both mux and host channels are connected', 'doctor.realtimeFail': 'Realtime channels are incomplete. Polling remains available and recovery is automatic.',
|
|
695
700
|
'doctor.start': 'Start', 'doctor.showQr': 'Show QR', 'doctor.copyAddress': 'Copy address', 'doctor.copyCommand': 'Copy command',
|
|
696
701
|
'doctor.reportCopied': 'Diagnostic report copied', 'doctor.commandCopied': 'Firewall command copied. Review the network scope before running it.', 'doctor.addressCopied': 'Server address copied',
|
|
697
|
-
'theme.default': 'Default', 'theme.dark': 'Sunset', 'theme.light': 'Elbphilharmonie', 'theme.neutral': 'Prairie Tower', 'theme.mono': 'Monochrome', 'theme.fish': 'Blue Fat Fish',
|
|
702
|
+
'theme.default': 'Default', 'theme.dark': 'Sunset', 'theme.light': 'Elbphilharmonie', 'theme.neutral': 'Prairie Tower', 'theme.mono': 'Monochrome', 'theme.fish': 'Blue Fat Fish', 'theme.penguin': 'Penguin Admin Day', 'theme.penguin-night': 'Penguin Admin Night', 'theme.bocchi': 'Bocchi', 'theme.nijika': 'Nijika', 'theme.ryo': 'Ryo', 'theme.kita': 'Kita',
|
|
698
703
|
'theme.panelTitle': 'Choose theme', 'theme.close': 'Close',
|
|
699
704
|
'repo': 'Repo',
|
|
700
705
|
'donateTitle': 'Support', 'donateThanks': 'Thanks for your support ☕',
|
package/public/admin.js
CHANGED
|
@@ -38,6 +38,63 @@ let qrShown = false
|
|
|
38
38
|
let qrToken = ''
|
|
39
39
|
let qrLabel = ''
|
|
40
40
|
let deviceKeyBusy = false
|
|
41
|
+
let lanBusy = false, lanCode = '', lanExpiry = 0, lanRevision = 0, lanRead = null
|
|
42
|
+
const lanText = (zh, en) => I18N.lang === 'en' ? en : zh
|
|
43
|
+
function lanError(code) {
|
|
44
|
+
return {
|
|
45
|
+
DEVICE_KEYS_REQUIRED: lanText('请先启用独立设备密钥。', 'Enable independent device keys first.'),
|
|
46
|
+
LAN_LISTENER_REQUIRED: lanText('网关目前仅允许本机访问,请改用可从局域网访问的监听地址。', 'The gateway only accepts local connections. Configure a LAN-accessible listener.'),
|
|
47
|
+
DISCOVERY_PORT_UNAVAILABLE: lanText('发现端口被占用,请检查是否运行了其他网关。', 'The discovery port is occupied. Check for another gateway.'),
|
|
48
|
+
GATEWAY_UNAVAILABLE: lanText('网关暂不可用,请检查运行状态。', 'The gateway is unavailable. Check its status.'),
|
|
49
|
+
PAIRING_CLOSED: lanText('配对已关闭,请重新开放。', 'Pairing is closed. Open a new window.'),
|
|
50
|
+
}[code] || lanText('操作失败,请检查网关后重试。', 'Operation failed. Check the gateway and try again.')
|
|
51
|
+
}
|
|
52
|
+
function renderLan(state = {}) {
|
|
53
|
+
$('lan-pairing-title').textContent = lanText('局域网发现与配对', 'LAN discovery and pairing')
|
|
54
|
+
$('lan-pairing-hint').textContent = lanText('需先启用上方的独立设备密钥,再开放配对。Android 手机可搜索同一 Wi-Fi 下的电脑,输入限时配对码连接。配对码仅显示本次,成功后自动关闭;扫码与手动连接仍可使用。', 'Enable independent device keys above, then open pairing. Find this computer from the Android app on the same Wi-Fi and enter the one-time code. Pairing closes after success; QR and manual connections remain available.')
|
|
55
|
+
$('btn-lan-open').textContent = lanText('开放 10 分钟配对', 'Open pairing for 10 minutes')
|
|
56
|
+
$('btn-lan-close').textContent = lanText('关闭配对', 'Close pairing')
|
|
57
|
+
const enabled = state.enabled === true
|
|
58
|
+
if (!enabled || state.expiresAt !== lanExpiry || Date.now() >= lanExpiry) lanCode = ''
|
|
59
|
+
$('lan-pairing-code').textContent = lanCode
|
|
60
|
+
$('lan-pairing-code').hidden = !lanCode
|
|
61
|
+
$('btn-lan-open').disabled = lanBusy || !lastState?.deviceKeys?.enabled
|
|
62
|
+
$('btn-lan-close').disabled = lanBusy || !enabled
|
|
63
|
+
$('lan-pairing-status').textContent = enabled ? lanText('配对开放至 ', 'Pairing open until ') + new Date(state.expiresAt).toLocaleTimeString()
|
|
64
|
+
: state.error ? lanError(state.error) : lanText('当前未开放配对。', 'Pairing is closed.')
|
|
65
|
+
}
|
|
66
|
+
async function refreshLan() {
|
|
67
|
+
if (lanBusy || lanRead || !lastState) return
|
|
68
|
+
const savedToken = token, revision = lanRevision, job = {}
|
|
69
|
+
lanRead = job
|
|
70
|
+
try {
|
|
71
|
+
const response = await fetch(API + '/lan', { headers: adminHeaders(), credentials: 'same-origin', signal: AbortSignal.timeout(5000) })
|
|
72
|
+
const state = await response.json()
|
|
73
|
+
if (savedToken !== token || lanBusy || revision !== lanRevision) return
|
|
74
|
+
if (!response.ok) { lanCode = ''; renderLan({ error: state.error || 'GATEWAY_UNAVAILABLE' }); return }
|
|
75
|
+
renderLan(state)
|
|
76
|
+
} catch { if (savedToken === token && !lanBusy && revision === lanRevision) { lanCode = ''; renderLan({ error: 'GATEWAY_UNAVAILABLE' }) } }
|
|
77
|
+
finally { if (lanRead === job) lanRead = null }
|
|
78
|
+
}
|
|
79
|
+
async function changeLan(enabled) {
|
|
80
|
+
if (lanBusy) return
|
|
81
|
+
lanRevision++
|
|
82
|
+
lanBusy = true
|
|
83
|
+
$('btn-lan-open').disabled = true; $('btn-lan-close').disabled = true
|
|
84
|
+
const savedToken = token, revision = lanRevision
|
|
85
|
+
try {
|
|
86
|
+
const response = await fetch(API + '/lan', { method: 'POST', headers: adminHeaders({ 'content-type': 'application/json' }),
|
|
87
|
+
credentials: 'same-origin', signal: AbortSignal.timeout(8000), body: JSON.stringify({ enabled }) })
|
|
88
|
+
const state = await response.json()
|
|
89
|
+
if (savedToken !== token || revision !== lanRevision) return
|
|
90
|
+
if (!response.ok || !state.ok) throw Error(state.error || 'PAIRING_FAILED')
|
|
91
|
+
lanCode = state.code || ''; lanExpiry = state.expiresAt || 0
|
|
92
|
+
lanBusy = false; renderLan(state)
|
|
93
|
+
} catch (error) { if (savedToken === token && revision === lanRevision) { lanCode = ''; lanBusy = false; renderLan({ error: error.message }); toast(lanError(error.message), 'err') } }
|
|
94
|
+
finally { if (revision === lanRevision) lanBusy = false }
|
|
95
|
+
}
|
|
96
|
+
$('btn-lan-open').addEventListener('click', () => changeLan(true))
|
|
97
|
+
$('btn-lan-close').addEventListener('click', () => changeLan(false))
|
|
41
98
|
const revealedDeviceKeys = new Set()
|
|
42
99
|
let gatewayPort = 8787
|
|
43
100
|
let gatewayPortLoaded = false
|
|
@@ -470,6 +527,7 @@ async function readState(job) {
|
|
|
470
527
|
|
|
471
528
|
function render(st) {
|
|
472
529
|
lastState = st
|
|
530
|
+
void refreshLan()
|
|
473
531
|
const isPlugin = st.mode === 'plugin'
|
|
474
532
|
const isGateway = st.mode === 'gateway'
|
|
475
533
|
shownToken = st.gatewayAuthError ? '' : st.token || token
|
|
@@ -777,6 +835,8 @@ function showMain() {
|
|
|
777
835
|
}
|
|
778
836
|
|
|
779
837
|
function logout() {
|
|
838
|
+
lanRevision++; lanBusy = false; lanCode = ''; lanExpiry = 0
|
|
839
|
+
$('lan-pairing-code').textContent = ''; $('lan-pairing-code').hidden = true
|
|
780
840
|
token = ''
|
|
781
841
|
store.del('dshAdminToken')
|
|
782
842
|
clearInterval(timer)
|
|
@@ -992,7 +1052,13 @@ const THEME_META = [
|
|
|
992
1052
|
{ id: 'light', sw: ['#F5F7F8', '#FFFFFF', '#176B87'] },
|
|
993
1053
|
{ id: 'neutral', sw: ['#EEF1E8', '#FAFBF6', '#47643C'] },
|
|
994
1054
|
{ id: 'mono', sw: ['#050505', '#333333', '#F5F5F5'] },
|
|
995
|
-
{ id: 'fish', sw: ['#EAF6FF', '#FFFFFF', '#2F52D0'] }
|
|
1055
|
+
{ id: 'fish', sw: ['#EAF6FF', '#FFFFFF', '#2F52D0'] },
|
|
1056
|
+
{ id: 'penguin', sw: ['#EDF3FA', '#FFFFFF', '#2B6CB0'] },
|
|
1057
|
+
{ id: 'penguin-night', sw: ['#10151B', '#1A222C', '#F2C230'] },
|
|
1058
|
+
{ id: 'bocchi', sw: ['#FFD9E8', '#FFFFFF', '#D0105A'] },
|
|
1059
|
+
{ id: 'nijika', sw: ['#FFF3D5', '#FFFFFF', '#94600C'] },
|
|
1060
|
+
{ id: 'ryo', sw: ['#E9F1FA', '#FFFFFF', '#315D91'] },
|
|
1061
|
+
{ id: 'kita', sw: ['#FFE9E5', '#FFFFFF', '#B6373C'] }
|
|
996
1062
|
]
|
|
997
1063
|
|
|
998
1064
|
function renderThemeBtn() {
|
|
@@ -1006,28 +1072,11 @@ function renderThemeBtn() {
|
|
|
1006
1072
|
if (btn) btn.title = t('theme.' + cur)
|
|
1007
1073
|
}
|
|
1008
1074
|
|
|
1009
|
-
function renderThemeOptions() {
|
|
1010
|
-
const box = $('theme-options')
|
|
1011
|
-
if (!box) return
|
|
1012
|
-
const cur = window.DSHTheme.get()
|
|
1013
|
-
box.innerHTML = THEME_META.map(m => `
|
|
1014
|
-
<button type="button" class="theme-option ${m.id === cur ? 'current' : ''}" data-theme="${m.id}" aria-pressed="${m.id === cur}" title="${t('theme.' + m.id)}">
|
|
1015
|
-
<span class="theme-swatches">${m.sw.map(c => `<i style="background:${c}"></i>`).join('')}</span>
|
|
1016
|
-
<span class="theme-name">${t('theme.' + m.id)}</span>
|
|
1017
|
-
<span class="theme-check">${m.id === cur ? '✓' : ''}</span>
|
|
1018
|
-
</button>`).join('')
|
|
1019
|
-
box.querySelectorAll('.theme-option').forEach(btn =>
|
|
1020
|
-
btn.addEventListener('click', () => {
|
|
1021
|
-
window.DSHTheme.set(btn.dataset.theme)
|
|
1022
|
-
renderThemeBtn()
|
|
1023
|
-
renderThemeOptions()
|
|
1024
|
-
$('modal-theme').classList.add('hidden')
|
|
1025
|
-
}))
|
|
1026
|
-
}
|
|
1027
|
-
|
|
1028
1075
|
function openThemePanel() {
|
|
1029
|
-
|
|
1030
|
-
|
|
1076
|
+
window.DSHTheme.openPicker({
|
|
1077
|
+
themes: THEME_META, label: id => t('theme.' + id), lang: I18N.lang,
|
|
1078
|
+
onSelect: id => { window.DSHTheme.set(id); renderThemeBtn() }
|
|
1079
|
+
})
|
|
1031
1080
|
}
|
|
1032
1081
|
|
|
1033
1082
|
function openDonateModal() {
|
|
@@ -1045,7 +1094,6 @@ $('btn-lang').addEventListener('click', () => {
|
|
|
1045
1094
|
})
|
|
1046
1095
|
|
|
1047
1096
|
$('btn-theme').addEventListener('click', openThemePanel)
|
|
1048
|
-
$('theme-close').addEventListener('click', () => $('modal-theme').classList.add('hidden'))
|
|
1049
1097
|
// 赞赏支持
|
|
1050
1098
|
$('btn-donate').addEventListener('click', openDonateModal)
|
|
1051
1099
|
$('donate-close').addEventListener('click', () => $('modal-donate').classList.add('hidden'))
|