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:
@@ -34,7 +34,14 @@ import { fixture, shadow, shadowAll, update } from '@test/support/render';
|
||||
|
||||
const SEARCH = 'explore.Service.SearchLocal';
|
||||
|
||||
function request(overrides: Partial<Request>): Request {
|
||||
// v3's bindings type `state` and `entity` as real enums where v2 typed
|
||||
// them as strings; the fixture widens both back to their value unions.
|
||||
type RequestOverrides = Partial<Omit<Request, 'state' | 'entity'>> & {
|
||||
state?: `${Request['state']}`;
|
||||
entity?: `${Request['entity']}`;
|
||||
};
|
||||
|
||||
function request(overrides: RequestOverrides): Request {
|
||||
return {
|
||||
id: 1,
|
||||
mbid: 'rg-wanted',
|
||||
|
||||
@@ -22,7 +22,7 @@ describe('component-tier harness', () => {
|
||||
it('routes generated bindings through the fake, not a module mock', async () => {
|
||||
// The import path under test is the real generated stub, which does
|
||||
// window['go']['queue']['Queue']['GetState']().
|
||||
const Queue = await import('@go/queue/Queue');
|
||||
const Queue = await import('@go/queue/queue.js');
|
||||
|
||||
wails.stub('queue.Queue.GetState', { currentIndex: 4 });
|
||||
|
||||
@@ -31,7 +31,7 @@ describe('component-tier harness', () => {
|
||||
});
|
||||
|
||||
it('resolves an unstubbed binding instead of hanging', async () => {
|
||||
const Queue = await import('@go/queue/Queue');
|
||||
const Queue = await import('@go/queue/queue.js');
|
||||
|
||||
// The real trap this pays for is the reverse: a *real* binding
|
||||
// called with wrong argument types never settles. Here, silence is
|
||||
|
||||
@@ -33,10 +33,22 @@ function view(id: string, state: string): DownloadView {
|
||||
}
|
||||
|
||||
function provider(id: number, enabled: boolean): DownloadProvider {
|
||||
return { id, name: `p${id}`, enabled, kind: 'test' } as DownloadProvider;
|
||||
return {
|
||||
id,
|
||||
name: `p${id}`,
|
||||
enabled,
|
||||
kind: 'test',
|
||||
} as unknown as DownloadProvider;
|
||||
}
|
||||
|
||||
function request(overrides: Partial<Request>): Request {
|
||||
// v3's bindings type `state` and `entity` as real enums where v2 typed
|
||||
// them as strings; the fixture widens both back to their value unions.
|
||||
type RequestOverrides = Partial<Omit<Request, 'state' | 'entity'>> & {
|
||||
state?: `${Request['state']}`;
|
||||
entity?: `${Request['entity']}`;
|
||||
};
|
||||
|
||||
function request(overrides: RequestOverrides): Request {
|
||||
return {
|
||||
id: 1,
|
||||
mbid: 'abc',
|
||||
|
||||
@@ -17,7 +17,16 @@ import {
|
||||
import { Events } from '../../src/events';
|
||||
import { emit, calls, stub, flush } from '@test/support/harness';
|
||||
|
||||
function job(overrides: Partial<Job> & { id: string }): Job {
|
||||
// v3's bindings type `state` and `kind` as real enums where v2 typed
|
||||
// them as strings, so the fixture widens both back to their value
|
||||
// unions — which is still literal-checked, just not enum-checked.
|
||||
type JobOverrides = Partial<Omit<Job, 'state' | 'kind'>> & {
|
||||
id: string;
|
||||
state?: `${Job['state']}`;
|
||||
kind?: `${Job['kind']}`;
|
||||
};
|
||||
|
||||
function job(overrides: JobOverrides): Job {
|
||||
return {
|
||||
kind: 'library-scan',
|
||||
state: 'running',
|
||||
@@ -43,7 +52,7 @@ describe('job predicates', () => {
|
||||
});
|
||||
|
||||
it('treats every in-flight state, including paused, as active', () => {
|
||||
const states = ['queued', 'running', 'pausing', 'paused', 'cancelling'];
|
||||
const states = ['queued', 'running', 'pausing', 'paused', 'cancelling'] as const;
|
||||
|
||||
expect(states.map((state) => isActive(job({ id: state, state })))).toEqual([
|
||||
true,
|
||||
|
||||
Reference in New Issue
Block a user