# 函数列表

> 全部 JS 函数索引（git-push 插件 doc-func 自动维护，README.md 仅引用本文件）。

<!-- dshgp-functions:start -->
## 函数列表

### lib/bootstrap.js（93 行 · 5 个函数）

| 函数 | 行号 | 行数 | 签名 |
|------|------|------|------|
| `loadDirMigrations` | 27-40 | 14 | `function loadDirMigrations() {` |
| `copyOnce` | 49-66 | 18 | `function copyOnce(srcName, dstName) {` |
| `copyInto` | 69-73 | 5 | `function copyInto(s, d) {` |
| `copyDirInto` | 76-84 | 9 | `function copyDirInto(src, dst) {` |
| `bootstrapDataDirs` | 87-92 | 6 | `export function bootstrapDataDirs() {` |

### lib/client-parts/apply.js（156 行 · 11 个函数）

| 函数 | 行号 | 行数 | 签名 |
|------|------|------|------|
| `injectIdentityStyle` | 7-14 | 8 | `function injectIdentityStyle() {` |
| `cleanupStaleDom` | 21-35 | 15 | `function cleanupStaleDom() {` |
| `stopMedia` | 22-27 | 6 | `const stopMedia = (root) => {` |
| `registerTheme` | 38-49 | 12 | `function registerTheme(ctx) {` |
| `reorderDockButtons` | 53-58 | 6 | `function reorderDockButtons(dock) {` |
| `btnByText` | 55-55 | 1 | `const btnByText = (t) => allBtns.find((b) => b.textContent === t);` |
| `lockDarkMode` | 61-70 | 10 | `function lockDarkMode() {` |
| `enforce` | 62-65 | 4 | `const enforce = () => {` |
| `setupEscClose` | 73-82 | 10 | `function setupEscClose(dock) {` |
| `onEsc` | 74-79 | 6 | `const onEsc = (e) => {` |
| `apply` | 84-148 | 65 | `function apply(ctx) {` |

### lib/client-parts/foundation/theme.js（95 行 · 4 个函数）

| 函数 | 行号 | 行数 | 签名 |
|------|------|------|------|
| `extractColors` | 13-53 | 41 | `function extractColors(img, count = 5) {` |
| `loadImage` | 63-70 | 8 | `function loadImage(url) {` |
| `currentWallpaperColors` | 77-92 | 16 | `async function currentWallpaperColors() {` |
| `wallpaper` | 82-82 | 1 | `const wallpaper = (id ? items.find((x) => x.id === id) : null)` |

### lib/client-parts/foundation/utils-upload.js（396 行 · 21 个函数）

| 函数 | 行号 | 行数 | 签名 |
|------|------|------|------|
| `buildUploadRowEl` | 2-31 | 30 | `function buildUploadRowEl() {` |
| `makeUploadBegin` | 56-78 | 23 | `function makeUploadBegin(ops, root, refresh) {` |
| `makeUploadSkip` | 81-95 | 15 | `function makeUploadSkip(ops, root, rows, refresh) {` |
| `makeUploadDispose` | 98-105 | 8 | `function makeUploadDispose(btn, panel, onDocClick) {` |
| `createUploadToggle` | 107-120 | 14 | `function createUploadToggle(dockEl) {` |
| `bindRowButtons` | 123-131 | 9 | `function bindRowButtons(r, controls) {` |
| `startUploadHud` | 133-179 | 47 | `function startUploadHud(dock) {` |
| `onDocClick` | 144-149 | 6 | `const onDocClick = (e) => {` |
| `refresh` | 155-165 | 11 | `function refresh() {` |
| `runUploadXhr` | 192-208 | 17 | `function runUploadXhr(url, body, onProgress) {` |
| `settleUpload` | 218-226 | 9 | `function settleUpload(uploadResult, userPaused, userCancelled, hud) {` |
| `uploadOneFileXhr` | 228-277 | 50 | `function uploadOneFileXhr(file, kind) {` |
| `run` | 255-265 | 11 | `const run = () => {` |
| `classifyUploadFile` | 287-292 | 6 | `function classifyUploadFile(f) {` |
| `isItemUsable` | 296-298 | 3 | `function isItemUsable(item) {` |
| `refreshList` | 301-306 | 6 | `async function refreshList(kind) {` |
| `groupUploadByKind` | 311-319 | 9 | `function groupUploadByKind(files, hud) {` |
| `dedupeByFileSize` | 323-335 | 13 | `function dedupeByFileSize(files, kind, hud) {` |
| `uploadFiles` | 337-360 | 24 | `async function uploadFiles(files) {` |
| `removeItems` | 364-380 | 17 | `async function removeItems(items) {` |
| `deleteServerFile` | 382-392 | 11 | `function deleteServerFile(item) {` |

### lib/client-parts/foundation/utils.js（237 行 · 19 个函数）

| 函数 | 行号 | 行数 | 签名 |
|------|------|------|------|
| `readCachedMediaToken` | 11-15 | 5 | `function readCachedMediaToken() {` |
| `saveMediaToken` | 16-19 | 4 | `function saveMediaToken(t) {` |
| `probeMediaToken` | 22-35 | 14 | `async function probeMediaToken() {` |
| `refreshMediaTokens` | 38-46 | 9 | `function refreshMediaTokens() {` |
| `withMediaToken` | 47-54 | 8 | `function withMediaToken(url) {` |
| `apiFetch` | 66-80 | 15 | `async function apiFetch(url, opts = {}, timeoutMs = FETCH_TIMEOUT_MS) {` |
| `fmtBytes` | 83-84 | 2 | `function fmtBytes(n) { return n >= BYTES_PER_MB ? (n / BYTES_PER_MB).toFixed(1) + " MB" : (n / BYTES_PER_KB).toFixed(0) + " KB"; }` |
| `fmtSpeed` | 84-85 | 2 | `function fmtSpeed(bps) { return bps >= BYTES_PER_MB ? (bps / BYTES_PER_MB).toFixed(1) + " MB/s" : (bps / BYTES_PER_KB).toFixed(0) + " KB/s"; }` |
| `createRowOps` | 86-134 | 49 | `function createRowOps(rows, refresh) {` |
| `idbOpen` | 142-155 | 14 | `function idbOpen() {` |
| `idbGetAll` | 156-162 | 7 | `function idbGetAll(store) {` |
| `idbPut` | 163-170 | 8 | `function idbPut(store, record) {` |
| `idbDelete` | 171-178 | 8 | `function idbDelete(store, key) {` |
| `lfaAvailable` | 184-186 | 3 | `function lfaAvailable() {` |
| `lfaGetAll` | 188-196 | 9 | `function lfaGetAll(store) {` |
| `lfaPut` | 198-203 | 6 | `function lfaPut(store, record) {` |
| `lfaRemove` | 205-209 | 5 | `function lfaRemove(store, id) {` |
| `PickerGuard` | 224-236 | 13 | `function PickerGuard() {` |
| `restore` | 228-232 | 5 | `const restore = () => {` |

### lib/client-parts/scenes/ambience.js（104 行 · 4 个函数）

| 函数 | 行号 | 行数 | 签名 |
|------|------|------|------|
| `createAmbientDots` | 14-33 | 20 | `function createAmbientDots(wrap, maxCount) {` |
| `createAmbienceLine` | 36-53 | 18 | `function createAmbienceLine(dock, panel, onCycle) {` |
| `startAmbience` | 55-104 | 50 | `function startAmbience(dock) {` |
| `setLevel` | 71-90 | 20 | `function setLevel(key, instant) {` |

### lib/client-parts/scenes/boot.js（437 行 · 22 个函数）

