Skip to content

Commit

Permalink
update deps (#833)
Browse files Browse the repository at this point in the history
  • Loading branch information
u1-liquid authored Dec 18, 2024
1 parent 7772d42 commit b3f73d7
Show file tree
Hide file tree
Showing 35 changed files with 2,609 additions and 2,790 deletions.
21 changes: 11 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"type": "git",
"url": "https://github.com/MisskeyIO/misskey.git"
},
"packageManager": "pnpm@9.14.2",
"packageManager": "pnpm@9.15.0",
"workspaces": [
"packages/frontend",
"packages/backend",
Expand Down Expand Up @@ -47,35 +47,36 @@
},
"resolutions": {
"@tensorflow/tfjs-core": "4.22.0",
"axios": "1.7.7",
"chokidar": "4.0.1",
"cookie": "1.0.1",
"axios": "1.7.9",
"chokidar": "4.0.2",
"cookie": "1.0.2",
"cookie-signature": "1.2.2",
"debug": "4.3.7",
"debug": "4.4.0",
"esbuild": "0.24.0",
"jpeg-js": "0.4.4",
"lodash": "4.17.21",
"punycode": "npm:[email protected]",
"sharp": "0.33.5",
"tough-cookie": "5.0.0",
"web-streams-polyfill": "4.0.0"
},
"dependencies": {
"cssnano": "7.0.6",
"execa": "9.5.1",
"execa": "9.5.2",
"js-yaml": "4.1.0",
"postcss": "8.4.49",
"terser": "5.36.0",
"terser": "5.37.0",
"typescript": "5.7.2"
},
"devDependencies": {
"@types/node": "22.10.0",
"@types/node": "22.10.2",
"@typescript-eslint/eslint-plugin": "7.10.0",
"@typescript-eslint/parser": "7.10.0",
"cross-env": "7.0.3",
"cypress": "13.16.0",
"cypress": "13.17.0",
"eslint": "8.57.1",
"ncp": "2.0.0",
"start-server-and-test": "2.0.8"
"start-server-and-test": "2.0.9"
},
"optionalDependencies": {
"@tensorflow/tfjs-core": "4.22.0"
Expand Down
5 changes: 3 additions & 2 deletions packages/backend/.swcrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://json.schemastore.org/swcrc",
"$schema": "https://swc.rs/schema.json",
"jsc": {
"parser": {
"syntax": "typescript",
Expand All @@ -17,7 +17,8 @@
"paths": {
"@/*": ["*"]
},
"target": "es2022"
"target": "es2022",
"keepClassNames": true
},
"minify": false
}
2 changes: 1 addition & 1 deletion packages/backend/jest.config.e2e.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const base = require('./jest.config.cjs')

module.exports = {
...base,
globalSetup: "<rootDir>/built-test/entry.js",
globalSetup: "<rootDir>/test-server/entry.mjs",
setupFilesAfterEnv: ["<rootDir>/test/jest.setup.ts"],
testMatch: [
"<rootDir>/test/e2e/**/*.ts",
Expand Down
86 changes: 42 additions & 44 deletions packages/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"revert": "pnpm typeorm migration:revert -d ormconfig.js",
"check:connect": "node ./scripts/check_connect.js",
"build": "swc src -d built -D --strip-leading-paths",
"build:test": "swc test-server -d built-test -D --config-file test-server/.swcrc --strip-leading-paths",
"watch:swc": "swc src -d built -D -w --strip-leading-paths",
"build:tsc": "tsc -p tsconfig.json && tsc-alias -p tsconfig.json",
"watch": "node ./scripts/watch.mjs",
Expand All @@ -23,27 +22,27 @@
"eslint": "eslint --quiet \"src/**/*.ts\"",
"lint": "pnpm typecheck && pnpm eslint",
"jest": "cross-env NODE_ENV=test node --experimental-vm-modules --experimental-import-meta-resolve node_modules/jest/bin/jest.js --forceExit --config jest.config.unit.cjs",
"jest:e2e": "cross-env NODE_ENV=test node --experimental-vm-modules --experimental-import-meta-resolve node_modules/jest/bin/jest.js --forceExit --config jest.config.e2e.cjs",
"jest:e2e": "cross-env NODE_ENV=test node --experimental-vm-modules --experimental-import-meta-resolve --no-experimental-require-module node_modules/jest/bin/jest.js --forceExit --config jest.config.e2e.cjs",
"jest-and-coverage": "cross-env NODE_ENV=test node --experimental-vm-modules --experimental-import-meta-resolve node_modules/jest/bin/jest.js --coverage --forceExit --config jest.config.unit.cjs",
"jest-and-coverage:e2e": "cross-env NODE_ENV=test node --experimental-vm-modules --experimental-import-meta-resolve node_modules/jest/bin/jest.js --coverage --forceExit --config jest.config.e2e.cjs",
"jest-and-coverage:e2e": "cross-env NODE_ENV=test node --experimental-vm-modules --experimental-import-meta-resolve --no-experimental-require-module node_modules/jest/bin/jest.js --coverage --forceExit --config jest.config.e2e.cjs",
"jest-clear": "cross-env NODE_ENV=test node --experimental-vm-modules --experimental-import-meta-resolve node_modules/jest/bin/jest.js --clearCache",
"test": "pnpm jest",
"test:e2e": "pnpm build && pnpm build:test && pnpm jest:e2e",
"test:e2e": "pnpm build && pnpm jest:e2e",
"test-and-coverage": "pnpm jest-and-coverage",
"test-and-coverage:e2e": "pnpm build && pnpm build:test && pnpm jest-and-coverage:e2e",
"test-and-coverage:e2e": "pnpm build && pnpm jest-and-coverage:e2e",
"generate-api-json": "pnpm build && node ./scripts/generate_api_json.js"
},
"optionalDependencies": {
"@swc/core-darwin-arm64": "1.9.3",
"@swc/core-darwin-x64": "1.9.3",
"@swc/core-linux-arm-gnueabihf": "1.9.3",
"@swc/core-linux-arm64-gnu": "1.9.3",
"@swc/core-linux-arm64-musl": "1.9.3",
"@swc/core-linux-x64-gnu": "1.9.3",
"@swc/core-linux-x64-musl": "1.9.3",
"@swc/core-win32-arm64-msvc": "1.9.3",
"@swc/core-win32-ia32-msvc": "1.9.3",
"@swc/core-win32-x64-msvc": "1.9.3",
"@swc/core-darwin-arm64": "1.10.1",
"@swc/core-darwin-x64": "1.10.1",
"@swc/core-linux-arm-gnueabihf": "1.10.1",
"@swc/core-linux-arm64-gnu": "1.10.1",
"@swc/core-linux-arm64-musl": "1.10.1",
"@swc/core-linux-x64-gnu": "1.10.1",
"@swc/core-linux-x64-musl": "1.10.1",
"@swc/core-win32-arm64-msvc": "1.10.1",
"@swc/core-win32-ia32-msvc": "1.10.1",
"@swc/core-win32-x64-msvc": "1.10.1",
"@tensorflow/tfjs": "4.22.0",
"@tensorflow/tfjs-node": "4.22.0",
"bufferutil": "4.0.8",
Expand All @@ -64,34 +63,34 @@
},
"dependencies": {
"@authenio/samlify-node-xmllint": "2.0.0",
"@aws-sdk/client-s3": "3.700.0",
"@aws-sdk/lib-storage": "3.700.0",
"@aws-sdk/client-s3": "3.714.0",
"@aws-sdk/lib-storage": "3.714.0",
"@bull-board/api": "6.5.3",
"@bull-board/fastify": "6.5.3",
"@bull-board/ui": "6.5.3",
"@discordapp/twemoji": "15.1.0",
"@elastic/elasticsearch": "8.16.2",
"@fastify/accepts": "5.0.1",
"@elastic/elasticsearch": "8.17.0",
"@fastify/accepts": "5.0.2",
"@fastify/cookie": "11.0.1",
"@fastify/cors": "10.0.1",
"@fastify/express": "4.0.1",
"@fastify/formbody": "8.0.1",
"@fastify/http-proxy": "10.0.2",
"@fastify/http-proxy": "11.0.0",
"@fastify/multipart": "9.0.1",
"@fastify/static": "8.0.3",
"@fastify/view": "10.0.1",
"@misskey-dev/sharp-read-bmp": "1.2.0",
"@misskey-dev/summaly": "MisskeyIO/summaly#5.1.2",
"@napi-rs/canvas": "0.1.64",
"@nestjs/common": "10.4.9",
"@nestjs/core": "10.4.9",
"@nestjs/testing": "10.4.9",
"@napi-rs/canvas": "0.1.65",
"@nestjs/common": "10.4.15",
"@nestjs/core": "10.4.15",
"@nestjs/testing": "10.4.15",
"@peertube/http-signature": "1.7.0",
"@simplewebauthn/server": "12.0.0",
"@simplewebauthn/server": "13.0.0",
"@sinonjs/fake-timers": "11.3.1",
"@smithy/node-http-handler": "3.3.1",
"@swc/cli": "0.5.1",
"@swc/core": "1.9.3",
"@smithy/node-http-handler": "3.3.2",
"@swc/cli": "0.5.2",
"@swc/core": "1.10.1",
"@twemoji/parser": "15.1.1",
"accepts": "1.3.8",
"ajv": "8.17.1",
Expand All @@ -100,26 +99,26 @@
"bcryptjs": "2.4.3",
"blurhash": "2.0.5",
"body-parser": "1.20.3",
"bullmq": "5.29.1",
"bullmq": "5.34.2",
"cacheable-lookup": "7.0.0",
"cbor": "10.0.3",
"chalk": "5.3.0",
"chalk-template": "1.1.0",
"chokidar": "4.0.1",
"chokidar": "4.0.2",
"cli-highlight": "2.1.11",
"color-convert": "2.0.1",
"content-disposition": "0.5.4",
"date-fns": "4.1.0",
"deep-email-validator": "0.1.21",
"fastify": "5.0.0",
"fastify": "5.2.0",
"fastify-http-errors-enhanced": "6.0.0",
"fastify-raw-body": "5.0.0",
"feed": "4.2.2",
"file-type": "19.6.0",
"fluent-ffmpeg": "2.1.3",
"form-data": "4.0.1",
"got": "14.4.5",
"happy-dom": "15.11.6",
"happy-dom": "15.11.7",
"hpagent": "1.2.0",
"htmlescape": "1.1.1",
"http-link-header": "1.1.3",
Expand All @@ -133,7 +132,7 @@
"json5": "2.2.3",
"jsonld": "8.3.2",
"jsrsasign": "11.1.0",
"meilisearch": "0.45.0",
"meilisearch": "0.46.0",
"mfm-js": "0.24.0",
"microformats-parser": "2.0.2",
"mime-types": "2.1.35",
Expand All @@ -145,12 +144,12 @@
"node-fetch": "3.3.2",
"node-forge": "1.3.1",
"nodemailer": "6.9.16",
"nsfwjs": "2.4.2",
"nsfwjs": "4.2.0",
"oauth": "0.10.0",
"oauth2orize": "1.12.0",
"oauth2orize-pkce": "0.1.2",
"os-utils": "0.0.14",
"otpauth": "9.3.5",
"otpauth": "9.3.6",
"parse5": "7.2.1",
"pg": "8.13.1",
"pino": "9.5.0",
Expand All @@ -159,7 +158,7 @@
"probe-image-size": "7.2.3",
"promise-limit": "2.7.0",
"pug": "3.0.3",
"punycode": "2.3.1",
"punycode.js": "2.3.1",
"qrcode": "1.5.4",
"random-seed": "0.3.0",
"ratelimiter": "3.4.1",
Expand All @@ -176,7 +175,7 @@
"slacc": "0.0.10",
"strict-event-emitter-types": "2.0.0",
"stringz": "2.1.0",
"systeminformation": "5.23.5",
"systeminformation": "5.23.13",
"tinycolor2": "1.6.0",
"tmp": "0.2.3",
"tsc-alias": "1.8.10",
Expand All @@ -193,8 +192,7 @@
"devDependencies": {
"@jest/globals": "29.7.0",
"@misskey-dev/eslint-plugin": "1.0.0",
"@nestjs/platform-express": "10.4.9",
"@simplewebauthn/types": "12.0.0",
"@nestjs/platform-express": "10.4.15",
"@swc/jest": "0.2.37",
"@types/accepts": "1.3.7",
"@types/archiver": "6.0.3",
Expand All @@ -209,18 +207,18 @@
"@types/js-yaml": "4.0.9",
"@types/jsdom": "21.1.7",
"@types/jsonld": "1.5.15",
"@types/jsrsasign": "10.5.14",
"@types/jsrsasign": "10.5.15",
"@types/mime-types": "2.1.4",
"@types/ms": "0.7.34",
"@types/node": "22.10.0",
"@types/node": "22.10.2",
"@types/node-forge": "1.3.11",
"@types/nodemailer": "6.4.17",
"@types/oauth": "0.9.6",
"@types/oauth2orize": "1.11.5",
"@types/oauth2orize-pkce": "0.1.2",
"@types/pg": "8.11.10",
"@types/pug": "2.0.10",
"@types/punycode": "2.1.4",
"@types/punycode.js": "npm:@types/punycode@2.1.4",
"@types/qrcode": "1.5.5",
"@types/random-seed": "0.3.5",
"@types/ratelimiter": "3.4.6",
Expand All @@ -240,11 +238,11 @@
"cross-env": "7.0.3",
"eslint": "8.57.1",
"eslint-plugin-import": "2.31.0",
"execa": "9.5.1",
"execa": "9.5.2",
"fkill": "^9.0.0",
"jest": "29.7.0",
"jest-mock": "29.7.0",
"nodemon": "3.1.7",
"nodemon": "3.1.9",
"pid-port": "1.0.0",
"simple-oauth2": "5.1.0"
}
Expand Down
17 changes: 11 additions & 6 deletions packages/backend/src/core/AiService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
* SPDX-License-Identifier: AGPL-3.0-only
*/

import * as fs from 'node:fs';
import { fileURLToPath } from 'node:url';
import { dirname } from 'node:path';
import { Injectable } from '@nestjs/common';
import * as nsfw from 'nsfwjs';
import si from 'systeminformation';
import { Mutex } from 'async-mutex';
import { sharpBmp } from '@misskey-dev/sharp-read-bmp';
import { bindThis } from '@/decorators.js';
import type Logger from '@/logger.js';
import { LoggerService } from '@/core/LoggerService.js';
Expand All @@ -33,7 +33,7 @@ export class AiService {
}

@bindThis
public async detectSensitive(path: string): Promise<nsfw.predictionType[] | null> {
public async detectSensitive(path: string, mime: string): Promise<nsfw.PredictionType[] | null> {
try {
if (isSupportedCpu === undefined) {
const cpuFlags = await this.getCpuFlags();
Expand All @@ -55,11 +55,16 @@ export class AiService {
});
}

const buffer = await fs.promises.readFile(path);
const image = await tf.node.decodeImage(buffer, 3) as any;
const sharp = await sharpBmp(path, mime);
const { data, info } = await sharp
.resize(299, 299, { fit: 'inside' })
.ensureAlpha()
.raw({ depth: 'int' })
.toBuffer({ resolveWithObject: true });

const image = tf.tensor3d(data, [info.height, info.width, info.channels], 'int32');
try {
const predictions = await this.model.classify(image);
return predictions;
return await this.model.classify(image);
} finally {
image.dispose();
}
Expand Down
Loading

0 comments on commit b3f73d7

Please sign in to comment.