dsh-paste-image 0.2.1 → 0.2.3

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.
package/CHANGELOG.md CHANGED
@@ -6,6 +6,32 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.2.3] - 2026-11-18
10
+
11
+ ### Fixed
12
+
13
+ - 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.
14
+
15
+ ### Tests
16
+
17
+ - 21 tests: the new one installs twice, asserts a single paste/drop listener pair, disposes, and installs again.
18
+
19
+ ## [0.2.2] - 2026-11-18
20
+
21
+ ### Added
22
+
23
+ - 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.
24
+ - A package-root `icon` (`./assets/icon-180.png`) and a `./locale/*.json` export; the icon and locales now travel inside the npm tarball.
25
+ - `.github/workflows/release.yml` publishes GitHub Releases to npm through OIDC trusted publishing, with no stored token.
26
+
27
+ ### Changed
28
+
29
+ - `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.
30
+
31
+ ### Tests
32
+
33
+ - 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.
34
+
9
35
  ## [0.2.1] - 2026-11-18
10
36
 
11
37
  ### Fixed
package/README.md CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  [![CI](https://github.com/pengtang1024/dsh-paste-image/actions/workflows/ci.yml/badge.svg)](https://github.com/pengtang1024/dsh-paste-image/actions/workflows/ci.yml)
4
4
  [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
5
+ [![npm](https://img.shields.io/npm/v/dsh-paste-image.svg)](https://www.npmjs.com/package/dsh-paste-image)
5
6
  [![Node](https://img.shields.io/badge/node-%3E%3D20-brightgreen.svg)](package.json)
6
7
 
7
8
  Paste or drop almost any image into DeepSeek Harness — even when the clipboard says `image/xpm` or lies about the MIME type.
@@ -52,7 +53,11 @@ A file is considered at all when its MIME type starts with `image/` or its name
52
53
 
53
54
  ## Install
54
55
 
55
- Not published to npm. Install from GitHub:
56
+ ```bash
57
+ dsh plugin --profile <profile> add dsh-paste-image
58
+ ```
59
+
60
+ The package ships prebuilt, so the install pulls eight small files through the npm registry. GitHub installs work too and skip the registry:
56
61
 
57
62
  ```bash
58
63
  dsh plugin --profile <profile> add github:pengtang1024/dsh-paste-image
@@ -76,7 +81,7 @@ npm test
76
81
  npm run check
77
82
  ```
78
83
 
79
- `npm test` runs the Node test suite (16 tests at 0.2.1) covering magic-byte sniffing, candidate detection, every BMP variant, the BMP-labelled-PNG conversion, headerless DIBs and native pass-through. `npm run check` syntax-checks `client.js` and `lib/index.js`.
84
+ `npm test` runs the Node test suite (21 tests at 0.2.3) covering magic-byte sniffing, candidate detection, every BMP variant, the BMP-labelled-PNG conversion, headerless DIBs and native pass-through. `npm run check` syntax-checks `client.js` and `lib/index.js`.
80
85
 
81
86
  Then check the real flow:
82
87
 
package/README.zh.md CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  [![CI](https://github.com/pengtang1024/dsh-paste-image/actions/workflows/ci.yml/badge.svg)](https://github.com/pengtang1024/dsh-paste-image/actions/workflows/ci.yml)
4
4
  [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
5
+ [![npm](https://img.shields.io/npm/v/dsh-paste-image.svg)](https://www.npmjs.com/package/dsh-paste-image)
5
6
  [![Node](https://img.shields.io/badge/node-%3E%3D20-brightgreen.svg)](package.json)
6
7
 
7
8
  把几乎任何图片粘进或拖进 DeepSeek Harness —— 哪怕剪贴板声称它是 `image/xpm`,或者干脆把 MIME 类型写错了。
@@ -52,7 +53,11 @@ DSH 桌面客户端(Electron/Chromium)的附件通道只接受四种类型
52
53
 
53
54
  ## 安装
54
55
 
55
- 未发布到 npm,从 GitHub 安装:
56
+ ```bash
57
+ dsh plugin --profile <profile> add dsh-paste-image
58
+ ```
59
+
60
+ 包里是预构建产物,安装只从 npm 拉 8 个小文件。也可以直接从 GitHub 装、绕开 registry:
56
61
 
57
62
  ```bash
58
63
  dsh plugin --profile <profile> add github:pengtang1024/dsh-paste-image
@@ -76,7 +81,7 @@ npm test
76
81
  npm run check