| 函数 | 行号 | 行数 | 签名 |
|------|------|------|------|
| `resolveAutoBootVideo` | 24-49 | 26 | `async function resolveAutoBootVideo(listData) {` |
| `pick` | 46-46 | 1 | `const pick = (saved && vids.find((w) => w.id === saved)) \|\| vids[0];` |
| `loadBootGifConfig` | 50-107 | 58 | `async function loadBootGifConfig() {` |
| `buildBootOverlay` | 114-146 | 33 | `function buildBootOverlay() {` |
| `finishBootIntro` | 152-189 | 38 | `function finishBootIntro(ov, st) {` |
| `bootRotateTo` | 193-217 | 25 | `function bootRotateTo(ov, urls, index, st) {` |
| `bootStartRotate` | 220-241 | 22 | `function bootStartRotate(ov, urls, st) {` |
| `segMs` | 225-228 | 4 | `const segMs = (i) => {` |
| `step` | 229-239 | 11 | `const step = () => {` |
| `playTransformIntro` | 243-302 | 60 | `function playTransformIntro() {` |
| `waitBootMediaReady` | 305-345 | 41 | `function waitBootMediaReady(el) {` |
| `isReadyNow` | 312-318 | 7 | `function isReadyNow() {` |
| `cleanup` | 319-330 | 12 | `function cleanup(ok) {` |
| `onOk` | 331-332 | 2 | `function onOk() { cleanup(true); }` |
| `onTick` | 332-333 | 2 | `function onTick() { if (isReadyNow()) cleanup(true); }` |
| `onErr` | 333-334 | 2 | `function onErr() { cleanup(false); }` |
| `showBootOverlay` | 352-436 | 85 | `function showBootOverlay(mediaEl, urls) {` |
| `finish` | 364-381 | 18 | `const finish = () => {` |
| `rotateTo` | 386-410 | 25 | `function rotateTo(index, urls2) {` |
| `segMs` | 413-416 | 4 | `function segMs(index) {` |
| `startRotate` | 417-434 | 18 | `function startRotate(urls2) {` |
| `step` | 421-431 | 11 | `const step = () => {` |

### lib/client-parts/scenes/font.js（87 行 · 6 个函数）

| 函数 | 行号 | 行数 | 签名 |
|------|------|------|------|
| `createFontToggle` | 13-21 | 9 | `function createFontToggle(dock) {` |
| `createFontCycle` | 24-66 | 43 | `function createFontCycle(btn, applyScale) {` |
| `setLevel` | 34-42 | 9 | `function setLevel(key) {` |
| `restore` | 50-53 | 4 | `function restore(key) {` |
| `startFont` | 68-86 | 19 | `function startFont(dock) {` |
| `applyScale` | 71-84 | 14 | `function applyScale(scale) {` |

### lib/client-parts/scenes/identity.js（472 行 · 4 个函数）

| 函数 | 行号 | 行数 | 签名 |
|------|------|------|------|
| `registerColorCSS` | 17-24 | 8 | `function registerColorCSS() {` |
| `capsuleCSS` | 35-69 | 35 | `function capsuleCSS() {` |
| `visit` | 41-47 | 7 | `function visit(r) {` |
| `identityCSS` | 467-470 | 4 | `function identityCSS() {` |

### lib/client-parts/scenes/upload.js（146 行 · 5 个函数）

| 函数 | 行号 | 行数 | 签名 |
|------|------|------|------|
| `syncBgEnabledUI` | 41-50 | 10 | `function syncBgEnabledUI() {` |
| `setBgEnabled` | 51-58 | 8 | `function setBgEnabled(on) {` |
| `onBgDocClick` | 70-76 | 7 | `const onBgDocClick = (e) => {` |
| `defaultWallpaper` | 101-105 | 5 | `function defaultWallpaper() {` |
| `initWallpaper` | 107-130 | 24 | `async function initWallpaper() {` |

### lib/client-parts/scenes/wallpaper.js（659 行 · 40 个函数）

| 函数 | 行号 | 行数 | 签名 |
|------|------|------|------|
| `startWallpaper` | 2-659 | 658 | `function startWallpaper(dock) {` |
| `loadIdSet` | 9-12 | 4 | `function loadIdSet(key) {` |
| `saveIdSet` | 13-15 | 3 | `function saveIdSet(key, set) {` |
| `syncModeBtn` | 91-96 | 6 | `function syncModeBtn() {` |
| `updateIntervalLine` | 103-105 | 3 | `function updateIntervalLine() {` |
| `updateVideoToggle` | 107-114 | 8 | `function updateVideoToggle() {` |
| `logSwitch` | 136-152 | 17 | `function logSwitch(extra) {` |
| `disposeVideoEl` | 160-163 | 4 | `function disposeVideoEl(el) {` |
| `renderImageLayer` | 165-178 | 14 | `function renderImageLayer() {` |
| `resolveVideoEl` | 182-186 | 5 | `function resolveVideoEl(v, takeOver, preReady) {` |
| `applyVideoSrc` | 190-194 | 5 | `function applyVideoSrc(video, v, takeOver) {` |
| `applyVideoAutoPlay` | 200-218 | 19 | `function applyVideoAutoPlay(video, v, takeOver, muted) {` |
| `unmute` | 208-212 | 5 | `const unmute = () => {` |
| `renderVideoLayer` | 220-287 | 68 | `function renderVideoLayer() {` |
| `renderLayers` | 288-314 | 27 | `function renderLayers() {` |
| `showByIndex` | 333-339 | 7 | `function showByIndex(kind, idx) {` |
| `toggleVideo` | 343-353 | 11 | `function toggleVideo(on) {` |
| `activeArr` | 355-356 | 2 | `function activeArr() { return videoOn ? vids : imgs; }` |
| `showItem` | 357-365 | 9 | `function showItem(item) {` |
| `doSwitch` | 367-371 | 5 | `function doSwitch() {` |
| `computeNextVideo` | 377-390 | 14 | `function computeNextVideo() {` |
| `disposePreload` | 391-396 | 6 | `function disposePreload() {` |
| `preloadNextVideo` | 397-412 | 16 | `function preloadNextVideo() {` |
| `onVideoTimeUpdate` | 413-418 | 6 | `function onVideoTimeUpdate() {` |
| `onVideoEnded` | 419-425 | 7 | `function onVideoEnded() {` |
| `onVideoError` | 429-437 | 9 | `function onVideoError() {` |
| `randomCandidates` | 439-446 | 8 | `function randomCandidates() {` |
| `doRandom` | 448-456 | 9 | `function doRandom() {` |
| `clearRandom` | 458-459 | 2 | `function clearRandom() { if (randomTimer) { clearTimeout(randomTimer); randomTimer = null; } }` |
| `scheduleRandom` | 460-469 | 10 | `function scheduleRandom() {` |
| `setMode` | 471-488 | 18 | `function setMode(m) {` |
| `setIntervalMinutes` | 490-495 | 6 | `function setIntervalMinutes(v) {` |
| `closePanel` | 497-498 | 2 | `function closePanel() { panel.classList.remove("open"); }` |
| `closePicker` | 500-501 | 2 | `function closePicker() { picker.classList.remove("open"); }` |
| `updatePickerActions` | 502-507 | 6 | `function updatePickerActions() {` |
| `buildPicker` | 509-555 | 47 | `function buildPicker() {` |
| `openPicker` | 558-564 | 7 | `function openPicker() {` |
| `collectSelectedWallpapers` | 568-575 | 8 | `function collectSelectedWallpapers(ids) {` |
| `removeSelected` | 579-592 | 14 | `async function removeSelected() {` |
| `loadCustomWallpapers` | 617-640 | 24 | `async function loadCustomWallpapers(refresh) {` |

### lib/client-parts/sound/music-extract.js（247 行 · 12 个函数）

| 函数 | 行号 | 行数 | 签名 |
|------|------|------|------|
| `startMusic` | 5-247 | 243 | `async function startMusic(dock) {` |
| `loadIdSet` | 7-10 | 4 | `function loadIdSet(key) {` |
| `saveIdSet` | 11-13 | 3 | `function saveIdSet(key, set) {` |
| `fillList` | 23-44 | 22 | `async function fillList() {` |
| `parseSyncsafeSize` | 69-70 | 2 | `function parseSyncsafeSize(v, i) { return ((v[i] & 127) << 21) \| ((v[i + 1] & 127) << 14) \| ((v[i + 2] & 127) << 7) \| (v[i + 3] & 127); }` |
| `readFourCC` | 70-71 | 2 | `function readFourCC(v, i) { return String.fromCharCode(v[i], v[i + 1], v[i + 2], v[i + 3]); }` |
| `str` | 71-83 | 13 | `function str(v, s, e) { let r = ""; for (let i = s; i < e && i < v.length; i++) r += String.fromCharCode(v[i]); return r; }` |
| `flacPicture` | 72-83 | 12 | `function flacPicture(b) {` |
| `u32` | 73-73 | 1 | `const u32 = (i) => ((b[i] << 24) >>> 0) \| ((b[i + 1] << 16)) \| ((b[i + 2] << 8)) \| b[i + 3];` |
| `extractCover` | 84-136 | 53 | `function extractCover(buf) {` |
| `dataUriToBuffer` | 137-153 | 17 | `function dataUriToBuffer(uri) {` |
| `resolveCover` | 154-182 | 29 | `async function resolveCover(item) {` |

