@aiti-ai/aiti-msg-share 0.1.8 → 0.1.11
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 +2 -3
- package/client/src/index.js +274 -12
- package/dist/aiti-msg-share-client.mjs +445 -15
- package/docs/README.zh-CN.md +2 -2
- package/icon.svg +1 -1
- package/index.ts +100 -6
- package/lib/provider-icons.mjs +63 -0
- package/package.json +12 -3
- package/test/provider-icons.test.mjs +47 -0
- package/test/share-core.test.mjs +14 -0
|
@@ -2125,6 +2125,15 @@ function contentKind() {
|
|
|
2125
2125
|
function supportsKind(t, kind) {
|
|
2126
2126
|
return !(t.kinds || []).length || (t.kinds || []).includes(kind);
|
|
2127
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
|
+
}
|
|
2128
2137
|
function shareT(key, params) {
|
|
2129
2138
|
if (!tFn) return key;
|
|
2130
2139
|
try {
|
|
@@ -2168,6 +2177,17 @@ var state = {
|
|
|
2168
2177
|
probe: [],
|
|
2169
2178
|
editing: null,
|
|
2170
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,
|
|
2171
2191
|
/** Local favourite sinks (share-sink topic): { ok, message, action } of the last run. */
|
|
2172
2192
|
sinkResult: null,
|
|
2173
2193
|
sinkBusy: ""
|
|
@@ -2235,17 +2255,89 @@ function set(partial) {
|
|
|
2235
2255
|
}
|
|
2236
2256
|
function chooseTarget(id) {
|
|
2237
2257
|
recentAdd(id);
|
|
2238
|
-
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);
|
|
2239
2261
|
}
|
|
2240
2262
|
function emit() {
|
|
2241
2263
|
listeners.forEach((fn) => fn());
|
|
2242
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
|
+
}
|
|
2243
2334
|
var STATUS_ICONS = { recent: "\u{1F558}", recommended: "\u2605", dead: "\u26A0", legacy: "\u26A0" };
|
|
2244
2335
|
var CFG_BADGE = {
|
|
2245
2336
|
anonymous: { icon: "\u{1F7E2}", key: "share.cfg.anonymous", color: "var(--accent, #4d8dff)" },
|
|
2246
2337
|
ready: { icon: "\u2713", key: "share.cfg.ready", color: "var(--accent, #4d8dff)" },
|
|
2247
2338
|
"needs-setup": { icon: "\u{1F7E0}", key: "share.cfg.needs", color: "#d9a13c" },
|
|
2248
|
-
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" }
|
|
2249
2341
|
};
|
|
2250
2342
|
var ICONS = {
|
|
2251
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"/>',
|
|
@@ -2299,7 +2391,7 @@ function openShare(payload = {}) {
|
|
|
2299
2391
|
text: raw,
|
|
2300
2392
|
rawText: raw,
|
|
2301
2393
|
baseText: raw,
|
|
2302
|
-
title: payload.title ||
|
|
2394
|
+
title: payload.title || deriveTitleLocal(raw),
|
|
2303
2395
|
tags: payload.tags || "",
|
|
2304
2396
|
targetId: payload.targetId || null,
|
|
2305
2397
|
result: null,
|
|
@@ -2333,6 +2425,8 @@ async function refresh(force = false) {
|
|
|
2333
2425
|
loading: false,
|
|
2334
2426
|
targetId: state.targetId || targets.find((t) => t.recommended)?.id || targets[0]?.id
|
|
2335
2427
|
});
|
|
2428
|
+
syncContainerFor(state.targetId);
|
|
2429
|
+
void ensureContainers(state.targetId);
|
|
2336
2430
|
if (force) await getJSON("refresh", { method: "POST" }).catch(() => {
|
|
2337
2431
|
});
|
|
2338
2432
|
} catch (e) {
|
|
@@ -2340,14 +2434,18 @@ async function refresh(force = false) {
|
|
|
2340
2434
|
}
|
|
2341
2435
|
}
|
|
2342
2436
|
function targetCard(target, selected, badge) {
|
|
2343
|
-
const disabled = target.status === "dead" || target.enabled === false;
|
|
2437
|
+
const disabled = target.status === "dead" || target.status === "legacy" || target.enabled === false;
|
|
2344
2438
|
return h(
|
|
2345
2439
|
"button",
|
|
2346
2440
|
{
|
|
2347
2441
|
type: "button",
|
|
2348
2442
|
key: target.id,
|
|
2349
2443
|
disabled,
|
|
2350
|
-
onClick: () =>
|
|
2444
|
+
onClick: () => {
|
|
2445
|
+
set({ targetId: target.id, error: "", containerOpen: false, containerFilter: "" });
|
|
2446
|
+
syncContainerFor(target.id);
|
|
2447
|
+
void ensureContainers(target.id);
|
|
2448
|
+
},
|
|
2351
2449
|
title: noteText(target.note) || target.name,
|
|
2352
2450
|
style: {
|
|
2353
2451
|
display: "inline-flex",
|
|
@@ -2363,7 +2461,8 @@ function targetCard(target, selected, badge) {
|
|
|
2363
2461
|
opacity: disabled ? 0.45 : 1
|
|
2364
2462
|
}
|
|
2365
2463
|
},
|
|
2366
|
-
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])] : [],
|
|
2367
2466
|
target.name || target.id,
|
|
2368
2467
|
...target.kinds?.length ? [h(
|
|
2369
2468
|
"span",
|
|
@@ -2530,7 +2629,7 @@ function sinkSection() {
|
|
|
2530
2629
|
function targetSection() {
|
|
2531
2630
|
const recent = recentGet();
|
|
2532
2631
|
const kind = contentKind();
|
|
2533
|
-
const compat = (x) => supportsKind(x, kind);
|
|
2632
|
+
const compat = (x) => supportsKind(x, kind) && x.status !== "dead" && x.status !== "legacy";
|
|
2534
2633
|
const t = state.targets;
|
|
2535
2634
|
const byId = new Map(t.map((x) => [x.id, x]));
|
|
2536
2635
|
const recentItems = recent.map((id) => byId.get(id)).filter(Boolean).filter(compat).slice(0, 5);
|
|
@@ -2571,6 +2670,330 @@ function targetSection() {
|
|
|
2571
2670
|
h("div", { style: { display: "flex", flexWrap: "wrap", gap: 6 } }, ...shown)
|
|
2572
2671
|
);
|
|
2573
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
|
+
}
|
|
2574
2997
|
function pageInfo() {
|
|
2575
2998
|
const ua = typeof navigator !== "undefined" && navigator.userAgent || "";
|
|
2576
2999
|
let os = "";
|
|
@@ -2641,7 +3064,8 @@ function errorText() {
|
|
|
2641
3064
|
badSxcu: "share.err.badSxcu",
|
|
2642
3065
|
noProbe: "share.err.noProbe",
|
|
2643
3066
|
forbidden: "share.err.forbidden",
|
|
2644
|
-
kind: "share.err.kind"
|
|
3067
|
+
kind: "share.err.kind",
|
|
3068
|
+
containerFail: "share.container.fail"
|
|
2645
3069
|
}[code];
|
|
2646
3070
|
if (key) return shareT(key, { name, detail });
|
|
2647
3071
|
return state.error || shareT("share.err.generic", { detail });
|
|
@@ -2830,7 +3254,8 @@ async function doShare() {
|
|
|
2830
3254
|
text: state.text,
|
|
2831
3255
|
title: state.title,
|
|
2832
3256
|
tags: state.tags,
|
|
2833
|
-
redact: false
|
|
3257
|
+
redact: false,
|
|
3258
|
+
container: state.containerFor || ""
|
|
2834
3259
|
};
|
|
2835
3260
|
if (state.kind === "image" && body.imageSrc) {
|
|
2836
3261
|
const blob = await fetch(body.imageSrc).then((r2) => {
|
|
@@ -2921,6 +3346,7 @@ function shareDialog() {
|
|
|
2921
3346
|
previewSection(),
|
|
2922
3347
|
sinkSection(),
|
|
2923
3348
|
targetSection(),
|
|
3349
|
+
containerSection(),
|
|
2924
3350
|
h(
|
|
2925
3351
|
"div",
|
|
2926
3352
|
{ style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 9 } },
|
|
@@ -3036,15 +3462,19 @@ function managerDialog() {
|
|
|
3036
3462
|
opacity: t.status === "dead" ? 0.5 : 1
|
|
3037
3463
|
}
|
|
3038
3464
|
},
|
|
3039
|
-
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}")),
|
|
3040
3466
|
h(
|
|
3041
3467
|
"div",
|
|
3042
3468
|
{ style: { flex: 1, minWidth: 0 } },
|
|
3043
3469
|
h("div", { style: { fontSize: 12, whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" } }, t.name || t.id),
|
|
3044
|
-
h(
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
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
|
+
)
|
|
3048
3478
|
),
|
|
3049
3479
|
(() => {
|
|
3050
3480
|
const b = CFG_BADGE[t.configState];
|
|
@@ -3058,7 +3488,7 @@ function managerDialog() {
|
|
|
3058
3488
|
!supportsKind(t, contentKind()) ? h("span", {
|
|
3059
3489
|
title: shareT("share.notCompatible", { kind: kindLabel(contentKind()) }),
|
|
3060
3490
|
style: { color: "var(--text-muted, #8b909b)", fontSize: 9, whiteSpace: "nowrap", flexShrink: 0 }
|
|
3061
|
-
}, "\u2205") : t.status !== "dead" && t.configState !== "needs-setup" ? h("button", {
|
|
3491
|
+
}, "\u2205") : t.status !== "dead" && t.status !== "legacy" && t.configState !== "needs-setup" ? h("button", {
|
|
3062
3492
|
type: "button",
|
|
3063
3493
|
title: shareT("share.useTarget"),
|
|
3064
3494
|
onClick: (e) => {
|
package/docs/README.zh-CN.md
CHANGED
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
|
|
7
7
|
## 关于 aiti
|
|
8
8
|
|
|
9
|
-
本包是 **aiti** 生态的一部分——由 [pi](https://pi.dev) 驱动的个人 AI 开发工作台:**aiti-agent**(基于开源 [pi-web](https://github.com/aiti-ai/
|
|
9
|
+
本包是 **aiti** 生态的一部分——由 [pi](https://pi.dev) 驱动的个人 AI 开发工作台:**aiti-agent**(基于开源 [pi-web](https://github.com/aiti-ai/aiti-ai) 的自托管 Web 工作台),加上对主流开发工具的调试注入(aiti-devtools)与丰富的扩展体系。
|
|
10
10
|
|
|
11
|
-
- 工作台(aiti-agent,基于 pi-web):<https://github.com/aiti-ai/
|
|
11
|
+
- 工作台(aiti-agent,基于 pi-web):<https://github.com/aiti-ai/aiti-ai>
|
|
12
12
|
- 生态主仓:<https://github.com/aiti-ai/aiti-ai>
|
|
13
13
|
- 站点:<https://aiti.pw>
|
|
14
14
|
|
package/icon.svg
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><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"/></svg>
|