@nanodoc/nanodoc-dsh-plugin 0.1.0-beta.1 → 0.1.0-beta.3
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/lib/client.js +51 -29
- package/package.json +4 -4
package/lib/client.js
CHANGED
|
@@ -40,13 +40,30 @@ __export(index_exports, {
|
|
|
40
40
|
});
|
|
41
41
|
module.exports = __toCommonJS(index_exports);
|
|
42
42
|
|
|
43
|
-
// src/client/
|
|
43
|
+
// src/client/error-page.ts
|
|
44
44
|
var React = __toESM(require("react"), 1);
|
|
45
|
+
function ErrorPage({ message }) {
|
|
46
|
+
return React.createElement("div", {
|
|
47
|
+
role: "alert",
|
|
48
|
+
style: {
|
|
49
|
+
flex: "1 0 100%",
|
|
50
|
+
minHeight: 96,
|
|
51
|
+
display: "grid",
|
|
52
|
+
placeContent: "center",
|
|
53
|
+
textAlign: "center",
|
|
54
|
+
padding: 16,
|
|
55
|
+
boxSizing: "border-box"
|
|
56
|
+
}
|
|
57
|
+
}, message);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// src/client/settings.tsx
|
|
61
|
+
var React2 = __toESM(require("react"), 1);
|
|
45
62
|
|
|
46
63
|
// package.json
|
|
47
64
|
var package_default = {
|
|
48
65
|
name: "@nanodoc/nanodoc-dsh-plugin",
|
|
49
|
-
version: "0.1.0-beta.
|
|
66
|
+
version: "0.1.0-beta.3",
|
|
50
67
|
description: "NanoDoc bundle: convert and translate PDFs, extract financial statements, and compare documents. Each component can be enabled or disabled independently.",
|
|
51
68
|
type: "module",
|
|
52
69
|
main: "lib/index.js",
|
|
@@ -108,9 +125,9 @@ var package_default = {
|
|
|
108
125
|
smoke: "node scripts/smoke.mjs"
|
|
109
126
|
},
|
|
110
127
|
dependencies: {
|
|
111
|
-
"@nanodoc/
|
|
112
|
-
"@nanodoc/mesh-dsh-plugin": "0.1.0-beta.
|
|
113
|
-
"@nanodoc/
|
|
128
|
+
"@nanodoc/calliper-dsh-plugin": "0.1.0-beta.2",
|
|
129
|
+
"@nanodoc/mesh-dsh-plugin": "0.1.0-beta.2",
|
|
130
|
+
"@nanodoc/pdflux-dsh-plugin": "0.1.0-beta.2"
|
|
114
131
|
},
|
|
115
132
|
icon: "./icon.svg",
|
|
116
133
|
publishConfig: {
|
|
@@ -207,12 +224,13 @@ function t(key, fallback) {
|
|
|
207
224
|
// src/client/settings.tsx
|
|
208
225
|
function registerSettings(ctx) {
|
|
209
226
|
const Card = (props) => {
|
|
210
|
-
const [configured, setConfigured] =
|
|
211
|
-
const [value, setValue] =
|
|
212
|
-
const [message, setMessage] =
|
|
213
|
-
const [
|
|
214
|
-
const [
|
|
215
|
-
const
|
|
227
|
+
const [configured, setConfigured] = React2.useState(void 0);
|
|
228
|
+
const [value, setValue] = React2.useState("");
|
|
229
|
+
const [message, setMessage] = React2.useState(void 0);
|
|
230
|
+
const [actionError, setActionError] = React2.useState(void 0);
|
|
231
|
+
const [loadError, setLoadError] = React2.useState(void 0);
|
|
232
|
+
const [busy, setBusy] = React2.useState(false);
|
|
233
|
+
const refresh = React2.useCallback(async () => {
|
|
216
234
|
setLoadError(void 0);
|
|
217
235
|
try {
|
|
218
236
|
const res = await ctx.remote?.credentials?.describe?.([API_KEY_REF]);
|
|
@@ -220,6 +238,7 @@ function registerSettings(ctx) {
|
|
|
220
238
|
const info = res.value?.[API_KEY_REF];
|
|
221
239
|
setConfigured(!!info?.configured);
|
|
222
240
|
} else {
|
|
241
|
+
setLoadError(t("settingsCredFailed", "\u8BFB\u53D6\u51ED\u636E\u72B6\u6001\u5931\u8D25\uFF0C\u8BF7\u68C0\u67E5\u8FDE\u63A5\u540E\u91CD\u8BD5"));
|
|
223
242
|
setConfigured(void 0);
|
|
224
243
|
}
|
|
225
244
|
} catch {
|
|
@@ -227,17 +246,18 @@ function registerSettings(ctx) {
|
|
|
227
246
|
setConfigured(void 0);
|
|
228
247
|
}
|
|
229
248
|
}, []);
|
|
230
|
-
|
|
249
|
+
React2.useEffect(() => {
|
|
231
250
|
if (props.view !== "summary") void refresh();
|
|
232
251
|
}, [refresh, props.view]);
|
|
233
252
|
if (props.view === "summary") {
|
|
234
|
-
return
|
|
253
|
+
return React2.createElement("div", null, t("settingsSummary", "\u586B\u5199 NanoDoc API \u5BC6\u94A5"));
|
|
235
254
|
}
|
|
236
255
|
const saveKey = async () => {
|
|
237
256
|
const next = value.trim();
|
|
238
257
|
if (!next) return;
|
|
239
258
|
setBusy(true);
|
|
240
259
|
setMessage(void 0);
|
|
260
|
+
setActionError(void 0);
|
|
241
261
|
try {
|
|
242
262
|
const res = await ctx.remote?.credentials?.set?.(API_KEY_REF, next);
|
|
243
263
|
if (res?.ok) {
|
|
@@ -245,10 +265,10 @@ function registerSettings(ctx) {
|
|
|
245
265
|
setMessage(t("settingsKeySaved", "\u5DF2\u4FDD\u5B58"));
|
|
246
266
|
await refresh();
|
|
247
267
|
} else {
|
|
248
|
-
|
|
268
|
+
setActionError(t("settingsKeySaveFailed", "\u4FDD\u5B58\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5"));
|
|
249
269
|
}
|
|
250
270
|
} catch {
|
|
251
|
-
|
|
271
|
+
setActionError(t("settingsKeySaveFailedRetry", "\u4FDD\u5B58\u5931\u8D25\uFF0C\u8BF7\u68C0\u67E5\u8FDE\u63A5\u540E\u91CD\u8BD5"));
|
|
252
272
|
} finally {
|
|
253
273
|
setBusy(false);
|
|
254
274
|
}
|
|
@@ -256,16 +276,17 @@ function registerSettings(ctx) {
|
|
|
256
276
|
const clearKey = async () => {
|
|
257
277
|
setBusy(true);
|
|
258
278
|
setMessage(void 0);
|
|
279
|
+
setActionError(void 0);
|
|
259
280
|
try {
|
|
260
281
|
const res = await ctx.remote?.credentials?.unset?.(API_KEY_REF);
|
|
261
282
|
if (!res?.ok) {
|
|
262
|
-
|
|
283
|
+
setActionError(t("settingsClearFailed", "\u6E05\u9664\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5"));
|
|
263
284
|
return;
|
|
264
285
|
}
|
|
265
286
|
setMessage(t("settingsKeyCleared", "\u5DF2\u6E05\u9664\u5BC6\u94A5"));
|
|
266
287
|
await refresh();
|
|
267
288
|
} catch {
|
|
268
|
-
|
|
289
|
+
setActionError(t("settingsClearFailedRetry", "\u6E05\u9664\u5931\u8D25\uFF0C\u8BF7\u68C0\u67E5\u8FDE\u63A5\u540E\u91CD\u8BD5"));
|
|
269
290
|
} finally {
|
|
270
291
|
setBusy(false);
|
|
271
292
|
}
|
|
@@ -297,23 +318,23 @@ function registerSettings(ctx) {
|
|
|
297
318
|
const label = PLUGIN_LANGUAGE === "zh" ? t("settingsApiKeyZh", "\u56FD\u5185 NanoDoc API \u5BC6\u94A5") : t("settingsApiKeyEn", "\u56FD\u9645 NanoDoc API \u5BC6\u94A5");
|
|
298
319
|
const ready = configured;
|
|
299
320
|
const canSave = !busy && value.trim().length > 0;
|
|
300
|
-
return
|
|
321
|
+
return React2.createElement(
|
|
301
322
|
"section",
|
|
302
323
|
{
|
|
303
324
|
style: { width: "100%", maxWidth: 480, boxSizing: "border-box", padding: "8px 0", font: '13px/1.5 -apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif' }
|
|
304
325
|
},
|
|
305
|
-
|
|
326
|
+
React2.createElement(
|
|
306
327
|
"div",
|
|
307
328
|
{ style: { display: "flex", alignItems: "center", gap: 8, marginBottom: 8 } },
|
|
308
|
-
|
|
309
|
-
|
|
329
|
+
React2.createElement("span", { style: { fontWeight: 600 } }, label),
|
|
330
|
+
React2.createElement(
|
|
310
331
|
"span",
|
|
311
332
|
{ style: { padding: "2px 6px", borderRadius: 4, fontSize: 12, background: ready ? "rgba(34,160,107,.12)" : "rgba(128,128,128,.1)", color: ready ? "#25855e" : "inherit" } },
|
|
312
333
|
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")
|
|
313
334
|
)
|
|
314
335
|
),
|
|
315
|
-
loadError ?
|
|
316
|
-
|
|
336
|
+
loadError ? React2.createElement(ErrorPage, { message: loadError }) : null,
|
|
337
|
+
React2.createElement("input", {
|
|
317
338
|
type: "password",
|
|
318
339
|
"aria-label": label,
|
|
319
340
|
style: inputStyle,
|
|
@@ -326,20 +347,21 @@ function registerSettings(ctx) {
|
|
|
326
347
|
if (e.key === "Enter" && canSave) void saveKey();
|
|
327
348
|
}
|
|
328
349
|
}),
|
|
329
|
-
|
|
350
|
+
React2.createElement(
|
|
330
351
|
"div",
|
|
331
352
|
{ style: { display: "flex", alignItems: "center", gap: 8, marginTop: 8 } },
|
|
332
|
-
|
|
353
|
+
React2.createElement("button", {
|
|
333
354
|
type: "button",
|
|
334
355
|
disabled: !canSave,
|
|
335
356
|
onClick: () => void saveKey(),
|
|
336
357
|
style: { ...buttonStyle, background: canSave ? "#4d6bfe" : "rgba(128,128,128,.1)", color: canSave ? "#fff" : "inherit", opacity: canSave ? 1 : 0.45, borderColor: "transparent" }
|
|
337
358
|
}, busy ? t("settingsBusy", "\u5904\u7406\u4E2D\u2026") : t("settingsSaveKey", "\u4FDD\u5B58\u5BC6\u94A5")),
|
|
338
|
-
ready ?
|
|
339
|
-
loadError ?
|
|
359
|
+
ready ? React2.createElement("button", { type: "button", disabled: busy, onClick: () => void clearKey(), style: buttonStyle }, t("settingsClearKey", "\u6E05\u9664\u5BC6\u94A5")) : null,
|
|
360
|
+
loadError ? React2.createElement("button", { type: "button", disabled: busy, onClick: () => void refresh(), style: buttonStyle }, t("settingsRetry", "\u91CD\u8BD5")) : null
|
|
340
361
|
),
|
|
341
|
-
|
|
342
|
-
|
|
362
|
+
React2.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")),
|
|
363
|
+
actionError ? React2.createElement(ErrorPage, { message: actionError }) : null,
|
|
364
|
+
message ? React2.createElement("div", { role: "status", style: { marginTop: 6, fontSize: 12 } }, message) : null
|
|
343
365
|
);
|
|
344
366
|
};
|
|
345
367
|
ctx.slots.inject(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nanodoc/nanodoc-dsh-plugin",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.3",
|
|
4
4
|
"description": "NanoDoc bundle: convert and translate PDFs, extract financial statements, and compare documents. Each component can be enabled or disabled independently.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -62,9 +62,9 @@
|
|
|
62
62
|
"smoke": "node scripts/smoke.mjs"
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@nanodoc/
|
|
66
|
-
"@nanodoc/mesh-dsh-plugin": "0.1.0-beta.
|
|
67
|
-
"@nanodoc/
|
|
65
|
+
"@nanodoc/calliper-dsh-plugin": "0.1.0-beta.2",
|
|
66
|
+
"@nanodoc/mesh-dsh-plugin": "0.1.0-beta.2",
|
|
67
|
+
"@nanodoc/pdflux-dsh-plugin": "0.1.0-beta.2"
|
|
68
68
|
},
|
|
69
69
|
"icon": "./icon.svg",
|
|
70
70
|
"publishConfig": {
|