deepseek-harness-background 0.5.2 → 0.5.4
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/README.md +172 -168
- package/README.zh.md +170 -165
- package/lib/client.js +550 -1538
- package/lib/client.js.map +1 -1
- package/lib/index.js +1 -100
- package/package.json +85 -85
package/lib/index.js
CHANGED
|
@@ -44,12 +44,6 @@ const OPACITY_MIN = 0;
|
|
|
44
44
|
const OPACITY_MAX = 1;
|
|
45
45
|
/** Default panel opacity (0..1); 1 = fully opaque official surfaces, 0 = fully transparent glass. */
|
|
46
46
|
const DEFAULT_PANEL_OPACITY = .15;
|
|
47
|
-
/**
|
|
48
|
-
* Session-projection key this plugin owns in the client-visible value map —
|
|
49
|
-
* the host fold registers it (src/projection.ts) and the rail reads it
|
|
50
|
-
* (src/client/timeline/source.ts); one shared constant so the two can never drift.
|
|
51
|
-
*/
|
|
52
|
-
const TIMELINE_PROJECTION_KEY = "bgTimeline";
|
|
53
47
|
/** Default background rendering mode. */
|
|
54
48
|
const DEFAULT_FIT = "cover";
|
|
55
49
|
/** Image positioning modes. `cover` fills the frame (cropping as needed); `contain` fits the whole image inside the frame (letterboxing). */
|
|
@@ -589,98 +583,6 @@ function makeBackgroundRoutes(settings, opts = {}) {
|
|
|
589
583
|
];
|
|
590
584
|
}
|
|
591
585
|
//#endregion
|
|
592
|
-
//#region src/projection.ts
|
|
593
|
-
/** Preview cap so projection payloads stay small (~1-2 lines per row). */
|
|
594
|
-
const MAX_TEXT_CHARS = 80;
|
|
595
|
-
/** Join the text blocks of a host-side ContentBlock list. */
|
|
596
|
-
function textOf(content) {
|
|
597
|
-
if (!Array.isArray(content)) return "";
|
|
598
|
-
let out = "";
|
|
599
|
-
for (const block of content) if (block !== null && typeof block === "object" && block.type === "text") {
|
|
600
|
-
const text = block.text;
|
|
601
|
-
if (typeof text === "string") out += text;
|
|
602
|
-
}
|
|
603
|
-
return out.trim().slice(0, MAX_TEXT_CHARS);
|
|
604
|
-
}
|
|
605
|
-
/**
|
|
606
|
-
* A surface replace cuts nodes out of the model-visible surface so indexed
|
|
607
|
-
* user messages whose seq is cited in sourceEventSeqs must leave the index.
|
|
608
|
-
* SurfaceOp.replace is the OBJECT form `{ op: 'replace', start, end }`
|
|
609
|
-
* (core/session types) — never the bare string 'replace'; matching the whole
|
|
610
|
-
* value against a string can never fire.
|
|
611
|
-
*/
|
|
612
|
-
function dropShadowedMessages(state, event) {
|
|
613
|
-
const op = event.surfaceOp;
|
|
614
|
-
if (op === null || typeof op !== "object" || op.op !== "replace") return state;
|
|
615
|
-
const shadowed = event.sourceEventSeqs;
|
|
616
|
-
if (!Array.isArray(shadowed) || shadowed.length === 0) return state;
|
|
617
|
-
const hide = /* @__PURE__ */ new Set();
|
|
618
|
-
for (const seq of shadowed) if (typeof seq === "number" && Number.isFinite(seq)) hide.add(seq);
|
|
619
|
-
if (hide.size === 0) return state;
|
|
620
|
-
const next = state.messages.filter((m) => !hide.has(m.seq));
|
|
621
|
-
return next.length === state.messages.length ? state : { messages: next };
|
|
622
|
-
}
|
|
623
|
-
/** Validate the persisted-state shape before a cache row seeds the fold. */
|
|
624
|
-
const stateSchema = { parse(value) {
|
|
625
|
-
if (value === null || typeof value !== "object" || !Array.isArray(value.messages)) throw new Error("bgTimeline: persisted state is not a message index");
|
|
626
|
-
return value;
|
|
627
|
-
} };
|
|
628
|
-
/**
|
|
629
|
-
* The projection definition in the runtime shape the registry drives (key /
|
|
630
|
-
* stateSchema / init / apply / wire / stateVersion). Typed loosely here and
|
|
631
|
-
* registered through a structural face: the typed contract lives behind
|
|
632
|
-
* @deepseek-ai/dsh-session-projection, which the shell provides at runtime
|
|
633
|
-
* but this package deliberately does not build against.
|
|
634
|
-
*/
|
|
635
|
-
const timelineProjectionDefinition = {
|
|
636
|
-
key: TIMELINE_PROJECTION_KEY,
|
|
637
|
-
stateSchema,
|
|
638
|
-
init: () => ({ messages: [] }),
|
|
639
|
-
apply: (state, event) => {
|
|
640
|
-
const e = event ?? {};
|
|
641
|
-
let next = state;
|
|
642
|
-
if (e.type === "user/message") {
|
|
643
|
-
const source = e.data?.source;
|
|
644
|
-
const seq = typeof e.seq === "number" ? e.seq : void 0;
|
|
645
|
-
if (source !== null && typeof source === "object" && source.kind === "user" && seq !== void 0 && Number.isFinite(seq)) {
|
|
646
|
-
const last = state.messages[state.messages.length - 1];
|
|
647
|
-
if (!(last !== void 0 && last.seq === seq)) {
|
|
648
|
-
const rawTime = typeof e.time === "number" ? e.time : typeof e.data?.time === "number" ? e.data.time : 0;
|
|
649
|
-
const id = typeof e.data?.id === "string" && e.data.id !== "" ? e.data.id : void 0;
|
|
650
|
-
const entry = {
|
|
651
|
-
seq,
|
|
652
|
-
time: rawTime,
|
|
653
|
-
text: textOf(e.data?.content),
|
|
654
|
-
...id === void 0 ? {} : { id }
|
|
655
|
-
};
|
|
656
|
-
next = { messages: [...state.messages, entry] };
|
|
657
|
-
}
|
|
658
|
-
}
|
|
659
|
-
}
|
|
660
|
-
return dropShadowedMessages(next, e);
|
|
661
|
-
},
|
|
662
|
-
wire: {
|
|
663
|
-
viewSchema: stateSchema,
|
|
664
|
-
view: (state) => state
|
|
665
|
-
},
|
|
666
|
-
stateVersion: 1
|
|
667
|
-
};
|
|
668
|
-
/**
|
|
669
|
-
* Register the timeline projection with the host registry (when mounted).
|
|
670
|
-
* Safe to call from the plugin root apply; the inject waits for the service
|
|
671
|
-
* and never throws when the deployment has none.
|
|
672
|
-
* @param ctx - Host context.
|
|
673
|
-
*/
|
|
674
|
-
function registerTimelineProjection(ctx) {
|
|
675
|
-
ctx.inject(["sessionProjections"], (hostCtx) => {
|
|
676
|
-
try {
|
|
677
|
-
hostCtx.sessionProjections?.register(timelineProjectionDefinition);
|
|
678
|
-
} catch (error) {
|
|
679
|
-
console.error("[deepseek-harness-background] timeline projection registration failed:", error);
|
|
680
|
-
}
|
|
681
|
-
});
|
|
682
|
-
}
|
|
683
|
-
//#endregion
|
|
684
586
|
//#region src/index.ts
|
|
685
587
|
/**
|
|
686
588
|
* Register the durable background section and its API routes when the Host
|
|
@@ -689,7 +591,6 @@ function registerTimelineProjection(ctx) {
|
|
|
689
591
|
* @param ctx - Host context that may acquire the settings and webServer services.
|
|
690
592
|
*/
|
|
691
593
|
function apply(ctx) {
|
|
692
|
-
registerTimelineProjection(ctx);
|
|
693
594
|
ctx.inject(["settings", "webServer"], (hostCtx) => {
|
|
694
595
|
if (!hostCtx.settings.describe().some((descriptor) => descriptor.ns === "ui-background")) hostCtx.settings.register(BACKGROUND_SETTINGS_NAMESPACE, BackgroundSettingsSchema, { applies: "live" });
|
|
695
596
|
try {
|
|
@@ -700,4 +601,4 @@ function apply(ctx) {
|
|
|
700
601
|
});
|
|
701
602
|
}
|
|
702
603
|
//#endregion
|
|
703
|
-
export { BACKGROUND_API_PREFIX, BACKGROUND_SETTINGS_NAMESPACE, BackgroundSettingsSchema, DEFAULT_FIT, DEFAULT_OPACITY, DEFAULT_PANEL_OPACITY, DEFAULT_SCRIM, FIT_MODES, OPACITY_MAX, OPACITY_MIN, PLUGIN_HOME_REL, SCRIM_MAX, SCRIM_MIN,
|
|
604
|
+
export { BACKGROUND_API_PREFIX, BACKGROUND_SETTINGS_NAMESPACE, BackgroundSettingsSchema, DEFAULT_FIT, DEFAULT_OPACITY, DEFAULT_PANEL_OPACITY, DEFAULT_SCRIM, FIT_MODES, OPACITY_MAX, OPACITY_MIN, PLUGIN_HOME_REL, SCRIM_MAX, SCRIM_MIN, apply, makeBackgroundRoutes, resolveHarnessHome };
|
package/package.json
CHANGED
|
@@ -1,85 +1,85 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "deepseek-harness-background",
|
|
3
|
-
"description": "Custom background image plugin for the DeepSeek Harness web GUI: upload a local picture or paste an image URL, and render it behind the whole app surface with adjustable opacity, scrim, panel transparency and frosted-glass blur.",
|
|
4
|
-
"version": "0.5.
|
|
5
|
-
"keywords": [
|
|
6
|
-
"deepseek-harness",
|
|
7
|
-
"dsh",
|
|
8
|
-
"plugin",
|
|
9
|
-
"dsh-plugin",
|
|
10
|
-
"theme",
|
|
11
|
-
"wallpaper",
|
|
12
|
-
"background",
|
|
13
|
-
"web-ui"
|
|
14
|
-
],
|
|
15
|
-
"author": "HaoyueQin",
|
|
16
|
-
"license": "MIT",
|
|
17
|
-
"repository": {
|
|
18
|
-
"type": "git",
|
|
19
|
-
"url": "git+https://github.com/HaoyueQin/deepseek-harness-background.git"
|
|
20
|
-
},
|
|
21
|
-
"homepage": "https://github.com/HaoyueQin/deepseek-harness-background",
|
|
22
|
-
"packageManager": "pnpm@11.9.0",
|
|
23
|
-
"type": "module",
|
|
24
|
-
"main": "lib/index.js",
|
|
25
|
-
"exports": {
|
|
26
|
-
".": "./lib/index.js",
|
|
27
|
-
"./client": "./lib/client.js",
|
|
28
|
-
"./package.json": "./package.json"
|
|
29
|
-
},
|
|
30
|
-
"dsh": {
|
|
31
|
-
"bundle": {
|
|
32
|
-
"patch": "./cordis.patch.yml"
|
|
33
|
-
},
|
|
34
|
-
"client": {
|
|
35
|
-
"inject": [
|
|
36
|
-
"@deepseek-ai/dsh-client-locale"
|
|
37
|
-
],
|
|
38
|
-
"platform": "web"
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
"scripts": {
|
|
42
|
-
"build": "tsdown",
|
|
43
|
-
"prepare": "tsdown",
|
|
44
|
-
"watch": "tsdown --watch",
|
|
45
|
-
"test": "vitest run",
|
|
46
|
-
"typecheck": "tsc --noEmit -p tsconfig.json"
|
|
47
|
-
},
|
|
48
|
-
"files": [
|
|
49
|
-
"lib",
|
|
50
|
-
"cordis.patch.yml",
|
|
51
|
-
"README.md",
|
|
52
|
-
"README.zh.md"
|
|
53
|
-
],
|
|
54
|
-
"peerDependencies": {
|
|
55
|
-
"@deepseek-ai/cordis": "^4.0.1",
|
|
56
|
-
"@deepseek-ai/dsh-client-locale": "
|
|
57
|
-
"@deepseek-ai/dsh-client-ui-slots": "
|
|
58
|
-
"
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
"@deepseek-ai/schemastery": "^3.18.1"
|
|
63
|
-
},
|
|
64
|
-
"devDependencies": {
|
|
65
|
-
"@deepseek-ai/cordis": "^4.0.1",
|
|
66
|
-
"@deepseek-ai/dsh-client-locale": "
|
|
67
|
-
"@deepseek-ai/dsh-client-ui-slots": "
|
|
68
|
-
"@deepseek-ai/dsh-host-webserver": "
|
|
69
|
-
"@deepseek-ai/dsh-settings": "
|
|
70
|
-
"@deepseek-ai/schemastery": "^3.18.1",
|
|
71
|
-
"@testing-library/dom": "^10.4.1",
|
|
72
|
-
"@testing-library/react": "^16.3.0",
|
|
73
|
-
"@types/node": "^22.0.0",
|
|
74
|
-
"@types/react": "~18.3.1",
|
|
75
|
-
"@types/react-dom": "~18.3.0",
|
|
76
|
-
"clsx": "^2.1.1",
|
|
77
|
-
"jsdom": "^29.1.1",
|
|
78
|
-
"lightningcss": "^1.33.0",
|
|
79
|
-
"react": "^18.2.0",
|
|
80
|
-
"react-dom": "^18.2.0",
|
|
81
|
-
"tsdown": "^0.22.14",
|
|
82
|
-
"typescript": "^5.8.0",
|
|
83
|
-
"vitest": "^4.1.8"
|
|
84
|
-
}
|
|
85
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "deepseek-harness-background",
|
|
3
|
+
"description": "Custom background image plugin for the DeepSeek Harness web GUI: upload a local picture or paste an image URL, and render it behind the whole app surface with adjustable opacity, scrim, panel transparency and frosted-glass blur.",
|
|
4
|
+
"version": "0.5.4",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"deepseek-harness",
|
|
7
|
+
"dsh",
|
|
8
|
+
"plugin",
|
|
9
|
+
"dsh-plugin",
|
|
10
|
+
"theme",
|
|
11
|
+
"wallpaper",
|
|
12
|
+
"background",
|
|
13
|
+
"web-ui"
|
|
14
|
+
],
|
|
15
|
+
"author": "HaoyueQin",
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/HaoyueQin/deepseek-harness-background.git"
|
|
20
|
+
},
|
|
21
|
+
"homepage": "https://github.com/HaoyueQin/deepseek-harness-background",
|
|
22
|
+
"packageManager": "pnpm@11.9.0",
|
|
23
|
+
"type": "module",
|
|
24
|
+
"main": "lib/index.js",
|
|
25
|
+
"exports": {
|
|
26
|
+
".": "./lib/index.js",
|
|
27
|
+
"./client": "./lib/client.js",
|
|
28
|
+
"./package.json": "./package.json"
|
|
29
|
+
},
|
|
30
|
+
"dsh": {
|
|
31
|
+
"bundle": {
|
|
32
|
+
"patch": "./cordis.patch.yml"
|
|
33
|
+
},
|
|
34
|
+
"client": {
|
|
35
|
+
"inject": [
|
|
36
|
+
"@deepseek-ai/dsh-client-locale"
|
|
37
|
+
],
|
|
38
|
+
"platform": "web"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build": "tsdown",
|
|
43
|
+
"prepare": "tsdown",
|
|
44
|
+
"watch": "tsdown --watch",
|
|
45
|
+
"test": "vitest run",
|
|
46
|
+
"typecheck": "tsc --noEmit -p tsconfig.json"
|
|
47
|
+
},
|
|
48
|
+
"files": [
|
|
49
|
+
"lib",
|
|
50
|
+
"cordis.patch.yml",
|
|
51
|
+
"README.md",
|
|
52
|
+
"README.zh.md"
|
|
53
|
+
],
|
|
54
|
+
"peerDependencies": {
|
|
55
|
+
"@deepseek-ai/cordis": "^4.0.1",
|
|
56
|
+
"@deepseek-ai/dsh-client-locale": ">=0.1.2-rc.1 || >=0.1.3-alpha.1 || >=0.1.5-alpha.1",
|
|
57
|
+
"@deepseek-ai/dsh-client-ui-slots": ">=0.1.2-rc.1 || >=0.1.3-alpha.1 || >=0.1.5-alpha.1",
|
|
58
|
+
"@deepseek-ai/dsh-settings": ">=0.1.2-rc.1 || >=0.1.3-alpha.1 || >=0.1.5-alpha.1",
|
|
59
|
+
"react": "^18.2.0"
|
|
60
|
+
},
|
|
61
|
+
"dependencies": {
|
|
62
|
+
"@deepseek-ai/schemastery": "^3.18.1"
|
|
63
|
+
},
|
|
64
|
+
"devDependencies": {
|
|
65
|
+
"@deepseek-ai/cordis": "^4.0.1",
|
|
66
|
+
"@deepseek-ai/dsh-client-locale": ">=0.1.2-rc.1 || >=0.1.3-alpha.1 || >=0.1.5-alpha.1",
|
|
67
|
+
"@deepseek-ai/dsh-client-ui-slots": ">=0.1.2-rc.1 || >=0.1.3-alpha.1 || >=0.1.5-alpha.1",
|
|
68
|
+
"@deepseek-ai/dsh-host-webserver": ">=0.1.2-rc.1 || >=0.1.3-alpha.1 || >=0.1.5-alpha.1",
|
|
69
|
+
"@deepseek-ai/dsh-settings": ">=0.1.2-rc.1 || >=0.1.3-alpha.1 || >=0.1.5-alpha.1",
|
|
70
|
+
"@deepseek-ai/schemastery": "^3.18.1",
|
|
71
|
+
"@testing-library/dom": "^10.4.1",
|
|
72
|
+
"@testing-library/react": "^16.3.0",
|
|
73
|
+
"@types/node": "^22.0.0",
|
|
74
|
+
"@types/react": "~18.3.1",
|
|
75
|
+
"@types/react-dom": "~18.3.0",
|
|
76
|
+
"clsx": "^2.1.1",
|
|
77
|
+
"jsdom": "^29.1.1",
|
|
78
|
+
"lightningcss": "^1.33.0",
|
|
79
|
+
"react": "^18.2.0",
|
|
80
|
+
"react-dom": "^18.2.0",
|
|
81
|
+
"tsdown": "^0.22.14",
|
|
82
|
+
"typescript": "^5.8.0",
|
|
83
|
+
"vitest": "^4.1.8"
|
|
84
|
+
}
|
|
85
|
+
}
|