SHA256
Доработать исследователь сети и кошелёк
This commit is contained in:
@@ -109,14 +109,16 @@ export function createDropdownMenu({
|
||||
|
||||
const button = document.createElement('button');
|
||||
button.type = 'button';
|
||||
button.className = `dropdown-menu__item${item.selected ? ' is-selected' : ''}${item.danger ? ' is-danger' : ''}${item.className ? ` ${item.className}` : ''}`;
|
||||
button.setAttribute('role', 'menuitem');
|
||||
const checkable = typeof item.checked === 'boolean';
|
||||
button.className = `dropdown-menu__item${(item.selected || item.checked) ? ' is-selected' : ''}${item.danger ? ' is-danger' : ''}${item.className ? ` ${item.className}` : ''}`;
|
||||
button.setAttribute('role', checkable ? 'menuitemcheckbox' : 'menuitem');
|
||||
if (checkable) button.setAttribute('aria-checked', String(item.checked));
|
||||
button.disabled = Boolean(item.disabled);
|
||||
|
||||
if (item.iconHtml) {
|
||||
if (checkable || item.iconHtml) {
|
||||
const icon = document.createElement('span');
|
||||
icon.className = 'dropdown-menu__icon';
|
||||
icon.innerHTML = item.iconHtml;
|
||||
icon.innerHTML = checkable ? iconHtml(item.checked ? 'checkbox-checked' : 'checkbox') : item.iconHtml;
|
||||
button.append(icon);
|
||||
} else if (item.iconSrc) {
|
||||
const icon = document.createElement('img');
|
||||
|
||||
@@ -34,6 +34,8 @@ const paths = {
|
||||
gift: '<rect x="3" y="8" width="18" height="5" rx="1"/><path d="M5 13v7a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-7M12 8v13M12 8S10.5 3 8 3.5 7 8 12 8Zm0 0s1.5-5 4-4.5S17 8 12 8Z"/>',
|
||||
plus: '<path d="M12 5v14M5 12h14"/>',
|
||||
check: '<path d="m5 12.5 4.5 4.5L19 7.5"/>',
|
||||
checkbox: '<rect x="4" y="4" width="16" height="16" rx="3"/>',
|
||||
'checkbox-checked': '<rect x="4" y="4" width="16" height="16" rx="3"/><path d="m7.5 12 3 3 6-6"/>',
|
||||
open: '<path d="M5 12h14M13 6l6 6-6 6"/>',
|
||||
chevron: '<path d="m9 6 6 6-6 6"/>',
|
||||
'chevron-up': '<path d="m6 15 6-6 6 6"/>',
|
||||
|
||||
@@ -4291,6 +4291,10 @@
|
||||
"close": "Close avatar preview"
|
||||
},
|
||||
"network_explorer": {
|
||||
"show_me": "Show me",
|
||||
"only_close": "Close friends only",
|
||||
"only_shining": "Shining members only",
|
||||
"show_history": "Show history",
|
||||
"depth": "Depth: {value1}",
|
||||
"depth_hint": "Up to {value1} links from the selected person. Tap to change depth.",
|
||||
"menu": "Connections menu",
|
||||
|
||||
@@ -4291,6 +4291,10 @@
|
||||
"close": "Закрыть просмотр аватара"
|
||||
},
|
||||
"network_explorer": {
|
||||
"show_me": "Показать меня",
|
||||
"only_close": "Только близкие",
|
||||
"only_shining": "Только сияющие",
|
||||
"show_history": "Показывать историю",
|
||||
"depth": "Глубина: {value1}",
|
||||
"depth_hint": "Максимум {value1} связей от выбранного пользователя. Нажмите, чтобы изменить глубину.",
|
||||
"menu": "Меню связей",
|
||||
|
||||
@@ -558,6 +558,12 @@ export function createExplorerCanvasGraph({ stage, model, onCenterTap, onNodeTap
|
||||
return {
|
||||
setModel, nodeScreenPoint,
|
||||
getFocusNode: () => nodeById.get(focusId) || null,
|
||||
centerCamera: () => {
|
||||
const node = nodeById.get(focusId);
|
||||
camX = -(node?.x || 0) * zoom;
|
||||
camY = -(node?.y || 0) * zoom;
|
||||
requestDraw();
|
||||
},
|
||||
recenter: () => { camX = 0; camY = 0; updateZoom(DIVE_ZOOM); requestDraw(); },
|
||||
destroy: () => {
|
||||
if (destroyed) return;
|
||||
|
||||
@@ -7,7 +7,7 @@ import { CONNECTIONS_GRAPH_CHANGED } from '../../services/connections-graph-cach
|
||||
import { createForceGraph } from '../network-legacy/force-graph.js';
|
||||
import { createExplorerCanvasGraph } from '../network-canvas-v4/graph-renderer.js';
|
||||
import { openNodeMenu } from '../network-legacy/node-menu.js';
|
||||
import { createExplorerGraph, keyOf, EXPLORER_DEFAULT_DEPTH, EXPLORER_MAX_DEPTH } from './graph-model.js';
|
||||
import { createExplorerGraph, keyOf } from './graph-model.js';
|
||||
import { getExplorerGraph, readExplorerCachedGraphs, clearExplorerGraphCache, explorerCacheScope, explorerGraphSavedAt } from './graph-cache.js';
|
||||
|
||||
export const pageMeta = {
|
||||
@@ -69,7 +69,7 @@ export function renderExplorer({ navigate, route, chrome } = {}, { canvas = fals
|
||||
const scope = explorerCacheScope(authService, state.session.login);
|
||||
if (!retained || retained.scope !== scope) retained = {
|
||||
scope, graph: createExplorerGraph(), positions: new Map(), center: '',
|
||||
depth: EXPLORER_DEFAULT_DEPTH, x2: false, close: false, shining: false, compact: false,
|
||||
depth: 3, x2: true, close: false, shining: false,
|
||||
};
|
||||
const session = retained;
|
||||
let centerLogin = normalizeLogin(route?.params?.login || session.center || state.session.login);
|
||||
@@ -118,8 +118,8 @@ export function renderExplorer({ navigate, route, chrome } = {}, { canvas = fals
|
||||
const center = keyOf(centerLogin);
|
||||
if (!session.positions.has(center)) session.positions.set(center, { x: 0, y: 0 });
|
||||
const pending = nodes.filter((node) => !session.positions.has(node.id)).sort((a, b) => a.distance - b.distance);
|
||||
const spacing = session.compact ? 62 : 84;
|
||||
const minNodeGap = session.compact ? 48 : 66;
|
||||
const spacing = 84;
|
||||
const minNodeGap = 66;
|
||||
for (const node of pending) {
|
||||
const connected = (adjacency.get(node.id) || []).filter((id) => session.positions.has(id));
|
||||
const nearest = connected.sort((a, b) => (byId.get(a)?.distance ?? 99) - (byId.get(b)?.distance ?? 99))[0];
|
||||
@@ -223,14 +223,13 @@ export function renderExplorer({ navigate, route, chrome } = {}, { canvas = fals
|
||||
if (disposed || seq !== loadSeq) return;
|
||||
if (!ok) { updateStatus(t('screens.network_explorer.error')); return; }
|
||||
draw();
|
||||
if (!session.x2) { updateStatus(); return; }
|
||||
|
||||
const friends = [...(session.graph.getFriends(next) || [])];
|
||||
let index = 0;
|
||||
let finished = 0;
|
||||
let failed = 0;
|
||||
const workers = Array.from({ length: Math.min(4, friends.length) }, async () => {
|
||||
while (index < friends.length && !disposed && seq === loadSeq && session.x2) {
|
||||
while (index < friends.length && !disposed && seq === loadSeq) {
|
||||
const friend = friends[index++];
|
||||
if (!await fetchGraph(friend, seq)) failed += 1;
|
||||
finished += 1;
|
||||
@@ -243,56 +242,43 @@ export function renderExplorer({ navigate, route, chrome } = {}, { canvas = fals
|
||||
updateStatus(failed ? t('screens.network_explorer.partial', { value1: failed }) : '');
|
||||
}
|
||||
|
||||
function chip(label, fn, selected = false) {
|
||||
const element = document.createElement('button');
|
||||
element.type = 'button'; element.className = `fg-filter-chip${selected ? ' is-active' : ''}`;
|
||||
element.textContent = label;
|
||||
element.setAttribute('aria-pressed', selected ? 'true' : 'false');
|
||||
element.addEventListener('click', fn);
|
||||
toolbar.append(element);
|
||||
return element;
|
||||
// Верхняя панель содержит только активные фильтры; меню читает то же состояние.
|
||||
function syncFilters() {
|
||||
toolbar.replaceChildren();
|
||||
for (const [key, label] of [
|
||||
['close', 'screens.network_explorer.only_close'],
|
||||
['shining', 'screens.network_explorer.only_shining'],
|
||||
]) {
|
||||
if (!session[key]) continue;
|
||||
const button = document.createElement('button');
|
||||
button.type = 'button';
|
||||
button.className = 'fg-filter-chip is-active';
|
||||
button.textContent = t(label);
|
||||
button.setAttribute('aria-pressed', 'true');
|
||||
button.addEventListener('click', () => toggleFilter(key));
|
||||
toolbar.append(button);
|
||||
}
|
||||
toolbar.hidden = !session.close && !session.shining;
|
||||
}
|
||||
function actionChip(label, fn) {
|
||||
const element = document.createElement('button');
|
||||
element.type = 'button'; element.className = 'fg-filter-chip';
|
||||
element.textContent = label;
|
||||
element.addEventListener('click', fn);
|
||||
toolbar.append(element);
|
||||
return element;
|
||||
function toggleFilter(key) {
|
||||
session[key] = !session[key];
|
||||
syncFilters();
|
||||
draw();
|
||||
}
|
||||
const closeChip = chip(t('screens.network_view.text_002'), () => {
|
||||
session.close = !session.close;
|
||||
closeChip.classList.toggle('is-active', session.close);
|
||||
closeChip.setAttribute('aria-pressed', String(session.close));
|
||||
function toggleHistory() {
|
||||
session.depth = session.depth === 3 ? 0 : 3;
|
||||
draw();
|
||||
}, session.close);
|
||||
const shineChip = chip(t('screens.network_view.text_003'), () => {
|
||||
session.shining = !session.shining;
|
||||
shineChip.classList.toggle('is-active', session.shining);
|
||||
shineChip.setAttribute('aria-pressed', String(session.shining));
|
||||
draw();
|
||||
}, session.shining);
|
||||
const x2Chip = chip('X2', () => {
|
||||
session.x2 = !session.x2;
|
||||
x2Chip.classList.toggle('is-active', session.x2);
|
||||
x2Chip.setAttribute('aria-pressed', String(session.x2));
|
||||
void load(centerLogin);
|
||||
}, session.x2);
|
||||
const depthChip = chip('', () => {
|
||||
session.depth = (session.depth + 1) % (EXPLORER_MAX_DEPTH + 1);
|
||||
syncDepth(); draw();
|
||||
});
|
||||
actionChip(t('screens.network_explorer.compact'), () => {
|
||||
session.compact = true;
|
||||
session.positions.clear();
|
||||
draw();
|
||||
});
|
||||
function syncDepth() {
|
||||
depthChip.textContent = t('screens.network_explorer.depth', { value1: session.depth });
|
||||
depthChip.title = t('screens.network_explorer.depth_hint', { value1: session.depth + (session.x2 ? 2 : 1) });
|
||||
depthChip.setAttribute('aria-label', depthChip.title);
|
||||
}
|
||||
syncDepth();
|
||||
function showMe() {
|
||||
const login = normalizeLogin(state.session.login);
|
||||
if (!login || disposed) return;
|
||||
// load() сдвигает координаты при смене центра; для уже выбранного себя
|
||||
// тоже возвращаем узел в начало координат, если он был перемещён вручную.
|
||||
if (keyOf(login) === keyOf(centerLogin)) shiftToCenter(login);
|
||||
void load(login, true);
|
||||
engine?.centerCamera?.();
|
||||
}
|
||||
syncFilters();
|
||||
|
||||
async function resetCache() {
|
||||
++loadSeq;
|
||||
@@ -435,8 +421,14 @@ export function renderExplorer({ navigate, route, chrome } = {}, { canvas = fals
|
||||
icon: 'moreVertical', title: t('screens.network_explorer.menu'),
|
||||
ariaLabel: t('screens.network_explorer.menu'),
|
||||
menu: {
|
||||
items: [
|
||||
items: () => [
|
||||
{ iconHtml: iconHtml('search'), label: t('screens.network_explorer.search'), action: openSearchModal },
|
||||
{ iconHtml: iconHtml('focus'), label: t('screens.network_explorer.show_me'), disabled: !normalizeLogin(state.session.login), action: showMe },
|
||||
{ divider: true },
|
||||
{ label: t('screens.network_explorer.only_close'), checked: session.close, action: () => toggleFilter('close') },
|
||||
{ label: t('screens.network_explorer.only_shining'), checked: session.shining, action: () => toggleFilter('shining') },
|
||||
{ label: t('screens.network_explorer.show_history'), checked: session.depth === 3, action: toggleHistory },
|
||||
{ divider: true },
|
||||
{ iconHtml: iconHtml('trash'), label: t('screens.network_explorer.clear_cache'), action: () => void resetCache() },
|
||||
],
|
||||
},
|
||||
|
||||
@@ -57,6 +57,7 @@ export function render({ navigate, chrome, route }) {
|
||||
q('recipient-label').textContent = t('wallet_multi.recipient');
|
||||
q('notify-label').textContent = t('wallet_multi.notify');
|
||||
q('notify-row').hidden = !recipientFromRoute;
|
||||
q('notify').checked = Boolean(recipientFromRoute);
|
||||
q('send').textContent = t('wallet_multi.send');
|
||||
q('hint').textContent = t('wallet_multi.no_stars');
|
||||
q('selected').textContent = '';
|
||||
|
||||
@@ -1289,7 +1289,6 @@ export function render({navigate, chrome}) {
|
||||
[t('screens.wallet_view.text_118'), t('screens.wallet_view.text_119'), () => renderArweaveWallet()],
|
||||
[t('screens.wallet_view.text_120'), t('screens.wallet_view.text_121'), () => renderTurboWallet()],
|
||||
[t('screens.wallet_view.support_project_label'), t('screens.wallet_view.support_project_hint'), () => openShineSupportDialog()],
|
||||
[t('screens.wallet_view.text_122'), t('screens.wallet_view.text_123'), () => renderShineBlockchainWallet()],
|
||||
[t('screens.wallet_view.text_124'), t('screens.wallet_view.text_125'), () => renderSupportHub()],
|
||||
];
|
||||
const buttons = items.map(([label, hint, open]) => {
|
||||
|
||||
@@ -421,6 +421,8 @@
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.fg-filter-bar[hidden] { display: none; }
|
||||
|
||||
.fg-filter-bar > button {
|
||||
pointer-events: auto;
|
||||
position: relative;
|
||||
|
||||
@@ -131,3 +131,24 @@ test('V3: сияние не стирает тип связи у красно-с
|
||||
assert.equal(edge.reverseRelationType, 'close_friend');
|
||||
assert.equal(find(g.snapshot('a', { depth: 0 }), 'b').shining, true);
|
||||
});
|
||||
|
||||
test('V3/V4: история с постоянно включённым X2 меняет радиус 5 ↔ 2, не удаляя граф', () => {
|
||||
const g = createExplorerGraph();
|
||||
for (const [a, b] of [['a','b'], ['b','c'], ['c','d'], ['d','e'], ['e','f'], ['f','g']]) {
|
||||
g.add(friends(a, [b]));
|
||||
}
|
||||
const ids = (depth) => g.snapshot('a', { x2: true, depth }).nodes.map((node) => node.id);
|
||||
assert.deepEqual(ids(3), ['a','b','c','d','e','f']);
|
||||
assert.deepEqual(ids(0), ['a','b','c']);
|
||||
assert.deepEqual(ids(3), ['a','b','c','d','e','f']);
|
||||
});
|
||||
|
||||
test('V3/V4: оба фильтра работают совместно и могут отключаться независимо', () => {
|
||||
const g = createExplorerGraph();
|
||||
g.add(friends('a', ['b'], ['c', 'd'], [], [['b', true], ['c', true], ['d', false]]));
|
||||
const ids = (close, shining) => g.snapshot('a', { x2: true, depth: 3, close, shining }).nodes.map((node) => node.id).sort();
|
||||
assert.deepEqual(ids(true, true), ['a','c']);
|
||||
assert.deepEqual(ids(false, true), ['a','b','c']);
|
||||
assert.deepEqual(ids(true, false), ['a','c','d']);
|
||||
assert.deepEqual(ids(false, false), ['a','b','c','d']);
|
||||
});
|
||||
|
||||
@@ -116,3 +116,23 @@ test('V4 Canvas открывается по умолчанию, но ранее
|
||||
assert.match(switcher, /const DEFAULT_MODE = 'explorer-canvas';/);
|
||||
assert.match(switcher, /MODES\.has\(saved\) \? saved : DEFAULT_MODE/);
|
||||
});
|
||||
|
||||
test('V3/V4: defaults, dynamic menu, active-only chips and self-centering contract', () => {
|
||||
const view = readFileSync(new URL('../js/pages/network-explorer/network-view.js', import.meta.url), 'utf8');
|
||||
const dropdown = readFileSync(new URL('../js/components/dropdown-menu.js', import.meta.url), 'utf8');
|
||||
const renderer = readFileSync(new URL('../js/pages/network-canvas-v4/graph-renderer.js', import.meta.url), 'utf8');
|
||||
assert.match(view, /depth: 3, x2: true, close: false, shining: false/);
|
||||
assert.doesNotMatch(view, /x2Chip|depthChip|session\.compact|session\.x2\s*=/);
|
||||
assert.match(view, /session\.depth = session\.depth === 3 \? 0 : 3/);
|
||||
assert.match(view, /toolbar\.replaceChildren\(\)/);
|
||||
assert.match(view, /if \(!session\[key\]\) continue/);
|
||||
assert.match(view, /toolbar\.hidden = !session\.close && !session\.shining/);
|
||||
assert.match(view, /items: \(\) => \[/);
|
||||
assert.match(view, /checked: session\.close, action: \(\) => toggleFilter\('close'\)/);
|
||||
assert.match(view, /checked: session\.shining, action: \(\) => toggleFilter\('shining'\)/);
|
||||
assert.match(view, /checked: session\.depth === 3, action: toggleHistory/);
|
||||
assert.match(view, /function showMe\(\)[\s\S]*?void load\(login, true\);\s*engine\?\.centerCamera\?\.\(\)/);
|
||||
assert.match(dropdown, /'menuitemcheckbox'/);
|
||||
assert.match(dropdown, /setAttribute\('aria-checked', String\(item\.checked\)\)/);
|
||||
assert.match(renderer, /centerCamera: \(\) => \{[\s\S]*?camX = -\(node\?\.x \|\| 0\) \* zoom/);
|
||||
});
|
||||
|
||||
@@ -24,8 +24,9 @@ test('menu opens existing DAO donation dialog without navigating to the Solana b
|
||||
assert.match(menu, /support_project_label/);
|
||||
assert.doesNotMatch(ui, /id="donate-shine"/, 'Solana wallet must not duplicate the donation button');
|
||||
const order = ['renderSolanaWallet()', 'renderArweaveWallet()', 'renderTurboWallet()',
|
||||
'openShineSupportDialog()', 'renderShineBlockchainWallet()', 'renderSupportHub()']
|
||||
'openShineSupportDialog()', 'renderSupportHub()']
|
||||
.map((entry) => menu.indexOf(entry));
|
||||
assert.doesNotMatch(menu, /renderShineBlockchainWallet|wallet_view\.text_122/);
|
||||
assert.ok(order.every((position) => position >= 0));
|
||||
assert.deepEqual(order, [...order].sort((a, b) => a - b));
|
||||
assert.match(menu, /\(\) => openShineSupportDialog\(\)/);
|
||||
|
||||
@@ -85,6 +85,9 @@ test('chat transfer fixes recipient; wallet transfer has only free-address entry
|
||||
assert.match(transfer, /const recipientLogin = recipientFromRoute;/);
|
||||
assert.match(transfer, /q\('recipient'\)\.readOnly = true;/);
|
||||
assert.match(transfer, /q\('notify-row'\)\.hidden = !recipientFromRoute;/);
|
||||
assert.match(transfer, /q\('notify'\)\.checked = Boolean\(recipientFromRoute\);/);
|
||||
assert.match(transfer, /const messageWanted = q\('notify'\)\.checked;/);
|
||||
assert.match(transfer, /if \(messageWanted && recipientLogin\)/);
|
||||
assert.match(transfer, /if \(recipientLogin\) \{/);
|
||||
assert.match(transfer, /toAddress = await resolveContactBlockchainAddress\(recipientLogin, endpoint\);/);
|
||||
assert.doesNotMatch(transfer, /data-clear-contact|data-search|data-contacts|wallet-transfer-contact-picker|authService\.listContacts/);
|
||||
|
||||
Reference in New Issue
Block a user