@jayyuen66/dsh-dir-prep-organize 0.1.0 → 0.1.1

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/client.js CHANGED
@@ -6,10 +6,9 @@ window.__ModuleLoader__.load({
6
6
  var exports = module.exports;
7
7
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
8
8
  let react = require("react");
9
- //#region node_modules/.pnpm/@jayyuen66+dsh-plugin-shared@0.1.0_@deepseek-ai+cordis@4.0.4_eslint-plugin-sonarjs@4.2._a5b0027b68963132c312048d042510c0/node_modules/@jayyuen66/dsh-plugin-shared/dist/record.js
10
- /** 对象类型守卫:非 `null` 的 `object` 且非数组(`Record` 索引签名投影的基础)。 */
11
- function isRecord(value) {
12
- return typeof value === "object" && value !== null && !Array.isArray(value);
9
+ //#region node_modules/.pnpm/@jayyuen66+dsh-plugin-shared@0.1.2_e1d13a9111f1b3b932c939974ed50e75/node_modules/@jayyuen66/dsh-plugin-shared/dist/record.js
10
+ function e$1(e) {
11
+ return typeof e == `object` && !!e && !Array.isArray(e);
13
12
  }
14
13
  //#endregion
15
14
  //#region src/templates.ts
@@ -64,7 +63,7 @@ function uniqueEntryId(candidate, index, seen) {
64
63
  * 返回 undefined 表示该条应被剔除。 */
65
64
  function normalizeEntry(item, index, seen) {
66
65
  let result;
67
- if (isRecord(item)) {
66
+ if (e$1(item)) {
68
67
  const { id, name, description, text, group, emoji } = item;
69
68
  const nextName = trimField(name);
70
69
  const nextText = trimField(text);
@@ -279,10 +278,32 @@ const UI_MESSAGES = {
279
278
  }
280
279
  };
281
280
  //#endregion
282
- //#region node_modules/.pnpm/@jayyuen66+dsh-plugin-shared@0.1.0_@deepseek-ai+cordis@4.0.4_eslint-plugin-sonarjs@4.2._a5b0027b68963132c312048d042510c0/node_modules/@jayyuen66/dsh-plugin-shared/dist/errors.js
283
- /** `Error` 取 `message`,其余一律 `String(error)`(`null` → `"null"`,对象 → 其 `toString()`)。 */
284
- function errorText(error) {
285
- return error instanceof Error ? error.message : String(error);
281
+ //#region node_modules/.pnpm/@jayyuen66+dsh-plugin-shared@0.1.2_e1d13a9111f1b3b932c939974ed50e75/node_modules/@jayyuen66/dsh-plugin-shared/dist/errors.js
282
+ function e(e) {
283
+ let t = Object.getOwnPropertyDescriptor(e, `message`);
284
+ return t !== void 0 && `value` in t && typeof t.value == `string` ? t.value : void 0;
285
+ }
286
+ function t(n, r) {
287
+ if (r.has(n)) return `<circular cause>`;
288
+ r.add(n);
289
+ try {
290
+ if (!(n instanceof Error)) {
291
+ if (typeof n == `object` && n) {
292
+ let t = e(n);
293
+ if (t !== void 0) return t;
294
+ }
295
+ return String(n);
296
+ }
297
+ let i = n.message === `` ? n.name : n.message, a = n instanceof AggregateError && n.errors.length > 0 ? ` [${n.errors.map((e) => t(e, r)).join(`; `)}]` : ``, o = n.cause === void 0 || n.cause === null ? `` : t(n.cause, r);
298
+ return `${i}${a}${o === `` || o === i ? `` : `: ${o}`}`;
299
+ } catch {
300
+ return `<unrenderable value>`;
301
+ } finally {
302
+ r.delete(n);
303
+ }
304
+ }
305
+ function n(e) {
306
+ return t(e, /* @__PURE__ */ new Set());
286
307
  }
287
308
  //#endregion
288
309
  //#region src/client-entry.ts
@@ -361,7 +382,7 @@ const CLASS_ROW_HEAD = "dpic-rowhead";
361
382
  const CLASS_IMPORT_PATH = "dpic-importpath";
362
383
  const SLOT_INPUT_RIGHT = "conversation.input.right";
363
384
  function parseDirEntry(raw) {
364
- const { name, isDir, sizeBytes, snippet } = isRecord(raw) ? raw : {};
385
+ const { name, isDir, sizeBytes, snippet } = e$1(raw) ? raw : {};
365
386
  return {
366
387
  name: typeof name === "string" ? name : "",
367
388
  isDir: isDir === true,
@@ -370,7 +391,7 @@ function parseDirEntry(raw) {
370
391
  };
371
392
  }
372
393
  function parseContextResponse(raw) {
373
- const { ok, error, csrf, cwd, truncated, entries } = isRecord(raw) ? raw : {};
394
+ const { ok, error, csrf, cwd, truncated, entries } = e$1(raw) ? raw : {};
374
395
  const parsedEntries = Array.isArray(entries) ? entries.map((entry) => parseDirEntry(entry)) : void 0;
375
396
  return {
376
397
  ok: ok === true,
@@ -382,7 +403,7 @@ function parseContextResponse(raw) {
382
403
  };
383
404
  }
384
405
  function parseModelResponse(raw) {
385
- const { ok, error, csrf, provider, model, reasoningEffort } = isRecord(raw) ? raw : {};
406
+ const { ok, error, csrf, provider, model, reasoningEffort } = e$1(raw) ? raw : {};
386
407
  return {
387
408
  ok: ok === true,
388
409
  ...typeof error === "string" ? { error } : {},
@@ -393,7 +414,7 @@ function parseModelResponse(raw) {
393
414
  };
394
415
  }
395
416
  function parseOrganizeResponse(raw) {
396
- const { ok, error, content } = isRecord(raw) ? raw : {};
417
+ const { ok, error, content } = e$1(raw) ? raw : {};
397
418
  return {
398
419
  ok: ok === true,
399
420
  ...typeof error === "string" ? { error } : {},
@@ -422,14 +443,14 @@ function formatImportSkips(t, skips) {
422
443
  return parts.length === 0 ? "" : t("skipSummary", { list: parts.join(t("skipSeparator")) });
423
444
  }
424
445
  function parseImportResponse(raw) {
425
- const { ok, error, count, truncated, skipped, entries } = isRecord(raw) ? raw : {};
446
+ const { ok, error, count, truncated, skipped, entries } = e$1(raw) ? raw : {};
426
447
  const parsedEntries = Array.isArray(entries) ? sanitizeTemplateList(entries) : void 0;
427
448
  return {
428
449
  ok: ok === true,
429
450
  ...typeof error === "string" ? { error } : {},
430
451
  ...typeof count === "number" ? { count } : {},
431
452
  ...truncated === true ? { truncated: true } : {},
432
- ...isRecord(skipped) ? { skipped: parseImportSkips(skipped) } : {},
453
+ ...e$1(skipped) ? { skipped: parseImportSkips(skipped) } : {},
433
454
  ...parsedEntries === void 0 ? {} : { entries: parsedEntries }
434
455
  };
435
456
  }
@@ -452,7 +473,7 @@ function formatContextSummary(resp) {
452
473
  async function httpErrorMessage(response) {
453
474
  const fallback = `HTTP ${String(response.status)}`;
454
475
  const body = await response.json().catch(() => null);
455
- const { error } = isRecord(body) ? body : {};
476
+ const { error } = e$1(body) ? body : {};
456
477
  return typeof error === "string" && error.length > 0 ? error : fallback;
457
478
  }
458
479
  async function fetchJson(url, init, timeoutMs = FETCH_TIMEOUT_MS) {
@@ -472,7 +493,7 @@ async function fetchJson(url, init, timeoutMs = FETCH_TIMEOUT_MS) {
472
493
  return await response.json();
473
494
  } catch (error) {
474
495
  if (error instanceof Error && error.name === "AbortError") throw new Error("请求超时", { cause: error });
475
- throw new Error(errorText(error), { cause: error });
496
+ throw new Error(n(error), { cause: error });
476
497
  } finally {
477
498
  clearTimeout(timer);
478
499
  }
@@ -507,7 +528,7 @@ async function loadBuiltinTemplates() {
507
528
  let settled;
508
529
  try {
509
530
  const body = await fetchJson(BUILTIN_TEMPLATES_URL);
510
- const payload = isRecord(body) ? body : void 0;
531
+ const payload = e$1(body) ? body : void 0;
511
532
  const okKey = "ok";
512
533
  const templatesKey = "templates";
513
534
  const rawReason = payload?.["error"];
@@ -524,7 +545,7 @@ async function loadBuiltinTemplates() {
524
545
  settled = {
525
546
  phase: "error",
526
547
  list: [],
527
- error: errorText(error)
548
+ error: n(error)
528
549
  };
529
550
  } finally {
530
551
  builtinInflight = null;
@@ -801,7 +822,7 @@ async function runOrganizeClick(args) {
801
822
  writeDraft(content);
802
823
  } catch (error) {
803
824
  if (seq.current !== mySeq) return;
804
- setFailed(errorText(error));
825
+ setFailed(n(error));
805
826
  if (flashTimer.current !== null) clearTimeout(flashTimer.current);
806
827
  flashTimer.current = setTimeout(() => {
807
828
  setFailed(void 0);
@@ -1202,7 +1223,7 @@ function ImportPanel(props) {
1202
1223
  skips: skipNote
1203
1224
  }));
1204
1225
  } catch (error) {
1205
- setImportError(errorText(error));
1226
+ setImportError(n(error));
1206
1227
  } finally {
1207
1228
  setImportBusy(false);
1208
1229
  }
@@ -1429,7 +1450,7 @@ function createPersistActions(args) {
1429
1450
  const { t, editable, dirty, rootsDirty, anythingDirty, confirmReset, templates, allowRoots, draft, rootsDraft, set, unset, readBack, setDraft, setDraftFor, setRootsDraft, setBusy, setSaveError, setConfirmReset } = args;
1430
1451
  function reportError(err) {
1431
1452
  console.error("[dir-prep-organize] templates settings write failed:", err);
1432
- setSaveError(errorText(err));
1453
+ setSaveError(n(err));
1433
1454
  }
1434
1455
  async function onSave() {
1435
1456
  if (!editable || !anythingDirty) return;