### lib/client-parts/sound/music-player.js（348 行 · 21 个函数）

| 函数 | 行号 | 行数 | 签名 |
|------|------|------|------|
| `fmt` | 1-6 | 6 | `function fmt(t) {` |
| `setCoverImage` | 7-13 | 7 | `function setCoverImage(url) { coverEl.style.backgroundImage = 'url("' + withMediaToken(url) + '")'; lblEl.style.display = "none"; }` |
| `setCoverFallback` | 8-13 | 6 | `function setCoverFallback(item) {` |
| `updateDisc` | 14-26 | 13 | `function updateDisc(item) {` |
| `refresh` | 27-36 | 10 | `function refresh() {` |
| `loadAndPlay` | 38-50 | 13 | `function loadAndPlay(i) {` |
| `expandCard` | 52-55 | 4 | `function expandCard() {` |
| `collapseMini` | 56-59 | 4 | `function collapseMini() {` |
| `openPicker` | 60-66 | 7 | `function openPicker() {` |
| `closePicker` | 67-68 | 2 | `function closePicker() { picker.classList.remove("open"); }` |
| `toggle` | 69-86 | 18 | `function toggle() {` |
| `shuffleCandidates` | 88-91 | 4 | `function shuffleCandidates() {` |
| `next` | 92-106 | 15 | `function next() {` |
| `prev` | 107-108 | 2 | `function prev() { if (list.length === 0) return; loadAndPlay(current > 0 ? current - 1 : list.length - 1); }` |
| `cycleMode` | 109-114 | 6 | `function cycleMode() {` |
| `setMode` | 115-121 | 7 | `function setMode(modeValue) {` |
| `updatePickerActions` | 123-127 | 5 | `function updatePickerActions() {` |
| `buildPicker` | 128-161 | 34 | `function buildPicker() {` |
| `removeSelectedSongs` | 162-195 | 34 | `async function removeSelectedSongs() {` |
| `setCover` | 201-249 | 49 | `function setCover() {` |
| `onDocClick` | 310-315 | 6 | `const onDocClick = (e) => {` |

### lib/client-parts/sound/typesound.js（265 行 · 21 个函数）

| 函数 | 行号 | 行数 | 签名 |
|------|------|------|------|
| `ensureTypeAudio` | 25-31 | 7 | `function ensureTypeAudio() {` |
| `typeNoiseBuffer` | 32-40 | 9 | `function typeNoiseBuffer(ctx) {` |
| `playTypeClick` | 41-73 | 33 | `function playTypeClick(key, style) {` |
| `pick` | 46-46 | 1 | `const pick = (v) => (soft ? v.soft : v.crisp);` |
| `buildVolumeLine` | 76-110 | 35 | `function buildVolumeLine(menu, line, label, ctx) {` |
| `syncIco` | 85-90 | 6 | `const syncIco = () => {` |
| `applyVideoSoundToBg` | 113-120 | 8 | `function applyVideoSoundToBg(loadVol, loadMuted) {` |
| `isEditableTarget` | 125-133 | 9 | `function isEditableTarget(el) {` |
| `attachTypeKeydown` | 135-146 | 12 | `function attachTypeKeydown(isTypeSoundOff, loadStyle) {` |
| `onKeydown` | 136-143 | 8 | `const onKeydown = (e) => {` |
| `buildTypeToggle` | 150-169 | 20 | `function buildTypeToggle(menu, onChange) {` |
| `setBox` | 159-159 | 1 | `const setBox = (on) => tbox.classList.toggle("on", on);` |
| `loadTypeStyle` | 171-193 | 23 | `function loadTypeStyle() { const s = localStorage.getItem("mediascape-dsh-type-style"); return s === "crisp" \|\| s === "soft" ? s : "soft"; }` |
| `buildStylePicker` | 172-193 | 22 | `function buildStylePicker(menu) {` |
| `startSoundPanel` | 195-263 | 69 | `function startSoundPanel(dock) {` |
| `loadVol` | 198-199 | 2 | `function loadVol() { return Math.min(100, Math.max(0, parseInt(localStorage.getItem(LS_VOL) \|\| String(VOL_RANGE.default), 10) \|\| VOL_RANGE.default)); }` |
| `loadMuted` | 199-200 | 2 | `function loadMuted() { return localStorage.getItem(LS_MUTED) !== "0"; }` |
| `saveVol` | 200-201 | 2 | `function saveVol(v) { try { localStorage.setItem(LS_VOL, String(v)); } catch (e) { /* localStorage 异常（配额/隐私模式）可忽略 */ } }` |
| `saveMuted` | 201-202 | 2 | `function saveMuted(m) { try { localStorage.setItem(LS_MUTED, m ? "1" : "0"); } catch (e) { /* localStorage 异常（配额/隐私模式）可忽略 */ } }` |
| `updateBtnState` | 215-220 | 6 | `const updateBtnState = () => {` |
| `onDocClick` | 245-249 | 5 | `const onDocClick = (e) => {` |

### lib/client-parts/toolbar/dock.js（146 行 · 12 个函数）

| 函数 | 行号 | 行数 | 签名 |
|------|------|------|------|
| `loadDockPos` | 4-17 | 14 | `function loadDockPos(dock, lsKey) {` |
| `saveDockPos` | 18-23 | 6 | `function saveDockPos(dock, lsKey) {` |
| `attachDockDrag` | 26-97 | 72 | `function attachDockDrag(dock, onReposition) {` |
| `clamp` | 31-37 | 7 | `function clamp(x, y) {` |
| `onDown` | 38-44 | 7 | `const onDown = (e) => {` |
| `onMove` | 45-60 | 16 | `const onMove = (e) => {` |
| `onUp` | 61-71 | 11 | `const onUp = (e) => {` |
| `onClickCapture` | 72-74 | 3 | `const onClickCapture = (e) => {` |
| `onResize` | 75-82 | 8 | `const onResize = () => {` |
| `startDock` | 99-144 | 46 | `function startDock() {` |
| `repositionPopup` | 108-131 | 24 | `function repositionPopup(el) {` |
| `repositionPopups` | 132-133 | 2 | `function repositionPopups() { for (const el of popups) repositionPopup(el); }` |

### lib/client.js（3941 行 · 202 个函数）

