dsh-workbuddy-files 0.1.0 → 0.1.2
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/lib/client.js +919 -892
- package/package.json +3 -3
- package/src/client/app.ts +34 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-workbuddy-files",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "WorkBuddy 风格的 DeepSeek Harness Web 插件:拖拽/粘贴文件与文件夹生成输入框引用气泡(附绝对路径)、@ 菜单检索缓存文件、对话区文件卡片、read_document 工具。",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dsh",
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
"README.md"
|
|
43
43
|
],
|
|
44
44
|
"scripts": {
|
|
45
|
-
"bundle": "tsdown",
|
|
46
|
-
"watch": "tsdown --watch",
|
|
45
|
+
"bundle": "tsdown --config tsdown.host.config.ts && tsdown --config tsdown.client.config.ts && node scripts/rename.mjs",
|
|
46
|
+
"watch": "tsdown --config tsdown.client.config.ts --watch",
|
|
47
47
|
"typecheck": "tsc --noEmit",
|
|
48
48
|
"prepublishOnly": "npm run typecheck && npm run bundle"
|
|
49
49
|
},
|
package/src/client/app.ts
CHANGED
|
@@ -35,7 +35,18 @@ export function makeFactory() {
|
|
|
35
35
|
return {
|
|
36
36
|
name: 'workbuddy-files',
|
|
37
37
|
apply(ctx) {
|
|
38
|
-
|
|
38
|
+
try {
|
|
39
|
+
applyClient(ctx, React)
|
|
40
|
+
} catch (err) {
|
|
41
|
+
console.error('[workbuddy-files] client apply 异常:', err)
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function applyClient(ctx: Record<string, unknown>, React: ReactLike): void {
|
|
49
|
+
const get = (name: string) => (ctx.get as (n: string) => unknown)(name)
|
|
39
50
|
|
|
40
51
|
// ---- 能力探测(缺失则优雅退出)----
|
|
41
52
|
const sessions = get('sessions') as never
|
|
@@ -54,9 +65,25 @@ export function makeFactory() {
|
|
|
54
65
|
if (slots === undefined) return
|
|
55
66
|
|
|
56
67
|
// ---- 包内样式 ----
|
|
57
|
-
|
|
68
|
+
// 正式插件包没有动态版的 styles 内置服务:回退到 document.head style 注入(dsh-pet 同款)
|
|
69
|
+
const injectCssViaHead = (css: string): void => {
|
|
70
|
+
if (typeof document === 'undefined') return
|
|
71
|
+
const tagId = 'dsh-workbuddy-files/styles'
|
|
72
|
+
if (document.querySelector('style[data-plugin-css="' + tagId + '"]') !== null) return
|
|
73
|
+
const tag = document.createElement('style')
|
|
74
|
+
tag.dataset.plugin = 'dsh-workbuddy-files'
|
|
75
|
+
tag.dataset.pluginCss = tagId
|
|
76
|
+
tag.textContent = css
|
|
77
|
+
document.head.appendChild(tag)
|
|
78
|
+
}
|
|
79
|
+
const insertStyles = () => {
|
|
80
|
+
if (styles !== undefined) return styles.insert(CSS)
|
|
81
|
+
injectCssViaHead(CSS)
|
|
82
|
+
return () => {}
|
|
83
|
+
}
|
|
58
84
|
const effect = (ctx.effect as (fn: () => (() => void) | undefined, label?: string) => void).bind(ctx)
|
|
59
85
|
effect(insertStyles, 'workbuddy: styles')
|
|
86
|
+
console.log('[workbuddy-files] client apply 开始:services slots=' + (slots !== undefined) + ' conversation=' + (conversation !== undefined) + ' inputTriggers=' + (inputTriggers !== undefined) + ' conversationEvents=' + (conversationEvents !== undefined) + ' styles=' + (styles !== undefined))
|
|
60
87
|
|
|
61
88
|
// ---- 共享实例 ----
|
|
62
89
|
const bus = createDropBus()
|
|
@@ -89,7 +116,11 @@ export function makeFactory() {
|
|
|
89
116
|
|
|
90
117
|
// ---- 拖拽 / 粘贴处理 + 窗口级监听 ----
|
|
91
118
|
const handlers = createDropHandlers({ bus, insert, ensureRoot, enqueueUpload })
|
|
92
|
-
effect(() =>
|
|
119
|
+
effect(() => {
|
|
120
|
+
const off = handlers.installListeners()
|
|
121
|
+
console.log('[workbuddy-files] 窗口拖拽/粘贴监听已注册')
|
|
122
|
+
return off
|
|
123
|
+
}, 'workbuddy: window listeners')
|
|
93
124
|
|
|
94
125
|
// ---- @ 触发源(文件缓存分组)----
|
|
95
126
|
if (inputTriggers !== undefined) {
|
|
@@ -124,7 +155,4 @@ export function makeFactory() {
|
|
|
124
155
|
))
|
|
125
156
|
|
|
126
157
|
console.log('[workbuddy-files] client 就绪:拖入即插气泡 + 后台缓存 / 统一遮罩 / 文件卡片')
|
|
127
|
-
},
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
158
|
}
|