dsh-wechat-studio 0.1.1 → 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/README.md +168 -163
- package/dist/client.js +24 -20
- package/icon.svg +28 -0
- package/package.json +4 -2
- package/src/host.js +4 -1
- package/src/version.js +71 -0
package/icon.svg
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" role="img" aria-labelledby="title desc">
|
|
2
|
+
<title id="title">公众号成稿台</title>
|
|
3
|
+
<desc id="desc">暖橙色背景上的白色稿纸,最后一行文字化作向右上发布的箭头。</desc>
|
|
4
|
+
<defs>
|
|
5
|
+
<linearGradient id="background" x1="32" y1="20" x2="224" y2="240" gradientUnits="userSpaceOnUse">
|
|
6
|
+
<stop stop-color="#FFB982"/>
|
|
7
|
+
<stop offset="1" stop-color="#FF8757"/>
|
|
8
|
+
</linearGradient>
|
|
9
|
+
<filter id="paper-shadow" x="35" y="25" width="190" height="215" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
|
|
10
|
+
<feDropShadow dx="0" dy="8" stdDeviation="8" flood-color="#8A3D24" flood-opacity="0.18"/>
|
|
11
|
+
</filter>
|
|
12
|
+
</defs>
|
|
13
|
+
|
|
14
|
+
<rect width="256" height="256" rx="60" fill="url(#background)"/>
|
|
15
|
+
<circle cx="218" cy="38" r="64" fill="#FFFFFF" opacity="0.12"/>
|
|
16
|
+
<circle cx="34" cy="226" r="76" fill="#FFFFFF" opacity="0.08"/>
|
|
17
|
+
|
|
18
|
+
<g transform="rotate(-6 128 128)">
|
|
19
|
+
<path d="M61 46C61 39.4 66.4 34 73 34H159L197 72V202C197 208.6 191.6 214 185 214H73C66.4 214 61 208.6 61 202V46Z" fill="#FFFDF9" filter="url(#paper-shadow)"/>
|
|
20
|
+
<path d="M159 34V61C159 67.1 163.9 72 170 72H197L159 34Z" fill="#FFE0C8"/>
|
|
21
|
+
<path d="M159 34L197 72H170C163.9 72 159 67.1 159 61V34Z" fill="#F7C7A7"/>
|
|
22
|
+
|
|
23
|
+
<path d="M88 91H158" stroke="#262522" stroke-width="11" stroke-linecap="round"/>
|
|
24
|
+
<path d="M88 122H167" stroke="#262522" stroke-width="11" stroke-linecap="round"/>
|
|
25
|
+
<path d="M88 153H120" stroke="#262522" stroke-width="11" stroke-linecap="round"/>
|
|
26
|
+
<path d="M119 181L174 139M151 137L177 137L177 163" fill="none" stroke="#F27645" stroke-width="12" stroke-linecap="round" stroke-linejoin="round"/>
|
|
27
|
+
</g>
|
|
28
|
+
</svg>
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-wechat-studio",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "DeepSeek Harness 插件「公众号成稿台」:写稿、按段改稿、朱雀报告质检、公众号排版预览和一键复制。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/host.js",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": "./src/host.js",
|
|
9
9
|
"./client": "./dist/client.js",
|
|
10
|
+
"./icon": "./icon.svg",
|
|
10
11
|
"./cordis.patch.yml": "./cordis.patch.yml",
|
|
11
12
|
"./package.json": "./package.json"
|
|
12
13
|
},
|
|
@@ -22,6 +23,7 @@
|
|
|
22
23
|
},
|
|
23
24
|
"homepage": "https://github.com/lqshow/dsh-wechat-studio#readme",
|
|
24
25
|
"license": "MIT",
|
|
26
|
+
"icon": "./icon.svg",
|
|
25
27
|
"scripts": {
|
|
26
28
|
"build": "node scripts/build.mjs",
|
|
27
29
|
"watch": "node scripts/build.mjs --watch",
|
|
@@ -35,5 +37,5 @@
|
|
|
35
37
|
"react-dom": "^18.3.1",
|
|
36
38
|
"unpdf": "^1.4.0"
|
|
37
39
|
},
|
|
38
|
-
"files": ["src", "dist", "skills", "vendor", "cordis.patch.yml", "README.md", "LICENSE"]
|
|
40
|
+
"files": ["src", "dist", "skills", "vendor", "icon.svg", "cordis.patch.yml", "README.md", "LICENSE"]
|
|
39
41
|
}
|
package/src/host.js
CHANGED
|
@@ -21,6 +21,7 @@ import { pdfToText } from './report.js'
|
|
|
21
21
|
import { publicSettings, readSettings, updateSettings } from './settings.js'
|
|
22
22
|
import { scheduleTime as parseScheduleTime } from './schedule-time.js'
|
|
23
23
|
import { Store } from './store.js'
|
|
24
|
+
import { createVersionChecker } from './version.js'
|
|
24
25
|
import { detect } from './zhuque.js'
|
|
25
26
|
import { draftSvgCard, insertSvgCard, previewSvgCard } from './svg-cards.js'
|
|
26
27
|
|
|
@@ -461,6 +462,7 @@ export async function route(deps, req, res) {
|
|
|
461
462
|
|
|
462
463
|
if (get) {
|
|
463
464
|
if (path === 'state') return ok()
|
|
465
|
+
if (path === 'version') return json(res, 200, await deps.versionChecker.check())
|
|
464
466
|
if (path === 'settings') return json(res, 200, { ...publicSettings(await readSettings(store.root)), version: VERSION })
|
|
465
467
|
if (path === 'models') return json(res, 200, { providers: await listModels(ctx), default: defaultSelection(ctx), current: modelOverride() })
|
|
466
468
|
if (path === 'skills') {
|
|
@@ -1100,7 +1102,8 @@ export function requestRejection(ctx, req) {
|
|
|
1100
1102
|
export function createHandler(ctx, { store = new Store(), fetchImpl } = {}) {
|
|
1101
1103
|
const pipeline = new Pipeline({ ctx, store, skillsDir: join(store.root, 'skills'), fetchImpl })
|
|
1102
1104
|
const insightsStore = new Store(store.root, { file: 'insights.json', empty: INSIGHTS_EMPTY })
|
|
1103
|
-
const
|
|
1105
|
+
const versionChecker = createVersionChecker({ currentVersion: VERSION, fetchImpl })
|
|
1106
|
+
const deps = { ctx, store, pipeline, insightsStore, versionChecker, fetchImpl }
|
|
1104
1107
|
const inlineCleanup = (async () => {
|
|
1105
1108
|
try {
|
|
1106
1109
|
JSON.parse(await readFile(store.file, 'utf8'))
|
package/src/version.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
const VERSION_URLS = [
|
|
2
|
+
'https://registry.npmjs.org/dsh-wechat-studio/latest',
|
|
3
|
+
'https://registry.npmmirror.com/dsh-wechat-studio/latest',
|
|
4
|
+
]
|
|
5
|
+
|
|
6
|
+
const CACHE_TTL_MS = 60 * 60 * 1000
|
|
7
|
+
const FETCH_TIMEOUT_MS = 8_000
|
|
8
|
+
|
|
9
|
+
function parseVersion(version) {
|
|
10
|
+
const match = /^v?(\d+)\.(\d+)\.(\d+)(?:-(alpha|beta|rc)(?:\.(\d+))?)?(?:\+[0-9a-z.-]+)?$/i.exec(String(version).trim())
|
|
11
|
+
if (!match) return null
|
|
12
|
+
const channel = match[4]?.toLowerCase()
|
|
13
|
+
return {
|
|
14
|
+
major: Number(match[1]),
|
|
15
|
+
minor: Number(match[2]),
|
|
16
|
+
patch: Number(match[3]),
|
|
17
|
+
rank: channel === 'rc' ? 3 : channel === 'beta' ? 2 : channel === 'alpha' ? 1 : 4,
|
|
18
|
+
serial: match[5] ? Number(match[5]) : 0,
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function isNewerRelease(latest, current) {
|
|
23
|
+
const a = parseVersion(latest)
|
|
24
|
+
const b = parseVersion(current)
|
|
25
|
+
if (!a || !b) return false
|
|
26
|
+
for (const key of ['major', 'minor', 'patch', 'rank', 'serial']) {
|
|
27
|
+
if (a[key] !== b[key]) return a[key] > b[key]
|
|
28
|
+
}
|
|
29
|
+
return false
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function createVersionChecker({ currentVersion, fetchImpl = fetch, now = () => Date.now(), ttlMs = CACHE_TTL_MS }) {
|
|
33
|
+
let cached = null
|
|
34
|
+
let inflight = null
|
|
35
|
+
|
|
36
|
+
const read = async () => {
|
|
37
|
+
for (const url of VERSION_URLS) {
|
|
38
|
+
try {
|
|
39
|
+
const response = await fetchImpl(url, {
|
|
40
|
+
headers: { accept: 'application/json' },
|
|
41
|
+
signal: AbortSignal.timeout(FETCH_TIMEOUT_MS),
|
|
42
|
+
})
|
|
43
|
+
if (!response.ok) continue
|
|
44
|
+
const body = await response.json()
|
|
45
|
+
if (typeof body?.version !== 'string' || !body.version) continue
|
|
46
|
+
const latest = body.version
|
|
47
|
+
return {
|
|
48
|
+
ready: true,
|
|
49
|
+
failed: false,
|
|
50
|
+
checkedAt: now(),
|
|
51
|
+
current: currentVersion,
|
|
52
|
+
latest,
|
|
53
|
+
updateAvailable: isNewerRelease(latest, currentVersion),
|
|
54
|
+
}
|
|
55
|
+
} catch {
|
|
56
|
+
// Try the mirror when the registry is unavailable or returns invalid data.
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return { ready: false, failed: true, checkedAt: now(), current: currentVersion, latest: null, updateAvailable: false }
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return {
|
|
63
|
+
async check() {
|
|
64
|
+
if (cached && now() - cached.checkedAt < ttlMs) return cached
|
|
65
|
+
if (!inflight) {
|
|
66
|
+
inflight = read().then(result => { cached = result; return result }).finally(() => { inflight = null })
|
|
67
|
+
}
|
|
68
|
+
return inflight
|
|
69
|
+
},
|
|
70
|
+
}
|
|
71
|
+
}
|