| 函数 | 行号 | 行数 | 签名 |
|------|------|------|------|
| `readCachedMediaToken` | 56-60 | 5 | `function readCachedMediaToken() {` |
| `saveMediaToken` | 61-64 | 4 | `function saveMediaToken(t) {` |
| `probeMediaToken` | 67-80 | 14 | `async function probeMediaToken() {` |
| `refreshMediaTokens` | 83-91 | 9 | `function refreshMediaTokens() {` |
| `withMediaToken` | 92-99 | 8 | `function withMediaToken(url) {` |
| `apiFetch` | 111-125 | 15 | `async function apiFetch(url, opts = {}, timeoutMs = FETCH_TIMEOUT_MS) {` |
| `fmtBytes` | 128-129 | 2 | `function fmtBytes(n) { return n >= BYTES_PER_MB ? (n / BYTES_PER_MB).toFixed(1) + " MB" : (n / BYTES_PER_KB).toFixed(0) + " KB"; }` |
| `fmtSpeed` | 129-130 | 2 | `function fmtSpeed(bps) { return bps >= BYTES_PER_MB ? (bps / BYTES_PER_MB).toFixed(1) + " MB/s" : (bps / BYTES_PER_KB).toFixed(0) + " KB/s"; }` |
| `createRowOps` | 131-179 | 49 | `function createRowOps(rows, refresh) {` |
| `idbOpen` | 187-200 | 14 | `function idbOpen() {` |
| `idbGetAll` | 201-207 | 7 | `function idbGetAll(store) {` |
| `idbPut` | 208-215 | 8 | `function idbPut(store, record) {` |
| `idbDelete` | 216-223 | 8 | `function idbDelete(store, key) {` |
| `lfaAvailable` | 229-231 | 3 | `function lfaAvailable() {` |
| `lfaGetAll` | 233-241 | 9 | `function lfaGetAll(store) {` |
| `lfaPut` | 243-248 | 6 | `function lfaPut(store, record) {` |
| `lfaRemove` | 250-254 | 5 | `function lfaRemove(store, id) {` |
| `PickerGuard` | 269-281 | 13 | `function PickerGuard() {` |
| `restore` | 273-277 | 5 | `const restore = () => {` |
| `extractColors` | 408-448 | 41 | `function extractColors(img, count = 5) {` |
| `loadImage` | 458-465 | 8 | `function loadImage(url) {` |
| `currentWallpaperColors` | 472-487 | 16 | `async function currentWallpaperColors() {` |
| `wallpaper` | 477-477 | 1 | `const wallpaper = (id ? items.find((x) => x.id === id) : null)` |
| `buildUploadRowEl` | 491-520 | 30 | `function buildUploadRowEl() {` |
| `makeUploadBegin` | 545-567 | 23 | `function makeUploadBegin(ops, root, refresh) {` |
| `makeUploadSkip` | 570-584 | 15 | `function makeUploadSkip(ops, root, rows, refresh) {` |
| `makeUploadDispose` | 587-594 | 8 | `function makeUploadDispose(btn, panel, onDocClick) {` |
| `createUploadToggle` | 596-609 | 14 | `function createUploadToggle(dockEl) {` |
| `bindRowButtons` | 612-620 | 9 | `function bindRowButtons(r, controls) {` |
| `startUploadHud` | 622-668 | 47 | `function startUploadHud(dock) {` |
| `onDocClick` | 633-638 | 6 | `const onDocClick = (e) => {` |
| `refresh` | 644-654 | 11 | `function refresh() {` |
| `runUploadXhr` | 681-697 | 17 | `function runUploadXhr(url, body, onProgress) {` |
| `settleUpload` | 707-715 | 9 | `function settleUpload(uploadResult, userPaused, userCancelled, hud) {` |
| `uploadOneFileXhr` | 717-766 | 50 | `function uploadOneFileXhr(file, kind) {` |
| `run` | 744-754 | 11 | `const run = () => {` |
| `classifyUploadFile` | 776-781 | 6 | `function classifyUploadFile(f) {` |
| `isItemUsable` | 785-787 | 3 | `function isItemUsable(item) {` |
| `refreshList` | 790-795 | 6 | `async function refreshList(kind) {` |
| `groupUploadByKind` | 800-808 | 9 | `function groupUploadByKind(files, hud) {` |
| `dedupeByFileSize` | 812-824 | 13 | `function dedupeByFileSize(files, kind, hud) {` |
| `uploadFiles` | 826-849 | 24 | `async function uploadFiles(files) {` |
| `removeItems` | 853-869 | 17 | `async function removeItems(items) {` |
| `deleteServerFile` | 871-881 | 11 | `function deleteServerFile(item) {` |
| `registerColorCSS` | 901-908 | 8 | `function registerColorCSS() {` |
| `capsuleCSS` | 919-953 | 35 | `function capsuleCSS() {` |
| `visit` | 925-931 | 7 | `function visit(r) {` |
| `identityCSS` | 1351-1354 | 4 | `function identityCSS() {` |
| `resolveAutoBootVideo` | 1379-1404 | 26 | `async function resolveAutoBootVideo(listData) {` |
| `pick` | 1401-1401 | 1 | `const pick = (saved && vids.find((w) => w.id === saved)) \|\| vids[0];` |
| `loadBootGifConfig` | 1405-1462 | 58 | `async function loadBootGifConfig() {` |
| `buildBootOverlay` | 1469-1501 | 33 | `function buildBootOverlay() {` |
| `finishBootIntro` | 1507-1544 | 38 | `function finishBootIntro(ov, st) {` |
| `bootRotateTo` | 1548-1572 | 25 | `function bootRotateTo(ov, urls, index, st) {` |
| `bootStartRotate` | 1575-1596 | 22 | `function bootStartRotate(ov, urls, st) {` |
| `segMs` | 1580-1583 | 4 | `const segMs = (i) => {` |
| `step` | 1584-1594 | 11 | `const step = () => {` |
| `playTransformIntro` | 1598-1657 | 60 | `function playTransformIntro() {` |
| `waitBootMediaReady` | 1660-1700 | 41 | `function waitBootMediaReady(el) {` |
| `isReadyNow` | 1667-1673 | 7 | `function isReadyNow() {` |
| `cleanup` | 1674-1685 | 12 | `function cleanup(ok) {` |
| `onOk` | 1686-1687 | 2 | `function onOk() { cleanup(true); }` |
| `onTick` | 1687-1688 | 2 | `function onTick() { if (isReadyNow()) cleanup(true); }` |
| `onErr` | 1688-1689 | 2 | `function onErr() { cleanup(false); }` |
| `showBootOverlay` | 1707-1791 | 85 | `function showBootOverlay(mediaEl, urls) {` |
| `finish` | 1719-1736 | 18 | `const finish = () => {` |
| `rotateTo` | 1741-1765 | 25 | `function rotateTo(index, urls2) {` |
| `segMs` | 1768-1771 | 4 | `function segMs(index) {` |
| `startRotate` | 1772-1789 | 18 | `function startRotate(urls2) {` |
| `step` | 1776-1786 | 11 | `const step = () => {` |
| `startWallpaper` | 1793-2593 | 801 | `function startWallpaper(dock) {` |
| `loadIdSet` | 1800-1803 | 4 | `function loadIdSet(key) {` |
| `saveIdSet` | 1804-1806 | 3 | `function saveIdSet(key, set) {` |
| `syncModeBtn` | 1882-1887 | 6 | `function syncModeBtn() {` |
| `updateIntervalLine` | 1894-1896 | 3 | `function updateIntervalLine() {` |
| `updateVideoToggle` | 1898-1905 | 8 | `function updateVideoToggle() {` |
| `logSwitch` | 1927-1943 | 17 | `function logSwitch(extra) {` |
| `disposeVideoEl` | 1951-1954 | 4 | `function disposeVideoEl(el) {` |
| `renderImageLayer` | 1956-1969 | 14 | `function renderImageLayer() {` |
| `resolveVideoEl` | 1973-1977 | 5 | `function resolveVideoEl(v, takeOver, preReady) {` |
| `applyVideoSrc` | 1981-1985 | 5 | `function applyVideoSrc(video, v, takeOver) {` |
| `applyVideoAutoPlay` | 1991-2009 | 19 | `function applyVideoAutoPlay(video, v, takeOver, muted) {` |
| `unmute` | 1999-2003 | 5 | `const unmute = () => {` |
| `renderVideoLayer` | 2011-2078 | 68 | `function renderVideoLayer() {` |
| `renderLayers` | 2079-2105 | 27 | `function renderLayers() {` |
| `showByIndex` | 2124-2130 | 7 | `function showByIndex(kind, idx) {` |
| `toggleVideo` | 2134-2144 | 11 | `function toggleVideo(on) {` |
| `activeArr` | 2146-2147 | 2 | `function activeArr() { return videoOn ? vids : imgs; }` |
| `showItem` | 2148-2156 | 9 | `function showItem(item) {` |
| `doSwitch` | 2158-2162 | 5 | `function doSwitch() {` |
| `computeNextVideo` | 2168-2181 | 14 | `function computeNextVideo() {` |
| `disposePreload` | 2182-2187 | 6 | `function disposePreload() {` |
| `preloadNextVideo` | 2188-2203 | 16 | `function preloadNextVideo() {` |
| `onVideoTimeUpdate` | 2204-2209 | 6 | `function onVideoTimeUpdate() {` |
| `onVideoEnded` | 2210-2216 | 7 | `function onVideoEnded() {` |
| `onVideoError` | 2220-2228 | 9 | `function onVideoError() {` |
| `randomCandidates` | 2230-2237 | 8 | `function randomCandidates() {` |
| `doRandom` | 2239-2247 | 9 | `function doRandom() {` |
| `clearRandom` | 2249-2250 | 2 | `function clearRandom() { if (randomTimer) { clearTimeout(randomTimer); randomTimer = null; } }` |
| `scheduleRandom` | 2251-2260 | 10 | `function scheduleRandom() {` |
| `setMode` | 2262-2279 | 18 | `function setMode(m) {` |
| `setIntervalMinutes` | 2281-2286 | 6 | `function setIntervalMinutes(v) {` |
| `closePanel` | 2288-2289 | 2 | `function closePanel() { panel.classList.remove("open"); }` |
| `closePicker` | 2291-2292 | 2 | `function closePicker() { picker.classList.remove("open"); }` |
| `updatePickerActions` | 2293-2298 | 6 | `function updatePickerActions() {` |
| `buildPicker` | 2300-2346 | 47 | `function buildPicker() {` |
| `openPicker` | 2349-2355 | 7 | `function openPicker() {` |
| `collectSelectedWallpapers` | 2359-2366 | 8 | `function collectSelectedWallpapers(ids) {` |
| `removeSelected` | 2370-2383 | 14 | `async function removeSelected() {` |
| `loadCustomWallpapers` | 2408-2431 | 24 | `async function loadCustomWallpapers(refresh) {` |
| `syncBgEnabledUI` | 2490-2499 | 10 | `function syncBgEnabledUI() {` |
| `setBgEnabled` | 2500-2507 | 8 | `function setBgEnabled(on) {` |
| `onBgDocClick` | 2519-2525 | 7 | `const onBgDocClick = (e) => {` |
| `defaultWallpaper` | 2550-2554 | 5 | `function defaultWallpaper() {` |
| `initWallpaper` | 2556-2579 | 24 | `async function initWallpaper() {` |
| `createAmbientDots` | 2608-2627 | 20 | `function createAmbientDots(wrap, maxCount) {` |
| `createAmbienceLine` | 2630-2647 | 18 | `function createAmbienceLine(dock, panel, onCycle) {` |
| `startAmbience` | 2649-2698 | 50 | `function startAmbience(dock) {` |
| `setLevel` | 2665-2684 | 20 | `function setLevel(key, instant) {` |
| `createFontToggle` | 2710-2718 | 9 | `function createFontToggle(dock) {` |
| `createFontCycle` | 2721-2763 | 43 | `function createFontCycle(btn, applyScale) {` |
| `setLevel` | 2731-2739 | 9 | `function setLevel(key) {` |
| `restore` | 2747-2750 | 4 | `function restore(key) {` |
| `startFont` | 2765-2783 | 19 | `function startFont(dock) {` |
| `applyScale` | 2768-2781 | 14 | `function applyScale(scale) {` |
| `ensureTypeAudio` | 2808-2814 | 7 | `function ensureTypeAudio() {` |
| `typeNoiseBuffer` | 2815-2823 | 9 | `function typeNoiseBuffer(ctx) {` |
| `playTypeClick` | 2824-2856 | 33 | `function playTypeClick(key, style) {` |
| `pick` | 2829-2829 | 1 | `const pick = (v) => (soft ? v.soft : v.crisp);` |
| `buildVolumeLine` | 2859-2893 | 35 | `function buildVolumeLine(menu, line, label, ctx) {` |
| `syncIco` | 2868-2873 | 6 | `const syncIco = () => {` |
| `applyVideoSoundToBg` | 2896-2903 | 8 | `function applyVideoSoundToBg(loadVol, loadMuted) {` |
| `isEditableTarget` | 2908-2916 | 9 | `function isEditableTarget(el) {` |
| `attachTypeKeydown` | 2918-2929 | 12 | `function attachTypeKeydown(isTypeSoundOff, loadStyle) {` |
| `onKeydown` | 2919-2926 | 8 | `const onKeydown = (e) => {` |
| `buildTypeToggle` | 2933-2952 | 20 | `function buildTypeToggle(menu, onChange) {` |
| `setBox` | 2942-2942 | 1 | `const setBox = (on) => tbox.classList.toggle("on", on);` |
| `loadTypeStyle` | 2954-2976 | 23 | `function loadTypeStyle() { const s = localStorage.getItem("mediascape-dsh-type-style"); return s === "crisp" \|\| s === "soft" ? s : "soft"; }` |
| `buildStylePicker` | 2955-2976 | 22 | `function buildStylePicker(menu) {` |
| `startSoundPanel` | 2978-3046 | 69 | `function startSoundPanel(dock) {` |
| `loadVol` | 2981-2982 | 2 | `function loadVol() { return Math.min(100, Math.max(0, parseInt(localStorage.getItem(LS_VOL) \|\| String(VOL_RANGE.default), 10) \|\| VOL_RANGE.default)); }` |
| `loadMuted` | 2982-2983 | 2 | `function loadMuted() { return localStorage.getItem(LS_MUTED) !== "0"; }` |
| `saveVol` | 2983-2984 | 2 | `function saveVol(v) { try { localStorage.setItem(LS_VOL, String(v)); } catch (e) { /* localStorage 异常（配额/隐私模式）可忽略 */ } }` |
| `saveMuted` | 2984-2985 | 2 | `function saveMuted(m) { try { localStorage.setItem(LS_MUTED, m ? "1" : "0"); } catch (e) { /* localStorage 异常（配额/隐私模式）可忽略 */ } }` |
| `updateBtnState` | 2998-3003 | 6 | `const updateBtnState = () => {` |
| `onDocClick` | 3028-3032 | 5 | `const onDocClick = (e) => {` |
| `startMusic` | 3052-3639 | 588 | `async function startMusic(dock) {` |
| `loadIdSet` | 3054-3057 | 4 | `function loadIdSet(key) {` |
| `saveIdSet` | 3058-3060 | 3 | `function saveIdSet(key, set) {` |
| `fillList` | 3070-3091 | 22 | `async function fillList() {` |
| `parseSyncsafeSize` | 3116-3117 | 2 | `function parseSyncsafeSize(v, i) { return ((v[i] & 127) << 21) \| ((v[i + 1] & 127) << 14) \| ((v[i + 2] & 127) << 7) \| (v[i + 3] & 127); }` |
| `readFourCC` | 3117-3118 | 2 | `function readFourCC(v, i) { return String.fromCharCode(v[i], v[i + 1], v[i + 2], v[i + 3]); }` |
| `str` | 3118-3130 | 13 | `function str(v, s, e) { let r = ""; for (let i = s; i < e && i < v.length; i++) r += String.fromCharCode(v[i]); return r; }` |
| `flacPicture` | 3119-3130 | 12 | `function flacPicture(b) {` |
| `u32` | 3120-3120 | 1 | `const u32 = (i) => ((b[i] << 24) >>> 0) \| ((b[i + 1] << 16)) \| ((b[i + 2] << 8)) \| b[i + 3];` |
| `extractCover` | 3131-3183 | 53 | `function extractCover(buf) {` |
| `dataUriToBuffer` | 3184-3200 | 17 | `function dataUriToBuffer(uri) {` |
| `resolveCover` | 3201-3229 | 29 | `async function resolveCover(item) {` |
| `fmt` | 3294-3299 | 6 | `function fmt(t) {` |
| `setCoverImage` | 3300-3306 | 7 | `function setCoverImage(url) { coverEl.style.backgroundImage = 'url("' + withMediaToken(url) + '")'; lblEl.style.display = "none"; }` |
| `setCoverFallback` | 3301-3306 | 6 | `function setCoverFallback(item) {` |
| `updateDisc` | 3307-3319 | 13 | `function updateDisc(item) {` |
| `refresh` | 3320-3329 | 10 | `function refresh() {` |
| `loadAndPlay` | 3331-3343 | 13 | `function loadAndPlay(i) {` |
| `expandCard` | 3345-3348 | 4 | `function expandCard() {` |
| `collapseMini` | 3349-3352 | 4 | `function collapseMini() {` |
| `openPicker` | 3353-3359 | 7 | `function openPicker() {` |
| `closePicker` | 3360-3361 | 2 | `function closePicker() { picker.classList.remove("open"); }` |
| `toggle` | 3362-3379 | 18 | `function toggle() {` |
| `shuffleCandidates` | 3381-3384 | 4 | `function shuffleCandidates() {` |
| `next` | 3385-3399 | 15 | `function next() {` |
| `prev` | 3400-3401 | 2 | `function prev() { if (list.length === 0) return; loadAndPlay(current > 0 ? current - 1 : list.length - 1); }` |
| `cycleMode` | 3402-3407 | 6 | `function cycleMode() {` |
| `setMode` | 3408-3414 | 7 | `function setMode(modeValue) {` |
| `updatePickerActions` | 3416-3420 | 5 | `function updatePickerActions() {` |
| `buildPicker` | 3421-3454 | 34 | `function buildPicker() {` |
| `removeSelectedSongs` | 3455-3488 | 34 | `async function removeSelectedSongs() {` |
| `setCover` | 3494-3542 | 49 | `function setCover() {` |
| `onDocClick` | 3603-3608 | 6 | `const onDocClick = (e) => {` |
| `loadDockPos` | 3644-3657 | 14 | `function loadDockPos(dock, lsKey) {` |
| `saveDockPos` | 3658-3663 | 6 | `function saveDockPos(dock, lsKey) {` |
| `attachDockDrag` | 3666-3737 | 72 | `function attachDockDrag(dock, onReposition) {` |
| `clamp` | 3671-3677 | 7 | `function clamp(x, y) {` |
| `onDown` | 3678-3684 | 7 | `const onDown = (e) => {` |
| `onMove` | 3685-3700 | 16 | `const onMove = (e) => {` |
| `onUp` | 3701-3711 | 11 | `const onUp = (e) => {` |
| `onClickCapture` | 3712-3714 | 3 | `const onClickCapture = (e) => {` |
| `onResize` | 3715-3722 | 8 | `const onResize = () => {` |
| `startDock` | 3739-3784 | 46 | `function startDock() {` |
| `repositionPopup` | 3748-3771 | 24 | `function repositionPopup(el) {` |
| `repositionPopups` | 3772-3773 | 2 | `function repositionPopups() { for (const el of popups) repositionPopup(el); }` |
| `injectIdentityStyle` | 3792-3799 | 8 | `function injectIdentityStyle() {` |
| `cleanupStaleDom` | 3806-3820 | 15 | `function cleanupStaleDom() {` |
| `stopMedia` | 3807-3812 | 6 | `const stopMedia = (root) => {` |
| `registerTheme` | 3823-3834 | 12 | `function registerTheme(ctx) {` |
| `reorderDockButtons` | 3838-3843 | 6 | `function reorderDockButtons(dock) {` |
| `btnByText` | 3840-3840 | 1 | `const btnByText = (t) => allBtns.find((b) => b.textContent === t);` |
| `lockDarkMode` | 3846-3855 | 10 | `function lockDarkMode() {` |
| `enforce` | 3847-3850 | 4 | `const enforce = () => {` |
| `setupEscClose` | 3858-3867 | 10 | `function setupEscClose(dock) {` |
| `onEsc` | 3859-3864 | 6 | `const onEsc = (e) => {` |
| `apply` | 3869-3933 | 65 | `function apply(ctx) {` |

