Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update deps #1319

Merged
merged 16 commits into from
Sep 2, 2024
Merged
604 changes: 149 additions & 455 deletions .all-contributorsrc

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions .ncurc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"reject": [
// These deps are esm only
"pixelmatch",
"mime",
"@types/mime",
"file-type",
// We support node 18 and above
"@types/node"
]
}
4 changes: 2 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"prettier.prettierPath": "./node_modules/prettier/index.cjs",
}
"prettier.prettierPath": "./node_modules/prettier/index.cjs"
}
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#### Make brightness function behave like other implementations ([#1312](https://github.com/jimp-dev/jimp/pull/1312))

This PR changes the `brightness` function to behave like the css brightness function and other implementations. Previously it was doing something odd. Instead of multiplying the color channel by the multiplier value, it multiplied against the inversion of the current color.
This PR changes the `brightness` function to behave like the css brightness function and other implementations. Previously it was doing something odd. Instead of multiplying the color channel by the multiplier value, it multiplied against the inversion of the current color.

In the current version a value of `1` won't change the colors at all. Values above 1 will brighten the colors, values below 1 will darken the colors.

Expand Down
7 changes: 2 additions & 5 deletions lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,5 @@
"npmClient": "pnpm",
"registry": "https://registry.npmjs.org/",
"version": "1.1.2",
"packages": [
"packages/*",
"plugins/*"
]
}
"packages": ["packages/*", "plugins/*"]
}
25 changes: 11 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
{
"name": "jimp-monorepo",
"private": true,
"packageManager": "pnpm@9.9.0",
"description": "The jimp monorepo.",
"repository": "jimp-dev/jimp",
"author": "Andrew Lisowski <lisowski54@gmail.com>",
"engines": {
"node": ">=18"
},
"author": "Andrew Lisowski <lisowski54@gmail.com>",
"scripts": {
"build": "turbo run build build:browser --filter=!docs",
"build": "turbo run build build:browser --filter=!@jimp/docs",
"dev": "turbo run dev",
"lint": "turbo run lint",
"test": "turbo run test -- --watch=false",
Expand All @@ -16,24 +18,19 @@
"format": "prettier --write \"**/*.{ts,tsx,md}\"",
"release": "pnpm build && auto shipit",
"generate-package": "turbo gen package",
"generate-plugin": "turbo gen plugin"
"generate-plugin": "turbo gen plugin",
"check-updates": "ncu --packageFile '{,*/**/}package.json'"
},
"devDependencies": {
"@auto-it/all-contributors": "^11.2.1",
"@auto-it/first-time-contributor": "^11.2.1",
"@auto-it/released": "^11.2.1",
"@jimp/config-eslint": "workspace:*",
"@jimp/config-typescript": "workspace:*",
"@turbo/gen": "^1.12.5",
"any-base": "^1.1.0",
"@turbo/gen": "^2.1.1",
"auto": "^11.2.1",
"prettier": "^3.2.5",
"turbo": "^1.13.0"
},
"packageManager": "pnpm@8.9.0",
"publishConfig": {
"registry": "https://registry.npmjs.org/",
"access": "public"
},
"sideEffects": false
"npm-check-updates": "^17.1.1",
"prettier": "^3.3.3",
"turbo": "^2.1.1"
}
}
64 changes: 24 additions & 40 deletions packages/config-eslint/base.js
Original file line number Diff line number Diff line change
@@ -1,44 +1,28 @@
const { resolve } = require("node:path");
import js from "@eslint/js";
import eslintConfigPrettier from "eslint-config-prettier";
import turboPlugin from "eslint-plugin-turbo";
import tseslint from "typescript-eslint";

const project = resolve(process.cwd(), "tsconfig.json");