77
82
  ```
78
83
 
79
- `npm test` 跑 Node 测试(0.2.1 为 16 个用例):魔数嗅探、候选判定、各个 BMP 变体、BMP 冒充 PNG 的转码、无头 DIB、原生 PNG 放行。`npm run check` 对 `client.js` 和 `lib/index.js` 做语法检查。
84
+ `npm test` 跑 Node 测试(0.2.3 为 21 个用例):魔数嗅探、候选判定、各个 BMP 变体、BMP 冒充 PNG 的转码、无头 DIB、原生 PNG 放行。`npm run check` 对 `client.js` 和 `lib/index.js` 做语法检查。
80
85
 
81
86
  再验证真实链路:
82
87
 
Binary file
package/client.js CHANGED
@@ -21,6 +21,8 @@
21
21
  var MAX_FILES = 8
22
22
  var MAX_PIXELS = 64 * 1024 * 1024
23
23
  var REROUTED = '__dshPasteImageRerouted'
24
+ var HANDLED = '__dshPasteImageHandled'
25
+ var INSTALLED = '__dshPasteImageInstalled'
24
26
  var BMP_HEADERS = { 12: true, 40: true, 52: true, 56: true, 64: true, 108: true, 124: true }
25
27
  var HEIC_BRANDS = { heic: true, heix: true, heis: true, heim: true, hevc: true, hevx: true, mif1: true, msf1: true }
26
28
  var BMP_BPPS = { 1: true, 4: true, 8: true, 16: true, 24: true, 32: true }
@@ -631,11 +633,22 @@
631
633
  composer().dispatchEvent(event)
632
634
  }
633
635
 
636
+ function claim(event) {
637
+ if (event[HANDLED]) return false
638
+ try {
639
+ Object.defineProperty(event, HANDLED, { value: true })
640
+ } catch (error) {
641
+ event[HANDLED] = true
642
+ }
643
+ return true
644
+ }
645
+
634
646
  async function handle(event, data) {
635
647
  if (!data || event[REROUTED]) return
636
648
  var files = Array.prototype.slice.call(data.files || [])
637
649
  if (files.length === 0 || files.length > MAX_FILES) return
638
650
  if (!files.some(isImageCandidate)) return
651
+ if (!claim(event)) return
639
652
  event.preventDefault()
640
653
  event.stopPropagation()
641
654
  var out = []
@@ -670,21 +683,38 @@
670
683
  }
671
684
 
672
685
  function install() {
673
- document.addEventListener(
674
- 'paste',
675
- function (event) {
676
- void handle(event, event.clipboardData)
677
- },
678
- true,
679
- )
680
- document.addEventListener(
681
- 'drop',
682
- function (event) {
683
- void handle(event, event.dataTransfer)
684
- },
685
- true,
686
- )
687
- return function () {}
686
+ if (typeof document === 'undefined') return function () {}
687
+ var record = document[INSTALLED]
688
+ if (!record) {
689
+ var controller = new AbortController()
690
+ var options = { capture: true, signal: controller.signal }
691
+ document.addEventListener(
692
+ 'paste',
693
+ function (event) {
694
+ void handle(event, event.clipboardData)
695
+ },
696
+ options,
697
+ )
698
+ document.addEventListener(
699
+ 'drop',
700
+ function (event) {
701
+ void handle(event, event.dataTransfer)
702
+ },
703
+ options,
704
+ )
705
+ record = {
706
+ refs: 0,
707
+ release: function () {
708
+ record.refs -= 1
709
+ if (record.refs > 0) return
710
+ controller.abort()
711
+ delete document[INSTALLED]
712
+ },
713
+ }
714
+ Object.defineProperty(document, INSTALLED, { value: record, configurable: true })
715
+ }
716
+ record.refs += 1
717
+ return record.release
688
718
  }
689
719
 
690
720
  var api = {
package/locale/en.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "Paste any image",
4
+ "description": "Paste or drop an image whose declared type is XPM, BMP or DIB, SVG, ICO, or simply wrong: the renderer sniffs the real bytes and hands the composer a PNG. Native PNG, JPEG, WebP and GIF pass through untouched. One paste takes up to 8 files, and converted images keep their aspect ratio at 4096 px on the long side. HEIC and TIFF are recognised but left as they are, because the plugin ships no decoder for them."
5
+ }
6
+ }
package/locale/zh.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "粘贴任意图片",
4
+ "description": "粘贴或拖入 XPM、BMP/DIB、SVG、ICO 或 MIME 类型标错的图片:渲染进程按真实字节嗅探格式,再交给输入框一个 PNG。原生 PNG、JPEG、WebP、GIF 一字节不改地放行。一次最多 8 个文件,转换后的图保持比例、长边 4096 像素。HEIC 与 TIFF 只识别不解码,因为没有内置解码器。"
5
+ }
6
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-paste-image",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "Paste any image into DeepSeek Harness: converts XPM/BMP/DIB/SVG/TIFF/etc. and MIME-lying images to real PNG in the renderer.",
5
5
  "keywords": [
6
6
  "dsh",
@@ -17,16 +17,20 @@
17
17
  "wayland"
18
18
  ],
19
19
  "private": false,
20
+ "icon": "./assets/icon-180.png",
20
21
  "type": "module",
21
22
  "main": "./lib/index.js",
22
23
  "exports": {
23
24
  ".": "./lib/index.js",
24
25
  "./client": "./client.js",
26
+ "./locale/*.json": "./locale/*.json",
25
27
  "./package.json": "./package.json"
26
28
  },
27
29
  "files": [
28
30
  "client.js",
29
31
  "lib",
32
+ "locale/*.json",
33
+ "assets/icon-180.png",
30
34
  "cordis.patch.yml",
31
35
  "README.md",
32
36
  "README.zh.md",