### lib/config.js（71 行 · 1 个函数）

| 函数 | 行号 | 行数 | 签名 |
|------|------|------|------|
| `uploadLimitBytes` | 59-70 | 12 | `export function uploadLimitBytes(dir) {` |

### lib/debug.js（141 行 · 8 个函数）

| 函数 | 行号 | 行数 | 签名 |
|------|------|------|------|
| `debugConfigPath` | 30-32 | 3 | `export function debugConfigPath() {` |
| `parseDebugConfig` | 45-59 | 15 | `function parseDebugConfig(cfg) {` |
| `readDebugConfig` | 61-72 | 12 | `export function readDebugConfig(force = false) {` |
| `logEnabled` | 81-86 | 6 | `export function logEnabled(category) {` |
| `isDebug` | 92-94 | 3 | `export function isDebug(key) {` |
| `logTs` | 101-105 | 5 | `export function logTs(d = new Date()) {` |
| `rotate` | 107-115 | 9 | `function rotate(file) {` |
| `writeLog` | 123-139 | 17 | `export function writeLog(name, entry) {` |

### lib/handlers-log.js（197 行 · 10 个函数）

| 函数 | 行号 | 行数 | 签名 |
|------|------|------|------|
| `wallpaperLogPath` | 16-17 | 2 | `function wallpaperLogPath() { return join(logsDir(), WALLPAPER_LOG_FILE); }` |
| `appendWallpaperLog` | 19-21 | 3 | `export function appendWallpaperLog(entry) {` |
| `readFileTail` | 37-57 | 21 | `function readFileTail(file, maxLines) {` |
| `readWallpaperLog` | 60-70 | 11 | `export function readWallpaperLog(lines = DEFAULT_LOG_LINES) {` |
| `nextAvailableName` | 73-77 | 5 | `export function nextAvailableName(dir, base, ext) {` |
| `uploadErrorResponse` | 80-90 | 11 | `export function uploadErrorResponse(res, payload, traceId, e, tag) {` |
| `finalizeUpload` | 102-127 | 26 | `export async function finalizeUpload(dir, payload, safeName, size, opts = {}) {` |
| `handleUploadPartDelete` | 134-157 | 24 | `export function handleUploadPartDelete(req, res) {` |
| `handleWallpaperLog` | 160-189 | 30 | `export function handleWallpaperLog(req, res) {` |
| `handleWallpaperLogRead` | 192-197 | 6 | `export function handleWallpaperLogRead(req, res, url) {` |

