dsh-nook 0.0.0-stage → 0.3.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 +36 -0
- package/README.md +88 -2
- package/client.js +1004 -0
- package/cordis.patch.yml +23 -0
- package/icon.svg +11 -0
- package/index.js +190 -0
- package/locale/en.json +6 -0
- package/locale/ja.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +70 -4
- package/scenes/L2_2529_D3_Towns_Plazas.html +1097 -0
- package/scenes/L2_6206_D5_Markets_Shops.html +822 -0
- package/scenes/L2_6834_D6_Courtyards_Gardens.html +735 -0
- package/scenes/L2_7180_D7_NightSky_DeepSea.html +819 -0
- package/scenes/L3_1356_D2_Waterside_HotSprings.html +2726 -0
- package/scenes/L3_171_D1_Nature_Terrain.html +750 -0
- package/scenes/L3_1966_D4_Travel_Transit.html +1590 -0
- package/scenes/L3_2464_D1_Nature_Terrain.html +867 -0
- package/scenes/L3_2559_D3_Towns_Plazas.html +1099 -0
- package/scenes/L3_2869_D3_Towns_Plazas.html +2677 -0
- package/scenes/L3_3241_D2_Waterside_HotSprings.html +1821 -0
- package/scenes/L3_3557_D4_Travel_Transit.html +1872 -0
- package/scenes/L3_6122_D5_Markets_Shops.html +1084 -0
- package/scenes/L3_6184_D5_Markets_Shops.html +1479 -0
- package/scenes/L3_6362_D5_Markets_Shops.html +993 -0
- package/scenes/L3_6656_D6_Courtyards_Gardens.html +916 -0
- package/scenes/L3_6754_D6_Courtyards_Gardens.html +1013 -0
- package/scenes/L4_179_D1_Nature_Terrain.html +1628 -0
- package/scenes/L4_2585_D3_Towns_Plazas.html +1369 -0
- package/scenes/L4_3186_D2_Waterside_HotSprings.html +1669 -0
- package/scenes/L4_3679_D4_Travel_Transit.html +1256 -0
- package/scenes/L4_7283_D7_NightSky_DeepSea.html +1400 -0
- package/scenes/L4_7698_D8_Interiors_Workshops.html +760 -0
- package/scenes/L4_7733_D8_Interiors_Workshops.html +697 -0
- package/scenes/L5_1297_D2_Waterside_HotSprings.html +1018 -0
- package/scenes/L5_2090_D1_Nature_Terrain.html +1630 -0
- package/scenes/L5_3999_D4_Travel_Transit.html +2318 -0
- package/scenes/L5_6993_D6_Courtyards_Gardens.html +1732 -0
- package/scenes/L5_7365_D7_NightSky_DeepSea.html +1569 -0
- package/scenes/L5_7381_D7_NightSky_DeepSea.html +1779 -0
- package/scenes/L5_7874_D8_Interiors_Workshops.html +1488 -0
- package/scenes/L5_7993_D8_Interiors_Workshops.html +1367 -0
- package/scenes/catalog.json +197 -0
- package/scenes/three.module.min.js +6 -0
- package/scripts/build-scenes.mjs +184 -0
- package/scripts/check-scenes.mjs +296 -0
package/cordis.patch.yml
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Bundle layer for dsh-nook.
|
|
2
|
+
#
|
|
3
|
+
# The row loads the package's Host half, which serves the vendored scene pages
|
|
4
|
+
# on /nook-scenes. The `dsh.client` declaration in package.json loads
|
|
5
|
+
# ./client as the browser half, which paints the diorama behind the
|
|
6
|
+
# conversation and registers the picker in the composer tool row.
|
|
7
|
+
#
|
|
8
|
+
# Config keys (all optional, read once when the Host half activates):
|
|
9
|
+
# enabled true paint the background by default
|
|
10
|
+
# scene random "random" or one id from scenes/catalog.json
|
|
11
|
+
# opacity 1 diorama presence in the corner, 0.35 .. 1
|
|
12
|
+
# rotateSeconds 0 pick a new random scene every N seconds, 0 disables
|
|
13
|
+
#
|
|
14
|
+
# A choice made in the in-app picker is stored in this browser and takes
|
|
15
|
+
# precedence over these defaults.
|
|
16
|
+
- insert:
|
|
17
|
+
- id: nook
|
|
18
|
+
name: dsh-nook
|
|
19
|
+
config:
|
|
20
|
+
enabled: true
|
|
21
|
+
scene: random
|
|
22
|
+
opacity: 1
|
|
23
|
+
rotateSeconds: 0
|
package/icon.svg
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="36" height="36" viewBox="0 0 36 36">
|
|
2
|
+
<title>Miniature hillside diorama with a house and a lantern</title>
|
|
3
|
+
<circle cx="11.2" cy="9.6" r="2.1" fill="#EFD9B4"/>
|
|
4
|
+
<path d="M6.2 29.4C7.8 19.8 12.6 14.4 18 14.4s10.2 5.4 11.8 15Z" fill="#6FA893"/>
|
|
5
|
+
<path d="M3.8 30.2C6.2 23.6 10.4 20.4 14.6 20.4s8.4 3.2 10.8 9.8Z" fill="#93C1A0"/>
|
|
6
|
+
<rect x="13" y="21.6" width="5.2" height="5" rx="0.5" fill="#F6EADC"/>
|
|
7
|
+
<path d="M12.2 21.9 15.6 18.6l3.4 3.3Z" fill="#D9886A"/>
|
|
8
|
+
<rect x="14.9" y="23.2" width="1.4" height="1.4" fill="#C97F5E"/>
|
|
9
|
+
<path d="M21.8 26.4v-3.9" stroke="#94795C" stroke-width="0.9" stroke-linecap="round"/>
|
|
10
|
+
<rect x="20.85" y="21.2" width="1.9" height="2.2" rx="0.4" fill="#F5C766"/>
|
|
11
|
+
</svg>
|
package/index.js
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host half of dsh-nook.
|
|
3
|
+
*
|
|
4
|
+
* The only thing the Host owns is delivery: a read-only route that serves the
|
|
5
|
+
* vendored kawaii diorama pages (plus three.js and the catalog) to the browser
|
|
6
|
+
* half, and the conversation-background settings the browser reads once at
|
|
7
|
+
* startup.
|
|
8
|
+
*
|
|
9
|
+
* Why a route instead of the client bundle: each scene is a self-contained
|
|
10
|
+
* WebGL document of its own, so it has to render in its own browsing context.
|
|
11
|
+
* The route serves exactly three extensions below `<package>/scenes`, with no
|
|
12
|
+
* directory traversal, no writes, and no user-supplied path join.
|
|
13
|
+
*
|
|
14
|
+
* The route deliberately carries no cookie fence. Its content is public,
|
|
15
|
+
* read-only artwork vendored into the package, the same class of static asset
|
|
16
|
+
* the Web app itself serves before a session exists; the browser half only
|
|
17
|
+
* embeds it from the same origin.
|
|
18
|
+
*/
|
|
19
|
+
import { readFile, stat } from 'node:fs/promises'
|
|
20
|
+
import { dirname, join, relative, resolve, sep } from 'node:path'
|
|
21
|
+
import { fileURLToPath } from 'node:url'
|
|
22
|
+
|
|
23
|
+
/** Cordis function-plugin name. */
|
|
24
|
+
export const name = 'nook'
|
|
25
|
+
|
|
26
|
+
/** The route carrier; everything else is package-local file reading. */
|
|
27
|
+
export const inject = ['webServer']
|
|
28
|
+
|
|
29
|
+
/** Route prefix the browser half resolves scene documents against. */
|
|
30
|
+
const ROUTE_PREFIX = '/nook-scenes'
|
|
31
|
+
|
|
32
|
+
/** Extensions the route answers; anything else is a 404. */
|
|
33
|
+
const MEDIA_TYPES = new Map([
|
|
34
|
+
['.html', 'text/html; charset=utf-8'],
|
|
35
|
+
['.js', 'text/javascript; charset=utf-8'],
|
|
36
|
+
['.json', 'application/json; charset=utf-8'],
|
|
37
|
+
])
|
|
38
|
+
|
|
39
|
+
/** Settings served with the catalog; the browser half treats them as defaults. */
|
|
40
|
+
const DEFAULTS = Object.freeze({
|
|
41
|
+
enabled: true,
|
|
42
|
+
scene: 'random',
|
|
43
|
+
opacity: 1,
|
|
44
|
+
rotateSeconds: 0,
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
const packageDir = dirname(fileURLToPath(import.meta.url))
|
|
48
|
+
const scenesDir = join(packageDir, 'scenes')
|
|
49
|
+
|
|
50
|
+
/** Coerce the row's raw config into the exact shape the browser half expects. */
|
|
51
|
+
function normalizeConfig(raw) {
|
|
52
|
+
const source = raw !== null && typeof raw === 'object' ? raw : {}
|
|
53
|
+
const opacity = Number(source.opacity)
|
|
54
|
+
const rotateSeconds = Number(source.rotateSeconds)
|
|
55
|
+
const scene = typeof source.scene === 'string' ? source.scene.trim() : ''
|
|
56
|
+
return {
|
|
57
|
+
enabled: source.enabled === undefined ? DEFAULTS.enabled : source.enabled !== false,
|
|
58
|
+
scene: scene === '' ? DEFAULTS.scene : scene,
|
|
59
|
+
opacity: Number.isFinite(opacity) ? Math.min(1, Math.max(0.35, opacity)) : DEFAULTS.opacity,
|
|
60
|
+
rotateSeconds: Number.isFinite(rotateSeconds)
|
|
61
|
+
? Math.min(3600, Math.max(0, Math.round(rotateSeconds)))
|
|
62
|
+
: DEFAULTS.rotateSeconds,
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Read and validate the build-time scene catalog.
|
|
68
|
+
*
|
|
69
|
+
* It is read per manifest request rather than cached for the plugin's life, so
|
|
70
|
+
* regenerating `scenes/` (a data change, not a code change) reaches an already
|
|
71
|
+
* running Host on the next page load instead of needing a restart.
|
|
72
|
+
*/
|
|
73
|
+
async function loadCatalog(logger) {
|
|
74
|
+
try {
|
|
75
|
+
const text = await readFile(join(scenesDir, 'catalog.json'), 'utf8')
|
|
76
|
+
const parsed = JSON.parse(text)
|
|
77
|
+
const scenes = Array.isArray(parsed?.scenes) ? parsed.scenes : []
|
|
78
|
+
const valid = scenes.filter(scene => typeof scene?.id === 'string'
|
|
79
|
+
&& typeof scene?.file === 'string'
|
|
80
|
+
&& typeof scene?.title === 'string'
|
|
81
|
+
&& typeof scene?.domain === 'string')
|
|
82
|
+
if (valid.length !== scenes.length) {
|
|
83
|
+
logger?.warn?.(`nook: dropped ${scenes.length - valid.length} malformed catalog entries`)
|
|
84
|
+
}
|
|
85
|
+
return valid
|
|
86
|
+
} catch (error) {
|
|
87
|
+
logger?.warn?.(`nook: no usable scenes/catalog.json (${error instanceof Error ? error.message : String(error)})`)
|
|
88
|
+
return []
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** Resolve one request-relative path inside the scenes directory, or null. */
|
|
93
|
+
function resolveScenePath(relativePath) {
|
|
94
|
+
let decoded
|
|
95
|
+
try {
|
|
96
|
+
decoded = decodeURIComponent(relativePath)
|
|
97
|
+
} catch {
|
|
98
|
+
return null
|
|
99
|
+
}
|
|
100
|
+
if (decoded === '' || decoded.includes('\0')) return null
|
|
101
|
+
const target = resolve(scenesDir, decoded)
|
|
102
|
+
const inside = relative(scenesDir, target)
|
|
103
|
+
if (inside === '' || inside.startsWith('..') || inside.startsWith(`..${sep}`)) return null
|
|
104
|
+
return target
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** Media type of a resolved path, or undefined when the extension is not served. */
|
|
108
|
+
function mediaTypeOf(path) {
|
|
109
|
+
const dot = path.lastIndexOf('.')
|
|
110
|
+
return dot === -1 ? undefined : MEDIA_TYPES.get(path.slice(dot).toLowerCase())
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function notFound() {
|
|
114
|
+
return new Response('not found', { status: 404, headers: { 'content-type': 'text/plain; charset=utf-8' } })
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Mount the route.
|
|
119
|
+
* @param ctx - the plugin context.
|
|
120
|
+
* @param rawConfig - the row config from `cordis.patch.yml`.
|
|
121
|
+
*/
|
|
122
|
+
export function apply(ctx, rawConfig) {
|
|
123
|
+
const config = normalizeConfig(rawConfig)
|
|
124
|
+
const logger = ctx.logger
|
|
125
|
+
|
|
126
|
+
const respond = async request => {
|
|
127
|
+
const url = new URL(request.url)
|
|
128
|
+
const relativePath = url.pathname.slice(ROUTE_PREFIX.length).replace(/^\/+/u, '')
|
|
129
|
+
|
|
130
|
+
if (relativePath === 'manifest.json') {
|
|
131
|
+
const scenes = await loadCatalog(logger)
|
|
132
|
+
const payload = JSON.stringify({
|
|
133
|
+
version: 1,
|
|
134
|
+
scenes: scenes.map(scene => ({ id: scene.id, file: scene.file, title: scene.title, domain: scene.domain })),
|
|
135
|
+
config,
|
|
136
|
+
})
|
|
137
|
+
return new Response(payload, {
|
|
138
|
+
headers: {
|
|
139
|
+
'content-type': 'application/json; charset=utf-8',
|
|
140
|
+
'cache-control': 'no-store',
|
|
141
|
+
},
|
|
142
|
+
})
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const path = resolveScenePath(relativePath)
|
|
146
|
+
if (path === null) return notFound()
|
|
147
|
+
const type = mediaTypeOf(path)
|
|
148
|
+
if (type === undefined) return notFound()
|
|
149
|
+
|
|
150
|
+
let info
|
|
151
|
+
try {
|
|
152
|
+
info = await stat(path)
|
|
153
|
+
} catch {
|
|
154
|
+
return notFound()
|
|
155
|
+
}
|
|
156
|
+
if (!info.isFile()) return notFound()
|
|
157
|
+
|
|
158
|
+
const etag = `"${info.size.toString(16)}-${Math.floor(info.mtimeMs).toString(16)}"`
|
|
159
|
+
const headers = {
|
|
160
|
+
'content-type': type,
|
|
161
|
+
'cache-control': 'public, max-age=0, must-revalidate',
|
|
162
|
+
etag,
|
|
163
|
+
}
|
|
164
|
+
if (request.headers.get('if-none-match') === etag) {
|
|
165
|
+
return new Response(null, { status: 304, headers })
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
try {
|
|
169
|
+
const body = await readFile(path)
|
|
170
|
+
return new Response(body, { headers })
|
|
171
|
+
} catch {
|
|
172
|
+
return notFound()
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
ctx.effect(() => ctx.webServer.register({
|
|
177
|
+
kind: 'prefix',
|
|
178
|
+
path: ROUTE_PREFIX,
|
|
179
|
+
resource: async request => {
|
|
180
|
+
try {
|
|
181
|
+
return await respond(request)
|
|
182
|
+
} catch (error) {
|
|
183
|
+
logger?.warn?.(error instanceof Error ? error : new Error(String(error)))
|
|
184
|
+
return new Response('scene route failed', { status: 500, headers: { 'content-type': 'text/plain; charset=utf-8' } })
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
}), 'nook: scene route')
|
|
188
|
+
|
|
189
|
+
logger?.info?.(`nook: ${ROUTE_PREFIX} serves scenes from ${scenesDir}`)
|
|
190
|
+
}
|
package/locale/en.json
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"meta": {
|
|
3
|
+
"title": "Nook - corner diorama",
|
|
4
|
+
"description": "Keeps one quiet kawaii 3D diorama in the conversation's bottom-right corner, feathered into the panel so it never competes with the transcript. Click it to fill the conversation, focus the composer to let it settle back; 32 scenes, or pick one yourself."
|
|
5
|
+
}
|
|
6
|
+
}
|
package/locale/ja.json
ADDED
package/locale/zh.json
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,72 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-nook",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "Nook - a quiet kawaii 3D diorama in the corner of the DeepSeek Harness conversation. Click to fill the panel; 32 scenes from the Fable-Kawaii-3D-ThreeJS dataset.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"dsh",
|
|
7
|
+
"dsh-plugin",
|
|
8
|
+
"deepseek-harness",
|
|
9
|
+
"plugin",
|
|
10
|
+
"nook",
|
|
11
|
+
"companion",
|
|
12
|
+
"background",
|
|
13
|
+
"decoration",
|
|
14
|
+
"threejs",
|
|
15
|
+
"webgl",
|
|
16
|
+
"diorama",
|
|
17
|
+
"theme"
|
|
18
|
+
],
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"author": "FreemanHsu",
|
|
21
|
+
"homepage": "https://github.com/FreemanHsu/dsh-nook#readme",
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "git+https://github.com/FreemanHsu/dsh-nook.git"
|
|
25
|
+
},
|
|
26
|
+
"bugs": {
|
|
27
|
+
"url": "https://github.com/FreemanHsu/dsh-nook/issues"
|
|
28
|
+
},
|
|
29
|
+
"type": "module",
|
|
30
|
+
"engines": {
|
|
31
|
+
"node": "^22.19.0 || >=24.0.0",
|
|
32
|
+
"dsh": ">=0.2.2-rc.5"
|
|
33
|
+
},
|
|
34
|
+
"publishConfig": {
|
|
35
|
+
"access": "public"
|
|
36
|
+
},
|
|
37
|
+
"exports": {
|
|
38
|
+
".": "./index.js",
|
|
39
|
+
"./client": "./client.js",
|
|
40
|
+
"./package.json": "./package.json",
|
|
41
|
+
"./locale/*.json": "./locale/*.json",
|
|
42
|
+
"./icon": "./icon.svg"
|
|
43
|
+
},
|
|
44
|
+
"files": [
|
|
45
|
+
"index.js",
|
|
46
|
+
"client.js",
|
|
47
|
+
"cordis.patch.yml",
|
|
48
|
+
"locale/*.json",
|
|
49
|
+
"icon.svg",
|
|
50
|
+
"scenes",
|
|
51
|
+
"scripts",
|
|
52
|
+
"README.md",
|
|
53
|
+
"LICENSE"
|
|
54
|
+
],
|
|
55
|
+
"scripts": {
|
|
56
|
+
"build:scenes": "node scripts/build-scenes.mjs",
|
|
57
|
+
"check:scenes": "node --experimental-vm-modules scripts/check-scenes.mjs",
|
|
58
|
+
"prepublishOnly": "node --experimental-vm-modules scripts/check-scenes.mjs"
|
|
59
|
+
},
|
|
60
|
+
"dsh": {
|
|
61
|
+
"bundle": {
|
|
62
|
+
"patch": "./cordis.patch.yml"
|
|
63
|
+
},
|
|
64
|
+
"client": {
|
|
65
|
+
"platform": "web",
|
|
66
|
+
"immediately": true,
|
|
67
|
+
"inject": [
|
|
68
|
+
"@deepseek-ai/dsh-client-ui-conversation"
|
|
69
|
+
]
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|