thurview 0.5.1 → 0.6.0

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/dist/ui/app.js CHANGED
@@ -1067,6 +1067,7 @@
1067
1067
  );
1068
1068
  return;
1069
1069
  }
1070
+ root.appendChild(interfaceDelta(doc.interfaces));
1070
1071
  const layout = h("div", { class: "doc-layout" });
1071
1072
  const toc = h(
1072
1073
  "nav",
@@ -1138,6 +1139,102 @@
1138
1139
  );
1139
1140
  docEl.querySelectorAll(".block.heading").forEach((el) => io.observe(el));
1140
1141
  }
1142
+ var DELTA_BLOCK = "interface-delta";
1143
+ var DELTA_SHOWN = 12;
1144
+ var CHANGE_CLASS = {
1145
+ removed: "del",
1146
+ changed: "warn",
1147
+ added: "ok"
1148
+ };
1149
+ function interfaceDelta(delta) {
1150
+ const wrap = h("div", { class: "block ifd", "data-block": DELTA_BLOCK });
1151
+ const threads = threadsFor((t) => t.type === "document" && t.blockId === DELTA_BLOCK);
1152
+ if (threads.length) wrap.classList.add("has-threads");
1153
+ const actions = h(
1154
+ "div",
1155
+ { class: "block-actions" },
1156
+ h(
1157
+ "button",
1158
+ {
1159
+ class: threads.length ? "count" : "",
1160
+ title: "Comment on the interface delta",
1161
+ onclick: (e) => {
1162
+ if (state.viewingRevision !== null) return;
1163
+ popover(commentPopover({ type: "document", blockId: DELTA_BLOCK }), {
1164
+ x: e.pageX + 10,
1165
+ y: e.pageY
1166
+ });
1167
+ }
1168
+ },
1169
+ threads.length ? String(threads.length) : "+"
1170
+ )
1171
+ );
1172
+ const body = h("div", { class: "ifd-body" });
1173
+ const toggle = h("span", { class: "heading-toggle" }, "hide");
1174
+ toggle.addEventListener("click", () => {
1175
+ const hidden = body.hidden;
1176
+ body.hidden = !hidden;
1177
+ toggle.textContent = hidden ? "hide" : "show";
1178
+ });
1179
+ const counts = delta ? ["removed", "changed", "added"].map((c) => [c, delta.entries.filter((e) => e.change === c).length]).filter(([, n]) => n > 0) : [];
1180
+ wrap.appendChild(
1181
+ h(
1182
+ "div",
1183
+ { class: "ifd-head" },
1184
+ h("span", { class: "t" }, "Interface delta"),
1185
+ counts.map(([c, n]) => h("span", { class: `badge ${CHANGE_CLASS[c]}` }, `${n} ${c}`)),
1186
+ h("span", { class: "spacer" }),
1187
+ toggle,
1188
+ actions
1189
+ )
1190
+ );
1191
+ body.appendChild(
1192
+ h(
1193
+ "p",
1194
+ { class: "ifd-verdict" },
1195
+ delta ? delta.verdict : "Unavailable: the code graph could not be built for these commits."
1196
+ )
1197
+ );
1198
+ const entries = delta?.entries ?? [];
1199
+ const rest = entries.slice(DELTA_SHOWN);
1200
+ for (const e of entries.slice(0, DELTA_SHOWN)) body.appendChild(interfaceRow(e));
1201
+ if (rest.length) {
1202
+ const more = h(
1203
+ "button",
1204
+ {
1205
+ class: "small ghost",
1206
+ onclick: () => {
1207
+ more.replaceWith(...rest.map(interfaceRow));
1208
+ }
1209
+ },
1210
+ `show ${rest.length} more`
1211
+ );
1212
+ body.appendChild(more);
1213
+ }
1214
+ wrap.appendChild(body);
1215
+ if (threads.length)
1216
+ wrap.appendChild(h("div", { class: "thread-pins" }, threads.map(threadPinRow)));
1217
+ return wrap;
1218
+ }
1219
+ function interfaceRow(e) {
1220
+ return h(
1221
+ "div",
1222
+ {
1223
+ class: `ifd-entry ifd-${e.change}`,
1224
+ title: "Open in Files",
1225
+ onclick: () => navigate("files", { path: e.file, line: e.line, side: e.graph })
1226
+ },
1227
+ h("span", { class: `badge ${CHANGE_CLASS[e.change]}` }, e.change),
1228
+ h(
1229
+ "div",
1230
+ { class: "ifd-what" },
1231
+ e.was ? h("div", { class: "ifd-was" }, h("code", null, e.was)) : null,
1232
+ h("code", { class: "ifd-name" }, e.name),
1233
+ e.capability ? h("div", { class: "ifd-cap" }, e.capability) : null
1234
+ ),
1235
+ h("span", { class: "ifd-where mono" }, `${e.file}:${e.line}`)
1236
+ );
1237
+ }
1141
1238
  function scrollToBlock(id) {
1142
1239
  const el = document.querySelector(`[data-block="${id}"]`);
1143
1240
  if (!el) return;