/** @type {import("eslint").Linter.Config} */
module.exports = {
extends: [
"eslint:recommended",
"prettier",
"eslint-config-turbo",
"plugin:@typescript-eslint/recommended",
],
plugins: ["only-warn"],
globals: {
React: true,
JSX: true,
},
env: {
node: true,
export default [
js.configs.recommended,
eslintConfigPrettier,
...tseslint.configs.recommended,
{
ignores: [
// Ignore dotfiles
".*.js",
"node_modules/",
"dist/",
"**/browser.js",
],
},
settings: {
"import/resolver": {
typescript: {
project,
},
{
name: "eslint-config-turbo (recreated flat)",
plugins: {
turbo: { rules: turboPlugin.rules },
},
},
parser: "@typescript-eslint/parser",
parserOptions: {
project,
},
ignorePatterns: [
// Ignore dotfiles
".*.js",
"node_modules/",
"dist/",
"**/browser.js",
],
overrides: [
{
files: ["*.js?(x)", "*.ts?(x)"],
rules: {
"turbo/no-undeclared-env-vars": "error",
},
],
};
},
];
13 changes: 8 additions & 5 deletions packages/config-eslint/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,20 @@
"license": "MIT",
"private": true,
"main": "base.js",
"type": "module",
"scripts": {
"clean": "rm -rf node_modules .tshy .tshy-build dist .turbo"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^7.2.0",
"@typescript-eslint/parser": "^7.2.0",
"eslint-config-prettier": "^9.1.0",
"eslint-config-turbo": "^1.12.5",
"eslint-plugin-only-warn": "^1.1.0",
"eslint-config-turbo": "^2.1.1",
"typescript": "^5.5.4"
},
"publishConfig": {},
"sideEffects": false
"sideEffects": false,
"dependencies": {
"@eslint/js": "^9.9.1",
"@types/eslint__js": "^8.42.3",
"typescript-eslint": "^8.3.0"
}
}
2 changes: 1 addition & 1 deletion packages/config-typescript/base.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@
"allowJs": true,
"target": "ES2022"
}
}
}
2 changes: 1 addition & 1 deletion packages/config-vitest/browser.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { nodePolyfills } from "vite-plugin-node-polyfills";
const require = createRequire(import.meta.url);
const imagesFolder = path.join(
path.join(path.dirname(require.resolve("@jimp/test-utils")), "../../"),
"images"
"images",
);