### lib/handlers-upload.js（320 行 · 9 个函数）

| 函数 | 行号 | 行数 | 签名 |
|------|------|------|------|
| `memBufferLimit` | 23-25 | 3 | `function memBufferLimit() {` |
| `receiveBody` | 27-115 | 89 | `function receiveBody(req, { tmpPath, partPath, limit, offset = 0 }) {` |
| `flushBufferToPart` | 42-46 | 5 | `const flushBufferToPart = () => {` |
| `onInterrupt` | 100-111 | 12 | `const onInterrupt = (label, err) => {` |
| `cleanupOrphanParts` | 118-129 | 12 | `function cleanupOrphanParts(dir, maxAgeMs = 24 * 3600 * 1000) {` |
| `handleFileUpload` | 139-247 | 109 | `function handleFileUpload(req, res, { kind }) {` |
| `handleUpload` | 250-252 | 3 | `export function handleUpload(req, res) {` |
| `handleMusicUpload` | 255-257 | 3 | `export function handleMusicUpload(req, res) {` |
| `handleCoverUpload` | 264-320 | 57 | `export function handleCoverUpload(req, res) {` |

### lib/handlers.js（278 行 · 8 个函数）

| 函数 | 行号 | 行数 | 签名 |
|------|------|------|------|
| `handleConfig` | 35-41 | 7 | `export function handleConfig(res) {` |
| `deleteWallpaperFile` | 46-62 | 17 | `function deleteWallpaperFile(file, dir) {` |
| `handleDelete` | 64-81 | 18 | `export function handleDelete(req, res, rel) {` |
| `scanWallpaperDir` | 86-108 | 23 | `function scanWallpaperDir(dir, labels) {` |
| `mergeOnlineWallpapers` | 111-134 | 24 | `function mergeOnlineWallpapers(items, labels) {` |
| `handleList` | 136-152 | 17 | `export function handleList(res) {` |
| `handleMusicList` | 158-222 | 65 | `export function handleMusicList(res) {` |
| `handleMusicDelete` | 236-274 | 39 | `export function handleMusicDelete(req, res, rel) {` |

### lib/index.js（229 行 · 5 个函数）

| 函数 | 行号 | 行数 | 签名 |
|------|------|------|------|
| `logApiRequest` | 34-49 | 16 | `function logApiRequest(req, res, rel) {` |
| `routeAssetsHandler` | 58-146 | 89 | `function routeAssetsHandler(req, res, url, rel, top) {` |
| `registerAssets` | 148-181 | 34 | `export function registerAssets(ctx) {` |
| `ensureDebugServer` | 195-214 | 20 | `function ensureDebugServer() {` |
| `apply` | 217-228 | 12 | `export function apply(ctx) {` |

### lib/labels.js（48 行 · 8 个函数）

