@paodingai/nanodoc-dsh-plugin 0.0.0-stage → 0.2.4-rc.15
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 +10 -2
- package/cordis.patch.yml +33 -0
- package/docs/DETAIL.zh.md +7 -0
- package/docs/preview-all.zh.png +0 -0
- package/icon.svg +11 -0
- package/lib/client.js +368 -0
- package/lib/index.js +10 -0
- package/lib/types/client/index.d.ts +3 -0
- package/lib/types/index.d.ts +4 -0
- package/locale/en.json +7 -0
- package/locale/zh.json +7 -0
- package/package.json +72 -4
package/README.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
-
#
|
|
1
|
+
# NanoDoc
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
组合包包含三项能力:PDF 转换与翻译(PDFlux)、财报主表解析(Mesh)、文档比对(Calliper)。填写共用的 NanoDoc API 密钥后,各组件可独立开启或关闭。
|
|
4
|
+
|
|
5
|
+
在对话框上传 PDF,即可执行转换、翻译、财报主表提取、文档比对;结果支持右侧预览与本地下载。
|
|
6
|
+
|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
**用法**:填写共用的 NanoDoc API 密钥并保存,然后在对话里拖入 PDF,说明要转换、翻译、解析财报主表还是比对文档。
|
|
10
|
+
|
|
11
|
+
同一个 Harness profile 中,请只启用要使用的 NanoDoc 版本。
|
package/cordis.patch.yml
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Bundle patch for @paodingai/nanodoc-dsh-plugin.
|
|
2
|
+
# Install with: dsh plugin --profile <name> add @paodingai/nanodoc-dsh-plugin
|
|
3
|
+
# Four rows: thin UI (nanodoc) + three capability packages (row ids must stay pdflux/mesh/calliper).
|
|
4
|
+
- insert:
|
|
5
|
+
- id: nanodoc
|
|
6
|
+
name: '@paodingai/nanodoc-dsh-plugin'
|
|
7
|
+
- id: pdflux
|
|
8
|
+
name: '@paodingai/pdflux-dsh-plugin'
|
|
9
|
+
config:
|
|
10
|
+
baseUrl: https://nanodoc-gateway-cn.test.paodingai.com
|
|
11
|
+
nanodocApiKeyRef: NANODOC_API_KEY_ZH
|
|
12
|
+
pollIntervalMs: 2000
|
|
13
|
+
maxWaitSeconds: 60
|
|
14
|
+
maxFileMB: 200
|
|
15
|
+
requireUploadApproval: false
|
|
16
|
+
- id: mesh
|
|
17
|
+
name: '@paodingai/mesh-dsh-plugin'
|
|
18
|
+
config:
|
|
19
|
+
baseUrl: https://nanodoc-gateway-cn.test.paodingai.com
|
|
20
|
+
nanodocApiKeyRef: NANODOC_API_KEY_ZH
|
|
21
|
+
pollIntervalMs: 2000
|
|
22
|
+
maxWaitSeconds: 60
|
|
23
|
+
maxFileMB: 200
|
|
24
|
+
requireUploadApproval: false
|
|
25
|
+
- id: calliper
|
|
26
|
+
name: '@paodingai/calliper-dsh-plugin'
|
|
27
|
+
config:
|
|
28
|
+
baseUrl: https://nanodoc-gateway-cn.test.paodingai.com
|
|
29
|
+
nanodocApiKeyRef: NANODOC_API_KEY_ZH
|
|
30
|
+
pollIntervalMs: 2000
|
|
31
|
+
maxWaitSeconds: 60
|
|
32
|
+
maxFileMB: 200
|
|
33
|
+
requireUploadApproval: false
|
|
Binary file
|
package/icon.svg
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<svg width="58" height="58" viewBox="0 0 58 58" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M32.5568 5.32203C34.0944 4.43444 35.8587 4.72545 37.047 5.73121L45.3234 10.657C46.7314 11.1927 47.8126 12.5349 47.8127 14.2537V37.6072C47.8126 38.981 47.0795 40.2503 45.8898 40.9373L25.5011 52.7087C22.9374 54.1887 19.7327 52.3389 19.7326 49.3787V26.0252C19.7326 24.6513 20.4657 23.3811 21.6554 22.6941L33.7287 15.7234V10.0046L16.8957 19.7234C15.7257 20.3992 15.005 21.6486 15.005 22.9998V46.3533C15.0051 46.7687 15.0694 47.1618 15.1867 47.5261L15.2072 47.5886L15.1437 47.6062C12.755 48.2641 10.2137 46.4893 10.213 43.8318V20.4783C10.213 19.0819 10.9588 17.7908 12.1681 17.0925L32.5568 5.32203Z" fill="url(#paint0_linear_1_225)"/>
|
|
3
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M30.7336 38.6406C30.0338 38.2104 29.1178 38.4291 28.6875 39.1288C28.2573 39.8287 28.4759 40.7447 29.1757 41.1749L30.1264 41.7593C30.8262 42.1893 31.7423 41.9709 32.1725 41.2711C32.6025 40.5713 32.3839 39.6553 31.6843 39.225L30.7336 38.6406ZM30.7285 27.2879C30.0287 26.8577 29.1127 27.0763 28.6824 27.7761C28.2522 28.4759 28.4708 29.3919 29.1706 29.8221L40.2584 36.638C40.9583 37.0683 41.8743 36.8497 42.3045 36.1498C42.7346 35.45 42.5161 34.534 41.8163 34.1038L30.7285 27.2879ZM30.7305 32.9639C30.0307 32.5341 29.1146 32.7525 28.6844 33.4521C28.2542 34.152 28.473 35.0689 29.1728 35.4991L32.341 37.4459C33.0409 37.8761 33.9569 37.6575 34.3871 36.9577C34.8172 36.2578 34.5987 35.3418 33.8989 34.9116L30.7305 32.9639ZM38.6459 26.48C37.946 26.0498 37.03 26.2684 36.5998 26.9682C36.1696 27.6681 36.3881 28.5841 37.088 29.0143L40.2555 30.9623C40.9554 31.3925 41.8723 31.1737 42.3025 30.4738C42.7327 29.774 42.514 28.857 41.8141 28.4268L38.6459 26.48ZM40.8605 22.1666C40.1607 21.7364 39.2447 21.9551 38.8145 22.6548C38.3842 23.3547 38.6028 24.2707 39.3027 24.7009L40.2533 25.2853C40.9532 25.7154 41.8692 25.4969 42.2994 24.7971C42.7295 24.0973 42.5109 23.1813 41.8112 22.751L40.8605 22.1666Z" fill="white"/>
|
|
4
|
+
<defs>
|
|
5
|
+
<linearGradient id="paint0_linear_1_225" x1="10.213" y1="16.014" x2="47.7863" y2="39.5297" gradientUnits="userSpaceOnUse">
|
|
6
|
+
<stop stop-color="#8B9FF8"/>
|
|
7
|
+
<stop offset="0.475962" stop-color="#6763F6"/>
|
|
8
|
+
<stop offset="1" stop-color="#3326C4"/>
|
|
9
|
+
</linearGradient>
|
|
10
|
+
</defs>
|
|
11
|
+
</svg>
|
package/lib/client.js
ADDED
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
window.__ModuleLoader__.load({
|
|
2
|
+
id: "@paodingai/nanodoc-dsh-plugin",
|
|
3
|
+
factory: (require) => {
|
|
4
|
+
var module = { exports: {} };
|
|
5
|
+
var exports = module.exports;
|
|
6
|
+
"use strict";
|
|
7
|
+
var __create = Object.create;
|
|
8
|
+
var __defProp = Object.defineProperty;
|
|
9
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
10
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
11
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
12
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
13
|
+
var __export = (target, all) => {
|
|
14
|
+
for (var name in all)
|
|
15
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
16
|
+
};
|
|
17
|
+
var __copyProps = (to, from, except, desc) => {
|
|
18
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
19
|
+
for (let key of __getOwnPropNames(from))
|
|
20
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
21
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
22
|
+
}
|
|
23
|
+
return to;
|
|
24
|
+
};
|
|
25
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
26
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
27
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
28
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
29
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
30
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
31
|
+
mod
|
|
32
|
+
));
|
|
33
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
34
|
+
|
|
35
|
+
// src/client/index.tsx
|
|
36
|
+
var index_exports = {};
|
|
37
|
+
__export(index_exports, {
|
|
38
|
+
apply: () => apply,
|
|
39
|
+
inject: () => inject
|
|
40
|
+
});
|
|
41
|
+
module.exports = __toCommonJS(index_exports);
|
|
42
|
+
|
|
43
|
+
// src/client/settings.tsx
|
|
44
|
+
var React = __toESM(require("react"), 1);
|
|
45
|
+
|
|
46
|
+
// package.json
|
|
47
|
+
var package_default = {
|
|
48
|
+
name: "@paodingai/nanodoc-dsh-plugin",
|
|
49
|
+
version: "0.2.4-rc.15",
|
|
50
|
+
description: "NanoDoc \u7EC4\u5408\u5305\uFF1A\u6574\u5408 PDF \u8F6C\u6362\u3001\u7FFB\u8BD1\u3001\u8D22\u62A5\u89E3\u6790\u3001\u6587\u6863\u6BD4\u5BF9\u80FD\u529B\uFF0C\u5404\u7EC4\u4EF6\u53EF\u72EC\u7ACB\u542F\u505C\u3002",
|
|
51
|
+
type: "module",
|
|
52
|
+
main: "lib/index.js",
|
|
53
|
+
types: "lib/types/index.d.ts",
|
|
54
|
+
exports: {
|
|
55
|
+
".": {
|
|
56
|
+
types: "./lib/types/index.d.ts",
|
|
57
|
+
default: "./lib/index.js"
|
|
58
|
+
},
|
|
59
|
+
"./client": {
|
|
60
|
+
types: "./lib/types/client/index.d.ts",
|
|
61
|
+
default: "./lib/client.js"
|
|
62
|
+
},
|
|
63
|
+
"./package.json": "./package.json",
|
|
64
|
+
"./locale/*.json": "./locale/*.json"
|
|
65
|
+
},
|
|
66
|
+
files: [
|
|
67
|
+
"docs/DETAIL.zh.md",
|
|
68
|
+
"docs/preview-all.zh.png",
|
|
69
|
+
"locale",
|
|
70
|
+
"icon.svg",
|
|
71
|
+
"lib",
|
|
72
|
+
"cordis.patch.yml",
|
|
73
|
+
"README.md"
|
|
74
|
+
],
|
|
75
|
+
dsh: {
|
|
76
|
+
bundle: {
|
|
77
|
+
patch: "./cordis.patch.yml"
|
|
78
|
+
},
|
|
79
|
+
client: {
|
|
80
|
+
platform: "web",
|
|
81
|
+
inject: [
|
|
82
|
+
"@deepseek-ai/dsh-client-locale",
|
|
83
|
+
"@deepseek-ai/dsh-api-remotes",
|
|
84
|
+
"@deepseek-ai/dsh-client-ui-plugin-manager"
|
|
85
|
+
]
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
engines: {
|
|
89
|
+
dsh: ">=0.2.2-rc.1 <0.3.0"
|
|
90
|
+
},
|
|
91
|
+
peerDependencies: {
|
|
92
|
+
"@deepseek-ai/cordis": "~4.1.0"
|
|
93
|
+
},
|
|
94
|
+
devDependencies: {
|
|
95
|
+
"@deepseek-ai/cordis": "4.1.0",
|
|
96
|
+
"@deepseek-ai/dsh-client-ui-slots": "0.2.2-rc.1",
|
|
97
|
+
"@types/node": "^22.20.5",
|
|
98
|
+
esbuild: "^0.25.0",
|
|
99
|
+
react: "^18.2.0",
|
|
100
|
+
typescript: "^5.6.0",
|
|
101
|
+
vitest: "^2.1.0"
|
|
102
|
+
},
|
|
103
|
+
scripts: {
|
|
104
|
+
build: "node build/build.mjs",
|
|
105
|
+
typecheck: "tsc -p tsconfig.json --noEmit",
|
|
106
|
+
test: "vitest run",
|
|
107
|
+
smoke: "node scripts/smoke.mjs"
|
|
108
|
+
},
|
|
109
|
+
dependencies: {
|
|
110
|
+
"@paodingai/calliper-dsh-plugin": "0.2.5-rc.11",
|
|
111
|
+
"@paodingai/mesh-dsh-plugin": "0.2.4-rc.14",
|
|
112
|
+
"@paodingai/pdflux-dsh-plugin": "0.2.7-rc.11"
|
|
113
|
+
},
|
|
114
|
+
icon: "./icon.svg",
|
|
115
|
+
publishConfig: {
|
|
116
|
+
registry: "https://registry.npmjs.org/",
|
|
117
|
+
access: "public",
|
|
118
|
+
tag: "latest"
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
// src/region.ts
|
|
123
|
+
var PLUGIN_LANGUAGE = "zh";
|
|
124
|
+
var API_KEY_REF = "NANODOC_API_KEY_ZH";
|
|
125
|
+
|
|
126
|
+
// src/client/settings-keys.ts
|
|
127
|
+
var SETTINGS_BUNDLE_KEY = package_default.name;
|
|
128
|
+
var rowId = PLUGIN_LANGUAGE === "en" ? "nanodoc-en" : "nanodoc";
|
|
129
|
+
var SETTINGS_ROW_KEYS = [`${SETTINGS_BUNDLE_KEY}#${rowId}`];
|
|
130
|
+
|
|
131
|
+
// src/client/locale/zh.json
|
|
132
|
+
var zh_default = {
|
|
133
|
+
settingsLanguage: "\u8BED\u8A00",
|
|
134
|
+
settingsLanguageZh: "\u4E2D\u6587",
|
|
135
|
+
settingsLanguageEn: "English",
|
|
136
|
+
settingsWebsite: "\u5B98\u7F51",
|
|
137
|
+
settingsWebsiteHint: "\u8BF7\u901A\u8FC7\u4E0A\u65B9\u5B98\u7F51\u94FE\u63A5\u6CE8\u518C\u8D26\u53F7\u5E76\u83B7\u53D6 API Key\u3002",
|
|
138
|
+
settingsApiKey: "NanoDoc API \u5BC6\u94A5",
|
|
139
|
+
settingsSaveKey: "\u4FDD\u5B58\u5BC6\u94A5",
|
|
140
|
+
settingsClearKey: "\u6E05\u9664\u5BC6\u94A5",
|
|
141
|
+
settingsRetry: "\u91CD\u8BD5",
|
|
142
|
+
settingsBusy: "\u5904\u7406\u4E2D\u2026",
|
|
143
|
+
settingsReading: "\u6B63\u5728\u8BFB\u53D6\u2026",
|
|
144
|
+
settingsConfigured: "\u5DF2\u914D\u7F6E",
|
|
145
|
+
settingsUnconfigured: "\u672A\u914D\u7F6E",
|
|
146
|
+
settingsReadFailed: "\u8BFB\u53D6\u5931\u8D25",
|
|
147
|
+
settingsCredFailed: "\u8BFB\u53D6\u51ED\u636E\u72B6\u6001\u5931\u8D25\uFF0C\u8BF7\u68C0\u67E5\u8FDE\u63A5\u540E\u91CD\u8BD5",
|
|
148
|
+
settingsKeySaved: "\u5DF2\u4FDD\u5B58",
|
|
149
|
+
settingsKeySaveFailed: "\u4FDD\u5B58\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5",
|
|
150
|
+
settingsKeySaveFailedRetry: "\u4FDD\u5B58\u5931\u8D25\uFF0C\u8BF7\u68C0\u67E5\u8FDE\u63A5\u540E\u91CD\u8BD5",
|
|
151
|
+
settingsKeyCleared: "\u5DF2\u6E05\u9664\u5BC6\u94A5",
|
|
152
|
+
settingsClearFailed: "\u6E05\u9664\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5",
|
|
153
|
+
settingsClearFailedRetry: "\u6E05\u9664\u5931\u8D25\uFF0C\u8BF7\u68C0\u67E5\u8FDE\u63A5\u540E\u91CD\u8BD5",
|
|
154
|
+
settingsLanguageSaved: "\u5DF2\u4FDD\u5B58\u8BED\u8A00",
|
|
155
|
+
settingsLanguageSaveFailed: "\u4FDD\u5B58\u8BED\u8A00\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5",
|
|
156
|
+
settingsKeyPlaceholder: "\u8BF7\u8F93\u5165 API \u5BC6\u94A5",
|
|
157
|
+
settingsKeyReplacePlaceholder: "\u8F93\u5165\u65B0\u5BC6\u94A5\u4EE5\u66FF\u6362",
|
|
158
|
+
settingsHint: "\u5F53\u524D\u8BED\u8A00\u5BF9\u5E94\u73AF\u5883\u7684\u5BC6\u94A5\u4FDD\u5B58\u5728\u672C\u673A\uFF1B\u7559\u7A7A\u4FDD\u7559\u73B0\u6709\u5BC6\u94A5\u3002",
|
|
159
|
+
settingsSummary: "\u586B\u5199 NanoDoc API \u5BC6\u94A5",
|
|
160
|
+
settingsApiKeyZh: "\u56FD\u5185 NanoDoc API \u5BC6\u94A5",
|
|
161
|
+
settingsApiKeyEn: "\u56FD\u9645 NanoDoc API \u5BC6\u94A5",
|
|
162
|
+
settingsLanguageKeyHint: "\u5148\u9009\u62E9\u8BED\u8A00\uFF0C\u518D\u586B\u5199\u8BE5\u73AF\u5883\u7684 API Key\uFF1B\u56FD\u5185\u4E0E\u56FD\u9645\u5BC6\u94A5\u5206\u5F00\u5B58\u50A8\uFF0C\u4E09\u9879\u80FD\u529B\u5171\u7528\u5BF9\u5E94\u73AF\u5883\u7684\u5BC6\u94A5\uFF0C\u5931\u6548\u65F6\u4E0D\u4F1A\u81EA\u52A8\u6539\u7528\u53E6\u4E00\u628A\u3002"
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
// src/client/locale/en.json
|
|
166
|
+
var en_default = {
|
|
167
|
+
settingsLanguage: "Language",
|
|
168
|
+
settingsLanguageZh: "\u4E2D\u6587",
|
|
169
|
+
settingsLanguageEn: "English",
|
|
170
|
+
settingsWebsite: "Official site",
|
|
171
|
+
settingsWebsiteHint: "Register on the official site above to obtain an API key.",
|
|
172
|
+
settingsApiKey: "NanoDoc API key",
|
|
173
|
+
settingsSaveKey: "Save key",
|
|
174
|
+
settingsClearKey: "Clear key",
|
|
175
|
+
settingsRetry: "Retry",
|
|
176
|
+
settingsBusy: "Working\u2026",
|
|
177
|
+
settingsReading: "Loading\u2026",
|
|
178
|
+
settingsConfigured: "Configured",
|
|
179
|
+
settingsUnconfigured: "Not configured",
|
|
180
|
+
settingsReadFailed: "Load failed",
|
|
181
|
+
settingsCredFailed: "Failed to read credential status. Check the connection and retry.",
|
|
182
|
+
settingsKeySaved: "Saved",
|
|
183
|
+
settingsKeySaveFailed: "Save failed; retry",
|
|
184
|
+
settingsKeySaveFailedRetry: "Save failed; check the connection and retry",
|
|
185
|
+
settingsKeyCleared: "API key cleared",
|
|
186
|
+
settingsClearFailed: "Failed to clear; retry",
|
|
187
|
+
settingsClearFailedRetry: "Failed to clear; check the connection and retry",
|
|
188
|
+
settingsLanguageSaved: "Language saved",
|
|
189
|
+
settingsLanguageSaveFailed: "Failed to save language; retry",
|
|
190
|
+
settingsKeyPlaceholder: "Enter API key",
|
|
191
|
+
settingsKeyReplacePlaceholder: "Enter a new key to replace",
|
|
192
|
+
settingsHint: "The key for the current language environment is stored on this machine; leave blank to keep the existing key.",
|
|
193
|
+
settingsSummary: "Enter the NanoDoc API key",
|
|
194
|
+
settingsApiKeyZh: "CN NanoDoc API key",
|
|
195
|
+
settingsApiKeyEn: "Intl NanoDoc API key",
|
|
196
|
+
settingsLanguageKeyHint: "Select a language first, then enter that environment\u2019s API key. CN and Intl keys are stored separately and shared by all three capabilities; requests never fall back to the other key."
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
// src/client/locale.ts
|
|
200
|
+
var DICTS = { zh: zh_default, en: en_default };
|
|
201
|
+
function t(key, fallback) {
|
|
202
|
+
const dict = DICTS[PLUGIN_LANGUAGE] ?? DICTS.zh;
|
|
203
|
+
return dict[key] ?? DICTS.zh[key] ?? DICTS.en[key] ?? fallback;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// src/client/settings.tsx
|
|
207
|
+
function registerSettings(ctx) {
|
|
208
|
+
const Card = (props) => {
|
|
209
|
+
const [configured, setConfigured] = React.useState(void 0);
|
|
210
|
+
const [value, setValue] = React.useState("");
|
|
211
|
+
const [message, setMessage] = React.useState(void 0);
|
|
212
|
+
const [loadError, setLoadError] = React.useState(void 0);
|
|
213
|
+
const [busy, setBusy] = React.useState(false);
|
|
214
|
+
const refresh = React.useCallback(async () => {
|
|
215
|
+
setLoadError(void 0);
|
|
216
|
+
try {
|
|
217
|
+
const res = await ctx.remote?.credentials?.describe?.([API_KEY_REF]);
|
|
218
|
+
if (res?.ok) {
|
|
219
|
+
const info = res.value?.[API_KEY_REF];
|
|
220
|
+
setConfigured(!!info?.configured);
|
|
221
|
+
} else {
|
|
222
|
+
setConfigured(void 0);
|
|
223
|
+
}
|
|
224
|
+
} catch {
|
|
225
|
+
setLoadError(t("settingsCredFailed", "\u8BFB\u53D6\u51ED\u636E\u72B6\u6001\u5931\u8D25\uFF0C\u8BF7\u68C0\u67E5\u8FDE\u63A5\u540E\u91CD\u8BD5"));
|
|
226
|
+
setConfigured(void 0);
|
|
227
|
+
}
|
|
228
|
+
}, []);
|
|
229
|
+
React.useEffect(() => {
|
|
230
|
+
if (props.view !== "summary") void refresh();
|
|
231
|
+
}, [refresh, props.view]);
|
|
232
|
+
if (props.view === "summary") {
|
|
233
|
+
return React.createElement("div", null, t("settingsSummary", "\u586B\u5199 NanoDoc API \u5BC6\u94A5"));
|
|
234
|
+
}
|
|
235
|
+
const saveKey = async () => {
|
|
236
|
+
const next = value.trim();
|
|
237
|
+
if (!next) return;
|
|
238
|
+
setBusy(true);
|
|
239
|
+
setMessage(void 0);
|
|
240
|
+
try {
|
|
241
|
+
const res = await ctx.remote?.credentials?.set?.(API_KEY_REF, next);
|
|
242
|
+
if (res?.ok) {
|
|
243
|
+
setValue("");
|
|
244
|
+
setMessage(t("settingsKeySaved", "\u5DF2\u4FDD\u5B58"));
|
|
245
|
+
await refresh();
|
|
246
|
+
} else {
|
|
247
|
+
setMessage(t("settingsKeySaveFailed", "\u4FDD\u5B58\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5"));
|
|
248
|
+
}
|
|
249
|
+
} catch {
|
|
250
|
+
setMessage(t("settingsKeySaveFailedRetry", "\u4FDD\u5B58\u5931\u8D25\uFF0C\u8BF7\u68C0\u67E5\u8FDE\u63A5\u540E\u91CD\u8BD5"));
|
|
251
|
+
} finally {
|
|
252
|
+
setBusy(false);
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
const clearKey = async () => {
|
|
256
|
+
setBusy(true);
|
|
257
|
+
setMessage(void 0);
|
|
258
|
+
try {
|
|
259
|
+
const res = await ctx.remote?.credentials?.unset?.(API_KEY_REF);
|
|
260
|
+
if (!res?.ok) {
|
|
261
|
+
setMessage(t("settingsClearFailed", "\u6E05\u9664\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5"));
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
setMessage(t("settingsKeyCleared", "\u5DF2\u6E05\u9664\u5BC6\u94A5"));
|
|
265
|
+
await refresh();
|
|
266
|
+
} catch {
|
|
267
|
+
setMessage(t("settingsClearFailedRetry", "\u6E05\u9664\u5931\u8D25\uFF0C\u8BF7\u68C0\u67E5\u8FDE\u63A5\u540E\u91CD\u8BD5"));
|
|
268
|
+
} finally {
|
|
269
|
+
setBusy(false);
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
const buttonStyle = {
|
|
273
|
+
height: 34,
|
|
274
|
+
boxSizing: "border-box",
|
|
275
|
+
border: "1px solid rgba(128,128,128,.25)",
|
|
276
|
+
borderRadius: 6,
|
|
277
|
+
padding: "0 12px",
|
|
278
|
+
font: "inherit",
|
|
279
|
+
whiteSpace: "nowrap",
|
|
280
|
+
cursor: busy ? "wait" : "pointer",
|
|
281
|
+
color: "inherit",
|
|
282
|
+
background: "transparent"
|
|
283
|
+
};
|
|
284
|
+
const inputStyle = {
|
|
285
|
+
width: "100%",
|
|
286
|
+
height: 34,
|
|
287
|
+
minWidth: 0,
|
|
288
|
+
boxSizing: "border-box",
|
|
289
|
+
padding: "0 10px",
|
|
290
|
+
borderRadius: 6,
|
|
291
|
+
border: "1px solid rgba(128,128,128,.35)",
|
|
292
|
+
background: "transparent",
|
|
293
|
+
color: "inherit",
|
|
294
|
+
font: "inherit"
|
|
295
|
+
};
|
|
296
|
+
const label = PLUGIN_LANGUAGE === "zh" ? t("settingsApiKeyZh", "\u56FD\u5185 NanoDoc API \u5BC6\u94A5") : t("settingsApiKeyEn", "\u56FD\u9645 NanoDoc API \u5BC6\u94A5");
|
|
297
|
+
const ready = configured;
|
|
298
|
+
const canSave = !busy && value.trim().length > 0;
|
|
299
|
+
return React.createElement(
|
|
300
|
+
"section",
|
|
301
|
+
{
|
|
302
|
+
style: { width: "100%", maxWidth: 480, boxSizing: "border-box", padding: "8px 0", font: '13px/1.5 -apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif' }
|
|
303
|
+
},
|
|
304
|
+
React.createElement(
|
|
305
|
+
"div",
|
|
306
|
+
{ style: { display: "flex", alignItems: "center", gap: 8, marginBottom: 8 } },
|
|
307
|
+
React.createElement("span", { style: { fontWeight: 600 } }, label),
|
|
308
|
+
React.createElement(
|
|
309
|
+
"span",
|
|
310
|
+
{ style: { padding: "2px 6px", borderRadius: 4, fontSize: 12, background: ready ? "rgba(34,160,107,.12)" : "rgba(128,128,128,.1)", color: ready ? "#25855e" : "inherit" } },
|
|
311
|
+
loadError ? t("settingsReadFailed", "\u8BFB\u53D6\u5931\u8D25") : ready === void 0 ? t("settingsReading", "\u6B63\u5728\u8BFB\u53D6\u2026") : ready ? t("settingsConfigured", "\u5DF2\u914D\u7F6E") : t("settingsUnconfigured", "\u672A\u914D\u7F6E")
|
|
312
|
+
)
|
|
313
|
+
),
|
|
314
|
+
loadError ? React.createElement("div", { role: "alert", style: { marginBottom: 8, fontSize: 12, color: "#c0392b" } }, loadError) : null,
|
|
315
|
+
React.createElement("input", {
|
|
316
|
+
type: "password",
|
|
317
|
+
"aria-label": label,
|
|
318
|
+
style: inputStyle,
|
|
319
|
+
placeholder: ready ? t("settingsKeyReplacePlaceholder", "\u8F93\u5165\u65B0\u5BC6\u94A5\u4EE5\u66FF\u6362") : t("settingsKeyPlaceholder", "\u8BF7\u8F93\u5165 API \u5BC6\u94A5"),
|
|
320
|
+
autoComplete: "off",
|
|
321
|
+
value,
|
|
322
|
+
disabled: busy,
|
|
323
|
+
onChange: (e) => setValue(e.target.value),
|
|
324
|
+
onKeyDown: (e) => {
|
|
325
|
+
if (e.key === "Enter" && canSave) void saveKey();
|
|
326
|
+
}
|
|
327
|
+
}),
|
|
328
|
+
React.createElement(
|
|
329
|
+
"div",
|
|
330
|
+
{ style: { display: "flex", alignItems: "center", gap: 8, marginTop: 8 } },
|
|
331
|
+
React.createElement("button", {
|
|
332
|
+
type: "button",
|
|
333
|
+
disabled: !canSave,
|
|
334
|
+
onClick: () => void saveKey(),
|
|
335
|
+
style: { ...buttonStyle, background: canSave ? "#4d6bfe" : "rgba(128,128,128,.1)", color: canSave ? "#fff" : "inherit", opacity: canSave ? 1 : 0.45, borderColor: "transparent" }
|
|
336
|
+
}, busy ? t("settingsBusy", "\u5904\u7406\u4E2D\u2026") : t("settingsSaveKey", "\u4FDD\u5B58\u5BC6\u94A5")),
|
|
337
|
+
ready ? React.createElement("button", { type: "button", disabled: busy, onClick: () => void clearKey(), style: buttonStyle }, t("settingsClearKey", "\u6E05\u9664\u5BC6\u94A5")) : null,
|
|
338
|
+
loadError ? React.createElement("button", { type: "button", disabled: busy, onClick: () => void refresh(), style: buttonStyle }, t("settingsRetry", "\u91CD\u8BD5")) : null
|
|
339
|
+
),
|
|
340
|
+
React.createElement("div", { style: { marginTop: 8, opacity: 0.6, fontSize: 12 } }, t("settingsHint", "\u5BC6\u94A5\u4FDD\u5B58\u5728\u672C\u673A\uFF1B\u7559\u7A7A\u4FDD\u7559\u73B0\u6709\u5BC6\u94A5\u3002")),
|
|
341
|
+
message ? React.createElement("div", { role: "status", style: { marginTop: 6, fontSize: 12 } }, message) : null
|
|
342
|
+
);
|
|
343
|
+
};
|
|
344
|
+
ctx.slots.inject(
|
|
345
|
+
"plugins.bundle.config",
|
|
346
|
+
() => ctx.slots.register({ name: "plugins.bundle.config", key: SETTINGS_BUNDLE_KEY }, Card)
|
|
347
|
+
);
|
|
348
|
+
for (const key of SETTINGS_ROW_KEYS) {
|
|
349
|
+
ctx.slots.inject(
|
|
350
|
+
"plugins.row.config",
|
|
351
|
+
() => ctx.slots.register({ name: "plugins.row.config", key }, Card)
|
|
352
|
+
);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
// src/client/index.tsx
|
|
357
|
+
var inject = [
|
|
358
|
+
"slots",
|
|
359
|
+
"remote",
|
|
360
|
+
"remote.credentials"
|
|
361
|
+
];
|
|
362
|
+
function apply(ctx) {
|
|
363
|
+
registerSettings(ctx);
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
return module.exports;
|
|
367
|
+
}
|
|
368
|
+
});
|
package/lib/index.js
ADDED
package/locale/en.json
ADDED
package/locale/zh.json
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,74 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paodingai/nanodoc-dsh-plugin",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.2.4-rc.15",
|
|
4
|
+
"description": "NanoDoc 组合包:整合 PDF 转换、翻译、财报解析、文档比对能力,各组件可独立启停。",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "lib/index.js",
|
|
7
|
+
"types": "lib/types/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./lib/types/index.d.ts",
|
|
11
|
+
"default": "./lib/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./client": {
|
|
14
|
+
"types": "./lib/types/client/index.d.ts",
|
|
15
|
+
"default": "./lib/client.js"
|
|
16
|
+
},
|
|
17
|
+
"./package.json": "./package.json",
|
|
18
|
+
"./locale/*.json": "./locale/*.json"
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"docs/DETAIL.zh.md",
|
|
22
|
+
"docs/preview-all.zh.png",
|
|
23
|
+
"locale",
|
|
24
|
+
"icon.svg",
|
|
25
|
+
"lib",
|
|
26
|
+
"cordis.patch.yml",
|
|
27
|
+
"README.md"
|
|
28
|
+
],
|
|
29
|
+
"dsh": {
|
|
30
|
+
"bundle": {
|
|
31
|
+
"patch": "./cordis.patch.yml"
|
|
32
|
+
},
|
|
33
|
+
"client": {
|
|
34
|
+
"platform": "web",
|
|
35
|
+
"inject": [
|
|
36
|
+
"@deepseek-ai/dsh-client-locale",
|
|
37
|
+
"@deepseek-ai/dsh-api-remotes",
|
|
38
|
+
"@deepseek-ai/dsh-client-ui-plugin-manager"
|
|
39
|
+
]
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"engines": {
|
|
43
|
+
"dsh": ">=0.2.2-rc.1 <0.3.0"
|
|
44
|
+
},
|
|
45
|
+
"peerDependencies": {
|
|
46
|
+
"@deepseek-ai/cordis": "~4.1.0"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@deepseek-ai/cordis": "4.1.0",
|
|
50
|
+
"@deepseek-ai/dsh-client-ui-slots": "0.2.2-rc.1",
|
|
51
|
+
"@types/node": "^22.20.5",
|
|
52
|
+
"esbuild": "^0.25.0",
|
|
53
|
+
"react": "^18.2.0",
|
|
54
|
+
"typescript": "^5.6.0",
|
|
55
|
+
"vitest": "^2.1.0"
|
|
56
|
+
},
|
|
57
|
+
"scripts": {
|
|
58
|
+
"build": "node build/build.mjs",
|
|
59
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
60
|
+
"test": "vitest run",
|
|
61
|
+
"smoke": "node scripts/smoke.mjs"
|
|
62
|
+
},
|
|
63
|
+
"dependencies": {
|
|
64
|
+
"@paodingai/calliper-dsh-plugin": "0.2.5-rc.11",
|
|
65
|
+
"@paodingai/mesh-dsh-plugin": "0.2.4-rc.14",
|
|
66
|
+
"@paodingai/pdflux-dsh-plugin": "0.2.7-rc.11"
|
|
67
|
+
},
|
|
68
|
+
"icon": "./icon.svg",
|
|
69
|
+
"publishConfig": {
|
|
70
|
+
"registry": "https://registry.npmjs.org/",
|
|
71
|
+
"access": "public",
|
|
72
|
+
"tag": "latest"
|
|
73
|
+
}
|
|
74
|
+
}
|