export default defineConfig({
Expand Down
11 changes: 7 additions & 4 deletions packages/config-vitest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
"version": "1.1.2",
"private": true,
"repository": "jimp-dev/jimp",
"engines": {
"node": ">=18"
},
"scripts": {
"dev": "tshy --watch",
"clean": "rm -rf node_modules .tshy .tshy-build dist .turbo"
Expand All @@ -12,14 +15,14 @@
"devDependencies": {
"@jimp/config-typescript": "workspace:*",
"@jimp/test-utils": "workspace:*",
"eslint": "^8.57.0",
"eslint": "^9.9.1",
"typescript": "^5.5.4",
"vitest": "^1.4.0"
"vitest": "^2.0.5"
},
"dependencies": {
"@esbuild-plugins/node-globals-polyfill": "^0.2.3",
"playwright": "^1.42.1",
"vite-plugin-node-polyfills": "^0.21.0"
"playwright": "^1.46.1",
"vite-plugin-node-polyfills": "^0.22.0"
},
"type": "module",
"publishConfig": {
Expand Down
5 changes: 0 additions & 5 deletions packages/core/.eslintrc.cjs

This file was deleted.

9 changes: 9 additions & 0 deletions packages/core/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import shared from "@jimp/config-eslint/base.js";
export default [
...shared,
{
rules: {
"@typescript-eslint/no-explicit-any": "off",
},
},
];
9 changes: 6 additions & 3 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"name": "@jimp/core",
"version": "1.1.2",
"repository": "jimp-dev/jimp",
"engines": {
"node": ">=18"
},
"scripts": {
"lint": "eslint .",
"test-off": "vitest",
Expand All @@ -26,11 +29,11 @@
"@jimp/test-utils": "workspace:*",
"@types/file-type": "^10.9.1",
"@types/mime": "^3.0.4",
"@types/node": "^20.12.5",
"eslint": "^8.57.0",
"@types/node": "^18.19.48",
"eslint": "^9.9.1",
"tshy": "^3.0.2",
"typescript": "^5.5.4",
"vitest": "^1.4.0"
"vitest": "^2.0.5"
},
"tshy": {
"exclude": [
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ export function createJimp<
let outputImage: Jimp;

if (format.hasAlpha) {
// eslint-disable-next-line @typescript-eslint/no-this-alias
outputImage = this;
} else {
outputImage = new CustomJimp({
Expand Down
10 changes: 3 additions & 7 deletions packages/core/src/utils/composite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Edge, JimpClass } from "@jimp/types";

import { BlendMode } from "./constants.js";
import * as compositeModes from "./composite-modes.js";
import { limit255, scan } from "@jimp/utils";
import { limit255 } from "@jimp/utils";

export function composite<I extends JimpClass>(
baseImage: I,
Expand All @@ -23,11 +23,8 @@ export function composite<I extends JimpClass>(
throw new Error("x and y must be numbers");
}

let {
mode = BlendMode.SRC_OVER,
opacitySource = 1.0,
opacityDest = 1.0,
} = options;
const { mode = BlendMode.SRC_OVER } = options;
let { opacitySource = 1.0, opacityDest = 1.0 } = options;

if (
typeof opacitySource !== "number" ||
Expand All @@ -41,7 +38,6 @@ export function composite<I extends JimpClass>(
opacityDest = 1.0;
}

// eslint-disable-next-line import/namespace
const blendmode = compositeModes[mode];

// round input
Expand Down
10 changes: 2 additions & 8 deletions packages/core/src/utils/image-bitmap.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
import EXIFParser, { ExifData } from "exif-parser";
import { JimpClass } from "@jimp/types";

const EXIF_TAGS = {
ORIENTATION: 0x0112, // decimal: 274
IMAGE_WIDTH: 0x0100, // decimal: 256
IMAGE_HEIGHT: 0x0101, // decimal: 257
};

/**
* Obtains image orientation from EXIF metadata.
*
Expand Down Expand Up @@ -120,7 +114,7 @@ function transformBitmap<I extends JimpClass>(
img.bitmap.width = width;
img.bitmap.height = height;

// @ts-ignore
// @ts-expect-error Accessing private property
img._exif.tags.Orientation = 1;
}

Expand Down Expand Up @@ -154,6 +148,6 @@ export async function attemptExifRotate<I extends JimpClass>(

exifRotate(image); // EXIF data
} catch (error) {
/* meh */
console.error(error);
}
}
5 changes: 0 additions & 5 deletions packages/diff/.eslintrc.cjs

This file was deleted.

2 changes: 2 additions & 0 deletions packages/diff/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import shared from "@jimp/config-eslint/base.js";
export default [...shared];
7 changes: 5 additions & 2 deletions packages/diff/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"name": "@jimp/diff",
"version": "1.1.2",
"repository": "jimp-dev/jimp",
"engines": {
"node": ">=18"
},
"scripts": {
"lint": "eslint .",
"test": "vitest",
Expand All @@ -23,10 +26,10 @@
"@jimp/core": "workspace:*",
"@jimp/test-utils": "workspace:*",
"@types/pixelmatch": "^5.2.6",
"eslint": "^8.57.0",
"eslint": "^9.9.1",
"tshy": "^3.0.2",
"typescript": "^5.5.4",
"vitest": "^1.4.0"
"vitest": "^2.0.5"
},
"tshy": {
"exclude": [
Expand Down
4 changes: 2 additions & 2 deletions packages/diff/src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ describe("Compare image difference", () => {

test("throws an error if threshold is invalid", () => {
expect(() => diff(imgs[0], imgs[3], -1)).toThrow(
"threshold must be a number between 0 and 1"
"threshold must be a number between 0 and 1",
);
});

test("should resize image before diffing", () => {
expect(diff(imgs[3], imgs[4]).percent).toStrictEqual(
diff(imgs[4], imgs[3]).percent
diff(imgs[4], imgs[3]).percent,
);
});
});
1 change: 1 addition & 0 deletions packages/diff/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export function diff<I extends JimpClass>(img1: I, img2: I, threshold = 0.1) {
throw new Error("threshold must be a number between 0 and 1");
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const diff = new (img1 as any).constructor({
width: bmp1.width,
height: bmp1.height,
Expand Down
Loading
Loading