Download static/search/execution/application/controller.js from VoiceOfML/Search: direct link, hf CLI and curl.
- Browser
- Download file 2.17 kB
-
https://huggingface.co/spaces/VoiceOfML/Search/resolve/main/static/search/execution/application/controller.js
- Command line
-
hf download hf://spaces/VoiceOfML/Search/static/search/execution/application/controller.js
-
curl -L -o controller.js https://huggingface.co/spaces/VoiceOfML/Search/resolve/main/static/search/execution/application/controller.js
2.17 kB
| // Owns the API attempt and completion. The host publishes request ownership | |
| // synchronously after cancellation, cache consumption and position preparation. | |
| (function () { | |
| /** @param {SearchExecutionDependencies} deps */ | |
| function create(deps) { | |
| /** @param {VoiceOfMLSearchRequestBody} requestBody @param {boolean} append @param {boolean} recoveringFirstPage @param {number} requestId */ | |
| async function execute(requestBody, append, recoveringFirstPage, requestId) { | |
| const current = () => requestId === deps.readView().requestId; | |
| let pagingSucceeded = false; | |
| let pagingError = null; | |
| try { | |
| const data = await deps.search(requestBody); | |
| if (!current()) return; | |
| if (!deps.applyPage(data, append)) { | |
| deps.hideLoading(); | |
| return; | |
| } | |
| deps.renderPage(append); | |
| deps.update({ page: deps.readView().loadedPage }); | |
| pagingSucceeded = true; | |
| deps.updateStatus(); | |
| deps.updateLoadInfo(); | |
| deps.syncURL(); | |
| deps.prefetch(); | |
| deps.warmConnection(); | |
| } catch (error) { | |
| const err = /** @type {Error} */ (error); | |
| if (!current()) return; | |
| if (append) deps.update({ page: Math.max(1, deps.readView().loadedPage) }); | |
| if (err.name === "AbortError") return; | |
| pagingError = err; | |
| if (!append) deps.update({ hasMore: true }); | |
| console.error("搜索失败:", err); | |
| if (!append && !recoveringFirstPage) deps.notify("搜索失败"); | |
| } finally { | |
| if (current()) { | |
| deps.update({ _pendingPage: 0, isLoading: false }); | |
| if (!append && pagingError) deps.clearSkeleton(); | |
| deps.hideLoading(); | |
| if (!append) deps.visualLoading(false); | |
| else deps.updateStatus(); | |
| if (!append) deps.finishPresentation(); | |
| if (globalThis.VoiceOfMLSearchExecutionPolicy.finishPaging(append, recoveringFirstPage, pagingSucceeded, pagingError)) deps.finishPaging(pagingSucceeded, pagingError); | |
| else deps.updatePaging(); | |
| } | |
| } | |
| } | |
| return { execute }; | |
| } | |
| globalThis.VoiceOfMLSearchExecution = { create }; | |
| })(); | |