-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
267 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
root = true | ||
|
||
[*] | ||
insert_final_newline = true | ||
indent_style = space | ||
indent_size = 2 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
* text eol=lf | ||
|
||
*.png -text | ||
*.jpg -text | ||
*.ico -text | ||
*.gif -text | ||
*.webp -text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,35 @@ | ||
{ | ||
"name": "koishi-plugin-imagify", | ||
"description": "imageify of so TM long message", | ||
"version": "2.2.6", | ||
"repository": "https://github.com/koishijs/koishi-plugin-imagify", | ||
"author": "Lipraty <[email protected]>", | ||
"main": "lib/index.js", | ||
"typings": "lib/index.d.ts", | ||
"files": [ | ||
"lib", | ||
"dist" | ||
"name": "@root/imagify", | ||
"version": "0.0.0", | ||
"private": true, | ||
"workspaces": [ | ||
"packages/*" | ||
], | ||
"packageManager": "[email protected]", | ||
"license": "MIT", | ||
"koishi": { | ||
"description": { | ||
"zh": "🖼️ 将过多的文本以图片发出", | ||
"en": "🖼️ imageify of so TM long message" | ||
}, | ||
"service": { | ||
"required": [ | ||
"puppeteer" | ||
] | ||
} | ||
"scripts": { | ||
"build": "yakumo build", | ||
"docs:dev": "vitepress dev docs --open", | ||
"docs:build": "vitepress build docs", | ||
"docs:serve": "vitepress serve docs", | ||
"bump": "yakumo version", | ||
"dep": "yakumo upgrade", | ||
"pub": "yakumo publish" | ||
}, | ||
"keywords": [ | ||
"chatbot", | ||
"koishi", | ||
"plugin", | ||
"image", | ||
"pptr", | ||
"puppeteer", | ||
"shortcut", | ||
"图像", | ||
"图片" | ||
], | ||
"devDependencies": { | ||
"@koishijs/cache": "^2.1.0", | ||
"koishi": "^4.16.4" | ||
}, | ||
"peerDependencies": { | ||
"koishi": "^4.16.4", | ||
"koishi-plugin-puppeteer": "^3.7.3" | ||
"@koishijs/client": "^5.22.3", | ||
"@koishijs/plugin-hmr": "^1.2.8", | ||
"@koishijs/scripts": "^4.5.0", | ||
"@types/node": "^20.11.3", | ||
"@types/react": "^18.2.48", | ||
"cross-env": "^7.0.3", | ||
"esbuild": "^0.18.20", | ||
"esbuild-register": "npm:@shigma/esbuild-register@^1.1.1", | ||
"typescript": "^5.3.3", | ||
"yakumo": "^1.0.0-alpha.10", | ||
"yakumo-esbuild": "^1.0.0-alpha.2", | ||
"yakumo-publish-sync": "^1.0.0-alpha.1", | ||
"yakumo-tsc": "^1.0.0-alpha.2", | ||
"yml-register": "^1.1.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{ | ||
"name": "koishi-plugin-imagify", | ||
"description": "imageify of so TM long message", | ||
"version": "2.2.6", | ||
"repository": "https://github.com/koishijs/koishi-plugin-imagify", | ||
"author": "Lipraty <[email protected]>", | ||
"main": "lib/index.js", | ||
"typings": "lib/index.d.ts", | ||
"files": [ | ||
"lib", | ||
"dist" | ||
], | ||
"license": "MIT", | ||
"koishi": { | ||
"description": { | ||
"zh": "🖼️ 将过多的文本以图片发出", | ||
"en": "🖼️ imageify of so TM long message" | ||
}, | ||
"service": { | ||
"required": [ | ||
"puppeteer" | ||
] | ||
} | ||
}, | ||
"keywords": [ | ||
"chatbot", | ||
"koishi", | ||
"plugin", | ||
"image", | ||
"pptr", | ||
"puppeteer", | ||
"shortcut", | ||
"图像", | ||
"图片" | ||
], | ||
"devDependencies": { | ||
"@koishijs/cache": "^2.1.0", | ||
"koishi": "^4.16.4" | ||
}, | ||
"peerDependencies": { | ||
"koishi": "^4.16.4", | ||
"koishi-plugin-puppeteer": "^3.7.3" | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { Context } from 'koishi' | ||
import { } from 'koishi-plugin-puppeteer' | ||
import type { Page } from 'puppeteer-core' | ||
import { PageWorker } from '../types' | ||
|
||
/// Puppeteer render | ||
|
||
/** | ||
* Load html template to page | ||
*/ | ||
export async function pptrRender(page: Page, html: string): Promise<Page> { | ||
await page.evaluate((eleString) => { | ||
document.querySelector('#container').innerHTML = eleString | ||
}, html) | ||
return page | ||
} | ||
|
||
/** | ||
* Get a worker from pagepool | ||
* @param pagepool | ||
*/ | ||
export async function pptrGetWorker(pagepool: PageWorker<Page>[]): Promise<[PageWorker<Page>[], Promise<PageWorker<Page>>]> { | ||
return [pagepool, new Promise<PageWorker<Page>>((resolve) => { | ||
function check() { | ||
const available = pagepool.find(p => !p.busy) | ||
|
||
if (available) { | ||
available.busy = true | ||
resolve(available) | ||
} else { | ||
setTimeout(check, 100) | ||
} | ||
} | ||
check() | ||
})] | ||
} | ||
|
||
/** | ||
* Screenshot page | ||
* @param quality image quality. maxmium hundred positive integer | ||
*/ | ||
export async function pptrScreenshot(page: Page, quality: number = 100): Promise<[Page, Buffer]> { | ||
const { width, height } = await page.evaluate(() => { | ||
const element = document.querySelector('._image') | ||
return { width: element.clientWidth, height: element.clientHeight } | ||
}) | ||
return [page, await page.screenshot({ | ||
clip: { x: 0, y: 0, width, height }, | ||
quality, | ||
type: 'jpeg' | ||
})] | ||
} | ||
|
||
/** | ||
* ? | ||
*/ | ||
export const pptrClose = (page: Page) => page.close() | ||
|
||
/// Canvas render | ||
|
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"compilerOptions": { | ||
"rootDir": "src", | ||
"outDir": "lib", | ||
"target": "es2020", | ||
"module": "commonjs", | ||
"declaration": true, | ||
"composite": true, | ||
"incremental": true, | ||
"skipLibCheck": true, | ||
"esModuleInterop": true, | ||
"moduleResolution": "node", | ||
"jsx": "react-jsx", | ||
"jsxImportSource": "@satorijs/element", | ||
}, | ||
"include": [ | ||
"src", | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{ | ||
"name": "koishi-plugin-imagify-pug", | ||
"description": "Pug engine for koishi-plugin-imagify", | ||
"version": "0.0.0", | ||
"repository": "https://github.com/koishijs/koishi-plugin-imagify", | ||
"author": "Lipraty <[email protected]>", | ||
"main": "lib/index.js", | ||
"typings": "lib/index.d.ts", | ||
"files": [ | ||
"lib", | ||
"dist" | ||
], | ||
"license": "MIT", | ||
"koishi": { | ||
"description": { | ||
"zh": "🖼️ 用于 Imagify 的 Pug 模板引擎", | ||
"en": "🖼️ Pug engine for koishi-plugin-imagify" | ||
}, | ||
"service": { | ||
"required": [ | ||
"imagify" | ||
] | ||
} | ||
}, | ||
"keywords": [ | ||
"chatbot", | ||
"koishi", | ||
"plugin", | ||
"image", | ||
"pptr", | ||
"puppeteer", | ||
"shortcut", | ||
"pug", | ||
"图像", | ||
"图片" | ||
], | ||
"devDependencies": { | ||
"@koishijs/cache": "^2.1.0", | ||
"koishi": "^4.16.4" | ||
}, | ||
"peerDependencies": { | ||
"koishi": "^4.16.4", | ||
"koishi-plugin-imagify": "^3.0.0" | ||
} | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"compilerOptions": { | ||
"rootDir": "src", | ||
"outDir": "lib", | ||
"target": "es2020", | ||
"module": "commonjs", | ||
"declaration": true, | ||
"composite": true, | ||
"incremental": true, | ||
"skipLibCheck": true, | ||
"esModuleInterop": true, | ||
"moduleResolution": "node", | ||
"jsx": "react-jsx", | ||
"jsxImportSource": "@satorijs/element", | ||
}, | ||
"include": [ | ||
"src", | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es2019", | ||
"module": "commonjs", | ||
"declaration": true, | ||
"composite": true, | ||
"incremental": true, | ||
"skipLibCheck": true, | ||
"esModuleInterop": true, | ||
"moduleResolution": "node", | ||
"strictBindCallApply": true, | ||
"jsx": "react-jsx", | ||
"jsxImportSource": "@satorijs/element", | ||
"types": [ | ||
"node", | ||
"yml-register/types", | ||
], | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,10 @@ | ||
{ | ||
"extends": "./tsconfig.base", | ||
"compilerOptions": { | ||
"rootDir": "src", | ||
"outDir": "lib", | ||
"target": "es2020", | ||
"module": "commonjs", | ||
"declaration": true, | ||
"composite": true, | ||
"incremental": true, | ||
"skipLibCheck": true, | ||
"esModuleInterop": true, | ||
"moduleResolution": "node", | ||
"jsx": "react-jsx", | ||
"jsxImportSource": "@satorijs/element", | ||
"baseUrl": ".", | ||
"paths": { | ||
"koishi-plugin-imagify": ["packages/core/src"], | ||
"koishi-plugin-imagify-*": ["packages/*/src"], | ||
}, | ||
}, | ||
"include": [ | ||
"src", | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"github": { | ||
"silent": true | ||
} | ||
} |