@zivye/dsh-img-save 0.1.0
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/LICENSE +21 -0
- package/README.md +57 -0
- package/cordis.patch.yml +5 -0
- package/lib/.gitignore +3 -0
- package/lib/client.js +165 -0
- package/package.json +53 -0
- package/src/client/index.js +186 -0
- package/src/host/index.js +8 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# DSH Image Download Plugin
|
|
2
|
+
|
|
3
|
+
Adds a download button when the pointer is over an image in a DeepSeek Harness conversation.
|
|
4
|
+
|
|
5
|
+
<img src="./doc/example.png" alt="example" width="250" style="display: block; margin: auto;">
|
|
6
|
+
|
|
7
|
+
## Design
|
|
8
|
+
|
|
9
|
+
- **Client-only behavior:** the plugin uses the exact image URL that DSH is already rendering. It does not read local files, upload image bytes, run shell commands, or call a remote service.
|
|
10
|
+
- **No polling or DOM observers:** pointer, scroll, and resize events drive positioning. This avoids observer feedback loops and UI freezes.
|
|
11
|
+
- **Preview-safe interaction:** pointer/click events on the download button are stopped so clicking it does not trigger the image's built-in preview/lightbox action.
|
|
12
|
+
- **Local URLs:** uses the browser download mechanism for `file:`, `blob:`, `data:`, and browser-accessible HTTP(S) image URLs. Browser security policy ultimately decides whether a particular local URL may be downloaded.
|
|
13
|
+
|
|
14
|
+
## Project layout
|
|
15
|
+
|
|
16
|
+
```text
|
|
17
|
+
src/
|
|
18
|
+
host/index.js # empty Host plugin; package is client-only
|
|
19
|
+
client/index.js # Cordis Client plugin source
|
|
20
|
+
lib/
|
|
21
|
+
client.js # esbuild ESM bundle of src/client/index.js
|
|
22
|
+
cordis.patch.yml # DSH profile bundle registration snippet
|
|
23
|
+
esbuild.config.mjs # bundles src/client -> lib/client (ESM, React external)
|
|
24
|
+
package.json
|
|
25
|
+
README.md
|
|
26
|
+
LICENSE
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Development
|
|
30
|
+
|
|
31
|
+
The client entry is an ESM source file. The published package ships an esbuild
|
|
32
|
+
bundle at `lib/client.js`, which the 1024 Store loads through
|
|
33
|
+
`exports["./client"]`. Build the bundle locally:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
npm install
|
|
37
|
+
npm run build
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
`npm run check` runs a syntax-only check on the source files.
|
|
41
|
+
|
|
42
|
+
## Intended DSH integration
|
|
43
|
+
|
|
44
|
+
The client bundle is a Cordis plugin which registers with the queried
|
|
45
|
+
`shell.overlay` slot. It requires the DSH client runtime to provide:
|
|
46
|
+
|
|
47
|
+
- `slots.inject()` and `slots.register()`;
|
|
48
|
+
- the `shell.overlay` slot;
|
|
49
|
+
- React (provided as an npm dependency) and the dynamic client builtins
|
|
50
|
+
(`document`, `window`, `requestAnimationFrame`).
|
|
51
|
+
|
|
52
|
+
`cordis.patch.yml` mounts the plugin into the Web roster of any DSH profile
|
|
53
|
+
that installs this package.
|
|
54
|
+
|
|
55
|
+
## License
|
|
56
|
+
|
|
57
|
+
MIT. See [LICENSE](./LICENSE).
|
package/cordis.patch.yml
ADDED
package/lib/.gitignore
ADDED
package/lib/client.js
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
// src/client/index.js
|
|
2
|
+
import React from "react";
|
|
3
|
+
var OVERLAY_SLOT = "shell.overlay";
|
|
4
|
+
var OVERLAY_ID = "image-download-overlay";
|
|
5
|
+
var BUTTON_SIZE = 34;
|
|
6
|
+
var INSET = 6;
|
|
7
|
+
function imageFromTarget(target) {
|
|
8
|
+
let node = target;
|
|
9
|
+
while (node && node !== document.body) {
|
|
10
|
+
if (node instanceof HTMLImageElement) return node;
|
|
11
|
+
node = node.parentNode;
|
|
12
|
+
}
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
function isDownloadableImage(image) {
|
|
16
|
+
if (!(image instanceof HTMLImageElement)) return false;
|
|
17
|
+
if (image.closest(".dsh-image-download-overlay")) return false;
|
|
18
|
+
const src = image.currentSrc || image.src;
|
|
19
|
+
if (!src) return false;
|
|
20
|
+
const rect = image.getBoundingClientRect();
|
|
21
|
+
return rect.width >= 24 && rect.height >= 24;
|
|
22
|
+
}
|
|
23
|
+
function positionFor(image) {
|
|
24
|
+
const rect = image.getBoundingClientRect();
|
|
25
|
+
return {
|
|
26
|
+
left: Math.max(INSET, rect.right - BUTTON_SIZE - INSET),
|
|
27
|
+
top: Math.max(INSET, rect.bottom - BUTTON_SIZE - INSET)
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function nameFor(src) {
|
|
31
|
+
try {
|
|
32
|
+
const file = new URL(src, window.location.href).pathname.split("/").pop();
|
|
33
|
+
if (file && /\.(png|jpe?g|webp|gif|svg|avif)$/i.test(file)) return file;
|
|
34
|
+
} catch {
|
|
35
|
+
}
|
|
36
|
+
return `image-${Date.now()}.png`;
|
|
37
|
+
}
|
|
38
|
+
function download(src) {
|
|
39
|
+
const link = document.createElement("a");
|
|
40
|
+
link.href = src;
|
|
41
|
+
link.download = nameFor(src);
|
|
42
|
+
link.rel = "noopener";
|
|
43
|
+
link.style.display = "none";
|
|
44
|
+
document.body.appendChild(link);
|
|
45
|
+
link.click();
|
|
46
|
+
link.remove();
|
|
47
|
+
}
|
|
48
|
+
function DownloadIcon() {
|
|
49
|
+
return React.createElement(
|
|
50
|
+
"svg",
|
|
51
|
+
{
|
|
52
|
+
viewBox: "0 0 24 24",
|
|
53
|
+
fill: "none",
|
|
54
|
+
stroke: "currentColor",
|
|
55
|
+
strokeWidth: "2",
|
|
56
|
+
strokeLinecap: "round",
|
|
57
|
+
strokeLinejoin: "round",
|
|
58
|
+
"aria-hidden": "true"
|
|
59
|
+
},
|
|
60
|
+
React.createElement("path", { d: "M12 3v12" }),
|
|
61
|
+
React.createElement("path", { d: "m7 10 5 5 5-5" }),
|
|
62
|
+
React.createElement("path", { d: "M5 21h14" })
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
function ImageDownloadOverlay() {
|
|
66
|
+
const [active, setActive] = React.useState(null);
|
|
67
|
+
React.useEffect(() => {
|
|
68
|
+
let current = null;
|
|
69
|
+
let frame = 0;
|
|
70
|
+
const clear = () => {
|
|
71
|
+
current = null;
|
|
72
|
+
setActive(null);
|
|
73
|
+
};
|
|
74
|
+
const reposition = () => {
|
|
75
|
+
frame = 0;
|
|
76
|
+
if (!current || !isDownloadableImage(current)) {
|
|
77
|
+
clear();
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
setActive({ image: current, src: current.currentSrc || current.src, ...positionFor(current) });
|
|
81
|
+
};
|
|
82
|
+
const schedule = () => {
|
|
83
|
+
if (frame) return;
|
|
84
|
+
frame = window.requestAnimationFrame(reposition);
|
|
85
|
+
};
|
|
86
|
+
const onPointerMove = (event) => {
|
|
87
|
+
const image = imageFromTarget(event.target);
|
|
88
|
+
if (!isDownloadableImage(image)) {
|
|
89
|
+
if (current) {
|
|
90
|
+
const rect = current.getBoundingClientRect();
|
|
91
|
+
const stillOverImage = event.clientX >= rect.left && event.clientX <= rect.right && event.clientY >= rect.top && event.clientY <= rect.bottom;
|
|
92
|
+
if (!stillOverImage) clear();
|
|
93
|
+
}
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
current = image;
|
|
97
|
+
schedule();
|
|
98
|
+
};
|
|
99
|
+
window.addEventListener("pointermove", onPointerMove, true);
|
|
100
|
+
window.addEventListener("scroll", schedule, true);
|
|
101
|
+
window.addEventListener("resize", schedule);
|
|
102
|
+
return () => {
|
|
103
|
+
window.removeEventListener("pointermove", onPointerMove, true);
|
|
104
|
+
window.removeEventListener("scroll", schedule, true);
|
|
105
|
+
window.removeEventListener("resize", schedule);
|
|
106
|
+
if (frame) window.cancelAnimationFrame(frame);
|
|
107
|
+
};
|
|
108
|
+
}, []);
|
|
109
|
+
if (!active) return null;
|
|
110
|
+
const stop = (event) => event.stopPropagation();
|
|
111
|
+
const onClick = (event) => {
|
|
112
|
+
event.preventDefault();
|
|
113
|
+
event.stopPropagation();
|
|
114
|
+
const src = active.image.currentSrc || active.image.src || active.src;
|
|
115
|
+
if (src) download(src);
|
|
116
|
+
};
|
|
117
|
+
return React.createElement(
|
|
118
|
+
"button",
|
|
119
|
+
{
|
|
120
|
+
type: "button",
|
|
121
|
+
className: "dsh-image-download-button",
|
|
122
|
+
style: { left: `${active.left}px`, top: `${active.top}px` },
|
|
123
|
+
title: "\u4E0B\u8F7D\u56FE\u7247",
|
|
124
|
+
"aria-label": "\u4E0B\u8F7D\u56FE\u7247",
|
|
125
|
+
onPointerDown: stop,
|
|
126
|
+
onMouseDown: stop,
|
|
127
|
+
onClick
|
|
128
|
+
},
|
|
129
|
+
React.createElement(DownloadIcon)
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
var index_default = {
|
|
133
|
+
inject: ["slots"],
|
|
134
|
+
apply(ctx) {
|
|
135
|
+
const slots = ctx.slots;
|
|
136
|
+
const disposeStyles = ctx.styles?.insert?.(`
|
|
137
|
+
.dsh-image-download-overlay { position: fixed; inset: 0; z-index: 9999; pointer-events: none; }
|
|
138
|
+
.dsh-image-download-button {
|
|
139
|
+
position: fixed; width: ${BUTTON_SIZE}px; height: ${BUTTON_SIZE}px; padding: 0; border: 0; border-radius: 9px;
|
|
140
|
+
display: flex; align-items: center; justify-content: center; pointer-events: auto; cursor: pointer;
|
|
141
|
+
color: #fff; background: rgba(23, 23, 27, .88); box-shadow: 0 3px 12px rgba(0, 0, 0, .30);
|
|
142
|
+
backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
|
|
143
|
+
transition: background .12s ease, transform .12s ease;
|
|
144
|
+
}
|
|
145
|
+
.dsh-image-download-button:hover { background: rgba(53, 53, 61, .96); transform: scale(1.06); }
|
|
146
|
+
.dsh-image-download-button:active { transform: scale(.94); }
|
|
147
|
+
.dsh-image-download-button svg { width: 18px; height: 18px; display: block; }
|
|
148
|
+
`);
|
|
149
|
+
const unregister = slots.inject(OVERLAY_SLOT, () => slots.register(
|
|
150
|
+
{ name: OVERLAY_SLOT, id: OVERLAY_ID, order: 1e3 },
|
|
151
|
+
() => React.createElement(
|
|
152
|
+
"div",
|
|
153
|
+
{ className: "dsh-image-download-overlay" },
|
|
154
|
+
React.createElement(ImageDownloadOverlay)
|
|
155
|
+
)
|
|
156
|
+
));
|
|
157
|
+
ctx.effect(() => () => {
|
|
158
|
+
unregister?.();
|
|
159
|
+
disposeStyles?.();
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
export {
|
|
164
|
+
index_default as default
|
|
165
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@zivye/dsh-img-save",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Hover-to-download buttons for images in DeepSeek Harness conversations.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"main": "./src/host/index.js",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": "./src/host/index.js",
|
|
10
|
+
"./client": {
|
|
11
|
+
"default": "./lib/client.js"
|
|
12
|
+
},
|
|
13
|
+
"./package.json": "./package.json"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"src",
|
|
17
|
+
"lib",
|
|
18
|
+
"cordis.patch.yml",
|
|
19
|
+
"README.md",
|
|
20
|
+
"LICENSE"
|
|
21
|
+
],
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "node esbuild.config.mjs",
|
|
24
|
+
"check": "node --check src/client/index.js && node --check src/host/index.js"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"esbuild": "^0.24.0"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"react": "^18.2.0"
|
|
31
|
+
},
|
|
32
|
+
"dsh": {
|
|
33
|
+
"bundle": {
|
|
34
|
+
"patch": "./cordis.patch.yml"
|
|
35
|
+
},
|
|
36
|
+
"client": {
|
|
37
|
+
"inject": [
|
|
38
|
+
"@deepseek-ai/dsh-client-ui-slots"
|
|
39
|
+
],
|
|
40
|
+
"platform": "web"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"keywords": [
|
|
44
|
+
"deepseek-harness",
|
|
45
|
+
"dsh",
|
|
46
|
+
"cordis",
|
|
47
|
+
"image",
|
|
48
|
+
"download"
|
|
49
|
+
],
|
|
50
|
+
"publishConfig": {
|
|
51
|
+
"access": "public"
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Image Download Client Plugin
|
|
3
|
+
*
|
|
4
|
+
* This source uses ordinary ESM for a publishable package. The final DSH client
|
|
5
|
+
* bundle must provide React and Cordis's `slots` client Service.
|
|
6
|
+
*/
|
|
7
|
+
import React from 'react'
|
|
8
|
+
|
|
9
|
+
const OVERLAY_SLOT = 'shell.overlay'
|
|
10
|
+
const OVERLAY_ID = 'image-download-overlay'
|
|
11
|
+
const BUTTON_SIZE = 34
|
|
12
|
+
const INSET = 6
|
|
13
|
+
|
|
14
|
+
function imageFromTarget(target) {
|
|
15
|
+
let node = target
|
|
16
|
+
while (node && node !== document.body) {
|
|
17
|
+
if (node instanceof HTMLImageElement) return node
|
|
18
|
+
node = node.parentNode
|
|
19
|
+
}
|
|
20
|
+
return null
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function isDownloadableImage(image) {
|
|
24
|
+
if (!(image instanceof HTMLImageElement)) return false
|
|
25
|
+
if (image.closest('.dsh-image-download-overlay')) return false
|
|
26
|
+
const src = image.currentSrc || image.src
|
|
27
|
+
if (!src) return false
|
|
28
|
+
const rect = image.getBoundingClientRect()
|
|
29
|
+
return rect.width >= 24 && rect.height >= 24
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function positionFor(image) {
|
|
33
|
+
const rect = image.getBoundingClientRect()
|
|
34
|
+
return {
|
|
35
|
+
left: Math.max(INSET, rect.right - BUTTON_SIZE - INSET),
|
|
36
|
+
top: Math.max(INSET, rect.bottom - BUTTON_SIZE - INSET),
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function nameFor(src) {
|
|
41
|
+
try {
|
|
42
|
+
const file = new URL(src, window.location.href).pathname.split('/').pop()
|
|
43
|
+
if (file && /\.(png|jpe?g|webp|gif|svg|avif)$/i.test(file)) return file
|
|
44
|
+
} catch {}
|
|
45
|
+
return `image-${Date.now()}.png`
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function download(src) {
|
|
49
|
+
const link = document.createElement('a')
|
|
50
|
+
link.href = src
|
|
51
|
+
link.download = nameFor(src)
|
|
52
|
+
link.rel = 'noopener'
|
|
53
|
+
link.style.display = 'none'
|
|
54
|
+
document.body.appendChild(link)
|
|
55
|
+
link.click()
|
|
56
|
+
link.remove()
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function DownloadIcon() {
|
|
60
|
+
return React.createElement(
|
|
61
|
+
'svg',
|
|
62
|
+
{
|
|
63
|
+
viewBox: '0 0 24 24',
|
|
64
|
+
fill: 'none',
|
|
65
|
+
stroke: 'currentColor',
|
|
66
|
+
strokeWidth: '2',
|
|
67
|
+
strokeLinecap: 'round',
|
|
68
|
+
strokeLinejoin: 'round',
|
|
69
|
+
'aria-hidden': 'true',
|
|
70
|
+
},
|
|
71
|
+
React.createElement('path', { d: 'M12 3v12' }),
|
|
72
|
+
React.createElement('path', { d: 'm7 10 5 5 5-5' }),
|
|
73
|
+
React.createElement('path', { d: 'M5 21h14' }),
|
|
74
|
+
)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function ImageDownloadOverlay() {
|
|
78
|
+
const [active, setActive] = React.useState(null)
|
|
79
|
+
|
|
80
|
+
React.useEffect(() => {
|
|
81
|
+
let current = null
|
|
82
|
+
let frame = 0
|
|
83
|
+
|
|
84
|
+
const clear = () => {
|
|
85
|
+
current = null
|
|
86
|
+
setActive(null)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const reposition = () => {
|
|
90
|
+
frame = 0
|
|
91
|
+
if (!current || !isDownloadableImage(current)) {
|
|
92
|
+
clear()
|
|
93
|
+
return
|
|
94
|
+
}
|
|
95
|
+
setActive({ image: current, src: current.currentSrc || current.src, ...positionFor(current) })
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const schedule = () => {
|
|
99
|
+
if (frame) return
|
|
100
|
+
frame = window.requestAnimationFrame(reposition)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const onPointerMove = (event) => {
|
|
104
|
+
const image = imageFromTarget(event.target)
|
|
105
|
+
if (!isDownloadableImage(image)) {
|
|
106
|
+
if (current) {
|
|
107
|
+
const rect = current.getBoundingClientRect()
|
|
108
|
+
const stillOverImage = event.clientX >= rect.left && event.clientX <= rect.right && event.clientY >= rect.top && event.clientY <= rect.bottom
|
|
109
|
+
if (!stillOverImage) clear()
|
|
110
|
+
}
|
|
111
|
+
return
|
|
112
|
+
}
|
|
113
|
+
current = image
|
|
114
|
+
schedule()
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
window.addEventListener('pointermove', onPointerMove, true)
|
|
118
|
+
window.addEventListener('scroll', schedule, true)
|
|
119
|
+
window.addEventListener('resize', schedule)
|
|
120
|
+
return () => {
|
|
121
|
+
window.removeEventListener('pointermove', onPointerMove, true)
|
|
122
|
+
window.removeEventListener('scroll', schedule, true)
|
|
123
|
+
window.removeEventListener('resize', schedule)
|
|
124
|
+
if (frame) window.cancelAnimationFrame(frame)
|
|
125
|
+
}
|
|
126
|
+
}, [])
|
|
127
|
+
|
|
128
|
+
if (!active) return null
|
|
129
|
+
|
|
130
|
+
const stop = (event) => event.stopPropagation()
|
|
131
|
+
const onClick = (event) => {
|
|
132
|
+
event.preventDefault()
|
|
133
|
+
event.stopPropagation()
|
|
134
|
+
const src = active.image.currentSrc || active.image.src || active.src
|
|
135
|
+
if (src) download(src)
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return React.createElement(
|
|
139
|
+
'button',
|
|
140
|
+
{
|
|
141
|
+
type: 'button',
|
|
142
|
+
className: 'dsh-image-download-button',
|
|
143
|
+
style: { left: `${active.left}px`, top: `${active.top}px` },
|
|
144
|
+
title: '下载图片',
|
|
145
|
+
'aria-label': '下载图片',
|
|
146
|
+
onPointerDown: stop,
|
|
147
|
+
onMouseDown: stop,
|
|
148
|
+
onClick,
|
|
149
|
+
},
|
|
150
|
+
React.createElement(DownloadIcon),
|
|
151
|
+
)
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export default {
|
|
155
|
+
inject: ['slots'],
|
|
156
|
+
apply(ctx) {
|
|
157
|
+
const slots = ctx.slots
|
|
158
|
+
const disposeStyles = ctx.styles?.insert?.(`
|
|
159
|
+
.dsh-image-download-overlay { position: fixed; inset: 0; z-index: 9999; pointer-events: none; }
|
|
160
|
+
.dsh-image-download-button {
|
|
161
|
+
position: fixed; width: ${BUTTON_SIZE}px; height: ${BUTTON_SIZE}px; padding: 0; border: 0; border-radius: 9px;
|
|
162
|
+
display: flex; align-items: center; justify-content: center; pointer-events: auto; cursor: pointer;
|
|
163
|
+
color: #fff; background: rgba(23, 23, 27, .88); box-shadow: 0 3px 12px rgba(0, 0, 0, .30);
|
|
164
|
+
backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
|
|
165
|
+
transition: background .12s ease, transform .12s ease;
|
|
166
|
+
}
|
|
167
|
+
.dsh-image-download-button:hover { background: rgba(53, 53, 61, .96); transform: scale(1.06); }
|
|
168
|
+
.dsh-image-download-button:active { transform: scale(.94); }
|
|
169
|
+
.dsh-image-download-button svg { width: 18px; height: 18px; display: block; }
|
|
170
|
+
`)
|
|
171
|
+
|
|
172
|
+
const unregister = slots.inject(OVERLAY_SLOT, () => slots.register(
|
|
173
|
+
{ name: OVERLAY_SLOT, id: OVERLAY_ID, order: 1000 },
|
|
174
|
+
() => React.createElement(
|
|
175
|
+
'div',
|
|
176
|
+
{ className: 'dsh-image-download-overlay' },
|
|
177
|
+
React.createElement(ImageDownloadOverlay),
|
|
178
|
+
),
|
|
179
|
+
))
|
|
180
|
+
|
|
181
|
+
ctx.effect(() => () => {
|
|
182
|
+
unregister?.()
|
|
183
|
+
disposeStyles?.()
|
|
184
|
+
})
|
|
185
|
+
},
|
|
186
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host half intentionally has no side effects.
|
|
3
|
+
*
|
|
4
|
+
* Downloads are started in the browser from the image URL already authorized
|
|
5
|
+
* and rendered by DSH. Keeping the implementation client-only means the
|
|
6
|
+
* plugin never reads local files or sends image bytes to a server.
|
|
7
|
+
*/
|
|
8
|
+
export function apply() {}
|