| 函数 | 行号 | 行数 | 签名 |
|------|------|------|------|
| `readMap` | 16-22 | 7 | `function readMap(p) {` |
| `writeMap` | 24-31 | 8 | `function writeMap(p, map) {` |
| `loadWallpaperLabels` | 34-35 | 2 | `export function loadWallpaperLabels() { return readMap(wallpaperLabelsPath()); }` |
| `saveWallpaperLabels` | 37-38 | 2 | `export function saveWallpaperLabels(map) { writeMap(wallpaperLabelsPath(), map); }` |
| `loadMusicLabels` | 40-41 | 2 | `export function loadMusicLabels() { return readMap(musicLabelsPath()); }` |
| `saveMusicLabels` | 43-44 | 2 | `export function saveMusicLabels(map) { writeMap(musicLabelsPath(), map); }` |
| `loadLabels` | 46-47 | 2 | `export function loadLabels() { return loadWallpaperLabels(); }` |
| `saveLabels` | 47-48 | 2 | `export function saveLabels(map) { return saveWallpaperLabels(map); }` |

### lib/media-token.js（106 行 · 7 个函数）

| 函数 | 行号 | 行数 | 签名 |
|------|------|------|------|
| `extractToken` | 29-33 | 5 | `function extractToken(text) {` |
| `installTokenCapture` | 39-51 | 13 | `export function installTokenCapture() {` |
| `logCandidates` | 57-65 | 9 | `function logCandidates() {` |
| `readTail` | 68-80 | 13 | `function readTail(file, bytes) {` |
| `tokenFromLogs` | 83-90 | 8 | `function tokenFromLogs() {` |
| `getDshToken` | 96-99 | 4 | `export function getDshToken() {` |
| `tokenSource` | 102-105 | 4 | `export function tokenSource() {` |

### lib/online.js（223 行 · 13 个函数）

| 函数 | 行号 | 行数 | 签名 |
|------|------|------|------|
| `loadOnlineSources` | 31-46 | 16 | `function loadOnlineSources() {` |
| `downloadOne` | 55-83 | 29 | `function downloadOne(src) {` |
| `prehash` | 88-101 | 14 | `function prehash(ctx) {` |
| `retry` | 104-107 | 4 | `function retry(msg, triesLeft, ctx) {` |
| `handleUnresumable` | 110-114 | 5 | `function handleUnresumable(res, tries, ctx) {` |
| `handleOverLimit` | 117-122 | 6 | `function handleOverLimit(size, req, ws, ctx) {` |
| `finalizeDownload` | 125-143 | 19 | `function finalizeDownload(hashAcc, ws, ctx) {` |
| `handleResponse` | 146-180 | 35 | `function handleResponse(res, offset, hashAcc, tries, ctx) {` |
| `failTo` | 160-164 | 5 | `const failTo = (msg, t) => {` |
| `attempt` | 183-191 | 9 | `function attempt(offset, hashAcc, tries, ctx) {` |
| `downloadAllOnline` | 194-212 | 19 | `async function downloadAllOnline() {` |
| `worker` | 200-208 | 9 | `const worker = async () => {` |
| `ensureOnlineDownload` | 217-222 | 6 | `export function ensureOnlineDownload() {` |

### lib/paths.js（54 行 · 10 个函数）

| 函数 | 行号 | 行数 | 签名 |
|------|------|------|------|
| `baseDir` | 8-10 | 3 | `function baseDir() {` |
| `themeDir` | 13-14 | 2 | `export function themeDir() { return join(baseDir(), 'theme-mediascape'); }` |
| `bootDir` | 16-17 | 2 | `export function bootDir() { return join(themeDir(), 'boot'); }` |
| `logsDir` | 19-20 | 2 | `export function logsDir() { return join(themeDir(), 'logs'); }` |
| `wallpaperDir` | 22-23 | 2 | `export function wallpaperDir() { return join(themeDir(), 'wallpaper'); }` |
| `musicDir` | 25-26 | 2 | `export function musicDir() { return join(themeDir(), 'music'); }` |
| `onlineDir` | 30-31 | 2 | `export function onlineDir() { return join(wallpaperDir(), ONLINE_DIR_NAME); }` |
| `wallpaperLabelsPath` | 38-39 | 2 | `export function wallpaperLabelsPath() { return join(wallpaperDir(), WALLPAPER_LABELS_FILE); }` |
| `musicLabelsPath` | 46-47 | 2 | `export function musicLabelsPath() { return join(musicDir(), MUSIC_LABELS_FILE); }` |
| `runtimeCapsulesPath` | 53-54 | 2 | `export function runtimeCapsulesPath() { return join(themeDir(), 'capsules.json'); }` |

### lib/stream.js（139 行 · 3 个函数）

| 函数 | 行号 | 行数 | 签名 |
|------|------|------|------|
| `parseRange` | 35-52 | 18 | `export function parseRange(range, total) {` |
| `pipeFile` | 66-71 | 6 | `export function pipeFile(res, file, range) {` |
| `serveStream` | 80-138 | 59 | `export function serveStream(res, req, file, mime) {` |

### test/e2e/assert-file-usable-check.mjs（120 行 · 1 个函数）

| 函数 | 行号 | 行数 | 签名 |
|------|------|------|------|
| `isItemUsable` | 48-48 | 1 | `const isItemUsable = (item) => !!(item && (item.file \|\| item.name) && typeof item.size === 'number' && item.size >= 0);` |

### test/e2e/auto-console.mjs（38 行 · 1 个函数）

| 函数 | 行号 | 行数 | 签名 |
|------|------|------|------|
| `findNeighbor` | 8-15 | 8 | `function findNeighbor(name, up = 8) {` |

### test/e2e/auto-diag.mjs（56 行 · 1 个函数）

| 函数 | 行号 | 行数 | 签名 |
|------|------|------|------|
| `findNeighbor` | 8-15 | 8 | `function findNeighbor(name, up = 8) {` |

### test/e2e/auto-final.mjs（59 行 · 2 个函数）

| 函数 | 行号 | 行数 | 签名 |
|------|------|------|------|
| `findNeighbor` | 8-15 | 8 | `function findNeighbor(name, up = 8) {` |
| `snap` | 36-48 | 13 | `const snap = async (label) => {` |

### test/e2e/auto-req.mjs（42 行 · 1 个函数）

| 函数 | 行号 | 行数 | 签名 |
|------|------|------|------|
| `findNeighbor` | 8-15 | 8 | `function findNeighbor(name, up = 8) {` |

### test/e2e/auto-run.mjs（60 行 · 2 个函数）

| 函数 | 行号 | 行数 | 签名 |
|------|------|------|------|
| `findNeighbor` | 8-15 | 8 | `function findNeighbor(name, up = 8) {` |
| `snap` | 36-49 | 14 | `const snap = async (label) => {` |

### test/e2e/auto-run2.mjs（61 行 · 2 个函数）

| 函数 | 行号 | 行数 | 签名 |
|------|------|------|------|
| `findNeighbor` | 8-15 | 8 | `function findNeighbor(name, up = 8) {` |
| `snap` | 36-50 | 15 | `const snap = async (label) => {` |

### test/e2e/auto-trace.mjs（40 行 · 1 个函数）

| 函数 | 行号 | 行数 | 签名 |
|------|------|------|------|
| `findNeighbor` | 8-15 | 8 | `function findNeighbor(name, up = 8) {` |

### test/e2e/auto-trace2.mjs（46 行 · 1 个函数）

| 函数 | 行号 | 行数 | 签名 |
|------|------|------|------|
| `findNeighbor` | 8-15 | 8 | `function findNeighbor(name, up = 8) {` |

### test/e2e/boot-auto-video-handoff-check.mjs（109 行 · 1 个函数）

| 函数 | 行号 | 行数 | 签名 |
|------|------|------|------|
| `findNeighbor` | 8-15 | 8 | `function findNeighbor(name, up = 8) {` |

### test/e2e/boot-durations-check.mjs（53 行 · 2 个函数）

| 函数 | 行号 | 行数 | 签名 |
|------|------|------|------|
| `findNeighbor` | 8-15 | 8 | `function findNeighbor(name, up = 8) {` |
| `snap` | 34-41 | 8 | `const snap = async (label) => {` |

