Replace project with current server release and Windows setup
Import the 2026-10-09 source release, Fastify/SQLite backend, restored source assets, and analytics-enabled server build. Replace files from the previous release while retaining the existing repository history. Make builds portable across Windows and Linux, configure local startup, normalize Windows static asset paths, and fix test fixture cleanup and file URL handling. Exclude local environment settings, databases, dependencies, validation output, and TypeScript build cache from version control. Validation: npm ci, static and server builds, 106 arrival tests, and actual local HTTP checks passed. The full suite passed 467 of 470 tests; three tests still require QA fixtures omitted from the supplied release, documented in README-서버실행.md.
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
/** A local presentation preference only. Never pass this state to media/inference. */
|
||||
export const PET_NAME_STORAGE_KEY = 'behind-glass.pet-name.v1';
|
||||
export const PET_NAME_MAX_LENGTH = 20;
|
||||
|
||||
export function normalizePetName(value: string): string {
|
||||
return Array.from(value.normalize('NFC').trim()).slice(0, PET_NAME_MAX_LENGTH).join('');
|
||||
}
|
||||
|
||||
export function petNameForms(value: string) {
|
||||
const name = normalizePetName(value) || '멍멍이';
|
||||
const last = name.codePointAt(name.length - 1) ?? 0;
|
||||
const hasFinalConsonant = last >= 0xac00 && last <= 0xd7a3 && (last - 0xac00) % 28 !== 0;
|
||||
const display = hasFinalConsonant ? `${name}이` : name;
|
||||
return { display, object: `${display}를`, subject: `${display}가`, possessive: `${display}의` };
|
||||
}
|
||||
|
||||
type NameStorage = Pick<Storage, 'getItem' | 'setItem'>;
|
||||
export type PetNameStore = ReturnType<typeof createPetNameStore>;
|
||||
|
||||
export function createPetNameStore(getStorage: () => NameStorage | undefined) {
|
||||
let name = '';
|
||||
let storage: NameStorage | undefined;
|
||||
let storageUnavailable = false;
|
||||
const listeners = new Set<() => void>();
|
||||
try {
|
||||
storage = getStorage();
|
||||
storageUnavailable = !storage;
|
||||
name = normalizePetName(storage?.getItem(PET_NAME_STORAGE_KEY) ?? '');
|
||||
} catch { storageUnavailable = true; }
|
||||
return {
|
||||
get name(): string { return name; },
|
||||
get storageUnavailable(): boolean { return storageUnavailable; },
|
||||
setName(value: string): void {
|
||||
const next = normalizePetName(value);
|
||||
if (next === name) return;
|
||||
name = next;
|
||||
try {
|
||||
storage?.setItem(PET_NAME_STORAGE_KEY, name);
|
||||
storageUnavailable = !storage;
|
||||
} catch { storageUnavailable = true; }
|
||||
listeners.forEach(listener => listener());
|
||||
},
|
||||
subscribe(listener: () => void, signal: AbortSignal): void {
|
||||
if (signal.aborted) return;
|
||||
listeners.add(listener);
|
||||
signal.addEventListener('abort', () => listeners.delete(listener), { once: true });
|
||||
}
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user