@cccarv82/freya 1.0.32 → 1.0.34
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/cli/web-ui.js +1 -3
- package/cli/web.js +34 -16
- package/package.json +1 -1
package/cli/web-ui.js
CHANGED
|
@@ -578,9 +578,7 @@
|
|
|
578
578
|
try {
|
|
579
579
|
setPill('run', 'exporting…');
|
|
580
580
|
const r = await api('/api/obsidian/export', { dir: dirOrDefault() });
|
|
581
|
-
setOut('## Obsidian export
|
|
582
|
-
|
|
583
|
-
' + (r.output || 'ok'));
|
|
581
|
+
setOut('## Obsidian export\n\n' + (r.output || 'ok'));
|
|
584
582
|
setPill('ok', 'exported');
|
|
585
583
|
setTimeout(() => setPill('ok', 'idle'), 800);
|
|
586
584
|
} catch (e) {
|
package/cli/web.js
CHANGED
|
@@ -277,6 +277,38 @@ function postTeamsCard(url, card) {
|
|
|
277
277
|
return postJson(url, card);
|
|
278
278
|
}
|
|
279
279
|
|
|
280
|
+
function extractFirstJsonObject(text) {
|
|
281
|
+
const t = String(text || '');
|
|
282
|
+
const start = t.indexOf('{');
|
|
283
|
+
if (start === -1) return null;
|
|
284
|
+
|
|
285
|
+
let depth = 0;
|
|
286
|
+
let inString = false;
|
|
287
|
+
let esc = false;
|
|
288
|
+
|
|
289
|
+
for (let i = start; i < t.length; i++) {
|
|
290
|
+
const ch = t[i];
|
|
291
|
+
|
|
292
|
+
if (esc) { esc = false; continue; }
|
|
293
|
+
if (ch === '\\') { esc = true; continue; }
|
|
294
|
+
|
|
295
|
+
if (ch === '"') {
|
|
296
|
+
inString = !inString;
|
|
297
|
+
continue;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
if (inString) continue;
|
|
301
|
+
|
|
302
|
+
if (ch === '{') depth++;
|
|
303
|
+
if (ch === '}') {
|
|
304
|
+
depth--;
|
|
305
|
+
if (depth === 0) return t.slice(start, i + 1);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
return null;
|
|
310
|
+
}
|
|
311
|
+
|
|
280
312
|
function escapeJsonControlChars(jsonText) {
|
|
281
313
|
// Replace unescaped control chars inside JSON string literals with safe escapes.
|
|
282
314
|
// Handles Copilot outputs where newlines/tabs leak into string values.
|
|
@@ -1206,14 +1238,7 @@ async function cmdWeb({ port, dir, open, dev }) {
|
|
|
1206
1238
|
const planRaw = String(payload.plan || '').trim();
|
|
1207
1239
|
if (!planRaw) return safeJson(res, 400, { error: 'Missing plan' });
|
|
1208
1240
|
|
|
1209
|
-
|
|
1210
|
-
const start = text.indexOf('{');
|
|
1211
|
-
const end = text.lastIndexOf('}');
|
|
1212
|
-
if (start === -1 || end === -1 || end <= start) return null;
|
|
1213
|
-
return text.slice(start, end + 1);
|
|
1214
|
-
}
|
|
1215
|
-
|
|
1216
|
-
const jsonText = extractJson(planRaw) || planRaw;
|
|
1241
|
+
const jsonText = extractFirstJsonObject(planRaw) || planRaw;
|
|
1217
1242
|
let plan;
|
|
1218
1243
|
try {
|
|
1219
1244
|
plan = JSON.parse(jsonText);
|
|
@@ -1298,14 +1323,7 @@ async function cmdWeb({ port, dir, open, dev }) {
|
|
|
1298
1323
|
const planRaw = String(payload.plan || '').trim();
|
|
1299
1324
|
if (!planRaw) return safeJson(res, 400, { error: 'Missing plan' });
|
|
1300
1325
|
|
|
1301
|
-
|
|
1302
|
-
const start = text.indexOf('{');
|
|
1303
|
-
const end = text.lastIndexOf('}');
|
|
1304
|
-
if (start === -1 || end === -1 || end <= start) return null;
|
|
1305
|
-
return text.slice(start, end + 1);
|
|
1306
|
-
}
|
|
1307
|
-
|
|
1308
|
-
const jsonText = extractJson(planRaw) || planRaw;
|
|
1326
|
+
const jsonText = extractFirstJsonObject(planRaw) || planRaw;
|
|
1309
1327
|
|
|
1310
1328
|
function errorSnippet(text, pos) {
|
|
1311
1329
|
const p = Number.isFinite(pos) ? pos : 0;
|