Format document

This commit is contained in:
Idrees Hassan
2025-09-13 16:57:16 -04:00
parent 0274b26c5f
commit 4d1254b9d4
3 changed files with 39 additions and 42 deletions

27
birb.js
View File

@@ -58,7 +58,7 @@ class Layer {
* @param {string[][]} pixels * @param {string[][]} pixels
* @param {string} [tag] * @param {string} [tag]
*/ */
constructor(pixels, tag="default") { constructor(pixels, tag = "default") {
this.pixels = pixels; this.pixels = pixels;
this.tag = tag; this.tag = tag;
} }
@@ -109,7 +109,7 @@ class Frame {
* @param {string} [tag] * @param {string} [tag]
* @returns {string[][]} * @returns {string[][]}
*/ */
getPixels(tag="default") { getPixels(tag = "default") {
return this.#pixelsByTag[tag] ?? this.#pixelsByTag["default"]; return this.#pixelsByTag[tag] ?? this.#pixelsByTag["default"];
} }
@@ -221,7 +221,7 @@ class BirdType {
* @param {Record<string, string>} colors * @param {Record<string, string>} colors
* @param {string[]} [tags] * @param {string[]} [tags]
*/ */
constructor(name, description, colors, tags=[]) { constructor(name, description, colors, tags = []) {
this.name = name; this.name = name;
this.description = description; this.description = description;
const defaultColors = { const defaultColors = {
@@ -443,8 +443,7 @@ function loadSpriteSheetPixels(dataUri, templateColors = true) {
}); });
} }
Promise.all([loadSpriteSheetPixels(SPRITE_SHEET), loadSpriteSheetPixels(DECORATIONS_SPRITE_SHEET, false), loadSpriteSheetPixels(FEATHER_SPRITE_SHEET)]) Promise.all([loadSpriteSheetPixels(SPRITE_SHEET), loadSpriteSheetPixels(DECORATIONS_SPRITE_SHEET, false), loadSpriteSheetPixels(FEATHER_SPRITE_SHEET)]).then(([birbPixels, decorationPixels, featherPixels]) => {
.then(([birbPixels, decorationPixels, featherPixels]) => {
const SPRITE_SHEET = birbPixels; const SPRITE_SHEET = birbPixels;
const DECORATIONS_SPRITE_SHEET = decorationPixels; const DECORATIONS_SPRITE_SHEET = decorationPixels;
const FEATHER_SPRITE_SHEET = featherPixels; const FEATHER_SPRITE_SHEET = featherPixels;
@@ -540,7 +539,7 @@ Promise.all([loadSpriteSheetPixels(SPRITE_SHEET), loadSpriteSheetPixels(DECORATI
const FEATHER_ANIMATIONS = { const FEATHER_ANIMATIONS = {
feather: new Anim([ feather: new Anim([
featherFrames.feather, featherFrames.feather,
], [ ], [
1000, 1000,
]), ]),
@@ -573,7 +572,7 @@ Promise.all([loadSpriteSheetPixels(SPRITE_SHEET), loadSpriteSheetPixels(DECORATI
class Separator extends MenuItem { class Separator extends MenuItem {
constructor() { constructor() {
super("", () => {}); super("", () => { });
} }
} }
@@ -585,7 +584,7 @@ Promise.all([loadSpriteSheetPixels(SPRITE_SHEET), loadSpriteSheetPixels(DECORATI
* @param {number} [top] * @param {number} [top]
* @param {number} [left] * @param {number} [left]
*/ */
constructor(id, site="", content="", top=0, left=0) { constructor(id, site = "", content = "", top = 0, left = 0) {
this.id = id; this.id = id;
this.site = site; this.site = site;
this.content = content; this.content = content;
@@ -593,7 +592,7 @@ Promise.all([loadSpriteSheetPixels(SPRITE_SHEET), loadSpriteSheetPixels(DECORATI
this.left = left; this.left = left;
} }
} }
const menuItems = [ const menuItems = [
new MenuItem(`Pet ${birdBirb()}`, pet), new MenuItem(`Pet ${birdBirb()}`, pet),
new MenuItem("Field Guide", insertFieldGuide), new MenuItem("Field Guide", insertFieldGuide),
@@ -634,7 +633,7 @@ Promise.all([loadSpriteSheetPixels(SPRITE_SHEET), loadSpriteSheetPixels(DECORATI
new MenuItem("Utilities", () => switchMenuItems(utilityItems), false), new MenuItem("Utilities", () => switchMenuItems(utilityItems), false),
new MenuItem("Music Player", () => insertMusicPlayer(), false), new MenuItem("Music Player", () => insertMusicPlayer(), false),
]; ];
const gameItems = [ const gameItems = [
new MenuItem("Go Back", () => switchMenuItems(otherItems), false), new MenuItem("Go Back", () => switchMenuItems(otherItems), false),
new Separator(), new Separator(),
@@ -899,13 +898,13 @@ Promise.all([loadSpriteSheetPixels(SPRITE_SHEET), loadSpriteSheetPixels(DECORATI
/** @type {Record<string, string>} */ /** @type {Record<string, string>} */
const stickyNoteParams = stickyNoteUrl.split("?")[1]?.split("&").reduce((params, param) => { const stickyNoteParams = stickyNoteUrl.split("?")[1]?.split("&").reduce((params, param) => {
const [key, value] = param.split("="); const [key, value] = param.split("=");
return {...params, [key]: value}; return { ...params, [key]: value };
}, {}); }, {});
/** @type {Record<string, string>} */ /** @type {Record<string, string>} */
const currentParams = currentUrl.split("?")[1]?.split("&").reduce((params, param) => { const currentParams = currentUrl.split("?")[1]?.split("&").reduce((params, param) => {
const [key, value] = param.split("="); const [key, value] = param.split("=");
return {...params, [key]: value}; return { ...params, [key]: value };
}, {}); }, {});
debug("Comparing params: ", stickyNoteParams, currentParams); debug("Comparing params: ", stickyNoteParams, currentParams);
@@ -1211,7 +1210,7 @@ Promise.all([loadSpriteSheetPixels(SPRITE_SHEET), loadSpriteSheetPixels(DECORATI
feather.style.left = `${Math.sin(3.14 * 2 * (ticks / 120)) * 25}px`; feather.style.left = `${Math.sin(3.14 * 2 * (ticks / 120)) * 25}px`;
} }
} }
// insertDecoration(); // insertDecoration();
// insertFieldGuide(); // insertFieldGuide();
@@ -1558,7 +1557,7 @@ Promise.all([loadSpriteSheetPixels(SPRITE_SHEET), loadSpriteSheetPixels(DECORATI
* @param {boolean} [parent] Whether to move the parent element when the child is dragged * @param {boolean} [parent] Whether to move the parent element when the child is dragged
* @param {(top: number, left: number) => void} [callback] Callback for when element is moved * @param {(top: number, left: number) => void} [callback] Callback for when element is moved
*/ */
function makeDraggable(element, parent = true, callback = () => {}) { function makeDraggable(element, parent = true, callback = () => { }) {
if (!element) { if (!element) {
return; return;
} }

27
dist/birb.js vendored
View File

@@ -390,7 +390,7 @@ class Layer {
* @param {string[][]} pixels * @param {string[][]} pixels
* @param {string} [tag] * @param {string} [tag]
*/ */
constructor(pixels, tag="default") { constructor(pixels, tag = "default") {
this.pixels = pixels; this.pixels = pixels;
this.tag = tag; this.tag = tag;
} }
@@ -441,7 +441,7 @@ class Frame {
* @param {string} [tag] * @param {string} [tag]
* @returns {string[][]} * @returns {string[][]}
*/ */
getPixels(tag="default") { getPixels(tag = "default") {
return this.#pixelsByTag[tag] ?? this.#pixelsByTag["default"]; return this.#pixelsByTag[tag] ?? this.#pixelsByTag["default"];
} }
@@ -553,7 +553,7 @@ class BirdType {
* @param {Record<string, string>} colors * @param {Record<string, string>} colors
* @param {string[]} [tags] * @param {string[]} [tags]
*/ */
constructor(name, description, colors, tags=[]) { constructor(name, description, colors, tags = []) {
this.name = name; this.name = name;
this.description = description; this.description = description;
const defaultColors = { const defaultColors = {
@@ -775,8 +775,7 @@ function loadSpriteSheetPixels(dataUri, templateColors = true) {
}); });
} }
Promise.all([loadSpriteSheetPixels(SPRITE_SHEET), loadSpriteSheetPixels(DECORATIONS_SPRITE_SHEET, false), loadSpriteSheetPixels(FEATHER_SPRITE_SHEET)]) Promise.all([loadSpriteSheetPixels(SPRITE_SHEET), loadSpriteSheetPixels(DECORATIONS_SPRITE_SHEET, false), loadSpriteSheetPixels(FEATHER_SPRITE_SHEET)]).then(([birbPixels, decorationPixels, featherPixels]) => {
.then(([birbPixels, decorationPixels, featherPixels]) => {
const SPRITE_SHEET = birbPixels; const SPRITE_SHEET = birbPixels;
const DECORATIONS_SPRITE_SHEET = decorationPixels; const DECORATIONS_SPRITE_SHEET = decorationPixels;
const FEATHER_SPRITE_SHEET = featherPixels; const FEATHER_SPRITE_SHEET = featherPixels;
@@ -872,7 +871,7 @@ Promise.all([loadSpriteSheetPixels(SPRITE_SHEET), loadSpriteSheetPixels(DECORATI
const FEATHER_ANIMATIONS = { const FEATHER_ANIMATIONS = {
feather: new Anim([ feather: new Anim([
featherFrames.feather, featherFrames.feather,
], [ ], [
1000, 1000,
]), ]),
@@ -905,7 +904,7 @@ Promise.all([loadSpriteSheetPixels(SPRITE_SHEET), loadSpriteSheetPixels(DECORATI
class Separator extends MenuItem { class Separator extends MenuItem {
constructor() { constructor() {
super("", () => {}); super("", () => { });
} }
} }
@@ -917,7 +916,7 @@ Promise.all([loadSpriteSheetPixels(SPRITE_SHEET), loadSpriteSheetPixels(DECORATI
* @param {number} [top] * @param {number} [top]
* @param {number} [left] * @param {number} [left]
*/ */
constructor(id, site="", content="", top=0, left=0) { constructor(id, site = "", content = "", top = 0, left = 0) {
this.id = id; this.id = id;
this.site = site; this.site = site;
this.content = content; this.content = content;
@@ -925,7 +924,7 @@ Promise.all([loadSpriteSheetPixels(SPRITE_SHEET), loadSpriteSheetPixels(DECORATI
this.left = left; this.left = left;
} }
} }
const menuItems = [ const menuItems = [
new MenuItem(`Pet ${birdBirb()}`, pet), new MenuItem(`Pet ${birdBirb()}`, pet),
new MenuItem("Field Guide", insertFieldGuide), new MenuItem("Field Guide", insertFieldGuide),
@@ -966,7 +965,7 @@ Promise.all([loadSpriteSheetPixels(SPRITE_SHEET), loadSpriteSheetPixels(DECORATI
new MenuItem("Utilities", () => switchMenuItems(utilityItems), false), new MenuItem("Utilities", () => switchMenuItems(utilityItems), false),
new MenuItem("Music Player", () => insertMusicPlayer(), false), new MenuItem("Music Player", () => insertMusicPlayer(), false),
]; ];
const gameItems = [ const gameItems = [
new MenuItem("Go Back", () => switchMenuItems(otherItems), false), new MenuItem("Go Back", () => switchMenuItems(otherItems), false),
new Separator(), new Separator(),
@@ -1231,13 +1230,13 @@ Promise.all([loadSpriteSheetPixels(SPRITE_SHEET), loadSpriteSheetPixels(DECORATI
/** @type {Record<string, string>} */ /** @type {Record<string, string>} */
const stickyNoteParams = stickyNoteUrl.split("?")[1]?.split("&").reduce((params, param) => { const stickyNoteParams = stickyNoteUrl.split("?")[1]?.split("&").reduce((params, param) => {
const [key, value] = param.split("="); const [key, value] = param.split("=");
return {...params, [key]: value}; return { ...params, [key]: value };
}, {}); }, {});
/** @type {Record<string, string>} */ /** @type {Record<string, string>} */
const currentParams = currentUrl.split("?")[1]?.split("&").reduce((params, param) => { const currentParams = currentUrl.split("?")[1]?.split("&").reduce((params, param) => {
const [key, value] = param.split("="); const [key, value] = param.split("=");
return {...params, [key]: value}; return { ...params, [key]: value };
}, {}); }, {});
debug("Comparing params: ", stickyNoteParams, currentParams); debug("Comparing params: ", stickyNoteParams, currentParams);
@@ -1543,7 +1542,7 @@ Promise.all([loadSpriteSheetPixels(SPRITE_SHEET), loadSpriteSheetPixels(DECORATI
feather.style.left = `${Math.sin(3.14 * 2 * (ticks / 120)) * 25}px`; feather.style.left = `${Math.sin(3.14 * 2 * (ticks / 120)) * 25}px`;
} }
} }
// insertDecoration(); // insertDecoration();
// insertFieldGuide(); // insertFieldGuide();
@@ -1890,7 +1889,7 @@ Promise.all([loadSpriteSheetPixels(SPRITE_SHEET), loadSpriteSheetPixels(DECORATI
* @param {boolean} [parent] Whether to move the parent element when the child is dragged * @param {boolean} [parent] Whether to move the parent element when the child is dragged
* @param {(top: number, left: number) => void} [callback] Callback for when element is moved * @param {(top: number, left: number) => void} [callback] Callback for when element is moved
*/ */
function makeDraggable(element, parent = true, callback = () => {}) { function makeDraggable(element, parent = true, callback = () => { }) {
if (!element) { if (!element) {
return; return;
} }

27
dist/birb.user.js vendored
View File

@@ -404,7 +404,7 @@ class Layer {
* @param {string[][]} pixels * @param {string[][]} pixels
* @param {string} [tag] * @param {string} [tag]
*/ */
constructor(pixels, tag="default") { constructor(pixels, tag = "default") {
this.pixels = pixels; this.pixels = pixels;
this.tag = tag; this.tag = tag;
} }
@@ -455,7 +455,7 @@ class Frame {
* @param {string} [tag] * @param {string} [tag]
* @returns {string[][]} * @returns {string[][]}
*/ */
getPixels(tag="default") { getPixels(tag = "default") {
return this.#pixelsByTag[tag] ?? this.#pixelsByTag["default"]; return this.#pixelsByTag[tag] ?? this.#pixelsByTag["default"];
} }
@@ -567,7 +567,7 @@ class BirdType {
* @param {Record<string, string>} colors * @param {Record<string, string>} colors
* @param {string[]} [tags] * @param {string[]} [tags]
*/ */
constructor(name, description, colors, tags=[]) { constructor(name, description, colors, tags = []) {
this.name = name; this.name = name;
this.description = description; this.description = description;
const defaultColors = { const defaultColors = {
@@ -789,8 +789,7 @@ function loadSpriteSheetPixels(dataUri, templateColors = true) {
}); });
} }
Promise.all([loadSpriteSheetPixels(SPRITE_SHEET), loadSpriteSheetPixels(DECORATIONS_SPRITE_SHEET, false), loadSpriteSheetPixels(FEATHER_SPRITE_SHEET)]) Promise.all([loadSpriteSheetPixels(SPRITE_SHEET), loadSpriteSheetPixels(DECORATIONS_SPRITE_SHEET, false), loadSpriteSheetPixels(FEATHER_SPRITE_SHEET)]).then(([birbPixels, decorationPixels, featherPixels]) => {
.then(([birbPixels, decorationPixels, featherPixels]) => {
const SPRITE_SHEET = birbPixels; const SPRITE_SHEET = birbPixels;
const DECORATIONS_SPRITE_SHEET = decorationPixels; const DECORATIONS_SPRITE_SHEET = decorationPixels;
const FEATHER_SPRITE_SHEET = featherPixels; const FEATHER_SPRITE_SHEET = featherPixels;
@@ -886,7 +885,7 @@ Promise.all([loadSpriteSheetPixels(SPRITE_SHEET), loadSpriteSheetPixels(DECORATI
const FEATHER_ANIMATIONS = { const FEATHER_ANIMATIONS = {
feather: new Anim([ feather: new Anim([
featherFrames.feather, featherFrames.feather,
], [ ], [
1000, 1000,
]), ]),
@@ -919,7 +918,7 @@ Promise.all([loadSpriteSheetPixels(SPRITE_SHEET), loadSpriteSheetPixels(DECORATI
class Separator extends MenuItem { class Separator extends MenuItem {
constructor() { constructor() {
super("", () => {}); super("", () => { });
} }
} }
@@ -931,7 +930,7 @@ Promise.all([loadSpriteSheetPixels(SPRITE_SHEET), loadSpriteSheetPixels(DECORATI
* @param {number} [top] * @param {number} [top]
* @param {number} [left] * @param {number} [left]
*/ */
constructor(id, site="", content="", top=0, left=0) { constructor(id, site = "", content = "", top = 0, left = 0) {
this.id = id; this.id = id;
this.site = site; this.site = site;
this.content = content; this.content = content;
@@ -939,7 +938,7 @@ Promise.all([loadSpriteSheetPixels(SPRITE_SHEET), loadSpriteSheetPixels(DECORATI
this.left = left; this.left = left;
} }
} }
const menuItems = [ const menuItems = [
new MenuItem(`Pet ${birdBirb()}`, pet), new MenuItem(`Pet ${birdBirb()}`, pet),
new MenuItem("Field Guide", insertFieldGuide), new MenuItem("Field Guide", insertFieldGuide),
@@ -980,7 +979,7 @@ Promise.all([loadSpriteSheetPixels(SPRITE_SHEET), loadSpriteSheetPixels(DECORATI
new MenuItem("Utilities", () => switchMenuItems(utilityItems), false), new MenuItem("Utilities", () => switchMenuItems(utilityItems), false),
new MenuItem("Music Player", () => insertMusicPlayer(), false), new MenuItem("Music Player", () => insertMusicPlayer(), false),
]; ];
const gameItems = [ const gameItems = [
new MenuItem("Go Back", () => switchMenuItems(otherItems), false), new MenuItem("Go Back", () => switchMenuItems(otherItems), false),
new Separator(), new Separator(),
@@ -1245,13 +1244,13 @@ Promise.all([loadSpriteSheetPixels(SPRITE_SHEET), loadSpriteSheetPixels(DECORATI
/** @type {Record<string, string>} */ /** @type {Record<string, string>} */
const stickyNoteParams = stickyNoteUrl.split("?")[1]?.split("&").reduce((params, param) => { const stickyNoteParams = stickyNoteUrl.split("?")[1]?.split("&").reduce((params, param) => {
const [key, value] = param.split("="); const [key, value] = param.split("=");
return {...params, [key]: value}; return { ...params, [key]: value };
}, {}); }, {});
/** @type {Record<string, string>} */ /** @type {Record<string, string>} */
const currentParams = currentUrl.split("?")[1]?.split("&").reduce((params, param) => { const currentParams = currentUrl.split("?")[1]?.split("&").reduce((params, param) => {
const [key, value] = param.split("="); const [key, value] = param.split("=");
return {...params, [key]: value}; return { ...params, [key]: value };
}, {}); }, {});
debug("Comparing params: ", stickyNoteParams, currentParams); debug("Comparing params: ", stickyNoteParams, currentParams);
@@ -1557,7 +1556,7 @@ Promise.all([loadSpriteSheetPixels(SPRITE_SHEET), loadSpriteSheetPixels(DECORATI
feather.style.left = `${Math.sin(3.14 * 2 * (ticks / 120)) * 25}px`; feather.style.left = `${Math.sin(3.14 * 2 * (ticks / 120)) * 25}px`;
} }
} }
// insertDecoration(); // insertDecoration();
// insertFieldGuide(); // insertFieldGuide();
@@ -1904,7 +1903,7 @@ Promise.all([loadSpriteSheetPixels(SPRITE_SHEET), loadSpriteSheetPixels(DECORATI
* @param {boolean} [parent] Whether to move the parent element when the child is dragged * @param {boolean} [parent] Whether to move the parent element when the child is dragged
* @param {(top: number, left: number) => void} [callback] Callback for when element is moved * @param {(top: number, left: number) => void} [callback] Callback for when element is moved
*/ */
function makeDraggable(element, parent = true, callback = () => {}) { function makeDraggable(element, parent = true, callback = () => { }) {
if (!element) { if (!element) {
return; return;
} }