sapper-iq 1.4.9 → 1.4.10
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/package.json +1 -1
- package/sapper-ui.mjs +17 -1
package/package.json
CHANGED
package/sapper-ui.mjs
CHANGED
|
@@ -3437,7 +3437,23 @@ const server = http.createServer(async (req, res) => {
|
|
|
3437
3437
|
const body = await readReqJSON(req);
|
|
3438
3438
|
try {
|
|
3439
3439
|
ensureDir(SAPPER_DIR);
|
|
3440
|
-
|
|
3440
|
+
// Deep-merge incoming over existing on-disk config so that fields the
|
|
3441
|
+
// Web UI doesn't know about (e.g. deepthink, consultant.verbose) are
|
|
3442
|
+
// preserved instead of being silently wiped by a stale textarea save.
|
|
3443
|
+
const existing = readJSON(CONFIG_FILE, {}) || {};
|
|
3444
|
+
const incoming = body.config || {};
|
|
3445
|
+
const isPlainObj = (v) => v && typeof v === 'object' && !Array.isArray(v);
|
|
3446
|
+
const deepMerge = (base, over) => {
|
|
3447
|
+
if (!isPlainObj(base)) return over;
|
|
3448
|
+
if (!isPlainObj(over)) return over;
|
|
3449
|
+
const out = { ...base };
|
|
3450
|
+
for (const k of Object.keys(over)) {
|
|
3451
|
+
out[k] = isPlainObj(base[k]) && isPlainObj(over[k]) ? deepMerge(base[k], over[k]) : over[k];
|
|
3452
|
+
}
|
|
3453
|
+
return out;
|
|
3454
|
+
};
|
|
3455
|
+
const merged = deepMerge(existing, incoming);
|
|
3456
|
+
fs.writeFileSync(CONFIG_FILE, JSON.stringify(merged, null, 2));
|
|
3441
3457
|
return json(res, { ok: true });
|
|
3442
3458
|
} catch (e) { return json(res, { error: e.message }, 500); }
|
|
3443
3459
|
}
|