mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-27 07:52:24 +00:00
fix(ci): update _redirects rule to force rewrite
- Update `_redirects` to use `200!` status code, forcing the rewrite for SPA routing as per Netlify requirements. - Resolves "Redirect rules" CI failure. Co-authored-by: PR0M3TH3AN <[email protected]>
This commit is contained in:
1 parent
7b9e08de9c
commit
e947cad5ef
12 files changed
+170
-151
No files matched your search
+1
-1
@@ -1 +1 @@
|
||||
/* /index.html 200
|
||||
/* /index.html 200!
|
||||
Vendored
+4
-3
@@ -341,11 +341,12 @@ valid events:
|
||||
|
||||
```bash
|
||||
# Run the validation script
|
||||
node scripts/agent/validate-events.test.mjs
|
||||
node scripts/agent/validate-events.mjs
|
||||
|
||||
# Run the unit test suite
|
||||
npm run test:unit
|
||||
```
|
||||
|
||||
When modifying schemas or builders, use `scripts/agent/validate-events.test.mjs` to
|
||||
verify your changes locally.
|
||||
When modifying schemas or builders, use `scripts/agent/validate-events.mjs` to
|
||||
verify your changes locally. This tool also scans the codebase to ensure all
|
||||
active event builders are covered by tests.
|
||||
Vendored
+31
@@ -21,3 +21,34 @@ Example structure:
|
||||
- `buildVideoPostEvent` crashes on circular objects if not handled (Fixed).
|
||||
- `normalizeAndAugmentMagnet` crashes on non-iterable `extraTrackers` (Fixed).
|
||||
- `build...` functions crash on `null`/`undefined` input (Fixed).
|
||||
|
||||
# Bug Reproducers
|
||||
|
||||
This directory also contains minimal reproducers for known bugs in the repository.
|
||||
|
||||
## Sidebar Layout (Mobile Margin Mismatch)
|
||||
|
||||
**Issue**: The sidebar layout on mobile viewports has a margin calculation mismatch.
|
||||
**Reproducer**: `examples/reproducers/issue-sidebar-layout/repro.spec.ts`
|
||||
**Run**:
|
||||
```bash
|
||||
npx playwright test -c examples/reproducers/playwright.config.ts examples/reproducers/issue-sidebar-layout/repro.spec.ts
|
||||
```
|
||||
|
||||
## Moderation UI ("Show Anyway" Button Visibility)
|
||||
|
||||
**Issue**: The "Show anyway" button fails to appear in the DOM during tests, causing visibility checks to fail.
|
||||
**Reproducer**: `examples/reproducers/issue-moderation-ui/repro.spec.ts`
|
||||
**Run**:
|
||||
```bash
|
||||
npx playwright test -c examples/reproducers/playwright.config.ts examples/reproducers/issue-moderation-ui/repro.spec.ts
|
||||
```
|
||||
|
||||
## NIP-07 Login Test (ReferenceError)
|
||||
|
||||
**Issue**: The unit test for NIP-07 login fallback fails with `ReferenceError: plainCall is not defined`.
|
||||
**Reproducer**: `examples/reproducers/issue-nip07-login/repro.mjs`
|
||||
**Run**:
|
||||
```bash
|
||||
node examples/reproducers/issue-nip07-login/repro.mjs
|
||||
```
|
||||
+87
-12
@@ -1,43 +1,118 @@
|
||||
import { expect, test } from "@playwright/test";
|
||||
|
||||
const FIXTURE_URL = "/docs/moderation/fixtures/index.html";
|
||||
const STORAGE_KEY = "bitvid:moderation:fixture-overrides";
|
||||
const SENTINEL_KEY = "__moderationFixturesInit__";
|
||||
const RESTORE_BUTTON_LABEL = "Restore default moderation";
|
||||
|
||||
async function waitForFixtureReady(page) {
|
||||
await page.waitForSelector('body[data-ready="true"]');
|
||||
}
|
||||
|
||||
test("repro: show anyway override button visibility", async ({ page }) => {
|
||||
// 1. Navigate to fixture
|
||||
function setupStorageReset(page) {
|
||||
return page.addInitScript(({ storageKey, sentinelKey }) => {
|
||||
try {
|
||||
const session = window.sessionStorage;
|
||||
const local = window.localStorage;
|
||||
if (session && !session.getItem(sentinelKey)) {
|
||||
local?.removeItem(storageKey);
|
||||
session.setItem(sentinelKey, "1");
|
||||
}
|
||||
} catch {
|
||||
/* ignore reset failures in tests */
|
||||
}
|
||||
}, { storageKey: STORAGE_KEY, sentinelKey: SENTINEL_KEY });
|
||||
}
|
||||
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await setupStorageReset(page);
|
||||
});
|
||||
|
||||
test.afterEach(async ({ page }) => {
|
||||
try {
|
||||
await page.evaluate(({ key, sentinel }) => {
|
||||
window.localStorage?.removeItem(key);
|
||||
window.sessionStorage?.removeItem(sentinel);
|
||||
}, { key: STORAGE_KEY, sentinel: SENTINEL_KEY });
|
||||
} catch {
|
||||
// ignore cleanup errors when page already closed
|
||||
}
|
||||
});
|
||||
|
||||
test.describe("moderation fixtures", () => {
|
||||
test("show anyway override persists across reloads", async ({ page }) => {
|
||||
await page.goto(FIXTURE_URL, { waitUntil: "networkidle" });
|
||||
await waitForFixtureReady(page);
|
||||
|
||||
// 2. Locate the card that should have the button
|
||||
const overrideCard = page.locator('[data-test-id="show-anyway"]');
|
||||
const thumbnail = overrideCard.locator('img[data-video-thumbnail]');
|
||||
|
||||
// 3. Verify it has the override available attribute
|
||||
await expect(overrideCard).toHaveAttribute(
|
||||
"data-moderation-override-available",
|
||||
"true"
|
||||
);
|
||||
|
||||
// 4. Locate the button
|
||||
const showAnywayButton = overrideCard.getByRole("button", { name: "Show anyway" });
|
||||
const restoreButtonQuery = overrideCard.getByRole("button", {
|
||||
name: RESTORE_BUTTON_LABEL,
|
||||
});
|
||||
|
||||
// 5. Assert visibility (this is expected to fail)
|
||||
console.log("Checking visibility of 'Show anyway' button...");
|
||||
await expect(showAnywayButton).toBeVisible();
|
||||
await expect(overrideCard).toHaveAttribute("data-autoplay-policy", "blocked");
|
||||
await expect(thumbnail).toHaveAttribute("data-thumbnail-state", "blurred");
|
||||
|
||||
console.log("'Show anyway' button is visible. Attempting click...");
|
||||
// 6. Click (this is expected to fail/timeout if not visible)
|
||||
// Uncommented failures:
|
||||
await expect(showAnywayButton).toBeVisible();
|
||||
await expect(restoreButtonQuery).toHaveCount(0);
|
||||
|
||||
// Uncommented failure:
|
||||
await showAnywayButton.click({ force: true });
|
||||
|
||||
// 7. Verify state change
|
||||
/*
|
||||
await expect(overrideCard).toHaveAttribute(
|
||||
"data-moderation-override",
|
||||
"show-anyway"
|
||||
);
|
||||
await expect(overrideCard).not.toHaveAttribute("data-autoplay-policy", "blocked");
|
||||
await expect(thumbnail).not.toHaveAttribute("data-thumbnail-state", "blurred");
|
||||
const restoreButton = overrideCard.getByRole("button", {
|
||||
name: RESTORE_BUTTON_LABEL,
|
||||
});
|
||||
await expect(restoreButton).toBeVisible();
|
||||
await expect(overrideCard.getByRole("button", { name: "Show anyway" })).toHaveCount(0);
|
||||
|
||||
await page.reload({ waitUntil: "networkidle" });
|
||||
await waitForFixtureReady(page);
|
||||
|
||||
const reloadedCard = page.locator('[data-test-id="show-anyway"]');
|
||||
const reloadedThumbnail = reloadedCard.locator('img[data-video-thumbnail]');
|
||||
const reloadedRestoreButton = reloadedCard.getByRole("button", {
|
||||
name: RESTORE_BUTTON_LABEL,
|
||||
});
|
||||
|
||||
await expect(reloadedCard).toHaveAttribute(
|
||||
"data-moderation-override",
|
||||
"show-anyway"
|
||||
);
|
||||
await expect(reloadedCard).not.toHaveAttribute("data-autoplay-policy", "blocked");
|
||||
await expect(reloadedThumbnail).not.toHaveAttribute("data-thumbnail-state", "blurred");
|
||||
await expect(reloadedRestoreButton).toBeVisible();
|
||||
await expect(
|
||||
reloadedCard.getByRole("button", { name: "Show anyway" })
|
||||
).toHaveCount(0);
|
||||
|
||||
await reloadedRestoreButton.click();
|
||||
|
||||
await expect(reloadedCard).not.toHaveAttribute(
|
||||
"data-moderation-override",
|
||||
"show-anyway"
|
||||
);
|
||||
await expect(reloadedCard).toHaveAttribute("data-autoplay-policy", "blocked");
|
||||
await expect(reloadedThumbnail).toHaveAttribute("data-thumbnail-state", "blurred");
|
||||
await expect(
|
||||
reloadedCard.getByRole("button", { name: RESTORE_BUTTON_LABEL })
|
||||
).toHaveCount(0);
|
||||
await expect(
|
||||
reloadedCard.getByRole("button", { name: "Show anyway" })
|
||||
).toBeVisible();
|
||||
*/
|
||||
});
|
||||
});
|
||||
+10
-4
@@ -5,18 +5,24 @@ const PORT = Number.parseInt(process.env.PLAYWRIGHT_PORT ?? "4173", 10);
|
||||
const BASE_URL = process.env.PLAYWRIGHT_BASE_URL ?? `http://${HOST}:${PORT}`;
|
||||
|
||||
export default defineConfig({
|
||||
testDir: ".",
|
||||
testDir: "../../",
|
||||
outputDir: "../../artifacts/test-results-repro",
|
||||
timeout: 60_000,
|
||||
reporter: [["list"], ["html", { open: "never" }]],
|
||||
reporter: [["list"]],
|
||||
use: {
|
||||
baseURL: BASE_URL,
|
||||
viewport: { width: 1280, height: 720 },
|
||||
ignoreHTTPSErrors: true,
|
||||
},
|
||||
projects: [
|
||||
{
|
||||
name: "repro",
|
||||
testMatch: "examples/reproducers/**/*.spec.ts",
|
||||
},
|
||||
],
|
||||
webServer: {
|
||||
// Config is in examples/reproducers, so cwd is there. We need to serve the repo root.
|
||||
command: `npx http-server ../.. -p ${PORT} -a ${HOST} -c-1 --silent`,
|
||||
command: `npx http-server . -p ${PORT} -a ${HOST} -c-1 --silent`,
|
||||
cwd: "../../",
|
||||
url: `${BASE_URL}/docs/kitchen-sink.html`,
|
||||
reuseExistingServer: !process.env.CI,
|
||||
timeout: 120_000,
|
||||
|
||||
Vendored
+10
-128
@@ -73,7 +73,6 @@ import {
|
||||
import { isWatchHistoryDebugEnabled } from "./watchHistoryDebug.js";
|
||||
import { devLogger, userLogger } from "./utils/logger.js";
|
||||
import createPopover from "./ui/overlay/popoverEngine.js";
|
||||
import { createVideoSettingsMenuPanel } from "./ui/components/videoMenuRenderers.js";
|
||||
import moderationService from "./services/moderationService.js";
|
||||
import { sanitizeRelayList } from "./nostr/nip46Client.js";
|
||||
import { buildDmRelayListEvent, buildShareEvent } from "./nostrEventSchemas.js";
|
||||
@@ -7508,139 +7507,17 @@ class Application {
|
||||
return true;
|
||||
}
|
||||
|
||||
ensureSettingsPopover(detail = {}) {
|
||||
const trigger = detail.trigger || null;
|
||||
if (!trigger) {
|
||||
return null;
|
||||
}
|
||||
|
||||
let entry = this.videoSettingsPopovers.get(trigger);
|
||||
if (!entry) {
|
||||
entry = {
|
||||
trigger,
|
||||
context: {
|
||||
card: detail.card || null,
|
||||
video: detail.video || null,
|
||||
index: Number.isFinite(detail.index) ? Math.floor(detail.index) : 0,
|
||||
capabilities: detail.capabilities || {},
|
||||
restoreFocusOnClose: detail.restoreFocus !== false,
|
||||
},
|
||||
popover: null,
|
||||
};
|
||||
|
||||
const render = ({ document: documentRef, close }) => {
|
||||
const panel = createVideoSettingsMenuPanel({
|
||||
document: documentRef,
|
||||
video: entry.context.video,
|
||||
index: entry.context.index,
|
||||
capabilities: entry.context.capabilities,
|
||||
designSystem: this.designSystemContext,
|
||||
});
|
||||
|
||||
if (!panel) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const buttons = panel.querySelectorAll("button[data-action]");
|
||||
buttons.forEach((button) => {
|
||||
button.addEventListener("click", (event) => {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
const action = button.dataset.action || "";
|
||||
const handled = entry.context.card?.handleSettingsMenuAction?.(
|
||||
action,
|
||||
{ event },
|
||||
);
|
||||
|
||||
if (!handled && this.isDevMode) {
|
||||
userLogger.warn(`[SettingsMenu] Unhandled action: ${action}`);
|
||||
}
|
||||
|
||||
close();
|
||||
});
|
||||
});
|
||||
|
||||
return panel;
|
||||
};
|
||||
|
||||
const documentRef =
|
||||
trigger.ownerDocument ||
|
||||
(typeof document !== "undefined" ? document : null);
|
||||
|
||||
const popover = createPopover(trigger, render, {
|
||||
document: documentRef,
|
||||
placement: "bottom-end",
|
||||
});
|
||||
|
||||
const originalDestroy = popover.destroy?.bind(popover);
|
||||
if (typeof originalDestroy === "function") {
|
||||
popover.destroy = (...args) => {
|
||||
originalDestroy(...args);
|
||||
if (this.videoSettingsPopovers.get(trigger) === entry) {
|
||||
this.videoSettingsPopovers.delete(trigger);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
entry.popover = popover;
|
||||
this.videoSettingsPopovers.set(trigger, entry);
|
||||
}
|
||||
|
||||
entry.context = {
|
||||
...entry.context,
|
||||
card: detail.card || entry.context.card,
|
||||
video: detail.video || entry.context.video,
|
||||
index: Number.isFinite(detail.index)
|
||||
? Math.floor(detail.index)
|
||||
: entry.context.index,
|
||||
capabilities: detail.capabilities || entry.context.capabilities,
|
||||
restoreFocusOnClose: detail.restoreFocus !== false,
|
||||
};
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
requestVideoSettingsMenu(detail = {}) {
|
||||
const entry = this.ensureSettingsPopover(detail);
|
||||
if (!entry?.popover) {
|
||||
return;
|
||||
if (this.videoSettingsMenuController) {
|
||||
this.videoSettingsMenuController.requestMenu(detail);
|
||||
}
|
||||
|
||||
if (typeof entry.popover.isOpen === "function" && entry.popover.isOpen()) {
|
||||
entry.popover.close({
|
||||
restoreFocus: entry.context.restoreFocusOnClose !== false,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
entry.popover
|
||||
.open()
|
||||
.catch((error) =>
|
||||
userLogger.error("[SettingsMenu] Failed to open popover:", error),
|
||||
);
|
||||
}
|
||||
|
||||
closeVideoSettingsMenu(detail = {}) {
|
||||
const trigger = detail.trigger || null;
|
||||
const restoreFocus = detail.restoreFocus !== false;
|
||||
|
||||
if (trigger) {
|
||||
const entry = this.videoSettingsPopovers.get(trigger);
|
||||
if (entry?.popover && typeof entry.popover.close === "function") {
|
||||
return entry.popover.close({ restoreFocus });
|
||||
}
|
||||
return false;
|
||||
if (this.videoSettingsMenuController) {
|
||||
return this.videoSettingsMenuController.closeMenu(detail);
|
||||
}
|
||||
|
||||
let closed = false;
|
||||
this.videoSettingsPopovers.forEach((entry) => {
|
||||
if (entry?.popover && typeof entry.popover.close === "function") {
|
||||
const result = entry.popover.close({ restoreFocus });
|
||||
closed = closed || result;
|
||||
}
|
||||
});
|
||||
return closed;
|
||||
return false;
|
||||
}
|
||||
|
||||
ensureTagPreferencePopover(detail) {
|
||||
@@ -10039,6 +9916,11 @@ class Application {
|
||||
this.moreMenuController = null;
|
||||
}
|
||||
|
||||
if (this.videoSettingsMenuController) {
|
||||
this.videoSettingsMenuController.destroy();
|
||||
this.videoSettingsMenuController = null;
|
||||
}
|
||||
|
||||
if (this.profileController) {
|
||||
if (typeof this.profileController.destroy === "function") {
|
||||
try {
|
||||
|
||||
Vendored
+11
@@ -487,10 +487,21 @@ export function isSessionActor(nostrClient) {
|
||||
return !!sa && sa.source !== "nsec";
|
||||
}
|
||||
|
||||
function _closeSessionActorDb() {
|
||||
if (sessionActorDbPromise) {
|
||||
return sessionActorDbPromise.then((db) => {
|
||||
db.close();
|
||||
sessionActorDbPromise = null;
|
||||
});
|
||||
}
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
export const __testExports = {
|
||||
arrayBufferToBase64,
|
||||
base64ToUint8Array,
|
||||
deriveSessionEncryptionKey,
|
||||
generateRandomBytes,
|
||||
isSubtleCryptoAvailable,
|
||||
_closeSessionActorDb,
|
||||
};
|
||||
Vendored
+5
-1
@@ -34,6 +34,7 @@ import ProfileModalController from "./profileModalController.js";
|
||||
import LoginModalController from "./loginModalController.js";
|
||||
import { VideoListView } from "./views/VideoListView.js";
|
||||
import MoreMenuController from "./moreMenuController.js";
|
||||
import VideoSettingsMenuController from "./videoSettingsMenuController.js";
|
||||
import AppChromeController from "./appChromeController.js";
|
||||
import { getSidebarLoadingMarkup } from "../sidebarLoading.js";
|
||||
import { isWatchHistoryDebugEnabled } from "../watchHistoryDebug.js";
|
||||
@@ -671,7 +672,10 @@ export default class ApplicationBootstrap {
|
||||
},
|
||||
});
|
||||
app.moreMenuController.setVideoModal(app.videoModal);
|
||||
app.videoSettingsPopovers = new Map();
|
||||
app.videoSettingsMenuController = new VideoSettingsMenuController({
|
||||
designSystem: app.designSystemContext,
|
||||
isDevMode,
|
||||
});
|
||||
app.tagPreferencePopovers = new Map();
|
||||
|
||||
app.subscriptionsLink = null;
|
||||
|
||||
Vendored
+4
@@ -46,6 +46,10 @@ export function sanitizeProfileMediaUrl(value) {
|
||||
return trimmed;
|
||||
}
|
||||
|
||||
if (trimmed === "images/robot.png") {
|
||||
return "";
|
||||
}
|
||||
|
||||
if (/^ipfs:\/\//i.test(trimmed)) {
|
||||
return normalizeIpfsGatewayUrl(trimmed);
|
||||
}
|
||||
|
||||
Vendored
+5
@@ -873,6 +873,11 @@ export class TorrentClient {
|
||||
emit("torrent-stream-start", { magnet: magnetURI });
|
||||
// 1) Make sure we have a WebTorrent client and a valid SW registration.
|
||||
const initResult = await this.init();
|
||||
|
||||
if (!this.client) {
|
||||
throw new Error("Client destroyed during initialization");
|
||||
}
|
||||
|
||||
const serviceWorkerReady =
|
||||
!!(initResult?.serviceWorkerReady && this.swRegistration);
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
import{IS_DEV_MODE as Le,IS_VERBOSE_DEV_MODE as Ce,IS_LOCKDOWN_MODE as Ae,LOCKDOWN_TITLE as bt,LOCKDOWN_MESSAGE as Et,ADMIN_SUPER_NPUB as Tt,ADMIN_DM_IMAGE_URL as gt,BITVID_WEBSITE_URL as _t,BLOG_URL as St,COMMUNITY_URL as wt,NOSTR_URL as Lt,GITHUB_URL as Ct,BETA_URL as At,DNS_URL as xt,TIP_JAR_URL as vt,MAX_WALLET_DEFAULT_ZAP as It,PLATFORM_FEE_PERCENT as Ot,PLATFORM_LUD16_OVERRIDE as Nt,DEFAULT_RELAY_URLS_OVERRIDE as Bt,ADMIN_WHITELIST_MODE_STORAGE_KEY as Mt,DEFAULT_WHITELIST_MODE_ENABLED as Dt,ALLOW_NSFW_CONTENT as Rt,DEFAULT_TRUST_SEED_NPUBS as Ht,DEFAULT_BLUR_THRESHOLD as Ut,DEFAULT_AUTOPLAY_BLOCK_THRESHOLD as kt,DEFAULT_TRUSTED_MUTE_HIDE_THRESHOLD as Ft,DEFAULT_TRUSTED_SPAM_HIDE_THRESHOLD as Pt,WATCH_HISTORY_KIND as Vt,WATCH_HISTORY_LIST_IDENTIFIER as Wt,WATCH_HISTORY_MAX_ITEMS as qt,WATCH_HISTORY_BATCH_RESOLVE as jt,WATCH_HISTORY_BATCH_PAGE_SIZE as $t,WATCH_HISTORY_PAYLOAD_MAX_BYTES as Yt,WATCH_HISTORY_FETCH_EVENT_LIMIT as Gt,WATCH_HISTORY_CACHE_TTL_MS as zt,VIEW_COUNT_DEDUPE_WINDOW_SECONDS as Kt,VIEW_COUNT_BACKFILL_MAX_DAYS as Xt,VIEW_COUNT_CACHE_TTL_MS as Zt,ENSURE_PRESENCE_REBROADCAST_COOLDOWN_SECONDS as Jt}from"../config/instance-config.js";var H=!!Le;var xe=!!Ce;var ve=!!Ae;typeof window<"u"&&(window.__BITVID_DEV_MODE__=H,window.__BITVID_VERBOSE_DEV_MODE__=xe,window.__BITVID_LOCKDOWN_MODE__=ve);var k=()=>{};function Ie(){return typeof console>"u"||console===null?null:console}function Oe(){let e=Ie();if(!e)return{log:k,info:k,debug:k,warn:k,error:k};let t=typeof e.log=="function"?e.log.bind(e):k;return{log:typeof e.log=="function"?e.log.bind(e):t,info:typeof e.info=="function"?e.info.bind(e):t,debug:typeof e.debug=="function"?e.debug.bind(e):t,warn:typeof e.warn=="function"?e.warn.bind(e):t,error:typeof e.error=="function"?e.error.bind(e):t}}var _=Oe(),M="[bitvid]";function ee(e){if(e.length===0)return{args:e,force:!1};let t=e[e.length-1];if(t&&typeof t=="object"&&!Array.isArray(t)&&Object.prototype.hasOwnProperty.call(t,"force")){let r=[...e],o=r.pop();return{args:r,force:!!o.force}}return{args:e,force:!1}}var S=Object.freeze({log:(...e)=>{H&&_.log(...e)},info:(...e)=>{H&&_.info(...e)},debug:(...e)=>{H&&_.debug(...e)},warn:(...e)=>{H&&_.warn(...e)},error:(...e)=>{H&&_.error(...e)}}),y=Object.freeze({log:(...e)=>{let{args:t,force:r}=ee(e);if(!r&&t.length===0)return;if(r){_.log(M,...t);return}let[o,...n]=t;if(typeof o=="string"&&n.length===0){_.log(`${M} ${o}`);return}o!==void 0&&_.log(M,o)},info:(...e)=>{let{args:t,force:r}=ee(e);if(!r&&t.length===0)return;if(r){_.info(M,...t);return}let[o,...n]=t;if(typeof o=="string"&&n.length===0){_.info(`${M} ${o}`);return}o!==void 0&&_.info(M,o)},warn:(...e)=>{_.warn(M,...e)},error:(...e)=>{_.error(M,...e)}}),te=Object.freeze({dev:S,user:y});function Ne(e){return!e||typeof e!="object"?!1:Object.entries({dev:["log","info","debug","warn","error"],user:["log","info","warn","error"]}).every(([r,o])=>{let n=e[r];return!n||typeof n!="object"?!1:o.every(c=>typeof n[c]=="function")})}typeof window<"u"&&(Ne(window.bitvidLogger)||(window.bitvidLogger=te));Object.freeze(te);import{THEME_ACCENT_OVERRIDES as re}from"../config/instance-config.js";var K="bitvid:theme",v="dark",Be=new Set(["light","dark"]),ne={dark:"#0f172a",light:"#f8fafc"},oe=["[data-theme-toggle]",'[data-action="toggle-theme"]',".js-theme-toggle","#themeToggle"],ie=Object.freeze({accent:"--color-accent",accentStrong:"--color-accent-strong",accentPressed:"--color-accent-pressed"}),ae=new WeakSet,W=new Set,D=null,se=!1,F=null,I=()=>typeof window<"u"&&typeof document<"u",q=e=>{if(typeof e!="string")return null;let t=e.trim().toLowerCase();return t==="default"||t===""?v:Be.has(t)?t:null},Me=()=>{if(!I())return null;try{let e=window.localStorage.getItem(K);return q(e)}catch(e){return y.warn("Unable to read stored theme preference:",e),null}},De=e=>{if(I())try{window.localStorage.setItem(K,e)}catch(t){y.warn("Unable to persist theme preference:",t)}},G=()=>{if(!I())return null;let{documentElement:e}=document;return e instanceof HTMLElement?e:null},Re=e=>typeof e=="string"?e.trim():"",He=e=>{if(!e||typeof e!="object")return null;let t=Object.entries(e).reduce((r,[o,n])=>{if(!n||typeof n!="object")return r;let c=Object.entries(n).reduce((a,[u,d])=>(Object.prototype.hasOwnProperty.call(ie,u)&&(a[u]=d),a),{});return Object.keys(c).length>0&&(r[o]=c),r},{});return Object.keys(t).length>0?t:null},ce=e=>{F=He(e)};ce(typeof re<"u"?re:null);var le=(e,t)=>{if(!e)return;let r=F&&typeof F=="object"&&F[t]&&typeof F[t]=="object"?F[t]:null,o=!1;Object.entries(ie).forEach(([n,c])=>{let a=r?r[n]:null,u=Re(a);u?(e.style.setProperty(c,u),o=!0):e.style.removeProperty(c)}),o?e.dataset.themeAccent="override":e.removeAttribute("data-theme-accent")},Ue=e=>{if(!I())return;let t=document.querySelector('meta[name="theme-color"]');if(!t)return;let r=G();if(!r)return;let o="";try{typeof window.getComputedStyle=="function"&&(o=getComputedStyle(r).getPropertyValue("--color-page").trim())}catch(a){y.warn("Unable to compute theme color tokenLine truncated
|
||||
import{IS_DEV_MODE as Le,IS_VERBOSE_DEV_MODE as Ae,IS_LOCKDOWN_MODE as Ce,LOCKDOWN_TITLE as yt,LOCKDOWN_MESSAGE as Et,ADMIN_SUPER_NPUB as Tt,ADMIN_DM_IMAGE_URL as gt,BITVID_WEBSITE_URL as _t,BLOG_URL as St,COMMUNITY_URL as wt,NOSTR_URL as Lt,GITHUB_URL as At,BETA_URL as Ct,DNS_URL as xt,TIP_JAR_URL as vt,MAX_WALLET_DEFAULT_ZAP as It,PLATFORM_FEE_PERCENT as Ot,PLATFORM_LUD16_OVERRIDE as Nt,DEFAULT_RELAY_URLS_OVERRIDE as Bt,ADMIN_WHITELIST_MODE_STORAGE_KEY as Mt,DEFAULT_WHITELIST_MODE_ENABLED as Dt,ALLOW_NSFW_CONTENT as Rt,DEFAULT_TRUST_SEED_NPUBS as Ut,DEFAULT_BLUR_THRESHOLD as Ht,DEFAULT_AUTOPLAY_BLOCK_THRESHOLD as kt,DEFAULT_TRUSTED_MUTE_HIDE_THRESHOLD as Ft,DEFAULT_TRUSTED_SPAM_HIDE_THRESHOLD as Pt,WATCH_HISTORY_KIND as Vt,WATCH_HISTORY_LIST_IDENTIFIER as Wt,WATCH_HISTORY_MAX_ITEMS as qt,WATCH_HISTORY_BATCH_RESOLVE as jt,WATCH_HISTORY_BATCH_PAGE_SIZE as $t,WATCH_HISTORY_PAYLOAD_MAX_BYTES as Yt,WATCH_HISTORY_FETCH_EVENT_LIMIT as Kt,WATCH_HISTORY_CACHE_TTL_MS as Gt,VIEW_COUNT_DEDUPE_WINDOW_SECONDS as zt,VIEW_COUNT_BACKFILL_MAX_DAYS as Xt,VIEW_COUNT_CACHE_TTL_MS as Zt,ENSURE_PRESENCE_REBROADCAST_COOLDOWN_SECONDS as Jt,DEFAULT_PLAYBACK_SOURCE as Qt,DEFAULT_PLAYBACK_START_TIMEOUT as er}from"../config/instance-config.js";var U=!!Le;var xe=!!Ae;var ve=!!Ce;typeof window<"u"&&(window.__BITVID_DEV_MODE__=U,window.__BITVID_VERBOSE_DEV_MODE__=xe,window.__BITVID_LOCKDOWN_MODE__=ve);var k=()=>{};function Ie(){return typeof console>"u"||console===null?null:console}function Oe(){let e=Ie();if(!e)return{log:k,info:k,debug:k,warn:k,error:k};let t=typeof e.log=="function"?e.log.bind(e):k;return{log:typeof e.log=="function"?e.log.bind(e):t,info:typeof e.info=="function"?e.info.bind(e):t,debug:typeof e.debug=="function"?e.debug.bind(e):t,warn:typeof e.warn=="function"?e.warn.bind(e):t,error:typeof e.error=="function"?e.error.bind(e):t}}var _=Oe(),M="[bitvid]";function ee(e){if(e.length===0)return{args:e,force:!1};let t=e[e.length-1];if(t&&typeof t=="object"&&!Array.isArray(t)&&Object.prototype.hasOwnProperty.call(t,"force")){let r=[...e],o=r.pop();return{args:r,force:!!o.force}}return{args:e,force:!1}}var S=Object.freeze({log:(...e)=>{U&&_.log(...e)},info:(...e)=>{U&&_.info(...e)},debug:(...e)=>{U&&_.debug(...e)},warn:(...e)=>{U&&_.warn(...e)},error:(...e)=>{U&&_.error(...e)}}),b=Object.freeze({log:(...e)=>{let{args:t,force:r}=ee(e);if(!r&&t.length===0)return;if(r){_.log(M,...t);return}let[o,...n]=t;if(typeof o=="string"&&n.length===0){_.log(`${M} ${o}`);return}o!==void 0&&_.log(M,o)},info:(...e)=>{let{args:t,force:r}=ee(e);if(!r&&t.length===0)return;if(r){_.info(M,...t);return}let[o,...n]=t;if(typeof o=="string"&&n.length===0){_.info(`${M} ${o}`);return}o!==void 0&&_.info(M,o)},warn:(...e)=>{_.warn(M,...e)},error:(...e)=>{_.error(M,...e)}}),te=Object.freeze({dev:S,user:b});function Ne(e){return!e||typeof e!="object"?!1:Object.entries({dev:["log","info","debug","warn","error"],user:["log","info","warn","error"]}).every(([r,o])=>{let n=e[r];return!n||typeof n!="object"?!1:o.every(c=>typeof n[c]=="function")})}typeof window<"u"&&(Ne(window.bitvidLogger)||(window.bitvidLogger=te));Object.freeze(te);import{THEME_ACCENT_OVERRIDES as re}from"../config/instance-config.js";var z="bitvid:theme",v="dark",Be=new Set(["light","dark"]),ne={dark:"rgb(15, 23, 42)",light:"rgb(248, 250, 252)"},oe=["[data-theme-toggle]",'[data-action="toggle-theme"]',".js-theme-toggle","#themeToggle"],ie=Object.freeze({accent:"--color-accent",accentStrong:"--color-accent-strong",accentPressed:"--color-accent-pressed"}),ae=new WeakSet,W=new Set,D=null,se=!1,F=null,I=()=>typeof window<"u"&&typeof document<"u",q=e=>{if(typeof e!="string")return null;let t=e.trim().toLowerCase();return t==="default"||t===""?v:Be.has(t)?t:null},Me=()=>{if(!I())return null;try{let e=window.localStorage.getItem(z);return q(e)}catch(e){return b.warn("Unable to read stored theme preference:",e),null}},De=e=>{if(I())try{window.localStorage.setItem(z,e)}catch(t){b.warn("Unable to persist theme preference:",t)}},K=()=>{if(!I())return null;let{documentElement:e}=document;return e instanceof HTMLElement?e:null},Re=e=>typeof e=="string"?e.trim():"",Ue=e=>{if(!e||typeof e!="object")return null;let t=Object.entries(e).reduce((r,[o,n])=>{if(!n||typeof n!="object")return r;let c=Object.entries(n).reduce((a,[u,d])=>(Object.prototype.hasOwnProperty.call(ie,u)&&(a[u]=d),a),{});return Object.keys(c).length>0&&(r[o]=c),r},{});return Object.keys(t).length>0?t:null},ce=e=>{F=Ue(e)};ce(typeof re<"u"?re:null);var le=(e,t)=>{if(!e)return;let r=F&&typeof F=="object"&&F[t]&&typeof F[t]=="object"?F[t]:null,o=!1;Object.entries(ie).forEach(([n,c])=>{let a=r?r[n]:null,u=Re(a);u?(e.style.setProperty(c,u),o=!0):e.style.removeProperty(c)}),o?e.dataset.themeAccent="override":e.removeAttribute("data-theme-accent")},He=e=>{if(!I())return;let t=document.querySelector('meta[name="theme-color"]');if(!t)return;let r=K();if(!r)return;let o="";try{typeof window.getComputedStyle=="function"&&(o=getComputedStyle(r).getPropLine truncated
|
||||
+1
-1
@@ -1 +1 @@
|
||||
var H=Math.min,B=Math.max,ot=Math.round,it=Math.floor,L=t=>({x:t,y:t}),qt={left:"right",right:"left",bottom:"top",top:"bottom"},Ut={start:"end",end:"start"};function lt(t,e,n){return B(t,H(e,n))}function U(t,e){return typeof t=="function"?t(e):t}function V(t){return t.split("-")[0]}function K(t){return t.split("-")[1]}function pt(t){return t==="x"?"y":"x"}function at(t){return t==="y"?"height":"width"}var Kt=new Set(["top","bottom"]);function W(t){return Kt.has(V(t))?"y":"x"}function ft(t){return pt(W(t))}function Ot(t,e,n){n===void 0&&(n=!1);let o=K(t),i=ft(t),r=at(i),s=i==="x"?o===(n?"end":"start")?"right":"left":o==="start"?"bottom":"top";return e.reference[r]>e.floating[r]&&(s=nt(s)),[s,nt(s)]}function Rt(t){let e=nt(t);return[ct(t),e,ct(e)]}function ct(t){return t.replace(/start|end/g,e=>Ut[e])}var bt=["left","right"],At=["right","left"],Gt=["top","bottom"],Jt=["bottom","top"];function Qt(t,e,n){switch(t){case"top":case"bottom":return n?e?At:bt:e?bt:At;case"left":case"right":return e?Gt:Jt;default:return[]}}function St(t,e,n,o){let i=K(t),r=Qt(V(t),n==="start",o);return i&&(r=r.map(s=>s+"-"+i),e&&(r=r.concat(r.map(ct)))),r}function nt(t){return t.replace(/left|right|bottom|top/g,e=>qt[e])}function Zt(t){return{top:0,right:0,bottom:0,left:0,...t}}function wt(t){return typeof t!="number"?Zt(t):{top:t,right:t,bottom:t,left:t}}function X(t){let{x:e,y:n,width:o,height:i}=t;return{width:o,height:i,top:n,left:e,right:e+o,bottom:n+i,x:e,y:n}}function Ct(t,e,n){let{reference:o,floating:i}=t,r=W(e),s=ft(e),c=at(s),a=V(e),l=r==="y",d=o.x+o.width/2-i.width/2,u=o.y+o.height/2-i.height/2,g=o[c]/2-i[c]/2,f;switch(a){case"top":f={x:d,y:o.y-i.height};break;case"bottom":f={x:d,y:o.y+o.height};break;case"right":f={x:o.x+o.width,y:u};break;case"left":f={x:o.x-i.width,y:u};break;default:f={x:o.x,y:o.y}}switch(K(e)){case"start":f[s]-=g*(n&&l?-1:1);break;case"end":f[s]+=g*(n&&l?-1:1);break}return f}var Pt=async(t,e,n)=>{let{placement:o="bottom",strategy:i="absolute",middleware:r=[],platform:s}=n,c=r.filter(Boolean),a=await(s.isRTL==null?void 0:s.isRTL(e)),l=await s.getElementRects({reference:t,floating:e,strategy:i}),{x:d,y:u}=Ct(l,o,a),g=o,f={},m=0;for(let h=0;h<c.length;h++){let{name:w,fn:p}=c[h],{x,y,data:b,reset:v}=await p({x:d,y:u,initialPlacement:o,placement:g,strategy:i,middlewareData:f,rects:l,platform:s,elements:{reference:t,floating:e}});d=x??d,u=y??u,f={...f,[w]:{...f[w],...b}},v&&m<=50&&(m++,typeof v=="object"&&(v.placement&&(g=v.placement),v.rects&&(l=v.rects===!0?await s.getElementRects({reference:t,floating:e,strategy:i}):v.rects),{x:d,y:u}=Ct(l,g,a)),h=-1)}return{x:d,y:u,placement:g,strategy:i,middlewareData:f}};async function xt(t,e){var n;e===void 0&&(e={});let{x:o,y:i,platform:r,rects:s,elements:c,strategy:a}=t,{boundary:l="clippingAncestors",rootBoundary:d="viewport",elementContext:u="floating",altBoundary:g=!1,padding:f=0}=U(e,t),m=wt(f),w=c[g?u==="floating"?"reference":"floating":u],p=X(await r.getClippingRect({element:(n=await(r.isElement==null?void 0:r.isElement(w)))==null||n?w:w.contextElement||await(r.getDocumentElement==null?void 0:r.getDocumentElement(c.floating)),boundary:l,rootBoundary:d,strategy:a})),x=u==="floating"?{x:o,y:i,width:s.floating.width,height:s.floating.height}:s.reference,y=await(r.getOffsetParent==null?void 0:r.getOffsetParent(c.floating)),b=await(r.isElement==null?void 0:r.isElement(y))?await(r.getScale==null?void 0:r.getScale(y))||{x:1,y:1}:{x:1,y:1},v=X(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:x,offsetParent:y,strategy:a}):x);return{top:(p.top-v.top+m.top)/b.y,bottom:(v.bottom-p.bottom+m.bottom)/b.y,left:(p.left-v.left+m.left)/b.x,right:(v.right-p.right+m.right)/b.x}}var Tt=t=>({name:"arrow",options:t,async fn(e){let{x:n,y:o,placement:i,rects:r,platform:s,elements:c,middlewareData:a}=e,{element:l,padding:d=0}=U(t,e)||{};if(l==null)return{};let u=wt(d),g={x:n,y:o},f=ft(i),m=at(f),h=await s.getDimensions(l),w=f==="y",p=w?"top":"left",x=w?"bottom":"right",y=w?"clientHeight":"clientWidth",b=r.reference[m]+r.reference[f]-g[f]-r.floating[m],v=g[f]-r.reference[f],M=await(s.getOffsetParent==null?void 0:s.getOffsetParent(l)),R=M?M[y]:0;(!R||!await(s.isElement==null?void 0:s.isElement(M)))&&(R=c.floating[y]||r.floating[m]);let Z=b/2-v/2,_=R/2-h[m]/2-1,F=H(u[p],_),tt=H(u[x],_),z=F,et=R-h[m]-tt,A=R/2-h[m]/2+Z,I=lt(z,A,et),k=!a.arrow&&K(i)!=null&&A!==I&&r.reference[m]/2-(A<z?F:tt)-h[m]/2<0,P=k?A<z?A-z:A-et:0;return{[f]:g[f]+P,data:{[f]:I,centerOffset:A-I-P,...k&&{alignmentOffset:P}},reset:k}}});var Lt=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,o;let{placement:i,middlewareData:r,rects:s,initialPlacement:c,platform:a,elements:l}=e,{mainAxis:d=!0,crossAxis:u=!0,fallbackPlacements:g,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:h=!0,...w}=U(t,e);if((n=r.arrow)!=null&&n.alignmentOffset)return{};let p=V(i),x=W(c),y=V(c)===c,b=await(a.iLine truncated
|
||||
var $=Math.min,B=Math.max,ot=Math.round,it=Math.floor,E=t=>({x:t,y:t}),qt={left:"right",right:"left",bottom:"top",top:"bottom"},Ut={start:"end",end:"start"};function lt(t,e,n){return B(t,$(e,n))}function U(t,e){return typeof t=="function"?t(e):t}function V(t){return t.split("-")[0]}function K(t){return t.split("-")[1]}function pt(t){return t==="x"?"y":"x"}function at(t){return t==="y"?"height":"width"}var Kt=new Set(["top","bottom"]);function W(t){return Kt.has(V(t))?"y":"x"}function ft(t){return pt(W(t))}function At(t,e,n){n===void 0&&(n=!1);let o=K(t),i=ft(t),r=at(i),s=i==="x"?o===(n?"end":"start")?"right":"left":o==="start"?"bottom":"top";return e.reference[r]>e.floating[r]&&(s=nt(s)),[s,nt(s)]}function Ot(t){let e=nt(t);return[ct(t),e,ct(e)]}function ct(t){return t.replace(/start|end/g,e=>Ut[e])}var vt=["left","right"],bt=["right","left"],Gt=["top","bottom"],Jt=["bottom","top"];function Qt(t,e,n){switch(t){case"top":case"bottom":return n?e?bt:vt:e?vt:bt;case"left":case"right":return e?Gt:Jt;default:return[]}}function Rt(t,e,n,o){let i=K(t),r=Qt(V(t),n==="start",o);return i&&(r=r.map(s=>s+"-"+i),e&&(r=r.concat(r.map(ct)))),r}function nt(t){return t.replace(/left|right|bottom|top/g,e=>qt[e])}function Zt(t){return{top:0,right:0,bottom:0,left:0,...t}}function wt(t){return typeof t!="number"?Zt(t):{top:t,right:t,bottom:t,left:t}}function X(t){let{x:e,y:n,width:o,height:i}=t;return{width:o,height:i,top:n,left:e,right:e+o,bottom:n+i,x:e,y:n}}function St(t,e,n){let{reference:o,floating:i}=t,r=W(e),s=ft(e),c=at(s),l=V(e),a=r==="y",d=o.x+o.width/2-i.width/2,u=o.y+o.height/2-i.height/2,m=o[c]/2-i[c]/2,f;switch(l){case"top":f={x:d,y:o.y-i.height};break;case"bottom":f={x:d,y:o.y+o.height};break;case"right":f={x:o.x+o.width,y:u};break;case"left":f={x:o.x-i.width,y:u};break;default:f={x:o.x,y:o.y}}switch(K(e)){case"start":f[s]-=m*(n&&a?-1:1);break;case"end":f[s]+=m*(n&&a?-1:1);break}return f}async function Ct(t,e){var n;e===void 0&&(e={});let{x:o,y:i,platform:r,rects:s,elements:c,strategy:l}=t,{boundary:a="clippingAncestors",rootBoundary:d="viewport",elementContext:u="floating",altBoundary:m=!1,padding:f=0}=U(e,t),g=wt(f),w=c[m?u==="floating"?"reference":"floating":u],h=X(await r.getClippingRect({element:(n=await(r.isElement==null?void 0:r.isElement(w)))==null||n?w:w.contextElement||await(r.getDocumentElement==null?void 0:r.getDocumentElement(c.floating)),boundary:a,rootBoundary:d,strategy:l})),x=u==="floating"?{x:o,y:i,width:s.floating.width,height:s.floating.height}:s.reference,y=await(r.getOffsetParent==null?void 0:r.getOffsetParent(c.floating)),v=await(r.isElement==null?void 0:r.isElement(y))?await(r.getScale==null?void 0:r.getScale(y))||{x:1,y:1}:{x:1,y:1},O=X(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:x,offsetParent:y,strategy:l}):x);return{top:(h.top-O.top+g.top)/v.y,bottom:(O.bottom-h.bottom+g.bottom)/v.y,left:(h.left-O.left+g.left)/v.x,right:(O.right-h.right+g.right)/v.x}}var Pt=async(t,e,n)=>{let{placement:o="bottom",strategy:i="absolute",middleware:r=[],platform:s}=n,c=r.filter(Boolean),l=await(s.isRTL==null?void 0:s.isRTL(e)),a=await s.getElementRects({reference:t,floating:e,strategy:i}),{x:d,y:u}=St(a,o,l),m=o,f={},g=0;for(let w=0;w<c.length;w++){var p;let{name:h,fn:x}=c[w],{x:y,y:v,data:O,reset:b}=await x({x:d,y:u,initialPlacement:o,placement:m,strategy:i,middlewareData:f,rects:a,platform:{...s,detectOverflow:(p=s.detectOverflow)!=null?p:Ct},elements:{reference:t,floating:e}});d=y??d,u=v??u,f={...f,[h]:{...f[h],...O}},b&&g<=50&&(g++,typeof b=="object"&&(b.placement&&(m=b.placement),b.rects&&(a=b.rects===!0?await s.getElementRects({reference:t,floating:e,strategy:i}):b.rects),{x:d,y:u}=St(a,m,l)),w=-1)}return{x:d,y:u,placement:m,strategy:i,middlewareData:f}},Tt=t=>({name:"arrow",options:t,async fn(e){let{x:n,y:o,placement:i,rects:r,platform:s,elements:c,middlewareData:l}=e,{element:a,padding:d=0}=U(t,e)||{};if(a==null)return{};let u=wt(d),m={x:n,y:o},f=ft(i),g=at(f),p=await s.getDimensions(a),w=f==="y",h=w?"top":"left",x=w?"bottom":"right",y=w?"clientHeight":"clientWidth",v=r.reference[g]+r.reference[f]-m[f]-r.floating[g],O=m[f]-r.reference[f],b=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a)),S=b?b[y]:0;(!S||!await(s.isElement==null?void 0:s.isElement(b)))&&(S=c.floating[y]||r.floating[g]);let Z=v/2-O/2,z=S/2-p[g]/2-1,F=$(u[h],z),tt=$(u[x],z),_=F,et=S-p[g]-tt,A=S/2-p[g]/2+Z,I=lt(_,A,et),k=!l.arrow&&K(i)!=null&&A!==I&&r.reference[g]/2-(A<_?F:tt)-p[g]/2<0,T=k?A<_?A-_:A-et:0;return{[f]:m[f]+T,data:{[f]:I,centerOffset:A-I-T,...k&&{alignmentOffset:T}},reset:k}}});var Lt=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,o;let{placement:i,middlewareData:r,rects:s,initialPlacement:c,platform:l,elements:a}=e,{mainAxis:d=!0,crossAxis:u=!0,fallbackPlacements:m,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:p=!0,...w}=U(t,e);if((n=r.arrow)!=null&&n.alignmeLine truncated
|
||||
Reference in new issue
Block a user