@aiti-ai/aiti-msg-share 0.1.0 → 0.1.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/README.md +33 -0
- package/client/src/index.js +474 -24
- package/dist/aiti-msg-share-client.mjs +679 -25
- package/index.ts +190 -28
- package/lib/provider-icons.mjs +63 -0
- package/lib/share-core.mjs +28 -0
- package/package.json +3 -3
- package/test/provider-icons.test.mjs +47 -0
- package/test/share-core.test.mjs +25 -0
|
@@ -2111,6 +2111,29 @@ var tFn = null;
|
|
|
2111
2111
|
function kindLabel(k) {
|
|
2112
2112
|
return shareT("share.kind." + k);
|
|
2113
2113
|
}
|
|
2114
|
+
var IMG_EXT = /\.(png|jpe?g|gif|webp|bmp|svg|ico|avif)$/i;
|
|
2115
|
+
var BIN_EXT = /\.(pdf|zip|7z|rar|gz|tgz|tar|bz2|xz|mp3|wav|ogg|flac|mp4|mkv|webm|mov|avi|docx|doc|xlsx|xls|pptx|epub|bin|exe|dmg|iso|apk|psd|woff2?|ttf)$/i;
|
|
2116
|
+
function contentKind() {
|
|
2117
|
+
if (state.kind === "image") return "image";
|
|
2118
|
+
if (state.kind === "file" && state.payload?.filePath) {
|
|
2119
|
+
const f = state.payload.filePath;
|
|
2120
|
+
if (IMG_EXT.test(f)) return "image";
|
|
2121
|
+
if (BIN_EXT.test(f)) return "file";
|
|
2122
|
+
}
|
|
2123
|
+
return "text";
|
|
2124
|
+
}
|
|
2125
|
+
function supportsKind(t, kind) {
|
|
2126
|
+
return !(t.kinds || []).length || (t.kinds || []).includes(kind);
|
|
2127
|
+
}
|
|
2128
|
+
function deriveTitleLocal(text) {
|
|
2129
|
+
for (const raw of String(text || "").split("\n")) {
|
|
2130
|
+
const line = raw.trim();
|
|
2131
|
+
if (!line || /^>\s*\*\*[^*]+\*\*\s*:/.test(line)) continue;
|
|
2132
|
+
const stripped = line.replace(/^#{1,6}\s+/, "").replace(/[*_`]+/g, "").trim();
|
|
2133
|
+
if (stripped) return stripped.length > 80 ? stripped.slice(0, 80).trim() : stripped;
|
|
2134
|
+
}
|
|
2135
|
+
return "";
|
|
2136
|
+
}
|
|
2114
2137
|
function shareT(key, params) {
|
|
2115
2138
|
if (!tFn) return key;
|
|
2116
2139
|
try {
|
|
@@ -2138,7 +2161,7 @@ var state = {
|
|
|
2138
2161
|
title: "",
|
|
2139
2162
|
tags: "",
|
|
2140
2163
|
// Which page-context fields get prepended to the shared content (multi-select).
|
|
2141
|
-
stamp: { os: true, browser: true, url:
|
|
2164
|
+
stamp: { os: true, browser: true, url: false, sessionId: true, sessionName: true },
|
|
2142
2165
|
targetId: null,
|
|
2143
2166
|
meta: {},
|
|
2144
2167
|
redact: true,
|
|
@@ -2153,9 +2176,35 @@ var state = {
|
|
|
2153
2176
|
search: "",
|
|
2154
2177
|
probe: [],
|
|
2155
2178
|
editing: null,
|
|
2156
|
-
form: {}
|
|
2179
|
+
form: {},
|
|
2180
|
+
/** Container picker (notebook/folder selection): per-target cache + pending pick.
|
|
2181
|
+
* containersByTarget[id] = { containers: [{id,label,parent,path}], label } */
|
|
2182
|
+
containersByTarget: {},
|
|
2183
|
+
containerFor: "",
|
|
2184
|
+
containerOpen: false,
|
|
2185
|
+
containerFilter: "",
|
|
2186
|
+
containerExpanded: {},
|
|
2187
|
+
containersLoading: false,
|
|
2188
|
+
containerError: "",
|
|
2189
|
+
/** Keyboard navigation index over the currently visible picker rows (-1 = none). */
|
|
2190
|
+
kbIndex: -1,
|
|
2191
|
+
/** Local favourite sinks (share-sink topic): { ok, message, action } of the last run. */
|
|
2192
|
+
sinkResult: null,
|
|
2193
|
+
sinkBusy: ""
|
|
2157
2194
|
};
|
|
2158
2195
|
var listeners = /* @__PURE__ */ new Set();
|
|
2196
|
+
function locale() {
|
|
2197
|
+
try {
|
|
2198
|
+
return typeof window !== "undefined" && String(window.__PI_LOCALE__ || "").startsWith("zh") ? "zh" : "en";
|
|
2199
|
+
} catch {
|
|
2200
|
+
return "en";
|
|
2201
|
+
}
|
|
2202
|
+
}
|
|
2203
|
+
function noteText(note) {
|
|
2204
|
+
if (!note) return "";
|
|
2205
|
+
if (typeof note === "object") return String(note[locale()] || note.zh || note.en || "").trim();
|
|
2206
|
+
return String(note);
|
|
2207
|
+
}
|
|
2159
2208
|
function api(path) {
|
|
2160
2209
|
return apiUrlFn ? apiUrlFn(`/api/extensions/aiti-msg-share/${path}`) : API(path);
|
|
2161
2210
|
}
|
|
@@ -2206,17 +2255,89 @@ function set(partial) {
|
|
|
2206
2255
|
}
|
|
2207
2256
|
function chooseTarget(id) {
|
|
2208
2257
|
recentAdd(id);
|
|
2209
|
-
set({ targetId: id, manager: false, editing: null, error: "", errorDetail: "" });
|
|
2258
|
+
set({ targetId: id, manager: false, editing: null, error: "", errorDetail: "", containerOpen: false, containerFilter: "" });
|
|
2259
|
+
syncContainerFor(id);
|
|
2260
|
+
void ensureContainers(id);
|
|
2210
2261
|
}
|
|
2211
2262
|
function emit() {
|
|
2212
2263
|
listeners.forEach((fn) => fn());
|
|
2213
2264
|
}
|
|
2265
|
+
function syncContainerFor(id) {
|
|
2266
|
+
const t = state.targets.find((x) => x.id === id);
|
|
2267
|
+
set({ containerFor: t?.lastContainer || "" });
|
|
2268
|
+
}
|
|
2269
|
+
async function ensureContainers(targetId, force = false) {
|
|
2270
|
+
const t = state.targets.find((x) => x.id === targetId);
|
|
2271
|
+
if (!t || !t.supportsContainers) return;
|
|
2272
|
+
if (state.containersByTarget[targetId] && !force) return;
|
|
2273
|
+
set({ containersLoading: true, containerError: "" });
|
|
2274
|
+
try {
|
|
2275
|
+
const r = await getJSON("containers", {
|
|
2276
|
+
method: "POST",
|
|
2277
|
+
headers: { "content-type": "application/json" },
|
|
2278
|
+
body: JSON.stringify({ targetId })
|
|
2279
|
+
});
|
|
2280
|
+
set({
|
|
2281
|
+
containersLoading: false,
|
|
2282
|
+
containersByTarget: {
|
|
2283
|
+
...state.containersByTarget,
|
|
2284
|
+
[targetId]: { containers: r.containers || [], label: r.containerLabel || null }
|
|
2285
|
+
}
|
|
2286
|
+
});
|
|
2287
|
+
} catch (e) {
|
|
2288
|
+
set({ containersLoading: false, containerError: e.message });
|
|
2289
|
+
}
|
|
2290
|
+
}
|
|
2291
|
+
function toggleContainerPanel() {
|
|
2292
|
+
if (state.containerOpen) {
|
|
2293
|
+
set({ containerOpen: false, containerFilter: "" });
|
|
2294
|
+
return;
|
|
2295
|
+
}
|
|
2296
|
+
const items = state.containersByTarget[state.targetId]?.containers || [];
|
|
2297
|
+
const expanded = {};
|
|
2298
|
+
for (const c of items) if (!c.parent) expanded[c.id] = true;
|
|
2299
|
+
const byId = new Map(items.map((c) => [c.id, c]));
|
|
2300
|
+
let cur = byId.get(state.containerFor);
|
|
2301
|
+
while (cur?.parent) {
|
|
2302
|
+
expanded[cur.parent] = true;
|
|
2303
|
+
cur = byId.get(cur.parent);
|
|
2304
|
+
}
|
|
2305
|
+
set({ containerOpen: true, containerFilter: "", containerExpanded: expanded, kbIndex: -1 });
|
|
2306
|
+
}
|
|
2307
|
+
function pickContainer(c) {
|
|
2308
|
+
const id = c ? c.id : "";
|
|
2309
|
+
const pathLabel = c ? c.path || c.label : "";
|
|
2310
|
+
set({ containerFor: id, containerOpen: false, containerFilter: "", kbIndex: -1 });
|
|
2311
|
+
void getJSON("targets/last-container", {
|
|
2312
|
+
method: "POST",
|
|
2313
|
+
headers: { "content-type": "application/json" },
|
|
2314
|
+
body: JSON.stringify({ id: state.targetId, container: id, label: pathLabel })
|
|
2315
|
+
}).then((r) => set({ targets: state.targets.map((x) => x.id === state.targetId && r?.target ? {
|
|
2316
|
+
...x,
|
|
2317
|
+
lastContainer: r.target.lastContainer,
|
|
2318
|
+
lastContainerLabel: r.target.lastContainerLabel,
|
|
2319
|
+
recentContainers: r.target.recentContainers
|
|
2320
|
+
} : x) })).catch(() => {
|
|
2321
|
+
});
|
|
2322
|
+
}
|
|
2323
|
+
function containerTree(items) {
|
|
2324
|
+
const ids = new Set(items.map((c) => c.id));
|
|
2325
|
+
const childrenOf = /* @__PURE__ */ new Map();
|
|
2326
|
+
for (const c of items) {
|
|
2327
|
+
const k = c.parent && ids.has(c.parent) ? c.parent : "";
|
|
2328
|
+
if (!childrenOf.has(k)) childrenOf.set(k, []);
|
|
2329
|
+
childrenOf.get(k).push(c);
|
|
2330
|
+
}
|
|
2331
|
+
for (const arr of childrenOf.values()) arr.sort((a, b) => String(a.label).localeCompare(String(b.label)));
|
|
2332
|
+
return childrenOf;
|
|
2333
|
+
}
|
|
2214
2334
|
var STATUS_ICONS = { recent: "\u{1F558}", recommended: "\u2605", dead: "\u26A0", legacy: "\u26A0" };
|
|
2215
2335
|
var CFG_BADGE = {
|
|
2216
2336
|
anonymous: { icon: "\u{1F7E2}", key: "share.cfg.anonymous", color: "var(--accent, #4d8dff)" },
|
|
2217
2337
|
ready: { icon: "\u2713", key: "share.cfg.ready", color: "var(--accent, #4d8dff)" },
|
|
2218
2338
|
"needs-setup": { icon: "\u{1F7E0}", key: "share.cfg.needs", color: "#d9a13c" },
|
|
2219
|
-
dead: { icon: "\u{1F480}", key: "share.cfg.dead", color: "var(--text-muted, #8b909b)" }
|
|
2339
|
+
dead: { icon: "\u{1F480}", key: "share.cfg.dead", color: "var(--text-muted, #8b909b)" },
|
|
2340
|
+
legacy: { icon: "\u26A0", key: "share.cfg.legacy", color: "#d9a13c" }
|
|
2220
2341
|
};
|
|
2221
2342
|
var ICONS = {
|
|
2222
2343
|
share: '<circle cx="18" cy="5" r="3"/><circle cx="6" cy="12" r="3"/><circle cx="18" cy="19" r="3"/><line x1="8.6" y1="10.5" x2="15.4" y2="6.5"/><line x1="8.6" y1="13.5" x2="15.4" y2="17.5"/>',
|
|
@@ -2261,6 +2382,7 @@ function btn(label, onClick, opts = {}) {
|
|
|
2261
2382
|
function openShare(payload = {}) {
|
|
2262
2383
|
const kind = payload.kind || "message";
|
|
2263
2384
|
const raw = payload.text || "";
|
|
2385
|
+
primeSinks();
|
|
2264
2386
|
set({
|
|
2265
2387
|
open: true,
|
|
2266
2388
|
manager: false,
|
|
@@ -2269,7 +2391,7 @@ function openShare(payload = {}) {
|
|
|
2269
2391
|
text: raw,
|
|
2270
2392
|
rawText: raw,
|
|
2271
2393
|
baseText: raw,
|
|
2272
|
-
title: payload.title ||
|
|
2394
|
+
title: payload.title || deriveTitleLocal(raw),
|
|
2273
2395
|
tags: payload.tags || "",
|
|
2274
2396
|
targetId: payload.targetId || null,
|
|
2275
2397
|
result: null,
|
|
@@ -2279,7 +2401,9 @@ function openShare(payload = {}) {
|
|
|
2279
2401
|
errorTarget: "",
|
|
2280
2402
|
errorProvider: "",
|
|
2281
2403
|
redact: true,
|
|
2282
|
-
redactHits: []
|
|
2404
|
+
redactHits: [],
|
|
2405
|
+
sinkResult: null,
|
|
2406
|
+
sinkBusy: ""
|
|
2283
2407
|
});
|
|
2284
2408
|
void refresh();
|
|
2285
2409
|
void refreshPreview();
|
|
@@ -2301,6 +2425,8 @@ async function refresh(force = false) {
|
|
|
2301
2425
|
loading: false,
|
|
2302
2426
|
targetId: state.targetId || targets.find((t) => t.recommended)?.id || targets[0]?.id
|
|
2303
2427
|
});
|
|
2428
|
+
syncContainerFor(state.targetId);
|
|
2429
|
+
void ensureContainers(state.targetId);
|
|
2304
2430
|
if (force) await getJSON("refresh", { method: "POST" }).catch(() => {
|
|
2305
2431
|
});
|
|
2306
2432
|
} catch (e) {
|
|
@@ -2308,15 +2434,19 @@ async function refresh(force = false) {
|
|
|
2308
2434
|
}
|
|
2309
2435
|
}
|
|
2310
2436
|
function targetCard(target, selected, badge) {
|
|
2311
|
-
const disabled = target.status === "dead" || target.enabled === false;
|
|
2437
|
+
const disabled = target.status === "dead" || target.status === "legacy" || target.enabled === false;
|
|
2312
2438
|
return h(
|
|
2313
2439
|
"button",
|
|
2314
2440
|
{
|
|
2315
2441
|
type: "button",
|
|
2316
2442
|
key: target.id,
|
|
2317
2443
|
disabled,
|
|
2318
|
-
onClick: () =>
|
|
2319
|
-
|
|
2444
|
+
onClick: () => {
|
|
2445
|
+
set({ targetId: target.id, error: "", containerOpen: false, containerFilter: "" });
|
|
2446
|
+
syncContainerFor(target.id);
|
|
2447
|
+
void ensureContainers(target.id);
|
|
2448
|
+
},
|
|
2449
|
+
title: noteText(target.note) || target.name,
|
|
2320
2450
|
style: {
|
|
2321
2451
|
display: "inline-flex",
|
|
2322
2452
|
alignItems: "center",
|
|
@@ -2331,7 +2461,8 @@ function targetCard(target, selected, badge) {
|
|
|
2331
2461
|
opacity: disabled ? 0.45 : 1
|
|
2332
2462
|
}
|
|
2333
2463
|
},
|
|
2334
|
-
h("span", null, STATUS_ICONS[badge] || "\u{1F517}"),
|
|
2464
|
+
h("span", null, target.icon || STATUS_ICONS[badge] || "\u{1F517}"),
|
|
2465
|
+
...target.icon && STATUS_ICONS[badge] ? [h("span", { style: { fontSize: 10, color: "var(--text-muted, #8b909b)" } }, STATUS_ICONS[badge])] : [],
|
|
2335
2466
|
target.name || target.id,
|
|
2336
2467
|
...target.kinds?.length ? [h(
|
|
2337
2468
|
"span",
|
|
@@ -2344,13 +2475,166 @@ function targetCard(target, selected, badge) {
|
|
|
2344
2475
|
})()
|
|
2345
2476
|
);
|
|
2346
2477
|
}
|
|
2478
|
+
var SINK_PRIME_EXTS = ["aiti-cmd", "aiti-prompts"];
|
|
2479
|
+
var sunkPrimed = false;
|
|
2480
|
+
function primeSinks() {
|
|
2481
|
+
if (sunkPrimed) return;
|
|
2482
|
+
sunkPrimed = true;
|
|
2483
|
+
const ensure = ctxRef?.ensureMaterialized;
|
|
2484
|
+
if (typeof ensure !== "function") return;
|
|
2485
|
+
for (const id of SINK_PRIME_EXTS) {
|
|
2486
|
+
try {
|
|
2487
|
+
Promise.resolve(ensure(id)).then(() => emit()).catch(() => {
|
|
2488
|
+
});
|
|
2489
|
+
} catch (e) {
|
|
2490
|
+
}
|
|
2491
|
+
}
|
|
2492
|
+
}
|
|
2493
|
+
function sinkItems() {
|
|
2494
|
+
const items = [];
|
|
2495
|
+
items.push({
|
|
2496
|
+
id: "copy",
|
|
2497
|
+
order: -1e3,
|
|
2498
|
+
builtin: true,
|
|
2499
|
+
get label() {
|
|
2500
|
+
return shareT("share.sink.copy");
|
|
2501
|
+
},
|
|
2502
|
+
icon: { svg: '<rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/>' },
|
|
2503
|
+
run: async () => {
|
|
2504
|
+
try {
|
|
2505
|
+
await navigator.clipboard.writeText(state.text);
|
|
2506
|
+
return { ok: true, message: shareT("share.sink.copied") };
|
|
2507
|
+
} catch (e) {
|
|
2508
|
+
return { ok: false, message: String(e && e.message || e) };
|
|
2509
|
+
}
|
|
2510
|
+
}
|
|
2511
|
+
});
|
|
2512
|
+
try {
|
|
2513
|
+
for (const it of ctxRef?.getTopicItems?.("share-sink") || []) if (it && it.id) items.push(it);
|
|
2514
|
+
} catch (e) {
|
|
2515
|
+
}
|
|
2516
|
+
return items.sort((a, b) => (Number(a.order) || 100) - (Number(b.order) || 100));
|
|
2517
|
+
}
|
|
2518
|
+
function stripStamp(text) {
|
|
2519
|
+
const lines = String(text || "").split("\n");
|
|
2520
|
+
let i = 0;
|
|
2521
|
+
while (i < lines.length && /^>\s*\*\*[^*]+\*\*\s*:/.test(lines[i])) i++;
|
|
2522
|
+
return lines.slice(i).join("\n").trim();
|
|
2523
|
+
}
|
|
2524
|
+
function sinkPayload() {
|
|
2525
|
+
const raw = typeof state.baseText === "string" && state.baseText.length ? state.baseText : state.text;
|
|
2526
|
+
return { ...state.payload || {}, kind: state.kind, text: stripStamp(raw), title: state.title, tags: state.tags };
|
|
2527
|
+
}
|
|
2528
|
+
async function runSink(item) {
|
|
2529
|
+
if (state.sinkBusy) return;
|
|
2530
|
+
const payload = sinkPayload();
|
|
2531
|
+
if (!item.builtin && typeof item.accepts === "function") {
|
|
2532
|
+
let ok = false;
|
|
2533
|
+
try {
|
|
2534
|
+
ok = !!item.accepts(payload);
|
|
2535
|
+
} catch (e) {
|
|
2536
|
+
ok = false;
|
|
2537
|
+
}
|
|
2538
|
+
if (!ok) {
|
|
2539
|
+
const empty = !String(payload.text || "").trim();
|
|
2540
|
+
set({ sinkResult: { ok: false, message: empty ? shareT("share.sink.empty") : shareT("share.sink.unsupported") } });
|
|
2541
|
+
return;
|
|
2542
|
+
}
|
|
2543
|
+
}
|
|
2544
|
+
set({ sinkBusy: item.id, sinkResult: null });
|
|
2545
|
+
try {
|
|
2546
|
+
const r = item.builtin ? await item.run(payload) : await item.save(payload);
|
|
2547
|
+
set({ sinkBusy: "", sinkResult: r || { ok: true } });
|
|
2548
|
+
} catch (e) {
|
|
2549
|
+
set({ sinkBusy: "", sinkResult: { ok: false, message: String(e && e.message || e) } });
|
|
2550
|
+
}
|
|
2551
|
+
}
|
|
2552
|
+
function sinkSection() {
|
|
2553
|
+
const items = sinkItems();
|
|
2554
|
+
if (!items.length) return null;
|
|
2555
|
+
const res = state.sinkResult;
|
|
2556
|
+
return h(
|
|
2557
|
+
"div",
|
|
2558
|
+
null,
|
|
2559
|
+
h("div", { style: { color: "var(--text-muted, #8b909b)", fontSize: 11, marginBottom: 5 } }, shareT("share.sinks")),
|
|
2560
|
+
h(
|
|
2561
|
+
"div",
|
|
2562
|
+
{ style: { display: "flex", flexWrap: "wrap", gap: 6 } },
|
|
2563
|
+
...items.map((it) => {
|
|
2564
|
+
const label = typeof it.label === "function" ? it.label() : it.label || it.id;
|
|
2565
|
+
const svg = it.icon && it.icon.svg;
|
|
2566
|
+
return h(
|
|
2567
|
+
"button",
|
|
2568
|
+
{
|
|
2569
|
+
type: "button",
|
|
2570
|
+
key: it.id,
|
|
2571
|
+
disabled: !!state.sinkBusy,
|
|
2572
|
+
onClick: () => {
|
|
2573
|
+
void runSink(it);
|
|
2574
|
+
},
|
|
2575
|
+
title: label,
|
|
2576
|
+
style: {
|
|
2577
|
+
display: "inline-flex",
|
|
2578
|
+
alignItems: "center",
|
|
2579
|
+
gap: 5,
|
|
2580
|
+
padding: "4px 9px",
|
|
2581
|
+
border: "1px solid var(--border, #34363c)",
|
|
2582
|
+
borderRadius: 8,
|
|
2583
|
+
background: "var(--bg-hover, #25272c)",
|
|
2584
|
+
color: "var(--text, #d8dade)",
|
|
2585
|
+
fontSize: 12,
|
|
2586
|
+
cursor: state.sinkBusy ? "default" : "pointer",
|
|
2587
|
+
opacity: state.sinkBusy && state.sinkBusy !== it.id ? 0.55 : 1
|
|
2588
|
+
}
|
|
2589
|
+
},
|
|
2590
|
+
svg ? h("span", { style: { display: "inline-flex" }, dangerouslySetInnerHTML: { __html: `<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">${svg}</svg>` } }) : null,
|
|
2591
|
+
label,
|
|
2592
|
+
state.sinkBusy === it.id ? h("span", { style: { fontSize: 10, opacity: 0.7 } }, "\u2026") : null
|
|
2593
|
+
);
|
|
2594
|
+
})
|
|
2595
|
+
),
|
|
2596
|
+
res ? h(
|
|
2597
|
+
"div",
|
|
2598
|
+
{ style: {
|
|
2599
|
+
marginTop: 6,
|
|
2600
|
+
fontSize: 11,
|
|
2601
|
+
display: "flex",
|
|
2602
|
+
alignItems: "center",
|
|
2603
|
+
gap: 8,
|
|
2604
|
+
color: res.ok ? "var(--ok, #4ade80)" : "#e05d5d",
|
|
2605
|
+
wordBreak: "break-word"
|
|
2606
|
+
} },
|
|
2607
|
+
h("span", null, (res.ok ? "\u2713 " : "\u26A0 ") + (res.message || (res.ok ? shareT("share.sink.saved") : ""))),
|
|
2608
|
+
res.ok && res.action && typeof res.action.run === "function" ? h("button", {
|
|
2609
|
+
type: "button",
|
|
2610
|
+
onClick: () => {
|
|
2611
|
+
try {
|
|
2612
|
+
res.action.run();
|
|
2613
|
+
} catch (e) {
|
|
2614
|
+
}
|
|
2615
|
+
},
|
|
2616
|
+
style: {
|
|
2617
|
+
border: "1px solid var(--accent, #4d8dff)",
|
|
2618
|
+
background: "none",
|
|
2619
|
+
color: "var(--accent, #4d8dff)",
|
|
2620
|
+
borderRadius: 6,
|
|
2621
|
+
padding: "1px 8px",
|
|
2622
|
+
fontSize: 11,
|
|
2623
|
+
cursor: "pointer"
|
|
2624
|
+
}
|
|
2625
|
+
}, res.action.label || "\u2192") : null
|
|
2626
|
+
) : null
|
|
2627
|
+
);
|
|
2628
|
+
}
|
|
2347
2629
|
function targetSection() {
|
|
2348
2630
|
const recent = recentGet();
|
|
2631
|
+
const kind = contentKind();
|
|
2632
|
+
const compat = (x) => supportsKind(x, kind) && x.status !== "dead" && x.status !== "legacy";
|
|
2349
2633
|
const t = state.targets;
|
|
2350
2634
|
const byId = new Map(t.map((x) => [x.id, x]));
|
|
2351
|
-
const recentItems = recent.map((id) => byId.get(id)).filter(Boolean).slice(0, 5);
|
|
2352
|
-
const mine = t.filter((x) => x.custom && !recent.includes(x.id));
|
|
2353
|
-
const recs = t.filter((x) => x.recommended && !recent.includes(x.id) && !x.custom).slice(0, 8);
|
|
2635
|
+
const recentItems = recent.map((id) => byId.get(id)).filter(Boolean).filter(compat).slice(0, 5);
|
|
2636
|
+
const mine = t.filter((x) => x.custom && !recent.includes(x.id) && compat(x));
|
|
2637
|
+
const recs = t.filter((x) => x.recommended && !recent.includes(x.id) && !x.custom && compat(x)).slice(0, 8);
|
|
2354
2638
|
const shown = [];
|
|
2355
2639
|
for (const item of recentItems) shown.push(targetCard(item, state.targetId === item.id, "recent"));
|
|
2356
2640
|
for (const item of mine) shown.push(targetCard(item, state.targetId === item.id, null));
|
|
@@ -2359,6 +2643,13 @@ function targetSection() {
|
|
|
2359
2643
|
if (sel && !recent.includes(sel.id) && !sel.custom && !sel.recommended) {
|
|
2360
2644
|
shown.unshift(targetCard(sel, true, null));
|
|
2361
2645
|
}
|
|
2646
|
+
if (!recentItems.length && !mine.length && !recs.length) {
|
|
2647
|
+
shown.push(h(
|
|
2648
|
+
"span",
|
|
2649
|
+
{ style: { color: "var(--text-muted, #8b909b)", fontSize: 11, padding: "4px 2px" } },
|
|
2650
|
+
shareT("share.noCompatible", { kind: kindLabel(kind) })
|
|
2651
|
+
));
|
|
2652
|
+
}
|
|
2362
2653
|
shown.push(h("button", {
|
|
2363
2654
|
type: "button",
|
|
2364
2655
|
onClick: () => set({ manager: true }),
|
|
@@ -2379,6 +2670,330 @@ function targetSection() {
|
|
|
2379
2670
|
h("div", { style: { display: "flex", flexWrap: "wrap", gap: 6 } }, ...shown)
|
|
2380
2671
|
);
|
|
2381
2672
|
}
|
|
2673
|
+
var panelVisible = [];
|
|
2674
|
+
function containerRow(c, depth, childCount, expanded, selected, highlighted, idx, kbActive) {
|
|
2675
|
+
const guides = [];
|
|
2676
|
+
for (let i = 0; i < depth; i++) guides.push(h("span", {
|
|
2677
|
+
key: "g" + i,
|
|
2678
|
+
style: { width: 14, textAlign: "center", flexShrink: 0, color: "var(--text-muted, #8b909b)", opacity: 0.45 }
|
|
2679
|
+
}, "\u2502"));
|
|
2680
|
+
return h(
|
|
2681
|
+
"div",
|
|
2682
|
+
{
|
|
2683
|
+
key: c.id,
|
|
2684
|
+
"data-kb": String(idx),
|
|
2685
|
+
onClick: () => pickContainer(c),
|
|
2686
|
+
title: c.path || c.label,
|
|
2687
|
+
style: {
|
|
2688
|
+
display: "flex",
|
|
2689
|
+
alignItems: "center",
|
|
2690
|
+
gap: 5,
|
|
2691
|
+
padding: "3px 6px",
|
|
2692
|
+
borderRadius: 6,
|
|
2693
|
+
cursor: "pointer",
|
|
2694
|
+
fontSize: 12,
|
|
2695
|
+
background: selected ? "rgba(77, 141, 255, 0.18)" : kbActive ? "var(--bg-hover, #25272c)" : "transparent",
|
|
2696
|
+
boxShadow: kbActive ? "inset 0 0 0 1px var(--accent, #4d8dff)" : void 0,
|
|
2697
|
+
color: "var(--text, #d8dade)"
|
|
2698
|
+
}
|
|
2699
|
+
},
|
|
2700
|
+
...guides,
|
|
2701
|
+
h("span", {
|
|
2702
|
+
onClick: (e) => {
|
|
2703
|
+
if (!childCount) return;
|
|
2704
|
+
e.stopPropagation();
|
|
2705
|
+
set({ containerExpanded: { ...state.containerExpanded, [c.id]: !expanded } });
|
|
2706
|
+
},
|
|
2707
|
+
style: {
|
|
2708
|
+
width: 14,
|
|
2709
|
+
textAlign: "center",
|
|
2710
|
+
flexShrink: 0,
|
|
2711
|
+
color: childCount ? "var(--text-muted, #8b909b)" : "transparent",
|
|
2712
|
+
cursor: childCount ? "pointer" : "default"
|
|
2713
|
+
}
|
|
2714
|
+
}, expanded ? "\u25BE" : "\u25B8"),
|
|
2715
|
+
h("span", { style: {
|
|
2716
|
+
flex: 1,
|
|
2717
|
+
minWidth: 0,
|
|
2718
|
+
whiteSpace: "nowrap",
|
|
2719
|
+
overflow: "hidden",
|
|
2720
|
+
textOverflow: "ellipsis",
|
|
2721
|
+
fontWeight: selected ? 600 : 400,
|
|
2722
|
+
color: highlighted && !selected ? "var(--accent, #4d8dff)" : void 0
|
|
2723
|
+
} }, c.label),
|
|
2724
|
+
selected ? h("span", { style: { color: "var(--accent, #4d8dff)", fontSize: 11, flexShrink: 0 } }, "\u2713") : null,
|
|
2725
|
+
childCount && !expanded ? h("span", { style: { color: "var(--text-muted, #8b909b)", fontSize: 10, flexShrink: 0 } }, childCount) : null
|
|
2726
|
+
);
|
|
2727
|
+
}
|
|
2728
|
+
function containerSearchState(items, query) {
|
|
2729
|
+
const q = query.toLowerCase();
|
|
2730
|
+
const match = /* @__PURE__ */ new Set();
|
|
2731
|
+
const ancestors = /* @__PURE__ */ new Set();
|
|
2732
|
+
const byId = new Map(items.map((c) => [c.id, c]));
|
|
2733
|
+
for (const c of items) {
|
|
2734
|
+
if (String(c.label).toLowerCase().includes(q)) {
|
|
2735
|
+
match.add(c.id);
|
|
2736
|
+
let cur = c;
|
|
2737
|
+
while (cur?.parent && byId.has(cur.parent)) {
|
|
2738
|
+
ancestors.add(cur.parent);
|
|
2739
|
+
cur = byId.get(cur.parent);
|
|
2740
|
+
}
|
|
2741
|
+
}
|
|
2742
|
+
}
|
|
2743
|
+
return { match, ancestors };
|
|
2744
|
+
}
|
|
2745
|
+
function renderContainerNodes(childrenOf, nodes, depth, search, flat) {
|
|
2746
|
+
const out = [];
|
|
2747
|
+
for (const c of nodes) {
|
|
2748
|
+
if (search && !search.match.has(c.id) && !search.ancestors.has(c.id)) continue;
|
|
2749
|
+
const kids = childrenOf.get(c.id) || [];
|
|
2750
|
+
const expanded = search ? search.ancestors.has(c.id) || kids.some((k) => search.match.has(k.id) || search.ancestors.has(k.id)) : !!state.containerExpanded[c.id];
|
|
2751
|
+
const idx = flat.length;
|
|
2752
|
+
flat.push(c);
|
|
2753
|
+
out.push(containerRow(
|
|
2754
|
+
c,
|
|
2755
|
+
depth,
|
|
2756
|
+
kids.length,
|
|
2757
|
+
expanded,
|
|
2758
|
+
state.containerFor === c.id,
|
|
2759
|
+
!!search && search.match.has(c.id),
|
|
2760
|
+
idx,
|
|
2761
|
+
state.kbIndex === idx
|
|
2762
|
+
));
|
|
2763
|
+
if (kids.length && expanded) out.push(...renderContainerNodes(childrenOf, kids, depth + 1, search, flat));
|
|
2764
|
+
}
|
|
2765
|
+
return out;
|
|
2766
|
+
}
|
|
2767
|
+
function containerQuickRow() {
|
|
2768
|
+
const t = state.targets.find((x) => x.id === state.targetId);
|
|
2769
|
+
const recents = (t?.recentContainers || []).filter((r) => r && r.id);
|
|
2770
|
+
if (recents.length < 2) return null;
|
|
2771
|
+
return h(
|
|
2772
|
+
"div",
|
|
2773
|
+
{ style: { display: "flex", flexWrap: "wrap", gap: 4, alignItems: "center", padding: "0 2px 4px" } },
|
|
2774
|
+
h("span", { style: { color: "var(--text-muted, #8b909b)", fontSize: 10, flexShrink: 0 } }, shareT("share.recent")),
|
|
2775
|
+
...recents.map((r) => {
|
|
2776
|
+
const sel = state.containerFor === r.id;
|
|
2777
|
+
return h("button", {
|
|
2778
|
+
type: "button",
|
|
2779
|
+
key: r.id,
|
|
2780
|
+
title: r.label,
|
|
2781
|
+
onClick: () => pickContainer({ id: r.id, label: r.label, path: r.label }),
|
|
2782
|
+
style: {
|
|
2783
|
+
border: "1px solid " + (sel ? "var(--accent, #4d8dff)" : "var(--border, #34363c)"),
|
|
2784
|
+
background: sel ? "rgba(77, 141, 255, 0.15)" : "var(--bg-hover, #25272c)",
|
|
2785
|
+
color: "var(--text, #d8dade)",
|
|
2786
|
+
borderRadius: 6,
|
|
2787
|
+
padding: "2px 8px",
|
|
2788
|
+
fontSize: 11,
|
|
2789
|
+
cursor: "pointer",
|
|
2790
|
+
maxWidth: 150,
|
|
2791
|
+
overflow: "hidden",
|
|
2792
|
+
textOverflow: "ellipsis",
|
|
2793
|
+
whiteSpace: "nowrap"
|
|
2794
|
+
}
|
|
2795
|
+
}, "\u{1F558} " + r.label);
|
|
2796
|
+
})
|
|
2797
|
+
);
|
|
2798
|
+
}
|
|
2799
|
+
function containerPanel(items) {
|
|
2800
|
+
const filter = state.containerFilter.trim();
|
|
2801
|
+
const childrenOf = containerTree(items);
|
|
2802
|
+
const roots = childrenOf.get("") || [];
|
|
2803
|
+
const empty = h(
|
|
2804
|
+
"div",
|
|
2805
|
+
{ style: { padding: "8px 6px", fontSize: 11, color: "var(--text-muted, #8b909b)" } },
|
|
2806
|
+
shareT("share.container.empty")
|
|
2807
|
+
);
|
|
2808
|
+
panelVisible = [];
|
|
2809
|
+
const flat = panelVisible;
|
|
2810
|
+
const search = filter ? containerSearchState(items, filter) : null;
|
|
2811
|
+
const rows = renderContainerNodes(childrenOf, roots, 0, search, flat);
|
|
2812
|
+
const kbMove = (delta) => {
|
|
2813
|
+
if (!panelVisible.length) return;
|
|
2814
|
+
const next = state.kbIndex < 0 ? delta > 0 ? 0 : panelVisible.length - 1 : Math.min(Math.max(state.kbIndex + delta, 0), panelVisible.length - 1);
|
|
2815
|
+
set({ kbIndex: next });
|
|
2816
|
+
setTimeout(() => {
|
|
2817
|
+
try {
|
|
2818
|
+
document.querySelector(`[data-ext-float] [data-kb="${next}"]`)?.scrollIntoView({ block: "nearest" });
|
|
2819
|
+
} catch (e) {
|
|
2820
|
+
}
|
|
2821
|
+
}, 0);
|
|
2822
|
+
};
|
|
2823
|
+
return h(
|
|
2824
|
+
"div",
|
|
2825
|
+
{ style: {
|
|
2826
|
+
border: "1px solid var(--border, #34363c)",
|
|
2827
|
+
borderRadius: 7,
|
|
2828
|
+
marginTop: 5,
|
|
2829
|
+
background: "var(--bg-panel, #1e2021)",
|
|
2830
|
+
maxHeight: 320,
|
|
2831
|
+
overflowY: "auto",
|
|
2832
|
+
padding: 4
|
|
2833
|
+
} },
|
|
2834
|
+
h(
|
|
2835
|
+
"div",
|
|
2836
|
+
{ style: {
|
|
2837
|
+
position: "sticky",
|
|
2838
|
+
top: -4,
|
|
2839
|
+
margin: -4,
|
|
2840
|
+
marginBottom: 0,
|
|
2841
|
+
padding: 4,
|
|
2842
|
+
background: "var(--bg-panel, #1e2021)",
|
|
2843
|
+
zIndex: 1
|
|
2844
|
+
} },
|
|
2845
|
+
h("input", {
|
|
2846
|
+
value: state.containerFilter,
|
|
2847
|
+
placeholder: shareT("share.container.search"),
|
|
2848
|
+
onInput: (e) => set({ containerFilter: e.target.value, kbIndex: -1 }),
|
|
2849
|
+
onKeyDown: (e) => {
|
|
2850
|
+
if (e.key === "Escape") {
|
|
2851
|
+
set({ containerOpen: false, containerFilter: "" });
|
|
2852
|
+
return;
|
|
2853
|
+
}
|
|
2854
|
+
if (e.key === "ArrowDown") {
|
|
2855
|
+
e.preventDefault();
|
|
2856
|
+
kbMove(1);
|
|
2857
|
+
return;
|
|
2858
|
+
}
|
|
2859
|
+
if (e.key === "ArrowUp") {
|
|
2860
|
+
e.preventDefault();
|
|
2861
|
+
kbMove(-1);
|
|
2862
|
+
return;
|
|
2863
|
+
}
|
|
2864
|
+
if (e.key === "Enter") {
|
|
2865
|
+
e.preventDefault();
|
|
2866
|
+
const c2 = panelVisible[state.kbIndex];
|
|
2867
|
+
if (c2) pickContainer(c2);
|
|
2868
|
+
return;
|
|
2869
|
+
}
|
|
2870
|
+
const c = panelVisible[state.kbIndex];
|
|
2871
|
+
if ((e.key === "ArrowRight" || e.key === "ArrowLeft") && c) {
|
|
2872
|
+
e.preventDefault();
|
|
2873
|
+
const kids = childrenOf.get(c.id) || [];
|
|
2874
|
+
const expanded = filter ? true : !!state.containerExpanded[c.id];
|
|
2875
|
+
if (e.key === "ArrowRight" && kids.length && !expanded) set({ containerExpanded: { ...state.containerExpanded, [c.id]: true } });
|
|
2876
|
+
if (e.key === "ArrowLeft" && !filter && expanded) set({ containerExpanded: { ...state.containerExpanded, [c.id]: false } });
|
|
2877
|
+
}
|
|
2878
|
+
},
|
|
2879
|
+
ref: (el) => {
|
|
2880
|
+
el?.focus?.();
|
|
2881
|
+
},
|
|
2882
|
+
style: {
|
|
2883
|
+
width: "100%",
|
|
2884
|
+
boxSizing: "border-box",
|
|
2885
|
+
background: "var(--bg-hover, #25272c)",
|
|
2886
|
+
border: "1px solid var(--border, #34363c)",
|
|
2887
|
+
borderRadius: 6,
|
|
2888
|
+
padding: "4px 8px",
|
|
2889
|
+
fontSize: 12,
|
|
2890
|
+
color: "var(--text, #d8dade)"
|
|
2891
|
+
}
|
|
2892
|
+
}),
|
|
2893
|
+
filter && rows.length ? h(
|
|
2894
|
+
"div",
|
|
2895
|
+
{ style: { fontSize: 10, color: "var(--text-muted, #8b909b)", marginTop: 3 } },
|
|
2896
|
+
shareT("share.container.matches", { n: String(search.match.size) })
|
|
2897
|
+
) : null
|
|
2898
|
+
),
|
|
2899
|
+
containerQuickRow(),
|
|
2900
|
+
state.containersLoading ? h("div", { style: { padding: "6px", fontSize: 11, color: "var(--text-muted, #8b909b)" } }, "\u2026") : null,
|
|
2901
|
+
rows.length ? rows : empty
|
|
2902
|
+
);
|
|
2903
|
+
}
|
|
2904
|
+
function containerSection() {
|
|
2905
|
+
const t = state.targets.find((x) => x.id === state.targetId);
|
|
2906
|
+
if (!t || !t.supportsContainers) return null;
|
|
2907
|
+
const cache = state.containersByTarget[state.targetId];
|
|
2908
|
+
const items = cache?.containers || [];
|
|
2909
|
+
const selected = items.find((c) => c.id === state.containerFor);
|
|
2910
|
+
const label = noteText(cache?.label) || noteText(t.containerLabel) || shareT("share.container.label");
|
|
2911
|
+
const missing = state.containerFor && items.length && !selected;
|
|
2912
|
+
const btnLabel = selected ? selected.path || selected.label : shareT("share.container.default");
|
|
2913
|
+
return h(
|
|
2914
|
+
"div",
|
|
2915
|
+
null,
|
|
2916
|
+
h(
|
|
2917
|
+
"div",
|
|
2918
|
+
{ style: { display: "flex", alignItems: "center", gap: 6 } },
|
|
2919
|
+
h(
|
|
2920
|
+
"span",
|
|
2921
|
+
{ style: { color: "var(--text-muted, #8b909b)", fontSize: 11, flexShrink: 0 } },
|
|
2922
|
+
"\u{1F4D3} " + label
|
|
2923
|
+
),
|
|
2924
|
+
h(
|
|
2925
|
+
"button",
|
|
2926
|
+
{
|
|
2927
|
+
type: "button",
|
|
2928
|
+
onClick: () => {
|
|
2929
|
+
void ensureContainers(state.targetId);
|
|
2930
|
+
toggleContainerPanel();
|
|
2931
|
+
},
|
|
2932
|
+
title: btnLabel,
|
|
2933
|
+
style: {
|
|
2934
|
+
flex: 1,
|
|
2935
|
+
minWidth: 0,
|
|
2936
|
+
display: "flex",
|
|
2937
|
+
alignItems: "center",
|
|
2938
|
+
gap: 5,
|
|
2939
|
+
textAlign: "left",
|
|
2940
|
+
border: "1px solid var(--border, #34363c)",
|
|
2941
|
+
background: "var(--bg-hover, #25272c)",
|
|
2942
|
+
color: selected ? "var(--text, #d8dade)" : "var(--text-muted, #8b909b)",
|
|
2943
|
+
borderRadius: 7,
|
|
2944
|
+
padding: "5px 9px",
|
|
2945
|
+
fontSize: 12,
|
|
2946
|
+
cursor: "pointer"
|
|
2947
|
+
}
|
|
2948
|
+
},
|
|
2949
|
+
h("span", { style: { flex: 1, minWidth: 0, whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" } }, btnLabel),
|
|
2950
|
+
h("span", { style: { color: "var(--text-muted, #8b909b)", fontSize: 10 } }, state.containerOpen ? "\u25B4" : "\u25BE")
|
|
2951
|
+
),
|
|
2952
|
+
h("button", {
|
|
2953
|
+
type: "button",
|
|
2954
|
+
onClick: () => {
|
|
2955
|
+
void ensureContainers(state.targetId, true);
|
|
2956
|
+
},
|
|
2957
|
+
title: shareT("share.container.refresh"),
|
|
2958
|
+
style: {
|
|
2959
|
+
border: "1px solid var(--border, #34363c)",
|
|
2960
|
+
background: "none",
|
|
2961
|
+
color: "var(--text-muted, #8b909b)",
|
|
2962
|
+
borderRadius: 7,
|
|
2963
|
+
padding: "5px 8px",
|
|
2964
|
+
fontSize: 12,
|
|
2965
|
+
cursor: "pointer",
|
|
2966
|
+
flexShrink: 0
|
|
2967
|
+
}
|
|
2968
|
+
}, "\u27F3")
|
|
2969
|
+
),
|
|
2970
|
+
missing ? h("div", { style: { color: "#d9a13c", fontSize: 10, marginTop: 4 } }, shareT("share.container.missing")) : null,
|
|
2971
|
+
state.containerOpen ? containerPanel(items) : null,
|
|
2972
|
+
state.containerError ? h(
|
|
2973
|
+
"div",
|
|
2974
|
+
{ style: {
|
|
2975
|
+
display: "flex",
|
|
2976
|
+
alignItems: "center",
|
|
2977
|
+
gap: 8,
|
|
2978
|
+
color: "#e05d5d",
|
|
2979
|
+
fontSize: 11,
|
|
2980
|
+
marginTop: 4
|
|
2981
|
+
} },
|
|
2982
|
+
shareT("share.container.fail", { detail: state.containerError }),
|
|
2983
|
+
h(
|
|
2984
|
+
"button",
|
|
2985
|
+
{
|
|
2986
|
+
type: "button",
|
|
2987
|
+
onClick: () => {
|
|
2988
|
+
void ensureContainers(state.targetId, true);
|
|
2989
|
+
},
|
|
2990
|
+
style: { border: "none", background: "none", color: "var(--accent, #4d8dff)", cursor: "pointer", fontSize: 11 }
|
|
2991
|
+
},
|
|
2992
|
+
shareT("share.container.refresh")
|
|
2993
|
+
)
|
|
2994
|
+
) : null
|
|
2995
|
+
);
|
|
2996
|
+
}
|
|
2382
2997
|
function pageInfo() {
|
|
2383
2998
|
const ua = typeof navigator !== "undefined" && navigator.userAgent || "";
|
|
2384
2999
|
let os = "";
|
|
@@ -2406,8 +3021,11 @@ function pageInfo() {
|
|
|
2406
3021
|
return null;
|
|
2407
3022
|
}
|
|
2408
3023
|
})();
|
|
2409
|
-
const
|
|
2410
|
-
const
|
|
3024
|
+
const sum = cur?.session || null;
|
|
3025
|
+
const rowSess = state.payload?.session;
|
|
3026
|
+
const listTitle = (s) => s ? s.name || s.firstMessage || String(s.id || "").slice(0, 12) : "";
|
|
3027
|
+
const sessionId = rowSess?.id || sum?.id || cur?.sessionId || state.payload?.sessionId || state.payload?.sessionName || (typeof location !== "undefined" ? new URL(location.href).searchParams.get("session") : "") || "";
|
|
3028
|
+
const sessionName = listTitle(rowSess) || listTitle(sum) || state.payload?.sessionName || "";
|
|
2411
3029
|
return { os, browser, url: typeof location !== "undefined" ? location.href : "", sessionId, sessionName };
|
|
2412
3030
|
}
|
|
2413
3031
|
var STAMP_LABELS = { os: "share.pi.os", browser: "share.pi.browser", url: "share.pi.url", sessionId: "share.pi.sessionId", sessionName: "share.pi.sessionName" };
|
|
@@ -2445,7 +3063,9 @@ function errorText() {
|
|
|
2445
3063
|
badRequest: "share.err.badRequest",
|
|
2446
3064
|
badSxcu: "share.err.badSxcu",
|
|
2447
3065
|
noProbe: "share.err.noProbe",
|
|
2448
|
-
forbidden: "share.err.forbidden"
|
|
3066
|
+
forbidden: "share.err.forbidden",
|
|
3067
|
+
kind: "share.err.kind",
|
|
3068
|
+
containerFail: "share.container.fail"
|
|
2449
3069
|
}[code];
|
|
2450
3070
|
if (key) return shareT(key, { name, detail });
|
|
2451
3071
|
return state.error || shareT("share.err.generic", { detail });
|
|
@@ -2634,8 +3254,26 @@ async function doShare() {
|
|
|
2634
3254
|
text: state.text,
|
|
2635
3255
|
title: state.title,
|
|
2636
3256
|
tags: state.tags,
|
|
2637
|
-
redact: false
|
|
2638
|
-
|
|
3257
|
+
redact: false,
|
|
3258
|
+
container: state.containerFor || ""
|
|
3259
|
+
};
|
|
3260
|
+
if (state.kind === "image" && body.imageSrc) {
|
|
3261
|
+
const blob = await fetch(body.imageSrc).then((r2) => {
|
|
3262
|
+
if (!r2.ok) throw new Error("HTTP " + r2.status);
|
|
3263
|
+
return r2.blob();
|
|
3264
|
+
}).catch((e) => {
|
|
3265
|
+
throw Object.assign(new Error(shareT("share.err.imageFetch", { detail: e?.message || e })), { detail: String(e?.message || e) });
|
|
3266
|
+
});
|
|
3267
|
+
const dataUrl = await new Promise((res, rej) => {
|
|
3268
|
+
const fr = new FileReader();
|
|
3269
|
+
fr.onload = () => res(String(fr.result));
|
|
3270
|
+
fr.onerror = () => rej(new Error("FileReader failed"));
|
|
3271
|
+
fr.readAsDataURL(blob);
|
|
3272
|
+
});
|
|
3273
|
+
body.imageBase64 = dataUrl;
|
|
3274
|
+
body.mime = blob.type || "image/png";
|
|
3275
|
+
body.filename = body.filename || "image." + (blob.type.split("/")[1] || "png").replace("jpeg", "jpg");
|
|
3276
|
+
}
|
|
2639
3277
|
const r = await getJSON("share", {
|
|
2640
3278
|
method: "POST",
|
|
2641
3279
|
headers: { "content-type": "application/json" },
|
|
@@ -2706,7 +3344,9 @@ function shareDialog() {
|
|
|
2706
3344
|
style: { padding: "12px 14px", display: "flex", flexDirection: "column", gap: 12, flex: 1, minHeight: 0, overflowY: "auto" }
|
|
2707
3345
|
},
|
|
2708
3346
|
previewSection(),
|
|
3347
|
+
sinkSection(),
|
|
2709
3348
|
targetSection(),
|
|
3349
|
+
containerSection(),
|
|
2710
3350
|
h(
|
|
2711
3351
|
"div",
|
|
2712
3352
|
{ style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 9 } },
|
|
@@ -2822,12 +3462,19 @@ function managerDialog() {
|
|
|
2822
3462
|
opacity: t.status === "dead" ? 0.5 : 1
|
|
2823
3463
|
}
|
|
2824
3464
|
},
|
|
2825
|
-
h("span", null, t.status === "dead" ? "\u{1F480}" : t.category === "archive" ? "\u{1F4D3}" : "\u{1F517}"),
|
|
3465
|
+
h("span", null, t.status === "dead" ? "\u{1F480}" : t.icon || (t.category === "archive" ? "\u{1F4D3}" : "\u{1F517}")),
|
|
2826
3466
|
h(
|
|
2827
3467
|
"div",
|
|
2828
3468
|
{ style: { flex: 1, minWidth: 0 } },
|
|
2829
3469
|
h("div", { style: { fontSize: 12, whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" } }, t.name || t.id),
|
|
2830
|
-
h(
|
|
3470
|
+
h(
|
|
3471
|
+
"div",
|
|
3472
|
+
{ style: { fontSize: 10, color: "var(--text-muted, #8b909b)", whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" } },
|
|
3473
|
+
(t.kinds || []).map(kindLabel).join("/") + (() => {
|
|
3474
|
+
const n = noteText(t.note);
|
|
3475
|
+
return n ? " \xB7 " + n : "";
|
|
3476
|
+
})() + (t.supportsContainers && t.lastContainerLabel ? " \xB7 \u{1F4D3} " + t.lastContainerLabel : "")
|
|
3477
|
+
)
|
|
2831
3478
|
),
|
|
2832
3479
|
(() => {
|
|
2833
3480
|
const b = CFG_BADGE[t.configState];
|
|
@@ -2838,7 +3485,10 @@ function managerDialog() {
|
|
|
2838
3485
|
})(),
|
|
2839
3486
|
t.recommended ? h("span", { style: { color: "var(--accent, #4d8dff)", fontSize: 10 } }, "\u2605") : null,
|
|
2840
3487
|
// "Use" closes the loop: pick this target for the pending share and return to it.
|
|
2841
|
-
t
|
|
3488
|
+
!supportsKind(t, contentKind()) ? h("span", {
|
|
3489
|
+
title: shareT("share.notCompatible", { kind: kindLabel(contentKind()) }),
|
|
3490
|
+
style: { color: "var(--text-muted, #8b909b)", fontSize: 9, whiteSpace: "nowrap", flexShrink: 0 }
|
|
3491
|
+
}, "\u2205") : t.status !== "dead" && t.status !== "legacy" && t.configState !== "needs-setup" ? h("button", {
|
|
2842
3492
|
type: "button",
|
|
2843
3493
|
title: shareT("share.useTarget"),
|
|
2844
3494
|
onClick: (e) => {
|
|
@@ -2880,7 +3530,10 @@ function managerDialog() {
|
|
|
2880
3530
|
"div",
|
|
2881
3531
|
{ style: { flex: 1, padding: 14, display: "flex", flexDirection: "column", gap: 12, overflowY: "auto" } },
|
|
2882
3532
|
h("div", { style: { fontWeight: 600 } }, edit.name || edit.id),
|
|
2883
|
-
|
|
3533
|
+
(() => {
|
|
3534
|
+
const n = noteText(edit.note);
|
|
3535
|
+
return n ? h("div", { style: { fontSize: 11, color: "var(--text-muted, #8b909b)" } }, n) : null;
|
|
3536
|
+
})(),
|
|
2884
3537
|
...fields.map((f) => {
|
|
2885
3538
|
const key = typeof f === "string" ? f : f.key;
|
|
2886
3539
|
const label = typeof f === "string" ? f : f.label || f.key;
|
|
@@ -3058,10 +3711,10 @@ function register(ctx) {
|
|
|
3058
3711
|
fontSize: 11
|
|
3059
3712
|
}
|
|
3060
3713
|
}, icon("share", 12), label);
|
|
3061
|
-
ctx.registerItems("userMessageActions", [{ id: "aiti-msg-share-user", render: shareAction(shareT("share.action")) }]);
|
|
3714
|
+
ctx.registerItems("userMessageActions", [{ id: "aiti-msg-share-user", render: shareAction(shareT("share.action")), meta: { order: 1 } }]);
|
|
3062
3715
|
ctx.registerItems("assistantMessageActions", [
|
|
3063
|
-
{ id: "aiti-msg-share-assistant", render: shareAction(shareT("share.action")) },
|
|
3064
|
-
{ id: "aiti-msg-share-assistant-top", render: shareAction(shareT("share.action")), meta: { placement: "top" } }
|
|
3716
|
+
{ id: "aiti-msg-share-assistant", render: shareAction(shareT("share.action")), meta: { order: 1 } },
|
|
3717
|
+
{ id: "aiti-msg-share-assistant-top", render: shareAction(shareT("share.action")), meta: { placement: "top", order: 1 } }
|
|
3065
3718
|
]);
|
|
3066
3719
|
ctx.registerItems("commands", [{
|
|
3067
3720
|
id: "aiti-msg-share.center",
|
|
@@ -3103,6 +3756,7 @@ function register(ctx) {
|
|
|
3103
3756
|
title: shareT("share.fileTip"),
|
|
3104
3757
|
icon: SHARE_ICON,
|
|
3105
3758
|
type: "share",
|
|
3759
|
+
order: 20,
|
|
3106
3760
|
match: (abs, isDir) => !isDir,
|
|
3107
3761
|
onClick: (abs) => openShare({ kind: "file", filePath: abs, filename: abs.split("/").pop() })
|
|
3108
3762
|
});
|