@dungsil/dsh-plugin-ui-image-paths 0.0.0-stage → 0.2.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/cordis.patch.yml +3 -0
- package/dist/client.js +82 -0
- package/dist/index.js +5159 -0
- package/locale/en.json +6 -0
- package/locale/ko.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +89 -3
- package/README.md +0 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 dungsil
|
|
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/cordis.patch.yml
ADDED
package/dist/client.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
window.__ModuleLoader__.load({ id: "@dungsil/dsh-plugin-ui-image-paths", factory(require) { const module = { exports: {} }; const exports = module.exports;
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
let react = require("react");
|
|
4
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
5
|
+
let _deepseek_ai_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
6
|
+
// src/protocol.ts
|
|
7
|
+
const name = "dungsil-ui-image-paths";
|
|
8
|
+
const projection = "dungsil.imageDirectories";
|
|
9
|
+
// src/client.tsx
|
|
10
|
+
const inject = ["slots"];
|
|
11
|
+
function ImageScope({ cwd, children }) {
|
|
12
|
+
const delegate = (0, _deepseek_ai_dsh_client_ui_primitives.useMarkdownDelegate)();
|
|
13
|
+
const scoped = (0, react.useMemo)(() => {
|
|
14
|
+
if (!cwd || !delegate.fileImages) return delegate;
|
|
15
|
+
const images = delegate.fileImages;
|
|
16
|
+
const absolute = (path) => /^(?:[/\\]|[a-zA-Z][a-zA-Z\d+.-]*:)/.test(path) ? path : `${cwd.replace(/[/\\]+$/, "")}/${path}`;
|
|
17
|
+
return {
|
|
18
|
+
...delegate,
|
|
19
|
+
fileImages: {
|
|
20
|
+
...images,
|
|
21
|
+
resolve: (path) => images.resolve(absolute(path)),
|
|
22
|
+
resourceAddress: images.resourceAddress ? (path) => images.resourceAddress(absolute(path)) : void 0
|
|
23
|
+
},
|
|
24
|
+
getTriggerProps: delegate.getTriggerProps ? (target) => delegate.getTriggerProps(target.kind === "image" && target.path ? {
|
|
25
|
+
...target,
|
|
26
|
+
path: absolute(target.path)
|
|
27
|
+
} : target) : void 0
|
|
28
|
+
};
|
|
29
|
+
}, [cwd, delegate]);
|
|
30
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.MarkdownDelegateProvider, {
|
|
31
|
+
...scoped,
|
|
32
|
+
children
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
function apply(ctx) {
|
|
36
|
+
const slot = "conversation.chat.flow";
|
|
37
|
+
ctx.slots.inject(slot, () => {
|
|
38
|
+
const originals = /* @__PURE__ */ new Map();
|
|
39
|
+
const refreshOutlet = () => null;
|
|
40
|
+
const sync = () => {
|
|
41
|
+
const entries = ctx.slots.entries(slot).filter((entry) => entry.component !== refreshOutlet);
|
|
42
|
+
for (const entry of originals.keys()) if (!entries.includes(entry)) originals.delete(entry);
|
|
43
|
+
for (const entry of entries) {
|
|
44
|
+
if (originals.has(entry)) continue;
|
|
45
|
+
const Original = entry.component;
|
|
46
|
+
function ImagePaths(props) {
|
|
47
|
+
const directories = props.useProjection(projection);
|
|
48
|
+
const renderSlot = (0, react.useMemo)(() => (childSlot, owner, options) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ImageScope, {
|
|
49
|
+
cwd: directories?.findLast((change) => change.seq <= owner.node.anchorSeq)?.cwd,
|
|
50
|
+
children: props.renderSlot(childSlot, owner, options)
|
|
51
|
+
}), [directories, props.renderSlot]);
|
|
52
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Original, {
|
|
53
|
+
...props,
|
|
54
|
+
renderSlot
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
originals.set(entry, {
|
|
58
|
+
original: entry.component,
|
|
59
|
+
wrapper: ImagePaths
|
|
60
|
+
});
|
|
61
|
+
entry.component = ImagePaths;
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
const unsubscribe = ctx.slots.subscribe(slot, sync);
|
|
65
|
+
const disposeRefresh = ctx.slots.register({
|
|
66
|
+
name: slot,
|
|
67
|
+
priority: Number.MAX_SAFE_INTEGER
|
|
68
|
+
}, refreshOutlet);
|
|
69
|
+
sync();
|
|
70
|
+
return () => {
|
|
71
|
+
unsubscribe();
|
|
72
|
+
for (const [entry, { original, wrapper }] of originals) if (entry.component === wrapper) entry.component = original;
|
|
73
|
+
originals.clear();
|
|
74
|
+
disposeRefresh();
|
|
75
|
+
};
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
exports.apply = apply;
|
|
79
|
+
exports.inject = inject;
|
|
80
|
+
exports.name = name;
|
|
81
|
+
|
|
82
|
+
return module.exports; } });
|