mirror of
https://github.com/NohamR/Pocket-Bird.git
synced 2026-05-25 04:07:23 +00:00
Fix type hints
This commit is contained in:
19
dist/birb.js
vendored
19
dist/birb.js
vendored
@@ -48,6 +48,7 @@ const DEFAULT_SETTINGS = {
|
||||
* @typedef {typeof DEFAULT_SETTINGS} Settings
|
||||
*/
|
||||
|
||||
/** @type {Partial<Settings>} */
|
||||
let userSettings = {};
|
||||
|
||||
const STYLESHEET = `:root {
|
||||
@@ -397,6 +398,7 @@ class Layer {
|
||||
|
||||
class Frame {
|
||||
|
||||
/** @type {{ [tag: string]: string[][] }} */
|
||||
#pixelsByTag = {};
|
||||
|
||||
/**
|
||||
@@ -523,6 +525,7 @@ const HEART_BORDER = "heart-border";
|
||||
const HEART_SHINE = "heart-shine";
|
||||
const FEATHER_SPINE = "feather-spine";
|
||||
|
||||
/** @type {Record<string, string>} */
|
||||
const SPRITE_SHEET_COLOR_MAP = {
|
||||
"transparent": TRANSPARENT,
|
||||
"#ffffff": BORDER,
|
||||
@@ -566,11 +569,13 @@ class BirdType {
|
||||
[HOOD]: colors.face,
|
||||
[NOSE]: colors.face,
|
||||
};
|
||||
/** @type {Record<string, string>} */
|
||||
this.colors = { ...defaultColors, ...colors, [THEME_HIGHLIGHT]: colors[THEME_HIGHLIGHT] ?? colors.hood ?? colors.face };
|
||||
this.tags = tags;
|
||||
}
|
||||
}
|
||||
|
||||
/** @type {Record<string, BirdType>} */
|
||||
const species = {
|
||||
bluebird: new BirdType("Eastern Bluebird",
|
||||
"Native to North American and very social, though can be timid around people.", {
|
||||
@@ -1013,6 +1018,7 @@ Promise.all([loadSpriteSheetPixels(SPRITE_SHEET), loadSpriteSheetPixels(DECORATI
|
||||
/** @type {HTMLElement|null} */
|
||||
let focusedElement = null;
|
||||
let lastActionTimestamp = Date.now();
|
||||
/** @type {number[]} */
|
||||
let petStack = [];
|
||||
let currentSpecies = DEFAULT_BIRD;
|
||||
let unlockedSpecies = [DEFAULT_BIRD];
|
||||
@@ -1034,6 +1040,7 @@ Promise.all([loadSpriteSheetPixels(SPRITE_SHEET), loadSpriteSheetPixels(DECORATI
|
||||
}
|
||||
|
||||
function load() {
|
||||
/** @type {Record<string, any>} */
|
||||
let saveData = {};
|
||||
if (isUserScript()) {
|
||||
log("Loading save data from UserScript storage");
|
||||
@@ -1065,6 +1072,7 @@ Promise.all([loadSpriteSheetPixels(SPRITE_SHEET), loadSpriteSheetPixels(DECORATI
|
||||
}
|
||||
|
||||
function save() {
|
||||
/** @type {Record<string, any>} */
|
||||
let saveData = {
|
||||
unlockedSpecies: unlockedSpecies,
|
||||
currentSpecies: currentSpecies,
|
||||
@@ -1172,11 +1180,14 @@ Promise.all([loadSpriteSheetPixels(SPRITE_SHEET), loadSpriteSheetPixels(DECORATI
|
||||
|
||||
const textarea = noteElement.querySelector(".birb-sticky-note-input");
|
||||
if (textarea && textarea instanceof HTMLTextAreaElement) {
|
||||
/** @type {NodeJS.Timeout | undefined} */
|
||||
let saveTimeout;
|
||||
// Save after debounce
|
||||
textarea.addEventListener("input", () => {
|
||||
stickyNote.content = textarea.value;
|
||||
clearTimeout(saveTimeout);
|
||||
if (saveTimeout) {
|
||||
clearTimeout(saveTimeout);
|
||||
}
|
||||
saveTimeout = setTimeout(() => {
|
||||
save();
|
||||
}, 250);
|
||||
@@ -1220,15 +1231,13 @@ Promise.all([loadSpriteSheetPixels(SPRITE_SHEET), loadSpriteSheetPixels(DECORATI
|
||||
/** @type {Record<string, string>} */
|
||||
const stickyNoteParams = stickyNoteUrl.split("?")[1]?.split("&").reduce((params, param) => {
|
||||
const [key, value] = param.split("=");
|
||||
params[key] = value;
|
||||
return params;
|
||||
return {...params, [key]: value};
|
||||
}, {});
|
||||
|
||||
/** @type {Record<string, string>} */
|
||||
const currentParams = currentUrl.split("?")[1]?.split("&").reduce((params, param) => {
|
||||
const [key, value] = param.split("=");
|
||||
params[key] = value;
|
||||
return params;
|
||||
return {...params, [key]: value};
|
||||
}, {});
|
||||
|
||||
debug("Comparing params: ", stickyNoteParams, currentParams);
|
||||
|
||||
Reference in New Issue
Block a user