### test/e2e/boot-e2e-check.mjs（59 行 · 2 个函数）

| 函数 | 行号 | 行数 | 签名 |
|------|------|------|------|
| `findNeighbor` | 8-15 | 8 | `function findNeighbor(name, up = 8) {` |
| `snap` | 33-46 | 14 | `const snap = async (label) => {` |

### test/e2e/boot-noblack-check.mjs（51 行 · 2 个函数）

| 函数 | 行号 | 行数 | 签名 |
|------|------|------|------|
| `findNeighbor` | 8-15 | 8 | `function findNeighbor(name, up = 8) {` |
| `snap` | 34-41 | 8 | `const snap = async (label) => {` |

### test/e2e/boot-rotate-sim.mjs（38 行 · 2 个函数）

| 函数 | 行号 | 行数 | 签名 |
|------|------|------|------|
| `simulate` | 2-23 | 22 | `function simulate(urls, durationMs, loop, stepCount) {` |
| `step` | 7-16 | 10 | `const step = () => {` |

### test/e2e/boot-timeline.mjs（71 行 · 1 个函数）

| 函数 | 行号 | 行数 | 签名 |
|------|------|------|------|
| `findNeighbor` | 8-15 | 8 | `function findNeighbor(name, up = 8) {` |

### test/e2e/capsules-cache-fallback-check.mjs（117 行 · 2 个函数）

| 函数 | 行号 | 行数 | 签名 |
|------|------|------|------|
| `check` | 29-32 | 4 | `const check = (name, ok, detail) => {` |
| `extractCapsules` | 34-38 | 5 | `const extractCapsules = (js) => {` |

### test/e2e/music-upload-cover-check.mjs（119 行 · 1 个函数）

| 函数 | 行号 | 行数 | 签名 |
|------|------|------|------|
| `musicJson` | 51-54 | 4 | `const musicJson = () => {` |

### test/e2e/plugin-startup-times.mjs（139 行 · 3 个函数）

| 函数 | 行号 | 行数 | 签名 |
|------|------|------|------|
| `pick` | 21-25 | 5 | `const pick = (name, def) => {` |
| `pickInt` | 26-29 | 4 | `const pickInt = (name, def) => {` |
| `authCookie` | 61-67 | 7 | `function authCookie(base) {` |

### test/e2e/theme-swatch-jscolor-check.mjs（92 行 · 1 个函数）

| 函数 | 行号 | 行数 | 签名 |
|------|------|------|------|
| `findNeighbor` | 8-15 | 8 | `function findNeighbor(name, up = 8) {` |

### test/e2e/theme-swatch-preset-switch-check.mjs（100 行 · 1 个函数）

| 函数 | 行号 | 行数 | 签名 |
|------|------|------|------|
| `findNeighbor` | 8-15 | 8 | `function findNeighbor(name, up = 8) {` |

### test/e2e/theme-swatch-screenshots.mjs（93 行 · 1 个函数）

| 函数 | 行号 | 行数 | 签名 |
|------|------|------|------|
| `findNeighbor` | 8-15 | 8 | `function findNeighbor(name, up = 8) {` |

### test/e2e/ui-dock-panels-screenshot.mjs（105 行 · 3 个函数）

| 函数 | 行号 | 行数 | 签名 |
|------|------|------|------|
| `findNeighbor` | 8-15 | 8 | `function findNeighbor(name, up = 8) {` |
| `wait` | 57-57 | 1 | `const wait = (ms) => new Promise((r) => setTimeout(r, ms));` |
| `snap` | 67-71 | 5 | `const snap = async (name) => {` |

### test/e2e/ui-dock-upload-remove-check.mjs（186 行 · 4 个函数）

| 函数 | 行号 | 行数 | 签名 |
|------|------|------|------|
| `findNeighbor` | 8-15 | 8 | `function findNeighbor(name, up = 8) {` |
| `apiList` | 60-63 | 4 | `const apiList = async (p) => {` |
| `wait` | 64-64 | 1 | `const wait = (ms) => new Promise((r) => setTimeout(r, ms));` |
| `shot` | 66-71 | 6 | `const shot = async (page, name) => {` |

### test/e2e/ui-media-no-overlap-check.mjs（70 行 · 1 个函数）

| 函数 | 行号 | 行数 | 签名 |
|------|------|------|------|
| `findNeighbor` | 8-15 | 8 | `function findNeighbor(name, up = 8) {` |

### test/e2e/upload-api-check.mjs（134 行 · 3 个函数）

| 函数 | 行号 | 行数 | 签名 |
|------|------|------|------|
| `ensurePreview` | 30-59 | 30 | `const ensurePreview = () => {` |
| `api` | 61-75 | 15 | `const api = async (method, path, body, ct) => {` |
| `musicDir` | 78-81 | 4 | `const musicDir = () => {` |

### test/e2e/upload-resume-check.mjs（126 行 · 5 个函数）

| 函数 | 行号 | 行数 | 签名 |
|------|------|------|------|
| `check` | 20-23 | 4 | `const check = (name, ok, detail) => {` |
| `makeReq` | 30-35 | 6 | `function makeReq(reqUrl) {` |
| `makeRes` | 36-43 | 8 | `function makeRes() {` |
| `waitDone` | 44-47 | 4 | `async function waitDone(fakeResp, timeout = 2000) {` |
| `pump` | 48-54 | 7 | `async function pump(req, buf, chunkSize = 128 * 1024) {` |

### test/e2e/upload-speed-check.mjs（89 行 · 6 个函数）

| 函数 | 行号 | 行数 | 签名 |
|------|------|------|------|
| `check` | 27-30 | 4 | `const check = (name, ok, detail) => {` |
| `makeReq` | 35-36 | 2 | `function makeReq(url) { const r = new Readable({ read() {} }); r.url = url; r.headers = {}; return r; }` |
| `makeRes` | 36-40 | 5 | `function makeRes() { return { status: 0, body: '', done: false, writeHead(s) { this.status = s; }, end(d) { this.body = String(d \|\| ''); this.done = true; } }; }` |
| `waitDone` | 37-40 | 4 | `async function waitDone(fakeResp, timeout = 60000) {` |
| `pump` | 41-47 | 7 | `async function pump(req, buf, chunk = 256 * 1024) {` |
| `forceLog` | 50-56 | 7 | `function forceLog(line) {` |

### test/e2e/upload-stream-write-check.mjs（157 行 · 4 个函数）

| 函数 | 行号 | 行数 | 签名 |
|------|------|------|------|
| `check` | 20-23 | 4 | `const check = (name, ok, detail) => {` |
| `makeReqRes` | 29-40 | 12 | `function makeReqRes() {` |
| `waitDone` | 42-47 | 6 | `async function waitDone(fakeResp, timeout = 2000) {` |
| `pump` | 49-56 | 8 | `async function pump(req, buf, chunkSize = 64 * 1024, onChunk) {` |

### test/e2e/video-cache-compare.mjs（156 行 · 4 个函数）

| 函数 | 行号 | 行数 | 签名 |
|------|------|------|------|
| `check` | 21-24 | 4 | `const check = (name, ok, detail) => {` |
| `serveOld` | 27-44 | 18 | `function serveOld(res, req, file) {` |
| `serveNew` | 47-78 | 32 | `function serveNew(res, req, file) {` |
| `httpGet` | 81-92 | 12 | `function httpGet(port, path, headers) {` |

### test/e2e/video-handoff-continuity-check.mjs（116 行 · 1 个函数）

| 函数 | 行号 | 行数 | 签名 |
|------|------|------|------|
| `findNeighbor` | 8-15 | 8 | `function findNeighbor(name, up = 8) {` |

### test/run-all.mjs（149 行 · 4 个函数）

| 函数 | 行号 | 行数 | 签名 |
|------|------|------|------|
| `testLogPath` | 23-26 | 4 | `function testLogPath() {` |
| `testLogTs` | 27-31 | 5 | `function testLogTs(d = new Date()) {` |
| `testLogWrite` | 32-38 | 7 | `function testLogWrite(entry) {` |
| `isEnvSensitive` | 89-89 | 1 | `const isEnvSensitive = (name) => ENV_SENSITIVE.some((s) => name.endsWith(s));` |

<!-- dshgp-functions:end -->
