nonebot-plugin-htmlrender 0.3.1__tar.gz → 0.3.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (22) hide show
  1. {nonebot_plugin_htmlrender-0.3.1 → nonebot_plugin_htmlrender-0.3.3}/PKG-INFO +3 -3
  2. {nonebot_plugin_htmlrender-0.3.1 → nonebot_plugin_htmlrender-0.3.3}/nonebot_plugin_htmlrender/browser.py +1 -1
  3. {nonebot_plugin_htmlrender-0.3.1 → nonebot_plugin_htmlrender-0.3.3}/nonebot_plugin_htmlrender/data_source.py +7 -5
  4. {nonebot_plugin_htmlrender-0.3.1 → nonebot_plugin_htmlrender-0.3.3}/pyproject.toml +4 -3
  5. {nonebot_plugin_htmlrender-0.3.1 → nonebot_plugin_htmlrender-0.3.3}/LICENSE +0 -0
  6. {nonebot_plugin_htmlrender-0.3.1 → nonebot_plugin_htmlrender-0.3.3}/README.md +0 -0
  7. {nonebot_plugin_htmlrender-0.3.1 → nonebot_plugin_htmlrender-0.3.3}/nonebot_plugin_htmlrender/__init__.py +0 -0
  8. {nonebot_plugin_htmlrender-0.3.1 → nonebot_plugin_htmlrender-0.3.3}/nonebot_plugin_htmlrender/config.py +0 -0
  9. {nonebot_plugin_htmlrender-0.3.1 → nonebot_plugin_htmlrender-0.3.3}/nonebot_plugin_htmlrender/templates/github-markdown-light.css +0 -0
  10. {nonebot_plugin_htmlrender-0.3.1 → nonebot_plugin_htmlrender-0.3.3}/nonebot_plugin_htmlrender/templates/katex/katex.min.b64_fonts.css +0 -0
  11. {nonebot_plugin_htmlrender-0.3.1 → nonebot_plugin_htmlrender-0.3.3}/nonebot_plugin_htmlrender/templates/katex/katex.min.js +0 -0
  12. {nonebot_plugin_htmlrender-0.3.1 → nonebot_plugin_htmlrender-0.3.3}/nonebot_plugin_htmlrender/templates/katex/mathtex-script-type.min.js +0 -0
  13. {nonebot_plugin_htmlrender-0.3.1 → nonebot_plugin_htmlrender-0.3.3}/nonebot_plugin_htmlrender/templates/markdown.html +0 -0
  14. {nonebot_plugin_htmlrender-0.3.1 → nonebot_plugin_htmlrender-0.3.3}/nonebot_plugin_htmlrender/templates/pygments-default.css +0 -0
  15. {nonebot_plugin_htmlrender-0.3.1 → nonebot_plugin_htmlrender-0.3.3}/nonebot_plugin_htmlrender/templates/text.css +0 -0
  16. {nonebot_plugin_htmlrender-0.3.1 → nonebot_plugin_htmlrender-0.3.3}/nonebot_plugin_htmlrender/templates/text.html +0 -0
  17. {nonebot_plugin_htmlrender-0.3.1 → nonebot_plugin_htmlrender-0.3.3}/tests/__init__.py +0 -0
  18. {nonebot_plugin_htmlrender-0.3.1 → nonebot_plugin_htmlrender-0.3.3}/tests/conftest.py +0 -0
  19. {nonebot_plugin_htmlrender-0.3.1 → nonebot_plugin_htmlrender-0.3.3}/tests/templates/markdown.css +0 -0
  20. {nonebot_plugin_htmlrender-0.3.1 → nonebot_plugin_htmlrender-0.3.3}/tests/templates/mystyle.css +0 -0
  21. {nonebot_plugin_htmlrender-0.3.1 → nonebot_plugin_htmlrender-0.3.3}/tests/templates/text.html +0 -0
  22. {nonebot_plugin_htmlrender-0.3.1 → nonebot_plugin_htmlrender-0.3.3}/tests/test_htmlrender.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: nonebot-plugin-htmlrender
3
- Version: 0.3.1
3
+ Version: 0.3.3
4
4
  Summary: 通过浏览器渲染图片
5
5
  Author-Email: kexue <xana278@foxmail.com>
6
6
  License: MIT License
@@ -26,9 +26,9 @@ License: MIT License
26
26
  SOFTWARE.
27
27
  Project-URL: Homepage, https://github.com/kexue-z/nonebot-plugin-htmlrender
28
28
  Project-URL: Bug tracker, https://github.com/kexue-z/nonebot-plugin-htmlrender/issues
29
- Requires-Python: <4.0,>=3.8
29
+ Requires-Python: <4.0,>=3.9
30
30
  Requires-Dist: playwright>=1.17.2
