[app] SunsetPlace: Wire the town list, the guess and storage into the garden; e2e and offline cover it
This commit is contained in:
@@ -10,7 +10,9 @@
|
||||
"typecheck": "svelte-check --threshold error --output human"
|
||||
},
|
||||
"dependencies": {
|
||||
"@rosea/content": "workspace:*",
|
||||
"@rosea/schema": "workspace:*",
|
||||
"@rosea/storage": "workspace:*",
|
||||
"@rosea/ui": "workspace:*"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -1,7 +1,31 @@
|
||||
<script lang="ts">
|
||||
import { Shell } from '@rosea/ui';
|
||||
import { guessTown } from '@rosea/content/guess';
|
||||
import { openProfile } from '@rosea/storage';
|
||||
import { Shell, type SunsetWiring } from '@rosea/ui';
|
||||
// Bundled at build time, so the letter is precached and opens offline (letter-slot.md L1).
|
||||
import letter from '../../../docs/LETTER.md?raw';
|
||||
|
||||
// The device's own zone, read here and nowhere else: the engine never asks the
|
||||
// device anything (CLAUDE.md §2). Only the zone's name; never GPS, never a lookup.
|
||||
const deviceZone = new Intl.DateTimeFormat().resolvedOptions().timeZone;
|
||||
const profile = openProfile();
|
||||
|
||||
// The town list is large, so it loads on the first search (sunset-place.md P5).
|
||||
// A failed load is forgotten, so the next keystroke tries again.
|
||||
let towns: Promise<typeof import('@rosea/content/places')> | undefined;
|
||||
const loadTowns = (): Promise<typeof import('@rosea/content/places')> =>
|
||||
(towns ??= import('@rosea/content/places').catch((error: unknown) => {
|
||||
towns = undefined;
|
||||
throw error;
|
||||
}));
|
||||
|
||||
const sunset: SunsetWiring = {
|
||||
guess: guessTown(deviceZone),
|
||||
search: async (query) => (await loadTowns()).searchTowns(query),
|
||||
load: () => profile.loadSunsetPlace(),
|
||||
save: (choice) => profile.saveSunsetPlace(choice),
|
||||
now: () => Date.now()
|
||||
};
|
||||
</script>
|
||||
|
||||
<Shell {letter} />
|
||||
<Shell {letter} {sunset} />
|
||||
|
||||
Reference in New Issue
Block a user