Skip to content

Releases

v0.4.1

Choose a tag to compare

@pengtang1024 pengtang1024 released this 23 Nov 03:38
v0.4.1

[0.4.1] - 2026-11-23

修复

  • 配置页不再拖累粘贴链路(client.js):模块工厂不再返回 inject: ['slots', 'locale'],apply() 一进来就先 ctx.effect(install, 'paste-image') 挂上 paste/drop 监听,再尽力注册配置页——slots/locale 已就绪时内联注册,否则用 ctx.inject(['slots', 'locale'], cb) 等服务到达后延迟注册,两者都没有就跳过。UI 服务缺失或注册抛错时,粘贴依旧可用。
  • 不再吞掉原生粘贴:handle() 只有拿到真正的 [data-composer-card] 才 claim 并 preventDefault()/stopPropagation();卡片不存在时直接返回,浏览器原生 paste/drop 路径继续执行,不再把合成 drop 派发到 document.body。
  • 声明宿主要求:package.json 新增 engines.dsh(>=0.2.0-rc.2 || >=0.2.1-rc.2 || >=0.2.2-rc.1),插件详情页不再显示“未声明宿主要求”。
  • 展示描述同步实际行为:package.json 与八种 locale/*.json 的简介从「只转 PNG」改为「PNG / JPEG / WebP(默认 PNG)」,并补充文件数与长边上限可配。
  • 测试:补充监听立即安装、ctx.inject 延迟注册、缺少 [data-composer-card] 时不接管三条用例,套件共 90 个测试(90 通过、0 失败)。

v0.4.0

Choose a tag to compare

@pengtang1024 pengtang1024 released this 21 Nov 13:01
v0.4.0

新增

  • 配置页面:注册到插件管理器的 plugins.row.config 槽位(key = dsh-paste-image#paste-image),入口是“设置 → 插件 → dsh-paste-image → 配置”。插件行显示一行状态摘要,页面提供 6 个复选框(启用、XPM / BMP-DIB / SVG / ICO-CUR 转换开关、控制台日志)、1 个输出格式下拉框(PNG / JPEG / WebP)、3 个数字输入(单次最大文件数 1–8、长边 512–8192、质量 0.1–1,选 PNG 时禁用)、保存与恢复默认。
  • 运行时设置:新增 getSettings() / applySettings() / resetSettings(),默认值等同于 0.3.1 的行为;normalize() 读取转换开关与输出格式/质量,canvasOf() 读取长边上限,handle() 读取总开关与文件数上限,日志由 logConversions 控制。保存后立即生效,无需重载页面;关掉某种格式后该格式原样交给原生通道,关掉总开关后监听器保留、粘贴与拖拽完全走原生路径。
  • 输出格式:新增 outputFormat(png / jpeg / webp,默认 png)与 quality(0.1–1,默认 0.92,仅 JPEG / WebP 生效);JPEG 编码前把透明像素合成到白底,PNG 无损、WebP 保留透明;浏览器不支持所选编码器时以实际 blob.type 为准回退,识别不了就回到 PNG,文件名扩展名同步。
  • 持久化:设置按浏览器保存在 localStorage 的 dsh-paste-image.settings.v1 键下,不上传、不写宿主;localStorage 不可用或内容损坏时回退到默认值/内存,不影响粘贴。
  • 测试:新增 26 个用例(tests/settings.test.mjs),覆盖默认值、范围钳制、持久化与损坏回退、恢复默认、行为接线、输出格式/质量与页面注册契约;测试总数从 61 增加到 87。
  • 文档:新增输出格式实测(docs/output-formats.md,英文 docs/en/output-formats.md),记录真实 Chromium 下五个夹具的 PNG / JPEG / WebP 体积与编码耗时(q=0.92 与 q=0.8),结论是体积比例取决于内容、没有通用百分比——照片用 JPEG/WebP 约小 82%,UI 截图用 JPEG 反而比 PNG 大 49%、PNG 仍可能更小,透明图必须避开 JPEG;README 配置节补了 4 行速查表并链接完整实测。

v0.3.1

Choose a tag to compare

@pengtang1024 pengtang1024 released this 21 Nov 07:57
v0.3.1

性能

  • normalize() 先用 file.slice() 读取至多 1 KiB 头做嗅探;嗅探结果是原生格式(PNG/JPEG/WebP/GIF)且声明 MIME 与之一致时直接返回 null,不再对整文件调用 arrayBuffer()。20 MiB PNG 直通基准从 3.803–3.929 ms/op、每次全量读取 20,971,520 字节,降到 0.0038–0.0063 ms/op、全量读取 0 字节;只有声明类型为空需要重包、或确实要转码时才读全量。
  • resolveColor() 复用一个 1×1 canvas 与 2D context,不再为每个调色板颜色新建画布;XPM 在 cpp === 1 时用字符码 Map 代替逐像素 row.slice()。512×512 XPM 基准从 4.712–4.837 ms/op 降到 3.35–3.95 ms/op(约 -24%,观测区间 -18%~-29%)。BMP→PNG 转换仍在约 3.9–4.0 ms/op,decodeBmp 在运行噪声内不变。
  • 优化只发生在原有的同步渲染进程代码里:没有新增 worker,没有网络请求,处理时机与行为不变。npm run bench 可复现完整基准,--quick 为 CI 规模的冒烟运行。

兼容性

  • 缺少 AbortController 时 install() 退回不带 signal 的监听,disposer 用 removeEventListener 精确卸载两个 handler。
  • 缺少 canvas.toBlob 时 toPngBlob() 回退到 toDataURL(),再把 base64 解码成 Blob。
  • 缺少 DataTransfer/DragEvent 时 handle() 在 claim 事件与 preventDefault() 之前返回,保留浏览器原生 paste/drop 路径,不会吞掉事件。
  • 缺少 file.slice()/file.size 的类 File 对象无法只读文件头,退回原有的全量读取路径。

测试

  • 61 个测试:41 个客户端/多语言用例,加上 20 个兼容性用例——无头 DIB、1/4/8/16/24/32 位 BMP、RLE4/RLE8、BITFIELDS、OS/2 core header、TIFF/HEIC/AVIF 嗅探、MIME 别名直通、BMP 冒充 PNG、8 文件上限、非图片透传,以及上述三条降级路径。CI 矩阵扩展到 Node 20/22/24,并新增 node bench/bench.mjs --quick 冒烟任务。

v0.3.0

Choose a tag to compare

@pengtang1024 pengtang1024 released this 20 Nov 10:37
v0.3.0

新增

  • 插件转为以中文为主:README.md 是简体中文,README.en.md 是英文版,另有 README.ja.md、README.es.md、README.fr.md、README.de.md、README.ru.md、README.pt.md 六种译文。每份 README 顶部都有同一行八语言切换链接,并新增「多语言」说明小节。
  • locale/ 目录为 DSH 界面支持的八种语言提供展示元数据:locale/en.json、locale/zh.json、locale/ja.json、locale/es.json、locale/fr.json、locale/de.json、locale/ru.json、locale/pt.json,各自携带本地化的 meta.title、meta.description,以及指向对应语言 README 的 meta.detail——中文指向 README.md,英文指向 README.en.md。插件列表行与详情页因此按界面语言显示,而不是回退到 manifest 名称和英文文案。
  • 技术文档改为以中文为主:docs/how-it-works.md、docs/formats.md、docs/troubleshooting.md、docs/releasing.md 均为中文,英文版位于 docs/en/ 下的同名文件。
  • CONTRIBUTING.md、CHANGELOG.md、SECURITY.md 同样以中文为主,英文版分别为 CONTRIBUTING.en.md、CHANGELOG.en.md、SECURITY.en.md;CODE_OF_CONDUCT.md 保留 Contributor Covenant 英文原文。贡献指南新增「翻译」小节,说明中文是源语言、改动时需要同步哪些文件,以及新增一种语言时如何扩展测试中的 LOCALES。

变更

  • files 发布 README*.md,不再写死两份 README;package.json 新增 i18n、localization、multilingual 关键词,版本为 0.3.0。
  • 英文版 README 不再直接引用只存在于中文里的错误提示;该错误改为可翻译的散文描述,使各语言译文都基于同一段英文说明。
  • 发布清单(docs/releasing.md)与格式文档(docs/formats.md)同步要求更新全部译文:发版时检查每种语言都仍有 locale 文件和 README,包内容检查期望全部八个 locale 与每一份译好的 README;格式文档的新增格式清单也要求同步更新各语言 README。文档之间的相对链接按语言指向中文页或 docs/en/ 下的英文页。

测试

  • 37 个测试:对八种语言逐语言校验元数据——各有一个可用的 locale 文件、标题、40 到 600 字符的简介,以及指向该语言 README 的 meta.detail;meta.detail 与 README 互链,每份 README 必须以 # dsh-paste-image 开头并链接全部八种译文;此外还检查 locale 集合与打包声明(files 中的 README*.md、locale/*.json,以及 ./locale/*.json 导出),并确认 README 与文档里的每个相对链接都指向真实存在的文件。图标与打包检查仍期望 README*.md 和每个 locale 文件。

v0.2.3 — one paste inserts one image

Choose a tag to compare

@pengtang1024 pengtang1024 released this 18 Nov 06:10

dsh-paste-image 0.2.3

Fixed

  • One paste could insert the same image several times: every copy of the client bundle that had been loaded added another document-level listener, and the old install() returned a no-op disposer so nothing was ever removed. Five loaded copies produced five identical attachments. install() is now idempotent, returns a reference-counted, abort-based disposer that removes both listeners once the last holder releases them, and each source paste/drop event is claimed once, so duplicate listeners can no longer convert and re-route the same event twice.

Tests

  • 21 tests: the new one installs twice, asserts a single paste/drop listener pair, disposes, and installs again.

v0.2.2 — Plugin Manager metadata

Choose a tag to compare

@pengtang1024 pengtang1024 released this 18 Nov 05:52

Added

  • Plugin Manager display metadata: locale/en.json and locale/zh.json ship meta.title and meta.description, so plugin rows and the detail page describe the capability instead of falling back to the manifest name and README.
  • A package-root icon (./assets/icon-180.png) and a ./locale/*.json export; the icon and locales now travel inside the npm tarball.
  • .github/workflows/release.yml publishes GitHub Releases to npm through OIDC trusted publishing, with no stored token.

Changed

  • dsh-paste-image@0.2.1 is the first npm release; both READMEs now lead with dsh plugin --profile <profile> add dsh-paste-image and keep the GitHub install as the no-registry alternative.

Tests

  • 20 tests: the four new ones assert both locale files carry usable meta.title/meta.description, the icon is a PNG under 256 KiB, and the locales plus icon are packaged and exported.

v0.2.1

Choose a tag to compare

@pengtang1024 pengtang1024 released this 18 Nov 04:48

Fixed

  • The release checklist in docs/releasing.md reported the 0.2.0 test count; it now matches the suite (16 tests).

v0.2.0 — full BMP/DIB, SVG and ICO support

Choose a tag to compare

@pengtang1024 pengtang1024 released this 18 Nov 04:31

Added

  • Full BMP/DIB coverage in decodeBmp(): 1/4/8/16/24/32-bit pixels, BI_RLE8/BI_RLE4, BI_BITFIELDS/BI_ALPHABITFIELDS, BITMAPCOREHEADER, BITMAPV2/V3/V4/V5HEADER, OS/2 v2 headers and headerless DIBs (the CF_DIB shape).
  • Embedded JPEG/PNG payloads (BI_JPEG/BI_PNG) are unwrapped and handed to the browser decoder.
  • SVG pastes are rasterised through an <img> element; viewBox provides the size when width/height are missing.
  • ICO/CUR fall back to the largest PNG-compressed directory entry when the browser cannot decode the icon.
  • Magic-byte detection for AVIF, HEIC/HEIF, ICO/CUR, SVG and headerless DIBs.
  • MIME alias table so image/jpg, image/x-png, image/x-bmp, image/x-xpixmap, image/svg+xml and friends are treated as the canonical type.
  • MAX_PIXELS guard (64 Mi px) before a BMP/XPM canvas is allocated.
  • docs/formats.md: the decision pipeline, the full format matrix, the BMP variant grid and the checklist for adding a format.
  • docs/releasing.md: version policy, release checklist, npm publish steps and marketplace sync.
  • Open-source scaffolding: .github/CODEOWNERS, issue-template contact links, README badges, and a Community section linking contributing, conduct, security, changelog and releases.

Changed

  • A native image with an empty declared type is re-wrapped with the sniffed type instead of being passed through and rejected by the host.
  • Row stride, palette entries, bit masks and alpha handling in the BMP decoder are shared by every pixel depth instead of being hard-coded for 24/32-bit.
  • BMP files using BI_CMYK compression (11/12/13) are rejected with bmp: unsupported compression instead of being decoded as RGB.

Fixed

  • 32-bit BMPs whose encoder leaves the alpha channel at zero no longer export as a fully transparent PNG.
  • Palette BMP entries are loaded with the correct entry size (3 bytes for the OS/2 core header, 4 otherwise), and a zero alpha byte in a palette entry no longer makes that colour transparent.
  • cordis.patch.yml is now part of the published files list. GitHub (and future npm) installs used to omit the loader patch, so the bundle entry never mounted; CI checks the tarball for the file.