Skip to content

refactor(frontend): fold main.ts / main.web.ts / main.capacitor.ts into bootstrapApp - #324

Merged
attson merged 1 commit into
mainfrom
refactor/bootstrap-app
Aug 4, 2026
Merged

refactor(frontend): fold main.ts / main.web.ts / main.capacitor.ts into bootstrapApp#324
attson merged 1 commit into
mainfrom
refactor/bootstrap-app

Conversation

@attson

@attson attson commented Aug 4, 2026

Copy link
Copy Markdown
Owner

Summary

Milestone 7-d. The three Vite entry points open-coded the same six-step boot sequence:

  1. `await initI18n({ loadPreference, savePreference })`
  2. `bridgeSharedI18n()`
  3. platform-specific pre-mount setup
  4. `initPlatform()`
  5. `createApp(App).use(Pinia).provide('platform').mount('#app')`
  6. platform-specific post-mount side effects

Steps 1, 2, 4, 5 were identical text. Steps 3 and 6 were the only things that actually differed (Wails: `EventsOn` wire; web: prefsSync engine wiring; capacitor: iOS keyboard accessory + capacitor prefsSync + locale storage helpers). Three copies of the same boilerplate had already drifted — the web entry silently missed the shared-i18n locale bridge for a stretch, capacitor forgot the `prefs:changed` hook that Wails installs, etc.

Fold the common path into `lib/bootstrapApp.ts` with a `bootstrapApp({ i18n, createPlatform, beforeMount?, afterMount? })` API. Each main.* becomes a small config object naming what actually differs:

file before after
main.ts 35 21
main.web.ts 42 26
main.capacitor.ts 65 50
bootstrapApp.ts +66

Behavior is preserved verbatim per entry — same load/save locale hooks, same platform factory, same prefsSync engines wired at the same point, same `EventsOn` hook, same iOS keyboard toggle. The shared-i18n locale bridge, previously a copy in each file, now runs unconditionally in `bootstrapApp` (matches what all three were already doing).

Test update: `App.test.ts > capacitor uses the shared web shell` was scanning main.capacitor.ts for `import App from './App.vue'` + `createApp(App)`; both moved into bootstrapApp.ts. The test now checks that capacitor main calls `bootstrapApp(` with `createCapacitorPlatform` and never re-introduces the old MobileApp shell.

Test plan

  • `npm test` 1631/1631
  • `npm run build` (vue-tsc + vite) green
  • Manual: `wails dev` boots (Wails path), `npm run dev` boots (web path), Capacitor build syncs (iOS path)

…to bootstrapApp

M7-d. The three Vite entry points open-coded the same six-step boot
sequence:

  1. await initI18n({ loadPreference, savePreference })
  2. bridgeSharedI18n()
  3. platform-specific pre-mount setup
  4. initPlatform(<factory>)
  5. createApp(App).use(Pinia).provide('platform').mount('#app')
  6. platform-specific post-mount side effects

Steps 1, 2, 4, 5 were identical text. Steps 3 and 6 were the *only*
things that actually differed (Wails: EventsOn wire; web: prefsSync
engine wiring; capacitor: iOS keyboard accessory + capacitor prefsSync
+ locale storage helpers). Three copies of the same boilerplate had
already drifted — the web entry silently missed the shared-i18n
locale bridge for a stretch, capacitor forgot the prefs:changed hook
that Wails installs, etc.

Fold the common path into `lib/bootstrapApp.ts` with a
`bootstrapApp({ i18n, createPlatform, beforeMount?, afterMount? })`
API. Each main.* becomes a small config object naming what actually
differs:

  main.ts           35 → 21 lines
  main.web.ts       42 → 26 lines
  main.capacitor.ts 65 → 50 lines
  bootstrapApp.ts   new 66 lines

Behavior is preserved verbatim per entry — same load/save locale hooks,
same platform factory, same prefsSync engines wired at the same point,
same EventsOn hook, same iOS keyboard toggle. The shared-i18n locale
bridge, previously a copy in each file, now runs unconditionally in
bootstrapApp (matches what all three were already doing).

Test update: `App.test.ts > capacitor uses the shared web shell` was
scanning main.capacitor.ts for `import App from './App.vue'` +
`createApp(App)`; both moved into bootstrapApp.ts. The test now checks
that capacitor main calls `bootstrapApp(` with `createCapacitorPlatform`
and never re-introduces the old MobileApp shell.

`npm test` 1631/1631; `npm run build` green.
@attson
attson merged commit 864e9e4 into main Aug 4, 2026
13 of 14 checks passed
@attson
attson deleted the refactor/bootstrap-app branch August 4, 2026 12:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant