diff --git a/dist/extension.zip b/dist/extension.zip index 36f7010..e463bc2 100644 Binary files a/dist/extension.zip and b/dist/extension.zip differ diff --git a/dist/extension/birb.js b/dist/extension/birb.js index d1df198..1b60e97 100644 --- a/dist/extension/birb.js +++ b/dist/extension/birb.js @@ -226,6 +226,22 @@ return document.documentElement.clientHeight; } + const TAG = { + DEFAULT: "default", + TUFT: "tuft", + }; + + class Layer { + /** + * @param {string[][]} pixels + * @param {string} [tag] + */ + constructor(pixels, tag = TAG.DEFAULT) { + this.pixels = pixels; + this.tag = tag; + } + } + /** * Palette color names * @type {Record} @@ -333,7 +349,7 @@ [PALETTE.UNDERBELLY]: "#d7cfcb", [PALETTE.WING]: "#b1b5c5", [PALETTE.WING_EDGE]: "#9d9fa9", - }, ["tuft"]), + }, [TAG.TUFT]), europeanRobin: new BirdType("European Robin", "Native to western Europe, this is the quintessential robin. Quite friendly, you'll often find them searching for worms.", { [PALETTE.FOOT]: "#af8e75", @@ -355,7 +371,7 @@ [PALETTE.UNDERBELLY]: "#dc3719", [PALETTE.WING]: "#d23215", [PALETTE.WING_EDGE]: "#b1321c", - }, ["tuft"]), + }, [TAG.TUFT]), americanGoldfinch: new BirdType("American Goldfinch", "Coloured a brilliant yellow, this bird feeds almost entirely on the seeds of plants such as thistle, sunflowers, and coneflowers.", { [PALETTE.BEAK]: "#ffaf34", @@ -432,17 +448,6 @@ }), }; - class Layer { - /** - * @param {string[][]} pixels - * @param {string} [tag] - */ - constructor(pixels, tag = "default") { - this.pixels = pixels; - this.tag = tag; - } - } - class Frame { /** @type {{ [tag: string]: string[][] }} */ @@ -457,10 +462,10 @@ for (let layer of layers) { tags.add(layer.tag); } - tags.add("default"); + tags.add(TAG.DEFAULT); for (let tag of tags) { let maxHeight = layers.reduce((max, layer) => Math.max(max, layer.pixels.length), 0); - if (layers[0].tag !== "default") { + if (layers[0].tag !== TAG.DEFAULT) { throw new Error("First layer must have the 'default' tag"); } this.pixels = layers[0].pixels.map(row => row.slice()); @@ -470,7 +475,7 @@ } // Combine layers for (let i = 1; i < layers.length; i++) { - if (layers[i].tag === "default" || layers[i].tag === tag) { + if (layers[i].tag === TAG.DEFAULT || layers[i].tag === tag) { let layerPixels = layers[i].pixels; let topMargin = maxHeight - layerPixels.length; for (let y = 0; y < layerPixels.length; y++) { @@ -488,8 +493,8 @@ * @param {string} [tag] * @returns {string[][]} */ - getPixels(tag = "default") { - return this.#pixelsByTag[tag] ?? this.#pixelsByTag["default"]; + getPixels(tag = TAG.DEFAULT) { + return this.#pixelsByTag[tag] ?? this.#pixelsByTag[TAG.DEFAULT]; } /** diff --git a/dist/obsidian/main.js b/dist/obsidian/main.js index 255ba72..e847f07 100644 --- a/dist/obsidian/main.js +++ b/dist/obsidian/main.js @@ -231,6 +231,22 @@ module.exports = class PocketBird extends Plugin { return document.documentElement.clientHeight; } + const TAG = { + DEFAULT: "default", + TUFT: "tuft", + }; + + class Layer { + /** + * @param {string[][]} pixels + * @param {string} [tag] + */ + constructor(pixels, tag = TAG.DEFAULT) { + this.pixels = pixels; + this.tag = tag; + } + } + /** * Palette color names * @type {Record} @@ -338,7 +354,7 @@ module.exports = class PocketBird extends Plugin { [PALETTE.UNDERBELLY]: "#d7cfcb", [PALETTE.WING]: "#b1b5c5", [PALETTE.WING_EDGE]: "#9d9fa9", - }, ["tuft"]), + }, [TAG.TUFT]), europeanRobin: new BirdType("European Robin", "Native to western Europe, this is the quintessential robin. Quite friendly, you'll often find them searching for worms.", { [PALETTE.FOOT]: "#af8e75", @@ -360,7 +376,7 @@ module.exports = class PocketBird extends Plugin { [PALETTE.UNDERBELLY]: "#dc3719", [PALETTE.WING]: "#d23215", [PALETTE.WING_EDGE]: "#b1321c", - }, ["tuft"]), + }, [TAG.TUFT]), americanGoldfinch: new BirdType("American Goldfinch", "Coloured a brilliant yellow, this bird feeds almost entirely on the seeds of plants such as thistle, sunflowers, and coneflowers.", { [PALETTE.BEAK]: "#ffaf34", @@ -437,17 +453,6 @@ module.exports = class PocketBird extends Plugin { }), }; - class Layer { - /** - * @param {string[][]} pixels - * @param {string} [tag] - */ - constructor(pixels, tag = "default") { - this.pixels = pixels; - this.tag = tag; - } - } - class Frame { /** @type {{ [tag: string]: string[][] }} */ @@ -462,10 +467,10 @@ module.exports = class PocketBird extends Plugin { for (let layer of layers) { tags.add(layer.tag); } - tags.add("default"); + tags.add(TAG.DEFAULT); for (let tag of tags) { let maxHeight = layers.reduce((max, layer) => Math.max(max, layer.pixels.length), 0); - if (layers[0].tag !== "default") { + if (layers[0].tag !== TAG.DEFAULT) { throw new Error("First layer must have the 'default' tag"); } this.pixels = layers[0].pixels.map(row => row.slice()); @@ -475,7 +480,7 @@ module.exports = class PocketBird extends Plugin { } // Combine layers for (let i = 1; i < layers.length; i++) { - if (layers[i].tag === "default" || layers[i].tag === tag) { + if (layers[i].tag === TAG.DEFAULT || layers[i].tag === tag) { let layerPixels = layers[i].pixels; let topMargin = maxHeight - layerPixels.length; for (let y = 0; y < layerPixels.length; y++) { @@ -493,8 +498,8 @@ module.exports = class PocketBird extends Plugin { * @param {string} [tag] * @returns {string[][]} */ - getPixels(tag = "default") { - return this.#pixelsByTag[tag] ?? this.#pixelsByTag["default"]; + getPixels(tag = TAG.DEFAULT) { + return this.#pixelsByTag[tag] ?? this.#pixelsByTag[TAG.DEFAULT]; } /** diff --git a/dist/userscript/birb.user.js b/dist/userscript/birb.user.js index 01018f5..c794adb 100644 --- a/dist/userscript/birb.user.js +++ b/dist/userscript/birb.user.js @@ -240,6 +240,22 @@ return document.documentElement.clientHeight; } + const TAG = { + DEFAULT: "default", + TUFT: "tuft", + }; + + class Layer { + /** + * @param {string[][]} pixels + * @param {string} [tag] + */ + constructor(pixels, tag = TAG.DEFAULT) { + this.pixels = pixels; + this.tag = tag; + } + } + /** * Palette color names * @type {Record} @@ -347,7 +363,7 @@ [PALETTE.UNDERBELLY]: "#d7cfcb", [PALETTE.WING]: "#b1b5c5", [PALETTE.WING_EDGE]: "#9d9fa9", - }, ["tuft"]), + }, [TAG.TUFT]), europeanRobin: new BirdType("European Robin", "Native to western Europe, this is the quintessential robin. Quite friendly, you'll often find them searching for worms.", { [PALETTE.FOOT]: "#af8e75", @@ -369,7 +385,7 @@ [PALETTE.UNDERBELLY]: "#dc3719", [PALETTE.WING]: "#d23215", [PALETTE.WING_EDGE]: "#b1321c", - }, ["tuft"]), + }, [TAG.TUFT]), americanGoldfinch: new BirdType("American Goldfinch", "Coloured a brilliant yellow, this bird feeds almost entirely on the seeds of plants such as thistle, sunflowers, and coneflowers.", { [PALETTE.BEAK]: "#ffaf34", @@ -446,17 +462,6 @@ }), }; - class Layer { - /** - * @param {string[][]} pixels - * @param {string} [tag] - */ - constructor(pixels, tag = "default") { - this.pixels = pixels; - this.tag = tag; - } - } - class Frame { /** @type {{ [tag: string]: string[][] }} */ @@ -471,10 +476,10 @@ for (let layer of layers) { tags.add(layer.tag); } - tags.add("default"); + tags.add(TAG.DEFAULT); for (let tag of tags) { let maxHeight = layers.reduce((max, layer) => Math.max(max, layer.pixels.length), 0); - if (layers[0].tag !== "default") { + if (layers[0].tag !== TAG.DEFAULT) { throw new Error("First layer must have the 'default' tag"); } this.pixels = layers[0].pixels.map(row => row.slice()); @@ -484,7 +489,7 @@ } // Combine layers for (let i = 1; i < layers.length; i++) { - if (layers[i].tag === "default" || layers[i].tag === tag) { + if (layers[i].tag === TAG.DEFAULT || layers[i].tag === tag) { let layerPixels = layers[i].pixels; let topMargin = maxHeight - layerPixels.length; for (let y = 0; y < layerPixels.length; y++) { @@ -502,8 +507,8 @@ * @param {string} [tag] * @returns {string[][]} */ - getPixels(tag = "default") { - return this.#pixelsByTag[tag] ?? this.#pixelsByTag["default"]; + getPixels(tag = TAG.DEFAULT) { + return this.#pixelsByTag[tag] ?? this.#pixelsByTag[TAG.DEFAULT]; } /** diff --git a/dist/web/birb.embed.js b/dist/web/birb.embed.js index 722645a..0d3bcb5 100644 --- a/dist/web/birb.embed.js +++ b/dist/web/birb.embed.js @@ -226,6 +226,22 @@ return document.documentElement.clientHeight; } + const TAG = { + DEFAULT: "default", + TUFT: "tuft", + }; + + class Layer { + /** + * @param {string[][]} pixels + * @param {string} [tag] + */ + constructor(pixels, tag = TAG.DEFAULT) { + this.pixels = pixels; + this.tag = tag; + } + } + /** * Palette color names * @type {Record} @@ -333,7 +349,7 @@ [PALETTE.UNDERBELLY]: "#d7cfcb", [PALETTE.WING]: "#b1b5c5", [PALETTE.WING_EDGE]: "#9d9fa9", - }, ["tuft"]), + }, [TAG.TUFT]), europeanRobin: new BirdType("European Robin", "Native to western Europe, this is the quintessential robin. Quite friendly, you'll often find them searching for worms.", { [PALETTE.FOOT]: "#af8e75", @@ -355,7 +371,7 @@ [PALETTE.UNDERBELLY]: "#dc3719", [PALETTE.WING]: "#d23215", [PALETTE.WING_EDGE]: "#b1321c", - }, ["tuft"]), + }, [TAG.TUFT]), americanGoldfinch: new BirdType("American Goldfinch", "Coloured a brilliant yellow, this bird feeds almost entirely on the seeds of plants such as thistle, sunflowers, and coneflowers.", { [PALETTE.BEAK]: "#ffaf34", @@ -432,17 +448,6 @@ }), }; - class Layer { - /** - * @param {string[][]} pixels - * @param {string} [tag] - */ - constructor(pixels, tag = "default") { - this.pixels = pixels; - this.tag = tag; - } - } - class Frame { /** @type {{ [tag: string]: string[][] }} */ @@ -457,10 +462,10 @@ for (let layer of layers) { tags.add(layer.tag); } - tags.add("default"); + tags.add(TAG.DEFAULT); for (let tag of tags) { let maxHeight = layers.reduce((max, layer) => Math.max(max, layer.pixels.length), 0); - if (layers[0].tag !== "default") { + if (layers[0].tag !== TAG.DEFAULT) { throw new Error("First layer must have the 'default' tag"); } this.pixels = layers[0].pixels.map(row => row.slice()); @@ -470,7 +475,7 @@ } // Combine layers for (let i = 1; i < layers.length; i++) { - if (layers[i].tag === "default" || layers[i].tag === tag) { + if (layers[i].tag === TAG.DEFAULT || layers[i].tag === tag) { let layerPixels = layers[i].pixels; let topMargin = maxHeight - layerPixels.length; for (let y = 0; y < layerPixels.length; y++) { @@ -488,8 +493,8 @@ * @param {string} [tag] * @returns {string[][]} */ - getPixels(tag = "default") { - return this.#pixelsByTag[tag] ?? this.#pixelsByTag["default"]; + getPixels(tag = TAG.DEFAULT) { + return this.#pixelsByTag[tag] ?? this.#pixelsByTag[TAG.DEFAULT]; } /** diff --git a/dist/web/birb.js b/dist/web/birb.js index 722645a..0d3bcb5 100644 --- a/dist/web/birb.js +++ b/dist/web/birb.js @@ -226,6 +226,22 @@ return document.documentElement.clientHeight; } + const TAG = { + DEFAULT: "default", + TUFT: "tuft", + }; + + class Layer { + /** + * @param {string[][]} pixels + * @param {string} [tag] + */ + constructor(pixels, tag = TAG.DEFAULT) { + this.pixels = pixels; + this.tag = tag; + } + } + /** * Palette color names * @type {Record} @@ -333,7 +349,7 @@ [PALETTE.UNDERBELLY]: "#d7cfcb", [PALETTE.WING]: "#b1b5c5", [PALETTE.WING_EDGE]: "#9d9fa9", - }, ["tuft"]), + }, [TAG.TUFT]), europeanRobin: new BirdType("European Robin", "Native to western Europe, this is the quintessential robin. Quite friendly, you'll often find them searching for worms.", { [PALETTE.FOOT]: "#af8e75", @@ -355,7 +371,7 @@ [PALETTE.UNDERBELLY]: "#dc3719", [PALETTE.WING]: "#d23215", [PALETTE.WING_EDGE]: "#b1321c", - }, ["tuft"]), + }, [TAG.TUFT]), americanGoldfinch: new BirdType("American Goldfinch", "Coloured a brilliant yellow, this bird feeds almost entirely on the seeds of plants such as thistle, sunflowers, and coneflowers.", { [PALETTE.BEAK]: "#ffaf34", @@ -432,17 +448,6 @@ }), }; - class Layer { - /** - * @param {string[][]} pixels - * @param {string} [tag] - */ - constructor(pixels, tag = "default") { - this.pixels = pixels; - this.tag = tag; - } - } - class Frame { /** @type {{ [tag: string]: string[][] }} */ @@ -457,10 +462,10 @@ for (let layer of layers) { tags.add(layer.tag); } - tags.add("default"); + tags.add(TAG.DEFAULT); for (let tag of tags) { let maxHeight = layers.reduce((max, layer) => Math.max(max, layer.pixels.length), 0); - if (layers[0].tag !== "default") { + if (layers[0].tag !== TAG.DEFAULT) { throw new Error("First layer must have the 'default' tag"); } this.pixels = layers[0].pixels.map(row => row.slice()); @@ -470,7 +475,7 @@ } // Combine layers for (let i = 1; i < layers.length; i++) { - if (layers[i].tag === "default" || layers[i].tag === tag) { + if (layers[i].tag === TAG.DEFAULT || layers[i].tag === tag) { let layerPixels = layers[i].pixels; let topMargin = maxHeight - layerPixels.length; for (let y = 0; y < layerPixels.length; y++) { @@ -488,8 +493,8 @@ * @param {string} [tag] * @returns {string[][]} */ - getPixels(tag = "default") { - return this.#pixelsByTag[tag] ?? this.#pixelsByTag["default"]; + getPixels(tag = TAG.DEFAULT) { + return this.#pixelsByTag[tag] ?? this.#pixelsByTag[TAG.DEFAULT]; } /** diff --git a/src/animation/frame.js b/src/animation/frame.js index d51515d..b623e41 100644 --- a/src/animation/frame.js +++ b/src/animation/frame.js @@ -1,6 +1,6 @@ import { Directions } from '../shared.js'; import { PALETTE, BirdType } from './sprites.js'; -import Layer from './layer.js'; +import Layer, { TAG } from './layer.js'; class Frame { @@ -16,10 +16,10 @@ class Frame { for (let layer of layers) { tags.add(layer.tag); } - tags.add("default"); + tags.add(TAG.DEFAULT); for (let tag of tags) { let maxHeight = layers.reduce((max, layer) => Math.max(max, layer.pixels.length), 0); - if (layers[0].tag !== "default") { + if (layers[0].tag !== TAG.DEFAULT) { throw new Error("First layer must have the 'default' tag"); } this.pixels = layers[0].pixels.map(row => row.slice()); @@ -29,7 +29,7 @@ class Frame { } // Combine layers for (let i = 1; i < layers.length; i++) { - if (layers[i].tag === "default" || layers[i].tag === tag) { + if (layers[i].tag === TAG.DEFAULT || layers[i].tag === tag) { let layerPixels = layers[i].pixels; let topMargin = maxHeight - layerPixels.length; for (let y = 0; y < layerPixels.length; y++) { @@ -47,8 +47,8 @@ class Frame { * @param {string} [tag] * @returns {string[][]} */ - getPixels(tag = "default") { - return this.#pixelsByTag[tag] ?? this.#pixelsByTag["default"]; + getPixels(tag = TAG.DEFAULT) { + return this.#pixelsByTag[tag] ?? this.#pixelsByTag[TAG.DEFAULT]; } /** diff --git a/src/animation/layer.js b/src/animation/layer.js index cd33990..72e6c95 100644 --- a/src/animation/layer.js +++ b/src/animation/layer.js @@ -1,9 +1,14 @@ +export const TAG = { + DEFAULT: "default", + TUFT: "tuft", +}; + class Layer { /** * @param {string[][]} pixels * @param {string} [tag] */ - constructor(pixels, tag = "default") { + constructor(pixels, tag = TAG.DEFAULT) { this.pixels = pixels; this.tag = tag; } diff --git a/src/animation/sprites.js b/src/animation/sprites.js index 9ff5e80..3aca274 100644 --- a/src/animation/sprites.js +++ b/src/animation/sprites.js @@ -1,3 +1,5 @@ +import { TAG } from "./layer.js"; + /** * Palette color names * @type {Record} @@ -105,7 +107,7 @@ export const SPECIES = { [PALETTE.UNDERBELLY]: "#d7cfcb", [PALETTE.WING]: "#b1b5c5", [PALETTE.WING_EDGE]: "#9d9fa9", - }, ["tuft"]), + }, [TAG.TUFT]), europeanRobin: new BirdType("European Robin", "Native to western Europe, this is the quintessential robin. Quite friendly, you'll often find them searching for worms.", { [PALETTE.FOOT]: "#af8e75", @@ -127,7 +129,7 @@ export const SPECIES = { [PALETTE.UNDERBELLY]: "#dc3719", [PALETTE.WING]: "#d23215", [PALETTE.WING_EDGE]: "#b1321c", - }, ["tuft"]), + }, [TAG.TUFT]), americanGoldfinch: new BirdType("American Goldfinch", "Coloured a brilliant yellow, this bird feeds almost entirely on the seeds of plants such as thistle, sunflowers, and coneflowers.", { [PALETTE.BEAK]: "#ffaf34",