dsh-featherhunter-plugin-base 0.0.0-stage → 0.0.2-drill
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/README.md +46 -2
- package/data/img/card-feishu.png +0 -0
- package/data/img/card-qq.png +0 -0
- package/data/img/card-wechat-2026-10-23.png +0 -0
- package/data/img/card-wechat-2026-11-06.png +0 -0
- package/data/img/qr-feishu.png +0 -0
- package/data/img/qr-qq.png +0 -0
- package/data/img/qr-wechat-2026-10-23.png +0 -0
- package/data/img/qr-wechat-2026-11-06.png +0 -0
- package/data/manifest.json +158 -0
- package/dist/client/content.d.ts +116 -0
- package/dist/client/index.d.ts +15 -0
- package/dist/client/index.js +1317 -0
- package/dist/client/modal.d.ts +42 -0
- package/dist/client/plugins.d.ts +44 -0
- package/dist/client/styles.d.ts +13 -0
- package/dist/client/texts.d.ts +11 -0
- package/dist/client/types.d.ts +90 -0
- package/dist/core/baseline.d.ts +2 -0
- package/dist/core/index.d.ts +40 -0
- package/dist/core/index.js +358 -0
- package/dist/core/types.d.ts +84 -0
- package/dist/node/cli.d.ts +2 -0
- package/dist/node/cli.js +797 -0
- package/dist/node/index.d.ts +17 -0
- package/dist/node/index.js +1220 -0
- package/dist/node/readme-compare.d.ts +199 -0
- package/dist/node/readme-sync.d.ts +143 -0
- package/dist/node/renderers.d.ts +48 -0
- package/dist/node/types.d.ts +56 -0
- package/package.json +75 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 FeatherHunter
|
|
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/README.md
CHANGED
|
@@ -1,3 +1,47 @@
|
|
|
1
|
-
#
|
|
1
|
+
# dsh-featherhunter-plugin-base
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
FeatherHunter DSH 插件共用的基础包:设置面板里的**联系作者弹窗 / 作者插件推荐卡**,
|
|
4
|
+
以及 **README 四块内容**(联系区、star 历史、致谢、MORE)的渲染与同步工具。
|
|
5
|
+
|
|
6
|
+
- 纯 ESM,零运行时依赖,单包三入口。
|
|
7
|
+
- `./client` 不 import React:宿主把 React 传进 `createBaseUI(React, options)`,共享宿主的 reconciler。
|
|
8
|
+
- 数据唯一真源在仓库 `contact/`,构建后发布为 `data/manifest.json` + `data/img/`,经 npm CDN 分发。
|
|
9
|
+
- 首次渲染用包内置基线(飞书 + QQ),随后回源更新;二维码过期时降级为链接。
|
|
10
|
+
|
|
11
|
+
## 入口
|
|
12
|
+
|
|
13
|
+
| 入口 | 内容 |
|
|
14
|
+
| --- | --- |
|
|
15
|
+
| `dsh-featherhunter-plugin-base/core` | 类型、manifest 校验、排序 / 语言 / 有效期工具、内置基线 |
|
|
16
|
+
| `dsh-featherhunter-plugin-base/client` | `createBaseUI(React, options)`:`ContactButton` / `ContactRow` / `AuthorPlugins` / `openContactModal` / `closeContactModal` / `preloadContent` |
|
|
17
|
+
| `dsh-featherhunter-plugin-base/node` | README 四块渲染器 + `verifyBlock` + CLI(`readme:init` / `readme:sync` / `contact:update` / `doctor`) |
|
|
18
|
+
|
|
19
|
+
## 使用
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import { createBaseUI } from "dsh-featherhunter-plugin-base/client";
|
|
23
|
+
|
|
24
|
+
const base = createBaseUI(React, { lang: "zh", selfId: "deck" });
|
|
25
|
+
// <base.ContactButton /> / <base.AuthorPlugins />
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
```sh
|
|
29
|
+
npx dsh-base readme:sync --check
|
|
30
|
+
npx dsh-base doctor
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## 开发
|
|
34
|
+
|
|
35
|
+
```sh
|
|
36
|
+
npm install
|
|
37
|
+
npm run typecheck
|
|
38
|
+
npm test
|
|
39
|
+
npm run build
|
|
40
|
+
npm run build:demo # demo/index.html 可直接用浏览器打开
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
数据从源图到发布清单的完整流程见票 03;CDN 分发与回滚见票 02。
|
|
44
|
+
|
|
45
|
+
## License
|
|
46
|
+
|
|
47
|
+
MIT
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schema": 1,
|
|
3
|
+
"version": "0.0.2-drill",
|
|
4
|
+
"revision": 2,
|
|
5
|
+
"updatedAt": "2026-10-31T00:00:00+08:00",
|
|
6
|
+
"fallbackUrl": "https://github.com/FeatherHunter/featherhunter-plugin-manage",
|
|
7
|
+
"groups": [
|
|
8
|
+
{
|
|
9
|
+
"id": "feishu",
|
|
10
|
+
"platform": "feishu",
|
|
11
|
+
"order": 10,
|
|
12
|
+
"readmeTitle": {
|
|
13
|
+
"zh": "飞书群(主)",
|
|
14
|
+
"en": "Feishu Group (Main)"
|
|
15
|
+
},
|
|
16
|
+
"alt": {
|
|
17
|
+
"zh": "DSH 插件交流群 飞书群二维码",
|
|
18
|
+
"en": "DSH plugin community group Feishu QR code"
|
|
19
|
+
},
|
|
20
|
+
"card": "card-feishu.png",
|
|
21
|
+
"qr": {
|
|
22
|
+
"kind": "remote",
|
|
23
|
+
"path": "qr-feishu.png"
|
|
24
|
+
},
|
|
25
|
+
"title": {
|
|
26
|
+
"zh": "DSH 插件交流群",
|
|
27
|
+
"en": "DSH Plugin Community"
|
|
28
|
+
},
|
|
29
|
+
"subtitle": {
|
|
30
|
+
"zh": "用户418832的组织",
|
|
31
|
+
"en": "User 418832's organization"
|
|
32
|
+
},
|
|
33
|
+
"note": {
|
|
34
|
+
"zh": "该二维码永久有效",
|
|
35
|
+
"en": "This QR code never expires"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"id": "qq",
|
|
40
|
+
"platform": "qq",
|
|
41
|
+
"order": 20,
|
|
42
|
+
"readmeTitle": {
|
|
43
|
+
"zh": "QQ群(新)",
|
|
44
|
+
"en": "QQ Group (New)"
|
|
45
|
+
},
|
|
46
|
+
"alt": {
|
|
47
|
+
"zh": "DSH 插件交流群 QQ 群二维码",
|
|
48
|
+
"en": "DSH plugin community group QQ QR code"
|
|
49
|
+
},
|
|
50
|
+
"card": "card-qq.png",
|
|
51
|
+
"qr": {
|
|
52
|
+
"kind": "remote",
|
|
53
|
+
"path": "qr-qq.png"
|
|
54
|
+
},
|
|
55
|
+
"title": {
|
|
56
|
+
"zh": "DSH 插件交流群",
|
|
57
|
+
"en": "DSH Plugin Community"
|
|
58
|
+
},
|
|
59
|
+
"subtitle": {
|
|
60
|
+
"zh": "群号:1020866453",
|
|
61
|
+
"en": "Group ID: 1020866453"
|
|
62
|
+
},
|
|
63
|
+
"note": {
|
|
64
|
+
"zh": "扫一扫二维码,加入群聊",
|
|
65
|
+
"en": "Scan the QR code to join the group chat"
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"id": "wechat",
|
|
70
|
+
"platform": "wechat",
|
|
71
|
+
"order": 30,
|
|
72
|
+
"readmeTitle": {
|
|
73
|
+
"zh": "微信群(新)",
|
|
74
|
+
"en": "WeChat Group (New)"
|
|
75
|
+
},
|
|
76
|
+
"alt": {
|
|
77
|
+
"zh": "DSH 插件交流群微信群二维码",
|
|
78
|
+
"en": "DSH plugin community group WeChat QR code"
|
|
79
|
+
},
|
|
80
|
+
"card": "card-wechat-2026-11-06.png",
|
|
81
|
+
"qr": {
|
|
82
|
+
"kind": "remote",
|
|
83
|
+
"path": "qr-wechat-2026-11-06.png"
|
|
84
|
+
},
|
|
85
|
+
"title": {
|
|
86
|
+
"zh": "DSH 插件交流群",
|
|
87
|
+
"en": "DSH Plugin Community"
|
|
88
|
+
},
|
|
89
|
+
"subtitle": {
|
|
90
|
+
"zh": "群聊:DSH 插件交流群",
|
|
91
|
+
"en": "Group chat: DSH Plugin Community"
|
|
92
|
+
},
|
|
93
|
+
"validUntil": "2026-11-06"
|
|
94
|
+
}
|
|
95
|
+
],
|
|
96
|
+
"plugins": [
|
|
97
|
+
{
|
|
98
|
+
"id": "deck",
|
|
99
|
+
"order": 10,
|
|
100
|
+
"verifiedAt": "2026-10-30",
|
|
101
|
+
"name": "dsh-mattpocock-skills-deck",
|
|
102
|
+
"repo": "FeatherHunter/dsh-mattpocock-skills-deck",
|
|
103
|
+
"desc": {
|
|
104
|
+
"zh": "近 30 万 star 的 mattpocock/skills 整套预置好(27 个技能),装好即用。",
|
|
105
|
+
"en": "The whole mattpocock/skills set (nearly 300k stars) preinstalled — 27 skills, ready as soon as it is installed."
|
|
106
|
+
},
|
|
107
|
+
"url": "https://github.com/FeatherHunter/dsh-mattpocock-skills-deck"
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"id": "prompt",
|
|
111
|
+
"order": 20,
|
|
112
|
+
"verifiedAt": "2026-10-30",
|
|
113
|
+
"name": "dsh-prompt",
|
|
114
|
+
"repo": "FeatherHunter/dsh-prompt",
|
|
115
|
+
"desc": {
|
|
116
|
+
"zh": "经常反复重复的模板化提示词,存成自定义模板,选中后直接注入,不再需要耗费精力。",
|
|
117
|
+
"en": "The boilerplate prompts you keep retyping, saved as custom templates and injected on selection — no more wasted effort."
|
|
118
|
+
},
|
|
119
|
+
"url": "https://github.com/FeatherHunter/dsh-prompt"
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"id": "palette",
|
|
123
|
+
"order": 30,
|
|
124
|
+
"verifiedAt": "2026-10-30",
|
|
125
|
+
"name": "dsh-opencode-palette",
|
|
126
|
+
"repo": "FeatherHunter/dsh-opencode-palette",
|
|
127
|
+
"desc": {
|
|
128
|
+
"zh": "38 款 opencode 经典配色 + 20+自定义主题 一键换装 DSH。",
|
|
129
|
+
"en": "38 classic opencode themes + 20+ custom themes — reskin DSH in one click."
|
|
130
|
+
},
|
|
131
|
+
"url": "https://github.com/FeatherHunter/dsh-opencode-palette"
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
"id": "im",
|
|
135
|
+
"order": 40,
|
|
136
|
+
"verifiedAt": "2026-10-30",
|
|
137
|
+
"name": "dsh-im-companion",
|
|
138
|
+
"repo": "FeatherHunter/dsh-im-companion",
|
|
139
|
+
"desc": {
|
|
140
|
+
"zh": "给 dsh-im 加了「助理」和「家」的概念。",
|
|
141
|
+
"en": "Adds the ideas of an “assistant” and a “home” to dsh-im."
|
|
142
|
+
},
|
|
143
|
+
"url": "https://github.com/FeatherHunter/dsh-im-companion"
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
"id": "ilife",
|
|
147
|
+
"order": 50,
|
|
148
|
+
"verifiedAt": "2026-10-30",
|
|
149
|
+
"name": "ilife",
|
|
150
|
+
"repo": "FeatherHunter/ilife",
|
|
151
|
+
"desc": {
|
|
152
|
+
"zh": "⚠️建设中⚠️爱生活:居家生活套件,记账、运动、饮食、体重、食谱、物品管理、作息规划、备忘录等。",
|
|
153
|
+
"en": "⚠️Work in progress⚠️ iLife, the home-life suite: bookkeeping, exercise, diet, weight, recipes, item management, schedule planning, memos and more."
|
|
154
|
+
},
|
|
155
|
+
"url": "https://github.com/FeatherHunter/ilife"
|
|
156
|
+
}
|
|
157
|
+
]
|
|
158
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import type { Manifest } from "../core/types";
|
|
2
|
+
/**
|
|
3
|
+
* Remote manifest transport (ticket 05).
|
|
4
|
+
*
|
|
5
|
+
* The contact modal must always paint the bundled baseline first and only then
|
|
6
|
+
* swap in the published manifest. Everything in this module is therefore
|
|
7
|
+
* best-effort: any failure (timeout, HTTP error, invalid JSON, invalid data,
|
|
8
|
+
* oversized image) silently degrades to the baseline, never to an error state.
|
|
9
|
+
*/
|
|
10
|
+
/** Published package name; the CDN URLs below are derived from it. */
|
|
11
|
+
export declare const PACKAGE_NAME = "dsh-featherhunter-plugin-base";
|
|
12
|
+
/** One request may take at most 1.5s; there are no retries. */
|
|
13
|
+
export declare const MANIFEST_TIMEOUT_MS = 1500;
|
|
14
|
+
/** A fetched manifest (success or failure) is reused for 30 minutes. */
|
|
15
|
+
export declare const MANIFEST_CACHE_TTL_MS: number;
|
|
16
|
+
/** Hard cap for a single QR image, enforced before it is shown. */
|
|
17
|
+
export declare const MAX_IMAGE_BYTES: number;
|
|
18
|
+
/** The only hosts the client is allowed to talk to (images and manifest). */
|
|
19
|
+
export declare const ALLOWED_CDN_HOSTS: readonly string[];
|
|
20
|
+
/** Minimal structural view of a fetch Response; easy to fake in tests. */
|
|
21
|
+
export interface FetchResponseLike {
|
|
22
|
+
ok: boolean;
|
|
23
|
+
status: number;
|
|
24
|
+
headers: {
|
|
25
|
+
get(name: string): string | null;
|
|
26
|
+
};
|
|
27
|
+
text(): Promise<string>;
|
|
28
|
+
arrayBuffer(): Promise<ArrayBuffer>;
|
|
29
|
+
}
|
|
30
|
+
export type FetchLike = (url: string, init?: {
|
|
31
|
+
signal?: AbortSignal;
|
|
32
|
+
cache?: string;
|
|
33
|
+
credentials?: string;
|
|
34
|
+
}) => Promise<FetchResponseLike>;
|
|
35
|
+
/** A loaded and validated manifest plus the QR images prefetched for it. */
|
|
36
|
+
export interface LoadedContent {
|
|
37
|
+
manifest: Manifest;
|
|
38
|
+
/** Channel name that produced the manifest ("unpkg" / "npmmirror" / ...). */
|
|
39
|
+
source: string;
|
|
40
|
+
/** Timestamp (loader clock) at which the manifest was accepted. */
|
|
41
|
+
fetchedAt: number;
|
|
42
|
+
/** Prefetched QR images keyed by "<version>/<path>", values are data URIs. */
|
|
43
|
+
images: Map<string, string>;
|
|
44
|
+
}
|
|
45
|
+
/** Context handed to a channel loader. */
|
|
46
|
+
export interface ChannelContext {
|
|
47
|
+
packageName: string;
|
|
48
|
+
fetchText: (url: string) => Promise<string>;
|
|
49
|
+
fetchJson: (url: string) => Promise<unknown>;
|
|
50
|
+
}
|
|
51
|
+
/** One CDN channel; the channels are tried in array order. */
|
|
52
|
+
export interface ManifestChannel {
|
|
53
|
+
name: string;
|
|
54
|
+
load: (context: ChannelContext) => Promise<{
|
|
55
|
+
raw: unknown;
|
|
56
|
+
url: string;
|
|
57
|
+
}>;
|
|
58
|
+
}
|
|
59
|
+
export interface ContentLoaderOptions {
|
|
60
|
+
/** Explicit manifest URL; when set, the default CDN channels are not used. */
|
|
61
|
+
manifestUrl?: string;
|
|
62
|
+
packageName?: string;
|
|
63
|
+
fetchImpl?: FetchLike;
|
|
64
|
+
timeoutMs?: number;
|
|
65
|
+
maxImageBytes?: number;
|
|
66
|
+
/** Clock override (testing seam). */
|
|
67
|
+
now?: () => number;
|
|
68
|
+
/** Channel override (testing seam). */
|
|
69
|
+
channels?: ManifestChannel[];
|
|
70
|
+
}
|
|
71
|
+
/** True for https URLs only. */
|
|
72
|
+
export declare function isHttpsUrl(value: string): boolean;
|
|
73
|
+
/** True when the URL is https and its host is on the CDN allowlist. */
|
|
74
|
+
export declare function isAllowedCdnUrl(value: string): boolean;
|
|
75
|
+
/** Exact-version QR image URLs, primary jsDelivr then the npmmirror mirror. */
|
|
76
|
+
export declare function imageUrls(version: string, path: string, packageName?: string): string[];
|
|
77
|
+
/** The three published channels, in fallback order. */
|
|
78
|
+
export declare function defaultChannels(packageName?: string): ManifestChannel[];
|
|
79
|
+
/**
|
|
80
|
+
* Validate a remote manifest beyond what parseManifest checks: length limits
|
|
81
|
+
* for user-visible text, a sane version, safe image paths and https links.
|
|
82
|
+
* Throws an Error whose message starts with "manifest: ".
|
|
83
|
+
*/
|
|
84
|
+
export declare function validateRemoteManifest(raw: unknown): Manifest;
|
|
85
|
+
/** Drop the module cache; tests use this, production never needs it. */
|
|
86
|
+
export declare function resetContentCache(): void;
|
|
87
|
+
export declare class ContentLoader {
|
|
88
|
+
readonly packageName: string;
|
|
89
|
+
readonly timeoutMs: number;
|
|
90
|
+
readonly maxImageBytes: number;
|
|
91
|
+
private readonly fetchImpl;
|
|
92
|
+
private readonly now;
|
|
93
|
+
private readonly channels;
|
|
94
|
+
constructor(options?: ContentLoaderOptions);
|
|
95
|
+
/** Cached content when it is still inside the 30 minute window. */
|
|
96
|
+
getCached(): LoadedContent | null;
|
|
97
|
+
/**
|
|
98
|
+
* Fetch and validate the manifest once per 30 minutes; concurrent callers
|
|
99
|
+
* share one request. Resolves to null when every channel failed.
|
|
100
|
+
*/
|
|
101
|
+
load(): Promise<LoadedContent | null>;
|
|
102
|
+
/** Prefetch every remote QR image of a manifest (best effort). */
|
|
103
|
+
ensureImages(content: LoadedContent): Promise<void>;
|
|
104
|
+
/** Data URI for a remote QR path, or null when it is not prefetched. */
|
|
105
|
+
imageFor(content: LoadedContent | null, path: string): string | null;
|
|
106
|
+
/** Warm the cache: manifest plus images. Never rejects. */
|
|
107
|
+
preload(): Promise<void>;
|
|
108
|
+
private loadImage;
|
|
109
|
+
private fetchImage;
|
|
110
|
+
private fetchContent;
|
|
111
|
+
private fetchText;
|
|
112
|
+
/** One request with the 1.5s abort window; the timer is always cleared. */
|
|
113
|
+
private request;
|
|
114
|
+
}
|
|
115
|
+
/** Build a loader bound to the published package (or a custom manifest URL). */
|
|
116
|
+
export declare function createContentLoader(options?: ContentLoaderOptions): ContentLoader;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type * as ReactNamespace from "react";
|
|
2
|
+
import type { BaseUI, BaseUIOptions } from "./types";
|
|
3
|
+
export type * from "./types";
|
|
4
|
+
/**
|
|
5
|
+
* Build the settings-panel widgets bound to the injected React runtime.
|
|
6
|
+
*
|
|
7
|
+
* The client bundle never imports React: the host passes its own copy so this
|
|
8
|
+
* package shares the host's reconciler and context.
|
|
9
|
+
*/
|
|
10
|
+
export declare function createBaseUI(React: typeof ReactNamespace, options?: BaseUIOptions): BaseUI;
|
|
11
|
+
export { BASE_CSS, BASE_STYLE_ID, ensureBaseStyles } from "./styles";
|
|
12
|
+
export { MESSAGES, resolveText } from "./texts";
|
|
13
|
+
export type { TextKey, TextOverrides } from "./texts";
|
|
14
|
+
export { ALLOWED_CDN_HOSTS, ContentLoader, MANIFEST_CACHE_TTL_MS, MANIFEST_TIMEOUT_MS, MAX_IMAGE_BYTES, createContentLoader, defaultChannels, imageUrls, isAllowedCdnUrl, isHttpsUrl, resetContentCache, validateRemoteManifest, } from "./content";
|
|
15
|
+
export type { ContentLoaderOptions, FetchLike, FetchResponseLike, LoadedContent, ManifestChannel } from "./content";
|