Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

favicon-marquee

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

favicon-marquee - npm Package Compare versions

Comparing version 2.0.0 to 2.1.0

34

lib/worker.d.ts

@@ -1,33 +0,1 @@

type Renderer = import("./types").Renderer;
type DataMessage = import("./types").DataMessage;
type FaviconMarqueeParameters = import("./types").FaviconMarqueeParameters;
type State = import("./types").State;
type Message = import("./types").Message;
declare const CANVAS_SIZE = 256;
declare class CanvasPainter {
private readonly text;
private readonly color;
private readonly stepSize;
private readonly font;
private readonly marginBottom;
private readonly background?;
private readonly textWidth;
private pixelsScrolled;
private renderingContext;
constructor({ text, font, color, step, marginBottom, background, }: FaviconMarqueeParameters, renderingContext: OffscreenCanvasRenderingContext2D | CanvasRenderingContext2D);
step(): void;
}
declare class OffscreenCanvasRenderer implements Renderer {
private readonly canvas;
private readonly canvasDrawer;
private state;
constructor(parameters: FaviconMarqueeParameters);
start(): void;
/**
* Stop the marquee. It can be restarted again using {@link start}
*/
stop(): void;
private getDataUrl;
private handleDataUrl;
}
declare let renderer: OffscreenCanvasRenderer | undefined;
export {};

@@ -1,47 +0,4 @@

"use strict";
// Currently, when any values are imported using normal 'import { x } from "y"' code, TypeScript generates ESM code for this file.
// Since Firefox does not support ESM workers, nothing can be imported like normal.
// TODO when Firefox starts supporting ESM workers (https://stackoverflow.com/a/45578811, expected March 2023):
// 1. Import the types like normal
// 2. Create a "module" type worker in main.ts
// 3. Stop duplicating the CanvasDrawer class code, instead import it and CANVAS_SIZE from canvasPainter.ts
// 4. Use enum values for OffscreenCanvasRenderer's state
import { CanvasPainter } from "./canvasPainter.js";
import { State } from "./types.js";
const CANVAS_SIZE = 256;
class CanvasPainter {
text;
color;
stepSize;
font;
marginBottom;
background;
textWidth;
pixelsScrolled;
renderingContext;
constructor({ text = "SCROLLING TEXT", font = '"Arial", sans-serif', color = "green", step = 0.75, marginBottom = 0, background, }, renderingContext) {
this.text = text;
this.color = color;
this.stepSize = step;
this.font = font;
this.marginBottom = marginBottom;
this.background = background;
this.pixelsScrolled = 0;
this.renderingContext = renderingContext;
this.renderingContext.font = CANVAS_SIZE + "px " + this.font;
this.textWidth = Math.ceil(this.renderingContext.measureText(this.text).width);
}
step() {
if (this.background) {
this.renderingContext.fillStyle = this.background;
this.renderingContext.fillRect(0, 0, CANVAS_SIZE, CANVAS_SIZE);
}
else {
this.renderingContext.clearRect(0, 0, CANVAS_SIZE, CANVAS_SIZE);
}
this.pixelsScrolled = (this.pixelsScrolled + this.stepSize) % (this.textWidth + 2 * CANVAS_SIZE);
this.renderingContext.fillStyle = this.color;
const widthOffset = -1 * this.pixelsScrolled + CANVAS_SIZE; // negation of pixelsScrolled because canvas scrolls left-to-right
// then add CANVAS_SIZE to begin rendering with blank canvas
this.renderingContext.fillText(this.text, widthOffset, CANVAS_SIZE - this.marginBottom);
}
}
class OffscreenCanvasRenderer {

@@ -58,9 +15,9 @@ canvas;

this.canvasDrawer = new CanvasPainter(parameters, renderingContext);
this.state = 0;
this.state = State.Stopped;
}
start() {
if (this.state == 1) {
if (this.state == State.Running) {
return;
}
this.state = 1;
this.state = State.Running;
const render = async () => {

@@ -80,3 +37,3 @@ if (this.state === 1) {

stop() {
this.state = 0;
this.state = State.Stopped;
}

@@ -83,0 +40,0 @@ async getDataUrl() {

2

lib/workerRenderer.js

@@ -6,3 +6,3 @@ export class WorkerRenderer {

constructor(parameters, favicon) {
this.worker = new Worker(new URL("./worker.js", import.meta.url));
this.worker = new Worker(new URL("./worker.js", import.meta.url), { type: "module" });
this.parameters = parameters;

@@ -9,0 +9,0 @@ this.favicon = favicon;

{
"name": "favicon-marquee",
"version": "2.0.0",
"version": "2.1.0",
"description": "An animated scrolling favicon for your website",

@@ -8,4 +8,6 @@ "author": "Sten Laane <sten@laane.xyz> (https://laane.xyz)",

"types": "lib/main.d.ts",
"type": "module",
"files": [
"lib"
"lib",
"!lib/**/__tests__/**/*"
],

@@ -16,9 +18,11 @@ "scripts": {

"format:fix": "prettier --write src/**/*",
"prepublishOnly": "npm run compile"
"prepublishOnly": "npm run compile",
"test": "tsc && docker compose -f src/__tests__/docker-compose.yml up --abort-on-container-exit"
},
"license": "MIT",
"devDependencies": {
"@typescript/lib-dom": "npm:@types/web@^0.0.90",
"@types/selenium-webdriver": "^4.1.15",
"prettier": "^2.8.3",
"typescript": "^4.9.4"
"selenium-webdriver": "^4.10.0",
"typescript": "~5.1.3"
},

@@ -25,0 +29,0 @@ "repository": "https://github.com/StenAL/favicon-marquee",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc