mirror of
https://github.com/NohamR/Pocket-Bird.git
synced 2026-05-24 19:59:36 +00:00
Enforce enum types
This commit is contained in:
BIN
dist/extension.zip
vendored
BIN
dist/extension.zip
vendored
Binary file not shown.
34
dist/extension/birb.js
vendored
34
dist/extension/birb.js
vendored
@@ -542,11 +542,7 @@
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Palette color names
|
||||
* @type {Record<string, string>}
|
||||
*/
|
||||
const PALETTE = {
|
||||
const PALETTE = Object.freeze(/** @type {const} */ ({
|
||||
THEME_HIGHLIGHT: "theme-highlight",
|
||||
TRANSPARENT: "transparent",
|
||||
OUTLINE: "outline",
|
||||
@@ -578,11 +574,13 @@
|
||||
HEART_BORDER: "heart-border",
|
||||
HEART_SHINE: "heart-shine",
|
||||
FEATHER_SPINE: "feather-spine",
|
||||
};
|
||||
}));
|
||||
|
||||
/** @typedef {typeof PALETTE[keyof typeof PALETTE]} PaletteColor */
|
||||
|
||||
/**
|
||||
* Mapping of sprite sheet colors to palette colors
|
||||
* @type {Record<string, string>}
|
||||
* @type {Record<string, PaletteColor>}
|
||||
*/
|
||||
const SPRITE_SHEET_COLOR_MAP = {
|
||||
"transparent": PALETTE.TRANSPARENT,
|
||||
@@ -618,6 +616,28 @@
|
||||
"#373737": PALETTE.FEATHER_SPINE,
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @type {Partial<Record<PaletteColor, PaletteColor>>}
|
||||
*/
|
||||
({
|
||||
[PALETTE.HOOD]: PALETTE.FACE,
|
||||
[PALETTE.EYEBROW]: PALETTE.FACE,
|
||||
[PALETTE.UPPER_EYELID]: PALETTE.EYEBROW,
|
||||
[PALETTE.UPPER_CORNER_EYE]: PALETTE.EYEBROW,
|
||||
[PALETTE.BEHIND_EYE]: PALETTE.FACE,
|
||||
[PALETTE.CORNER_EYE]: PALETTE.FACE,
|
||||
[PALETTE.TEMPLE]: PALETTE.FACE,
|
||||
[PALETTE.LOWER_EYELID]: PALETTE.FACE,
|
||||
[PALETTE.NOSE]: PALETTE.FACE,
|
||||
[PALETTE.NOSE_TIP]: PALETTE.NOSE,
|
||||
[PALETTE.CHEEK]: PALETTE.FACE,
|
||||
[PALETTE.SCRUFF]: PALETTE.FACE,
|
||||
[PALETTE.COLLAR]: PALETTE.FACE,
|
||||
[PALETTE.COLLAR_SCRUFF]: PALETTE.COLLAR,
|
||||
[PALETTE.WING_SPOTS]: PALETTE.WING,
|
||||
});
|
||||
|
||||
const RARITY = Object.freeze(/** @type {const} */ ({
|
||||
FAMILIAR: "familiar",
|
||||
UNCOMMON: "uncommon"
|
||||
|
||||
34
dist/obsidian/main.js
vendored
34
dist/obsidian/main.js
vendored
@@ -547,11 +547,7 @@ module.exports = class PocketBird extends Plugin {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Palette color names
|
||||
* @type {Record<string, string>}
|
||||
*/
|
||||
const PALETTE = {
|
||||
const PALETTE = Object.freeze(/** @type {const} */ ({
|
||||
THEME_HIGHLIGHT: "theme-highlight",
|
||||
TRANSPARENT: "transparent",
|
||||
OUTLINE: "outline",
|
||||
@@ -583,11 +579,13 @@ module.exports = class PocketBird extends Plugin {
|
||||
HEART_BORDER: "heart-border",
|
||||
HEART_SHINE: "heart-shine",
|
||||
FEATHER_SPINE: "feather-spine",
|
||||
};
|
||||
}));
|
||||
|
||||
/** @typedef {typeof PALETTE[keyof typeof PALETTE]} PaletteColor */
|
||||
|
||||
/**
|
||||
* Mapping of sprite sheet colors to palette colors
|
||||
* @type {Record<string, string>}
|
||||
* @type {Record<string, PaletteColor>}
|
||||
*/
|
||||
const SPRITE_SHEET_COLOR_MAP = {
|
||||
"transparent": PALETTE.TRANSPARENT,
|
||||
@@ -623,6 +621,28 @@ module.exports = class PocketBird extends Plugin {
|
||||
"#373737": PALETTE.FEATHER_SPINE,
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @type {Partial<Record<PaletteColor, PaletteColor>>}
|
||||
*/
|
||||
({
|
||||
[PALETTE.HOOD]: PALETTE.FACE,
|
||||
[PALETTE.EYEBROW]: PALETTE.FACE,
|
||||
[PALETTE.UPPER_EYELID]: PALETTE.EYEBROW,
|
||||
[PALETTE.UPPER_CORNER_EYE]: PALETTE.EYEBROW,
|
||||
[PALETTE.BEHIND_EYE]: PALETTE.FACE,
|
||||
[PALETTE.CORNER_EYE]: PALETTE.FACE,
|
||||
[PALETTE.TEMPLE]: PALETTE.FACE,
|
||||
[PALETTE.LOWER_EYELID]: PALETTE.FACE,
|
||||
[PALETTE.NOSE]: PALETTE.FACE,
|
||||
[PALETTE.NOSE_TIP]: PALETTE.NOSE,
|
||||
[PALETTE.CHEEK]: PALETTE.FACE,
|
||||
[PALETTE.SCRUFF]: PALETTE.FACE,
|
||||
[PALETTE.COLLAR]: PALETTE.FACE,
|
||||
[PALETTE.COLLAR_SCRUFF]: PALETTE.COLLAR,
|
||||
[PALETTE.WING_SPOTS]: PALETTE.WING,
|
||||
});
|
||||
|
||||
const RARITY = Object.freeze(/** @type {const} */ ({
|
||||
FAMILIAR: "familiar",
|
||||
UNCOMMON: "uncommon"
|
||||
|
||||
34
dist/userscript/birb.user.js
vendored
34
dist/userscript/birb.user.js
vendored
@@ -556,11 +556,7 @@
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Palette color names
|
||||
* @type {Record<string, string>}
|
||||
*/
|
||||
const PALETTE = {
|
||||
const PALETTE = Object.freeze(/** @type {const} */ ({
|
||||
THEME_HIGHLIGHT: "theme-highlight",
|
||||
TRANSPARENT: "transparent",
|
||||
OUTLINE: "outline",
|
||||
@@ -592,11 +588,13 @@
|
||||
HEART_BORDER: "heart-border",
|
||||
HEART_SHINE: "heart-shine",
|
||||
FEATHER_SPINE: "feather-spine",
|
||||
};
|
||||
}));
|
||||
|
||||
/** @typedef {typeof PALETTE[keyof typeof PALETTE]} PaletteColor */
|
||||
|
||||
/**
|
||||
* Mapping of sprite sheet colors to palette colors
|
||||
* @type {Record<string, string>}
|
||||
* @type {Record<string, PaletteColor>}
|
||||
*/
|
||||
const SPRITE_SHEET_COLOR_MAP = {
|
||||
"transparent": PALETTE.TRANSPARENT,
|
||||
@@ -632,6 +630,28 @@
|
||||
"#373737": PALETTE.FEATHER_SPINE,
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @type {Partial<Record<PaletteColor, PaletteColor>>}
|
||||
*/
|
||||
({
|
||||
[PALETTE.HOOD]: PALETTE.FACE,
|
||||
[PALETTE.EYEBROW]: PALETTE.FACE,
|
||||
[PALETTE.UPPER_EYELID]: PALETTE.EYEBROW,
|
||||
[PALETTE.UPPER_CORNER_EYE]: PALETTE.EYEBROW,
|
||||
[PALETTE.BEHIND_EYE]: PALETTE.FACE,
|
||||
[PALETTE.CORNER_EYE]: PALETTE.FACE,
|
||||
[PALETTE.TEMPLE]: PALETTE.FACE,
|
||||
[PALETTE.LOWER_EYELID]: PALETTE.FACE,
|
||||
[PALETTE.NOSE]: PALETTE.FACE,
|
||||
[PALETTE.NOSE_TIP]: PALETTE.NOSE,
|
||||
[PALETTE.CHEEK]: PALETTE.FACE,
|
||||
[PALETTE.SCRUFF]: PALETTE.FACE,
|
||||
[PALETTE.COLLAR]: PALETTE.FACE,
|
||||
[PALETTE.COLLAR_SCRUFF]: PALETTE.COLLAR,
|
||||
[PALETTE.WING_SPOTS]: PALETTE.WING,
|
||||
});
|
||||
|
||||
const RARITY = Object.freeze(/** @type {const} */ ({
|
||||
FAMILIAR: "familiar",
|
||||
UNCOMMON: "uncommon"
|
||||
|
||||
34
dist/web/birb.embed.js
vendored
34
dist/web/birb.embed.js
vendored
@@ -542,11 +542,7 @@
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Palette color names
|
||||
* @type {Record<string, string>}
|
||||
*/
|
||||
const PALETTE = {
|
||||
const PALETTE = Object.freeze(/** @type {const} */ ({
|
||||
THEME_HIGHLIGHT: "theme-highlight",
|
||||
TRANSPARENT: "transparent",
|
||||
OUTLINE: "outline",
|
||||
@@ -578,11 +574,13 @@
|
||||
HEART_BORDER: "heart-border",
|
||||
HEART_SHINE: "heart-shine",
|
||||
FEATHER_SPINE: "feather-spine",
|
||||
};
|
||||
}));
|
||||
|
||||
/** @typedef {typeof PALETTE[keyof typeof PALETTE]} PaletteColor */
|
||||
|
||||
/**
|
||||
* Mapping of sprite sheet colors to palette colors
|
||||
* @type {Record<string, string>}
|
||||
* @type {Record<string, PaletteColor>}
|
||||
*/
|
||||
const SPRITE_SHEET_COLOR_MAP = {
|
||||
"transparent": PALETTE.TRANSPARENT,
|
||||
@@ -618,6 +616,28 @@
|
||||
"#373737": PALETTE.FEATHER_SPINE,
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @type {Partial<Record<PaletteColor, PaletteColor>>}
|
||||
*/
|
||||
({
|
||||
[PALETTE.HOOD]: PALETTE.FACE,
|
||||
[PALETTE.EYEBROW]: PALETTE.FACE,
|
||||
[PALETTE.UPPER_EYELID]: PALETTE.EYEBROW,
|
||||
[PALETTE.UPPER_CORNER_EYE]: PALETTE.EYEBROW,
|
||||
[PALETTE.BEHIND_EYE]: PALETTE.FACE,
|
||||
[PALETTE.CORNER_EYE]: PALETTE.FACE,
|
||||
[PALETTE.TEMPLE]: PALETTE.FACE,
|
||||
[PALETTE.LOWER_EYELID]: PALETTE.FACE,
|
||||
[PALETTE.NOSE]: PALETTE.FACE,
|
||||
[PALETTE.NOSE_TIP]: PALETTE.NOSE,
|
||||
[PALETTE.CHEEK]: PALETTE.FACE,
|
||||
[PALETTE.SCRUFF]: PALETTE.FACE,
|
||||
[PALETTE.COLLAR]: PALETTE.FACE,
|
||||
[PALETTE.COLLAR_SCRUFF]: PALETTE.COLLAR,
|
||||
[PALETTE.WING_SPOTS]: PALETTE.WING,
|
||||
});
|
||||
|
||||
const RARITY = Object.freeze(/** @type {const} */ ({
|
||||
FAMILIAR: "familiar",
|
||||
UNCOMMON: "uncommon"
|
||||
|
||||
34
dist/web/birb.js
vendored
34
dist/web/birb.js
vendored
@@ -542,11 +542,7 @@
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Palette color names
|
||||
* @type {Record<string, string>}
|
||||
*/
|
||||
const PALETTE = {
|
||||
const PALETTE = Object.freeze(/** @type {const} */ ({
|
||||
THEME_HIGHLIGHT: "theme-highlight",
|
||||
TRANSPARENT: "transparent",
|
||||
OUTLINE: "outline",
|
||||
@@ -578,11 +574,13 @@
|
||||
HEART_BORDER: "heart-border",
|
||||
HEART_SHINE: "heart-shine",
|
||||
FEATHER_SPINE: "feather-spine",
|
||||
};
|
||||
}));
|
||||
|
||||
/** @typedef {typeof PALETTE[keyof typeof PALETTE]} PaletteColor */
|
||||
|
||||
/**
|
||||
* Mapping of sprite sheet colors to palette colors
|
||||
* @type {Record<string, string>}
|
||||
* @type {Record<string, PaletteColor>}
|
||||
*/
|
||||
const SPRITE_SHEET_COLOR_MAP = {
|
||||
"transparent": PALETTE.TRANSPARENT,
|
||||
@@ -618,6 +616,28 @@
|
||||
"#373737": PALETTE.FEATHER_SPINE,
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @type {Partial<Record<PaletteColor, PaletteColor>>}
|
||||
*/
|
||||
({
|
||||
[PALETTE.HOOD]: PALETTE.FACE,
|
||||
[PALETTE.EYEBROW]: PALETTE.FACE,
|
||||
[PALETTE.UPPER_EYELID]: PALETTE.EYEBROW,
|
||||
[PALETTE.UPPER_CORNER_EYE]: PALETTE.EYEBROW,
|
||||
[PALETTE.BEHIND_EYE]: PALETTE.FACE,
|
||||
[PALETTE.CORNER_EYE]: PALETTE.FACE,
|
||||
[PALETTE.TEMPLE]: PALETTE.FACE,
|
||||
[PALETTE.LOWER_EYELID]: PALETTE.FACE,
|
||||
[PALETTE.NOSE]: PALETTE.FACE,
|
||||
[PALETTE.NOSE_TIP]: PALETTE.NOSE,
|
||||
[PALETTE.CHEEK]: PALETTE.FACE,
|
||||
[PALETTE.SCRUFF]: PALETTE.FACE,
|
||||
[PALETTE.COLLAR]: PALETTE.FACE,
|
||||
[PALETTE.COLLAR_SCRUFF]: PALETTE.COLLAR,
|
||||
[PALETTE.WING_SPOTS]: PALETTE.WING,
|
||||
});
|
||||
|
||||
const RARITY = Object.freeze(/** @type {const} */ ({
|
||||
FAMILIAR: "familiar",
|
||||
UNCOMMON: "uncommon"
|
||||
|
||||
@@ -152,8 +152,9 @@ function getColor(part) {
|
||||
if (currentSpecies.colors[part]) {
|
||||
return currentSpecies.colors[part];
|
||||
}
|
||||
if (DEFAULT_COLOR_OVERRIDES[part]) {
|
||||
return getColor(DEFAULT_COLOR_OVERRIDES[part]);
|
||||
const override = DEFAULT_COLOR_OVERRIDES[/** @type {keyof typeof DEFAULT_COLOR_OVERRIDES} */ (part)];
|
||||
if (override) {
|
||||
return getColor(override);
|
||||
}
|
||||
for (const [color, partName] of Object.entries(COLOR_MAP)) {
|
||||
if (partName === part) {
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
import species from "../species.js"
|
||||
|
||||
/**
|
||||
* Palette color names
|
||||
* @type {Record<string, string>}
|
||||
*/
|
||||
export const PALETTE = {
|
||||
export const PALETTE = Object.freeze(/** @type {const} */ ({
|
||||
THEME_HIGHLIGHT: "theme-highlight",
|
||||
TRANSPARENT: "transparent",
|
||||
OUTLINE: "outline",
|
||||
@@ -36,11 +32,13 @@ export const PALETTE = {
|
||||
HEART_BORDER: "heart-border",
|
||||
HEART_SHINE: "heart-shine",
|
||||
FEATHER_SPINE: "feather-spine",
|
||||
};
|
||||
}));
|
||||
|
||||
/** @typedef {typeof PALETTE[keyof typeof PALETTE]} PaletteColor */
|
||||
|
||||
/**
|
||||
* Mapping of sprite sheet colors to palette colors
|
||||
* @type {Record<string, string>}
|
||||
* @type {Record<string, PaletteColor>}
|
||||
*/
|
||||
export const SPRITE_SHEET_COLOR_MAP = {
|
||||
"transparent": PALETTE.TRANSPARENT,
|
||||
@@ -78,7 +76,7 @@ export const SPRITE_SHEET_COLOR_MAP = {
|
||||
|
||||
|
||||
/**
|
||||
* @type {Record<string, string>}
|
||||
* @type {Partial<Record<PaletteColor, PaletteColor>>}
|
||||
*/
|
||||
export const DEFAULT_COLOR_OVERRIDES = {
|
||||
[PALETTE.HOOD]: PALETTE.FACE,
|
||||
|
||||
Reference in New Issue
Block a user