Skip to content

Commit

Permalink
feat: replace canvas library
Browse files Browse the repository at this point in the history
  • Loading branch information
Julusian committed Jul 2, 2024
1 parent d1af252 commit 7b5202a
Show file tree
Hide file tree
Showing 4 changed files with 163 additions and 255 deletions.
6 changes: 3 additions & 3 deletions satellite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"dev": "ts-node src/main.ts config.json",
"dev-electron": "run build:main && electron dist/electron.js",
"build": "rimraf dist && run build:main",
"build:main": "tsc -p tsconfig.build.json",
"build:main": "run -T tsc -p tsconfig.build.json",
"build:electron": "electron-builder --publish=never",
"lint:raw": "eslint --ext .ts --ext .js --ext .tsx --ext .jsx",
"lint": "run lint:raw ."
Expand Down Expand Up @@ -48,9 +48,9 @@
"dependencies": {
"@elgato-stream-deck/node": "^6.2.0",
"@julusian/image-rs": "^0.2.1",
"@julusian/jpeg-turbo": "^2.1.0",
"@julusian/skia-canvas": "^1.0.5",
"@julusian/jpeg-turbo": "^2.2.0-1",
"@loupedeck/node": "^1.1.2",
"@napi-rs/canvas": "^0.1.53",
"@xencelabs-quick-keys/node": "^1.0.0",
"conf": "^10.2.0",
"electron-about-window": "^1.15.2",
Expand Down
7 changes: 1 addition & 6 deletions satellite/src/cards.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as path from 'path'
import { promisify } from 'util'
import { readFile } from 'fs'
import { Canvas, Image, loadImage } from '@julusian/skia-canvas'
import { Canvas, Image, loadImage } from '@napi-rs/canvas'
import * as imageRs from '@julusian/image-rs'
import { networkInterfaces } from 'os'

Expand All @@ -10,11 +10,6 @@ const readFileP = promisify(readFile)
export class CardGenerator {
private iconImage: Image | undefined

constructor() {
// Ensure skia-canvas is loaded at startup
new Canvas()
}

async loadIcon(): Promise<Image> {
if (!this.iconImage) {
const rawData = await readFileP(path.join(__dirname, '../assets/icon.png'))
Expand Down
1 change: 1 addition & 0 deletions satellite/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"{{PACKAGE-NAME}}": ["./src/index.ts"]
},
"types": ["node"],
"lib": ["dom"],
"skipLibCheck": true,
"resolveJsonModule": true,
"esModuleInterop": true,
Expand Down
Loading

0 comments on commit 7b5202a

Please sign in to comment.