32 lines
1.3 KiB
Svelte
32 lines
1.3 KiB
Svelte
<script lang="ts">
|
|
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} {sunset} />
|