diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2d7de7f..959657e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,18 +2,19 @@ name: CI on: push: branches: - - '*' - - '!master' + - "*" + - "!master" jobs: - test: - runs-on: macos-latest + functional_tests: + name: Functional Tests + runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Setup node env - uses: actions/setup-node@v1 - with: - node-version: 12.x - - run: npm install - - run: npm run test - env: - CI: true + - uses: actions/checkout@v4 + - name: Setup node env + uses: actions/setup-node@v4 + with: + node-version: 22.x + - run: npm install + - run: npm run test:unit + env: + CI: true diff --git a/.github/workflows/lambda-deploy-dev.yml b/.github/workflows/lambda-deploy-dev.yml new file mode 100644 index 0000000..708baeb --- /dev/null +++ b/.github/workflows/lambda-deploy-dev.yml @@ -0,0 +1,48 @@ +name: Deploy to Lambda Dev +on: + push: + branches: + - development +jobs: + run_tests: + name: Run Tests + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Setup node env + uses: actions/setup-node@v4 + with: + node-version: 22.x + - run: npm install + - run: npm run test:unit + env: + CI: true + deploy_source: + name: Deploy to Lambda Dev + needs: run_tests + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Use Node.js 22.x + uses: actions/setup-node@v4 + with: + node-version: 22.x + - name: npm install and build + run: | + npm ci + npm prune --production + env: + CI: true + - name: zip + uses: montudor/action-zip@v1 + with: + args: zip -qq -r ./app.zip board.js package.json draw-canvas.js draw-error.js effects fonts grid.js icon.js index.js input-parser.js line.js node_modules options.js overlay.js overlays parsers renderer room.js styles.css token.js 5xx.jpg missing-token.jpg + - name: default deploy + uses: appleboy/lambda-action@master + with: + aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws_region: us-west-2 + s3_bucket: otfbm-deploy-dev + function_name: otfbm-dev + zip_file: app.zip diff --git a/.github/workflows/lambda-deploy.yml b/.github/workflows/lambda-deploy.yml index 1801721..adddeba 100644 --- a/.github/workflows/lambda-deploy.yml +++ b/.github/workflows/lambda-deploy.yml @@ -6,27 +6,27 @@ on: jobs: test: name: run tests - runs-on: macos-latest + runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Setup node env - uses: actions/setup-node@v1 - with: - node-version: 12.x - - run: npm install - - run: npm run test - env: - CI: true + - uses: actions/checkout@v4 + - name: Setup node env + uses: actions/setup-node@v4 + with: + node-version: 22.x + - run: npm install + - run: npm run test:unit + env: + CI: true deploy_source: name: deploy to lambda needs: test runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 - - name: Use Node.js 12.x - uses: actions/setup-node@v1 + - uses: actions/checkout@v4 + - name: Use Node.js 22.x + uses: actions/setup-node@v4 with: - node-version: 12.x + node-version: 22.x - name: npm install and build run: | npm ci @@ -34,9 +34,9 @@ jobs: env: CI: true - name: zip - uses: montudor/action-zip@v0.1.0 + uses: montudor/action-zip@v1 with: - args: zip -r ./app.zip board.js draw-canvas.js draw-error.js effects fonts grid.js icon.js index.js input-parser.js line.js node_modules options.js overlay.js overlays parsers renderer room.js styles.css token.js 5xx.jpg missing-token.jpg + args: zip -qq -r ./app.zip board.js draw-canvas.js draw-error.js effects fonts grid.js icon.js index.js input-parser.js line.js node_modules options.js overlay.js overlays parsers renderer room.js styles.css token.js 5xx.jpg missing-token.jpg - name: default deploy uses: appleboy/lambda-action@master with: @@ -45,4 +45,4 @@ jobs: aws_region: us-west-2 s3_bucket: otfbm-deploy function_name: otfbm - zip_file: app.zip \ No newline at end of file + zip_file: app.zip diff --git a/.gitignore b/.gitignore index 7d9ae5b..7b74ec0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ node_modules .nyc_output -app.zip \ No newline at end of file +.tap +app.zip diff --git a/background/background.py b/background/background.py index 0a53d39..0e48857 100755 --- a/background/background.py +++ b/background/background.py @@ -41,7 +41,7 @@ def lambda_handler(event, context): def download_img(buffer, url): - resp = requests.get(url, stream=True) + resp = requests.get(url, stream=True, headers={"user-agent": "curl/8.1.1"}) # TODO err handling if resp.status_code == 200: for chunk in resp: diff --git a/board.js b/board.js index ca28d8b..5854f8f 100644 --- a/board.js +++ b/board.js @@ -1,15 +1,12 @@ -const Line = require("./line.js"); -const canvas = require("canvas"); +import Line from "./line.js"; +import canvas from "canvas"; const { Image, createCanvas } = canvas; /* Constant definitions for fonts, colors, etc. */ const scaleMarkerColour = "#888888"; // Grey -module.exports = class Board { - constructor({ - ctx, - options - }) { +export default class Board { + constructor({ ctx, options }) { this.state = []; this.lines = []; this.effects = []; @@ -25,7 +22,7 @@ module.exports = class Board { this.gridsize = options.cellSizePx; this.zoom = options.zoom; this.padding = options.cellSizePx; - this.fowOpacity = options.fowOpacity + this.fowOpacity = options.fowOpacity; this.gridOpacity = options.gridOpacity; this.gridColour = options.gridColour; this.isGridUserColour = options.isGridUserColour; @@ -86,11 +83,16 @@ module.exports = class Board { drawBorder() { // undo padding and any pan before drawing the border - this.ctx.translate(-this.padding + this.panX * this.gridsize, -this.padding + this.panY * this.gridsize); + this.ctx.translate( + -this.padding + this.panX * this.gridsize, + -this.padding + this.panY * this.gridsize + ); const textDarkModeAlpha = `rgba(244, 246, 255, ${this.edgeOpacity})`; const textLightModeAlpha = `rgba(7, 3, 26, ${this.edgeOpacity})`; - let bgAlpha = this.options.darkMode ? textLightModeAlpha : textDarkModeAlpha; + let bgAlpha = this.options.darkMode + ? textLightModeAlpha + : textDarkModeAlpha; const imgheight = this.imgheight * this.backgroundZoom * this.zoom; const imgwidth = this.imgwidth * this.backgroundZoom * this.zoom; @@ -98,9 +100,13 @@ module.exports = class Board { const isEdgeOpaque = this.edgeOpacity == 1 || this.background === null; const atLeft = isEdgeOpaque || this.panX < 1; - const atRight = isEdgeOpaque || this.panX * this.gridsize + this.width + this.gridsize - 1 >= imgwidth; + const atRight = + isEdgeOpaque || + this.panX * this.gridsize + this.width + this.gridsize - 1 >= imgwidth; const atTop = isEdgeOpaque || this.panY < 1; - const atBottom = isEdgeOpaque || this.panY * this.gridsize + this.height + this.gridsize - 1 >= imgheight; + const atBottom = + isEdgeOpaque || + this.panY * this.gridsize + this.height + this.gridsize - 1 >= imgheight; // fill the edges this.ctx.lineCap = "square"; @@ -112,7 +118,7 @@ module.exports = class Board { this.ctx.lineTo(end.x, end.y); this.ctx.strokeStyle = colour; this.ctx.stroke(); - } + }; // TL -> BL fillEdge( @@ -125,13 +131,19 @@ module.exports = class Board { if (atBottom) { fillEdge( { x: this.padding * 0.5, y: this.height + this.padding * 1.5 }, - { x: this.width + this.padding * 1.5, y: this.height + this.padding * 1.5 }, + { + x: this.width + this.padding * 1.5, + y: this.height + this.padding * 1.5, + }, this.options.bg ); } else { fillEdge( { x: this.padding * 1.5, y: this.height + this.padding * 1.5 }, - { x: this.width + this.padding * 0.5, y: this.height + this.padding * 1.5 }, + { + x: this.width + this.padding * 0.5, + y: this.height + this.padding * 1.5, + }, bgAlpha ); } @@ -164,14 +176,12 @@ module.exports = class Board { const drawGridEdgeLine = (start, end, isSolid) => { this.ctx.beginPath(); - if (isSolid) - this.ctx.setLineDash([]); - else - this.ctx.setLineDash([5 * this.zoom - 2, 5 * this.zoom + 2]); + if (isSolid) this.ctx.setLineDash([]); + else this.ctx.setLineDash([5 * this.zoom - 2, 5 * this.zoom + 2]); this.ctx.moveTo(start.x, start.y); this.ctx.lineTo(end.x, end.y); this.ctx.stroke(); - } + }; drawGridEdgeLine( { x: this.padding, y: this.padding }, @@ -203,14 +213,14 @@ module.exports = class Board { const drawDottedLine = (start, end) => { drawGridEdgeLine(start, end, false); - } + }; - const leftoverHeight = imgheight % this.gridsize + const leftoverHeight = imgheight % this.gridsize; const height = imgheight - leftoverHeight; - const drawHeight = height - (this.panY * this.gridsize) + this.padding; - const leftoverWidth = imgwidth % this.gridsize + const drawHeight = height - this.panY * this.gridsize + this.padding; + const leftoverWidth = imgwidth % this.gridsize; const width = imgwidth - leftoverWidth; - const drawWidth = width - (this.panX * this.gridsize) + this.padding; + const drawWidth = width - this.panX * this.gridsize + this.padding; const startHeight = this.padding + this.height; const endHeight = this.padding * 2 + this.height; const startWidth = this.padding + this.width; @@ -220,13 +230,13 @@ module.exports = class Board { if (!atBottom) { drawDottedLine( { x: this.padding, y: this.padding + this.height }, - { x: this.padding, y: this.padding * 2 + this.height }, + { x: this.padding, y: this.padding * 2 + this.height } ); } if (!atTop) { drawDottedLine( { x: this.padding, y: 0 }, - { x: this.padding, y: this.padding }, + { x: this.padding, y: this.padding } ); } } @@ -241,13 +251,14 @@ module.exports = class Board { if (!atLeft) { drawDottedLine( { x: 0, y: this.padding }, - { x: this.padding, y: this.padding }, + { x: this.padding, y: this.padding } ); } } if (!atLeft) { - if (drawHeight < this.padding * 2 + this.height) { // dont draw right on the edge of the canvas, it looks weird + if (drawHeight < this.padding * 2 + this.height) { + // dont draw right on the edge of the canvas, it looks weird drawDottedLine( { x: 0, y: drawHeight }, { x: this.padding, y: drawHeight } @@ -256,27 +267,31 @@ module.exports = class Board { } if (!atBottom) { - if (drawWidth < this.padding * 2 + this.width) { // dont draw right on the edge of the canvas, it looks weird - if (drawWidth < this.width) { // dont draw over the "5ft" key + if (drawWidth < this.padding * 2 + this.width) { + // dont draw right on the edge of the canvas, it looks weird + if (drawWidth < this.width) { + // dont draw over the "5ft" key drawDottedLine( { x: drawWidth, y: startHeight }, - { x: drawWidth, y: endHeight }, + { x: drawWidth, y: endHeight } ); } } } if (!atTop) { - if (drawWidth < this.padding * 2 + this.width) { // dont draw right on the edge of the canvas, it looks weird + if (drawWidth < this.padding * 2 + this.width) { + // dont draw right on the edge of the canvas, it looks weird drawDottedLine( { x: drawWidth, y: 0 }, - { x: drawWidth, y: this.padding }, + { x: drawWidth, y: this.padding } ); } } if (!atRight) { - if (drawHeight < this.padding * 2 + this.height) { // dont draw right on the edge of the canvas, it looks weird + if (drawHeight < this.padding * 2 + this.height) { + // dont draw right on the edge of the canvas, it looks weird drawDottedLine( { x: startWidth, y: drawHeight }, { x: endWidth, y: drawHeight } @@ -294,16 +309,24 @@ module.exports = class Board { // Drawing x axis alphabetic labels let num = this.panX; for (let i = this.gridsize; i <= this.width; i += this.gridsize) { - let character = String.fromCharCode(num % 26 + 65); + let character = String.fromCharCode((num % 26) + 65); if (num >= 26) character = String.fromCharCode(Math.floor(num / 26) + 64) + character; + // Top axis label this.ctx.fillText( character, this.padding + i - this.gridsize / 2, this.padding / 2 ); + // Bottom axis label + this.ctx.fillText( + character, + this.padding + i - this.gridsize / 2, + this.padding * 1.5 + this.height + ); + num += 1; } @@ -312,11 +335,19 @@ module.exports = class Board { for (let i = this.gridsize; i <= this.height; i += this.gridsize) { num += 1; + // Left axis label this.ctx.fillText( String(num), this.padding / 2, this.padding + i - this.gridsize / 2 ); + + // Right axis label + this.ctx.fillText( + String(num), + this.padding * 1.5 + this.width, + this.padding + i - this.gridsize / 2 + ); } // Drawing the scale marker @@ -326,42 +357,46 @@ module.exports = class Board { this.ctx.lineCap = "square"; this.ctx.strokeStyle = atBottom ? scaleMarkerColour : this.options.fg; - this.ctx.moveTo(this.padding + this.width - this.gridsize, this.padding + this.height + (this.gridsize * 0.15)); - this.ctx.lineTo(this.padding + this.width - this.gridsize, this.padding + this.height + (this.gridsize * 0.65)); - - this.ctx.moveTo(this.padding + this.width - this.gridsize, this.padding + this.height + (this.gridsize * 0.5)); - this.ctx.lineTo(this.padding + this.width - this.gridsize + (this.gridsize * 0.1), this.padding + this.height + (this.gridsize * 0.5)); - - this.ctx.moveTo(this.padding + this.width, this.padding + this.height + (this.gridsize * 0.15)); - this.ctx.lineTo(this.padding + this.width, this.padding + this.height + (this.gridsize * 0.65)); + this.ctx.moveTo( + this.padding + this.width, + this.padding + this.height + this.gridsize * 0.2 + ); + this.ctx.lineTo( + this.padding + this.width, + this.padding + this.height + this.gridsize * 0.8 + ); - this.ctx.moveTo(this.padding + this.width, this.padding + this.height + (this.gridsize * 0.5)); - this.ctx.lineTo(this.padding + this.width - (this.gridsize * 0.1), this.padding + this.height + (this.gridsize * 0.5)); + this.ctx.moveTo( + this.padding + this.width + this.gridsize - 2, + this.padding + this.height + this.gridsize * 0.2 + ); + this.ctx.lineTo( + this.padding + this.width + this.gridsize - 2, + this.padding + this.height + this.gridsize * 0.8 + ); this.ctx.stroke(); // Scale text this.ctx.beginPath(); this.ctx.fillStyle = atBottom ? scaleMarkerColour : this.options.fg; - this.ctx.textAlign = 'center'; + this.ctx.textAlign = "center"; this.ctx.fillText( "5ft", - this.padding + this.width - (this.gridsize / 2), - this.padding + this.height + (this.gridsize / 2), - this.gridsize, + this.padding + this.width + this.gridsize / 2, + this.padding + this.height + this.gridsize / 2, + this.gridsize ); } drawGridLines(ctx = this.ctx) { - if (this.gridOpacity === 0) - return; + if (this.gridOpacity === 0) return; ctx.save(); ctx.beginPath(); ctx.strokeStyle = this.gridColour; ctx.globalAlpha = this.gridOpacity; - if (!this.isGridUserColour) - ctx.globalCompositeOperation = "difference"; + if (!this.isGridUserColour) ctx.globalCompositeOperation = "difference"; for (let i = this.gridsize; i < this.width - 1; i += this.gridsize) { ctx.moveTo(0.5 + i + this.padding, this.padding); @@ -396,15 +431,23 @@ module.exports = class Board { const offsetY = this.backgroundOffsetY / this.zoom; const scaledOffsetX = this.backgroundOffsetX; const scaledOffsetY = this.backgroundOffsetY; - const offsetTrimX = (img.width * this.backgroundZoom - offsetX) % gridsize; - const offsetTrimY = (img.height * this.backgroundZoom - offsetY) % gridsize; + const offsetTrimX = + (img.width * this.backgroundZoom - offsetX) % gridsize; + const offsetTrimY = + (img.height * this.backgroundZoom - offsetY) % gridsize; const scaledOffsetTrimX = offsetTrimX * this.zoom; const scaledOffsetTrimY = offsetTrimY * this.zoom; this.imgwidth = img.width; this.imgheight = img.height; - this.dWidth = (img.width * this.backgroundZoom * this.zoom) - scaledOffsetX - scaledOffsetTrimX - this.dHeight = (img.height * this.backgroundZoom * this.zoom) - scaledOffsetY - scaledOffsetTrimY + this.dWidth = + img.width * this.backgroundZoom * this.zoom - + scaledOffsetX - + scaledOffsetTrimX; + this.dHeight = + img.height * this.backgroundZoom * this.zoom - + scaledOffsetY - + scaledOffsetTrimY; this.ctx.drawImage( img, @@ -415,11 +458,11 @@ module.exports = class Board { this.padding - this.panX * this.gridsize, this.padding - this.panY * this.gridsize, this.dWidth, - this.dHeight, + this.dHeight ); }; img.onerror = (err) => { - throw new Error('Failed to load background image'); + throw new Error("Failed to load background image"); }; img.src = this.background; } @@ -427,7 +470,10 @@ module.exports = class Board { this.drawGridLines(); // move ctx to account for padding and pan - this.ctx.translate(this.padding - this.panX * this.gridsize, this.padding - this.panY * this.gridsize); + this.ctx.translate( + this.padding - this.panX * this.gridsize, + this.padding - this.panY * this.gridsize + ); Line.fg = this.options.fg; Line.bg = this.options.bg; @@ -438,7 +484,7 @@ module.exports = class Board { for (const { x, y, item } of this) { if (item) { - if (item.type !== 'token') { + if (item.type !== "token") { item.draw(this.ctx, x, y, this.gridsize, this.zoom); } } @@ -456,8 +502,7 @@ module.exports = class Board { } drawFog() { - if (this.fog.length == 0) - return; + if (this.fog.length == 0) return; // fog mask // Extend fog mask over entire image to allow for panning @@ -465,14 +510,16 @@ module.exports = class Board { let fogCtx = fogCanv.getContext("2d"); // move fog ctx to account for padding and pan fogCtx.globalAlpha = this.fowOpacity; - fogCtx.fillStyle = this.options.bg + fogCtx.fillStyle = this.options.bg; fogCtx.fillRect(0, 0, fogCanv.width, fogCanv.height); - fogCtx.save() - for (let f of this.fog) - f.draw(fogCtx, this.gridsize); - fogCtx.translate(this.padding - this.panX * this.gridsize, this.padding - this.panY * this.gridsize); - fogCtx.save() - this.ctx.drawImage(fogCanv, 0, 0); + fogCtx.save(); + for (let f of this.fog) f.draw(fogCtx, this.gridsize); + fogCtx.translate( + this.padding - this.panX * this.gridsize, + this.padding - this.panY * this.gridsize + ); + fogCtx.save(); + this.ctx.drawImage(fogCanv, 0, 0); this.ctx.restore(); } } diff --git a/dev.js b/dev.js new file mode 100644 index 0000000..8e9d14d --- /dev/null +++ b/dev.js @@ -0,0 +1,4 @@ +import createServer from "./server.js"; + +const server = createServer(); +server.listen({ port: 4001 }); diff --git a/draw-canvas.js b/draw-canvas.js index 6321525..84faf07 100644 --- a/draw-canvas.js +++ b/draw-canvas.js @@ -1,43 +1,46 @@ -const { join } = require("path"); -const fs = require("fs").promises; -const fetch = require("node-fetch"); -const InputParser = require("./input-parser.js"); -const Board = require("./board.js"); -const Options = require("./options.js"); -const Renderer = require("./renderer/index.js"); -const Overlay = require("./overlay.js"); -const Grid = require("./grid.js"); -const AWS = require("aws-sdk"); +import { join } from "path"; +import { promises as fs } from "fs"; +import fetch from "node-fetch"; +import InputParser from "./input-parser.js"; +import Board from "./board.js"; +import Options from "./options.js"; +import Renderer from "./renderer/index.js"; +import Overlay from "./overlay.js"; +import Grid from "./grid.js"; -AWS.config.update({ region: "us-west-2" }); -const cw = new AWS.CloudWatch({ apiVersion: "2010-08-01" }); +// AWS-SDK v3 update. +import { CloudWatch } from "@aws-sdk/client-cloudwatch"; + +const cw = new CloudWatch({ + region: "us-west-2", +}); let crypto; try { - crypto = require('crypto'); + crypto = require("crypto"); } catch (err) { - console.log('crypto support is disabled!'); + console.log("crypto support is disabled!"); } const scramble = (id) => { - if (!id) return 'N/A'; + if (!id) return "N/A"; if (!crypto) return String(id); try { - const hash = crypto.createHash('sha256'); + const hash = crypto.createHash("sha256"); hash.update(String(id)); - return String(hash.digest('hex')).slice(0, 10); - } catch(err) { - return 'N/A'; + return String(hash.digest("hex")).slice(0, 10); + } catch (err) { + return "N/A"; } }; const base64Fetch = async (url) => { const res = await fetch(url); if (res.ok) { - const buffer = await res.buffer(); - return `data:${res.headers.get("content-type")};base64,${buffer.toString( - "base64" - )}`; + const buffer = await res.arrayBuffer(); + return `data:${res.headers.get("content-type")};base64,${Buffer.from( + buffer + ).toString("base64")}`; } const err = new Error( `We couldn't seem to get our claws on the token image you asked for` @@ -50,17 +53,22 @@ const imageCodeFetch = async (url) => { if (!url) return null; let status = 200; try { - const u = new URL(join('meta', Buffer.from(url).toString('base64')), 'https://token.otfbm.io'); - const res = await fetch(u); + const u = new URL( + join("meta", Buffer.from(url).toString("base64")), + "https://token.otfbm.io" + ); + const res = await fetch(u, { + headers: { "user-agent": "curl/8.1.1" }, + }); if (res.ok) { const text = await res.text(); const code = text.match(/([A-Za-z0-9]*)<\/body>/); return code[1]; } status = res.status; - } catch(err) { + } catch (err) { console.error(err); - status = 500 + status = 500; } const error = new Error( `We couldn't seem to get our claws on the token code for the image you asked for` @@ -72,8 +80,8 @@ const imageCodeFetch = async (url) => { let fallbackTokenImage; const fetchTokenImageAsBase64 = async (code) => { if (!code) return null; - const useFacialRecognition = code[code.length - 1] !== '~'; - const c = useFacialRecognition ? code: code.slice(0, code.length - 1); + const useFacialRecognition = code[code.length - 1] !== "~"; + const c = useFacialRecognition ? code : code.slice(0, code.length - 1); if (useFacialRecognition) { try { @@ -90,16 +98,19 @@ const fetchTokenImageAsBase64 = async (code) => { } if (!fallbackTokenImage) { - const buff = await fs.readFile(join(__dirname, "missing-token.jpg")); + const buff = await fs.readFile( + new URL("./missing-token.jpg", import.meta.url) + ); fallbackTokenImage = buff.toString("base64"); } return `data:image/jpeg;base64,${fallbackTokenImage}`; }; const getBracket = (val, brackets) => { + console.log(brackets); // Given list of brackets of form "s" // return first bracket in list which returns true for val - for (bracket of brackets) { + for (let bracket of brackets) { if (bracket.charAt(0) === "<") { if (val < parseFloat(bracket.substring(1, bracket.length))) { return bracket; @@ -112,23 +123,58 @@ const getBracket = (val, brackets) => { } const [lower, upper] = bracket.split("-"); if (parseFloat(lower) <= val && val <= parseFloat(upper)) { - return bracket + return bracket; } } -} +}; -module.exports = async function main(pathname, query, metrics = true) { +export default async function main(pathname, query, metrics = true) { const options = new Options(); const input = new InputParser(); await input.parse(options, pathname, query); if (metrics) { - const cellsize = getBracket(options._cellSize, ["<40", "40-59", "60-79", "80-99"]); - const numTokens = getBracket(input.tokens.length, ["1-5", "6-10", "11-15", "16-20", ">20"]); - const numLines = getBracket(input.lines.length, ["1-5", "6-10", "11-15", "16-20", ">20"]); - const numEffects = getBracket(input.effects.length, ["1-5", "6-10", "11-15", "16-20", ">20"]); - const numIcons = getBracket(input.icons.length, ["1-5", "6-10", "11-15", "16-20", ">20"]); - const numOverlays = getBracket(input.overlays.length, ["1-5", "6-10", "11-15", "16-20", ">20"]); + const cellsize = getBracket(options._cellSize, [ + "<40", + "40-59", + "60-79", + "80-99", + ]); + const numTokens = getBracket(input.tokens.length, [ + "1-5", + "6-10", + "11-15", + "16-20", + ">20", + ]); + const numLines = getBracket(input.lines.length, [ + "1-5", + "6-10", + "11-15", + "16-20", + ">20", + ]); + const numEffects = getBracket(input.effects.length, [ + "1-5", + "6-10", + "11-15", + "16-20", + ">20", + ]); + const numIcons = getBracket(input.icons.length, [ + "1-5", + "6-10", + "11-15", + "16-20", + ">20", + ]); + const numOverlays = getBracket(input.overlays.length, [ + "1-5", + "6-10", + "11-15", + "16-20", + ">20", + ]); const datapoint = { MetricData: [ @@ -202,7 +248,8 @@ module.exports = async function main(pathname, query, metrics = true) { Dimensions: [ { Name: "DevelopmentMode", - Value: query.d && query.d[0] === "1" ? "development" : "production", + Value: + query.d && query.d[0] === "1" ? "development" : "production", }, { Name: "AliasOrWebsite", @@ -238,8 +285,8 @@ module.exports = async function main(pathname, query, metrics = true) { } }); }); - } catch(err) { - console.log('Failed to push metrics, swallowing error', err); + } catch (err) { + console.log("Failed to push metrics, swallowing error", err); } } @@ -295,7 +342,10 @@ module.exports = async function main(pathname, query, metrics = true) { const tokenSpecsByCoords = new Map(); for (const overlay of input.tokens) { const serializedCoord = "c:" + overlay.tl + "s:" + overlay.size; - tokenSpecsByCoords.set(serializedCoord, [overlay, ...(tokenSpecsByCoords.get(serializedCoord) || [])]); + tokenSpecsByCoords.set(serializedCoord, [ + overlay, + ...(tokenSpecsByCoords.get(serializedCoord) || []), + ]); } for (const [coord, specs] of tokenSpecsByCoords) { @@ -309,11 +359,11 @@ module.exports = async function main(pathname, query, metrics = true) { // Since we are not adding sub-items to grid, apply those side-effects manually here // TODO: refactor side effects out of grid.add baseSpecAsJson.cell = baseSpecAsJson.tl; - specs.forEach(s => { + specs.forEach((s) => { const [w, h] = grid.getDims(s); s.width = w; s.height = h; - }) + }); const multitokenOverlay = new Overlay({ ...baseSpecAsJson, type: "multitoken", @@ -337,4 +387,4 @@ module.exports = async function main(pathname, query, metrics = true) { board.drawBorder(); return renderer.canv; -}; +} diff --git a/draw-error.js b/draw-error.js index 6485ff5..8ce056b 100644 --- a/draw-error.js +++ b/draw-error.js @@ -1,13 +1,13 @@ -const { join } = require("path"); -const fs = require("fs").promises; -const canvas = require("canvas"); +import { join } from "node:path"; +import fs from "node:fs/promises"; +import canvas from "canvas"; const { createCanvas, Image } = canvas; const WIDTH = 419; const HEIGHT = 600; -module.exports = async function error(msg) { - const buffer = await fs.readFile(join(__dirname, "./5xx.jpg")); +export default async function error(msg) { + const buffer = await fs.readFile(new URL('./5xx.jpg', import.meta.url)); const canvas = createCanvas(WIDTH, HEIGHT); const ctx = canvas.getContext("2d"); const img = new Image(); diff --git a/effects/arrow-effect.js b/effects/arrow-effect.js index 6898034..9518160 100644 --- a/effects/arrow-effect.js +++ b/effects/arrow-effect.js @@ -1,6 +1,6 @@ -const Line = require("../line.js"); +import Line from "../line.js"; -module.exports = class ArrowEffect { +export default class ArrowEffect { constructor({ colour, startPt, endPt }) { this.colour = colour; this.startPt = startPt; diff --git a/effects/circle-effect.js b/effects/circle-effect.js index e19ccca..3bb7ec0 100644 --- a/effects/circle-effect.js +++ b/effects/circle-effect.js @@ -1,4 +1,4 @@ -module.exports = class CircleEffect { +export default class CircleEffect { constructor({ size, colour, anchorPt, offset, anchorType, alpha }) { this.colour = colour; this.size = size; @@ -37,4 +37,4 @@ module.exports = class CircleEffect { ctx.fill(); ctx.restore(); } -}; +} diff --git a/effects/fog-effect.js b/effects/fog-effect.js index 453d70d..6172503 100644 --- a/effects/fog-effect.js +++ b/effects/fog-effect.js @@ -1,4 +1,4 @@ -module.exports = class FogEffect { +export default class FogEffect { constructor({ startPt, endPt }) { this.startPt = startPt; this.endPt = endPt; @@ -14,4 +14,4 @@ module.exports = class FogEffect { ctx.clearRect(x1, y1, width, height) ctx.save() } -} +}; diff --git a/effects/square-effect.js b/effects/square-effect.js index edd02aa..98715a1 100644 --- a/effects/square-effect.js +++ b/effects/square-effect.js @@ -1,4 +1,4 @@ -module.exports = class SquareEffect { +export default class SquareEffect { constructor({ width, length, colour, startPt, endPt, anchorTopLeft, alpha }) { this.colour = colour; this.width = width; @@ -52,4 +52,4 @@ module.exports = class SquareEffect { ctx.fill(); ctx.restore(); } -}; +} diff --git a/effects/triangle-effect.js b/effects/triangle-effect.js index 8b28027..b4d7992 100644 --- a/effects/triangle-effect.js +++ b/effects/triangle-effect.js @@ -1,4 +1,4 @@ -module.exports = class TriangleEffect { +export default class TriangleEffect { constructor({ size, colour, startPt, endPt, alpha }) { this.colour = colour; this.width = size; @@ -36,4 +36,4 @@ module.exports = class TriangleEffect { ctx.fill(); ctx.restore(); } -}; +} diff --git a/favicon.ico b/favicon.ico new file mode 100644 index 0000000..378d77a Binary files /dev/null and b/favicon.ico differ diff --git a/grid.js b/grid.js index 3fac646..9205074 100644 --- a/grid.js +++ b/grid.js @@ -1,10 +1,10 @@ -const assert = require("assert"); -const Options = require("./options.js"); -const Overlay = require("./overlay.js"); +import assert from "assert"; +import Options from "./options.js"; +import Overlay from "./overlay.js"; const gridDepth = 5; -module.exports = class Grid { +export default class Grid { constructor(options) { assert( options instanceof Options, diff --git a/icon.js b/icon.js index 74e230e..285de43 100644 --- a/icon.js +++ b/icon.js @@ -1,7 +1,7 @@ -const canvas = require("canvas"); +import canvas from "canvas"; const { Image } = canvas; -module.exports = class Icon { +export default class Icon { constructor({ icon } = {}) { this.icon = icon; } diff --git a/index.js b/index.js index 728646b..6ca1e8c 100644 --- a/index.js +++ b/index.js @@ -1,15 +1,19 @@ -const drawCanvas = require("./draw-canvas.js"); -const drawError = require("./draw-error.js"); +import drawCanvas from "./draw-canvas.js"; +import drawError from "./draw-error.js"; -exports.handler = async (event, context, metrics) => { +export const handler = async (event, context, metrics) => { let stripped; try { const query = (event && event.multiValueQueryStringParameters) || {}; const path = event.rawPath || event.path; + console.log(query, path) const canvas = await drawCanvas(path, query, metrics); + console.log(canvas) const data = canvas.toDataURL("image/jpeg", { quality: 0.80 }); + console.log(data) stripped = data.replace(/^data:image\/\w+;base64,/, ""); } catch (err) { + console.log(err) // const canvas = await drawError(err.message); // const data = canvas.toDataURL("image/jpeg", { quality: 0.80 }); // stripped = data.replace(/^data:image\/\w+;base64,/, ""); diff --git a/input-parser.js b/input-parser.js index f32b0d9..1c686ed 100644 --- a/input-parser.js +++ b/input-parser.js @@ -1,15 +1,15 @@ -const ViewParser = require("./parsers/view-parser.js"); -const TokenParser = require("./parsers/token.js"); -const IconParser = require("./parsers/icon.js"); -const OverlayParser = require("./parsers/overlay.js"); -const BackgroundParser = require("./parsers/background.js"); -const LineParser = require("./parsers/line-parser.js"); -const Icon = require("./icon.js"); -const EffectParser = require("./parsers/effect-parser.js"); -const FogParser = require("./parsers/fog-parser.js"); -const ConfigParser = require('./parsers/config.js'); - -module.exports = class InputParser { +import ViewParser from "./parsers/view-parser.js"; +import TokenParser from "./parsers/token.js"; +import IconParser from "./parsers/icon.js"; +import OverlayParser from "./parsers/overlay.js"; +import BackgroundParser from "./parsers/background.js"; +import LineParser from "./parsers/line-parser.js"; +import Icon from "./icon.js"; +import EffectParser from "./parsers/effect-parser.js"; +import FogParser from "./parsers/fog-parser.js"; +import ConfigParser from './parsers/config.js'; + +export default class InputParser { constructor() { this.lines = []; this.tokens = []; @@ -154,4 +154,4 @@ module.exports = class InputParser { options.parseOptions(c.options); } } -}; +} diff --git a/line.js b/line.js index 4ade997..4937c9b 100644 --- a/line.js +++ b/line.js @@ -1,4 +1,4 @@ -module.exports = class Line { +export default class Line { static fg; static bg; @@ -104,4 +104,4 @@ module.exports = class Line { y: (1 - t) * a.y + t * b.y } } -} +}; diff --git a/options.js b/options.js index f6e3546..8343c27 100644 --- a/options.js +++ b/options.js @@ -1,10 +1,9 @@ -const ColourParser = require("./parsers/colour-parser.js"); +import ColourParser from "./parsers/colour-parser.js"; const lightColour = "#f4f6ff"; // Powdered Sugar const darkColour = "#07031a"; // Midnight Blue -module.exports = class Options { - +export default class Options { constructor() { this._view = { width: 10, height: 10, panX: 0, panY: 0 }; this._zoom = 1; @@ -16,98 +15,91 @@ module.exports = class Options { this._isGridUserColour = false; this._edgeOpacity = 0.6; this._background = { image: null, offsetX: 0, offsetY: 0, zoom: 1 }; - this._font = 'AzoSans'; + this._font = "sans-serif"; } set view(value) { this._view = value; // ensure that width and pan don't exceed 100 - if ((this._view.width + this._view.panX) > 100) { + if (this._view.width + this._view.panX > 100) { this._view.panX = 100 - this._view.width; } - if ((this._view.height + this._view.panY) > 100) { + if (this._view.height + this._view.panY > 100) { this._view.panY = 100 - this._view.height; } } parseOptions(str) { - if (str.charAt(0) !== '@') - return false; + if (str.charAt(0) !== "@") return false; let parsed = this.parseZoom(str); - let matches = str.match(/(G(PK|PU|BK|GY|BN|[WKEARGBYPCNOI]|~[0-9A-F]{6}|~[0-9A-F]{3}))|[DEFN]|[CHW][0-9]*|[BZ][0-9\.]*|[O][0-9]+:[0-9]+/ig); + let matches = str.match( + /(G(PK|PU|BK|GY|BN|[WKEARGBYPCNOI]|~[0-9A-F]{6}|~[0-9A-F]{3}))|[DEFN]|[CHW][0-9]*|[BZ][0-9\.]*|[O][0-9]+:[0-9]+/gi + ); - if (!matches) - return parsed; + if (!matches) return parsed; for (const match of matches) { switch (match.charAt(0)) { - - case 'b': + case "b": const bgZoom = parseFloat(match.substring(1), 10); - if (!Number.isNaN(bgZoom)) - this._background.zoom = bgZoom; + if (!Number.isNaN(bgZoom)) this._background.zoom = bgZoom; break; - case 'c': + case "c": let size = parseInt(match.substring(1), 10); if (size < 20) size = 20; if (size > 100) size = 100; this._cellSize = size; break; - case 'd': + case "d": this._darkMode = true; break; - case 'e': + case "e": this._edgeOpacity = 1; break; - case 'f': - this._font = 'FleischWurst'; + case "f": + this._font = "sans-serif"; break; - case 'g': + case "g": this._gridColour = ColourParser.parse(match.substring(1)); this._isGridUserColour = true; this._gridOpacity = 100; break; - case 'h': + case "h": if (match.length > 1) { const opacity = Number(match.substring(1), 10); this._gridOpacity = opacity <= 100 ? opacity / 100 : 1; - } - else - this._gridOpacity = 0.25; + } else this._gridOpacity = 0.25; break; - case 'w': + case "w": if (match.length > 1) { const opacity = Number(match.substring(1), 10); this._fowOpacity = opacity <= 100 ? opacity / 100 : 1; - } - else - this._fowOpacity = 1; + } else this._fowOpacity = 1; break; - case 'n': + case "n": this._gridOpacity = 0; break; - case 'o': - const offset = match.substring(1).split(':'); + case "o": + const offset = match.substring(1).split(":"); this._background.offsetX = parseInt(offset[0]); this._background.offsetY = parseInt(offset[1]); break; - case 'z': + case "z": const zoom = parseFloat(match.substring(1), 10); - if (!Number.isNaN(zoom)) - this._zoom = zoom; + if (!Number.isNaN(zoom)) this._zoom = zoom; break; } } @@ -147,8 +139,7 @@ module.exports = class Options { } get fg() { - if (this.isGridUserColour) - return this.gridColour; + if (this.isGridUserColour) return this.gridColour; return this.darkMode ? lightColour : darkColour; } diff --git a/overlay.js b/overlay.js index 27a48df..d9f8465 100644 --- a/overlay.js +++ b/overlay.js @@ -1,4 +1,4 @@ -module.exports = class Overlay { +export default class Overlay { constructor({ cells = [], cell = "", type, label, color, size, imageCode, image, imageURL, width = undefined, height = undefined } = {}) { this._cells = cells; this._cell = cell; @@ -110,4 +110,4 @@ module.exports = class Overlay { imageURL: this.imageURL, } } -} +}; diff --git a/overlays/brick-wall/index.js b/overlays/brick-wall/index.js index 6fabfe5..04e8c6c 100644 --- a/overlays/brick-wall/index.js +++ b/overlays/brick-wall/index.js @@ -1,6 +1,6 @@ -const template = require("./template.js"); +import template from "./template.js"; -module.exports = class BrickWallOverlay { +export default class BrickWallOverlay { constructor(options) { this.options = options; } diff --git a/overlays/brick-wall/template.js b/overlays/brick-wall/template.js index 486fba2..f62af6c 100644 --- a/overlays/brick-wall/template.js +++ b/overlays/brick-wall/template.js @@ -1,4 +1,4 @@ -module.exports = ({ +export default ({ height, width, color, diff --git a/overlays/chair/index.js b/overlays/chair/index.js index 892a196..d30ec81 100644 --- a/overlays/chair/index.js +++ b/overlays/chair/index.js @@ -1,6 +1,6 @@ -const template = require("./template.js"); +import template from "./template.js"; -module.exports = class ChairOverlay { +export default class ChairOverlay { constructor(options) { this.options = options; } diff --git a/overlays/chair/template.js b/overlays/chair/template.js index 2c0fbd8..213ebd9 100644 --- a/overlays/chair/template.js +++ b/overlays/chair/template.js @@ -1,4 +1,4 @@ -module.exports = ({ +export default ({ height, width, color, diff --git a/overlays/chest/index.js b/overlays/chest/index.js index 21fbcb9..97c6805 100644 --- a/overlays/chest/index.js +++ b/overlays/chest/index.js @@ -1,6 +1,6 @@ -const template = require("./template.js"); +import template from "./template.js"; -module.exports = class ChestOverlay { +export default class ChestOverlay { constructor(options) { this.options = options; } diff --git a/overlays/chest/template.js b/overlays/chest/template.js index ea64090..7c00e8f 100644 --- a/overlays/chest/template.js +++ b/overlays/chest/template.js @@ -1,4 +1,4 @@ -module.exports = ({ +export default ({ height, width, color, diff --git a/overlays/column/index.js b/overlays/column/index.js index 34d6f01..a383135 100644 --- a/overlays/column/index.js +++ b/overlays/column/index.js @@ -1,6 +1,6 @@ -const template = require("./template.js"); +import template from "./template.js"; -module.exports = class ColumnOverlay { +export default class ColumnOverlay { constructor(options) { this.options = options; } diff --git a/overlays/column/template.js b/overlays/column/template.js index 83ac847..dfb08bc 100644 --- a/overlays/column/template.js +++ b/overlays/column/template.js @@ -1,4 +1,4 @@ -module.exports = ({ +export default ({ height, width, color, diff --git a/overlays/covered-pit/index.js b/overlays/covered-pit/index.js index 6da910f..a2b7f89 100644 --- a/overlays/covered-pit/index.js +++ b/overlays/covered-pit/index.js @@ -1,6 +1,6 @@ -const template = require("./template.js"); +import template from "./template.js"; -module.exports = class CoveredPitOverlay { +export default class CoveredPitOverlay { constructor(options) { this.options = options; } diff --git a/overlays/covered-pit/template.js b/overlays/covered-pit/template.js index 1b5f5d6..80a8294 100644 --- a/overlays/covered-pit/template.js +++ b/overlays/covered-pit/template.js @@ -1,4 +1,4 @@ -module.exports = ({ +export default ({ height, width, color, diff --git a/overlays/crowd/index.js b/overlays/crowd/index.js index 5defffb..6da2e45 100644 --- a/overlays/crowd/index.js +++ b/overlays/crowd/index.js @@ -1,6 +1,6 @@ -const template = require("./template.js"); +import template from "./template.js"; -module.exports = class CrowdOverlay { +export default class CrowdOverlay { constructor(options) { this.options = options; } diff --git a/overlays/crowd/template.js b/overlays/crowd/template.js index 48b5afb..79c09b4 100644 --- a/overlays/crowd/template.js +++ b/overlays/crowd/template.js @@ -1,4 +1,4 @@ -module.exports = ({ +export default ({ height, width, color, diff --git a/overlays/crystals/index.js b/overlays/crystals/index.js index d683fc5..1826764 100644 --- a/overlays/crystals/index.js +++ b/overlays/crystals/index.js @@ -1,6 +1,6 @@ -const template = require("./template.js"); +import template from "./template.js"; -module.exports = class CrystalsPitOverlay { +export default class CrystalsPitOverlay { constructor(options) { this.options = options; } diff --git a/overlays/crystals/template.js b/overlays/crystals/template.js index 14c2f92..06f92f2 100644 --- a/overlays/crystals/template.js +++ b/overlays/crystals/template.js @@ -1,4 +1,4 @@ -module.exports = ({ +export default ({ height, width, color, diff --git a/overlays/explosion/index.js b/overlays/explosion/index.js index b0d67d1..8b10e14 100644 --- a/overlays/explosion/index.js +++ b/overlays/explosion/index.js @@ -1,6 +1,6 @@ -const template = require("./template.js"); +import template from "./template.js"; -module.exports = class ExplosionOverlay { +export default class ExplosionOverlay { constructor(options) { this.options = options; } diff --git a/overlays/explosion/template.js b/overlays/explosion/template.js index f7f705e..73708cc 100644 --- a/overlays/explosion/template.js +++ b/overlays/explosion/template.js @@ -1,4 +1,4 @@ -module.exports = ({ +export default ({ height, width, color, diff --git a/overlays/fire/index.js b/overlays/fire/index.js index 8f9b575..c91b2ff 100644 --- a/overlays/fire/index.js +++ b/overlays/fire/index.js @@ -1,6 +1,6 @@ -const template = require("./template.js"); +import template from "./template.js"; -module.exports = class FireOverlay { +export default class FireOverlay { constructor(options) { this.options = options; } diff --git a/overlays/fire/template.js b/overlays/fire/template.js index cc20806..7972df0 100644 --- a/overlays/fire/template.js +++ b/overlays/fire/template.js @@ -1,4 +1,4 @@ -module.exports = ({ +export default ({ height, width, color, diff --git a/overlays/gargoyle-statue/index.js b/overlays/gargoyle-statue/index.js index 274ce0c..52cf4f4 100644 --- a/overlays/gargoyle-statue/index.js +++ b/overlays/gargoyle-statue/index.js @@ -1,6 +1,6 @@ -const template = require("./template.js"); +import template from "./template.js"; -module.exports = class GargoyleStatueOverlay { +export default class GargoyleStatueOverlay { constructor(options) { this.options = options; } diff --git a/overlays/gargoyle-statue/template.js b/overlays/gargoyle-statue/template.js index 9bd0b6a..05e1fdb 100644 --- a/overlays/gargoyle-statue/template.js +++ b/overlays/gargoyle-statue/template.js @@ -1,4 +1,4 @@ -module.exports = ({ +export default ({ height, width, color, diff --git a/overlays/ladder/index.js b/overlays/ladder/index.js index 37f8718..6d71024 100644 --- a/overlays/ladder/index.js +++ b/overlays/ladder/index.js @@ -1,6 +1,6 @@ -const template = require("./template.js"); +import template from "./template.js"; -module.exports = class LadderOverlay { +export default class LadderOverlay { constructor(options) { this.options = options; } diff --git a/overlays/ladder/template.js b/overlays/ladder/template.js index 44f0c99..e4edf5a 100644 --- a/overlays/ladder/template.js +++ b/overlays/ladder/template.js @@ -1,4 +1,4 @@ -module.exports = ({ +export default ({ height, width, color, diff --git a/overlays/lightning/index.js b/overlays/lightning/index.js index d186a0b..d9873f3 100644 --- a/overlays/lightning/index.js +++ b/overlays/lightning/index.js @@ -1,6 +1,6 @@ -const template = require("./template.js"); +import template from "./template.js"; -module.exports = class LightningOverlay { +export default class LightningOverlay { constructor(options) { this.options = options; } diff --git a/overlays/lightning/template.js b/overlays/lightning/template.js index c84c1d4..1aac367 100644 --- a/overlays/lightning/template.js +++ b/overlays/lightning/template.js @@ -1,4 +1,4 @@ -module.exports = ({ +export default ({ height, width, color, diff --git a/overlays/magic-portal/index.js b/overlays/magic-portal/index.js index d28d733..4fd00c3 100644 --- a/overlays/magic-portal/index.js +++ b/overlays/magic-portal/index.js @@ -1,6 +1,6 @@ -const template = require("./template.js"); +import template from "./template.js"; -module.exports = class MagicPortalOverlay { +export default class MagicPortalOverlay { constructor(options) { this.options = options; } diff --git a/overlays/magic-portal/template.js b/overlays/magic-portal/template.js index cb7c05b..2d6bcf9 100644 --- a/overlays/magic-portal/template.js +++ b/overlays/magic-portal/template.js @@ -1,4 +1,4 @@ -module.exports = ({ +export default ({ height, width, color, diff --git a/overlays/net/index.js b/overlays/net/index.js index f7e5a09..734528b 100644 --- a/overlays/net/index.js +++ b/overlays/net/index.js @@ -1,6 +1,6 @@ -const template = require("./template.js"); +import template from "./template.js"; -module.exports = class NetOverlay { +export default class NetOverlay { constructor(options) { this.options = options; } diff --git a/overlays/net/template.js b/overlays/net/template.js index 58068ff..4bff9e9 100644 --- a/overlays/net/template.js +++ b/overlays/net/template.js @@ -1,4 +1,4 @@ -module.exports = ({ +export default ({ height, width, color, diff --git a/overlays/open-pit/index.js b/overlays/open-pit/index.js index b5e73dc..a7e4755 100644 --- a/overlays/open-pit/index.js +++ b/overlays/open-pit/index.js @@ -1,6 +1,6 @@ -const template = require("./template.js"); +import template from "./template.js"; -module.exports = class OpenPitOverlay { +export default class OpenPitOverlay { constructor(options) { this.options = options; } diff --git a/overlays/open-pit/template.js b/overlays/open-pit/template.js index e8bafac..552489c 100644 --- a/overlays/open-pit/template.js +++ b/overlays/open-pit/template.js @@ -1,4 +1,4 @@ -module.exports = ({ +export default ({ height, width, color, diff --git a/overlays/palisade/index.js b/overlays/palisade/index.js index 6e8965b..a4e3fff 100644 --- a/overlays/palisade/index.js +++ b/overlays/palisade/index.js @@ -1,6 +1,6 @@ -const template = require("./template.js"); +import template from "./template.js"; -module.exports = class PalisadeOverlay { +export default class PalisadeOverlay { constructor(options) { this.options = options; } diff --git a/overlays/palisade/template.js b/overlays/palisade/template.js index 3ac8ab1..893f8ac 100644 --- a/overlays/palisade/template.js +++ b/overlays/palisade/template.js @@ -1,4 +1,4 @@ -module.exports = ({ +export default ({ height, width, color, diff --git a/overlays/person/index.js b/overlays/person/index.js index 41cba84..8fe7815 100644 --- a/overlays/person/index.js +++ b/overlays/person/index.js @@ -1,6 +1,6 @@ -const template = require("./template.js"); +import template from "./template.js"; -module.exports = class PersonOverlay { +export default class PersonOverlay { constructor(options) { this.options = options; } diff --git a/overlays/person/template.js b/overlays/person/template.js index f1308a7..cfa5991 100644 --- a/overlays/person/template.js +++ b/overlays/person/template.js @@ -1,4 +1,4 @@ -module.exports = ({ +export default ({ height, width, color, diff --git a/overlays/pillar-round/index.js b/overlays/pillar-round/index.js index 55bd4ea..30b827e 100644 --- a/overlays/pillar-round/index.js +++ b/overlays/pillar-round/index.js @@ -1,6 +1,6 @@ -const template = require("./template.js"); +import template from "./template.js"; -module.exports = class PillarRoundOverlay { +export default class PillarRoundOverlay { constructor(options) { this.options = options; } diff --git a/overlays/pillar-round/template.js b/overlays/pillar-round/template.js index 659f0a6..e19f530 100644 --- a/overlays/pillar-round/template.js +++ b/overlays/pillar-round/template.js @@ -1,4 +1,4 @@ -module.exports = ({ +export default ({ height, width, color, @@ -9,4 +9,4 @@ module.exports = ({ `; -} \ No newline at end of file +}; \ No newline at end of file diff --git a/overlays/pillar-square/index.js b/overlays/pillar-square/index.js index b13561f..7ba8372 100644 --- a/overlays/pillar-square/index.js +++ b/overlays/pillar-square/index.js @@ -1,6 +1,6 @@ -const template = require("./template.js"); +import template from "./template.js"; -module.exports = class PillarSquareOverlay { +export default class PillarSquareOverlay { constructor(options) { this.options = options; } diff --git a/overlays/pillar-square/template.js b/overlays/pillar-square/template.js index 9af08db..8393a4c 100644 --- a/overlays/pillar-square/template.js +++ b/overlays/pillar-square/template.js @@ -1,4 +1,4 @@ -module.exports = ({ +export default ({ height, width, color, @@ -8,4 +8,4 @@ module.exports = ({ `; -} \ No newline at end of file +}; \ No newline at end of file diff --git a/overlays/puddle/index.js b/overlays/puddle/index.js index 2f2adab..acdc359 100644 --- a/overlays/puddle/index.js +++ b/overlays/puddle/index.js @@ -1,6 +1,6 @@ -const template = require("./template.js"); +import template from "./template.js"; -module.exports = class PuddleOverlay { +export default class PuddleOverlay { constructor(options) { this.options = options; } diff --git a/overlays/puddle/template.js b/overlays/puddle/template.js index 8c68d78..4e1fcf4 100644 --- a/overlays/puddle/template.js +++ b/overlays/puddle/template.js @@ -1,4 +1,4 @@ -module.exports = ({ +export default ({ height, width, color, diff --git a/overlays/secret-door/index.js b/overlays/secret-door/index.js index 3485868..37f3258 100644 --- a/overlays/secret-door/index.js +++ b/overlays/secret-door/index.js @@ -1,6 +1,6 @@ -const template = require("./template.js"); +import template from "./template.js"; -module.exports = class SecretDoorOverlay { +export default class SecretDoorOverlay { constructor(options) { this.options = options; } diff --git a/overlays/secret-door/template.js b/overlays/secret-door/template.js index cf78a13..d18481b 100644 --- a/overlays/secret-door/template.js +++ b/overlays/secret-door/template.js @@ -1,4 +1,4 @@ -module.exports = ({ +export default ({ height, width, color, diff --git a/overlays/spiked-pit/index.js b/overlays/spiked-pit/index.js index 4b576b2..b473631 100644 --- a/overlays/spiked-pit/index.js +++ b/overlays/spiked-pit/index.js @@ -1,6 +1,6 @@ -const template = require("./template.js"); +import template from "./template.js"; -module.exports = class SpikedPitOverlay { +export default class SpikedPitOverlay { constructor(options) { this.options = options; } diff --git a/overlays/spiked-pit/template.js b/overlays/spiked-pit/template.js index 94a8d53..b1593f0 100644 --- a/overlays/spiked-pit/template.js +++ b/overlays/spiked-pit/template.js @@ -1,4 +1,4 @@ -module.exports = ({ +export default ({ height, width, color, diff --git a/overlays/spiked-trunk/index.js b/overlays/spiked-trunk/index.js index 589a8de..3fef01d 100644 --- a/overlays/spiked-trunk/index.js +++ b/overlays/spiked-trunk/index.js @@ -1,6 +1,6 @@ -const template = require("./template.js"); +import template from "./template.js"; -module.exports = class SpikedTrunkOverlay { +export default class SpikedTrunkOverlay { constructor(options) { this.options = options; } diff --git a/overlays/spiked-trunk/template.js b/overlays/spiked-trunk/template.js index c7397f8..aad38c4 100644 --- a/overlays/spiked-trunk/template.js +++ b/overlays/spiked-trunk/template.js @@ -1,4 +1,4 @@ -module.exports = ({ +export default ({ height, width, color, diff --git a/overlays/stairs/index.js b/overlays/stairs/index.js index 3d21a52..625fd43 100644 --- a/overlays/stairs/index.js +++ b/overlays/stairs/index.js @@ -1,6 +1,6 @@ -const template = require("./template.js"); +import template from "./template.js"; -module.exports = class StairsOverlay { +export default class StairsOverlay { constructor(options) { this.options = options; } diff --git a/overlays/stairs/template.js b/overlays/stairs/template.js index b7c570b..3f41031 100644 --- a/overlays/stairs/template.js +++ b/overlays/stairs/template.js @@ -1,4 +1,4 @@ -module.exports = ({ +export default ({ height, width, color, diff --git a/overlays/statue-star/index.js b/overlays/statue-star/index.js index 4f00771..ed38e29 100644 --- a/overlays/statue-star/index.js +++ b/overlays/statue-star/index.js @@ -1,6 +1,6 @@ -const template = require("./template.js"); +import template from "./template.js"; -module.exports = class StatueOverlay { +export default class StatueOverlay { constructor(options) { this.options = options; } diff --git a/overlays/statue-star/template.js b/overlays/statue-star/template.js index c033188..b85c0fe 100644 --- a/overlays/statue-star/template.js +++ b/overlays/statue-star/template.js @@ -1,4 +1,4 @@ -module.exports = ({ +export default ({ height, width, radius, diff --git a/overlays/stone-throne/index.js b/overlays/stone-throne/index.js index a016f7f..dfea49d 100644 --- a/overlays/stone-throne/index.js +++ b/overlays/stone-throne/index.js @@ -1,6 +1,6 @@ -const template = require("./template.js"); +import template from "./template.js"; -module.exports = class StoneThroneOverlay { +export default class StoneThroneOverlay { constructor(options) { this.options = options; } diff --git a/overlays/stone-throne/template.js b/overlays/stone-throne/template.js index 81c13f5..1ba19d3 100644 --- a/overlays/stone-throne/template.js +++ b/overlays/stone-throne/template.js @@ -1,4 +1,4 @@ -module.exports = ({ +export default ({ height, width, color, diff --git a/overlays/table/index.js b/overlays/table/index.js index d747179..ef6bdcd 100644 --- a/overlays/table/index.js +++ b/overlays/table/index.js @@ -1,6 +1,6 @@ -const template = require("./template.js"); +import template from "./template.js"; -module.exports = class TableOverlay { +export default class TableOverlay { constructor(options) { this.options = options; } diff --git a/overlays/table/template.js b/overlays/table/template.js index bfb9dc9..bc21f4f 100644 --- a/overlays/table/template.js +++ b/overlays/table/template.js @@ -1,4 +1,4 @@ -module.exports = ({ +export default ({ height, width, color, diff --git a/overlays/thorns/index.js b/overlays/thorns/index.js index bf5edbe..295c8f2 100644 --- a/overlays/thorns/index.js +++ b/overlays/thorns/index.js @@ -1,6 +1,6 @@ -const template = require("./template.js"); +import template from "./template.js"; -module.exports = class ThornsOverlay { +export default class ThornsOverlay { constructor(options) { this.options = options; } diff --git a/overlays/thorns/template.js b/overlays/thorns/template.js index 7fb6336..473766a 100644 --- a/overlays/thorns/template.js +++ b/overlays/thorns/template.js @@ -1,4 +1,4 @@ -module.exports = ({ +export default ({ height, width, color, diff --git a/overlays/token/index.js b/overlays/token/index.js index b3561c4..ffc5223 100644 --- a/overlays/token/index.js +++ b/overlays/token/index.js @@ -1,7 +1,7 @@ -const multiTemplate = require("./multi-template.js"); -const template = require("./template.js"); +import multiTemplate from "./multi-template.js"; +import template from "./template.js"; -module.exports = class TokenOverlay { +export default class TokenOverlay { constructor(options) { this.options = options; } diff --git a/overlays/token/multi-template.js b/overlays/token/multi-template.js index df2508f..9122749 100644 --- a/overlays/token/multi-template.js +++ b/overlays/token/multi-template.js @@ -1,10 +1,10 @@ -const { Image } = require('canvas') +import { Image } from 'canvas'; // For rendering multiple tokens on the same space const subLabelFontSize = 14; -module.exports = ({ +export default ({ gridsize, size, tokenSpecs @@ -171,4 +171,4 @@ module.exports = ({ ctx.restore(); } } -} +}; diff --git a/overlays/token/template.js b/overlays/token/template.js index 3f8b00b..3b1a989 100644 --- a/overlays/token/template.js +++ b/overlays/token/template.js @@ -1,8 +1,8 @@ -const { Image } = require('canvas') +import { Image } from 'canvas'; const subLabelFontSize = 14; -module.exports = ({ +export default ({ gridsize, size, color, @@ -113,4 +113,4 @@ module.exports = ({ } ctx.lineWidth = borderWidth; ctx.stroke(); -} +}; diff --git a/overlays/trap/index.js b/overlays/trap/index.js index 47b4d6b..4df791f 100644 --- a/overlays/trap/index.js +++ b/overlays/trap/index.js @@ -1,6 +1,6 @@ -const template = require("./template.js"); +import template from "./template.js"; -module.exports = class TrapOverlay { +export default class TrapOverlay { constructor(options) { this.options = options; } diff --git a/overlays/trap/template.js b/overlays/trap/template.js index 6c4a0dc..b90ac7e 100644 --- a/overlays/trap/template.js +++ b/overlays/trap/template.js @@ -1,4 +1,4 @@ -module.exports = ({ +export default ({ height, width, color, @@ -10,4 +10,4 @@ module.exports = ({ T `; -} \ No newline at end of file +}; \ No newline at end of file diff --git a/overlays/trip-wire/index.js b/overlays/trip-wire/index.js index a5e325a..c621939 100644 --- a/overlays/trip-wire/index.js +++ b/overlays/trip-wire/index.js @@ -1,6 +1,6 @@ -const template = require("./template.js"); +import template from "./template.js"; -module.exports = class TripWireOverlay { +export default class TripWireOverlay { constructor(options) { this.options = options; } diff --git a/overlays/trip-wire/template.js b/overlays/trip-wire/template.js index 09f7722..3de54ca 100644 --- a/overlays/trip-wire/template.js +++ b/overlays/trip-wire/template.js @@ -1,4 +1,4 @@ -module.exports = ({ +export default ({ height, width, color, diff --git a/overlays/web/index.js b/overlays/web/index.js index e1551dc..cb44285 100644 --- a/overlays/web/index.js +++ b/overlays/web/index.js @@ -1,6 +1,6 @@ -const template = require("./template.js"); +import template from "./template.js"; -module.exports = class WebOverlay { +export default class WebOverlay { constructor(options) { this.options = options; } diff --git a/overlays/web/template.js b/overlays/web/template.js index 08fe6d4..bf380c0 100644 --- a/overlays/web/template.js +++ b/overlays/web/template.js @@ -1,4 +1,4 @@ -module.exports = ({ +export default ({ height, width, color, diff --git a/overlays/wind/index.js b/overlays/wind/index.js index 6e94c66..103b2cd 100644 --- a/overlays/wind/index.js +++ b/overlays/wind/index.js @@ -1,6 +1,6 @@ -const template = require("./template.js"); +import template from "./template.js"; -module.exports = class WindOverlay { +export default class WindOverlay { constructor(options) { this.options = options; } diff --git a/overlays/wind/template.js b/overlays/wind/template.js index 0d4e5f9..b166d92 100644 --- a/overlays/wind/template.js +++ b/overlays/wind/template.js @@ -1,4 +1,4 @@ -module.exports = ({ +export default ({ height, width, color, diff --git a/package.json b/package.json index 1dbd361..4fcde43 100644 --- a/package.json +++ b/package.json @@ -3,27 +3,28 @@ "version": "1.0.0", "description": "", "main": "index.js", + "type": "module", "scripts": { "test": "npm run test:unit && npm run test:integration", - "test:unit": "NODE_NO_WARNINGS=1 tap ./test/unit --no-cov --no-esm --timeout 30000", - "test:integration": "NODE_NO_WARNINGS=1 tap ./test/integration --no-cov --no-esm --timeout 30000", - "test:integration:update": "NODE_NO_WARNINGS=1 TAP_SNAPSHOT=1 tap ./test/integration --no-cov --no-esm --timeout 30000", - "start": "node server.js", - "dev": "nodemon server.js" + "test:unit": "NODE_NO_WARNINGS=1 tap ./test/unit -- --no-cov --disable-coverage --allow-incomplete-coverage --allow-empty-coverage --timeout 30000", + "test:integration": "NODE_NO_WARNINGS=1 tap ./test/integration -- --no-cov --disable-coverage --allow-incomplete-coverage --allow-empty-coverage --timeout 30000", + "test:integration:update": "NODE_NO_WARNINGS=1 TAP_SNAPSHOT=1 tap ./test/integration -- --no-cov --disable-coverage --allow-incomplete-coverage --allow-empty-coverage --timeout 30000", + "start": "node dev.js", + "dev": "nodemon dev.js" }, "keywords": [], "author": "", "license": "ISC", "dependencies": { - "aws-sdk": "^2.753.0", - "node-fetch": "^2.6.0" + "@aws-sdk/client-cloudwatch": "^3.936.0", + "node-fetch": "^3.3.2" }, "devDependencies": { - "canvas": "^2.6.1", - "fastify": "^2.14.1", - "fastify-static": "^2.7.0", - "nodemon": "^2.0.4", - "tap": "^14.10.7", + "@fastify/static": "^7.0.4", + "canvas": "^3.1.0", + "fastify": "^5.6.2", + "nodemon": "^3.1.9", + "tap": "^21.1.3", "tap-image-snapshot": "github:gingermusketeer/tap-image-snapshot" } } diff --git a/parsers/background.js b/parsers/background.js index 5101d7f..4305db0 100644 --- a/parsers/background.js +++ b/parsers/background.js @@ -1,6 +1,6 @@ -const fetch = require("node-fetch"); +import fetch from "node-fetch"; -module.exports = class BackgroundParser { +export default class BackgroundParser { async parse(query) { let backgroundImage = null; if (query.bg) { @@ -8,22 +8,28 @@ module.exports = class BackgroundParser { const pathname = Buffer.from(bg).toString("base64"); const bgBaseURL = "https://bg.otfbm.io"; // const res = await fetch(new URL(pathname, bgBaseURL)); + /*const res = await fetch(bg, { + headers: { "user-agent": "curl/8.1.1" }, + });*/ const res = await fetch(bg); const contentLength = res.headers.get("content-length"); // if (contentLength > 1102000) { - // res.destroy(); - // throw new Error("Background image too large"); + // res.destroy(); + // throw new Error("Background image too large"); // } - const buffer = await res.buffer(); + const buffer = await res.arrayBuffer(); // if (buffer.byteLength > 1102000) throw new Error("Background image too large"); - - backgroundImage = `data:${res.headers.get( - "content-type" - )};base64,${buffer.toString("base64")}`; + try { + backgroundImage = `data:${res.headers.get( + "content-type" + )};base64,${Buffer.from(buffer).toString("base64")}`; + } catch (err) { + console.log("background parser error caught:", err); + } } return backgroundImage; } -}; +} diff --git a/parsers/colour-parser.js b/parsers/colour-parser.js index 294656b..2a364da 100644 --- a/parsers/colour-parser.js +++ b/parsers/colour-parser.js @@ -19,7 +19,7 @@ const colourCodes = new Map([ ["PK", "#ffc1fa"] // pink ]); -module.exports = class ColourParser { +export default class ColourParser { /** * parse a colour * @param {string} str colour code @@ -36,4 +36,4 @@ module.exports = class ColourParser { } return "#07031a"; } -} +}; diff --git a/parsers/config.js b/parsers/config.js index a461a32..f67d0bf 100644 --- a/parsers/config.js +++ b/parsers/config.js @@ -1,4 +1,4 @@ -const fetch = require("node-fetch"); +import fetch from "node-fetch"; async function fetchConfig(url) { const res = await fetch(url); @@ -25,7 +25,7 @@ function deepMerge(...sources) { return acc; } -module.exports = class ConfigParser { +export default class ConfigParser { async parse(query) { let config = null; try { @@ -39,4 +39,4 @@ module.exports = class ConfigParser { } return config; } -}; +} diff --git a/parsers/coord-parser.js b/parsers/coord-parser.js index 5ebca52..e210f52 100644 --- a/parsers/coord-parser.js +++ b/parsers/coord-parser.js @@ -1,6 +1,6 @@ const charOffset = 64; // y coordinates start at A -module.exports = class CoordParser { +export default class CoordParser { /** * convert excel style coordinates to x,y * @param {string} coord @@ -31,4 +31,4 @@ module.exports = class CoordParser { } return result; } -} \ No newline at end of file +}; \ No newline at end of file diff --git a/parsers/effect-parser.js b/parsers/effect-parser.js index 124f12c..f4e8144 100644 --- a/parsers/effect-parser.js +++ b/parsers/effect-parser.js @@ -1,9 +1,9 @@ -const CoordParser = require("./coord-parser.js"); -const TriangleEffect = require("../effects/triangle-effect.js"); -const CircleEffect = require("../effects/circle-effect.js"); -const SquareEffect = require("../effects/square-effect.js"); -const ArrowEffect = require("../effects/arrow-effect.js"); -const ColourParser = require("./colour-parser.js"); +import CoordParser from "./coord-parser.js"; +import TriangleEffect from "../effects/triangle-effect.js"; +import CircleEffect from "../effects/circle-effect.js"; +import SquareEffect from "../effects/square-effect.js"; +import ArrowEffect from "../effects/arrow-effect.js"; +import ColourParser from "./colour-parser.js"; const effectShapes = new Map([ ["T", "triangle"], // aka cone @@ -19,7 +19,7 @@ const decorateUnder = (obj, under) => { return obj; }; -module.exports = class EffectParser { +export default class EffectParser { parse(str) { let trimmed = str.toUpperCase(); if (trimmed.charAt(0) !== "*") return false; @@ -107,4 +107,4 @@ module.exports = class EffectParser { return decorateUnder(overlay, renderUnder); } -}; +} diff --git a/parsers/fog-parser.js b/parsers/fog-parser.js index 0ad3b22..0d1580f 100644 --- a/parsers/fog-parser.js +++ b/parsers/fog-parser.js @@ -1,7 +1,7 @@ -const CoordParser = require("./coord-parser.js"); -const FogEffect = require("../effects/fog-effect.js"); +import CoordParser from "./coord-parser.js"; +import FogEffect from "../effects/fog-effect.js"; -module.exports = class FogParser { +export default class FogParser { parse(str) { const reg = /\*F(([A-Z]{1,2}[0-9]{1,2})+)/i; const matches = str.match(reg); diff --git a/parsers/icon.js b/parsers/icon.js index d8b51df..b6f3f7b 100644 --- a/parsers/icon.js +++ b/parsers/icon.js @@ -1,4 +1,4 @@ -const CoordParser = require("./coord-parser.js"); +import CoordParser from "./coord-parser.js"; const icons = new Map([ ["$D", "./icons/doorway.svg"], @@ -12,7 +12,7 @@ const icons = new Map([ ["$o", "./icons/covered-pit.svg"], ]); -module.exports = class IconParser { +export default class IconParser { parse(str) { if (str.length < 4) return false; diff --git a/parsers/line-parser.js b/parsers/line-parser.js index 6eda48d..bf00c09 100644 --- a/parsers/line-parser.js +++ b/parsers/line-parser.js @@ -1,7 +1,7 @@ -const CoordParser = require("./coord-parser.js"); -const ColourParser = require("./colour-parser.js"); +import CoordParser from "./coord-parser.js"; +import ColourParser from "./colour-parser.js"; -module.exports = class LineParser { +export default class LineParser { parse(str) { let trimmed = str; if (trimmed.charAt(0) !== '_') diff --git a/parsers/overlay.js b/parsers/overlay.js index 368f4c4..1f60681 100644 --- a/parsers/overlay.js +++ b/parsers/overlay.js @@ -1,4 +1,4 @@ -const ColorParser = require("./colour-parser.js"); +import ColorParser from "./colour-parser.js"; const overlays = new Map([ ["tr", "trap"], @@ -35,9 +35,9 @@ const overlays = new Map([ ["es", "chest"] ]); -const Overlay = require("../overlay.js"); +import Overlay from "../overlay.js"; -module.exports = class OverlayParser { +export default class OverlayParser { parse(str) { if (str.length < 4) return false; const reg = /^([A-Za-z][A-Za-z]?[0-9][0-9]?)([A-Za-z][A-Za-z]?[0-9][0-9]?)?(PK|PU|BK|GY|BN|[WKEARGBYPCNOI]|~[0-9A-F]{6}|~[0-9A-F]{3})?\$([A-Za-z]{2})?$/i; diff --git a/parsers/size-parser.js b/parsers/size-parser.js index 3bb4ea2..4ddad1c 100644 --- a/parsers/size-parser.js +++ b/parsers/size-parser.js @@ -8,7 +8,7 @@ const sizes = new Map([ ["G", "gargantuan"], ]); -module.exports = class SizeParser { +export default class SizeParser { static parse(str) { if (str) { var upper = str.toUpperCase(); @@ -16,4 +16,4 @@ module.exports = class SizeParser { } return "medium"; } -} +}; diff --git a/parsers/token.js b/parsers/token.js index 98a5d2b..c45f79c 100644 --- a/parsers/token.js +++ b/parsers/token.js @@ -1,8 +1,8 @@ -const Overlay = require("../overlay.js"); -const ColourParser = require("./colour-parser.js"); -const SizeParser = require("./size-parser.js"); +import Overlay from "../overlay.js"; +import ColourParser from "./colour-parser.js"; +import SizeParser from "./size-parser.js"; -module.exports = class TokenParser { +export default class TokenParser { async parse(str, tokenImages) { if (str.length < 2) return false; @@ -58,4 +58,4 @@ module.exports = class TokenParser { if (regex.test(label.toLowerCase())) return url; } } -}; +} diff --git a/parsers/view-parser.js b/parsers/view-parser.js index d2ec264..27e35ab 100644 --- a/parsers/view-parser.js +++ b/parsers/view-parser.js @@ -1,6 +1,6 @@ -const CoordParser = require("./coord-parser.js"); +import CoordParser from "./coord-parser.js"; -module.exports = class ViewParser { +export default class ViewParser { parse(str) { let match = str.match(/^([A-Z]{1,2}[0-9]{1,2}):([A-Z]{1,4}[0-9]{1,2})$/i); if (match) { diff --git a/renderer/canvas.js b/renderer/canvas.js index 4cf4c9e..69cde36 100644 --- a/renderer/canvas.js +++ b/renderer/canvas.js @@ -1,4 +1,4 @@ -module.exports = class CanvasRenderer { +export default class CanvasRenderer { constructor(ctx, options) { this.ctx = ctx; this.options = options; @@ -23,4 +23,4 @@ module.exports = class CanvasRenderer { new renderer(this.options).render(cell, this.ctx); this.ctx.restore(); } -} +}; diff --git a/renderer/index.js b/renderer/index.js index 1b7c3ce..6d77b63 100644 --- a/renderer/index.js +++ b/renderer/index.js @@ -1,44 +1,42 @@ -const canvas = require("canvas"); -const SVGRenderer = require("./svg.js"); -const CanvasRenderer = require("./canvas.js"); - -// overlays -const assert = require("assert"); -const Options = require("../options.js"); -const Stairs = require("../overlays/stairs/index.js"); -const Token = require("../overlays/token/index.js"); -const MultiToken = require("../overlays/token/index.js"); -const Trap = require("../overlays/trap/index.js"); -const PillarRound = require("../overlays/pillar-round/index.js"); -const PillarSquare = require("../overlays/pillar-square/index.js"); -const StatueStar = require("../overlays/statue-star/index.js"); -const CoveredPit = require("../overlays/covered-pit/index.js"); -const OpenPit = require("../overlays/open-pit/index.js"); -const Ladder = require("../overlays/ladder/index.js"); -const MagicPortal = require("../overlays/magic-portal/index.js") -const GargoyleStatue = require("../overlays/gargoyle-statue/index.js") -const SpikedPit = require("../overlays/spiked-pit/index.js") -const Fire = require("../overlays/fire/index.js") -const Crystals = require("../overlays//crystals/index.js") -const BrickWall = require("../overlays/brick-wall/index.js") -const Lightning = require("../overlays/lightning/index.js") -const StoneThrone = require("../overlays/stone-throne/index.js") -const TripWire = require("../overlays/trip-wire/index.js") -const Person = require("../overlays/person/index.js") -const Crowd = require("../overlays/crowd/index.js") -const Wind = require("../overlays/wind/index.js") -const Web = require("../overlays/web/index.js") -const Palisade = require("../overlays/palisade/index.js") -const SpikedTrunk = require("../overlays/spiked-trunk/index.js") -const SecretDoor = require("../overlays/secret-door/index.js") -const Thorns = require("../overlays/thorns/index.js") -const Column = require("../overlays/column/index.js") -const Explosion = require("../overlays/explosion/index.js") -const Chair = require("../overlays/chair/index.js") -const Table = require("../overlays/table/index.js") -const Net = require("../overlays/net/index.js") -const Puddle = require("../overlays/puddle/index.js") -const Chest = require("../overlays/chest/index.js") +import canvas from "canvas"; +import SVGRenderer from "./svg.js"; +import CanvasRenderer from "./canvas.js"; +import assert from "assert"; +import Options from "../options.js"; +import Stairs from "../overlays/stairs/index.js"; +import Token from "../overlays/token/index.js"; +import MultiToken from "../overlays/token/index.js"; +import Trap from "../overlays/trap/index.js"; +import PillarRound from "../overlays/pillar-round/index.js"; +import PillarSquare from "../overlays/pillar-square/index.js"; +import StatueStar from "../overlays/statue-star/index.js"; +import CoveredPit from "../overlays/covered-pit/index.js"; +import OpenPit from "../overlays/open-pit/index.js"; +import Ladder from "../overlays/ladder/index.js"; +import MagicPortal from "../overlays/magic-portal/index.js"; +import GargoyleStatue from "../overlays/gargoyle-statue/index.js"; +import SpikedPit from "../overlays/spiked-pit/index.js"; +import Fire from "../overlays/fire/index.js"; +import Crystals from "../overlays//crystals/index.js"; +import BrickWall from "../overlays/brick-wall/index.js"; +import Lightning from "../overlays/lightning/index.js"; +import StoneThrone from "../overlays/stone-throne/index.js"; +import TripWire from "../overlays/trip-wire/index.js"; +import Person from "../overlays/person/index.js"; +import Crowd from "../overlays/crowd/index.js"; +import Wind from "../overlays/wind/index.js"; +import Web from "../overlays/web/index.js"; +import Palisade from "../overlays/palisade/index.js"; +import SpikedTrunk from "../overlays/spiked-trunk/index.js"; +import SecretDoor from "../overlays/secret-door/index.js"; +import Thorns from "../overlays/thorns/index.js"; +import Column from "../overlays/column/index.js"; +import Explosion from "../overlays/explosion/index.js"; +import Chair from "../overlays/chair/index.js"; +import Table from "../overlays/table/index.js"; +import Net from "../overlays/net/index.js"; +import Puddle from "../overlays/puddle/index.js"; +import Chest from "../overlays/chest/index.js"; const { createCanvas, registerFont } = canvas; @@ -68,7 +66,7 @@ registerFont('./fonts/Fleisch-Wurst.otf', { style: 'normal', }); -module.exports = class Renderer { +export default class Renderer { constructor(options) { assert( options instanceof Options, diff --git a/renderer/svg.js b/renderer/svg.js index 7cfdf99..3e6d134 100644 --- a/renderer/svg.js +++ b/renderer/svg.js @@ -1,7 +1,7 @@ -const canvas = require("canvas"); +import canvas from "canvas"; const { Image } = canvas; -module.exports = class SVGRenderer { +export default class SVGRenderer { constructor(ctx, options) { this.ctx = ctx; this.options = options; diff --git a/server.js b/server.js index a9876a8..96a877b 100644 --- a/server.js +++ b/server.js @@ -1,5 +1,5 @@ -const fastify = require('fastify'); -const func = require('./index').handler; +import fastify from 'fastify'; +import { handler as func } from './index.js'; const normalizeQueryParams = (query) => { let q = {}; @@ -32,9 +32,5 @@ const createServer = ({ logger = true } = {}) => { return server; } -module.exports = createServer; +export default createServer; -if (!module.parent) { - const server = createServer(); - server.listen(4001); -} \ No newline at end of file diff --git a/tap-snapshots/test-integration-config.test.js-TAP-tokens.test.png b/tap-snapshots/test-integration-config.test.js-TAP-tokens.test.png new file mode 100644 index 0000000..2606f48 Binary files /dev/null and b/tap-snapshots/test-integration-config.test.js-TAP-tokens.test.png differ diff --git a/tap-snapshots/test-integration-config.test.mjs-TAP-tokens.test.png b/tap-snapshots/test-integration-config.test.mjs-TAP-tokens.test.png index 2a3d048..e9b97a2 100644 Binary files a/tap-snapshots/test-integration-config.test.mjs-TAP-tokens.test.png and b/tap-snapshots/test-integration-config.test.mjs-TAP-tokens.test.png differ diff --git a/tap-snapshots/test-integration-image-snapshots.test.js-TAP-FoW---basic---dark-mode.test.png b/tap-snapshots/test-integration-image-snapshots.test.js-TAP-FoW---basic---dark-mode.test.png new file mode 100644 index 0000000..8303763 Binary files /dev/null and b/tap-snapshots/test-integration-image-snapshots.test.js-TAP-FoW---basic---dark-mode.test.png differ diff --git a/tap-snapshots/test-integration-image-snapshots.test.js-TAP-FoW---basic---light-mode.test.png b/tap-snapshots/test-integration-image-snapshots.test.js-TAP-FoW---basic---light-mode.test.png new file mode 100644 index 0000000..cf9ae57 Binary files /dev/null and b/tap-snapshots/test-integration-image-snapshots.test.js-TAP-FoW---basic---light-mode.test.png differ diff --git a/tap-snapshots/test-integration-image-snapshots.test.js-TAP-background.test.png b/tap-snapshots/test-integration-image-snapshots.test.js-TAP-background.test.png new file mode 100644 index 0000000..54e0191 Binary files /dev/null and b/tap-snapshots/test-integration-image-snapshots.test.js-TAP-background.test.png differ diff --git a/tap-snapshots/test-integration-image-snapshots.test.js-TAP-complex-multiple-features-1.test.png b/tap-snapshots/test-integration-image-snapshots.test.js-TAP-complex-multiple-features-1.test.png new file mode 100644 index 0000000..3a60904 Binary files /dev/null and b/tap-snapshots/test-integration-image-snapshots.test.js-TAP-complex-multiple-features-1.test.png differ diff --git a/tap-snapshots/test-integration-image-snapshots.test.js-TAP-complex-multiple-features-2.test.png b/tap-snapshots/test-integration-image-snapshots.test.js-TAP-complex-multiple-features-2.test.png new file mode 100644 index 0000000..eff9746 Binary files /dev/null and b/tap-snapshots/test-integration-image-snapshots.test.js-TAP-complex-multiple-features-2.test.png differ diff --git a/tap-snapshots/test-integration-image-snapshots.test.js-TAP-dotted-lines-pan-x-only---to-the-end.test.png b/tap-snapshots/test-integration-image-snapshots.test.js-TAP-dotted-lines-pan-x-only---to-the-end.test.png new file mode 100644 index 0000000..f09e832 Binary files /dev/null and b/tap-snapshots/test-integration-image-snapshots.test.js-TAP-dotted-lines-pan-x-only---to-the-end.test.png differ diff --git a/tap-snapshots/test-integration-image-snapshots.test.js-TAP-dotted-lines-pan-x-only.test.png b/tap-snapshots/test-integration-image-snapshots.test.js-TAP-dotted-lines-pan-x-only.test.png new file mode 100644 index 0000000..27ace4f Binary files /dev/null and b/tap-snapshots/test-integration-image-snapshots.test.js-TAP-dotted-lines-pan-x-only.test.png differ diff --git a/tap-snapshots/test-integration-image-snapshots.test.js-TAP-dotted-lines-pan-y-only.test.png b/tap-snapshots/test-integration-image-snapshots.test.js-TAP-dotted-lines-pan-y-only.test.png new file mode 100644 index 0000000..758098b Binary files /dev/null and b/tap-snapshots/test-integration-image-snapshots.test.js-TAP-dotted-lines-pan-y-only.test.png differ diff --git a/tap-snapshots/test-integration-image-snapshots.test.js-TAP-dotted-lines-top-right---right-bottom-left---left.test.png b/tap-snapshots/test-integration-image-snapshots.test.js-TAP-dotted-lines-top-right---right-bottom-left---left.test.png new file mode 100644 index 0000000..aefc398 Binary files /dev/null and b/tap-snapshots/test-integration-image-snapshots.test.js-TAP-dotted-lines-top-right---right-bottom-left---left.test.png differ diff --git a/tap-snapshots/test-integration-image-snapshots.test.js-TAP-dotted-lines-top-right---up-pan-bottom-left---left-pan-.test.png b/tap-snapshots/test-integration-image-snapshots.test.js-TAP-dotted-lines-top-right---up-pan-bottom-left---left-pan-.test.png new file mode 100644 index 0000000..714ae5f Binary files /dev/null and b/tap-snapshots/test-integration-image-snapshots.test.js-TAP-dotted-lines-top-right---up-pan-bottom-left---left-pan-.test.png differ diff --git a/tap-snapshots/test-integration-image-snapshots.test.js-TAP-edge-case-border-between-az-and-ba.test.png b/tap-snapshots/test-integration-image-snapshots.test.js-TAP-edge-case-border-between-az-and-ba.test.png new file mode 100644 index 0000000..f653152 Binary files /dev/null and b/tap-snapshots/test-integration-image-snapshots.test.js-TAP-edge-case-border-between-az-and-ba.test.png differ diff --git a/tap-snapshots/test-integration-image-snapshots.test.js-TAP-edge-case-border-between-z-and-aa.test.png b/tap-snapshots/test-integration-image-snapshots.test.js-TAP-edge-case-border-between-z-and-aa.test.png new file mode 100644 index 0000000..1e2acba Binary files /dev/null and b/tap-snapshots/test-integration-image-snapshots.test.js-TAP-edge-case-border-between-z-and-aa.test.png differ diff --git a/tap-snapshots/test-integration-image-snapshots.test.js-TAP-edge-cases-effects.test.png b/tap-snapshots/test-integration-image-snapshots.test.js-TAP-edge-cases-effects.test.png new file mode 100644 index 0000000..87561fb Binary files /dev/null and b/tap-snapshots/test-integration-image-snapshots.test.js-TAP-edge-cases-effects.test.png differ diff --git a/tap-snapshots/test-integration-image-snapshots.test.js-TAP-edge-cases-overlays.test.png b/tap-snapshots/test-integration-image-snapshots.test.js-TAP-edge-cases-overlays.test.png new file mode 100644 index 0000000..67091e6 Binary files /dev/null and b/tap-snapshots/test-integration-image-snapshots.test.js-TAP-edge-cases-overlays.test.png differ diff --git a/tap-snapshots/test-integration-image-snapshots.test.js-TAP-edge-cases-walls.test.png b/tap-snapshots/test-integration-image-snapshots.test.js-TAP-edge-cases-walls.test.png new file mode 100644 index 0000000..ae7bf62 Binary files /dev/null and b/tap-snapshots/test-integration-image-snapshots.test.js-TAP-edge-cases-walls.test.png differ diff --git a/tap-snapshots/test-integration-image-snapshots.test.js-TAP-effects.test.png b/tap-snapshots/test-integration-image-snapshots.test.js-TAP-effects.test.png new file mode 100644 index 0000000..8790143 Binary files /dev/null and b/tap-snapshots/test-integration-image-snapshots.test.js-TAP-effects.test.png differ diff --git a/tap-snapshots/test-integration-image-snapshots.test.js-TAP-overlays-colors.test.png b/tap-snapshots/test-integration-image-snapshots.test.js-TAP-overlays-colors.test.png new file mode 100644 index 0000000..555e82c Binary files /dev/null and b/tap-snapshots/test-integration-image-snapshots.test.js-TAP-overlays-colors.test.png differ diff --git a/tap-snapshots/test-integration-image-snapshots.test.js-TAP-overlays-rotations.test.png b/tap-snapshots/test-integration-image-snapshots.test.js-TAP-overlays-rotations.test.png new file mode 100644 index 0000000..c33ae32 Binary files /dev/null and b/tap-snapshots/test-integration-image-snapshots.test.js-TAP-overlays-rotations.test.png differ diff --git a/tap-snapshots/test-integration-image-snapshots.test.js-TAP-overlays-sizes.test.png b/tap-snapshots/test-integration-image-snapshots.test.js-TAP-overlays-sizes.test.png new file mode 100644 index 0000000..bbd0a09 Binary files /dev/null and b/tap-snapshots/test-integration-image-snapshots.test.js-TAP-overlays-sizes.test.png differ diff --git a/tap-snapshots/test-integration-image-snapshots.test.js-TAP-overlays.test.png b/tap-snapshots/test-integration-image-snapshots.test.js-TAP-overlays.test.png new file mode 100644 index 0000000..dc6dd53 Binary files /dev/null and b/tap-snapshots/test-integration-image-snapshots.test.js-TAP-overlays.test.png differ diff --git a/tap-snapshots/test-integration-image-snapshots.test.js-TAP-settings-dark-mode.test.png b/tap-snapshots/test-integration-image-snapshots.test.js-TAP-settings-dark-mode.test.png new file mode 100644 index 0000000..847206c Binary files /dev/null and b/tap-snapshots/test-integration-image-snapshots.test.js-TAP-settings-dark-mode.test.png differ diff --git a/tap-snapshots/test-integration-image-snapshots.test.js-TAP-settings-grid-transparency-half.test.png b/tap-snapshots/test-integration-image-snapshots.test.js-TAP-settings-grid-transparency-half.test.png new file mode 100644 index 0000000..89722d6 Binary files /dev/null and b/tap-snapshots/test-integration-image-snapshots.test.js-TAP-settings-grid-transparency-half.test.png differ diff --git a/tap-snapshots/test-integration-image-snapshots.test.js-TAP-settings-grid-transparency-no-grid.test.png b/tap-snapshots/test-integration-image-snapshots.test.js-TAP-settings-grid-transparency-no-grid.test.png new file mode 100644 index 0000000..5aa51bf Binary files /dev/null and b/tap-snapshots/test-integration-image-snapshots.test.js-TAP-settings-grid-transparency-no-grid.test.png differ diff --git a/tap-snapshots/test-integration-image-snapshots.test.js-TAP-settings-zoom-2.test.png b/tap-snapshots/test-integration-image-snapshots.test.js-TAP-settings-zoom-2.test.png new file mode 100644 index 0000000..64ee5d5 Binary files /dev/null and b/tap-snapshots/test-integration-image-snapshots.test.js-TAP-settings-zoom-2.test.png differ diff --git a/tap-snapshots/test-integration-image-snapshots.test.js-TAP-settings-zoom-3.test.png b/tap-snapshots/test-integration-image-snapshots.test.js-TAP-settings-zoom-3.test.png new file mode 100644 index 0000000..047f633 Binary files /dev/null and b/tap-snapshots/test-integration-image-snapshots.test.js-TAP-settings-zoom-3.test.png differ diff --git a/tap-snapshots/test-integration-image-snapshots.test.js-TAP-token-image-backgrounds.test.png b/tap-snapshots/test-integration-image-snapshots.test.js-TAP-token-image-backgrounds.test.png new file mode 100644 index 0000000..ea7e747 Binary files /dev/null and b/tap-snapshots/test-integration-image-snapshots.test.js-TAP-token-image-backgrounds.test.png differ diff --git a/tap-snapshots/test-integration-image-snapshots.test.js-TAP-tokens.test.png b/tap-snapshots/test-integration-image-snapshots.test.js-TAP-tokens.test.png new file mode 100644 index 0000000..b70da12 Binary files /dev/null and b/tap-snapshots/test-integration-image-snapshots.test.js-TAP-tokens.test.png differ diff --git a/tap-snapshots/test-integration-image-snapshots.test.js-TAP-walls.test.png b/tap-snapshots/test-integration-image-snapshots.test.js-TAP-walls.test.png new file mode 100644 index 0000000..a93a385 Binary files /dev/null and b/tap-snapshots/test-integration-image-snapshots.test.js-TAP-walls.test.png differ diff --git a/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-FoW---basic---dark-mode.diff.png b/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-FoW---basic---dark-mode.diff.png deleted file mode 100644 index e0da295..0000000 Binary files a/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-FoW---basic---dark-mode.diff.png and /dev/null differ diff --git a/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-FoW---basic---dark-mode.test.png b/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-FoW---basic---dark-mode.test.png index f959f2c..ca6372b 100644 Binary files a/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-FoW---basic---dark-mode.test.png and b/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-FoW---basic---dark-mode.test.png differ diff --git a/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-FoW---basic---light-mode.diff.png b/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-FoW---basic---light-mode.diff.png deleted file mode 100644 index 5dbb9b5..0000000 Binary files a/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-FoW---basic---light-mode.diff.png and /dev/null differ diff --git a/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-FoW---basic---light-mode.test.png b/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-FoW---basic---light-mode.test.png index 4be20c3..d2d98ba 100644 Binary files a/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-FoW---basic---light-mode.test.png and b/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-FoW---basic---light-mode.test.png differ diff --git a/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-background.test.png b/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-background.test.png index 111b821..476d8bc 100644 Binary files a/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-background.test.png and b/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-background.test.png differ diff --git a/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-complex-multiple-features-1.test.png b/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-complex-multiple-features-1.test.png index 0048200..07b60a9 100644 Binary files a/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-complex-multiple-features-1.test.png and b/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-complex-multiple-features-1.test.png differ diff --git a/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-complex-multiple-features-2.test.png b/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-complex-multiple-features-2.test.png index b9ac3e9..5ce3ce2 100644 Binary files a/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-complex-multiple-features-2.test.png and b/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-complex-multiple-features-2.test.png differ diff --git a/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-dotted-lines-pan-x-only---to-the-end.test.png b/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-dotted-lines-pan-x-only---to-the-end.test.png index c212c5a..46aabfd 100644 Binary files a/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-dotted-lines-pan-x-only---to-the-end.test.png and b/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-dotted-lines-pan-x-only---to-the-end.test.png differ diff --git a/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-dotted-lines-pan-x-only.test.png b/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-dotted-lines-pan-x-only.test.png index f8c34be..da13a48 100644 Binary files a/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-dotted-lines-pan-x-only.test.png and b/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-dotted-lines-pan-x-only.test.png differ diff --git a/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-dotted-lines-pan-y-only.test.png b/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-dotted-lines-pan-y-only.test.png index 216e074..caa79e7 100644 Binary files a/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-dotted-lines-pan-y-only.test.png and b/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-dotted-lines-pan-y-only.test.png differ diff --git a/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-dotted-lines-top-right---right-bottom-left---left.test.png b/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-dotted-lines-top-right---right-bottom-left---left.test.png index 91c25c4..48b5f42 100644 Binary files a/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-dotted-lines-top-right---right-bottom-left---left.test.png and b/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-dotted-lines-top-right---right-bottom-left---left.test.png differ diff --git a/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-dotted-lines-top-right---up-pan-bottom-left---left-pan-.test.png b/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-dotted-lines-top-right---up-pan-bottom-left---left-pan-.test.png index 00d1321..c3f3c62 100644 Binary files a/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-dotted-lines-top-right---up-pan-bottom-left---left-pan-.test.png and b/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-dotted-lines-top-right---up-pan-bottom-left---left-pan-.test.png differ diff --git a/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-edge-case-border-between-az-and-ba.test.png b/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-edge-case-border-between-az-and-ba.test.png index d526108..0807e64 100644 Binary files a/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-edge-case-border-between-az-and-ba.test.png and b/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-edge-case-border-between-az-and-ba.test.png differ diff --git a/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-edge-case-border-between-z-and-aa.test.png b/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-edge-case-border-between-z-and-aa.test.png index 0f0ff9b..da3f56b 100644 Binary files a/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-edge-case-border-between-z-and-aa.test.png and b/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-edge-case-border-between-z-and-aa.test.png differ diff --git a/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-edge-cases-effects.test.png b/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-edge-cases-effects.test.png index 8438b59..7d35284 100644 Binary files a/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-edge-cases-effects.test.png and b/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-edge-cases-effects.test.png differ diff --git a/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-edge-cases-overlays.test.png b/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-edge-cases-overlays.test.png index 43971ba..ebc1859 100644 Binary files a/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-edge-cases-overlays.test.png and b/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-edge-cases-overlays.test.png differ diff --git a/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-edge-cases-walls.test.png b/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-edge-cases-walls.test.png index b060eea..212289e 100644 Binary files a/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-edge-cases-walls.test.png and b/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-edge-cases-walls.test.png differ diff --git a/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-effects.test.png b/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-effects.test.png index 16e8c39..b220632 100644 Binary files a/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-effects.test.png and b/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-effects.test.png differ diff --git a/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-overlays-colors.test.png b/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-overlays-colors.test.png index 26ad659..e46a7a8 100644 Binary files a/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-overlays-colors.test.png and b/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-overlays-colors.test.png differ diff --git a/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-overlays-rotations.test.png b/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-overlays-rotations.test.png index 83958c1..85a283b 100644 Binary files a/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-overlays-rotations.test.png and b/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-overlays-rotations.test.png differ diff --git a/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-overlays-sizes.test.png b/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-overlays-sizes.test.png index 436fbaa..699c9fe 100644 Binary files a/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-overlays-sizes.test.png and b/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-overlays-sizes.test.png differ diff --git a/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-overlays.test.png b/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-overlays.test.png index 352049e..d841f7e 100644 Binary files a/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-overlays.test.png and b/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-overlays.test.png differ diff --git a/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-settings-dark-mode.test.png b/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-settings-dark-mode.test.png index 104cd55..8205cfd 100644 Binary files a/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-settings-dark-mode.test.png and b/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-settings-dark-mode.test.png differ diff --git a/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-settings-grid-transparency-half.test.png b/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-settings-grid-transparency-half.test.png index 2d2bf26..7e1b07c 100644 Binary files a/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-settings-grid-transparency-half.test.png and b/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-settings-grid-transparency-half.test.png differ diff --git a/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-settings-grid-transparency-no-grid.test.png b/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-settings-grid-transparency-no-grid.test.png index 2a5cfc9..a5d1f8c 100644 Binary files a/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-settings-grid-transparency-no-grid.test.png and b/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-settings-grid-transparency-no-grid.test.png differ diff --git a/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-settings-zoom-2.test.png b/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-settings-zoom-2.test.png index 0d1ffd1..b54d1a1 100644 Binary files a/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-settings-zoom-2.test.png and b/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-settings-zoom-2.test.png differ diff --git a/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-settings-zoom-3.test.png b/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-settings-zoom-3.test.png index cd5b702..00d41df 100644 Binary files a/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-settings-zoom-3.test.png and b/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-settings-zoom-3.test.png differ diff --git a/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-tokens.test.png b/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-tokens.test.png index 0e2d6ca..645c5ca 100644 Binary files a/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-tokens.test.png and b/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-tokens.test.png differ diff --git a/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-walls.test.png b/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-walls.test.png index c9b3e7f..23b504f 100644 Binary files a/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-walls.test.png and b/tap-snapshots/test-integration-image-snapshots.test.mjs-TAP-walls.test.png differ diff --git a/test/integration/config.test.mjs b/test/integration/config.test.js similarity index 100% rename from test/integration/config.test.mjs rename to test/integration/config.test.js diff --git a/test/integration/image-snapshots.test.mjs b/test/integration/image-snapshots.test.js similarity index 100% rename from test/integration/image-snapshots.test.mjs rename to test/integration/image-snapshots.test.js diff --git a/token/otfbm-token.py b/token/otfbm-token.py index 84da5c6..6d34eee 100755 --- a/token/otfbm-token.py +++ b/token/otfbm-token.py @@ -134,7 +134,7 @@ def convert_alpha(buffer): def download_img(buffer, url): - resp = requests.get(url, stream=True) + resp = requests.get(url, stream=True, headers={"user-agent": "curl/8.1.1"}) # TODO err handling if resp.status_code == 200: for chunk in resp: