feat(wails): move the frontend onto v3's generated bindings
frontend/wailsjs/ is deleted and frontend/bindings/ takes its place — a real TypeScript module tree nested by Go import path, generated by wails3's static analyser rather than by building the app and running it. The @go alias absorbs the constant prefix, so a call site imports '@go/library/library.js' and the codemod over all 93 sites was a specifier rewrite plus splitting @go/models' namespaces into one import per package. The 12 SetContext bindings and the fake `context` model are gone, as Phase 2's ServiceStartup port promised: 272 methods across 12 services, none of them plumbing. @runtime/runtime is now a local shim (src/wails/runtime.ts) over @wailsio/runtime, so the 22 EventsOn imports are untouched. It unwraps v3's WailsEvent into v2's callback shape, which is exact here: nothing in backend/events passes more than one data argument, and v3 only packs arguments into a slice when there is more than one. v3 tells the truth about two things v2 lied about, and that is most of the diff. A Go nil slice really does arrive as JSON null, and a Go named string type really is an enum; v2 typed them as T[] and string. utils/binding.ts states the app's actual contract — an absent list is an empty list — once, at the boundary where it is true, and also drops the CancellablePromise the app never cancels. Four test fixtures widen an enum field back to its value union. Not done, and Phase 5's to fix: frontend/test/support/wails-fake.ts still fakes window.go, which v3 does not have, so `make ui-test` is broken and harness.test.ts fails to compile on EventsEmit. That test also asserts v2 ordering that no longer holds — v3's Events.Emit calls the backend and does not notify in-page listeners at all. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UDCbcCZQepnpSQYJ6SxxZm
This commit is contained in:
@@ -7,8 +7,8 @@ import { classMap } from 'lit/directives/class-map.js';
|
||||
import '@components/page-header/page-header';
|
||||
import { designTokens } from '../../styles/tokens.css';
|
||||
import { srOnly } from '../../styles/sr-only.css';
|
||||
import { SearchLocal, SearchLyrics, GetThumbnail, GetThumbnails, GetArtistImageURL, GetArtistImagesCachedPaths, GetExploreShelves, RecordSearchClick } from '@go/explore/Service';
|
||||
import { GetFilePathsByAlbums, GetFilePathsByRecordingMBIDs } from '@go/library/Library';
|
||||
import { SearchLocal, SearchLyrics, GetThumbnail, GetThumbnails, GetArtistImageURL, GetArtistImagesCachedPaths, GetExploreShelves, RecordSearchClick } from '@go/explore/service.js';
|
||||
import { GetFilePathsByAlbums, GetFilePathsByRecordingMBIDs } from '@go/library/library.js';
|
||||
import { EventsOn } from '@runtime/runtime';
|
||||
import { Events } from '../../events';
|
||||
import { libraryStore } from '../../store/library-store';
|
||||
@@ -21,7 +21,7 @@ import { describeError } from '../../utils/describe-error';
|
||||
import '@awesome.me/webawesome/dist/components/icon/icon.js';
|
||||
import '../library-status-indicator/library-status-indicator.js';
|
||||
import '../top-results-row/top-results-row.js';
|
||||
import { explore } from '@go/models';
|
||||
import * as explore from '@go/explore/models.js';
|
||||
import { ViewLifecycleMixin } from '../../utils/view-lifecycle';
|
||||
import { registerCacheProbe } from '../../utils/cache-stats';
|
||||
import { LRUMap } from '../../utils/lru-map';
|
||||
@@ -34,6 +34,7 @@ import type { ContextMenuHost } from '@utils/context-menu-controller.js';
|
||||
import '@awesome.me/webawesome/dist/components/popup/popup.js';
|
||||
import type WaPopup from '@awesome.me/webawesome/dist/components/popup/popup.js';
|
||||
import '@awesome.me/webawesome/dist/components/dropdown-item/dropdown-item.js';
|
||||
import { dict, dictByName } from '@utils/binding';
|
||||
|
||||
/** The region explore's own action failures (play/queue) are rendered in. */
|
||||
export const ExploreRegion = 'explore';
|
||||
@@ -833,10 +834,10 @@ export class ExploreView extends ViewLifecycleMixin(LitElement) implements Conte
|
||||
// a state this view already renders honestly. A *rejected*
|
||||
// call still reaches the catch below.
|
||||
if (!page || !Array.isArray(page.shelves)) {
|
||||
this.shelves = explore.ShelfPage.createFrom({
|
||||
this.shelves = {
|
||||
shelves: [],
|
||||
state: 'no-index',
|
||||
});
|
||||
};
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -853,10 +854,10 @@ export class ExploreView extends ViewLifecycleMixin(LitElement) implements Conte
|
||||
// Inline, and quietly: the search box above still works, so
|
||||
// this is a panel that could not fill itself rather than
|
||||
// something the user asked for and did not get.
|
||||
this.shelves = explore.ShelfPage.createFrom({
|
||||
this.shelves = {
|
||||
shelves: [],
|
||||
state: 'no-index',
|
||||
});
|
||||
};
|
||||
} finally {
|
||||
this.shelvesPending = false;
|
||||
}
|
||||
@@ -1043,13 +1044,12 @@ export class ExploreView extends ViewLifecycleMixin(LitElement) implements Conte
|
||||
// index has no hits, in which case we keep the owned-library
|
||||
// matches already displayed.
|
||||
const result =
|
||||
(await SearchLocal(query)) ??
|
||||
explore.MBSearchResult.createFrom({
|
||||
(await SearchLocal(query)) ?? {
|
||||
artists: [],
|
||||
releaseGroups: [],
|
||||
recordings: [],
|
||||
topResults: [],
|
||||
});
|
||||
};
|
||||
|
||||
// Discard stale response
|
||||
if (version !== this.searchVersion) {
|
||||
@@ -1131,14 +1131,16 @@ export class ExploreView extends ViewLifecycleMixin(LitElement) implements Conte
|
||||
*/
|
||||
private async albumFilePaths(localId: number): Promise<string[]> {
|
||||
const libraryID = libraryStore.getSelectedLibraryId() ?? 0;
|
||||
const byAlbum = await GetFilePathsByAlbums([localId], libraryID);
|
||||
const byAlbum = await dict(GetFilePathsByAlbums([localId], libraryID));
|
||||
|
||||
return byAlbum[localId] ?? [];
|
||||
}
|
||||
|
||||
private async recordingFilePath(mbid: string): Promise<string | null> {
|
||||
const libraryID = libraryStore.getSelectedLibraryId() ?? 0;
|
||||
const byMBID = await GetFilePathsByRecordingMBIDs([mbid], libraryID);
|
||||
const byMBID = await dictByName(
|
||||
GetFilePathsByRecordingMBIDs([mbid], libraryID),
|
||||
);
|
||||
|
||||
return byMBID[mbid]?.[0] ?? null;
|
||||
}
|
||||
@@ -2018,7 +2020,7 @@ export class ExploreView extends ViewLifecycleMixin(LitElement) implements Conte
|
||||
// of nothing.
|
||||
if (!page) return nothing;
|
||||
|
||||
if (page.shelves.length === 0) {
|
||||
if (!page.shelves?.length) {
|
||||
return html`
|
||||
<div class="shelves-empty">
|
||||
<wa-icon
|
||||
@@ -2048,7 +2050,7 @@ export class ExploreView extends ViewLifecycleMixin(LitElement) implements Conte
|
||||
to come.
|
||||
</p>`
|
||||
: nothing}
|
||||
${page.shelves.map((shelf) =>
|
||||
${(page.shelves ?? []).map((shelf) =>
|
||||
shelf.artists?.length
|
||||
? this.renderArtistsSection(
|
||||
shelf.artists,
|
||||
|
||||
Reference in New Issue
Block a user