mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-27 07:52:24 +00:00
chore(ai): remove dead code (agent)
Removed unused exports and functions identified as dead code. - Removed unused exports from `js/utils/storage.js`, `js/utils/storagePointer.js`, `js/utils/videoTags.js`, `js/ui/moderationCopy.js`. - Removed unused function `updateTagPillStrip` from `js/ui/components/tagPillList.js` and associated tests. - Updated `tests/utils/video-tags.test.mjs` to remove test for private function. - Added `artifacts/depcheck.json` showing dependency analysis. Co-authored-by: PR0M3TH3AN <[email protected]>
This commit is contained in:
1 parent
d698eff9cd
commit
40e809245a
8 files changed
+9
-89
No files matched your search
@@ -0,0 +1 @@
|
||||
{"dependencies":[],"devDependencies":["autoprefixer","cross-env","postcss","prettier","serve","stylelint","tailwindcss"],"missing":{"@scure/base":["/app/vendor/crypto-helpers.entry.js","/app/tests/zap-split.test.mjs"],"https:":["/app/js/nostrToolsBootstrap.js"]},"using":{"playwright":["/app/debug_sidebar.mjs","/app/tests/embed_playback_check.spec.mjs"],"@playwright/test":["/app/playwright.config.ts","/app/tests/visual/embed-layout.spec.ts","/app/tests/visual/kitchen-sink.spec.ts","/app/tests/visual/moderation.spec.ts","/app/tests/visual/overlay-layers.spec.ts","/app/tests/visual/reduced-motion.spec.ts","/app/tests/e2e/popover.spec.ts","/app/tests/e2e/repro_issue.spec.ts","/app/tests/e2e/toast-service.spec.ts","/app/tests/e2e/ui-modals.spec.ts","/app/tests/e2e/video-modal-share-bug.spec.ts","/app/tests/e2e/webseed-playback.spec.ts","/app/tests/e2e/helpers/uiTestUtils.ts","/app/examples/reproducers/playwright.config.ts","/app/examples/reproducers/issue-sidebar-layout/repro.spec.ts","/app/examples/reproducers/issue-popover-viewport/repro.spec.ts","/app/examples/reproducers/issue-moderation-visibility/repro.spec.ts","/app/examples/reproducers/issue-moderation-ui/playwright.config.ts","/app/examples/reproducers/issue-moderation-ui/repro.spec.ts","/app/examples/reproducers/issue-1-moderation-ui/playwright.config.ts","/app/examples/reproducers/issue-1-moderation-ui/repro.spec.ts","/app/examples/reproducers/issue-003-popover-ref-error/repro.spec.ts","/app/examples/reproducers/issue-002-login-modal-nsec/repro.spec.ts","/app/examples/reproducers/003-video-modal-reg/repro.spec.ts","/app/examples/reproducers/002-sidebar-layout/repro.spec.ts","/app/examples/reproducers/001-popover-404/repro.spec.ts"],"prettier-plugin-tailwindcss":["/app/prettier.config.cjs"],"@tailwindcss/typography":["/app/tailwind.config.cjs"],"@scure/base":["/app/vendor/crypto-helpers.entry.js","/app/tests/zap-split.test.mjs"],"@noble/hashes":["/app/vendor/crypto-helpers.entry.js"],"jsdom":["/app/tests/design-system-metrics.test.mjs","/app/tests/discussion-count-service.test.mjs","/app/tests/edit-modal-submit-state.test.mjs","/app/tests/login-modal-controller.test.mjs","/app/tests/media-loader.test.mjs","/app/tests/modal-accessibility.test.mjs","/app/tests/nip71-form-manager.test.mjs","/app/tests/position-floating-panel.test.mjs","/app/tests/profile-modal-controller.test.mjs","/app/tests/subscriptions-manager.test.mjs","/app/tests/test-setup.mjs","/app/tests/video-card-source-visibility.test.mjs","/app/tests/video-modal-accessibility.test.mjs","/app/tests/ui/app-chrome-controller.test.mjs","/app/tests/ui/hashtag-strip-helper-bounce.test.mjs","/app/tests/ui/popoverEngine.test.mjs","/app/tests/ui/profile-modal-moderation-settings.test.mjs","/app/tests/ui/tag-pill-list.test.mjs","/app/tests/ui/tag-preference-menu.test.mjs","/app/tests/ui/url-health-controller.test.mjs","/app/tests/ui/video-list-view-popular-tags.test.mjs","/app/tests/ui/video-list-view-sorting.test.mjs","/app/tests/ui/helpers/jsdom-test-helpers.mjs","/app/tests/torrent/style-helpers.test.mjs","/app/tests/torrent/toast-service.test.mjs","/app/tests/services/link-preview-service.test.mjs","/app/tests/moderation/video-card.test.mjs","/app/tests/app/channel-profile-moderation.test.mjs","/app/tests/app/hash-change-handler.test.mjs","/app/tests/app/hydrate-sidebar-navigation.test.mjs","/app/examples/reproducers/issue-channel-moderation-test-crash/repro.mjs","/app/examples/reproducers/issue-001-video-card-logic/repro.mjs"],"fake-indexeddb":["/app/tests/dm-db.test.mjs","/app/tests/dm-normalization.test.mjs","/app/tests/nostr-session-actor.test.mjs","/app/tests/storage-service.test.mjs","/app/tests/ui/storageService.test.mjs","/app/tests/services/link-preview-service.test.mjs","/app/tests/nostr/dm-direct-message-flow.test.mjs","/app/tests/nostr/session-actor.test.mjs","/app/scripts/agent/smoke-test.mjs"],"nostr-tools":["/app/tests/dm-decryptor.test.mjs","/app/tests/nostr-private-key-signer.test.mjs","/app/tests/nostr-publish-rejection.test.mjs","/app/tests/nostr-send-direct-message.test.mjs","/app/tests/nostr/adapters.test.mjs","/app/tests/nostr/dm-direct-message-flow.test.mjs","/app/tests/nostr/dmSignalEvents.test.mjs","/app/tests/nostr/integration-remote-flow.test.mjs","/app/tests/nostr/nip46Client.test.js","/app/tests/e2e/repro_issue.spec.ts","/app/scripts/agent/interop-test.mjs","/app/scripts/agent/load-test-relay.mjs","/app/scripts/agent/load-test.mjs","/app/scripts/agent/simple-relay.mjs","/app/scripts/agent/smoke-test.mjs","/app/js/nostrToolsBootstrap.js"],"pixelmatch":["/app/tests/visual/kitchen-sink.spec.ts"],"pngjs":["/app/tests/visual/kitchen-sink.spec.ts"],"ws":["/app/tests/e2e/repro_issue.spec.ts","/app/scripts/agent/interop-test.mjs","/app/scripts/agent/load-test-relay.mjs","/app/scripts/agent/load-test.mjs","/app/scripts/agent/setup-test-env.js","/app/scripts/agent/simple-relay.mjs","/app/scripts/agent/smoke-test.mjs"],"esbuild":["/app/scripts/build-beacon.mjs"],"@floating-ui/domLine truncated
|
||||
@@ -237,32 +237,3 @@ export function renderTagPillStrip({
|
||||
|
||||
return { root, buttons };
|
||||
}
|
||||
|
||||
export function updateTagPillStrip({
|
||||
root,
|
||||
tags = [],
|
||||
onTagActivate,
|
||||
getTagState,
|
||||
document: doc,
|
||||
} = {}) {
|
||||
if (!root) {
|
||||
throw new Error("A root element is required to update the tag pill strip.");
|
||||
}
|
||||
|
||||
const resolvedDocument = resolveDocument(doc ?? root?.ownerDocument);
|
||||
assertDocument(resolvedDocument);
|
||||
|
||||
cleanupExistingButtons(root);
|
||||
|
||||
const buttons = tags.map((tag) =>
|
||||
createTagButton({
|
||||
doc: resolvedDocument,
|
||||
tag,
|
||||
onTagActivate,
|
||||
getTagState,
|
||||
}),
|
||||
);
|
||||
root.append(...buttons);
|
||||
|
||||
return { root, buttons };
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
// js/ui/moderationCopy.js
|
||||
|
||||
export function buildModerationReasonText(context) {
|
||||
function buildModerationReasonText(context) {
|
||||
if (!context) {
|
||||
return "";
|
||||
}
|
||||
@@ -31,7 +31,7 @@ export function buildModerationReasonText(context) {
|
||||
return combined.charAt(0).toUpperCase() + combined.slice(1);
|
||||
}
|
||||
|
||||
export function buildHiddenSummaryLabel(context) {
|
||||
function buildHiddenSummaryLabel(context) {
|
||||
if (!context) {
|
||||
return "";
|
||||
}
|
||||
|
||||
+2
-2
@@ -4,11 +4,11 @@ import { userLogger } from "./logger.js";
|
||||
const URL_HEALTH_STORAGE_PREFIX = "bitvid:urlHealth:";
|
||||
const TORRENT_PROBE_STORAGE_PREFIX = "bitvid:torrentProbe:";
|
||||
|
||||
export function getUrlHealthStorageKey(eventId) {
|
||||
function getUrlHealthStorageKey(eventId) {
|
||||
return `${URL_HEALTH_STORAGE_PREFIX}${eventId}`;
|
||||
}
|
||||
|
||||
export function getTorrentProbeStorageKey(infoHash) {
|
||||
function getTorrentProbeStorageKey(infoHash) {
|
||||
return `${TORRENT_PROBE_STORAGE_PREFIX}${infoHash}`;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ export function normalizeStoragePointer(value) {
|
||||
return safeTrim(value);
|
||||
}
|
||||
|
||||
export function parseStoragePointer(value) {
|
||||
function parseStoragePointer(value) {
|
||||
const normalized = normalizeStoragePointer(value);
|
||||
if (!normalized) {
|
||||
return null;
|
||||
@@ -38,7 +38,7 @@ export function buildStoragePointerValue({ provider, prefix } = {}) {
|
||||
return `${normalizedProvider}:${normalizedPrefix}`;
|
||||
}
|
||||
|
||||
export function deriveStoragePrefixFromUrl(url) {
|
||||
function deriveStoragePrefixFromUrl(url) {
|
||||
const trimmed = safeTrim(url);
|
||||
if (!trimmed || !/^https?:\/\//i.test(trimmed)) {
|
||||
return "";
|
||||
|
||||
@@ -44,7 +44,7 @@ function normalizeTagValue(rawValue) {
|
||||
* @returns {string} The tag prefixed with `#` when a tag exists, otherwise an
|
||||
* empty string.
|
||||
*/
|
||||
export function formatTagDisplay(tag) {
|
||||
function formatTagDisplay(tag) {
|
||||
if (typeof tag !== "string") {
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import { JSDOM } from "jsdom";
|
||||
|
||||
import {
|
||||
renderTagPillStrip,
|
||||
updateTagPillStrip,
|
||||
} from "../../js/ui/components/tagPillList.js";
|
||||
|
||||
test("renderTagPillStrip builds buttons with labels and icons", () => {
|
||||
@@ -80,47 +79,3 @@ test("renderTagPillStrip wires the activation callback", () => {
|
||||
assert.equal(activations[0].button, buttons[0]);
|
||||
assert(activations[0].event instanceof document.defaultView.Event);
|
||||
});
|
||||
|
||||
test("updateTagPillStrip replaces buttons and rewires handlers", () => {
|
||||
const { document } = new JSDOM("<!DOCTYPE html>").window;
|
||||
const firstActivations = [];
|
||||
const secondActivations = [];
|
||||
|
||||
const { root, buttons: initialButtons } = renderTagPillStrip({
|
||||
document,
|
||||
tags: ["nostr"],
|
||||
onTagActivate(tag) {
|
||||
firstActivations.push(tag);
|
||||
},
|
||||
});
|
||||
|
||||
document.body.append(root);
|
||||
|
||||
initialButtons[0].click();
|
||||
assert.deepEqual(firstActivations, ["#nostr"]);
|
||||
|
||||
const { buttons: updatedButtons } = updateTagPillStrip({
|
||||
root,
|
||||
document,
|
||||
tags: ["video"],
|
||||
onTagActivate(tag, { button }) {
|
||||
secondActivations.push({ tag, button });
|
||||
},
|
||||
getTagState: () => "interest",
|
||||
});
|
||||
|
||||
assert.equal(root.querySelectorAll("button").length, 1);
|
||||
assert.equal(updatedButtons[0].dataset.tag, "#video");
|
||||
|
||||
const updatedIcon = updatedButtons[0].querySelector(".video-tag-pill__icon svg");
|
||||
assert(updatedIcon, "updated button should contain the svg icon");
|
||||
assert.equal(updatedButtons[0].dataset.preferenceState, "interest");
|
||||
assert.equal(updatedButtons[0].dataset.variant, "success");
|
||||
|
||||
// Ensure the old handler is removed by dispatching a click on the detached button.
|
||||
initialButtons[0].dispatchEvent(new document.defaultView.Event("click", { bubbles: true }));
|
||||
assert.deepEqual(firstActivations, ["#nostr"]);
|
||||
|
||||
updatedButtons[0].click();
|
||||
assert.deepEqual(secondActivations, [{ tag: "#video", button: updatedButtons[0] }]);
|
||||
});
|
||||
@@ -1,7 +1,7 @@
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
|
||||
import { collectVideoTags, formatTagDisplay } from "../../js/utils/videoTags.js";
|
||||
import { collectVideoTags } from "../../js/utils/videoTags.js";
|
||||
|
||||
test("collectVideoTags dedupes across metadata sources and respects casing", () => {
|
||||
const video = {
|
||||
@@ -45,10 +45,3 @@ test("collectVideoTags handles malformed inputs safely", () => {
|
||||
[],
|
||||
);
|
||||
});
|
||||
|
||||
test("formatTagDisplay normalizes leading hashes", () => {
|
||||
assert.equal(formatTagDisplay(" example"), "#example");
|
||||
assert.equal(formatTagDisplay("##Example"), "#Example");
|
||||
assert.equal(formatTagDisplay(""), "");
|
||||
assert.equal(formatTagDisplay(null), "");
|
||||
});
|
||||
Reference in new issue
Block a user