31
- Requires-Dist: nonebot2[fastapi]>=2.2.0
31
+ Requires-Dist: nonebot2>=2.2.0
32
32
  Requires-Dist: jinja2>=3.0.3
33
33
  Requires-Dist: markdown>=3.3.6
34
34
  Requires-Dist: Pygments>=2.10.0
@@ -8,6 +8,7 @@
8
8
  @Description : None
9
9
  @GitHub : https://github.com/yanyongyu
10
10
  """
11
+
11
12
  __author__ = "yanyongyu"
12
13
 
13
14
  from contextlib import asynccontextmanager
@@ -18,7 +19,6 @@ from nonebot.log import logger
18
19
  from playwright.async_api import Browser, Error, Page, Playwright, async_playwright
19
20
 
20
21
  from .config import Config
21
- import asyncio
22
22
 
23
23
  config = get_plugin_config(Config)
24
24
 
@@ -1,6 +1,6 @@
1
1
  from os import getcwd
2
2
  from pathlib import Path
3
- from typing import Literal, Optional, Union
3
+ from typing import Any, Dict, Literal, Optional, Union
4
4
 
5
5
  import aiofiles
6
6
  import jinja2
@@ -192,6 +192,7 @@ async def html_to_pic(
192
192
  if "file:" not in template_path:
193
193
  raise Exception("template_path 应该为 file:///path/to/template")
194
194
  async with get_new_page(device_scale_factor, **kwargs) as page:
195
+ page.on("console", lambda msg: logger.debug(f"浏览器控制台: {msg.text}"))
195
196
  await page.goto(template_path)
196
197
  await page.set_content(html, wait_until="networkidle")
197
198
  await page.wait_for_timeout(wait)
@@ -205,8 +206,8 @@ async def html_to_pic(
205
206
  async def template_to_pic(
206
207
  template_path: str,
207
208
  template_name: str,
208
- templates: dict,
209
- pages: Optional[dict] = None,
209
+ templates: Dict[Any, Any],
210
+ pages: Optional[Dict[Any, Any]] = None,
210
211
  wait: int = 0,
211
212
  type: Literal["jpeg", "png"] = "png", # noqa: A002
212
213
  quality: Union[int, None] = None,
@@ -217,8 +218,8 @@ async def template_to_pic(
217
218
  Args:
218
219
  template_path (str): 模板路径
219
220
  template_name (str): 模板名
220
- templates (dict): 模板内参数 如: {"name": "abc"}
221
- pages (dict): 网页参数 Defaults to
221
+ templates (Dict[Any, Any]): 模板内参数 如: {"name": "abc"}
222
+ pages (Optional[Dict[Any, Any]]): 网页参数 Defaults to
222
223
  {"base_url": f"file://{getcwd()}", "viewport": {"width": 500, "height": 10}}
223
224
  wait (int, optional): 网页载入等待时间. Defaults to 0.
224
225
  type (Literal["jpeg", "png"]): 图片类型, 默认 png
@@ -259,6 +260,7 @@ async def capture_element(
259
260
  **kwargs,
260
261
  ) -> bytes:
261
262
  async with get_new_page(**kwargs) as page:
263
+ page.on("console", lambda msg: logger.debug(f"浏览器控制台: {msg.text}"))
262
264
  await page.goto(url, timeout=timeout)
263
265
  return await page.locator(element).screenshot(
264
266
  type=type,
@@ -1,13 +1,13 @@
1
1
  [project]
2
2
  name = "nonebot-plugin-htmlrender"
3
- version = "0.3.1"
3
+ version = "0.3.3"
4
4
  description = "通过浏览器渲染图片"
5
5
  authors = [
6
6
  { name = "kexue", email = "xana278@foxmail.com" },
7
7
  ]
8
8
  dependencies = [
9
9
  "playwright>=1.17.2",
10
- "nonebot2[fastapi]>=2.2.0",
10
+ "nonebot2>=2.2.0",
11
11
  "jinja2>=3.0.3",
12
12
  "markdown>=3.3.6",
13
13
  "Pygments>=2.10.0",
@@ -15,7 +15,7 @@ dependencies = [
15
15
  "pymdown-extensions>=9.1",
16
16
  "aiofiles>=0.8.0",
17
17
  ]
18
- requires-python = ">=3.8,<4.0"
18
+ requires-python = ">=3.9,<4.0"
19
19
  readme = "README.md"
20
20
 
21
21
  [project.license]
@@ -30,6 +30,7 @@ dev = [
30
30
  "pytest-asyncio<1.0.0,>=0.18.1",
31
31
  "nonebug @ git+https://github.com/nonebot/nonebug.git",
32
32
  "nonebot-adapter-onebot>=2.2.3",
33
+ "fastapi>=0.111.0",
33
34
  ]
34
35
 
35
36
  [tool.pdm.build]