@gongfpp/dsh-novel-fish 0.1.4 → 1.0.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/README.md +67 -55
- package/assets/icon.png +0 -0
- package/docs/community-markets.md +48 -29
- package/docs/compatibility-017.md +70 -0
- package/docs/continuous-reading-020.md +46 -0
- package/docs/evidence/banner-100.png +0 -0
- package/docs/evidence/compatibility-017-result.json +65 -0
- package/docs/evidence/continuous-reading-020-result.json +72 -0
- package/docs/evidence/native-settings-sample.md +11 -0
- package/docs/evidence/native-settings-types-015.png +0 -0
- package/docs/evidence/npm-market-014-result.json +132 -0
- package/docs/evidence/plugin-settings-details.png +0 -0
- package/docs/evidence/public-release-015-result.json +36 -0
- package/docs/evidence/reading-demo-100.png +0 -0
- package/docs/evidence/settings-100.png +0 -0
- package/docs/host-adapter.md +3 -3
- package/docs/icon-metadata-021.md +40 -0
- package/docs/interaction-paths-020.md +39 -0
- package/docs/marketplace.md +3 -3
- package/docs/native-settings-update.md +48 -0
- package/docs/plugin-settings-update.md +61 -0
- package/docs/release.md +70 -1
- package/index.json +70 -6
- package/lib/client.js +306 -185
- package/locale/en.json +15 -6
- package/locale/zh.json +15 -6
- package/package.json +15 -13
- package/scripts/check-host-contracts.mjs +246 -0
- package/src/chat-adapter.js +22 -2
- package/src/client.js +5 -5
- package/src/settings.js +155 -95
- package/src/store.js +22 -3
- package/test/chat-adapter.test.js +61 -3
- package/test/client.test.js +82 -0
- package/test/helpers/host-primitives.js +28 -0
- package/test/host-contracts.test.js +32 -0
- package/test/release.test.js +19 -5
- package/test/settings.test.js +214 -65
- package/test/store.test.js +40 -0
- package/assets/icon.svg +0 -1
package/lib/client.js
CHANGED
|
@@ -15558,7 +15558,8 @@ ${part}` : part;
|
|
|
15558
15558
|
currentBookId: null,
|
|
15559
15559
|
targetTypes: Object.freeze(["reasoning"]),
|
|
15560
15560
|
mainTitle: "",
|
|
15561
|
-
extraTitle: ""
|
|
15561
|
+
extraTitle: "",
|
|
15562
|
+
continueOnReopen: false
|
|
15562
15563
|
});
|
|
15563
15564
|
var EMPTY_STATUS = Object.freeze({ kind: "empty" });
|
|
15564
15565
|
function passageSnapshotKey(bookId, stepKey) {
|
|
@@ -15615,15 +15616,17 @@ ${part}` : part;
|
|
|
15615
15616
|
this.#emitUi();
|
|
15616
15617
|
}
|
|
15617
15618
|
async setOption(key, value) {
|
|
15618
|
-
if (!["enabled", "targetTypes", "mainTitle", "extraTitle"].includes(key)) throw new Error("\u672A\u77E5\u8BBE\u7F6E\u9879");
|
|
15619
|
+
if (!["enabled", "targetTypes", "mainTitle", "extraTitle", "continueOnReopen"].includes(key)) throw new Error("\u672A\u77E5\u8BBE\u7F6E\u9879");
|
|
15619
15620
|
let normalized;
|
|
15620
15621
|
if (key === "targetTypes") {
|
|
15621
15622
|
if (!Array.isArray(value) || value.some((type) => !TARGET_TYPES.includes(type)) || new Set(value).size !== value.length) {
|
|
15622
15623
|
throw new Error("\u9605\u8BFB\u7C7B\u578B\u5FC5\u987B\u662F\u6709\u6548\u4E14\u4E0D\u91CD\u590D\u7684\u7C7B\u578B\u6570\u7EC4");
|
|
15623
15624
|
}
|
|
15624
15625
|
normalized = Object.freeze([...value]);
|
|
15626
|
+
} else if (key === "enabled" || key === "continueOnReopen") {
|
|
15627
|
+
normalized = Boolean(value);
|
|
15625
15628
|
} else {
|
|
15626
|
-
normalized =
|
|
15629
|
+
normalized = String(value);
|
|
15627
15630
|
}
|
|
15628
15631
|
if (key === "enabled" && !normalized || key === "targetTypes") this.#cancelPendingReads();
|
|
15629
15632
|
return this.#updateSettings(() => ({ [key]: normalized }));
|
|
@@ -15672,7 +15675,20 @@ ${part}` : part;
|
|
|
15672
15675
|
if (settings.currentBookId !== previousSettings.currentBookId) this.#clearPassages(false);
|
|
15673
15676
|
});
|
|
15674
15677
|
}
|
|
15678
|
+
/** Reopening a region shows the passage it already holds; a first expansion reads the next one. */
|
|
15675
15679
|
async claimPassage(stepKey, targetType = "reasoning") {
|
|
15680
|
+
return this.#readPassage(stepKey, targetType, false);
|
|
15681
|
+
}
|
|
15682
|
+
/**
|
|
15683
|
+
* Same contract as claimPassage, except a region that already shows a passage
|
|
15684
|
+
* advances to the next one. Only an explicit reopen can reach this path, so a
|
|
15685
|
+
* repeated expansion still cannot paginate by accident while long reads
|
|
15686
|
+
* continue inside the same native row.
|
|
15687
|
+
*/
|
|
15688
|
+
async continuePassage(stepKey, targetType = "reasoning") {
|
|
15689
|
+
return this.#readPassage(stepKey, targetType, true);
|
|
15690
|
+
}
|
|
15691
|
+
async #readPassage(stepKey, targetType, advance) {
|
|
15676
15692
|
if (this.disposed) return EMPTY_STATUS;
|
|
15677
15693
|
const generation = this.cacheGeneration;
|
|
15678
15694
|
const requestKey = `${generation}\0${targetType}\0${stepKey}`;
|
|
@@ -15685,7 +15701,8 @@ ${part}` : part;
|
|
|
15685
15701
|
bookId = this.state.settings.currentBookId;
|
|
15686
15702
|
if (!bookId) return EMPTY_STATUS;
|
|
15687
15703
|
const existing = this.getPassageStatus(bookId, stepKey);
|
|
15688
|
-
if (existing.kind === "
|
|
15704
|
+
if (existing.kind === "end") return existing;
|
|
15705
|
+
if (!advance && existing.kind === "ready") return existing;
|
|
15689
15706
|
const book = this.state.books.find((item) => item.id === bookId);
|
|
15690
15707
|
if (!book || book.progress >= book.segmentCount) {
|
|
15691
15708
|
return this.#writePassageStatus(bookId, stepKey, { kind: "end", bookId });
|
|
@@ -15976,6 +15993,19 @@ ${part}` : part;
|
|
|
15976
15993
|
}
|
|
15977
15994
|
}
|
|
15978
15995
|
};
|
|
15996
|
+
let queued = null;
|
|
15997
|
+
const coalescedRefresh = () => {
|
|
15998
|
+
if (!queued) return;
|
|
15999
|
+
queued = null;
|
|
16000
|
+
if (!disposed) refresh();
|
|
16001
|
+
};
|
|
16002
|
+
const scheduleRefresh = () => {
|
|
16003
|
+
if (queued) return;
|
|
16004
|
+
const entry = { frame: null };
|
|
16005
|
+
queued = entry;
|
|
16006
|
+
if (view?.requestAnimationFrame) entry.frame = view.requestAnimationFrame(coalescedRefresh);
|
|
16007
|
+
else queueMicrotask(coalescedRefresh);
|
|
16008
|
+
};
|
|
15979
16009
|
const activate = (event) => {
|
|
15980
16010
|
if (!event.isTrusted || event.defaultPrevented) return;
|
|
15981
16011
|
if (event.type === "keydown" && (event.repeat || !["Enter", " "].includes(event.key))) return;
|
|
@@ -16001,13 +16031,14 @@ ${part}` : part;
|
|
|
16001
16031
|
const current = store.getSettingsSnapshot();
|
|
16002
16032
|
const currentId = identityOf(root);
|
|
16003
16033
|
if (!disposed && toggle.isConnected && toggle.getAttribute("aria-expanded") === "true" && current.enabled && current.currentBookId === bookId && isTarget(current, currentId) && store.cacheGeneration === intent.generation && readingKey(currentId) === intent.key) {
|
|
16004
|
-
void store.
|
|
16034
|
+
if (current.continueOnReopen === true) void store.continuePassage(readingKey(id), id.type);
|
|
16035
|
+
else void store.claimPassage(readingKey(id), id.type);
|
|
16005
16036
|
}
|
|
16006
16037
|
};
|
|
16007
16038
|
if (view?.requestAnimationFrame) intent.frame = view.requestAnimationFrame(verify);
|
|
16008
16039
|
else queueMicrotask(verify);
|
|
16009
16040
|
};
|
|
16010
|
-
const observer = new MutationObserver(
|
|
16041
|
+
const observer = new MutationObserver(scheduleRefresh);
|
|
16011
16042
|
observer.observe(document.body, {
|
|
16012
16043
|
childList: true,
|
|
16013
16044
|
subtree: true,
|
|
@@ -16027,6 +16058,8 @@ ${part}` : part;
|
|
|
16027
16058
|
stopPassages();
|
|
16028
16059
|
document.removeEventListener("click", activate, true);
|
|
16029
16060
|
document.removeEventListener("keydown", activate, true);
|
|
16061
|
+
if (queued && queued.frame !== null && view?.cancelAnimationFrame) view.cancelAnimationFrame(queued.frame);
|
|
16062
|
+
queued = null;
|
|
16030
16063
|
for (const intent of pending.values()) if (intent.frame !== null) view.cancelAnimationFrame(intent.frame);
|
|
16031
16064
|
pending.clear();
|
|
16032
16065
|
for (const root of decorated.keys()) restore(root);
|
|
@@ -16130,70 +16163,83 @@ ${part}` : part;
|
|
|
16130
16163
|
|
|
16131
16164
|
// src/settings.js
|
|
16132
16165
|
var TYPE_LABELS = { reasoning: "typeReasoning", "tool-call": "typeToolCall", "read-file": "typeReadFile", command: "typeCommand", "file-search": "typeFileSearch" };
|
|
16133
|
-
var PANEL = {
|
|
16134
|
-
display: "grid",
|
|
16135
|
-
gap: 14,
|
|
16136
|
-
padding: 14,
|
|
16137
|
-
border: "1px solid var(--dsw-alias-border-l2)",
|
|
16138
|
-
borderRadius: "var(--dsw-radius-md, 10px)",
|
|
16139
|
-
color: "var(--dsw-alias-label-primary)",
|
|
16140
|
-
fontSize: "var(--dsh-content-font-size-secondary, 13px)"
|
|
16141
|
-
};
|
|
16142
|
-
var LABEL = { display: "grid", gap: 5, color: "var(--dsw-alias-label-secondary)" };
|
|
16143
|
-
var CONTROL = {
|
|
16144
|
-
boxSizing: "border-box",
|
|
16145
|
-
width: "100%",
|
|
16146
|
-
minWidth: 0,
|
|
16147
|
-
border: "1px solid var(--dsw-alias-border-l2)",
|
|
16148
|
-
borderRadius: "var(--dsw-radius-sm, 6px)",
|
|
16149
|
-
background: "var(--dsw-alias-bg-base)",
|
|
16150
|
-
color: "var(--dsw-alias-label-primary)",
|
|
16151
|
-
padding: "7px 9px",
|
|
16152
|
-
font: "inherit"
|
|
16153
|
-
};
|
|
16154
|
-
var BUTTON = {
|
|
16155
|
-
...CONTROL,
|
|
16156
|
-
width: "auto",
|
|
16157
|
-
cursor: "pointer",
|
|
16158
|
-
background: "var(--dsw-alias-interactive-bg-hover)"
|
|
16159
|
-
};
|
|
16160
16166
|
var MAIN_TITLES = ["", "\u601D\u8003", "\u5206\u6790", "\u68C0\u67E5", "Thinking"];
|
|
16161
16167
|
var EXTRA_TITLES = ["", "Checking project structure", "Analyzing the request", "Reviewing implementation", "Verifying results"];
|
|
16162
|
-
|
|
16168
|
+
var STYLES = `
|
|
16169
|
+
.novel-fish-settings{display:flex;flex-direction:column;gap:32px;min-width:0;font-size:14px;line-height:1.6;color:var(--dsw-alias-label-primary)}
|
|
16170
|
+
.novel-fish-settings .novel-fish-section{display:flex;flex-direction:column;gap:16px;min-width:0}
|
|
16171
|
+
.novel-fish-settings .novel-fish-row{display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:12px}
|
|
16172
|
+
.novel-fish-settings h3{margin:0;font:inherit;font-weight:600}
|
|
16173
|
+
.novel-fish-settings .novel-fish-field{display:flex;flex-direction:column;gap:8px;min-width:0}
|
|
16174
|
+
.novel-fish-settings .novel-fish-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,240px),1fr));gap:16px}
|
|
16175
|
+
.novel-fish-settings .novel-fish-select,.novel-fish-settings .novel-fish-input{display:flex;width:100%;min-width:0}
|
|
16176
|
+
.novel-fish-settings .novel-fish-select-button{width:100%;justify-content:space-between;gap:12px;text-align:start}
|
|
16177
|
+
.novel-fish-settings .novel-fish-selection{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}
|
|
16178
|
+
.novel-fish-settings .novel-fish-hint{margin:0;color:var(--dsw-alias-label-tertiary);font-size:13px;line-height:1.6}
|
|
16179
|
+
.novel-fish-settings .novel-fish-error{color:var(--dsw-alias-state-error-primary)}
|
|
16180
|
+
`;
|
|
16181
|
+
function createSettingsRow(React, { Switch, Button, Input, Menu, Modal, IconChevronDownOutlineRegular }) {
|
|
16163
16182
|
const h = React.createElement;
|
|
16164
|
-
function
|
|
16183
|
+
function SelectMenu({ label, summary, value, items, disabled, onChange, marker, multiple = false, footer }) {
|
|
16184
|
+
const [open, setOpen] = React.useState(false);
|
|
16185
|
+
const selection = multiple ? summary : items.find((item) => item.id === value)?.label ?? label;
|
|
16186
|
+
return h(Menu, {
|
|
16187
|
+
open,
|
|
16188
|
+
onClose: () => setOpen(false),
|
|
16189
|
+
portal: true,
|
|
16190
|
+
autoFocus: true,
|
|
16191
|
+
className: "novel-fish-select",
|
|
16192
|
+
items: items.map((item) => ({ ...item, disabled: disabled || item.disabled })),
|
|
16193
|
+
footer: footer?.map((item) => ({ ...item, disabled })),
|
|
16194
|
+
...multiple ? { selectedIds: value } : { selectedId: value },
|
|
16195
|
+
onSelect: (id) => {
|
|
16196
|
+
if (disabled) return;
|
|
16197
|
+
if (!multiple) setOpen(false);
|
|
16198
|
+
onChange(id);
|
|
16199
|
+
},
|
|
16200
|
+
anchor: h(Button, {
|
|
16201
|
+
variant: "outline",
|
|
16202
|
+
disabled,
|
|
16203
|
+
className: "novel-fish-select-button",
|
|
16204
|
+
"aria-label": label,
|
|
16205
|
+
"aria-haspopup": "menu",
|
|
16206
|
+
"aria-expanded": open,
|
|
16207
|
+
...marker,
|
|
16208
|
+
onClick: () => {
|
|
16209
|
+
if (!disabled) setOpen((current) => !current);
|
|
16210
|
+
}
|
|
16211
|
+
}, h("span", { className: "novel-fish-selection" }, selection), h(IconChevronDownOutlineRegular, { size: 16 }))
|
|
16212
|
+
});
|
|
16213
|
+
}
|
|
16214
|
+
function PresetField({ t, label, value, choices, disabled, onChange, testId }) {
|
|
16165
16215
|
const [custom, setCustom] = React.useState(!choices.includes(value));
|
|
16166
16216
|
const showCustom = custom || !choices.includes(value);
|
|
16167
16217
|
return h(
|
|
16168
|
-
"
|
|
16169
|
-
{
|
|
16218
|
+
"div",
|
|
16219
|
+
{ className: "novel-fish-field" },
|
|
16170
16220
|
h("span", null, label),
|
|
16171
|
-
h(
|
|
16172
|
-
|
|
16173
|
-
|
|
16174
|
-
|
|
16175
|
-
|
|
16176
|
-
|
|
16177
|
-
|
|
16178
|
-
|
|
16179
|
-
|
|
16180
|
-
if (
|
|
16181
|
-
|
|
16182
|
-
|
|
16183
|
-
|
|
16184
|
-
|
|
16185
|
-
|
|
16186
|
-
choices.map((choice) => h("option", { key: choice, value: choice }, choice || t(testId === "title" ? "settings.nativeTitle" : "settings.noExtra"))),
|
|
16187
|
-
h("option", { value: "__custom" }, t("settings.custom"))
|
|
16188
|
-
),
|
|
16189
|
-
showCustom ? h("input", {
|
|
16190
|
-
style: CONTROL,
|
|
16221
|
+
h(SelectMenu, {
|
|
16222
|
+
label,
|
|
16223
|
+
value: showCustom ? "__custom" : value,
|
|
16224
|
+
disabled,
|
|
16225
|
+
marker: { "data-novel-preset": testId },
|
|
16226
|
+
items: [...choices.map((choice) => ({ id: choice, label: choice || t(testId === "title" ? "settings.nativeTitle" : "settings.noExtra") })), { id: "__custom", label: t("settings.custom") }],
|
|
16227
|
+
onChange: (next) => {
|
|
16228
|
+
if (next === "__custom") setCustom(true);
|
|
16229
|
+
else void onChange(next).then((saved) => {
|
|
16230
|
+
if (saved) setCustom(false);
|
|
16231
|
+
});
|
|
16232
|
+
}
|
|
16233
|
+
}),
|
|
16234
|
+
showCustom ? h(Input, {
|
|
16235
|
+
className: "novel-fish-input",
|
|
16191
16236
|
defaultValue: value,
|
|
16192
16237
|
disabled,
|
|
16193
|
-
maxLength,
|
|
16194
16238
|
"aria-label": t("settings.customField", { label }),
|
|
16195
16239
|
[`data-novel-${testId}`]: true,
|
|
16196
|
-
onChange: (event) =>
|
|
16240
|
+
onChange: (event) => {
|
|
16241
|
+
void onChange(event.currentTarget.value);
|
|
16242
|
+
}
|
|
16197
16243
|
}) : null
|
|
16198
16244
|
);
|
|
16199
16245
|
}
|
|
@@ -16202,6 +16248,16 @@ ${part}` : part;
|
|
|
16202
16248
|
const ui = useNovelUi((value) => value);
|
|
16203
16249
|
const [busy, setBusy] = React.useState(false);
|
|
16204
16250
|
const [savingTypes, setSavingTypes] = React.useState(false);
|
|
16251
|
+
const [savingEnabled, setSavingEnabled] = React.useState(false);
|
|
16252
|
+
const [savingContinue, setSavingContinue] = React.useState(false);
|
|
16253
|
+
const [removeBook, setRemoveBook] = React.useState(null);
|
|
16254
|
+
const [removeError, setRemoveError] = React.useState(null);
|
|
16255
|
+
const enabling = React.useRef(false);
|
|
16256
|
+
const continuing = React.useRef(false);
|
|
16257
|
+
const changingTypes = React.useRef(false);
|
|
16258
|
+
const importing = React.useRef(false);
|
|
16259
|
+
const removing = React.useRef(false);
|
|
16260
|
+
const fileInput = React.useRef(null);
|
|
16205
16261
|
const selectedBook = state.books.find((book) => book.id === state.settings.currentBookId);
|
|
16206
16262
|
const disabled = busy || !state.hydrated || Boolean(state.error);
|
|
16207
16263
|
const perform = async (action) => {
|
|
@@ -16213,18 +16269,44 @@ ${part}` : part;
|
|
|
16213
16269
|
return false;
|
|
16214
16270
|
}
|
|
16215
16271
|
};
|
|
16272
|
+
const setEnabled = async (enabled) => {
|
|
16273
|
+
if (disabled || enabling.current) return;
|
|
16274
|
+
enabling.current = true;
|
|
16275
|
+
setSavingEnabled(true);
|
|
16276
|
+
try {
|
|
16277
|
+
await perform(() => onSetOption("enabled", enabled));
|
|
16278
|
+
} finally {
|
|
16279
|
+
enabling.current = false;
|
|
16280
|
+
setSavingEnabled(false);
|
|
16281
|
+
}
|
|
16282
|
+
};
|
|
16283
|
+
const setContinue = async (enabled) => {
|
|
16284
|
+
if (disabled || continuing.current) return;
|
|
16285
|
+
continuing.current = true;
|
|
16286
|
+
setSavingContinue(true);
|
|
16287
|
+
try {
|
|
16288
|
+
await perform(() => onSetOption("continueOnReopen", enabled));
|
|
16289
|
+
} finally {
|
|
16290
|
+
continuing.current = false;
|
|
16291
|
+
setSavingContinue(false);
|
|
16292
|
+
}
|
|
16293
|
+
};
|
|
16216
16294
|
const setTypes = async (types) => {
|
|
16295
|
+
if (disabled || changingTypes.current) return;
|
|
16296
|
+
changingTypes.current = true;
|
|
16217
16297
|
setSavingTypes(true);
|
|
16218
16298
|
try {
|
|
16219
16299
|
await perform(() => onSetOption("targetTypes", types));
|
|
16220
16300
|
} finally {
|
|
16301
|
+
changingTypes.current = false;
|
|
16221
16302
|
setSavingTypes(false);
|
|
16222
16303
|
}
|
|
16223
16304
|
};
|
|
16224
16305
|
const importFile = async (event) => {
|
|
16225
16306
|
const input = event.currentTarget;
|
|
16226
16307
|
const file = input.files?.[0];
|
|
16227
|
-
if (!file) return;
|
|
16308
|
+
if (!file || disabled || importing.current) return;
|
|
16309
|
+
importing.current = true;
|
|
16228
16310
|
setBusy(true);
|
|
16229
16311
|
onSetNotice(t("settings.importing"));
|
|
16230
16312
|
try {
|
|
@@ -16234,132 +16316,153 @@ ${part}` : part;
|
|
|
16234
16316
|
onSetNotice(t("settings.importError", { message: errorMessage(error) }));
|
|
16235
16317
|
} finally {
|
|
16236
16318
|
input.value = "";
|
|
16319
|
+
importing.current = false;
|
|
16320
|
+
setBusy(false);
|
|
16321
|
+
}
|
|
16322
|
+
};
|
|
16323
|
+
const closeRemove = () => {
|
|
16324
|
+
if (!removing.current) setRemoveBook(null);
|
|
16325
|
+
};
|
|
16326
|
+
const confirmRemove = async () => {
|
|
16327
|
+
if (!removeBook || disabled || removing.current) return;
|
|
16328
|
+
removing.current = true;
|
|
16329
|
+
setRemoveError(null);
|
|
16330
|
+
setBusy(true);
|
|
16331
|
+
try {
|
|
16332
|
+
await onDeleteBook(removeBook.id);
|
|
16333
|
+
setRemoveBook(null);
|
|
16334
|
+
} catch (error) {
|
|
16335
|
+
setRemoveError(t("settings.actionError", { message: errorMessage(error) }));
|
|
16336
|
+
} finally {
|
|
16337
|
+
removing.current = false;
|
|
16237
16338
|
setBusy(false);
|
|
16238
16339
|
}
|
|
16239
16340
|
};
|
|
16240
16341
|
return h(
|
|
16241
16342
|
"section",
|
|
16242
|
-
{
|
|
16343
|
+
{ className: "novel-fish-settings", "data-novel-settings": true },
|
|
16344
|
+
h("style", null, STYLES),
|
|
16345
|
+
!state.hydrated && !state.error ? h("div", { role: "status" }, t("settings.storageLoading")) : null,
|
|
16346
|
+
state.error ? h("div", { role: "alert", className: "novel-fish-error" }, state.error) : null,
|
|
16243
16347
|
h(
|
|
16244
|
-
"
|
|
16245
|
-
{
|
|
16246
|
-
h(
|
|
16247
|
-
|
|
16248
|
-
|
|
16249
|
-
|
|
16250
|
-
|
|
16251
|
-
|
|
16252
|
-
|
|
16253
|
-
|
|
16254
|
-
h("input", { type: "
|
|
16255
|
-
const enabled = event.currentTarget.checked;
|
|
16256
|
-
void perform(() => onSetOption("enabled", enabled));
|
|
16257
|
-
} }),
|
|
16258
|
-
t("settings.enabled")
|
|
16259
|
-
),
|
|
16260
|
-
h(
|
|
16261
|
-
"label",
|
|
16262
|
-
{ style: LABEL },
|
|
16263
|
-
h("span", null, t("settings.bookSource")),
|
|
16264
|
-
h("input", { type: "file", accept: ".epub,.txt,.md,application/epub+zip,text/plain,text/markdown", onChange: (event) => {
|
|
16348
|
+
"section",
|
|
16349
|
+
{ className: "novel-fish-section" },
|
|
16350
|
+
h(
|
|
16351
|
+
"div",
|
|
16352
|
+
{ className: "novel-fish-row" },
|
|
16353
|
+
h("h3", null, t("settings.books")),
|
|
16354
|
+
h(Button, { variant: "outline", disabled, "data-novel-import": true, onClick: () => {
|
|
16355
|
+
if (!disabled) fileInput.current?.click();
|
|
16356
|
+
} }, t("settings.importBook"))
|
|
16357
|
+
),
|
|
16358
|
+
h("input", { ref: fileInput, hidden: true, type: "file", accept: ".epub,.txt,.md,application/epub+zip,text/plain,text/markdown", onChange: (event) => {
|
|
16265
16359
|
void importFile(event);
|
|
16266
|
-
}, disabled, "data-novel-file-input": true })
|
|
16267
|
-
),
|
|
16268
|
-
h(
|
|
16269
|
-
"label",
|
|
16270
|
-
{ style: LABEL },
|
|
16271
|
-
h("span", null, t("settings.selectBook")),
|
|
16360
|
+
}, disabled, "data-novel-file-input": true }),
|
|
16272
16361
|
h(
|
|
16273
|
-
"
|
|
16274
|
-
{
|
|
16275
|
-
|
|
16276
|
-
|
|
16362
|
+
"div",
|
|
16363
|
+
{ className: "novel-fish-field" },
|
|
16364
|
+
h("span", null, t("settings.selectBook")),
|
|
16365
|
+
h(SelectMenu, {
|
|
16366
|
+
label: t("settings.selectBook"),
|
|
16277
16367
|
value: state.settings.currentBookId ?? "",
|
|
16278
|
-
|
|
16279
|
-
|
|
16280
|
-
|
|
16368
|
+
disabled: disabled || !state.books.length,
|
|
16369
|
+
marker: { "data-novel-book-select": true },
|
|
16370
|
+
items: [{ id: "", label: t("settings.noBook") }, ...state.books.map((book) => ({ id: book.id, label: `${book.title} \xB7 ${book.format.toUpperCase()}` }))],
|
|
16371
|
+
onChange: (id) => {
|
|
16281
16372
|
void perform(() => onSelectBook(id));
|
|
16282
16373
|
}
|
|
16283
|
-
}
|
|
16284
|
-
|
|
16285
|
-
|
|
16286
|
-
|
|
16374
|
+
})
|
|
16375
|
+
),
|
|
16376
|
+
selectedBook ? h(
|
|
16377
|
+
"div",
|
|
16378
|
+
{ className: "novel-fish-row" },
|
|
16379
|
+
h("span", { className: "novel-fish-hint", "data-novel-progress": true }, t("settings.progressValue", { progress: selectedBook.progress, total: selectedBook.segmentCount, percent: Math.floor(selectedBook.progress / selectedBook.segmentCount * 100) })),
|
|
16380
|
+
h(Button, { variant: "ghost", disabled, "data-novel-delete": true, onClick: () => {
|
|
16381
|
+
setRemoveError(null);
|
|
16382
|
+
setRemoveBook(selectedBook);
|
|
16383
|
+
} }, t("settings.deleteBook"))
|
|
16384
|
+
) : h("p", { className: "novel-fish-hint" }, t("settings.emptyLibrary"))
|
|
16287
16385
|
),
|
|
16288
|
-
selectedBook ? h(
|
|
16289
|
-
"div",
|
|
16290
|
-
{ style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 8 } },
|
|
16291
|
-
h("span", { "data-novel-progress": true }, t("settings.progressValue", { progress: selectedBook.progress, total: selectedBook.segmentCount, percent: Math.floor(selectedBook.progress / selectedBook.segmentCount * 100) })),
|
|
16292
|
-
h("button", { type: "button", style: BUTTON, disabled, onClick: () => {
|
|
16293
|
-
if (globalThis.confirm?.(t("settings.removeConfirm", { title: selectedBook.title }))) void perform(() => onDeleteBook(selectedBook.id));
|
|
16294
|
-
} }, t("settings.deleteBook"))
|
|
16295
|
-
) : h("div", null, t("settings.emptyLibrary")),
|
|
16296
16386
|
h(
|
|
16297
|
-
"
|
|
16298
|
-
{
|
|
16299
|
-
h("
|
|
16387
|
+
"section",
|
|
16388
|
+
{ className: "novel-fish-section" },
|
|
16389
|
+
h("h3", null, t("settings.reading")),
|
|
16300
16390
|
h(
|
|
16301
|
-
"
|
|
16302
|
-
{
|
|
16303
|
-
h(
|
|
16304
|
-
|
|
16305
|
-
|
|
16306
|
-
|
|
16307
|
-
|
|
16308
|
-
|
|
16309
|
-
|
|
16310
|
-
|
|
16311
|
-
|
|
16312
|
-
|
|
16313
|
-
|
|
16314
|
-
|
|
16315
|
-
|
|
16316
|
-
|
|
16317
|
-
|
|
16318
|
-
|
|
16319
|
-
|
|
16320
|
-
|
|
16321
|
-
|
|
16322
|
-
|
|
16323
|
-
|
|
16324
|
-
|
|
16325
|
-
|
|
16326
|
-
|
|
16327
|
-
|
|
16328
|
-
|
|
16329
|
-
|
|
16330
|
-
|
|
16331
|
-
|
|
16332
|
-
|
|
16333
|
-
|
|
16334
|
-
}
|
|
16335
|
-
}),
|
|
16336
|
-
t(`settings.${TYPE_LABELS[type]}`)
|
|
16337
|
-
))
|
|
16338
|
-
)
|
|
16391
|
+
"div",
|
|
16392
|
+
{ className: "novel-fish-row" },
|
|
16393
|
+
h("span", null, t("settings.enabled")),
|
|
16394
|
+
h(Switch, { checked: state.settings.enabled, disabled: disabled || savingEnabled, label: t("settings.enabled"), onChange: (enabled) => {
|
|
16395
|
+
void setEnabled(enabled);
|
|
16396
|
+
} })
|
|
16397
|
+
),
|
|
16398
|
+
h(
|
|
16399
|
+
"div",
|
|
16400
|
+
{ className: "novel-fish-field" },
|
|
16401
|
+
h("span", null, t("settings.targetType")),
|
|
16402
|
+
h(SelectMenu, {
|
|
16403
|
+
label: t("settings.targetType"),
|
|
16404
|
+
summary: t("settings.selectedTypes", { count: state.settings.targetTypes.length, total: TARGET_TYPES.length }),
|
|
16405
|
+
value: state.settings.targetTypes,
|
|
16406
|
+
multiple: true,
|
|
16407
|
+
disabled: disabled || savingTypes,
|
|
16408
|
+
marker: { "data-novel-type-select": true },
|
|
16409
|
+
items: TARGET_TYPES.map((type) => ({ id: type, label: t(`settings.${TYPE_LABELS[type]}`) })),
|
|
16410
|
+
footer: [{ id: "__all", label: t(state.settings.targetTypes.length === TARGET_TYPES.length ? "settings.clearTypes" : "settings.allTypes") }],
|
|
16411
|
+
onChange: (type) => {
|
|
16412
|
+
void setTypes(type === "__all" ? state.settings.targetTypes.length === TARGET_TYPES.length ? [] : [...TARGET_TYPES] : TARGET_TYPES.filter((value) => value === type ? !state.settings.targetTypes.includes(type) : state.settings.targetTypes.includes(value)));
|
|
16413
|
+
}
|
|
16414
|
+
}),
|
|
16415
|
+
h("p", { className: "novel-fish-hint" }, t("settings.typeHint"))
|
|
16416
|
+
),
|
|
16417
|
+
h(
|
|
16418
|
+
"div",
|
|
16419
|
+
{ className: "novel-fish-row" },
|
|
16420
|
+
h("span", null, t("settings.continueOnReopen")),
|
|
16421
|
+
h(Switch, { checked: state.settings.continueOnReopen === true, disabled: disabled || savingContinue, label: t("settings.continueOnReopen"), onChange: (enabled) => {
|
|
16422
|
+
void setContinue(enabled);
|
|
16423
|
+
} })
|
|
16339
16424
|
),
|
|
16340
|
-
h("
|
|
16425
|
+
h("p", { className: "novel-fish-hint" }, t("settings.continueOnReopenHint"))
|
|
16341
16426
|
),
|
|
16342
16427
|
h(
|
|
16343
|
-
"
|
|
16344
|
-
{
|
|
16345
|
-
|
|
16346
|
-
|
|
16347
|
-
|
|
16348
|
-
|
|
16349
|
-
|
|
16350
|
-
|
|
16351
|
-
|
|
16352
|
-
|
|
16353
|
-
|
|
16354
|
-
|
|
16355
|
-
|
|
16356
|
-
|
|
16357
|
-
|
|
16358
|
-
|
|
16428
|
+
"section",
|
|
16429
|
+
{ className: "novel-fish-section" },
|
|
16430
|
+
h("h3", null, t("settings.appearance")),
|
|
16431
|
+
h(
|
|
16432
|
+
"div",
|
|
16433
|
+
{ key: String(state.hydrated), className: "novel-fish-grid" },
|
|
16434
|
+
[
|
|
16435
|
+
["mainTitle", "settings.titleMain", "title", MAIN_TITLES],
|
|
16436
|
+
["extraTitle", "settings.titleExtra", "extra", EXTRA_TITLES]
|
|
16437
|
+
].map(([key, label, testId, choices]) => h(PresetField, {
|
|
16438
|
+
key,
|
|
16439
|
+
t,
|
|
16440
|
+
label: t(label),
|
|
16441
|
+
value: state.settings[key],
|
|
16442
|
+
choices,
|
|
16443
|
+
disabled,
|
|
16444
|
+
testId,
|
|
16445
|
+
onChange: (value) => perform(() => onSetOption(key, value))
|
|
16446
|
+
}))
|
|
16447
|
+
),
|
|
16448
|
+
h("p", { className: "novel-fish-hint" }, t("settings.nativeControls"))
|
|
16359
16449
|
),
|
|
16360
|
-
h("
|
|
16361
|
-
h(
|
|
16362
|
-
|
|
16450
|
+
ui.notice ? h("div", { role: "status", "data-novel-notice": true }, ui.notice) : null,
|
|
16451
|
+
h(Modal, {
|
|
16452
|
+
open: Boolean(removeBook),
|
|
16453
|
+
onClose: closeRemove,
|
|
16454
|
+
title: t("settings.deleteBook"),
|
|
16455
|
+
closeLabel: t("settings.cancel"),
|
|
16456
|
+
description: removeBook ? t("settings.removeConfirm", { title: removeBook.title }) : "",
|
|
16457
|
+
footer: h(
|
|
16458
|
+
React.Fragment,
|
|
16459
|
+
null,
|
|
16460
|
+
h(Button, { variant: "outline", disabled: busy, onClick: closeRemove }, t("settings.cancel")),
|
|
16461
|
+
h(Button, { variant: "primary", disabled: disabled || !removeBook, "data-novel-delete-confirm": true, onClick: () => {
|
|
16462
|
+
void confirmRemove();
|
|
16463
|
+
} }, t("settings.confirmDelete"))
|
|
16464
|
+
)
|
|
16465
|
+
}, removeError ? h("p", { role: "alert" }, removeError) : null)
|
|
16363
16466
|
);
|
|
16364
16467
|
}
|
|
16365
16468
|
return React.memo(SettingsRow);
|
|
@@ -16381,7 +16484,7 @@ ${part}` : part;
|
|
|
16381
16484
|
stopped: "\u5DF2\u505C\u6B62",
|
|
16382
16485
|
unknownBlock: "\u672A\u77E5\u5185\u5BB9\u5757",
|
|
16383
16486
|
jsonTruncated: "\u2026 \u5DF2\u622A\u65AD\uFF0C\u5171 {total} \u5B57\u7B26",
|
|
16384
|
-
noBook: "\u8BF7\u5148\u5728\
|
|
16487
|
+
noBook: "\u8BF7\u5148\u5728\u63D2\u4EF6 \u2192 \u5C0F\u8BF4\u6478\u9C7C\u4E2D\u9009\u62E9\u4E00\u672C\u4E66\u3002",
|
|
16385
16488
|
switchHint: "\u8BF7\u6536\u8D77\u540E\u518D\u4E3B\u52A8\u5C55\u5F00\u6B64\u533A\u57DF\uFF0C\u4ECE\u5F53\u524D\u8FDB\u5EA6\u8BFB\u53D6\u3002",
|
|
16386
16489
|
loading: "\u6B63\u5728\u8BFB\u53D6\u2026",
|
|
16387
16490
|
readError: "\u5C0F\u8BF4\u672A\u80FD\u52A0\u8F7D\uFF0C\u9605\u8BFB\u8FDB\u5EA6\u672A\u6539\u53D8\u3002",
|
|
@@ -16401,16 +16504,25 @@ ${part}` : part;
|
|
|
16401
16504
|
typeReadFile: "\u6253\u5F00\u6587\u4EF6\uFF08read / read_image\uFF09",
|
|
16402
16505
|
typeCommand: "\u8FD0\u884C\u547D\u4EE4\uFF08bash / pwsh\uFF09",
|
|
16403
16506
|
typeFileSearch: "\u6587\u4EF6\u641C\u7D22\uFF08grep / glob\uFF09",
|
|
16404
|
-
selectedTypes: "\u5DF2\u9009\u62E9 {count} / {total} \u7C7B
|
|
16405
|
-
allTypes: "\u5168\u9009
|
|
16406
|
-
|
|
16507
|
+
selectedTypes: "\u5DF2\u9009\u62E9 {count} / {total} \u7C7B",
|
|
16508
|
+
allTypes: "\u5168\u9009",
|
|
16509
|
+
clearTypes: "\u53D6\u6D88\u5168\u9009",
|
|
16510
|
+
typeHint: "\u9996\u6B21\u4E3B\u52A8\u5C55\u5F00\u53E6\u4E00\u4E2A\u533A\u57DF\u624D\u7EED\u8BFB\uFF1B\u7A7A\u9009\u65F6\u4E0D\u8BFB\u53D6\u3002",
|
|
16511
|
+
continueOnReopen: "\u540C\u4E00\u533A\u57DF\u518D\u6B21\u5C55\u5F00\u7EED\u8BFB",
|
|
16512
|
+
continueOnReopenHint: "\u5F00\u542F\u540E\uFF0C\u6536\u8D77\u518D\u4E3B\u52A8\u5C55\u5F00\u540C\u4E00\u533A\u57DF\u4F1A\u63A5\u7740\u8BFB\u4E0B\u4E00\u6BB5\uFF1B\u5173\u95ED\u65F6\u91CD\u590D\u5C55\u5F00\u53EA\u663E\u793A\u8FD9\u4E00\u6BB5\u3002",
|
|
16513
|
+
books: "\u4E66\u7C4D",
|
|
16514
|
+
importBook: "\u5BFC\u5165\u4E66\u7C4D",
|
|
16515
|
+
reading: "\u804A\u5929\u5185\u9605\u8BFB",
|
|
16516
|
+
appearance: "\u6807\u9898\u663E\u793A",
|
|
16517
|
+
cancel: "\u53D6\u6D88",
|
|
16518
|
+
confirmDelete: "\u5220\u9664",
|
|
16407
16519
|
bookSource: "\u5BFC\u5165\u4E66\u7C4D\uFF08EPUB / TXT / MD\uFF09",
|
|
16408
16520
|
selectBook: "\u5F53\u524D\u4E66\u7C4D",
|
|
16409
16521
|
noBook: "\u8BF7\u9009\u62E9\u4E66\u7C4D",
|
|
16410
16522
|
deleteBook: "\u5220\u9664\u5F53\u524D\u4E66\u7C4D",
|
|
16411
|
-
progressValue: "\u5DF2\u8BFB {progress} / {total} \u6BB5\
|
|
16523
|
+
progressValue: "\u5DF2\u8BFB {progress} / {total} \u6BB5 \xB7 {percent}%",
|
|
16412
16524
|
emptyLibrary: "\u8BF7\u5BFC\u5165 EPUB\u3001TXT \u6216 MD \u6587\u4EF6\u5F00\u59CB\u9605\u8BFB\u3002",
|
|
16413
|
-
nativeControls: "\u56FE\u6807\
|
|
16525
|
+
nativeControls: "\u56FE\u6807\u4E0E\u6298\u53E0\u4EA4\u4E92\u8DDF\u968F DSH\u3002",
|
|
16414
16526
|
titleMain: "\u4E3B\u6807\u9898",
|
|
16415
16527
|
titleExtra: "\u8865\u5145\u6587\u5B57",
|
|
16416
16528
|
nativeTitle: "\u8DDF\u968F DSH \u7684\u539F\u751F\u533A\u57DF\u6807\u9898",
|
|
@@ -16439,7 +16551,7 @@ ${part}` : part;
|
|
|
16439
16551
|
stopped: "Stopped",
|
|
16440
16552
|
unknownBlock: "Unknown content block",
|
|
16441
16553
|
jsonTruncated: "\u2026 truncated, {total} characters",
|
|
16442
|
-
noBook: "Select a book under
|
|
16554
|
+
noBook: "Select a book under Plugins \u2192 Novel Fish first.",
|
|
16443
16555
|
switchHint: "Collapse and actively expand this region to read from the current progress.",
|
|
16444
16556
|
loading: "Loading\u2026",
|
|
16445
16557
|
readError: "The passage could not be loaded; progress did not change.",
|
|
@@ -16459,16 +16571,25 @@ ${part}` : part;
|
|
|
16459
16571
|
typeReadFile: "Open files (read / read_image)",
|
|
16460
16572
|
typeCommand: "Run commands (bash / pwsh)",
|
|
16461
16573
|
typeFileSearch: "File search (grep / glob)",
|
|
16462
|
-
selectedTypes: "{count} / {total} types selected
|
|
16463
|
-
allTypes: "Select
|
|
16464
|
-
|
|
16574
|
+
selectedTypes: "{count} / {total} types selected",
|
|
16575
|
+
allTypes: "Select all",
|
|
16576
|
+
clearTypes: "Deselect all",
|
|
16577
|
+
typeHint: "A different region\u2019s first active expansion continues reading. Select none to stop reading.",
|
|
16578
|
+
continueOnReopen: "Continue in the same region",
|
|
16579
|
+
continueOnReopenHint: "When on, collapsing and actively reopening the same region reads the next passage; when off, reopening only shows the passage already there.",
|
|
16580
|
+
books: "Books",
|
|
16581
|
+
importBook: "Import book",
|
|
16582
|
+
reading: "Reading in chat",
|
|
16583
|
+
appearance: "Titles",
|
|
16584
|
+
cancel: "Cancel",
|
|
16585
|
+
confirmDelete: "Delete",
|
|
16465
16586
|
bookSource: "Import a book (EPUB / TXT / MD)",
|
|
16466
16587
|
selectBook: "Current book",
|
|
16467
16588
|
noBook: "Select a book",
|
|
16468
16589
|
deleteBook: "Delete current book",
|
|
16469
|
-
progressValue: "Read {progress} / {total} passages
|
|
16590
|
+
progressValue: "Read {progress} / {total} passages \xB7 {percent}%",
|
|
16470
16591
|
emptyLibrary: "Import an EPUB, TXT, or MD file to begin.",
|
|
16471
|
-
nativeControls: "Icons
|
|
16592
|
+
nativeControls: "Icons and disclosure interactions follow DSH.",
|
|
16472
16593
|
titleMain: "Main title",
|
|
16473
16594
|
titleExtra: "Additional text",
|
|
16474
16595
|
nativeTitle: "Follow the native DSH region title",
|
|
@@ -16497,12 +16618,13 @@ ${part}` : part;
|
|
|
16497
16618
|
id: MODULE_ID,
|
|
16498
16619
|
factory(require2) {
|
|
16499
16620
|
const React = require2("react");
|
|
16621
|
+
const primitives = require2("@deepseek-ai/dsh-client-ui-primitives");
|
|
16500
16622
|
return {
|
|
16501
16623
|
inject: ["slots", "locale"],
|
|
16502
16624
|
apply(ctx) {
|
|
16503
16625
|
const storage = new IndexedDbStorage();
|
|
16504
16626
|
const store = new NovelStore(storage);
|
|
16505
|
-
const SettingsRow = createSettingsRow(React);
|
|
16627
|
+
const SettingsRow = createSettingsRow(React, primitives);
|
|
16506
16628
|
const settingsActions = {
|
|
16507
16629
|
onSetOption: (key, value) => store.setOption(key, value),
|
|
16508
16630
|
onSetNotice: (notice) => store.setNotice(notice),
|
|
@@ -16512,10 +16634,9 @@ ${part}` : part;
|
|
|
16512
16634
|
};
|
|
16513
16635
|
ctx.effect(() => ctx.locale.register(LOCALE, { zh: flatten(zh_default), en: flatten(en_default) }), "novel-fish: locale");
|
|
16514
16636
|
ctx.effect(() => () => store.dispose(), "novel-fish: store");
|
|
16515
|
-
ctx.slots.inject("
|
|
16516
|
-
name: "
|
|
16517
|
-
|
|
16518
|
-
order: 24,
|
|
16637
|
+
ctx.slots.inject("plugins.bundle.config", () => ctx.slots.register({
|
|
16638
|
+
name: "plugins.bundle.config",
|
|
16639
|
+
key: MODULE_ID,
|
|
16519
16640
|
locale: LOCALE,
|
|
16520
16641
|
inject: () => ({
|
|
16521
16642
|
hooks: {
|