@d86e/hive-panel 1.0.17 → 1.0.18
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/package.json +1 -1
- package/public/panel.js +173 -14
package/package.json
CHANGED
package/public/panel.js
CHANGED
|
@@ -4122,6 +4122,8 @@ export function mount(root, options = {}) {
|
|
|
4122
4122
|
initialized: false,
|
|
4123
4123
|
paged: false,
|
|
4124
4124
|
signature: "",
|
|
4125
|
+
expanded: new Set(),
|
|
4126
|
+
rowNodes: new Map(),
|
|
4125
4127
|
};
|
|
4126
4128
|
let initBusy = false;
|
|
4127
4129
|
let initOutput = null;
|
|
@@ -4375,6 +4377,8 @@ export function mount(root, options = {}) {
|
|
|
4375
4377
|
eventState.total = 0;
|
|
4376
4378
|
eventState.recycled = 0;
|
|
4377
4379
|
eventState.signature = "";
|
|
4380
|
+
eventState.expanded.clear();
|
|
4381
|
+
eventState.rowNodes.clear();
|
|
4378
4382
|
eventsList.scrollTop = 0;
|
|
4379
4383
|
void loadEventPage(true);
|
|
4380
4384
|
});
|
|
@@ -8026,36 +8030,189 @@ function renderMarkdownInto(doc, host, source) {
|
|
|
8026
8030
|
return eventClock(event.ts) + " · " + eventActor(event) + " · " + action;
|
|
8027
8031
|
}
|
|
8028
8032
|
|
|
8033
|
+
function eventRowHeight(row) {
|
|
8034
|
+
if (typeof row.getBoundingClientRect === "function") {
|
|
8035
|
+
const rect = row.getBoundingClientRect();
|
|
8036
|
+
if (rect && Number(rect.height) > 0) return Number(rect.height);
|
|
8037
|
+
}
|
|
8038
|
+
return 28;
|
|
8039
|
+
}
|
|
8040
|
+
|
|
8041
|
+
function eventRowViewportOffset(row) {
|
|
8042
|
+
if (typeof row.getBoundingClientRect === "function") {
|
|
8043
|
+
const rowRect = row.getBoundingClientRect();
|
|
8044
|
+
const listRect = typeof eventsList.getBoundingClientRect === "function"
|
|
8045
|
+
? eventsList.getBoundingClientRect()
|
|
8046
|
+
: null;
|
|
8047
|
+
if (rowRect && listRect && Number.isFinite(Number(rowRect.top)) && Number.isFinite(Number(listRect.top))) {
|
|
8048
|
+
return Number(rowRect.top) - Number(listRect.top);
|
|
8049
|
+
}
|
|
8050
|
+
}
|
|
8051
|
+
const index = (eventsList.children || []).indexOf(row);
|
|
8052
|
+
if (Number.isFinite(Number(row.offsetTop))) return Number(row.offsetTop) - (Number(eventsList.scrollTop) || 0);
|
|
8053
|
+
return index * 28 - (Number(eventsList.scrollTop) || 0);
|
|
8054
|
+
}
|
|
8055
|
+
|
|
8056
|
+
function captureEventAnchor() {
|
|
8057
|
+
if ((Number(eventsList.scrollTop) || 0) <= 0) return { atTop: true, scrollTop: 0 };
|
|
8058
|
+
const rows = [...eventState.rowNodes.values()].filter((entry) => entry.row.parentNode === eventsList);
|
|
8059
|
+
rows.sort((left, right) => eventRowViewportOffset(left.row) - eventRowViewportOffset(right.row));
|
|
8060
|
+
for (const entry of rows) {
|
|
8061
|
+
const offset = eventRowViewportOffset(entry.row);
|
|
8062
|
+
if (offset + eventRowHeight(entry.row) > 0) {
|
|
8063
|
+
return {
|
|
8064
|
+
atTop: false,
|
|
8065
|
+
key: entry.key,
|
|
8066
|
+
offset,
|
|
8067
|
+
scrollTop: Number(eventsList.scrollTop) || 0,
|
|
8068
|
+
};
|
|
8069
|
+
}
|
|
8070
|
+
}
|
|
8071
|
+
return { atTop: false, key: null, offset: 0, scrollTop: Number(eventsList.scrollTop) || 0 };
|
|
8072
|
+
}
|
|
8073
|
+
|
|
8074
|
+
function restoreEventAnchor(anchor) {
|
|
8075
|
+
if (!anchor) return;
|
|
8076
|
+
if (anchor.atTop) {
|
|
8077
|
+
eventsList.scrollTop = 0;
|
|
8078
|
+
return;
|
|
8079
|
+
}
|
|
8080
|
+
if (!anchor.key) {
|
|
8081
|
+
eventsList.scrollTop = anchor.scrollTop;
|
|
8082
|
+
return;
|
|
8083
|
+
}
|
|
8084
|
+
const entry = eventState.rowNodes.get(anchor.key);
|
|
8085
|
+
if (!entry || entry.row.parentNode !== eventsList) {
|
|
8086
|
+
eventsList.scrollTop = anchor.scrollTop;
|
|
8087
|
+
return;
|
|
8088
|
+
}
|
|
8089
|
+
let contentTop = null;
|
|
8090
|
+
if (typeof entry.row.getBoundingClientRect === "function") {
|
|
8091
|
+
const rowRect = entry.row.getBoundingClientRect();
|
|
8092
|
+
const listRect = typeof eventsList.getBoundingClientRect === "function"
|
|
8093
|
+
? eventsList.getBoundingClientRect()
|
|
8094
|
+
: null;
|
|
8095
|
+
if (rowRect && listRect && Number.isFinite(Number(rowRect.top)) && Number.isFinite(Number(listRect.top))) {
|
|
8096
|
+
contentTop = Number(rowRect.top) - Number(listRect.top) + (Number(eventsList.scrollTop) || 0);
|
|
8097
|
+
}
|
|
8098
|
+
}
|
|
8099
|
+
if (contentTop === null && Number.isFinite(Number(entry.row.offsetTop))) contentTop = Number(entry.row.offsetTop);
|
|
8100
|
+
if (contentTop === null) {
|
|
8101
|
+
const index = (eventsList.children || []).indexOf(entry.row);
|
|
8102
|
+
contentTop = index * 28;
|
|
8103
|
+
}
|
|
8104
|
+
eventsList.scrollTop = Math.max(0, contentTop - anchor.offset);
|
|
8105
|
+
}
|
|
8106
|
+
|
|
8107
|
+
function insertEventRow(row, before) {
|
|
8108
|
+
if (row.parentNode) {
|
|
8109
|
+
const current = row.parentNode.children ? row.parentNode.children.indexOf(row) : -1;
|
|
8110
|
+
if (current >= 0) row.parentNode.children.splice(current, 1);
|
|
8111
|
+
row.parentNode = null;
|
|
8112
|
+
}
|
|
8113
|
+
if (before) {
|
|
8114
|
+
if (typeof eventsList.insertBefore === "function") {
|
|
8115
|
+
eventsList.insertBefore(row, before);
|
|
8116
|
+
return;
|
|
8117
|
+
}
|
|
8118
|
+
const index = eventsList.children.indexOf(before);
|
|
8119
|
+
if (index >= 0) {
|
|
8120
|
+
row.parentNode = eventsList;
|
|
8121
|
+
eventsList.children.splice(index, 0, row);
|
|
8122
|
+
return;
|
|
8123
|
+
}
|
|
8124
|
+
}
|
|
8125
|
+
eventsList.appendChild(row);
|
|
8126
|
+
}
|
|
8127
|
+
|
|
8128
|
+
function eventRowNext(row) {
|
|
8129
|
+
const index = (eventsList.children || []).indexOf(row);
|
|
8130
|
+
return index >= 0 ? eventsList.children[index + 1] || null : null;
|
|
8131
|
+
}
|
|
8132
|
+
|
|
8133
|
+
function eventKey(event) {
|
|
8134
|
+
const raw = event.raw || {};
|
|
8135
|
+
const ref = raw.task || raw.card || raw.cardId || raw.id || event.task || "";
|
|
8136
|
+
return [event.ts, event.kind, event.actor || raw.actor || "", ref].join("|");
|
|
8137
|
+
}
|
|
8138
|
+
|
|
8139
|
+
function createEventRow(event) {
|
|
8140
|
+
const key = eventKey(event);
|
|
8141
|
+
const row = element(doc, "div", "hive-event");
|
|
8142
|
+
row.appendChild(element(doc, "span", "hive-event-sentence", eventSentence(event)));
|
|
8143
|
+
const details = element(doc, "details", "hive-event-raw");
|
|
8144
|
+
details.appendChild(element(doc, "summary", "hive-event-summary", translate("events.details")));
|
|
8145
|
+
details.appendChild(
|
|
8146
|
+
element(doc, "pre", "hive-json hive-event-json", JSON.stringify(event.raw || event, null, 2)),
|
|
8147
|
+
);
|
|
8148
|
+
if (eventState.expanded.has(key)) {
|
|
8149
|
+
details.open = true;
|
|
8150
|
+
setAttr(details, "open", "");
|
|
8151
|
+
}
|
|
8152
|
+
details.addEventListener("toggle", () => {
|
|
8153
|
+
if (details.open) eventState.expanded.add(key);
|
|
8154
|
+
else eventState.expanded.delete(key);
|
|
8155
|
+
});
|
|
8156
|
+
row.appendChild(details);
|
|
8157
|
+
return { row, details, key };
|
|
8158
|
+
}
|
|
8159
|
+
|
|
8029
8160
|
function renderEventRows() {
|
|
8030
8161
|
const signature =
|
|
8031
8162
|
eventState.filter +
|
|
8032
8163
|
"|" + String(eventState.items.length) +
|
|
8033
8164
|
"|" + String(eventState.recycled) +
|
|
8165
|
+
"|" + String(eventState.error ? 1 : 0) +
|
|
8034
8166
|
"|" + (eventState.items[0] ? eventState.items[0].ts : "") +
|
|
8035
8167
|
"|" + (eventState.items[eventState.items.length - 1] ? eventState.items[eventState.items.length - 1].ts : "");
|
|
8036
8168
|
if (signature === eventState.signature) return;
|
|
8037
8169
|
eventState.signature = signature;
|
|
8038
|
-
|
|
8170
|
+
const anchor = captureEventAnchor();
|
|
8171
|
+
const keptTop = Number(eventsList.scrollTop) || 0;
|
|
8172
|
+
|
|
8039
8173
|
if (eventState.error) {
|
|
8174
|
+
eventState.rowNodes.clear();
|
|
8175
|
+
clearNode(eventsList);
|
|
8040
8176
|
eventsList.appendChild(element(doc, "div", "hive-event-error", eventState.error));
|
|
8177
|
+
eventsList.scrollTop = keptTop;
|
|
8041
8178
|
return;
|
|
8042
8179
|
}
|
|
8043
8180
|
if (eventState.items.length === 0) {
|
|
8181
|
+
eventState.rowNodes.clear();
|
|
8182
|
+
clearNode(eventsList);
|
|
8044
8183
|
eventsList.appendChild(emptyState(translate("events.empty")));
|
|
8184
|
+
eventsList.scrollTop = keptTop;
|
|
8045
8185
|
return;
|
|
8046
8186
|
}
|
|
8047
|
-
|
|
8048
|
-
|
|
8049
|
-
|
|
8050
|
-
|
|
8051
|
-
|
|
8052
|
-
|
|
8053
|
-
|
|
8054
|
-
|
|
8055
|
-
|
|
8056
|
-
|
|
8057
|
-
|
|
8187
|
+
|
|
8188
|
+
const mappedRows = new Set([...eventState.rowNodes.values()].map((entry) => entry.row));
|
|
8189
|
+
for (const child of [...(eventsList.children || [])]) {
|
|
8190
|
+
if (String(child.className).split(/\s+/).includes("hive-event") && !mappedRows.has(child)) {
|
|
8191
|
+
eventsList.removeChild(child);
|
|
8192
|
+
}
|
|
8193
|
+
}
|
|
8194
|
+
const desired = new Set(eventState.items.map((event) => eventKey(event)));
|
|
8195
|
+
for (const [key, entry] of eventState.rowNodes) {
|
|
8196
|
+
if (desired.has(key)) continue;
|
|
8197
|
+
if (entry.row.parentNode) entry.row.parentNode.removeChild(entry.row);
|
|
8198
|
+
eventState.rowNodes.delete(key);
|
|
8199
|
+
}
|
|
8200
|
+
|
|
8201
|
+
let cursor = null;
|
|
8202
|
+
for (let index = eventState.items.length - 1; index >= 0; index -= 1) {
|
|
8203
|
+
const event = eventState.items[index];
|
|
8204
|
+
const key = eventKey(event);
|
|
8205
|
+
let entry = eventState.rowNodes.get(key);
|
|
8206
|
+
if (!entry) {
|
|
8207
|
+
entry = createEventRow(event);
|
|
8208
|
+
eventState.rowNodes.set(key, entry);
|
|
8209
|
+
}
|
|
8210
|
+
if (entry.row.parentNode !== eventsList || eventRowNext(entry.row) !== cursor) {
|
|
8211
|
+
insertEventRow(entry.row, cursor);
|
|
8212
|
+
}
|
|
8213
|
+
cursor = entry.row;
|
|
8058
8214
|
}
|
|
8215
|
+
restoreEventAnchor(anchor);
|
|
8059
8216
|
}
|
|
8060
8217
|
|
|
8061
8218
|
function maybeLoadEventPage() {
|
|
@@ -8071,7 +8228,6 @@ function renderMarkdownInto(doc, host, source) {
|
|
|
8071
8228
|
eventState.loading = true;
|
|
8072
8229
|
eventState.error = "";
|
|
8073
8230
|
eventState.paged = true;
|
|
8074
|
-
const beforeTop = Number(eventsList.scrollTop) || 0;
|
|
8075
8231
|
const cursor = reset ? 0 : eventState.cursor;
|
|
8076
8232
|
try {
|
|
8077
8233
|
const response = await fetchImpl(eventPageUrl(cursor), {
|
|
@@ -8099,7 +8255,6 @@ function renderMarkdownInto(doc, host, source) {
|
|
|
8099
8255
|
eventState.total = total;
|
|
8100
8256
|
eventState.signature = "";
|
|
8101
8257
|
if (!destroyed && lastModel) renderEvents(lastModel);
|
|
8102
|
-
if (!reset) eventsList.scrollTop = beforeTop;
|
|
8103
8258
|
} catch (error) {
|
|
8104
8259
|
eventState.error = translate("events.loadFailed");
|
|
8105
8260
|
reportError(error);
|
|
@@ -8116,6 +8271,8 @@ function renderMarkdownInto(doc, host, source) {
|
|
|
8116
8271
|
eventState.initialized = false;
|
|
8117
8272
|
eventState.items = [];
|
|
8118
8273
|
eventState.signature = "";
|
|
8274
|
+
eventState.expanded.clear();
|
|
8275
|
+
eventState.rowNodes.clear();
|
|
8119
8276
|
eventsCount.textContent = "0";
|
|
8120
8277
|
clearNode(eventsFilter);
|
|
8121
8278
|
eventsRecycle.className = "hive-events-recycle is-hidden";
|
|
@@ -8194,6 +8351,8 @@ function renderMarkdownInto(doc, host, source) {
|
|
|
8194
8351
|
eventState.error = "";
|
|
8195
8352
|
eventState.paged = false;
|
|
8196
8353
|
eventState.signature = "";
|
|
8354
|
+
eventState.expanded.clear();
|
|
8355
|
+
eventState.rowNodes.clear();
|
|
8197
8356
|
eventsList.scrollTop = 0;
|
|
8198
8357
|
planTriggerButton = null;
|
|
8199
8358
|
closeHelp(false);
|