/** The path the site is served under: the editor, the play page, the API and every data file. */ export const SITE_PATH = '/feuerwerk/'; /** The API's one entry point. */ export const API_ENDPOINT = `${SITE_PATH}api/index.php`; /** Where the uploaded files of one kind are served, e.g. `dataPath('textures')`. */ export function dataPath(kind: string): string { return `${SITE_PATH}data/${kind}`; } /** The prefix of every `localStorage` key while the editor was called Game Maker. */ const OLD_KEY_PREFIX = 'game-maker.'; const KEY_PREFIX = 'feuerwerk.'; type KeyStore = Pick; /** * Moves what a browser kept under the old name to the new one: settings, panel sizes, folds and * saves survive the rename. A key the new name already has keeps its value. Answers how many moved. */ export function moveOldStoredKeys(storage: KeyStore): number { const old: string[] = []; for (let i = 0; i < storage.length; i++) { const key = storage.key(i); if (key?.startsWith(OLD_KEY_PREFIX)) old.push(key); } let moved = 0; for (const key of old) { const value = storage.getItem(key); const renamed = KEY_PREFIX + key.slice(OLD_KEY_PREFIX.length); if (value !== null && storage.getItem(renamed) === null) { storage.setItem(renamed, value); moved++; } storage.removeItem(key); } return moved; }