mirror of
https://github.com/BetterSEQTA/BetterSEQTA-Plus.git
synced 2026-12-06 19:56:45 +10:30
feat: performance mode AND fix background image bug.
This commit is contained in:
1 parent
d9c0fee06d
commit
5dba4ba8b5
68 files changed
+2882
-1212
No files matched your search
@@ -0,0 +1,180 @@
|
||||
/**
|
||||
* Chrome trace analyzer — aggregates hotspots for BetterSEQTA+ optimization.
|
||||
* Usage: node scripts/analyze-trace.mjs <path-to-trace.json>
|
||||
*/
|
||||
import fs from "node:fs";
|
||||
|
||||
const path = process.argv[2];
|
||||
if (!path) {
|
||||
console.error("Usage: node scripts/analyze-trace.mjs <trace.json>");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const raw = fs.readFileSync(path, "utf8");
|
||||
const { traceEvents } = JSON.parse(raw);
|
||||
|
||||
const DURATION_PHASES = new Set(["X", "b", "e"]);
|
||||
const openStacks = new Map(); // key -> { name, cat, args, ts }
|
||||
|
||||
const byName = new Map();
|
||||
const byCat = new Map();
|
||||
const byUrl = new Map();
|
||||
const byFunction = new Map();
|
||||
const layoutEvents = [];
|
||||
const paintEvents = [];
|
||||
const longTasks = [];
|
||||
const timers = [];
|
||||
const observers = [];
|
||||
const hitTests = [];
|
||||
const betterseqtaHits = new Map();
|
||||
const ipcMessages = new Map();
|
||||
const gcEvents = [];
|
||||
|
||||
let minTs = Infinity;
|
||||
let maxTs = -Infinity;
|
||||
|
||||
function add(map, key, dur, count = 1) {
|
||||
const e = map.get(key) ?? { dur: 0, count: 0 };
|
||||
e.dur += dur;
|
||||
e.count += count;
|
||||
map.set(key, e);
|
||||
}
|
||||
|
||||
function stackKey(ev) {
|
||||
return `${ev.pid}:${ev.tid}:${ev.name}:${ev.ts}`;
|
||||
}
|
||||
|
||||
for (const ev of traceEvents) {
|
||||
if (ev.ts != null) {
|
||||
minTs = Math.min(minTs, ev.ts);
|
||||
maxTs = Math.max(maxTs, ev.ts);
|
||||
}
|
||||
|
||||
const ph = ev.ph;
|
||||
const name = ev.name ?? "";
|
||||
const cat = ev.cat ?? "";
|
||||
const args = ev.args ?? {};
|
||||
|
||||
if (ph === "b") {
|
||||
openStacks.set(`${ev.pid}:${ev.tid}:${ev.id ?? name}`, ev);
|
||||
continue;
|
||||
}
|
||||
|
||||
let dur = ev.dur ?? 0;
|
||||
if (ph === "e" && ev.id != null) {
|
||||
const start = openStacks.get(`${ev.pid}:${ev.tid}:${ev.id}`);
|
||||
if (start) dur = ev.ts - start.ts;
|
||||
}
|
||||
if (dur <= 0 && ph !== "X") continue;
|
||||
|
||||
add(byName, name, dur);
|
||||
|
||||
const catParts = cat.split(",").filter(Boolean);
|
||||
for (const c of catParts.length ? catParts : [cat || "(none)"]) {
|
||||
add(byCat, c, dur);
|
||||
}
|
||||
|
||||
const url =
|
||||
args.data?.url ??
|
||||
args.url ??
|
||||
args.fileName ??
|
||||
args.data?.scriptName ??
|
||||
args.data?.frame ??
|
||||
"";
|
||||
if (url && typeof url === "string" && dur > 0) {
|
||||
add(byUrl, url.slice(0, 200), dur);
|
||||
}
|
||||
|
||||
const fn =
|
||||
args.data?.functionName ??
|
||||
args.functionName ??
|
||||
args.data?.columnNumber != null
|
||||
? `${args.data?.functionName ?? name}@${args.data?.url ?? ""}:${args.data?.lineNumber ?? "?"}`
|
||||
: "";
|
||||
if (fn && dur > 100) {
|
||||
add(byFunction, String(fn).slice(0, 250), dur);
|
||||
}
|
||||
|
||||
if (/Layout|UpdateLayoutTree|InvalidateLayout|LocalFrameView::performLayout/i.test(name)) {
|
||||
layoutEvents.push({ name, dur, ts: ev.ts, cat });
|
||||
}
|
||||
if (/Paint|Raster|DrawFrame|CompositeLayers|UpdateLayer/i.test(name)) {
|
||||
paintEvents.push({ name, dur, ts: ev.ts });
|
||||
}
|
||||
if (name === "RunTask" && dur > 50000) {
|
||||
longTasks.push({ dur, ts: ev.ts, cat, args: JSON.stringify(args).slice(0, 300) });
|
||||
}
|
||||
if (/Timer|setTimeout|setInterval|FireIdleCallback|requestAnimationFrame|RequestAnimationFrame/i.test(name)) {
|
||||
timers.push({ name, dur, ts: ev.ts });
|
||||
}
|
||||
if (/MutationObserver|ResizeObserver|IntersectionObserver|DeliverObservations|NotifyMutation/i.test(name)) {
|
||||
observers.push({ name, dur, ts: ev.ts });
|
||||
}
|
||||
if (/HitTest|FindElement|ElementAt/i.test(name)) {
|
||||
hitTests.push({ name, dur, ts: ev.ts });
|
||||
}
|
||||
if (/V8\.GC|GC_|MajorGC|MinorGC|IncrementalMarking/i.test(name)) {
|
||||
gcEvents.push({ name, dur, ts: ev.ts });
|
||||
}
|
||||
if (/IPC|MessagePort|postMessage/i.test(name)) {
|
||||
add(ipcMessages, name, dur);
|
||||
}
|
||||
|
||||
const blob = JSON.stringify(args);
|
||||
if (/betterseqta|BetterSEQTA|bsplus|SEQTA\.ts|monofile|AddBetterSEQTA/i.test(blob + name + url)) {
|
||||
const key = `${name} | ${(url || blob).slice(0, 120)}`;
|
||||
add(betterseqtaHits, key, dur);
|
||||
}
|
||||
}
|
||||
|
||||
function top(map, n = 40, minCount = 1) {
|
||||
return [...map.entries()]
|
||||
.filter(([, v]) => v.count >= minCount)
|
||||
.sort((a, b) => b[1].dur - a[1].dur)
|
||||
.slice(0, n)
|
||||
.map(([k, v]) => ({
|
||||
key: k,
|
||||
totalMs: (v.dur / 1000).toFixed(1),
|
||||
count: v.count,
|
||||
avgMs: (v.dur / v.count / 1000).toFixed(2),
|
||||
}));
|
||||
}
|
||||
|
||||
const traceDurationMs = ((maxTs - minTs) / 1000).toFixed(0);
|
||||
|
||||
console.log(JSON.stringify({
|
||||
summary: {
|
||||
traceDurationMs,
|
||||
eventCount: traceEvents.length,
|
||||
layoutCount: layoutEvents.length,
|
||||
layoutTotalMs: (layoutEvents.reduce((s, e) => s + e.dur, 0) / 1000).toFixed(1),
|
||||
paintCount: paintEvents.length,
|
||||
paintTotalMs: (paintEvents.reduce((s, e) => s + e.dur, 0) / 1000).toFixed(1),
|
||||
longTaskCount: longTasks.length,
|
||||
longTaskTotalMs: (longTasks.reduce((s, e) => s + e.dur, 0) / 1000).toFixed(1),
|
||||
timerCount: timers.length,
|
||||
timerTotalMs: (timers.reduce((s, e) => s + e.dur, 0) / 1000).toFixed(1),
|
||||
observerCount: observers.length,
|
||||
observerTotalMs: (observers.reduce((s, e) => s + e.dur, 0) / 1000).toFixed(1),
|
||||
hitTestCount: hitTests.length,
|
||||
hitTestTotalMs: (hitTests.reduce((s, e) => s + e.dur, 0) / 1000).toFixed(1),
|
||||
gcCount: gcEvents.length,
|
||||
gcTotalMs: (gcEvents.reduce((s, e) => s + e.dur, 0) / 1000).toFixed(1),
|
||||
},
|
||||
topEventNames: top(byName, 50),
|
||||
topCategories: top(byCat, 30),
|
||||
topUrls: top(byUrl, 40),
|
||||
topFunctions: top(byFunction, 40, 1),
|
||||
topBetterseqta: top(betterseqtaHits, 50),
|
||||
topLongTasks: longTasks.sort((a, b) => b.dur - a.dur).slice(0, 20).map(e => ({
|
||||
ms: (e.dur / 1000).toFixed(1),
|
||||
cat: e.cat,
|
||||
args: e.args,
|
||||
})),
|
||||
topLayout: layoutEvents.sort((a, b) => b.dur - a.dur).slice(0, 15).map(e => ({
|
||||
name: e.name, ms: (e.dur / 1000).toFixed(2),
|
||||
})),
|
||||
topObservers: observers.sort((a, b) => b.dur - a.dur).slice(0, 15).map(e => ({
|
||||
name: e.name, ms: (e.dur / 1000).toFixed(2), count: 1,
|
||||
})),
|
||||
}, null, 2));
|
||||
+47
-2
@@ -16,6 +16,7 @@
|
||||
@include meta.load-css("injected/sidebar-styles.scss");
|
||||
@include meta.load-css("injected/theme.scss");
|
||||
@include meta.load-css("injected/transparency.scss");
|
||||
@include meta.load-css("injected/performance-mode.scss");
|
||||
|
||||
:root {
|
||||
background: var(--better-main) !important;
|
||||
@@ -2071,11 +2072,21 @@ html.transparencyEffects
|
||||
box-shadow: 0px 10px 15px -3px rgba(0, 0, 0, 0.4);
|
||||
}
|
||||
|
||||
/* Smoothed by attachNotificationsPanelAnimation (matches #ExtensionPopup spring) */
|
||||
/* Smoothed by attachNotificationsPanelAnimation (CSS transition, no JS spring ticks) */
|
||||
.bsplus-notifications-panel {
|
||||
transform-origin: top right;
|
||||
will-change: opacity, transform;
|
||||
opacity: 0;
|
||||
transform: scale(0.94);
|
||||
transition:
|
||||
opacity 0.2s cubic-bezier(0.22, 1, 0.36, 1),
|
||||
transform 0.2s cubic-bezier(0.22, 1, 0.36, 1);
|
||||
filter: drop-shadow(0px 0px 20px rgba(0, 0, 0, 0.35));
|
||||
backface-visibility: hidden;
|
||||
}
|
||||
|
||||
.bsplus-notifications-panel--open {
|
||||
opacity: 1;
|
||||
transform: scale(1);
|
||||
}
|
||||
|
||||
#menu li.active {
|
||||
@@ -4289,6 +4300,40 @@ div.day-empty {
|
||||
z-index: 49;
|
||||
transform: scale(1) !important;
|
||||
}
|
||||
|
||||
/* Lightweight popup motion (performance mode) — fade + scale, no blur springs. */
|
||||
.whatsnewBackground.bsplus-popup-css-animate {
|
||||
opacity: 0;
|
||||
transition: opacity var(--bs-motion-duration, 0.2s) var(--bs-motion-ease, cubic-bezier(0.22, 1, 0.36, 1));
|
||||
|
||||
.whatsnewContainer {
|
||||
opacity: 0;
|
||||
transform: scale(0.94);
|
||||
transition:
|
||||
opacity var(--bs-motion-duration, 0.2s) var(--bs-motion-ease, cubic-bezier(0.22, 1, 0.36, 1)),
|
||||
transform var(--bs-motion-duration, 0.2s) var(--bs-motion-ease, cubic-bezier(0.22, 1, 0.36, 1));
|
||||
}
|
||||
|
||||
&.bsplus-popup-css-animate--open {
|
||||
opacity: 1;
|
||||
|
||||
.whatsnewContainer {
|
||||
opacity: 1;
|
||||
transform: scale(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.whatsnewBackground.bsplus-popup-backdrop--lite {
|
||||
backdrop-filter: none !important;
|
||||
-webkit-backdrop-filter: none !important;
|
||||
background: rgba(0, 0, 0, 0.55) !important;
|
||||
|
||||
.whatsnewContainer {
|
||||
backdrop-filter: none !important;
|
||||
-webkit-backdrop-filter: none !important;
|
||||
}
|
||||
}
|
||||
.whatsnewImgContainer {
|
||||
width: 96%;
|
||||
display: flex;
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
html.performanceMode {
|
||||
--bs-settings-ease: 0.2s cubic-bezier(0.22, 1, 0.36, 1);
|
||||
--bs-motion-duration: 0.2s;
|
||||
--bs-motion-ease: cubic-bezier(0.22, 1, 0.36, 1);
|
||||
|
||||
backdrop-filter: none !important;
|
||||
-webkit-backdrop-filter: none !important;
|
||||
filter: none !important;
|
||||
|
||||
/* Inline page loaders only — boot overlay lives in #loading shadow DOM. */
|
||||
.bkloading-inline .big-circle,
|
||||
.bkloading-inline .small-circle,
|
||||
.bkloading-inline .outer-circle {
|
||||
animation: none !important;
|
||||
}
|
||||
|
||||
/* Custom title: cheaper hit-testing during mouse moves (trace showed many HitTests). */
|
||||
.bsplus-custom-title,
|
||||
#title.bsplus-custom-title {
|
||||
contain: layout style paint;
|
||||
}
|
||||
|
||||
/* Settings backdrop — skip expensive blur in performance mode. */
|
||||
#ExtensionPopup ~ *,
|
||||
.outside-container.hide {
|
||||
backdrop-filter: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
html.performanceModeSimpleUi {
|
||||
.bsplus-analytics-charts,
|
||||
.bsplus-analytics-chart-cell {
|
||||
display: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
/* Boot loading spinner uses shadow DOM; custom properties inherit from the host. */
|
||||
#loading.bkloading {
|
||||
--bk-stage-duration: 0.85s !important;
|
||||
--bk-spin-outer: 1s !important;
|
||||
--bk-spin-inner: 3s !important;
|
||||
--bk-spin-small: 3s !important;
|
||||
}
|
||||
|
||||
html.performanceMode.transparencyEffects,
|
||||
html.performanceMode .backdrop-blur-xl,
|
||||
html.performanceMode .backdrop-blur-sm,
|
||||
html.performanceMode [class*="backdrop-blur"] {
|
||||
backdrop-filter: none !important;
|
||||
-webkit-backdrop-filter: none !important;
|
||||
}
|
||||
|
||||
/* Sidebar drill locks: `.drilling` on the list handles pointer-events in perf mode —
|
||||
skip expensive `:has()` selectors that drive hit-test cost during mouse moves. */
|
||||
html.performanceMode #menu.bsplus-custom-sidebar {
|
||||
&:has(> #bsplus-sidebar-root > li.hasChildren.bsplus-active > .sub)
|
||||
> #bsplus-sidebar-root
|
||||
> li:not(.hasChildren.bsplus-active),
|
||||
&:has(> #bsplus-sidebar-root > li.hasChildren.bsplus-active > .sub)
|
||||
> #bsplus-sidebar-root
|
||||
> li:not(.hasChildren.bsplus-active)
|
||||
* {
|
||||
pointer-events: unset !important;
|
||||
}
|
||||
|
||||
> #bsplus-sidebar-root:has(> li.hasChildren.bsplus-active > .sub)
|
||||
> li:not(.hasChildren.bsplus-active)::before,
|
||||
> #bsplus-sidebar-root:has(> li.hasChildren.bsplus-active > .sub)
|
||||
> li:not(.hasChildren.bsplus-active)::after {
|
||||
content: none !important;
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
> #bsplus-sidebar-root li.hasChildren.bsplus-active
|
||||
> .sub:has(.hasChildren.bsplus-active) {
|
||||
pointer-events: unset !important;
|
||||
}
|
||||
|
||||
> #bsplus-sidebar-root.drilling li.hasChildren > .sub:not(:has(.sub)) {
|
||||
pointer-events: auto !important;
|
||||
}
|
||||
|
||||
> #bsplus-sidebar-root.drilling li.hasChildren > .sub:has(.sub) {
|
||||
pointer-events: unset !important;
|
||||
}
|
||||
}
|
||||
@@ -34,9 +34,16 @@
|
||||
#ExtensionPopup {
|
||||
border-radius: 0;
|
||||
filter: none;
|
||||
/* Avoid transform on the host — it makes shadow `position: fixed` children
|
||||
size to the host instead of the viewport on Engage stacking contexts. */
|
||||
transform-origin: center center;
|
||||
will-change: opacity;
|
||||
transition: opacity 0.05s;
|
||||
opacity: 0;
|
||||
transition: opacity var(--bs-motion-duration, 0.2s) cubic-bezier(0.22, 1, 0.36, 1);
|
||||
}
|
||||
|
||||
#ExtensionPopup.bsplus-settings-host--open {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
#ExtensionPopup.bsplus-settings-host--closing {
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<script lang="ts">
|
||||
import type { Component } from "svelte";
|
||||
|
||||
let {
|
||||
loader,
|
||||
props = {},
|
||||
remountKey = "default",
|
||||
}: {
|
||||
loader: () => Promise<{ default: Component }>;
|
||||
props?: Record<string, unknown>;
|
||||
/** Change to force a fresh import (e.g. different panel). Props-only updates reuse the component. */
|
||||
remountKey?: string;
|
||||
} = $props();
|
||||
|
||||
let Comp = $state<Component | null>(null);
|
||||
let loadedKey = $state("");
|
||||
|
||||
$effect(() => {
|
||||
const key = remountKey;
|
||||
if (key === loadedKey && Comp) return;
|
||||
|
||||
loadedKey = key;
|
||||
Comp = null;
|
||||
void loader().then((mod) => {
|
||||
if (loadedKey === key) Comp = mod.default;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
{#if Comp}
|
||||
<Comp {...props} />
|
||||
{:else}
|
||||
<div class="px-2 py-8 text-sm text-zinc-400 animate-pulse">Loading…</div>
|
||||
{/if}
|
||||
@@ -1,6 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { onMount, onDestroy } from 'svelte';
|
||||
import { animate as motionAnimate } from 'motion';
|
||||
import { fullMotionEffectsEnabled } from '@/seqta/utils/performanceMode';
|
||||
|
||||
let { initial, animate, exit, transition, children, class: className } = $props<{
|
||||
initial?: any,
|
||||
@@ -13,8 +14,27 @@
|
||||
|
||||
let divElement: HTMLElement;
|
||||
|
||||
const applyCssKeyframe = (keyframe: Record<string, unknown>) => {
|
||||
if (!divElement || !keyframe) return;
|
||||
if (keyframe.x != null) {
|
||||
divElement.style.transition =
|
||||
'transform var(--bs-motion-duration, 0.2s) var(--bs-motion-ease, cubic-bezier(0.22, 1, 0.36, 1))';
|
||||
const x = keyframe.x;
|
||||
divElement.style.transform =
|
||||
typeof x === 'number' ? `translateX(${x}px)` : `translateX(${String(x)})`;
|
||||
}
|
||||
if (typeof keyframe.opacity === 'number') {
|
||||
divElement.style.opacity = String(keyframe.opacity);
|
||||
}
|
||||
};
|
||||
|
||||
const playAnimation = (keyframe: any) => {
|
||||
if (divElement && keyframe) {
|
||||
if (!fullMotionEffectsEnabled()) {
|
||||
applyCssKeyframe(keyframe);
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
let finalKeyframe = { ...keyframe };
|
||||
|
||||
if (finalKeyframe.height === 'auto') {
|
||||
@@ -72,7 +92,7 @@
|
||||
});
|
||||
</script>
|
||||
|
||||
<div class={className} bind:this={divElement} style="will-change: transform, opacity;">
|
||||
<div class={className} bind:this={divElement} style={fullMotionEffectsEnabled() ? 'will-change: transform, opacity;' : undefined}>
|
||||
{#if children}
|
||||
{@render children()}
|
||||
{/if}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { settingsState } from "@/seqta/utils/listeners/SettingsState";
|
||||
import { animationsEnabled } from "@/seqta/utils/performanceMode";
|
||||
import { rafThrottle } from "@/seqta/utils/rafThrottle";
|
||||
import SidebarNavItem from "./SidebarNavItem.svelte";
|
||||
|
||||
type NavGroup = {
|
||||
@@ -39,11 +40,13 @@
|
||||
indicatorReady = true;
|
||||
};
|
||||
|
||||
const scheduleIndicator = rafThrottle(updateIndicator);
|
||||
|
||||
$effect(() => {
|
||||
selectedId;
|
||||
groups;
|
||||
trackEl;
|
||||
queueMicrotask(updateIndicator);
|
||||
scheduleIndicator();
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -54,8 +57,8 @@
|
||||
{#if indicatorReady}
|
||||
<div
|
||||
class="pointer-events-none absolute left-0 top-0 z-0 rounded-lg bg-zinc-200/90 dark:bg-zinc-700/90"
|
||||
style="transform: translate({indicatorX}px, {indicatorY}px); width: {indicatorW}px; height: {indicatorH}px; transition: {$settingsState.animations
|
||||
? 'transform 0.28s cubic-bezier(0.22, 1, 0.36, 1), width 0.28s cubic-bezier(0.22, 1, 0.36, 1), height 0.28s cubic-bezier(0.22, 1, 0.36, 1)'
|
||||
style="transform: translate({indicatorX}px, {indicatorY}px); width: {indicatorW}px; height: {indicatorH}px; transition: {animationsEnabled()
|
||||
? 'transform var(--bs-motion-duration, 0.28s) var(--bs-motion-ease, cubic-bezier(0.22, 1, 0.36, 1)), width var(--bs-motion-duration, 0.28s) var(--bs-motion-ease, cubic-bezier(0.22, 1, 0.36, 1)), height var(--bs-motion-duration, 0.28s) var(--bs-motion-ease, cubic-bezier(0.22, 1, 0.36, 1))'
|
||||
: 'none'};"
|
||||
></div>
|
||||
{/if}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { animate } from 'motion';
|
||||
import { standalone } from '../utils/standalone.svelte'
|
||||
import { standalone } from '../utils/standalone.svelte';
|
||||
import { fullMotionEffectsEnabled } from '@/seqta/utils/performanceMode';
|
||||
|
||||
let { state, onChange } = $props<{ state: boolean, onChange: (newState: boolean) => void }>();
|
||||
let handle: HTMLElement | null = null;
|
||||
@@ -10,13 +11,18 @@
|
||||
damping: 30,
|
||||
};
|
||||
|
||||
const knobX = $derived(state ? (standalone.standalone ? 24 : 20) : 0);
|
||||
|
||||
const animateSwitch = (enabled: boolean) => {
|
||||
if (!handle) return;
|
||||
const x = enabled ? (standalone.standalone ? 24 : 20) : 0;
|
||||
if (!fullMotionEffectsEnabled()) {
|
||||
handle.style.transform = `translateX(${x}px)`;
|
||||
return;
|
||||
}
|
||||
animate(
|
||||
handle,
|
||||
{
|
||||
x: enabled ? (standalone.standalone ? 24 : 20) : 0,
|
||||
},
|
||||
{ x },
|
||||
{
|
||||
type: 'spring',
|
||||
stiffness: springParams.stiffness,
|
||||
@@ -25,7 +31,6 @@
|
||||
);
|
||||
};
|
||||
|
||||
// Trigger animation whenever state changes
|
||||
$effect(() => animateSwitch(state));
|
||||
</script>
|
||||
|
||||
@@ -39,6 +44,7 @@
|
||||
>
|
||||
<div
|
||||
bind:this={handle}
|
||||
class="w-6 h-6 bg-white dark:bg-[#FEFEFE] rounded-full drop-shadow-md"
|
||||
class="w-6 h-6 bg-white dark:bg-[#FEFEFE] rounded-full drop-shadow-md transition-transform duration-200"
|
||||
style={fullMotionEffectsEnabled() ? undefined : `transform: translateX(${knobX}px)`}
|
||||
></div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,39 +1,60 @@
|
||||
<script lang="ts">
|
||||
import MotionDiv from './MotionDiv.svelte';
|
||||
import { onMount } from 'svelte';
|
||||
import MotionDiv from "./MotionDiv.svelte";
|
||||
import LazyPanel from "./LazyPanel.svelte";
|
||||
import type { Component } from "svelte";
|
||||
import { onMount } from "svelte";
|
||||
|
||||
let { tabs, activeTab = $bindable(0) } = $props<{ tabs: { title: string, Content: any, props?: any }[]; activeTab?: number }>();
|
||||
let containerRef: HTMLElement | null = null;
|
||||
type TabDef = {
|
||||
title: string;
|
||||
Content?: Component;
|
||||
loader?: () => Promise<{ default: Component }>;
|
||||
props?: Record<string, unknown>;
|
||||
};
|
||||
|
||||
let { tabs, activeTab = $bindable(0) } = $props<{
|
||||
tabs: TabDef[];
|
||||
activeTab?: number;
|
||||
}>();
|
||||
|
||||
let containerRef: HTMLElement | null = $state(null);
|
||||
let tabWidth = $state(0);
|
||||
let containerWidth = $state(0);
|
||||
|
||||
const springTransition = { type: 'spring', stiffness: 250, damping: 25 };
|
||||
const springTransition = { type: "spring", stiffness: 250, damping: 25 };
|
||||
|
||||
const updateTabWidth = () => {
|
||||
tabWidth = tabs.length > 0 ? 100 / tabs.length : 0;
|
||||
function measureTabs() {
|
||||
if (!containerRef || tabs.length === 0) return;
|
||||
tabWidth = 100 / tabs.length;
|
||||
containerRef.style.setProperty("--tab-width", `${tabWidth}%`);
|
||||
containerWidth = containerRef.getBoundingClientRect().width;
|
||||
}
|
||||
|
||||
const indicatorX = $derived((tabWidth * activeTab * containerWidth) / 100);
|
||||
|
||||
$effect(() => {
|
||||
tabs.length;
|
||||
if (!containerRef) return;
|
||||
containerRef.style.setProperty('--tab-width', `${tabWidth}%`);
|
||||
};
|
||||
|
||||
const calcXPos = (index: number | null) => {
|
||||
if (containerRef) {
|
||||
return tabWidth * (index !== null ? index : activeTab) * containerRef.getBoundingClientRect().width / 100;
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
measureTabs();
|
||||
requestAnimationFrame(measureTabs);
|
||||
|
||||
const ro =
|
||||
typeof ResizeObserver !== "undefined"
|
||||
? new ResizeObserver(measureTabs)
|
||||
: null;
|
||||
ro?.observe(containerRef);
|
||||
|
||||
return () => ro?.disconnect();
|
||||
});
|
||||
|
||||
onMount(() => {
|
||||
updateTabWidth();
|
||||
|
||||
const handleMessage = (event: MessageEvent) => {
|
||||
if (event.data === "popupClosed") {
|
||||
activeTab = 0;
|
||||
}
|
||||
};
|
||||
window.addEventListener("message", handleMessage);
|
||||
|
||||
return () => {
|
||||
window.removeEventListener("message", handleMessage);
|
||||
};
|
||||
return () => window.removeEventListener("message", handleMessage);
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -42,7 +63,7 @@
|
||||
<div bind:this={containerRef} class="flex relative">
|
||||
<MotionDiv
|
||||
class="absolute top-0 left-0 z-0 h-full bg-gradient-to-tr dark:from-[#38373D]/80 dark:to-[#38373D] from-[#DDDDDD]/80 to-[#DDDDDD] rounded-full opacity-40 tab-width"
|
||||
animate={{ x: calcXPos(activeTab) }}
|
||||
animate={{ x: indicatorX }}
|
||||
transition={springTransition}
|
||||
/>
|
||||
{#each tabs as { title }, index}
|
||||
@@ -50,7 +71,7 @@
|
||||
role="tab"
|
||||
aria-selected={activeTab === index}
|
||||
class="relative z-10 flex-1 px-4 py-2 focus-visible:outline-none"
|
||||
onclick={() => activeTab = index}
|
||||
onclick={() => (activeTab = index)}
|
||||
>
|
||||
{title}
|
||||
</button>
|
||||
@@ -58,7 +79,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="overflow-hidden px-4 flex-1 min-h-0">
|
||||
{#each tabs as { Content, props }, index (index)}
|
||||
{#each tabs as tab, index (index)}
|
||||
{#if activeTab === index}
|
||||
<div
|
||||
role="tabpanel"
|
||||
@@ -68,7 +89,11 @@
|
||||
class="sticky top-0 w-full h-3 -mb-3 bg-gradient-to-b from-white/80 dark:from-zinc-800/80 to-transparent pointer-events-none z-[1]"
|
||||
aria-hidden="true"
|
||||
></div>
|
||||
<Content {...props} />
|
||||
{#if tab.loader}
|
||||
<LazyPanel loader={tab.loader} props={tab.props} />
|
||||
{:else if tab.Content}
|
||||
<tab.Content {...tab.props} />
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
{/each}
|
||||
|
||||
@@ -9,25 +9,51 @@
|
||||
let { isEditMode, selectNoBackground = $bindable(), selectedBackground = $bindable() } = $props<{ isEditMode: boolean, selectNoBackground: () => void, selectedBackground: string | null }>();
|
||||
let backgrounds = $state<{ id: string; type: string; blob: Blob | null; url?: string }[]>([]);
|
||||
let error = $state<string | null>(null);
|
||||
let notice = $state<string | null>(null);
|
||||
let uploading = $state(false);
|
||||
|
||||
let imageBackgrounds = $derived(backgrounds.filter(bg => bg.type === 'image'));
|
||||
let videoBackgrounds = $derived(backgrounds.filter(bg => bg.type === 'video'));
|
||||
|
||||
function inferBackgroundType(file: File): 'image' | 'video' {
|
||||
const mime = file.type.toLowerCase();
|
||||
if (mime.startsWith('video/')) return 'video';
|
||||
if (mime.startsWith('image/')) return 'image';
|
||||
const ext = file.name.split('.').pop()?.toLowerCase() ?? '';
|
||||
if (['mp4', 'mov', 'webm', 'm4v', 'mkv'].includes(ext)) return 'video';
|
||||
return 'image';
|
||||
}
|
||||
|
||||
function setError(e: unknown) {
|
||||
error = e instanceof Error ? e.message : 'An unknown error occurred';
|
||||
if (e instanceof Error) {
|
||||
error = e.message;
|
||||
return;
|
||||
}
|
||||
if (typeof e === 'string' && e) {
|
||||
error = e;
|
||||
return;
|
||||
}
|
||||
error = 'An unknown error occurred';
|
||||
}
|
||||
|
||||
async function getTheme() {
|
||||
return localStorage.getItem('selectedBackground');
|
||||
}
|
||||
|
||||
async function setTheme(theme: string) {
|
||||
localStorage.setItem('selectedBackground', theme);
|
||||
function isHeicFile(file: File): boolean {
|
||||
const mime = file.type.toLowerCase();
|
||||
const ext = file.name.split('.').pop()?.toLowerCase() ?? '';
|
||||
return (
|
||||
mime.includes('heic') ||
|
||||
mime.includes('heif') ||
|
||||
ext === 'heic' ||
|
||||
ext === 'heif'
|
||||
);
|
||||
}
|
||||
|
||||
async function handleFileChange(file: File): Promise<void> {
|
||||
if (!file) return;
|
||||
|
||||
uploading = true;
|
||||
error = null;
|
||||
notice = null;
|
||||
|
||||
try {
|
||||
if (!isIndexedDBSupported()) {
|
||||
throw new Error("Your browser doesn't support IndexedDB. Unable to save backgrounds.");
|
||||
@@ -38,17 +64,36 @@
|
||||
throw new Error("Not enough storage space to save this background.");
|
||||
}
|
||||
|
||||
const fileId = `${Date.now()}-${file.name}`;
|
||||
const fileType = file.type.split('/')[0];
|
||||
const blob = new Blob([file], { type: file.type });
|
||||
const fileId = `${Date.now()}-${file.name.replace(/[^\w.-]+/g, '_')}`;
|
||||
const fileType = inferBackgroundType(file);
|
||||
const blob = file.slice(0, file.size, file.type || (fileType === 'video' ? 'video/mp4' : 'image/jpeg'));
|
||||
|
||||
await writeData(fileId, fileType, blob);
|
||||
backgrounds = [...backgrounds, { id: fileId, type: fileType, blob, url: URL.createObjectURL(blob) }];
|
||||
backgrounds = [
|
||||
...backgrounds,
|
||||
{ id: fileId, type: fileType, blob, url: URL.createObjectURL(blob) },
|
||||
];
|
||||
backgroundUpdates.triggerUpdate();
|
||||
|
||||
if (isHeicFile(file)) {
|
||||
notice =
|
||||
'HEIC saved, but Chrome and Edge often cannot preview it. Export as JPEG or PNG if the thumbnail stays blank.';
|
||||
}
|
||||
} catch (e) {
|
||||
setError(e);
|
||||
} finally {
|
||||
uploading = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function getTheme() {
|
||||
return localStorage.getItem('selectedBackground');
|
||||
}
|
||||
|
||||
async function setTheme(theme: string) {
|
||||
localStorage.setItem('selectedBackground', theme);
|
||||
}
|
||||
|
||||
async function syncBackgrounds(): Promise<void> {
|
||||
try {
|
||||
error = null;
|
||||
@@ -100,8 +145,9 @@
|
||||
if (selectedBackground === fileId) {
|
||||
selectNoBackground();
|
||||
}
|
||||
backgroundUpdates.triggerUpdate();
|
||||
} catch (e) {
|
||||
error = e instanceof Error ? `Failed to delete background: ${e.message}` : 'An unknown error occurred';
|
||||
setError(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,11 +184,34 @@
|
||||
</script>
|
||||
|
||||
<div class="relative px-1 { !( isEditMode && imageBackgrounds.length === 0 && videoBackgrounds.length === 0 ) && 'pt-2' }">
|
||||
{#if notice}
|
||||
<div
|
||||
class="mx-1 mb-3 rounded-lg border border-amber-300/60 bg-amber-50 px-3 py-2 text-sm text-amber-900 dark:border-amber-900/50 dark:bg-amber-950/40 dark:text-amber-100"
|
||||
role="status"
|
||||
>
|
||||
{notice}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if error}
|
||||
<div
|
||||
class="mx-1 mb-3 rounded-lg border border-red-300/60 bg-red-50 px-3 py-2 text-sm text-red-800 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-200"
|
||||
role="alert"
|
||||
>
|
||||
{error}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if !(imageBackgrounds.length === 0 && isEditMode)}
|
||||
<h2 class="pb-2 text-lg font-bold">Background Images</h2>
|
||||
<div class="flex flex-wrap gap-4 mb-4">
|
||||
{#if !isEditMode}
|
||||
<BackgroundUploader on:fileChange={e => handleFileChange(e.detail)} />
|
||||
<BackgroundUploader onFileChange={handleFileChange} />
|
||||
{#if uploading}
|
||||
<div class="flex h-16 w-16 items-center justify-center rounded-xl bg-zinc-100 dark:bg-zinc-900">
|
||||
<div class="h-5 w-5 animate-spin rounded-full border-2 border-zinc-400 border-t-transparent"></div>
|
||||
</div>
|
||||
{/if}
|
||||
{/if}
|
||||
{#each imageBackgrounds as bg (bg.id)}
|
||||
{#if bg.url}
|
||||
@@ -163,7 +232,7 @@
|
||||
<h2 class="py-2 text-lg font-bold">Background Videos</h2>
|
||||
<div class="flex flex-wrap gap-4">
|
||||
{#if !isEditMode}
|
||||
<BackgroundUploader on:fileChange={e => handleFileChange(e.detail)} />
|
||||
<BackgroundUploader onFileChange={handleFileChange} />
|
||||
{/if}
|
||||
{#each videoBackgrounds as bg (bg.id)}
|
||||
{#if bg.url}
|
||||
|
||||
@@ -1,26 +1,29 @@
|
||||
<script lang="ts">
|
||||
import { createEventDispatcher } from 'svelte';
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
let { onFileChange }: { onFileChange?: (file: File) => void } = $props();
|
||||
|
||||
function handleFileChange(event: Event) {
|
||||
const input = event.target as HTMLInputElement;
|
||||
const input = event.currentTarget as HTMLInputElement;
|
||||
const file = input.files?.[0];
|
||||
if (file) {
|
||||
dispatch('fileChange', file);
|
||||
onFileChange?.(file);
|
||||
}
|
||||
// Allow re-selecting the same file.
|
||||
input.value = "";
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="relative w-16 h-16 overflow-hidden transition rounded-xl bg-zinc-100 dark:bg-zinc-900">
|
||||
<div class="flex items-center justify-center w-full h-full text-3xl font-bold text-gray-400 transition font-IconFamily hover:text-gray-500">
|
||||
<!-- Plus icon -->
|
||||
<div
|
||||
class="flex items-center justify-center w-full h-full text-3xl font-bold text-gray-400 transition font-IconFamily hover:text-gray-500 pointer-events-none"
|
||||
>
|
||||
<!-- Plus icon -->
|
||||
|
||||
</div>
|
||||
<input
|
||||
type="file"
|
||||
accept="image/*, video/mp4"
|
||||
on:change={handleFileChange}
|
||||
accept="image/*,video/*,.mp4,.mov,.webm,.m4v,.heic,.heif"
|
||||
onchange={handleFileChange}
|
||||
class="absolute inset-0 w-full h-full opacity-0 cursor-pointer"
|
||||
aria-label="Upload background image or video"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,24 +1,107 @@
|
||||
import localforage from "localforage";
|
||||
|
||||
type BackgroundRecord = { id: string; type: string; blob: Blob };
|
||||
|
||||
const store = localforage.createInstance({
|
||||
name: "BackgroundDB",
|
||||
storeName: "backgrounds",
|
||||
});
|
||||
const DB_NAME = "BackgroundDB";
|
||||
const STORE_NAME = "backgrounds";
|
||||
const DB_VERSION = 1;
|
||||
|
||||
export async function openDatabase(): Promise<typeof store> {
|
||||
await store.ready();
|
||||
return store;
|
||||
let dbPromise: Promise<IDBDatabase> | null = null;
|
||||
|
||||
function promisifyRequest<T>(request: IDBRequest<T>): Promise<T> {
|
||||
return new Promise((resolve, reject) => {
|
||||
request.onsuccess = () => resolve(request.result);
|
||||
request.onerror = () => reject(request.error);
|
||||
});
|
||||
}
|
||||
|
||||
function waitForTransaction(tx: IDBTransaction): Promise<void> {
|
||||
return new Promise((resolve, reject) => {
|
||||
tx.oncomplete = () => resolve();
|
||||
tx.onerror = () => reject(tx.error);
|
||||
tx.onabort = () => reject(tx.error);
|
||||
});
|
||||
}
|
||||
|
||||
function openDatabaseInternal(): Promise<IDBDatabase> {
|
||||
if (!dbPromise) {
|
||||
dbPromise = new Promise((resolve, reject) => {
|
||||
const request = indexedDB.open(DB_NAME, DB_VERSION);
|
||||
|
||||
request.onerror = () => {
|
||||
dbPromise = null;
|
||||
reject(request.error);
|
||||
};
|
||||
|
||||
request.onupgradeneeded = () => {
|
||||
const db = request.result;
|
||||
if (!db.objectStoreNames.contains(STORE_NAME)) {
|
||||
db.createObjectStore(STORE_NAME, { keyPath: "id" });
|
||||
}
|
||||
};
|
||||
|
||||
request.onsuccess = () => resolve(request.result);
|
||||
});
|
||||
}
|
||||
|
||||
return dbPromise;
|
||||
}
|
||||
|
||||
function storeUsesInlineKeys(store: IDBObjectStore): boolean {
|
||||
return store.keyPath !== null && store.keyPath !== "";
|
||||
}
|
||||
|
||||
async function withStore<T>(
|
||||
mode: IDBTransactionMode,
|
||||
run: (store: IDBObjectStore) => Promise<T>,
|
||||
): Promise<T> {
|
||||
const db = await openDatabaseInternal();
|
||||
const tx = db.transaction(STORE_NAME, mode);
|
||||
const result = await run(tx.objectStore(STORE_NAME));
|
||||
await waitForTransaction(tx);
|
||||
return result;
|
||||
}
|
||||
|
||||
export async function openDatabase(): Promise<IDBDatabase> {
|
||||
return openDatabaseInternal();
|
||||
}
|
||||
|
||||
export async function readAllData(): Promise<BackgroundRecord[]> {
|
||||
await store.ready();
|
||||
const items: BackgroundRecord[] = [];
|
||||
await store.iterate<BackgroundRecord, void>((value) => {
|
||||
if (value?.id && value.blob) items.push(value);
|
||||
return withStore("readonly", async (store) => {
|
||||
const items: BackgroundRecord[] = [];
|
||||
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
const request = store.openCursor();
|
||||
|
||||
request.onsuccess = () => {
|
||||
const cursor = request.result;
|
||||
if (!cursor) {
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
const value = cursor.value as Partial<BackgroundRecord> | undefined;
|
||||
const id =
|
||||
typeof value?.id === "string"
|
||||
? value.id
|
||||
: cursor.key == null
|
||||
? ""
|
||||
: String(cursor.key);
|
||||
|
||||
if (id && value?.blob instanceof Blob) {
|
||||
items.push({
|
||||
id,
|
||||
type: typeof value.type === "string" ? value.type : "image",
|
||||
blob: value.blob,
|
||||
});
|
||||
}
|
||||
|
||||
cursor.continue();
|
||||
};
|
||||
|
||||
request.onerror = () => reject(request.error);
|
||||
});
|
||||
|
||||
return items;
|
||||
});
|
||||
return items;
|
||||
}
|
||||
|
||||
export async function writeData(
|
||||
@@ -26,25 +109,54 @@ export async function writeData(
|
||||
type: string,
|
||||
blob: Blob,
|
||||
): Promise<void> {
|
||||
await store.setItem(id, { id, type, blob });
|
||||
const record: BackgroundRecord = { id, type, blob };
|
||||
|
||||
try {
|
||||
await withStore("readwrite", async (store) => {
|
||||
const request = storeUsesInlineKeys(store)
|
||||
? store.put(record)
|
||||
: store.put(record, id);
|
||||
await promisifyRequest(request);
|
||||
});
|
||||
} catch (e) {
|
||||
const detail = e instanceof Error ? e.message : String(e);
|
||||
throw new Error(`Failed to save background: ${detail}`);
|
||||
}
|
||||
}
|
||||
|
||||
export async function deleteData(id: string): Promise<void> {
|
||||
await store.removeItem(id);
|
||||
try {
|
||||
await withStore("readwrite", async (store) => {
|
||||
await promisifyRequest(store.delete(id));
|
||||
});
|
||||
} catch (e) {
|
||||
const detail = e instanceof Error ? e.message : String(e);
|
||||
throw new Error(`Failed to delete background: ${detail}`);
|
||||
}
|
||||
}
|
||||
|
||||
export async function clearAllData(): Promise<void> {
|
||||
await store.clear();
|
||||
await withStore("readwrite", async (store) => {
|
||||
await promisifyRequest(store.clear());
|
||||
});
|
||||
}
|
||||
|
||||
export async function getDataById(
|
||||
id: string,
|
||||
): Promise<BackgroundRecord | undefined> {
|
||||
const item = await store.getItem<BackgroundRecord>(id);
|
||||
return item ?? undefined;
|
||||
const item = await withStore("readonly", async (store) =>
|
||||
promisifyRequest(store.get(id)),
|
||||
);
|
||||
if (!item?.id || !(item.blob instanceof Blob)) return undefined;
|
||||
return item as BackgroundRecord;
|
||||
}
|
||||
|
||||
export function closeDatabase(): void {}
|
||||
export function closeDatabase(): void {
|
||||
if (dbPromise) {
|
||||
void dbPromise.then((db) => db.close());
|
||||
dbPromise = null;
|
||||
}
|
||||
}
|
||||
|
||||
export function isIndexedDBSupported(): boolean {
|
||||
return "indexedDB" in window;
|
||||
|
||||
@@ -39,6 +39,21 @@ input {
|
||||
scrollbar-width: none !important;
|
||||
}
|
||||
|
||||
[data-settings-panel] {
|
||||
transform: scale(0.94);
|
||||
opacity: 0;
|
||||
transform-origin: center center;
|
||||
transition:
|
||||
transform var(--bs-motion-duration, 0.22s) cubic-bezier(0.22, 1, 0.36, 1),
|
||||
opacity var(--bs-motion-duration, 0.22s) cubic-bezier(0.22, 1, 0.36, 1);
|
||||
will-change: transform, opacity;
|
||||
}
|
||||
|
||||
[data-settings-panel].bsplus-settings-panel--open {
|
||||
transform: scale(1);
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.cm-editor {
|
||||
width: 100%;
|
||||
min-height: 100px;
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
<script lang="ts">
|
||||
import Settings from "./settings/general.svelte";
|
||||
import Shortcuts from "./settings/shortcuts.svelte";
|
||||
import Theme from "./settings/theme.svelte";
|
||||
import Store from "./store.svelte";
|
||||
import TabbedContainer from "../components/TabbedContainer.svelte";
|
||||
import LazyPanel from "../components/LazyPanel.svelte";
|
||||
import darkLogo from "@/resources/icons/betterseqta-dark-full.png";
|
||||
import lightLogo from "@/resources/icons/betterseqta-light-full.png";
|
||||
import { resolveExtensionAssetUrl } from "@/lib/extensionAssetUrl";
|
||||
@@ -11,16 +8,13 @@
|
||||
import { standalone as StandaloneStore } from "../utils/standalone.svelte";
|
||||
import { onMount, onDestroy } from "svelte";
|
||||
import { settingsState } from "@/seqta/utils/listeners/SettingsState";
|
||||
import { isPerformanceMode } from "@/seqta/utils/performanceMode";
|
||||
|
||||
import { closeExtensionPopup } from "@/seqta/utils/Closers/closeExtensionPopup";
|
||||
import { OpenAboutPage } from "@/seqta/utils/Openers/OpenAboutPage";
|
||||
import { OpenWhatsNewPopup } from "@/seqta/utils/Openers/OpenWhatsNewPopup";
|
||||
|
||||
import type { Component } from "svelte";
|
||||
import FontPickerModal from "../components/FontPickerModal.svelte";
|
||||
import CloudPanel from "../components/CloudPanel.svelte";
|
||||
import DisclaimerModal from "../components/DisclaimerModal.svelte";
|
||||
import FeedbackModal from "../components/FeedbackModal.svelte";
|
||||
import SidebarNav from "../components/SidebarNav.svelte";
|
||||
import StoreHeader from "../components/store/Header.svelte";
|
||||
import { settingsPopup } from "@/seqta/utils/settingsPopup";
|
||||
@@ -42,6 +36,11 @@
|
||||
type ThemeView = "theme-settings" | "theme-store";
|
||||
type BackgroundView = "background-settings" | "background-store";
|
||||
|
||||
const loadSettingsBody = () => import("./settings/SettingsBody.svelte");
|
||||
const loadShortcuts = () => import("./settings/shortcuts.svelte");
|
||||
const loadThemeSettings = () => import("./settings/theme.svelte");
|
||||
const loadStore = () => import("./store.svelte");
|
||||
|
||||
type NavItem = {
|
||||
id: string;
|
||||
label: string;
|
||||
@@ -62,6 +61,18 @@
|
||||
let backgroundCategories = $state<string[]>([]);
|
||||
let storeSearchTerm = $state("");
|
||||
let settingsSearch = $state("");
|
||||
let debouncedSettingsSearch = $state("");
|
||||
let settingsSearchTimer: ReturnType<typeof setTimeout> | null = null;
|
||||
|
||||
$effect(() => {
|
||||
const query = settingsSearch;
|
||||
if (settingsSearchTimer) clearTimeout(settingsSearchTimer);
|
||||
const delay = isPerformanceMode() ? 250 : 150;
|
||||
settingsSearchTimer = setTimeout(() => {
|
||||
debouncedSettingsSearch = query;
|
||||
settingsSearchTimer = null;
|
||||
}, delay);
|
||||
});
|
||||
|
||||
let showDisclaimerModal = $state(false);
|
||||
let disclaimerCallbacks = $state<{ onConfirm: () => void; onCancel: () => void } | null>(null);
|
||||
@@ -143,7 +154,7 @@
|
||||
);
|
||||
|
||||
const sectionTitle = $derived.by(() => {
|
||||
if (activePage === "settings" && settingsSearch.trim()) return "Search results";
|
||||
if (activePage === "settings" && debouncedSettingsSearch.trim()) return "Search results";
|
||||
if (activePage === "themes") return "Themes";
|
||||
if (activePage === "backgrounds") return "Backgrounds";
|
||||
return [...userNav, ...appNav].find((item) => item.id === activeSection)?.label ?? "Settings";
|
||||
@@ -182,6 +193,10 @@
|
||||
};
|
||||
|
||||
let ColourPickerComponent = $state<Component | null>(null);
|
||||
let FontPickerComponent = $state<Component | null>(null);
|
||||
let CloudPanelComponent = $state<Component | null>(null);
|
||||
let DisclaimerModalComponent = $state<Component | null>(null);
|
||||
let FeedbackModalComponent = $state<Component | null>(null);
|
||||
|
||||
const openColourPicker = async () => {
|
||||
if (!ColourPickerComponent) {
|
||||
@@ -190,7 +205,10 @@
|
||||
showColourPicker = true;
|
||||
};
|
||||
|
||||
const openFontPicker = () => {
|
||||
const openFontPicker = async () => {
|
||||
if (!FontPickerComponent) {
|
||||
FontPickerComponent = (await import("../components/FontPickerModal.svelte")).default;
|
||||
}
|
||||
showFontPicker = true;
|
||||
};
|
||||
|
||||
@@ -216,27 +234,43 @@
|
||||
let showFeedbackModal = $state<boolean>(false);
|
||||
let feedbackFocusId = $state<string | null>(null);
|
||||
|
||||
const openCloudPanel = () => {
|
||||
const openCloudPanel = async () => {
|
||||
if (!CloudPanelComponent) {
|
||||
CloudPanelComponent = (await import("../components/CloudPanel.svelte")).default;
|
||||
}
|
||||
showCloudPanel = true;
|
||||
};
|
||||
|
||||
const openFeedback = (feedbackId?: string | null) => {
|
||||
const openFeedback = async (feedbackId?: string | null) => {
|
||||
if (!FeedbackModalComponent) {
|
||||
FeedbackModalComponent = (await import("../components/FeedbackModal.svelte")).default;
|
||||
}
|
||||
feedbackFocusId = typeof feedbackId === "string" && feedbackId ? feedbackId : null;
|
||||
showFeedbackModal = true;
|
||||
};
|
||||
|
||||
const showDisclaimer = (
|
||||
const showDisclaimer = async (
|
||||
onConfirm: () => void,
|
||||
onCancel: () => void,
|
||||
title = "Confirm",
|
||||
message = "",
|
||||
) => {
|
||||
if (!DisclaimerModalComponent) {
|
||||
DisclaimerModalComponent = (await import("../components/DisclaimerModal.svelte")).default;
|
||||
}
|
||||
disclaimerCallbacks = { onConfirm, onCancel };
|
||||
disclaimerTitle = title;
|
||||
disclaimerMessage = message;
|
||||
showDisclaimerModal = true;
|
||||
};
|
||||
|
||||
const settingsSharedProps = {
|
||||
showColourPicker: openColourPicker,
|
||||
showFontPicker: openFontPicker,
|
||||
showDisclaimer,
|
||||
showCloudPanel: openCloudPanel,
|
||||
};
|
||||
|
||||
const closePopupsOnSettingsClose = () => {
|
||||
showColourPicker = false;
|
||||
showFontPicker = false;
|
||||
@@ -312,9 +346,16 @@
|
||||
}
|
||||
|
||||
if (ghReleaseUpdateEnabled) {
|
||||
void checkGithubReleaseUpdate().then((info) => {
|
||||
ghReleaseUpdate = info;
|
||||
});
|
||||
const runCheck = () => {
|
||||
void checkGithubReleaseUpdate().then((info) => {
|
||||
ghReleaseUpdate = info;
|
||||
});
|
||||
};
|
||||
if (typeof requestIdleCallback === "function") {
|
||||
requestIdleCallback(runCheck, { timeout: 4000 });
|
||||
} else {
|
||||
setTimeout(runCheck, 500);
|
||||
}
|
||||
}
|
||||
|
||||
const pendingFeedbackId = consumeOpenFeedbackRequest();
|
||||
@@ -468,17 +509,22 @@
|
||||
|
||||
{#if isStoreView}
|
||||
<div class="min-w-0 min-h-0 flex-1">
|
||||
<Store
|
||||
activeTab={activePage as StoreTab}
|
||||
searchTerm={storeSearchTerm}
|
||||
{selectedBackgroundCategory}
|
||||
setActiveTab={(tab) => {
|
||||
activePage = tab;
|
||||
if (tab === "themes") activeThemeView = "theme-store";
|
||||
else activeBackgroundView = "background-store";
|
||||
<LazyPanel
|
||||
loader={loadStore}
|
||||
remountKey="store"
|
||||
props={{
|
||||
activeTab: activePage as StoreTab,
|
||||
searchTerm: storeSearchTerm,
|
||||
selectedBackgroundCategory,
|
||||
setActiveTab: (tab: StoreTab) => {
|
||||
activePage = tab;
|
||||
if (tab === "themes") activeThemeView = "theme-store";
|
||||
else activeBackgroundView = "background-store";
|
||||
},
|
||||
setSearchTerm: (term: string) => (storeSearchTerm = term),
|
||||
setBackgroundCategories: (categories: string[]) =>
|
||||
(backgroundCategories = categories),
|
||||
}}
|
||||
setSearchTerm={(term) => (storeSearchTerm = term)}
|
||||
setBackgroundCategories={(categories) => (backgroundCategories = categories)}
|
||||
/>
|
||||
</div>
|
||||
{:else}
|
||||
@@ -490,25 +536,38 @@
|
||||
</div>
|
||||
<div class="flex-1 min-h-0 px-4 pb-8 overflow-y-auto no-scrollbar">
|
||||
{#if activePage === "settings"}
|
||||
{#if activeSection === "shortcuts" && !settingsSearch.trim()}
|
||||
<Shortcuts />
|
||||
{#if activeSection === "shortcuts" && !debouncedSettingsSearch.trim()}
|
||||
<LazyPanel loader={loadShortcuts} remountKey="shortcuts-page" />
|
||||
{:else}
|
||||
<Settings
|
||||
showColourPicker={openColourPicker}
|
||||
showFontPicker={openFontPicker}
|
||||
{showDisclaimer}
|
||||
showCloudPanel={openCloudPanel}
|
||||
activeSection={settingsSearch.trim() ? "all" : activeSection}
|
||||
searchQuery={settingsSearch}
|
||||
<LazyPanel
|
||||
loader={loadSettingsBody}
|
||||
remountKey="settings-body"
|
||||
props={{
|
||||
...settingsSharedProps,
|
||||
activeSection: debouncedSettingsSearch.trim() ? "all" : activeSection,
|
||||
searchQuery: debouncedSettingsSearch,
|
||||
}}
|
||||
/>
|
||||
{#if settingsSearch.trim()}
|
||||
<Shortcuts searchQuery={settingsSearch} />
|
||||
{#if debouncedSettingsSearch.trim()}
|
||||
<LazyPanel
|
||||
loader={loadShortcuts}
|
||||
remountKey="shortcuts-search"
|
||||
props={{ searchQuery: debouncedSettingsSearch }}
|
||||
/>
|
||||
{/if}
|
||||
{/if}
|
||||
{:else if activePage === "themes"}
|
||||
<Theme section="themes" />
|
||||
<LazyPanel
|
||||
loader={loadThemeSettings}
|
||||
remountKey="theme-settings"
|
||||
props={{ section: "themes" }}
|
||||
/>
|
||||
{:else}
|
||||
<Theme section="backgrounds" />
|
||||
<LazyPanel
|
||||
loader={loadThemeSettings}
|
||||
remountKey="background-settings"
|
||||
props={{ section: "backgrounds" }}
|
||||
/>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
@@ -548,17 +607,21 @@
|
||||
tabs={[
|
||||
{
|
||||
title: "Settings",
|
||||
Content: Settings,
|
||||
loader: loadSettingsBody,
|
||||
props: {
|
||||
showColourPicker: openColourPicker,
|
||||
showFontPicker: openFontPicker,
|
||||
showDisclaimer,
|
||||
showCloudPanel: openCloudPanel,
|
||||
...settingsSharedProps,
|
||||
activeSection: "all",
|
||||
},
|
||||
},
|
||||
{ title: "Shortcuts", Content: Shortcuts },
|
||||
{ title: "Themes", Content: Theme },
|
||||
{
|
||||
title: "Shortcuts",
|
||||
loader: loadShortcuts,
|
||||
},
|
||||
{
|
||||
title: "Themes",
|
||||
loader: loadThemeSettings,
|
||||
props: { section: "all" },
|
||||
},
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
@@ -584,7 +647,9 @@
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
class="absolute inset-0 bg-black/60 backdrop-blur-sm transition-colors duration-200"
|
||||
class="absolute inset-0 bg-black/60 {$settingsState.performanceMode
|
||||
? 'backdrop-blur-none'
|
||||
: 'backdrop-blur-sm'} transition-colors duration-200"
|
||||
aria-label="Close settings"
|
||||
onclick={handleClose}
|
||||
></button>
|
||||
@@ -606,24 +671,24 @@
|
||||
/>
|
||||
{/if}
|
||||
|
||||
{#if showCloudPanel}
|
||||
<CloudPanel
|
||||
{#if showCloudPanel && CloudPanelComponent}
|
||||
<CloudPanelComponent
|
||||
hidePanel={() => {
|
||||
showCloudPanel = false;
|
||||
}}
|
||||
/>
|
||||
{/if}
|
||||
|
||||
{#if showFontPicker}
|
||||
<FontPickerModal
|
||||
{#if showFontPicker && FontPickerComponent}
|
||||
<FontPickerComponent
|
||||
hidePicker={() => {
|
||||
showFontPicker = false;
|
||||
}}
|
||||
/>
|
||||
{/if}
|
||||
|
||||
{#if showDisclaimerModal && disclaimerCallbacks}
|
||||
<DisclaimerModal
|
||||
{#if showDisclaimerModal && disclaimerCallbacks && DisclaimerModalComponent}
|
||||
<DisclaimerModalComponent
|
||||
title={disclaimerTitle}
|
||||
message={disclaimerMessage}
|
||||
onConfirm={() => {
|
||||
@@ -639,8 +704,8 @@
|
||||
/>
|
||||
{/if}
|
||||
|
||||
{#if showFeedbackModal}
|
||||
<FeedbackModal
|
||||
{#if showFeedbackModal && FeedbackModalComponent}
|
||||
<FeedbackModalComponent
|
||||
initialFeedbackId={feedbackFocusId}
|
||||
onClose={() => {
|
||||
showFeedbackModal = false;
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
<script lang="ts">
|
||||
import type { Component } from "svelte";
|
||||
import type { SettingsSectionId, SettingsSectionSharedProps } from "./shared";
|
||||
import { SECTION_LOADERS } from "./sectionLoaders";
|
||||
|
||||
let {
|
||||
section,
|
||||
...rest
|
||||
}: SettingsSectionSharedProps & { section: SettingsSectionId } = $props();
|
||||
|
||||
let Comp = $state<Component | null>(null);
|
||||
let loadToken = 0;
|
||||
|
||||
$effect(() => {
|
||||
section;
|
||||
Comp = null;
|
||||
const token = ++loadToken;
|
||||
void SECTION_LOADERS[section]().then((mod) => {
|
||||
if (token === loadToken) Comp = mod.default;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
{#if Comp}
|
||||
<Comp {section} {...rest} />
|
||||
{:else}
|
||||
<div class="px-5 py-6 text-sm text-zinc-400 animate-pulse">Loading…</div>
|
||||
{/if}
|
||||
@@ -0,0 +1,201 @@
|
||||
<script lang="ts">
|
||||
import Switch from "@/interface/components/Switch.svelte";
|
||||
import Button from "@/interface/components/Button.svelte";
|
||||
import Slider from "@/interface/components/Slider.svelte";
|
||||
import Select from "@/interface/components/Select.svelte";
|
||||
import HotkeyInput from "@/interface/components/HotkeyInput.svelte";
|
||||
import SettingRow from "./SettingRow.svelte";
|
||||
import { settingsState } from "@/seqta/utils/listeners/SettingsState";
|
||||
import { cloudAuth } from "@/seqta/utils/CloudAuth";
|
||||
import {
|
||||
setPerformanceModePluginOverride,
|
||||
} from "@/seqta/utils/performanceMode";
|
||||
import { PERFORMANCE_HEAVY_PLUGIN_IDS } from "@/seqta/utils/performanceModeConfig";
|
||||
import { onMount } from "svelte";
|
||||
import {
|
||||
matchesSearch,
|
||||
PLUGIN_SECTION_BY_ID,
|
||||
type SettingsSectionId,
|
||||
type SettingsSectionSharedProps,
|
||||
} from "./shared";
|
||||
import {
|
||||
pluginSettingsStore,
|
||||
type PluginSettingsEntry,
|
||||
} from "./pluginSettingsState.svelte";
|
||||
|
||||
let {
|
||||
section,
|
||||
showDisclaimer,
|
||||
searchQuery = "",
|
||||
}: SettingsSectionSharedProps & { section: SettingsSectionId } = $props();
|
||||
|
||||
let cloudState = $state(cloudAuth.state);
|
||||
$effect(() => {
|
||||
const unsub = cloudAuth.subscribe((s) => {
|
||||
cloudState = s;
|
||||
});
|
||||
return unsub;
|
||||
});
|
||||
|
||||
onMount(() => {
|
||||
void pluginSettingsStore.ensureLoaded();
|
||||
});
|
||||
|
||||
const pluginHit = (plugin: PluginSettingsEntry) =>
|
||||
matchesSearch(
|
||||
searchQuery,
|
||||
plugin.name,
|
||||
plugin.description,
|
||||
...Object.values(plugin.settings).flatMap((s) => [s.title, s.description]),
|
||||
);
|
||||
|
||||
const visiblePlugins = $derived(
|
||||
pluginSettingsStore.plugins.filter(
|
||||
(plugin) =>
|
||||
(PLUGIN_SECTION_BY_ID[plugin.pluginId] ?? "features") === section &&
|
||||
pluginHit(plugin),
|
||||
),
|
||||
);
|
||||
|
||||
const pluginPerfPaused = (pluginId: string) =>
|
||||
($settingsState.performanceMode ?? false) &&
|
||||
$settingsState.performanceModePluginOverrides?.[pluginId] !== true &&
|
||||
PERFORMANCE_HEAVY_PLUGIN_IDS.has(pluginId);
|
||||
</script>
|
||||
|
||||
{#if pluginSettingsStore.loading && visiblePlugins.length === 0}
|
||||
<div class="px-5 py-6 text-sm text-zinc-400">Loading plugin settings…</div>
|
||||
{/if}
|
||||
|
||||
{#each visiblePlugins as plugin (plugin.pluginId)}
|
||||
{@const perfPaused = pluginPerfPaused(plugin.pluginId)}
|
||||
<div class="border-none">
|
||||
<div
|
||||
class="p-1 my-1 from-white to-zinc-100 bg-gradient-to-br rounded-xl border shadow-sm border-zinc-200/50 dark:border-zinc-700/40 dark:to-zinc-900/50 dark:from-zinc-900/40 {!(plugin as PluginSettingsEntry & { disableToggle?: boolean }).disableToggle && Object.keys(plugin.settings).length === 0 ? 'hidden' : ''} {perfPaused ? 'opacity-60' : ''}"
|
||||
>
|
||||
{#if perfPaused}
|
||||
<div
|
||||
class="flex justify-between items-center px-5 py-3 border-b border-amber-200/60 dark:border-amber-900/40 bg-amber-50/80 dark:bg-amber-950/20"
|
||||
>
|
||||
<p class="text-sm text-amber-800 dark:text-amber-200">
|
||||
Paused by Performance Mode — enable anyway
|
||||
</p>
|
||||
<Switch
|
||||
state={$settingsState.performanceModePluginOverrides?.[plugin.pluginId] === true}
|
||||
onChange={(forceOn: boolean) =>
|
||||
setPerformanceModePluginOverride(plugin.pluginId, forceOn)}
|
||||
/>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if plugin.disableToggle}
|
||||
<div class="flex justify-between items-center px-5 py-4 {perfPaused ? 'pointer-events-none' : ''}">
|
||||
<div class="pr-4">
|
||||
<h2 class="flex gap-2 items-center text-xl font-bold">
|
||||
Enable {plugin.name}
|
||||
{#if plugin.beta}
|
||||
<span
|
||||
class="px-2 py-0.5 text-xs font-medium text-orange-800 bg-orange-100 rounded-full border border-orange-300/30 dark:bg-orange-900/30 dark:text-orange-300 dark:border-orange-900/30"
|
||||
>
|
||||
Beta
|
||||
</span>
|
||||
{/if}
|
||||
</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">{plugin.description}</p>
|
||||
</div>
|
||||
<div>
|
||||
<Switch
|
||||
state={(pluginSettingsStore.values[plugin.pluginId]?.enabled as boolean | undefined) ?? true}
|
||||
onChange={async (value) => {
|
||||
if (plugin.pluginId === "assessments-average" && value === true) {
|
||||
showDisclaimer(
|
||||
async () => {
|
||||
await pluginSettingsStore.update(plugin.pluginId, "enabled", true);
|
||||
},
|
||||
() => {},
|
||||
"Assessment Averages Disclaimer",
|
||||
"This feature calculates a simple average of your assessment grades. It does not take into account:\n• Assessment weightings\n• Different grading scales\n• Other factors used in official reports\n\nThe displayed average may be inaccurate compared to your actual marks found in reports.\n\nDo you want to enable this feature?",
|
||||
);
|
||||
return;
|
||||
}
|
||||
await pluginSettingsStore.update(plugin.pluginId, "enabled", value);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if !perfPaused && (!plugin.disableToggle || ((pluginSettingsStore.values[plugin.pluginId]?.enabled as boolean | undefined) ?? true))}
|
||||
{#each Object.entries(plugin.settings) as [key, setting] (key)}
|
||||
{#if key !== "enabled" && !(key === "useCloudPfp" && !cloudState.isLoggedIn)}
|
||||
<div class="flex justify-between items-center px-5 py-4">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-xl font-bold">{setting.title || key}</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">{setting.description || ""}</p>
|
||||
</div>
|
||||
<div>
|
||||
{#if setting.type === "boolean"}
|
||||
<Switch
|
||||
state={(pluginSettingsStore.values[plugin.pluginId]?.[key] as boolean | undefined) ?? setting.default}
|
||||
onChange={(value) => pluginSettingsStore.update(plugin.pluginId, key, value)}
|
||||
/>
|
||||
{:else if setting.type === "number"}
|
||||
<div class="w-28 shrink-0">
|
||||
<Slider
|
||||
state={(pluginSettingsStore.values[plugin.pluginId]?.[key] as number | undefined) ?? setting.default}
|
||||
onChange={(value) => pluginSettingsStore.update(plugin.pluginId, key, value)}
|
||||
min={setting.min}
|
||||
max={setting.max}
|
||||
step={setting.step}
|
||||
/>
|
||||
</div>
|
||||
{:else if setting.type === "string"}
|
||||
<input
|
||||
type="text"
|
||||
class="px-2 py-1 text-sm rounded-md dark:bg-[#38373D]/50 bg-[#DDDDDD] dark:text-white border-none"
|
||||
value={(pluginSettingsStore.values[plugin.pluginId]?.[key] as string | undefined) ?? setting.default}
|
||||
oninput={(e) =>
|
||||
pluginSettingsStore.update(plugin.pluginId, key, e.currentTarget.value)}
|
||||
/>
|
||||
{:else if setting.type === "select"}
|
||||
<Select
|
||||
value={(pluginSettingsStore.values[plugin.pluginId]?.[key] as string | undefined) ?? setting.default}
|
||||
onChange={(value) => pluginSettingsStore.update(plugin.pluginId, key, value)}
|
||||
options={(setting.options as string[]).map((opt) => ({
|
||||
value: opt,
|
||||
label: opt.charAt(0).toUpperCase() + opt.slice(1),
|
||||
}))}
|
||||
/>
|
||||
{:else if setting.type === "button"}
|
||||
<Button onClick={() => setting.trigger?.()} text={setting.title} />
|
||||
{:else if setting.type === "hotkey"}
|
||||
<HotkeyInput
|
||||
value={(pluginSettingsStore.values[plugin.pluginId]?.[key] as string | undefined) ?? setting.default}
|
||||
onChange={(value) => pluginSettingsStore.update(plugin.pluginId, key, value)}
|
||||
/>
|
||||
{:else if setting.type === "component" && setting.component}
|
||||
{@const Component = setting.component as import("svelte").Component}
|
||||
<Component />
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
{/each}
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
{#if plugin.pluginId === "global-search"}
|
||||
<SettingRow
|
||||
title="Theme of the Month"
|
||||
description="Show the monthly featured theme popup when a new entry is available"
|
||||
id={15}
|
||||
Component={Switch}
|
||||
{searchQuery}
|
||||
props={{
|
||||
state: !($settingsState.themeOfTheMonthDisabled ?? false),
|
||||
onChange: (isOn: boolean) => (settingsState.themeOfTheMonthDisabled = !isOn),
|
||||
}}
|
||||
/>
|
||||
{/if}
|
||||
</div>
|
||||
{/each}
|
||||
@@ -0,0 +1,26 @@
|
||||
<script lang="ts">
|
||||
import type { SettingsList } from "@/interface/types/SettingsProps";
|
||||
import { matchesSearch } from "./shared";
|
||||
|
||||
let {
|
||||
title,
|
||||
description,
|
||||
Component,
|
||||
props = {},
|
||||
searchQuery = "",
|
||||
}: SettingsList & { searchQuery?: string } = $props();
|
||||
|
||||
const visible = $derived(matchesSearch(searchQuery, title, description));
|
||||
</script>
|
||||
|
||||
{#if visible}
|
||||
<div class="flex justify-between items-center px-5 py-5">
|
||||
<div class="pr-5">
|
||||
<h2 class="text-xl font-bold">{title}</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">{description}</p>
|
||||
</div>
|
||||
<div class="shrink-0">
|
||||
<Component {...props} />
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
@@ -0,0 +1,57 @@
|
||||
<script lang="ts">
|
||||
import LazySection from "./LazySection.svelte";
|
||||
import {
|
||||
ALL_SETTINGS_SECTIONS,
|
||||
type SettingsSectionId,
|
||||
type SettingsSectionSharedProps,
|
||||
} from "./shared";
|
||||
import { isPerformanceMode } from "@/seqta/utils/performanceMode";
|
||||
|
||||
let {
|
||||
activeSection = "general",
|
||||
...rest
|
||||
}: SettingsSectionSharedProps & { activeSection?: string } = $props();
|
||||
|
||||
let mountedSectionCount = $state(ALL_SETTINGS_SECTIONS.length);
|
||||
|
||||
$effect(() => {
|
||||
if (activeSection !== "all") {
|
||||
mountedSectionCount = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
mountedSectionCount = 1;
|
||||
let idx = 1;
|
||||
const step = () => {
|
||||
if (idx >= ALL_SETTINGS_SECTIONS.length) return;
|
||||
mountedSectionCount = ++idx;
|
||||
if (typeof requestIdleCallback === "function") {
|
||||
requestIdleCallback(step, { timeout: isPerformanceMode() ? 800 : 500 });
|
||||
} else {
|
||||
setTimeout(step, isPerformanceMode() ? 64 : 32);
|
||||
}
|
||||
};
|
||||
|
||||
if (typeof requestIdleCallback === "function") {
|
||||
requestIdleCallback(step, { timeout: isPerformanceMode() ? 800 : 500 });
|
||||
} else {
|
||||
setTimeout(step, isPerformanceMode() ? 64 : 32);
|
||||
}
|
||||
});
|
||||
|
||||
const sectionsToShow = $derived.by((): SettingsSectionId[] => {
|
||||
if (activeSection === "all") {
|
||||
return ALL_SETTINGS_SECTIONS.slice(0, mountedSectionCount);
|
||||
}
|
||||
if (ALL_SETTINGS_SECTIONS.includes(activeSection as SettingsSectionId)) {
|
||||
return [activeSection as SettingsSectionId];
|
||||
}
|
||||
return ["general"];
|
||||
});
|
||||
</script>
|
||||
|
||||
<div class="flex flex-col divide-y divide-zinc-100 dark:divide-zinc-700">
|
||||
{#each sectionsToShow as section (section)}
|
||||
<LazySection {section} {...rest} />
|
||||
{/each}
|
||||
</div>
|
||||
@@ -1,813 +1,8 @@
|
||||
<script lang="ts">
|
||||
import Switch from "../../components/Switch.svelte"
|
||||
import Button from "../../components/Button.svelte"
|
||||
import Slider from "../../components/Slider.svelte"
|
||||
import Select from "@/interface/components/Select.svelte"
|
||||
import HotkeyInput from "@/interface/components/HotkeyInput.svelte"
|
||||
import SettingsBody from "./SettingsBody.svelte";
|
||||
import type { SettingsSectionSharedProps } from "./shared";
|
||||
|
||||
import browser from "webextension-polyfill"
|
||||
|
||||
import type { SettingsList } from "@/interface/types/SettingsProps"
|
||||
import { settingsState } from "@/seqta/utils/listeners/SettingsState.ts"
|
||||
import PickerSwatch from "@/interface/components/PickerSwatch.svelte"
|
||||
import SidebarAppearance from "@/interface/components/SidebarAppearance.svelte"
|
||||
import ConnectMobileApp from "@/interface/components/ConnectMobileApp.svelte"
|
||||
import CloudSettingsSync from "@/interface/components/CloudSettingsSync.svelte"
|
||||
import CloudHeader from "@/interface/components/store/CloudHeader.svelte"
|
||||
import { cloudAuth } from "@/seqta/utils/CloudAuth"
|
||||
import { showPrivacyNotification } from "@/seqta/utils/Openers/OpenPrivacyNotification"
|
||||
import { showThemeOfTheMonthPopupNow } from "@/seqta/utils/Openers/OpenThemeOfTheMonthPopup"
|
||||
import { closeExtensionPopup } from "@/seqta/utils/Closers/closeExtensionPopup"
|
||||
import { getSnapshotForUpload } from "@/seqta/utils/cloudSettingsSync"
|
||||
import { getStoredOverride, setApiBase } from "@/seqta/utils/DevApiBase"
|
||||
import { onMount } from "svelte"
|
||||
|
||||
let devApiBaseInput = $state<string>(getStoredOverride() ?? "")
|
||||
let devApiBaseActive = $state<string | null>(getStoredOverride())
|
||||
|
||||
function applyDevApiBase() {
|
||||
const trimmed = devApiBaseInput.trim()
|
||||
if (trimmed === "") {
|
||||
setApiBase(null)
|
||||
devApiBaseActive = null
|
||||
return
|
||||
}
|
||||
if (!/^https?:\/\//.test(trimmed)) {
|
||||
alert("Please enter a full URL starting with http:// or https://")
|
||||
return
|
||||
}
|
||||
setApiBase(trimmed)
|
||||
devApiBaseActive = trimmed.replace(/\/$/, "")
|
||||
}
|
||||
|
||||
function clearDevApiBase() {
|
||||
devApiBaseInput = ""
|
||||
setApiBase(null)
|
||||
devApiBaseActive = null
|
||||
}
|
||||
|
||||
import { getAllPluginSettings } from "@/plugins"
|
||||
import { isSeqtaEngageExperience } from "@/seqta/utils/isSeqtaEngage"
|
||||
|
||||
const isEngage = isSeqtaEngageExperience();
|
||||
import type { BooleanSetting, StringSetting, NumberSetting, SelectSetting, ButtonSetting, HotkeySetting, ComponentSetting } from "@/plugins/core/types"
|
||||
|
||||
// Union type representing all possible settings
|
||||
type SettingType =
|
||||
(Omit<BooleanSetting, 'type'> & { type: 'boolean', id: string }) |
|
||||
(Omit<StringSetting, 'type'> & { type: 'string', id: string }) |
|
||||
(Omit<NumberSetting, 'type'> & { type: 'number', id: string }) |
|
||||
(Omit<SelectSetting<string>, 'type'> & {
|
||||
type: 'select',
|
||||
id: string,
|
||||
options: string[]
|
||||
}) |
|
||||
(Omit<ButtonSetting, 'type'> & {
|
||||
type: 'button',
|
||||
id: string
|
||||
}) |
|
||||
(Omit<HotkeySetting, 'type'> & {
|
||||
type: 'hotkey',
|
||||
id: string
|
||||
}) |
|
||||
(Omit<ComponentSetting, 'type'> & {
|
||||
type: 'component',
|
||||
id: string,
|
||||
component: any
|
||||
});
|
||||
|
||||
interface Plugin {
|
||||
pluginId: string;
|
||||
name: string;
|
||||
description: string;
|
||||
beta?: boolean;
|
||||
settings: Record<string, SettingType>;
|
||||
}
|
||||
|
||||
const pluginSettings = getAllPluginSettings().filter(
|
||||
(plugin) => !(isSeqtaEngageExperience() && plugin.pluginId === "global-search"),
|
||||
) as Plugin[];
|
||||
const pluginSettingsValues = $state<Record<string, Record<string, any>>>({});
|
||||
|
||||
let cloudState = $state(cloudAuth.state);
|
||||
$effect(() => {
|
||||
const unsub = cloudAuth.subscribe((s) => { cloudState = s; });
|
||||
return unsub;
|
||||
});
|
||||
|
||||
async function loadPluginSettings() {
|
||||
for (const plugin of pluginSettings) {
|
||||
if (Object.keys(plugin.settings).length === 0) continue;
|
||||
|
||||
const storageKey = `plugin.${plugin.pluginId}.settings`;
|
||||
const stored = await browser.storage.local.get(storageKey);
|
||||
|
||||
pluginSettingsValues[plugin.pluginId] = stored[storageKey] || {};
|
||||
|
||||
for (const [key, setting] of Object.entries(plugin.settings)) {
|
||||
if (
|
||||
pluginSettingsValues[plugin.pluginId][key] === undefined &&
|
||||
setting.type !== 'button' &&
|
||||
setting.type !== 'component'
|
||||
) {
|
||||
pluginSettingsValues[plugin.pluginId][key] = setting.default;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function updatePluginSetting(pluginId: string, key: string, value: any) {
|
||||
const storageKey = `plugin.${pluginId}.settings`;
|
||||
|
||||
if (!pluginSettingsValues[pluginId]) {
|
||||
pluginSettingsValues[pluginId] = {};
|
||||
}
|
||||
pluginSettingsValues[pluginId][key] = value;
|
||||
|
||||
const stored = await browser.storage.local.get(storageKey);
|
||||
const currentSettings = (stored[storageKey] || {}) as Record<string, any>;
|
||||
|
||||
currentSettings[key] = value;
|
||||
|
||||
await browser.storage.local.set({ [storageKey]: currentSettings });
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
void loadPluginSettings();
|
||||
});
|
||||
|
||||
const { showColourPicker, showFontPicker, showDisclaimer, showCloudPanel, activeSection = "general", searchQuery = "" } = $props<{
|
||||
showColourPicker: () => void;
|
||||
showFontPicker: () => void;
|
||||
showDisclaimer: (onConfirm: () => void, onCancel: () => void, title?: string, message?: string) => void;
|
||||
showCloudPanel: () => void;
|
||||
activeSection?: string;
|
||||
searchQuery?: string;
|
||||
}>();
|
||||
|
||||
/** Map each plugin into the settings sidebar category that fits its purpose. */
|
||||
const pluginSectionById: Record<string, string> = {
|
||||
"profile-picture": "account",
|
||||
"animated-background": "appearance",
|
||||
"background-music": "appearance",
|
||||
timetable: "timetable",
|
||||
timetableEdit: "timetable",
|
||||
"assessments-overview": "assessments",
|
||||
"assessments-average": "assessments",
|
||||
"grade-analytics": "assessments",
|
||||
"global-search": "features",
|
||||
"enhanced-navigation": "features",
|
||||
messageFolders: "features",
|
||||
notificationCollector: "features",
|
||||
};
|
||||
|
||||
const showsSection = (section: string) =>
|
||||
activeSection === "all" || activeSection === section;
|
||||
|
||||
const pluginBelongsInSection = (pluginId: string) =>
|
||||
activeSection === "all" ||
|
||||
(pluginSectionById[pluginId] ?? "features") === activeSection;
|
||||
|
||||
const matchesSearch = (...parts: Array<string | undefined>) => {
|
||||
const q = searchQuery.trim().toLowerCase();
|
||||
return !q || parts.some((part) => part?.toLowerCase().includes(q));
|
||||
};
|
||||
|
||||
const founderBadgeSetting = {
|
||||
title: "Titlebar founder badge",
|
||||
description: "Show your Cloud founder badge in the SEQTA titlebar",
|
||||
} as const;
|
||||
|
||||
const showCloudCardHeader = $derived(
|
||||
matchesSearch("BetterSEQTA Cloud", "Account & sync"),
|
||||
);
|
||||
|
||||
const showFounderBadgeSetting = $derived(
|
||||
matchesSearch(
|
||||
founderBadgeSetting.title,
|
||||
founderBadgeSetting.description,
|
||||
"founder badge",
|
||||
"titlebar",
|
||||
"founder",
|
||||
),
|
||||
);
|
||||
|
||||
const showCloudAccountCard = $derived(showCloudCardHeader || showFounderBadgeSetting);
|
||||
|
||||
const pluginHit = (plugin: Plugin) =>
|
||||
matchesSearch(plugin.name, plugin.description, ...Object.values(plugin.settings).flatMap((s) => [s.title, s.description]));
|
||||
|
||||
async function exportCloudSettingsJsonToFile() {
|
||||
const payload = await getSnapshotForUpload();
|
||||
const blob = new Blob([JSON.stringify(payload, null, 2)], {
|
||||
type: "application/json",
|
||||
});
|
||||
const url = URL.createObjectURL(blob);
|
||||
const a = document.createElement("a");
|
||||
a.href = url;
|
||||
a.download = `betterseqta-plus-settings-export-${new Date().toISOString().replace(/[:.]/g, "-")}.json`;
|
||||
a.click();
|
||||
URL.revokeObjectURL(url);
|
||||
}
|
||||
let props: SettingsSectionSharedProps & { activeSection?: string } = $props();
|
||||
</script>
|
||||
|
||||
{#snippet Setting({ title, description, Component, props }: SettingsList) }
|
||||
{#if matchesSearch(title, description)}
|
||||
<div class="flex justify-between items-center px-5 py-5">
|
||||
<div class="pr-5">
|
||||
<h2 class="text-xl font-bold">{title}</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">{description}</p>
|
||||
</div>
|
||||
<div class="shrink-0">
|
||||
<Component {...props} />
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
{/snippet}
|
||||
|
||||
<div class="flex flex-col divide-y divide-zinc-100 dark:divide-zinc-700">
|
||||
{#if showsSection("account")}
|
||||
{@render Setting({
|
||||
title: "Connect Mobile App",
|
||||
description: "Link your SEQTA session to DesQTA — the modern desktop and mobile app for SEQTA Learn",
|
||||
id: 0,
|
||||
Component: ConnectMobileApp,
|
||||
props: {}
|
||||
})}
|
||||
|
||||
{#if showCloudAccountCard}
|
||||
<div class="border-none">
|
||||
<div class="p-1 my-1 from-white to-zinc-100 bg-gradient-to-br rounded-xl border shadow-sm border-zinc-200/50 dark:border-zinc-700/40 dark:to-zinc-900/50 dark:from-zinc-900/40">
|
||||
{#if showCloudCardHeader}
|
||||
<div class="flex justify-between items-center px-5 py-4">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-xl font-bold">BetterSEQTA Cloud</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">Account & sync</p>
|
||||
</div>
|
||||
<div>
|
||||
<CloudHeader alwaysShowUserName onClick={showCloudPanel} />
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
{#if cloudState.isLoggedIn}
|
||||
<div class="px-3 pb-3" class:pt-3={!showCloudCardHeader}>
|
||||
{#if showCloudCardHeader}
|
||||
<CloudSettingsSync showDisclaimer={(onConfirm, onCancel) => showDisclaimer(onConfirm, onCancel, "Restore from cloud?", "This will replace your local settings with the cloud backup. Continue?")} />
|
||||
{/if}
|
||||
{#if showFounderBadgeSetting}
|
||||
{@render Setting({
|
||||
title: founderBadgeSetting.title,
|
||||
description: founderBadgeSetting.description,
|
||||
id: 17,
|
||||
Component: Switch,
|
||||
props: {
|
||||
state: $settingsState.showTitlebarFounderBadge !== false,
|
||||
onChange: (isOn: boolean) => (settingsState.showTitlebarFounderBadge = isOn),
|
||||
},
|
||||
})}
|
||||
{/if}
|
||||
</div>
|
||||
{:else if showFounderBadgeSetting}
|
||||
<div class="px-5 pb-4 text-sm text-zinc-600 dark:text-zinc-400">
|
||||
Sign in to Cloud first.
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
{/if}
|
||||
|
||||
{#if showsSection("general")}
|
||||
{#each [
|
||||
...(!isEngage
|
||||
? [
|
||||
{
|
||||
title: "Edit Sidebar Layout",
|
||||
description: "Reorder pages on the sidebar",
|
||||
id: 5,
|
||||
Component: Button,
|
||||
props: {
|
||||
onClick: () => browser.runtime.sendMessage({ type: 'currentTab', info: 'EditSidebar' }),
|
||||
text: "Edit"
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "Icon Only Sidebar",
|
||||
description: "Show only icons in the sidebar for a compact layout",
|
||||
id: 14,
|
||||
Component: Switch,
|
||||
props: {
|
||||
state: $settingsState.iconOnlySidebar ?? false,
|
||||
onChange: (isOn: boolean) => settingsState.iconOnlySidebar = isOn
|
||||
}
|
||||
},
|
||||
]
|
||||
: []),
|
||||
{
|
||||
title: "Animations",
|
||||
description: "Enable animations on certain pages",
|
||||
id: 6,
|
||||
Component: Switch,
|
||||
props: {
|
||||
state: $settingsState.animations,
|
||||
onChange: (isOn: boolean) => settingsState.animations = isOn
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "12 Hour Time",
|
||||
description: "Prefer 12 hour time format for SEQTA",
|
||||
id: 9,
|
||||
Component: Switch,
|
||||
props: {
|
||||
state: $settingsState.timeFormat === "12",
|
||||
onChange: (isOn: boolean) => settingsState.timeFormat = isOn ? "12" : "24"
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "Default Page",
|
||||
description: "Choose which page loads first when you open SEQTA",
|
||||
id: 10,
|
||||
Component: Select,
|
||||
props: {
|
||||
value: $settingsState.defaultPage ?? "home",
|
||||
onChange: (value: string) => (settingsState.defaultPage = value),
|
||||
options: isEngage
|
||||
? [
|
||||
{ value: "home", label: "Home" },
|
||||
{ value: "dashboard", label: "Dashboard" },
|
||||
{ value: "timetable", label: "Timetable" },
|
||||
{ value: "messages", label: "Messages" },
|
||||
{ value: "documents", label: "Documents" },
|
||||
{ value: "reports", label: "Reports" },
|
||||
]
|
||||
: [
|
||||
{ value: "home", label: "Home" },
|
||||
{ value: "dashboard", label: "Dashboard" },
|
||||
{ value: "timetable", label: "Timetable" },
|
||||
{ value: "welcome", label: "Welcome" },
|
||||
{ value: "messages", label: "Messages" },
|
||||
{ value: "documents", label: "Documents" },
|
||||
{ value: "reports", label: "Reports" },
|
||||
],
|
||||
},
|
||||
},
|
||||
...(!isEngage
|
||||
? [
|
||||
{
|
||||
title: "News Feed Source",
|
||||
description: "Choose the sources for your news feed",
|
||||
id: 11,
|
||||
Component: Select,
|
||||
props: {
|
||||
value: $settingsState.newsSource,
|
||||
onChange: (value: string) => settingsState.newsSource = value,
|
||||
options: [
|
||||
{ value: "australia", label: "Australia" },
|
||||
{ value: "usa", label: "USA" },
|
||||
{ value: "uk", label: "UK" },
|
||||
{ value: "taiwan", label: "Taiwan" },
|
||||
{ value: "hong_kong", label: "Hong Kong" },
|
||||
{ value: "panama", label: "Panama" },
|
||||
{ value: "canada", label: "Canada" },
|
||||
{ value: "singapore", label: "Singapore" },
|
||||
{ value: "japan", label: "Japan" },
|
||||
{ value: "netherlands", label: "Netherlands" },
|
||||
],
|
||||
},
|
||||
},
|
||||
]
|
||||
: []),
|
||||
] as option (option.id)}
|
||||
{@render Setting(option)}
|
||||
{/each}
|
||||
{/if}
|
||||
|
||||
{#if showsSection("appearance")}
|
||||
{#each [
|
||||
{
|
||||
title: "Custom Theme Colour",
|
||||
description: "Customise the overall theme colour of SEQTA Learn",
|
||||
id: 4,
|
||||
Component: PickerSwatch,
|
||||
props: {
|
||||
onClick: showColourPicker
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "Interface Font",
|
||||
description: "Choose the typeface used across SEQTA Learn",
|
||||
id: 16,
|
||||
Component: Button,
|
||||
props: {
|
||||
onClick: showFontPicker,
|
||||
text: "Change"
|
||||
}
|
||||
},
|
||||
] as option (option.id)}
|
||||
{@render Setting(option)}
|
||||
{/each}
|
||||
|
||||
{#if !isEngage && matchesSearch("Sidebar Style", "Item Size", "Corner Radius", "Active Indicator", "Sidebar Width", "Transparency Effects", "Blur Strength")}
|
||||
<div class="border-none">
|
||||
<SidebarAppearance />
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if matchesSearch("Adaptive Theme Colour", "Soft Gradient", "Smooth colour transition")}
|
||||
<div class="border-none">
|
||||
<div class="p-1 my-1 from-white to-zinc-100 bg-gradient-to-br rounded-xl border shadow-sm border-zinc-200/50 dark:border-zinc-700/40 dark:to-zinc-900/50 dark:from-zinc-900/40">
|
||||
<div class="flex justify-between items-center px-5 py-4">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-xl font-bold">Adaptive Theme Colour</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">Change the theme colour based on the current class (e.g. when viewing a course or assessments page)</p>
|
||||
</div>
|
||||
<div>
|
||||
<Switch
|
||||
state={$settingsState.adaptiveThemeColour ?? false}
|
||||
onChange={(isOn: boolean) => settingsState.adaptiveThemeColour = isOn}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
{#if $settingsState.adaptiveThemeColour}
|
||||
<div class="flex justify-between items-center px-5 py-4 pl-7 border-t border-zinc-100 dark:border-zinc-700/50">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-xl font-bold">Soft Gradient</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">Use a soft gradient instead of a solid colour when viewing a class</p>
|
||||
</div>
|
||||
<div>
|
||||
<Switch
|
||||
state={$settingsState.adaptiveThemeGradient ?? false}
|
||||
onChange={(isOn: boolean) => settingsState.adaptiveThemeGradient = isOn}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-between items-center px-5 py-4 pl-7 border-t border-zinc-100 dark:border-zinc-700/50">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-xl font-bold">Smooth colour transition</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">Ease between class/subject colours when navigating instead of switching instantly</p>
|
||||
</div>
|
||||
<div>
|
||||
<Switch
|
||||
state={$settingsState.adaptiveThemeColourTransition ?? true}
|
||||
onChange={(isOn: boolean) => settingsState.adaptiveThemeColourTransition = isOn}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
{/if}
|
||||
|
||||
{#if showsSection("general")}
|
||||
{#if matchesSearch("Home Page Assessments", "Include Past Assessments", "Maximum Subjects", "Maximum Assessments per Subject")}
|
||||
<div class="border-none">
|
||||
<div class="p-1 my-1 from-white to-zinc-100 bg-gradient-to-br rounded-xl border shadow-sm border-zinc-200/50 dark:border-zinc-700/40 dark:to-zinc-900/50 dark:from-zinc-900/40">
|
||||
<div class="flex justify-between items-center px-5 py-4">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-xl font-bold">Home Page Assessments</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">Limit upcoming assessments shown on the home page by subject</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-between items-center px-5 py-4 pl-7 border-t border-zinc-100 dark:border-zinc-700/50">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-xl font-bold">Include Past Assessments</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">Show past-due assessments from the upcoming list, matching the Assessments page</p>
|
||||
</div>
|
||||
<div>
|
||||
<Switch
|
||||
state={$settingsState.homeUpcomingIncludePast ?? true}
|
||||
onChange={(isOn: boolean) => (settingsState.homeUpcomingIncludePast = isOn)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-between items-center px-5 py-4 pl-7 border-t border-zinc-100 dark:border-zinc-700/50">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-xl font-bold">Maximum Subjects</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">Number of subjects to include, ordered by soonest due date</p>
|
||||
</div>
|
||||
<Select
|
||||
value={String($settingsState.homeUpcomingSubjectsMax ?? 5)}
|
||||
onChange={(value: string) => (settingsState.homeUpcomingSubjectsMax = Number(value))}
|
||||
options={[
|
||||
{ value: "0", label: "All" },
|
||||
{ value: "3", label: "3" },
|
||||
{ value: "5", label: "5" },
|
||||
{ value: "7", label: "7" },
|
||||
{ value: "10", label: "10" },
|
||||
{ value: "15", label: "15" },
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
<div class="flex justify-between items-center px-5 py-4 pl-7 border-t border-zinc-100 dark:border-zinc-700/50">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-xl font-bold">Maximum Assessments per Subject</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">Assessments shown for each included subject</p>
|
||||
</div>
|
||||
<Select
|
||||
value={String($settingsState.homeUpcomingAssessmentsPerSubjectMax ?? 0)}
|
||||
onChange={(value: string) => (settingsState.homeUpcomingAssessmentsPerSubjectMax = Number(value))}
|
||||
options={[
|
||||
{ value: "0", label: "All" },
|
||||
{ value: "1", label: "1" },
|
||||
{ value: "2", label: "2" },
|
||||
{ value: "3", label: "3" },
|
||||
{ value: "5", label: "5" },
|
||||
{ value: "10", label: "10" },
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
{/if}
|
||||
|
||||
{#each pluginSettings as plugin (plugin.pluginId)}
|
||||
{#if pluginBelongsInSection(plugin.pluginId) && pluginHit(plugin)}
|
||||
<div class="border-none">
|
||||
<div class="p-1 my-1 from-white to-zinc-100 bg-gradient-to-br rounded-xl border shadow-sm border-zinc-200/50 dark:border-zinc-700/40 dark:to-zinc-900/50 dark:from-zinc-900/40 {!(plugin as any).disableToggle && Object.keys(plugin.settings).length === 0 ? 'hidden' : ''}">
|
||||
<!-- Always show enable toggle if disableToggle is true -->
|
||||
{#if (plugin as any).disableToggle}
|
||||
<div class="flex justify-between items-center px-5 py-4">
|
||||
<div class="pr-4">
|
||||
<h2 class="flex gap-2 items-center text-xl font-bold">
|
||||
Enable {plugin.name}
|
||||
{#if plugin.beta}
|
||||
<span class="px-2 py-0.5 text-xs font-medium text-orange-800 bg-orange-100 rounded-full border border-orange-300/30 dark:bg-orange-900/30 dark:text-orange-300 dark:border-orange-900/30">
|
||||
Beta
|
||||
</span>
|
||||
{/if}
|
||||
</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">{plugin.description}</p>
|
||||
</div>
|
||||
<div>
|
||||
<Switch
|
||||
state={pluginSettingsValues[plugin.pluginId]?.enabled ?? true}
|
||||
onChange={async (value) => {
|
||||
if (plugin.pluginId === 'assessments-average' && value === true) {
|
||||
showDisclaimer(
|
||||
async () => {
|
||||
await updatePluginSetting(plugin.pluginId, 'enabled', true);
|
||||
},
|
||||
() => {},
|
||||
"Assessment Averages Disclaimer",
|
||||
"This feature calculates a simple average of your assessment grades. It does not take into account:\n• Assessment weightings\n• Different grading scales\n• Other factors used in official reports\n\nThe displayed average may be inaccurate compared to your actual marks found in reports.\n\nDo you want to enable this feature?"
|
||||
);
|
||||
return;
|
||||
}
|
||||
await updatePluginSetting(plugin.pluginId, 'enabled', value);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if !((plugin as any).disableToggle) || (pluginSettingsValues[plugin.pluginId]?.enabled ?? true)}
|
||||
{#each Object.entries(plugin.settings) as [key, setting] (key)}
|
||||
<!-- Skip the 'enabled' setting and hide cloud-only settings when not signed in -->
|
||||
{#if key !== 'enabled' && !(key === 'useCloudPfp' && !cloudState.isLoggedIn)}
|
||||
<div class="flex justify-between items-center px-5 py-4">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-xl font-bold">{setting.title || key}</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">{setting.description || ''}</p>
|
||||
</div>
|
||||
<div>
|
||||
{#if setting.type === 'boolean'}
|
||||
<Switch
|
||||
state={pluginSettingsValues[plugin.pluginId]?.[key] ?? setting.default}
|
||||
onChange={(value) => updatePluginSetting(plugin.pluginId, key, value)}
|
||||
/>
|
||||
{:else if setting.type === 'number'}
|
||||
<div class="w-28 shrink-0">
|
||||
<Slider
|
||||
state={pluginSettingsValues[plugin.pluginId]?.[key] ?? setting.default}
|
||||
onChange={(value) => updatePluginSetting(plugin.pluginId, key, value)}
|
||||
min={setting.min}
|
||||
max={setting.max}
|
||||
step={setting.step}
|
||||
/>
|
||||
</div>
|
||||
{:else if setting.type === 'string'}
|
||||
<input
|
||||
type="text"
|
||||
class="px-2 py-1 text-sm rounded-md dark:bg-[#38373D]/50 bg-[#DDDDDD] dark:text-white border-none"
|
||||
value={pluginSettingsValues[plugin.pluginId]?.[key] ?? setting.default}
|
||||
oninput={(e) => updatePluginSetting(plugin.pluginId, key, e.currentTarget.value)}
|
||||
/>
|
||||
{:else if setting.type === 'select'}
|
||||
<Select
|
||||
value={pluginSettingsValues[plugin.pluginId]?.[key] ?? setting.default}
|
||||
onChange={(value) => updatePluginSetting(plugin.pluginId, key, value)}
|
||||
options={(setting.options as string[]).map(opt => ({
|
||||
value: opt,
|
||||
label: opt.charAt(0).toUpperCase() + opt.slice(1)
|
||||
}))}
|
||||
/>
|
||||
{:else if setting.type === 'button'}
|
||||
<Button
|
||||
onClick={() => setting.trigger?.()}
|
||||
text={setting.title}
|
||||
/>
|
||||
{:else if setting.type === 'hotkey'}
|
||||
<HotkeyInput
|
||||
value={pluginSettingsValues[plugin.pluginId]?.[key] ?? setting.default}
|
||||
onChange={(value) => updatePluginSetting(plugin.pluginId, key, value)}
|
||||
/>
|
||||
{:else if setting.type === 'component'}
|
||||
{#if setting.component}
|
||||
{@const Component = setting.component}
|
||||
<Component />
|
||||
{/if}
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
{/each}
|
||||
{/if}
|
||||
</div>
|
||||
{#if plugin.pluginId === 'global-search'}
|
||||
{@render Setting({
|
||||
title: "Theme of the Month",
|
||||
description: "Show the monthly featured theme popup when a new entry is available",
|
||||
id: 15,
|
||||
Component: Switch,
|
||||
props: {
|
||||
state: !($settingsState.themeOfTheMonthDisabled ?? false),
|
||||
onChange: (isOn: boolean) => settingsState.themeOfTheMonthDisabled = !isOn
|
||||
}
|
||||
})}
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
{/each}
|
||||
|
||||
{#if showsSection("advanced")}
|
||||
{@render Setting({
|
||||
title: "BetterSEQTA+",
|
||||
description: "Enables BetterSEQTA+ features",
|
||||
id: 12,
|
||||
Component: Switch,
|
||||
props: {
|
||||
state: $settingsState.onoff,
|
||||
onChange: (isOn: boolean) => settingsState.onoff = isOn
|
||||
}
|
||||
})}
|
||||
|
||||
{#if $settingsState.devMode && matchesSearch(
|
||||
"Developer Mode",
|
||||
"Verbose logging",
|
||||
"Delay loading screen",
|
||||
"Sensitive Hider",
|
||||
"Mock Notices",
|
||||
"Show Privacy Notification",
|
||||
"Show Theme of the Month",
|
||||
"Export cloud settings JSON",
|
||||
"API Base URL",
|
||||
"GitHub latest version override",
|
||||
)}
|
||||
<div class="flex-col p-1 my-1 bg-gradient-to-br from-white rounded-xl border shadow-sm to-zinc-100 border-zinc-200/50 dark:border-zinc-700/40 dark:to-zinc-900/50 dark:from-zinc-900/40">
|
||||
<div class="flex justify-between items-center px-5 py-4">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-xl font-bold">Developer Mode</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">Enables developer mode, allowing you to test new features and changes.</p>
|
||||
</div>
|
||||
<div>
|
||||
<Switch state={$settingsState.devMode} onChange={(isOn: boolean) => settingsState.devMode = isOn} />
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-between items-center px-5 py-4">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-xl font-bold">Verbose logging</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">Show diagnostic console output (indexer, theme manager, timetable colour patch, etc.)</p>
|
||||
</div>
|
||||
<div>
|
||||
<Switch
|
||||
state={$settingsState.verboseLogging ?? false}
|
||||
onChange={(isOn: boolean) => settingsState.verboseLogging = isOn}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-between items-center px-5 py-4">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-xl font-bold">Delay loading screen</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">Keep the loading overlay visible for 5 extra seconds so you can preview canvas variants.</p>
|
||||
</div>
|
||||
<div>
|
||||
<Switch
|
||||
state={$settingsState.devDelayLoadingScreen ?? false}
|
||||
onChange={(isOn: boolean) => settingsState.devDelayLoadingScreen = isOn}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-between items-center px-5 py-4">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-xl font-bold">Sensitive Hider</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">Replace sensitive content with mock data</p>
|
||||
</div>
|
||||
<div>
|
||||
<Switch
|
||||
state={$settingsState.hideSensitiveContent ?? false}
|
||||
onChange={(isOn: boolean) => settingsState.hideSensitiveContent = isOn}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-between items-center px-5 py-4">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-xl font-bold">Mock Notices</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">Use fake notice data on homepage instead of real data</p>
|
||||
</div>
|
||||
<div>
|
||||
<Switch
|
||||
state={$settingsState.mockNotices ?? false}
|
||||
onChange={(isOn: boolean) => settingsState.mockNotices = isOn}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-between items-center px-5 py-4">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-xl font-bold">Show Privacy Notification</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">Show the privacy notification popup on next page load</p>
|
||||
</div>
|
||||
<div>
|
||||
<Button
|
||||
onClick={async () => {
|
||||
settingsState.privacyStatementShown = false;
|
||||
settingsState.privacyStatementLastUpdated = undefined;
|
||||
closeExtensionPopup();
|
||||
// Small delay to ensure popup is closed before showing notification
|
||||
await new Promise(resolve => setTimeout(resolve, 100));
|
||||
await showPrivacyNotification();
|
||||
}}
|
||||
text="Show Now"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-between items-center px-5 py-4">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-xl font-bold">Show Theme of the Month</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">Fetch and show the current month's popup now (ignores dismissed state)</p>
|
||||
</div>
|
||||
<div>
|
||||
<Button
|
||||
onClick={async () => {
|
||||
closeExtensionPopup();
|
||||
await new Promise((resolve) => setTimeout(resolve, 100));
|
||||
await showThemeOfTheMonthPopupNow();
|
||||
}}
|
||||
text="Show Now"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-between items-center px-5 py-4">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-xl font-bold">Export cloud settings JSON</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">Download the same payload as cloud sync (OAuth tokens stripped). For debugging and server testing.</p>
|
||||
</div>
|
||||
<div>
|
||||
<Button onClick={exportCloudSettingsJsonToFile} text="Export to file" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-col gap-2 px-4 py-3">
|
||||
<div class="flex justify-between items-start gap-3">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-xl font-bold">API Base URL (session only)</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">Override the content API host for this browser session. Cleared on restart. Affects themes, theme of the month, and other server-driven content.</p>
|
||||
{#if devApiBaseActive}
|
||||
<p class="text-xs mt-1 text-amber-600 dark:text-amber-400">
|
||||
Override active: <span class="font-mono">{devApiBaseActive}</span>
|
||||
</p>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex gap-2 items-center">
|
||||
<input
|
||||
type="text"
|
||||
placeholder="https://betterseqta.org"
|
||||
bind:value={devApiBaseInput}
|
||||
class="flex-1 px-2 py-1 text-xs rounded border bg-white dark:bg-zinc-800 border-zinc-300 dark:border-zinc-700 text-zinc-900 dark:text-zinc-100"
|
||||
/>
|
||||
<Button onClick={applyDevApiBase} text="Apply" />
|
||||
{#if devApiBaseActive}
|
||||
<Button onClick={clearDevApiBase} text="Clear" />
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-col gap-2 px-4 py-3">
|
||||
<div>
|
||||
<h2 class="text-xl font-bold">GitHub latest version override</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">Pretend a newer GitHub release exists to test the update badge. Only applies when dev mode is on.</p>
|
||||
</div>
|
||||
<input
|
||||
type="text"
|
||||
placeholder="e.g. 9.9.9"
|
||||
value={$settingsState.devGhReleaseVersionOverride ?? ""}
|
||||
oninput={(e) => {
|
||||
settingsState.devGhReleaseVersionOverride = e.currentTarget.value;
|
||||
}}
|
||||
class="px-2 py-1 text-xs rounded border bg-white dark:bg-zinc-800 border-zinc-300 dark:border-zinc-700 text-zinc-900 dark:text-zinc-100"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
{/if}
|
||||
</div>
|
||||
<SettingsBody {...props} />
|
||||
@@ -0,0 +1,101 @@
|
||||
import browser from "webextension-polyfill";
|
||||
import { isSeqtaEngageExperience } from "@/seqta/utils/isSeqtaEngage";
|
||||
import type {
|
||||
BooleanSetting,
|
||||
ButtonSetting,
|
||||
ComponentSetting,
|
||||
HotkeySetting,
|
||||
NumberSetting,
|
||||
SelectSetting,
|
||||
StringSetting,
|
||||
} from "@/plugins/core/types";
|
||||
|
||||
type SettingType =
|
||||
| (Omit<BooleanSetting, "type"> & { type: "boolean"; id: string })
|
||||
| (Omit<StringSetting, "type"> & { type: "string"; id: string })
|
||||
| (Omit<NumberSetting, "type"> & { type: "number"; id: string })
|
||||
| (Omit<SelectSetting<string>, "type"> & {
|
||||
type: "select";
|
||||
id: string;
|
||||
options: string[];
|
||||
})
|
||||
| (Omit<ButtonSetting, "type"> & { type: "button"; id: string })
|
||||
| (Omit<HotkeySetting, "type"> & { type: "hotkey"; id: string })
|
||||
| (Omit<ComponentSetting, "type"> & {
|
||||
type: "component";
|
||||
id: string;
|
||||
component: unknown;
|
||||
});
|
||||
|
||||
export type PluginSettingsEntry = {
|
||||
pluginId: string;
|
||||
name: string;
|
||||
description: string;
|
||||
beta?: boolean;
|
||||
settings: Record<string, SettingType>;
|
||||
disableToggle?: boolean;
|
||||
};
|
||||
|
||||
let loadPromise: Promise<void> | null = null;
|
||||
|
||||
class PluginSettingsStore {
|
||||
loaded = $state(false);
|
||||
loading = $state(false);
|
||||
plugins = $state<PluginSettingsEntry[]>([]);
|
||||
values = $state<Record<string, Record<string, unknown>>>({});
|
||||
|
||||
ensureLoaded(): Promise<void> {
|
||||
if (this.loaded) return Promise.resolve();
|
||||
if (loadPromise) return loadPromise;
|
||||
|
||||
this.loading = true;
|
||||
loadPromise = this.load().finally(() => {
|
||||
this.loading = false;
|
||||
this.loaded = true;
|
||||
});
|
||||
return loadPromise;
|
||||
}
|
||||
|
||||
private async load(): Promise<void> {
|
||||
const { getAllPluginSettings } = await import("@/plugins");
|
||||
this.plugins = getAllPluginSettings().filter(
|
||||
(plugin) =>
|
||||
!(isSeqtaEngageExperience() && plugin.pluginId === "global-search"),
|
||||
) as PluginSettingsEntry[];
|
||||
|
||||
for (const plugin of this.plugins) {
|
||||
if (Object.keys(plugin.settings).length === 0) continue;
|
||||
|
||||
const storageKey = `plugin.${plugin.pluginId}.settings`;
|
||||
const stored = await browser.storage.local.get(storageKey);
|
||||
this.values[plugin.pluginId] = (stored[storageKey] as Record<string, unknown>) || {};
|
||||
|
||||
for (const [key, setting] of Object.entries(plugin.settings)) {
|
||||
if (
|
||||
this.values[plugin.pluginId][key] === undefined &&
|
||||
setting.type !== "button" &&
|
||||
setting.type !== "component"
|
||||
) {
|
||||
this.values[plugin.pluginId][key] = setting.default;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async update(pluginId: string, key: string, value: unknown): Promise<void> {
|
||||
await this.ensureLoaded();
|
||||
|
||||
if (!this.values[pluginId]) {
|
||||
this.values[pluginId] = {};
|
||||
}
|
||||
this.values[pluginId][key] = value;
|
||||
|
||||
const storageKey = `plugin.${pluginId}.settings`;
|
||||
const stored = await browser.storage.local.get(storageKey);
|
||||
const currentSettings = (stored[storageKey] || {}) as Record<string, unknown>;
|
||||
currentSettings[key] = value;
|
||||
await browser.storage.local.set({ [storageKey]: currentSettings });
|
||||
}
|
||||
}
|
||||
|
||||
export const pluginSettingsStore = new PluginSettingsStore();
|
||||
@@ -0,0 +1,15 @@
|
||||
import type { Component } from "svelte";
|
||||
import type { SettingsSectionId } from "./shared";
|
||||
|
||||
export const SECTION_LOADERS: Record<
|
||||
SettingsSectionId,
|
||||
() => Promise<{ default: Component }>
|
||||
> = {
|
||||
account: () => import("./sections/account.svelte"),
|
||||
general: () => import("./sections/generalOptions.svelte"),
|
||||
appearance: () => import("./sections/appearance.svelte"),
|
||||
timetable: () => import("./sections/plugins.svelte"),
|
||||
assessments: () => import("./sections/plugins.svelte"),
|
||||
features: () => import("./sections/plugins.svelte"),
|
||||
advanced: () => import("./sections/advanced.svelte"),
|
||||
};
|
||||
@@ -0,0 +1,110 @@
|
||||
<script lang="ts">
|
||||
import Switch from "@/interface/components/Switch.svelte";
|
||||
import ConnectMobileApp from "@/interface/components/ConnectMobileApp.svelte";
|
||||
import CloudSettingsSync from "@/interface/components/CloudSettingsSync.svelte";
|
||||
import CloudHeader from "@/interface/components/store/CloudHeader.svelte";
|
||||
import SettingRow from "../SettingRow.svelte";
|
||||
import PluginSettingsBlocks from "../PluginSettingsBlocks.svelte";
|
||||
import { settingsState } from "@/seqta/utils/listeners/SettingsState";
|
||||
import { cloudAuth } from "@/seqta/utils/CloudAuth";
|
||||
import { matchesSearch, type SettingsSectionSharedProps } from "../shared";
|
||||
|
||||
let {
|
||||
showDisclaimer,
|
||||
showCloudPanel,
|
||||
searchQuery = "",
|
||||
}: SettingsSectionSharedProps = $props();
|
||||
|
||||
let cloudState = $state(cloudAuth.state);
|
||||
$effect(() => {
|
||||
const unsub = cloudAuth.subscribe((s) => {
|
||||
cloudState = s;
|
||||
});
|
||||
return unsub;
|
||||
});
|
||||
|
||||
const founderBadgeSetting = {
|
||||
title: "Titlebar founder badge",
|
||||
description: "Show your Cloud founder badge in the SEQTA titlebar",
|
||||
} as const;
|
||||
|
||||
const showCloudCardHeader = $derived(
|
||||
matchesSearch(searchQuery, "BetterSEQTA Cloud", "Account & sync"),
|
||||
);
|
||||
|
||||
const showFounderBadgeSetting = $derived(
|
||||
matchesSearch(
|
||||
searchQuery,
|
||||
founderBadgeSetting.title,
|
||||
founderBadgeSetting.description,
|
||||
"founder badge",
|
||||
"titlebar",
|
||||
"founder",
|
||||
),
|
||||
);
|
||||
|
||||
const showCloudAccountCard = $derived(showCloudCardHeader || showFounderBadgeSetting);
|
||||
</script>
|
||||
|
||||
<SettingRow
|
||||
title="Connect Mobile App"
|
||||
description="Link your SEQTA session to DesQTA — the modern desktop and mobile app for SEQTA Learn"
|
||||
id={0}
|
||||
Component={ConnectMobileApp}
|
||||
{searchQuery}
|
||||
props={{}}
|
||||
/>
|
||||
|
||||
{#if showCloudAccountCard}
|
||||
<div class="border-none">
|
||||
<div
|
||||
class="p-1 my-1 from-white to-zinc-100 bg-gradient-to-br rounded-xl border shadow-sm border-zinc-200/50 dark:border-zinc-700/40 dark:to-zinc-900/50 dark:from-zinc-900/40"
|
||||
>
|
||||
{#if showCloudCardHeader}
|
||||
<div class="flex justify-between items-center px-5 py-4">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-xl font-bold">BetterSEQTA Cloud</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">Account & sync</p>
|
||||
</div>
|
||||
<div>
|
||||
<CloudHeader alwaysShowUserName onClick={showCloudPanel} />
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
{#if cloudState.isLoggedIn}
|
||||
<div class="px-3 pb-3" class:pt-3={!showCloudCardHeader}>
|
||||
{#if showCloudCardHeader}
|
||||
<CloudSettingsSync
|
||||
showDisclaimer={(onConfirm, onCancel) =>
|
||||
showDisclaimer(
|
||||
onConfirm,
|
||||
onCancel,
|
||||
"Restore from cloud?",
|
||||
"This will replace your local settings with the cloud backup. Continue?",
|
||||
)}
|
||||
/>
|
||||
{/if}
|
||||
{#if showFounderBadgeSetting}
|
||||
<SettingRow
|
||||
title={founderBadgeSetting.title}
|
||||
description={founderBadgeSetting.description}
|
||||
id={17}
|
||||
Component={Switch}
|
||||
{searchQuery}
|
||||
props={{
|
||||
state: $settingsState.showTitlebarFounderBadge !== false,
|
||||
onChange: (isOn: boolean) => (settingsState.showTitlebarFounderBadge = isOn),
|
||||
}}
|
||||
/>
|
||||
{/if}
|
||||
</div>
|
||||
{:else if showFounderBadgeSetting}
|
||||
<div class="px-5 pb-4 text-sm text-zinc-600 dark:text-zinc-400">
|
||||
Sign in to Cloud first.
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<PluginSettingsBlocks section="account" {showDisclaimer} {searchQuery} />
|
||||
@@ -0,0 +1,248 @@
|
||||
<script lang="ts">
|
||||
import Switch from "@/interface/components/Switch.svelte";
|
||||
import Button from "@/interface/components/Button.svelte";
|
||||
import SettingRow from "../SettingRow.svelte";
|
||||
import { settingsState } from "@/seqta/utils/listeners/SettingsState";
|
||||
import { showPrivacyNotification } from "@/seqta/utils/Openers/OpenPrivacyNotification";
|
||||
import { showThemeOfTheMonthPopupNow } from "@/seqta/utils/Openers/OpenThemeOfTheMonthPopup";
|
||||
import { closeExtensionPopup } from "@/seqta/utils/Closers/closeExtensionPopup";
|
||||
import { getSnapshotForUpload } from "@/seqta/utils/cloudSettingsSync";
|
||||
import { getStoredOverride, setApiBase } from "@/seqta/utils/DevApiBase";
|
||||
import { matchesSearch, type SettingsSectionSharedProps } from "../shared";
|
||||
|
||||
let { searchQuery = "" }: SettingsSectionSharedProps = $props();
|
||||
|
||||
let devApiBaseInput = $state<string>(getStoredOverride() ?? "");
|
||||
let devApiBaseActive = $state<string | null>(getStoredOverride());
|
||||
|
||||
function applyDevApiBase() {
|
||||
const trimmed = devApiBaseInput.trim();
|
||||
if (trimmed === "") {
|
||||
setApiBase(null);
|
||||
devApiBaseActive = null;
|
||||
return;
|
||||
}
|
||||
if (!/^https?:\/\//.test(trimmed)) {
|
||||
alert("Please enter a full URL starting with http:// or https://");
|
||||
return;
|
||||
}
|
||||
setApiBase(trimmed);
|
||||
devApiBaseActive = trimmed.replace(/\/$/, "");
|
||||
}
|
||||
|
||||
function clearDevApiBase() {
|
||||
devApiBaseInput = "";
|
||||
setApiBase(null);
|
||||
devApiBaseActive = null;
|
||||
}
|
||||
|
||||
async function exportCloudSettingsJsonToFile() {
|
||||
const payload = await getSnapshotForUpload();
|
||||
const blob = new Blob([JSON.stringify(payload, null, 2)], {
|
||||
type: "application/json",
|
||||
});
|
||||
const url = URL.createObjectURL(blob);
|
||||
const a = document.createElement("a");
|
||||
a.href = url;
|
||||
a.download = `betterseqta-plus-settings-export-${new Date().toISOString().replace(/[:.]/g, "-")}.json`;
|
||||
a.click();
|
||||
URL.revokeObjectURL(url);
|
||||
}
|
||||
</script>
|
||||
|
||||
<SettingRow
|
||||
title="BetterSEQTA+"
|
||||
description="Enables BetterSEQTA+ features"
|
||||
id={12}
|
||||
Component={Switch}
|
||||
{searchQuery}
|
||||
props={{
|
||||
state: $settingsState.onoff,
|
||||
onChange: (isOn: boolean) => (settingsState.onoff = isOn),
|
||||
}}
|
||||
/>
|
||||
|
||||
{#if $settingsState.devMode && matchesSearch(
|
||||
searchQuery,
|
||||
"Developer Mode",
|
||||
"Verbose logging",
|
||||
"Delay loading screen",
|
||||
"Sensitive Hider",
|
||||
"Mock Notices",
|
||||
"Show Privacy Notification",
|
||||
"Show Theme of the Month",
|
||||
"Export cloud settings JSON",
|
||||
"API Base URL",
|
||||
"GitHub latest version override",
|
||||
)}
|
||||
<div
|
||||
class="flex-col p-1 my-1 bg-gradient-to-br from-white rounded-xl border shadow-sm to-zinc-100 border-zinc-200/50 dark:border-zinc-700/40 dark:to-zinc-900/50 dark:from-zinc-900/40"
|
||||
>
|
||||
<div class="flex justify-between items-center px-5 py-4">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-xl font-bold">Developer Mode</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">
|
||||
Enables developer mode, allowing you to test new features and changes.
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
<Switch
|
||||
state={$settingsState.devMode}
|
||||
onChange={(isOn: boolean) => (settingsState.devMode = isOn)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-between items-center px-5 py-4">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-xl font-bold">Verbose logging</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">
|
||||
Show diagnostic console output (indexer, theme manager, timetable colour patch, etc.)
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
<Switch
|
||||
state={$settingsState.verboseLogging ?? false}
|
||||
onChange={(isOn: boolean) => (settingsState.verboseLogging = isOn)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-between items-center px-5 py-4">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-xl font-bold">Delay loading screen</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">
|
||||
Keep the loading overlay visible for 5 extra seconds so you can preview canvas variants.
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
<Switch
|
||||
state={$settingsState.devDelayLoadingScreen ?? false}
|
||||
onChange={(isOn: boolean) => (settingsState.devDelayLoadingScreen = isOn)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-between items-center px-5 py-4">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-xl font-bold">Sensitive Hider</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">
|
||||
Replace sensitive content with mock data
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
<Switch
|
||||
state={$settingsState.hideSensitiveContent ?? false}
|
||||
onChange={(isOn: boolean) => (settingsState.hideSensitiveContent = isOn)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-between items-center px-5 py-4">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-xl font-bold">Mock Notices</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">
|
||||
Use fake notice data on homepage instead of real data
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
<Switch
|
||||
state={$settingsState.mockNotices ?? false}
|
||||
onChange={(isOn: boolean) => (settingsState.mockNotices = isOn)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-between items-center px-5 py-4">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-xl font-bold">Show Privacy Notification</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">
|
||||
Show the privacy notification popup on next page load
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
<Button
|
||||
onClick={async () => {
|
||||
settingsState.privacyStatementShown = false;
|
||||
settingsState.privacyStatementLastUpdated = undefined;
|
||||
closeExtensionPopup();
|
||||
await new Promise((resolve) => setTimeout(resolve, 100));
|
||||
await showPrivacyNotification();
|
||||
}}
|
||||
text="Show Now"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-between items-center px-5 py-4">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-xl font-bold">Show Theme of the Month</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">
|
||||
Fetch and show the current month's popup now (ignores dismissed state)
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
<Button
|
||||
onClick={async () => {
|
||||
closeExtensionPopup();
|
||||
await new Promise((resolve) => setTimeout(resolve, 100));
|
||||
await showThemeOfTheMonthPopupNow();
|
||||
}}
|
||||
text="Show Now"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-between items-center px-5 py-4">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-xl font-bold">Export cloud settings JSON</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">
|
||||
Download the same payload as cloud sync (OAuth tokens stripped). For debugging and server
|
||||
testing.
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
<Button onClick={exportCloudSettingsJsonToFile} text="Export to file" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-col gap-2 px-4 py-3">
|
||||
<div class="flex justify-between items-start gap-3">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-xl font-bold">API Base URL (session only)</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">
|
||||
Override the content API host for this browser session. Cleared on restart. Affects
|
||||
themes, theme of the month, and other server-driven content.
|
||||
</p>
|
||||
{#if devApiBaseActive}
|
||||
<p class="text-xs mt-1 text-amber-600 dark:text-amber-400">
|
||||
Override active: <span class="font-mono">{devApiBaseActive}</span>
|
||||
</p>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex gap-2 items-center">
|
||||
<input
|
||||
type="text"
|
||||
placeholder="https://betterseqta.org"
|
||||
bind:value={devApiBaseInput}
|
||||
class="flex-1 px-2 py-1 text-xs rounded border bg-white dark:bg-zinc-800 border-zinc-300 dark:border-zinc-700 text-zinc-900 dark:text-zinc-100"
|
||||
/>
|
||||
<Button onClick={applyDevApiBase} text="Apply" />
|
||||
{#if devApiBaseActive}
|
||||
<Button onClick={clearDevApiBase} text="Clear" />
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-col gap-2 px-4 py-3">
|
||||
<div>
|
||||
<h2 class="text-xl font-bold">GitHub latest version override</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">
|
||||
Pretend a newer GitHub release exists to test the update badge. Only applies when dev mode
|
||||
is on.
|
||||
</p>
|
||||
</div>
|
||||
<input
|
||||
type="text"
|
||||
placeholder="e.g. 9.9.9"
|
||||
value={$settingsState.devGhReleaseVersionOverride ?? ""}
|
||||
oninput={(e) => {
|
||||
settingsState.devGhReleaseVersionOverride = e.currentTarget.value;
|
||||
}}
|
||||
class="px-2 py-1 text-xs rounded border bg-white dark:bg-zinc-800 border-zinc-300 dark:border-zinc-700 text-zinc-900 dark:text-zinc-100"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
@@ -0,0 +1,105 @@
|
||||
<script lang="ts">
|
||||
import Switch from "@/interface/components/Switch.svelte";
|
||||
import Button from "@/interface/components/Button.svelte";
|
||||
import PickerSwatch from "@/interface/components/PickerSwatch.svelte";
|
||||
import SidebarAppearance from "@/interface/components/SidebarAppearance.svelte";
|
||||
import SettingRow from "../SettingRow.svelte";
|
||||
import PluginSettingsBlocks from "../PluginSettingsBlocks.svelte";
|
||||
import { settingsState } from "@/seqta/utils/listeners/SettingsState";
|
||||
import { isSeqtaEngageExperience } from "@/seqta/utils/isSeqtaEngage";
|
||||
import { matchesSearch, type SettingsSectionSharedProps } from "../shared";
|
||||
|
||||
let {
|
||||
showColourPicker,
|
||||
showFontPicker,
|
||||
showDisclaimer,
|
||||
searchQuery = "",
|
||||
}: SettingsSectionSharedProps = $props();
|
||||
|
||||
const isEngage = isSeqtaEngageExperience();
|
||||
</script>
|
||||
|
||||
{#each [
|
||||
{
|
||||
title: "Custom Theme Colour",
|
||||
description: "Customise the overall theme colour of SEQTA Learn",
|
||||
id: 4,
|
||||
Component: PickerSwatch,
|
||||
props: { onClick: showColourPicker },
|
||||
},
|
||||
{
|
||||
title: "Interface Font",
|
||||
description: "Choose the typeface used across SEQTA Learn",
|
||||
id: 16,
|
||||
Component: Button,
|
||||
props: { onClick: showFontPicker, text: "Change" },
|
||||
},
|
||||
] as option (option.id)}
|
||||
<SettingRow {...option} {searchQuery} />
|
||||
{/each}
|
||||
|
||||
{#if !isEngage && matchesSearch(searchQuery, "Sidebar Style", "Item Size", "Corner Radius", "Active Indicator", "Sidebar Width", "Transparency Effects", "Blur Strength")}
|
||||
<div class="border-none">
|
||||
<SidebarAppearance />
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if matchesSearch(searchQuery, "Adaptive Theme Colour", "Soft Gradient", "Smooth colour transition")}
|
||||
<div class="border-none">
|
||||
<div
|
||||
class="p-1 my-1 from-white to-zinc-100 bg-gradient-to-br rounded-xl border shadow-sm border-zinc-200/50 dark:border-zinc-700/40 dark:to-zinc-900/50 dark:from-zinc-900/40"
|
||||
>
|
||||
<div class="flex justify-between items-center px-5 py-4">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-xl font-bold">Adaptive Theme Colour</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">
|
||||
Change the theme colour based on the current class (e.g. when viewing a course or
|
||||
assessments page)
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
<Switch
|
||||
state={$settingsState.adaptiveThemeColour ?? false}
|
||||
onChange={(isOn: boolean) => (settingsState.adaptiveThemeColour = isOn)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
{#if $settingsState.adaptiveThemeColour}
|
||||
<div
|
||||
class="flex justify-between items-center px-5 py-4 pl-7 border-t border-zinc-100 dark:border-zinc-700/50"
|
||||
>
|
||||
<div class="pr-4">
|
||||
<h2 class="text-xl font-bold">Soft Gradient</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">
|
||||
Use a soft gradient instead of a solid colour when viewing a class
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
<Switch
|
||||
state={$settingsState.adaptiveThemeGradient ?? false}
|
||||
onChange={(isOn: boolean) => (settingsState.adaptiveThemeGradient = isOn)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="flex justify-between items-center px-5 py-4 pl-7 border-t border-zinc-100 dark:border-zinc-700/50"
|
||||
>
|
||||
<div class="pr-4">
|
||||
<h2 class="text-xl font-bold">Smooth colour transition</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">
|
||||
Ease between class/subject colours when navigating instead of switching instantly
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
<Switch
|
||||
state={$settingsState.adaptiveThemeColourTransition ?? true}
|
||||
onChange={(isOn: boolean) => (settingsState.adaptiveThemeColourTransition = isOn)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<PluginSettingsBlocks section="appearance" {showDisclaimer} {searchQuery} />
|
||||
@@ -0,0 +1,244 @@
|
||||
<script lang="ts">
|
||||
import Switch from "@/interface/components/Switch.svelte";
|
||||
import Button from "@/interface/components/Button.svelte";
|
||||
import Select from "@/interface/components/Select.svelte";
|
||||
import SettingRow from "../SettingRow.svelte";
|
||||
import { settingsState } from "@/seqta/utils/listeners/SettingsState";
|
||||
import { isSeqtaEngageExperience } from "@/seqta/utils/isSeqtaEngage";
|
||||
import {
|
||||
PERFORMANCE_HEAVY_PLUGINS,
|
||||
setPerformanceModePluginOverride,
|
||||
} from "@/seqta/utils/performanceMode";
|
||||
import browser from "webextension-polyfill";
|
||||
import { matchesSearch, type SettingsSectionSharedProps } from "../shared";
|
||||
|
||||
let { searchQuery = "" }: SettingsSectionSharedProps = $props();
|
||||
|
||||
const isEngage = isSeqtaEngageExperience();
|
||||
|
||||
const generalOptions = $derived([
|
||||
{
|
||||
title: "Performance Mode",
|
||||
description:
|
||||
"Pauses heavy plugins, disables blur, and uses shorter smooth animations while SEQTA is open",
|
||||
id: 0,
|
||||
Component: Switch,
|
||||
props: {
|
||||
state: $settingsState.performanceMode ?? false,
|
||||
onChange: (isOn: boolean) => (settingsState.performanceMode = isOn),
|
||||
},
|
||||
},
|
||||
...(!isEngage
|
||||
? [
|
||||
{
|
||||
title: "Edit Sidebar Layout",
|
||||
description: "Reorder pages on the sidebar",
|
||||
id: 5,
|
||||
Component: Button,
|
||||
props: {
|
||||
onClick: () =>
|
||||
browser.runtime.sendMessage({ type: "currentTab", info: "EditSidebar" }),
|
||||
text: "Edit",
|
||||
},
|
||||
},
|
||||
{
|
||||
title: "Icon Only Sidebar",
|
||||
description: "Show only icons in the sidebar for a compact layout",
|
||||
id: 14,
|
||||
Component: Switch,
|
||||
props: {
|
||||
state: $settingsState.iconOnlySidebar ?? false,
|
||||
onChange: (isOn: boolean) => (settingsState.iconOnlySidebar = isOn),
|
||||
},
|
||||
},
|
||||
]
|
||||
: []),
|
||||
{
|
||||
title: "Animations",
|
||||
description: "Enable animations on certain pages",
|
||||
id: 6,
|
||||
Component: Switch,
|
||||
props: {
|
||||
state: $settingsState.animations,
|
||||
onChange: (isOn: boolean) => (settingsState.animations = isOn),
|
||||
},
|
||||
},
|
||||
{
|
||||
title: "12 Hour Time",
|
||||
description: "Prefer 12 hour time format for SEQTA",
|
||||
id: 9,
|
||||
Component: Switch,
|
||||
props: {
|
||||
state: $settingsState.timeFormat === "12",
|
||||
onChange: (isOn: boolean) => (settingsState.timeFormat = isOn ? "12" : "24"),
|
||||
},
|
||||
},
|
||||
{
|
||||
title: "Default Page",
|
||||
description: "Choose which page loads first when you open SEQTA",
|
||||
id: 10,
|
||||
Component: Select,
|
||||
props: {
|
||||
value: $settingsState.defaultPage ?? "home",
|
||||
onChange: (value: string) => (settingsState.defaultPage = value),
|
||||
options: isEngage
|
||||
? [
|
||||
{ value: "home", label: "Home" },
|
||||
{ value: "dashboard", label: "Dashboard" },
|
||||
{ value: "timetable", label: "Timetable" },
|
||||
{ value: "messages", label: "Messages" },
|
||||
{ value: "documents", label: "Documents" },
|
||||
{ value: "reports", label: "Reports" },
|
||||
]
|
||||
: [
|
||||
{ value: "home", label: "Home" },
|
||||
{ value: "dashboard", label: "Dashboard" },
|
||||
{ value: "timetable", label: "Timetable" },
|
||||
{ value: "welcome", label: "Welcome" },
|
||||
{ value: "messages", label: "Messages" },
|
||||
{ value: "documents", label: "Documents" },
|
||||
{ value: "reports", label: "Reports" },
|
||||
],
|
||||
},
|
||||
},
|
||||
...(!isEngage
|
||||
? [
|
||||
{
|
||||
title: "News Feed Source",
|
||||
description: "Choose the sources for your news feed",
|
||||
id: 11,
|
||||
Component: Select,
|
||||
props: {
|
||||
value: $settingsState.newsSource,
|
||||
onChange: (value: string) => (settingsState.newsSource = value),
|
||||
options: [
|
||||
{ value: "australia", label: "Australia" },
|
||||
{ value: "usa", label: "USA" },
|
||||
{ value: "uk", label: "UK" },
|
||||
{ value: "taiwan", label: "Taiwan" },
|
||||
{ value: "hong_kong", label: "Hong Kong" },
|
||||
{ value: "panama", label: "Panama" },
|
||||
{ value: "canada", label: "Canada" },
|
||||
{ value: "singapore", label: "Singapore" },
|
||||
{ value: "japan", label: "Japan" },
|
||||
{ value: "netherlands", label: "Netherlands" },
|
||||
],
|
||||
},
|
||||
},
|
||||
]
|
||||
: []),
|
||||
]);
|
||||
</script>
|
||||
|
||||
{#each generalOptions as option (option.id)}
|
||||
<SettingRow {...option} {searchQuery} />
|
||||
{#if option.id === 0 && $settingsState.performanceMode && matchesSearch(searchQuery, "Performance Mode", "Global Search", "Assessment Averages", "enable anyway", "paused")}
|
||||
<div class="border-none -mt-px">
|
||||
<div
|
||||
class="mx-5 mb-4 rounded-xl border border-zinc-200/80 bg-zinc-50/80 px-4 py-3 dark:border-zinc-700/60 dark:bg-zinc-900/40"
|
||||
>
|
||||
<p class="mb-3 text-sm font-medium text-zinc-500 dark:text-zinc-400">
|
||||
Paused for performance — enable anyway:
|
||||
</p>
|
||||
<div class="space-y-3">
|
||||
{#each PERFORMANCE_HEAVY_PLUGINS as heavy (heavy.id)}
|
||||
<div class="flex justify-between items-center gap-4">
|
||||
<div class="min-w-0">
|
||||
<p class="text-sm font-semibold text-zinc-800 dark:text-zinc-100">{heavy.name}</p>
|
||||
<p class="text-xs text-zinc-500 dark:text-zinc-400">{heavy.description}</p>
|
||||
</div>
|
||||
<Switch
|
||||
state={$settingsState.performanceModePluginOverrides?.[heavy.id] === true}
|
||||
onChange={(forceOn: boolean) => setPerformanceModePluginOverride(heavy.id, forceOn)}
|
||||
/>
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
{/each}
|
||||
|
||||
{#if matchesSearch(
|
||||
searchQuery,
|
||||
"Home Page Assessments",
|
||||
"Include Past Assessments",
|
||||
"Maximum Subjects",
|
||||
"Maximum Assessments per Subject",
|
||||
)}
|
||||
<div class="border-none">
|
||||
<div
|
||||
class="p-1 my-1 from-white to-zinc-100 bg-gradient-to-br rounded-xl border shadow-sm border-zinc-200/50 dark:border-zinc-700/40 dark:to-zinc-900/50 dark:from-zinc-900/40"
|
||||
>
|
||||
<div class="flex justify-between items-center px-5 py-4">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-xl font-bold">Home Page Assessments</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">
|
||||
Limit upcoming assessments shown on the home page by subject
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="flex justify-between items-center px-5 py-4 pl-7 border-t border-zinc-100 dark:border-zinc-700/50"
|
||||
>
|
||||
<div class="pr-4">
|
||||
<h2 class="text-xl font-bold">Include Past Assessments</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">
|
||||
Show past-due assessments from the upcoming list, matching the Assessments page
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
<Switch
|
||||
state={$settingsState.homeUpcomingIncludePast ?? true}
|
||||
onChange={(isOn: boolean) => (settingsState.homeUpcomingIncludePast = isOn)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="flex justify-between items-center px-5 py-4 pl-7 border-t border-zinc-100 dark:border-zinc-700/50"
|
||||
>
|
||||
<div class="pr-4">
|
||||
<h2 class="text-xl font-bold">Maximum Subjects</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">
|
||||
Number of subjects to include, ordered by soonest due date
|
||||
</p>
|
||||
</div>
|
||||
<Select
|
||||
value={String($settingsState.homeUpcomingSubjectsMax ?? 5)}
|
||||
onChange={(value: string) => (settingsState.homeUpcomingSubjectsMax = Number(value))}
|
||||
options={[
|
||||
{ value: "0", label: "All" },
|
||||
{ value: "3", label: "3" },
|
||||
{ value: "5", label: "5" },
|
||||
{ value: "7", label: "7" },
|
||||
{ value: "10", label: "10" },
|
||||
{ value: "15", label: "15" },
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
class="flex justify-between items-center px-5 py-4 pl-7 border-t border-zinc-100 dark:border-zinc-700/50"
|
||||
>
|
||||
<div class="pr-4">
|
||||
<h2 class="text-xl font-bold">Maximum Assessments per Subject</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">
|
||||
Assessments shown for each included subject
|
||||
</p>
|
||||
</div>
|
||||
<Select
|
||||
value={String($settingsState.homeUpcomingAssessmentsPerSubjectMax ?? 0)}
|
||||
onChange={(value: string) =>
|
||||
(settingsState.homeUpcomingAssessmentsPerSubjectMax = Number(value))}
|
||||
options={[
|
||||
{ value: "0", label: "All" },
|
||||
{ value: "1", label: "1" },
|
||||
{ value: "2", label: "2" },
|
||||
{ value: "3", label: "3" },
|
||||
{ value: "5", label: "5" },
|
||||
{ value: "10", label: "10" },
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
@@ -0,0 +1,12 @@
|
||||
<script lang="ts">
|
||||
import PluginSettingsBlocks from "../PluginSettingsBlocks.svelte";
|
||||
import type { SettingsSectionId, SettingsSectionSharedProps } from "../shared";
|
||||
|
||||
let {
|
||||
section,
|
||||
showDisclaimer,
|
||||
searchQuery = "",
|
||||
}: SettingsSectionSharedProps & { section: SettingsSectionId } = $props();
|
||||
</script>
|
||||
|
||||
<PluginSettingsBlocks {section} {showDisclaimer} {searchQuery} />
|
||||
@@ -0,0 +1,47 @@
|
||||
export const ALL_SETTINGS_SECTIONS = [
|
||||
"account",
|
||||
"general",
|
||||
"appearance",
|
||||
"timetable",
|
||||
"assessments",
|
||||
"features",
|
||||
"advanced",
|
||||
] as const;
|
||||
|
||||
export type SettingsSectionId = (typeof ALL_SETTINGS_SECTIONS)[number];
|
||||
|
||||
export type SettingsSectionSharedProps = {
|
||||
showColourPicker: () => void;
|
||||
showFontPicker: () => void;
|
||||
showDisclaimer: (
|
||||
onConfirm: () => void,
|
||||
onCancel: () => void,
|
||||
title?: string,
|
||||
message?: string,
|
||||
) => void;
|
||||
showCloudPanel: () => void;
|
||||
searchQuery?: string;
|
||||
};
|
||||
|
||||
export function matchesSearch(
|
||||
searchQuery: string,
|
||||
...parts: Array<string | undefined>
|
||||
): boolean {
|
||||
const q = searchQuery.trim().toLowerCase();
|
||||
return !q || parts.some((part) => part?.toLowerCase().includes(q));
|
||||
}
|
||||
|
||||
export const PLUGIN_SECTION_BY_ID: Record<string, SettingsSectionId> = {
|
||||
"profile-picture": "account",
|
||||
"animated-background": "appearance",
|
||||
"background-music": "appearance",
|
||||
timetable: "timetable",
|
||||
timetableEdit: "timetable",
|
||||
"assessments-overview": "assessments",
|
||||
"assessments-average": "assessments",
|
||||
"grade-analytics": "assessments",
|
||||
"global-search": "features",
|
||||
"enhanced-navigation": "features",
|
||||
messageFolders: "features",
|
||||
notificationCollector: "features",
|
||||
};
|
||||
@@ -175,11 +175,18 @@
|
||||
onMount(async () => {
|
||||
window.addEventListener('bsplus:highlight-theme', onHighlightThemeEvent);
|
||||
|
||||
await fetchThemes();
|
||||
await fetchCurrentThemes();
|
||||
|
||||
const pending = consumePendingHighlightThemeId();
|
||||
if (pending) focusThemeById(pending);
|
||||
const load = async () => {
|
||||
await fetchThemes();
|
||||
await fetchCurrentThemes();
|
||||
const pending = consumePendingHighlightThemeId();
|
||||
if (pending) focusThemeById(pending);
|
||||
};
|
||||
|
||||
if (typeof requestIdleCallback === "function") {
|
||||
requestIdleCallback(() => void load(), { timeout: 2500 });
|
||||
} else {
|
||||
void load();
|
||||
}
|
||||
|
||||
return () => {
|
||||
window.removeEventListener('bsplus:highlight-theme', onHighlightThemeEvent);
|
||||
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
syncAnimatedBackground,
|
||||
updateAnimationSpeed,
|
||||
} from "./backgroundLayers";
|
||||
import { isPerformanceMode } from "@/seqta/utils/performanceMode";
|
||||
|
||||
const settings = defineSettings({
|
||||
speed: numberSetting({
|
||||
@@ -40,6 +41,11 @@ const animatedBackgroundPlugin: Plugin<typeof settings> = {
|
||||
settings: instance.settings,
|
||||
|
||||
run: async (api) => {
|
||||
if (isPerformanceMode()) {
|
||||
removeAnimatedBackgroundLayers();
|
||||
return () => removeAnimatedBackgroundLayers();
|
||||
}
|
||||
|
||||
await syncAnimatedBackground(api);
|
||||
const resync = () => void syncAnimatedBackground(api);
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
import styles from "./styles.css?inline";
|
||||
import BackgroundMusicSetting from "./BackgroundMusicSetting.svelte";
|
||||
import localforage from "localforage";
|
||||
import { isPerformanceMode } from "@/seqta/utils/performanceMode";
|
||||
|
||||
const settings = defineSettings({
|
||||
uploader: componentSetting({
|
||||
@@ -187,6 +188,10 @@ const backgroundMusicPlugin: Plugin<typeof settings> = {
|
||||
defaultEnabled: false,
|
||||
|
||||
run: async (api) => {
|
||||
if (isPerformanceMode()) {
|
||||
return () => stopAudio();
|
||||
}
|
||||
|
||||
await api.storage.loaded;
|
||||
|
||||
type BgSettings = { volume?: number; pauseOnHidden?: boolean };
|
||||
|
||||
@@ -17,6 +17,7 @@ import {
|
||||
isValidHotkey,
|
||||
} from "./src/utils/hotkeyUtils";
|
||||
import { titleBarState } from "@/seqta/ui/titlebar/titleBarState.svelte";
|
||||
import { isPluginAllowedInPerformanceMode } from "@/seqta/utils/performanceMode";
|
||||
|
||||
const settings = defineSettings({
|
||||
searchHotkey: hotkeySetting({
|
||||
@@ -91,6 +92,7 @@ const runGlobalSearch = globalSearchPlugin.run!;
|
||||
|
||||
globalSearchPlugin.run = async (api) => {
|
||||
if (isSeqtaEngageExperience() || isSeqtaLoginPage()) return () => {};
|
||||
if (!isPluginAllowedInPerformanceMode("global-search")) return () => {};
|
||||
|
||||
// Eager chrome (like Analytics menu injection) — heavy chunk loads behind it.
|
||||
const hotkey = isValidHotkey(api.settings.searchHotkey ?? "")
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
getStoredPassiveItems,
|
||||
installPassiveObserver,
|
||||
} from "../indexing/passiveObserver";
|
||||
import { globalSearchIndexingEnabled } from "@/seqta/utils/performanceMode";
|
||||
|
||||
function scheduleIdleIndexing(run: () => void): void {
|
||||
if (typeof requestIdleCallback === "function") {
|
||||
@@ -83,7 +84,7 @@ const globalSearchPlugin: Plugin<{}> = {
|
||||
(await import("../indexing/selfTests")).runGlobalSearchSelfTests(),
|
||||
};
|
||||
|
||||
if (api.settings.passiveIndexing) {
|
||||
if (globalSearchIndexingEnabled(!!api.settings.passiveIndexing)) {
|
||||
try {
|
||||
installPassiveObserver();
|
||||
} catch (error) {
|
||||
@@ -91,7 +92,10 @@ const globalSearchPlugin: Plugin<{}> = {
|
||||
}
|
||||
}
|
||||
|
||||
if (api.settings.runIndexingOnLoad && !isIndexingPaused()) {
|
||||
if (
|
||||
globalSearchIndexingEnabled(!!api.settings.runIndexingOnLoad) &&
|
||||
!isIndexingPaused()
|
||||
) {
|
||||
scheduleIdleIndexing(() => {
|
||||
if (!isIndexingPaused()) void runIndexing();
|
||||
});
|
||||
|
||||
@@ -3,6 +3,7 @@ import { unmount } from "svelte";
|
||||
import { warmUpVectorSearchOnInteraction } from "../search/vector/vectorSearch";
|
||||
import { formatHotkeyForDisplay, isValidHotkey } from "../utils/hotkeyUtils";
|
||||
import { waitForElm } from "@/seqta/utils/waitForElm";
|
||||
import { transparencyEnabled } from "@/seqta/utils/performanceMode";
|
||||
import browser from "webextension-polyfill";
|
||||
|
||||
type AppRef = {
|
||||
@@ -295,7 +296,7 @@ export async function mountSearchBar(
|
||||
SearchBar,
|
||||
searchRoot.attachShadow({ mode: "open" }),
|
||||
{
|
||||
transparencyEffects: api.settings.transparencyEffects,
|
||||
transparencyEffects: transparencyEnabled(),
|
||||
showRecentFirst: api.settings.showRecentFirst,
|
||||
searchHotkey: currentHotkey,
|
||||
},
|
||||
|
||||
@@ -9,6 +9,7 @@ import { INDEX_SCHEMA_VERSION, SCHEMA_VERSION_KEY } from "./schemaVersion";
|
||||
import { resetSearchIndexes } from "./resetIndexes";
|
||||
import { isIndexingPaused } from "./indexingPause";
|
||||
import { setIndexingActive } from "./indexingState";
|
||||
import { isPluginBlockedByPerformanceMode } from "@/seqta/utils/performanceMode";
|
||||
|
||||
import { verboseDebug } from '@/utils/verboseLog';
|
||||
const META_STORE = "meta";
|
||||
@@ -286,6 +287,11 @@ function dispatchVectorProgress(
|
||||
}
|
||||
|
||||
export async function runIndexing(): Promise<void> {
|
||||
if (isPluginBlockedByPerformanceMode("global-search")) {
|
||||
verboseDebug("[Indexer] Skipping indexing — performance mode blocks Global Search.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (isIndexingPaused()) {
|
||||
verboseDebug(
|
||||
"[Indexer] Skipping indexing — index was reset; reload the page to rebuild.",
|
||||
|
||||
@@ -13,6 +13,7 @@ import { decorateIndexItems } from "./renderComponents";
|
||||
import { isIndexingPaused } from "./indexingPause";
|
||||
import { isIndexingActive } from "./indexingState";
|
||||
import { isAssessmentListRoute } from "./routeFilters";
|
||||
import { isPluginBlockedByPerformanceMode } from "@/seqta/utils/performanceMode";
|
||||
|
||||
/**
|
||||
* Passive network observer.
|
||||
@@ -481,6 +482,7 @@ async function consumeResponse(
|
||||
url: string,
|
||||
requestBody: unknown,
|
||||
): Promise<void> {
|
||||
if (isPluginBlockedByPerformanceMode("global-search")) return;
|
||||
if (!response.ok) return;
|
||||
|
||||
const route = normalizeSeqtaPath(url);
|
||||
|
||||
@@ -21,6 +21,9 @@
|
||||
} from "./timeRange";
|
||||
import { openAnalyticsPrivacyPopup } from "./openAnalyticsPrivacyPopup";
|
||||
import { settingsState } from "@/seqta/utils/listeners/SettingsState";
|
||||
import { animationsEnabled } from "@/seqta/utils/performanceMode";
|
||||
|
||||
let { simpleMode = false } = $props<{ simpleMode?: boolean }>();
|
||||
|
||||
let analyticsData: Assessment[] | null = $state(null);
|
||||
let loading = $state(true);
|
||||
@@ -40,7 +43,7 @@
|
||||
|
||||
let timestampInterval: ReturnType<typeof setInterval> | null = null;
|
||||
let contentReady = $state(false);
|
||||
const fadeDuration = $derived($settingsState.animations ? 200 : 0);
|
||||
const fadeDuration = $derived(animationsEnabled() ? 200 : 0);
|
||||
|
||||
const formattedTimestamp = $derived(() => {
|
||||
if (!lastUpdated) return "";
|
||||
@@ -401,6 +404,7 @@
|
||||
/>
|
||||
</div>
|
||||
|
||||
{#if !simpleMode}
|
||||
<div class="bsplus-analytics-filter-group">
|
||||
<span class="bsplus-analytics-field-label">Grade range</span>
|
||||
<GradeRangeSlider bind:value={gradeRange} />
|
||||
@@ -413,6 +417,7 @@
|
||||
<span>Per-subject trends</span>
|
||||
</label>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{@render sidebarActions()}
|
||||
</aside>
|
||||
@@ -436,6 +441,7 @@
|
||||
</div>
|
||||
|
||||
<div class="bsplus-analytics-results">
|
||||
{#if !simpleMode}
|
||||
<div class="bsplus-analytics-charts">
|
||||
<div class="bsplus-analytics-chart-cell">
|
||||
<AnalyticsAreaChart
|
||||
@@ -449,6 +455,7 @@
|
||||
<AnalyticsBarChart data={gradedFiltered()} {timeRange} {customTimeRange} />
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<AssessmentTable data={timeScopedData()} />
|
||||
</div>
|
||||
|
||||
@@ -11,6 +11,7 @@ import { isMenuOptionsOpen } from "@/seqta/utils/Openers/menuOptionsState";
|
||||
import { settingsState } from "@/seqta/utils/listeners/SettingsState";
|
||||
import { applyMenuItemVisibility } from "@/seqta/utils/menuItemVisibility";
|
||||
import { getNativeMenuList } from "@/seqta/ui/sidebar/parseNativeMenu";
|
||||
import { rafThrottle } from "@/seqta/utils/rafThrottle";
|
||||
|
||||
const ANALYTICS_MENU_ICON = MenuitemSVGKey.analytics;
|
||||
export const ANALYTICS_MENU_CLASS = "betterseqta-grade-analytics-item";
|
||||
@@ -88,10 +89,11 @@ export async function injectAnalyticsMenuItem(): Promise<() => void> {
|
||||
|
||||
syncAnalyticsMenu();
|
||||
|
||||
const scheduleAnalyticsSync = rafThrottle(syncAnalyticsMenu);
|
||||
const menuObserver = new MutationObserver(() => {
|
||||
const list = getNativeMenuList() ?? menuList;
|
||||
if (!list || isMenuOptionsOpen() || list.contains(analyticsItem)) return;
|
||||
syncAnalyticsMenu();
|
||||
scheduleAnalyticsSync();
|
||||
});
|
||||
menuObserver.observe(menuList, { childList: true });
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import tailwindStyles from "./tailwind.css?inline";
|
||||
import pluginStyles from "./styles.css?inline";
|
||||
import { settingsState } from "@/seqta/utils/listeners/SettingsState";
|
||||
import { isSimpleAnalyticsUi } from "@/seqta/utils/performanceMode";
|
||||
import { mount, unmount } from "svelte";
|
||||
import GradeAnalyticsPage from "./GradeAnalyticsPage.svelte";
|
||||
import { buildContrastAccentPalette } from "./utils/accentColor";
|
||||
@@ -121,6 +122,7 @@ function syncThemeToAnalyticsUi() {
|
||||
if (analyticsRoot) {
|
||||
syncThemeFromPage(analyticsRoot);
|
||||
analyticsRoot.classList.toggle("bsplus-analytics-motion", !!settingsState.animations);
|
||||
analyticsRoot.classList.toggle("bsplus-analytics-simple", isSimpleAnalyticsUi());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,7 +206,10 @@ export function renderAnalyticsPage(container: HTMLElement) {
|
||||
attributeFilter: ["class"],
|
||||
});
|
||||
|
||||
currentApp = mount(GradeAnalyticsPage, { target: analyticsRoot });
|
||||
currentApp = mount(GradeAnalyticsPage, {
|
||||
target: analyticsRoot,
|
||||
props: { simpleMode: isSimpleAnalyticsUi() },
|
||||
});
|
||||
}
|
||||
|
||||
export function unmountAnalyticsPage() {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { Plugin } from "../../core/types";
|
||||
import { isPerformanceMode } from "@/seqta/utils/performanceMode";
|
||||
import { booleanSetting } from "@/plugins/core/settingsHelpers";
|
||||
import { isSeqtaEngageExperience } from "@/seqta/utils/isSeqtaEngage";
|
||||
import { verboseInfo } from "@/utils/verboseLog";
|
||||
@@ -60,7 +60,7 @@ const notificationCollectorPlugin: Plugin<
|
||||
let pollInterval: number | null = null;
|
||||
let isVisible = !document.hidden;
|
||||
let archiveSyncInFlight = false;
|
||||
const baseInterval = 30000;
|
||||
const baseInterval = isPerformanceMode() ? 60000 : 30000;
|
||||
const maxInterval = 300000;
|
||||
|
||||
api.storage.lastNotificationCount ||= 0;
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
} from "@/types/CustomThemes";
|
||||
import { BSPLUS_PENDING_THEME_ENSURE_AFTER_CLOUD_KEY } from "@/seqta/utils/cloudSettingsSync";
|
||||
import { settingsState } from "@/seqta/utils/listeners/SettingsState";
|
||||
import { fullMotionEffectsEnabled } from "@/seqta/utils/performanceMode";
|
||||
import debounce from "@/seqta/utils/debounce";
|
||||
import { themeUpdates } from "@/interface/hooks/ThemeUpdates";
|
||||
import { getApiBase } from "@/seqta/utils/DevApiBase";
|
||||
@@ -125,7 +126,7 @@ export class ThemeManager {
|
||||
private async applyViewTransition(callback: () => void): Promise<void> {
|
||||
if (
|
||||
!document.startViewTransition ||
|
||||
!settingsState.animations ||
|
||||
!fullMotionEffectsEnabled() ||
|
||||
window.matchMedia("(prefers-reduced-motion: reduce)").matches
|
||||
) {
|
||||
// Just run the callback without animation if transitions not supported
|
||||
|
||||
@@ -13,6 +13,7 @@ import { createPluginAPI } from "./createAPI";
|
||||
import browser from "webextension-polyfill";
|
||||
import { settingsState } from "@/seqta/utils/listeners/SettingsState";
|
||||
import { verboseInfo } from "@/utils/verboseLog";
|
||||
import { isPluginAllowedInPerformanceMode } from "@/seqta/utils/performanceMode";
|
||||
|
||||
interface PluginSettingsStorage {
|
||||
enabled?: boolean;
|
||||
@@ -191,6 +192,14 @@ export class PluginManager {
|
||||
}
|
||||
}
|
||||
|
||||
if (!isPluginAllowedInPerformanceMode(pluginId)) {
|
||||
this.disposePluginAPI(pluginId);
|
||||
verboseInfo(
|
||||
`Plugin "${pluginId}" paused by performance mode`,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// Inject plugin styles if provided
|
||||
if (plugin.styles) {
|
||||
const styleElement = document.createElement("style");
|
||||
|
||||
+57
-19
@@ -8,6 +8,8 @@ import { delay } from "@/seqta/utils/delay";
|
||||
import stringToHTML from "@/seqta/utils/stringToHTML";
|
||||
import { MessageHandler } from "@/seqta/utils/listeners/MessageListener";
|
||||
import { settingsState } from "@/seqta/utils/listeners/SettingsState";
|
||||
import { animationsEnabled, fullMotionEffectsEnabled, isPerformanceMode, syncPerformanceModeEffects } from "@/seqta/utils/performanceMode";
|
||||
import { animatePopupOpen } from "@/seqta/utils/popupAnimation";
|
||||
import { StorageChangeHandler } from "@/seqta/utils/listeners/StorageChanges";
|
||||
import { eventManager } from "@/seqta/utils/listeners/EventManager";
|
||||
import debounce from "@/seqta/utils/debounce";
|
||||
@@ -253,11 +255,21 @@ async function LoadPageElements(): Promise<void> {
|
||||
|
||||
async function handleNotices(node: Element): Promise<void> {
|
||||
if (!(node instanceof HTMLElement)) return;
|
||||
if (!settingsState.animations) return;
|
||||
if (!animationsEnabled()) return;
|
||||
|
||||
if (!fullMotionEffectsEnabled()) {
|
||||
node.style.opacity = "0";
|
||||
node.style.transform = "translateY(8px)";
|
||||
node.style.transition = "opacity 0.2s ease, transform 0.2s ease";
|
||||
requestAnimationFrame(() => {
|
||||
node.style.opacity = "1";
|
||||
node.style.transform = "none";
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
node.style.opacity = "0";
|
||||
|
||||
// get index of node in relation to parent
|
||||
const index = Array.from(node.parentElement!.children).indexOf(node);
|
||||
|
||||
const { animate } = await loadMotion();
|
||||
@@ -370,7 +382,7 @@ async function handleMessages(node: Element): Promise<void> {
|
||||
document.title = "Direct Messages ― SEQTA Learn";
|
||||
SortMessagePageItems(node);
|
||||
|
||||
if (!settingsState.animations) return;
|
||||
if (!animationsEnabled() || !fullMotionEffectsEnabled()) return;
|
||||
|
||||
// Hides messages on page load
|
||||
const style = document.createElement("style");
|
||||
@@ -398,7 +410,7 @@ async function handleMessages(node: Element): Promise<void> {
|
||||
|
||||
async function handleDashboard(node: Element): Promise<void> {
|
||||
if (!(node instanceof HTMLElement)) return;
|
||||
if (!settingsState.animations) return;
|
||||
if (!animationsEnabled() || !fullMotionEffectsEnabled()) return;
|
||||
|
||||
const style = document.createElement("style");
|
||||
style.classList.add("dashboardHider");
|
||||
@@ -429,7 +441,7 @@ async function handleDashboard(node: Element): Promise<void> {
|
||||
|
||||
async function handleDocuments(node: Element): Promise<void> {
|
||||
if (!(node instanceof HTMLElement)) return;
|
||||
if (!settingsState.animations) return;
|
||||
if (!animationsEnabled() || !fullMotionEffectsEnabled()) return;
|
||||
|
||||
await waitForElm(".document", true, 10);
|
||||
try {
|
||||
@@ -453,7 +465,7 @@ async function handleDocuments(node: Element): Promise<void> {
|
||||
|
||||
async function handleReports(node: Element): Promise<void> {
|
||||
if (!(node instanceof HTMLElement)) return;
|
||||
if (!settingsState.animations) return;
|
||||
if (!animationsEnabled() || !fullMotionEffectsEnabled()) return;
|
||||
|
||||
await waitForElm(".report", true, 10);
|
||||
try {
|
||||
@@ -668,13 +680,17 @@ export function showConflictPopup() {
|
||||
document.getElementById("container")?.append(background);
|
||||
|
||||
// CSS fade — avoid Motion on conflict overlay (not critical-path shell, but keeps Motion off this import path).
|
||||
if (settingsState.animations) {
|
||||
const el = background as HTMLElement;
|
||||
el.style.opacity = "0";
|
||||
el.style.transition = "opacity 200ms ease-in-out";
|
||||
requestAnimationFrame(() => {
|
||||
el.style.opacity = "1";
|
||||
});
|
||||
if (animationsEnabled()) {
|
||||
if (fullMotionEffectsEnabled()) {
|
||||
const el = background as HTMLElement;
|
||||
el.style.opacity = "0";
|
||||
el.style.transition = "opacity 200ms ease-in-out";
|
||||
requestAnimationFrame(() => {
|
||||
el.style.opacity = "1";
|
||||
});
|
||||
} else {
|
||||
animatePopupOpen(background);
|
||||
}
|
||||
}
|
||||
|
||||
background.addEventListener("click", (event) => {
|
||||
@@ -748,11 +764,28 @@ export function init() {
|
||||
new StorageChangeHandler();
|
||||
new MessageHandler();
|
||||
|
||||
void updateAllColors();
|
||||
applySelectedFont();
|
||||
syncPerformanceModeEffects();
|
||||
|
||||
const deferBootWork = (fn: () => void) => {
|
||||
if (typeof requestIdleCallback === "function") {
|
||||
requestIdleCallback(fn, { timeout: 3000 });
|
||||
} else {
|
||||
setTimeout(fn, 100);
|
||||
}
|
||||
};
|
||||
deferBootWork(() => {
|
||||
void updateAllColors();
|
||||
applySelectedFont();
|
||||
});
|
||||
|
||||
let hashColorTimer: ReturnType<typeof setTimeout> | null = null;
|
||||
window.addEventListener("hashchange", () => {
|
||||
if (settingsState.adaptiveThemeColour) void updateAllColors();
|
||||
if (!settingsState.adaptiveThemeColour) return;
|
||||
if (hashColorTimer) clearTimeout(hashColorTimer);
|
||||
hashColorTimer = setTimeout(() => {
|
||||
hashColorTimer = null;
|
||||
void updateAllColors();
|
||||
}, isPerformanceMode() ? 200 : 80);
|
||||
});
|
||||
if (!onLogin) {
|
||||
loading();
|
||||
@@ -824,9 +857,14 @@ export function init() {
|
||||
);
|
||||
}
|
||||
|
||||
[1000, 1200, 1500].forEach((delay) =>
|
||||
setTimeout(focusEditor, delay),
|
||||
);
|
||||
let attempts = 0;
|
||||
const tryFocus = () => {
|
||||
focusEditor();
|
||||
if (attempts++ < 5) {
|
||||
requestAnimationFrame(tryFocus);
|
||||
}
|
||||
};
|
||||
requestAnimationFrame(tryFocus);
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
@@ -17,6 +17,8 @@ import { delay } from "@/seqta/utils/delay";
|
||||
import { LUCIDE_MOON_ICON_SVG } from "@/lib/icons/lucideMoon";
|
||||
import { LUCIDE_SUN_ICON_SVG } from "@/lib/icons/lucideSun";
|
||||
import { ensureTitlebarFounderBadgeMounted, refreshTitlebarFounderBadge } from "@/seqta/ui/founderBadge/mountTitlebarFounderBadge";
|
||||
import { isPerformanceMode } from "@/seqta/utils/performanceMode";
|
||||
import { rafThrottle } from "@/seqta/utils/rafThrottle";
|
||||
|
||||
let cachedUserInfo: any = null;
|
||||
let userInfoFetchPromise: Promise<any> | null = null;
|
||||
@@ -145,8 +147,7 @@ export async function AddBetterSEQTAElements() {
|
||||
setupEventListeners();
|
||||
await addDarkLightToggle();
|
||||
customizeMenuToggle();
|
||||
// Kept as fallback if the custom Svelte sidebar fails to mount.
|
||||
setupSidebarAccessibility();
|
||||
maybeSetupSidebarAccessibility();
|
||||
}
|
||||
|
||||
addExtensionSettings();
|
||||
@@ -500,11 +501,18 @@ async function setupEngageSettingsButton() {
|
||||
}
|
||||
(content as HTMLElement).dataset.bsplusEngageSettingsWatch = "1";
|
||||
|
||||
const observer = new MutationObserver(() => {
|
||||
if (document.getElementById("AddedSettings")) return;
|
||||
void tryMount();
|
||||
});
|
||||
observer.observe(content, { childList: true, subtree: true });
|
||||
let engageRemountTimer: ReturnType<typeof setTimeout> | null = null;
|
||||
const debouncedTryMount = () => {
|
||||
if (engageRemountTimer) clearTimeout(engageRemountTimer);
|
||||
engageRemountTimer = setTimeout(() => {
|
||||
engageRemountTimer = null;
|
||||
if (document.getElementById("AddedSettings")) return;
|
||||
void tryMount();
|
||||
}, isPerformanceMode() ? 300 : 80);
|
||||
};
|
||||
|
||||
const observer = new MutationObserver(debouncedTryMount);
|
||||
observer.observe(content, { childList: true, subtree: !isPerformanceMode() });
|
||||
}
|
||||
|
||||
function GetLightDarkModeString() {
|
||||
@@ -572,6 +580,12 @@ function customizeMenuToggle() {
|
||||
}
|
||||
}
|
||||
|
||||
function maybeSetupSidebarAccessibility() {
|
||||
const menu = document.getElementById("menu");
|
||||
if (menu?.classList.contains("bsplus-custom-sidebar")) return;
|
||||
setupSidebarAccessibility();
|
||||
}
|
||||
|
||||
function setupSidebarAccessibility() {
|
||||
updateSidebarAccessibility();
|
||||
|
||||
@@ -579,6 +593,7 @@ function setupSidebarAccessibility() {
|
||||
if (!menu) return;
|
||||
|
||||
sidebarAccessibilityObserver?.disconnect();
|
||||
const throttledA11yUpdate = rafThrottle(scheduleSidebarAccessibilityUpdate);
|
||||
sidebarAccessibilityObserver = new MutationObserver((mutations) => {
|
||||
// Custom Svelte sidebar owns drill a11y — ignore its DOM (opening Goals/Folios
|
||||
// mutates a lot; re-running here used to help freeze the tab).
|
||||
@@ -603,7 +618,7 @@ function setupSidebarAccessibility() {
|
||||
return;
|
||||
}
|
||||
}
|
||||
scheduleSidebarAccessibilityUpdate();
|
||||
throttledA11yUpdate();
|
||||
});
|
||||
sidebarAccessibilityObserver.observe(menu, {
|
||||
subtree: true,
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
resolveLoadingTheme,
|
||||
type LoadingVariant,
|
||||
} from "./loadingVariants";
|
||||
import { isPerformanceMode } from "@/seqta/utils/performanceMode";
|
||||
|
||||
let stopCanvas: (() => void) | null = null;
|
||||
let unbindThemeGuard: (() => void) | null = null;
|
||||
@@ -320,7 +321,9 @@ export default function loading() {
|
||||
document.documentElement.append(host);
|
||||
|
||||
applyVariantTheme(host, shadow, variant);
|
||||
startCanvasForRoot(host, shadow, variant);
|
||||
if (!isPerformanceMode()) {
|
||||
startCanvasForRoot(host, shadow, variant);
|
||||
}
|
||||
|
||||
activeLoading = { host, shadow, variant };
|
||||
unbindThemeGuard = bindLoadingThemeGuard();
|
||||
|
||||
@@ -5,6 +5,7 @@ import { lightenAndPaleColor } from "./lightenAndPaleColor";
|
||||
import ColorLuminance from "./ColorLuminance";
|
||||
import { settingsState } from "@/seqta/utils/listeners/SettingsState";
|
||||
import { getAdaptiveColour } from "@/seqta/utils/adaptiveThemeColour";
|
||||
import { adaptiveThemeTransitionEnabled, transparencyEnabled } from "@/seqta/utils/performanceMode";
|
||||
import { getCustomThemeAdaptiveCssVariableBindings } from "@/seqta/ui/colors/customThemeAdaptiveBindings";
|
||||
|
||||
import { resolveExtensionAssetUrl } from "@/lib/extensionAssetUrl";
|
||||
@@ -126,7 +127,7 @@ function getRepresentativeRgbChannels(s: string): { r: number; g: number; b: num
|
||||
}
|
||||
|
||||
function applyColorsWith(selectedColor: string) {
|
||||
if (settingsState.transparencyEffects) {
|
||||
if (transparencyEnabled()) {
|
||||
document.documentElement.classList.add("transparencyEffects");
|
||||
}
|
||||
|
||||
@@ -253,7 +254,7 @@ export async function updateAllColors() {
|
||||
|
||||
const shouldAnimate =
|
||||
settingsState.adaptiveThemeColour &&
|
||||
(settingsState.adaptiveThemeColourTransition ?? true) &&
|
||||
adaptiveThemeTransitionEnabled() &&
|
||||
!!toHex;
|
||||
|
||||
const applyImmediate = () => {
|
||||
|
||||
@@ -15,6 +15,8 @@ import {
|
||||
applySidebarStyleClass,
|
||||
clearSidebarAppearance,
|
||||
} from "./sidebarStyles";
|
||||
import { isPerformanceMode } from "@/seqta/utils/performanceMode";
|
||||
import { applyMenuItemVisibility } from "@/seqta/utils/menuItemVisibility";
|
||||
|
||||
const ROOT_ID = "bsplus-sidebar-root";
|
||||
const MENU_CLASS = "bsplus-custom-sidebar";
|
||||
@@ -32,6 +34,8 @@ let earlyPrepareStarted = false;
|
||||
let catchupTimers: ReturnType<typeof setTimeout>[] = [];
|
||||
let nativeMenuListenerAttached = false;
|
||||
let lastMenuFingerprint = "";
|
||||
let catchupSessionStarted = false;
|
||||
let sidebarLookScheduled = false;
|
||||
|
||||
const settingsListeners: Array<{
|
||||
key: keyof SettingsState;
|
||||
@@ -68,10 +72,16 @@ function syncFromMenu(force = false) {
|
||||
* MutationObserver + scheduleSync cover ongoing changes; this only covers a short window.
|
||||
*/
|
||||
function startCatchupSync() {
|
||||
if (catchupSessionStarted) {
|
||||
syncFromMenu();
|
||||
return;
|
||||
}
|
||||
catchupSessionStarted = true;
|
||||
|
||||
for (const t of catchupTimers) clearTimeout(t);
|
||||
catchupTimers = [];
|
||||
// Immediate, then a few delayed passes (~1s total) instead of 50ms×60.
|
||||
const delays = [0, 200, 500, 1000];
|
||||
const delays = isPerformanceMode() ? [0, 400, 1000] : [0, 200, 500, 1000];
|
||||
for (const ms of delays) {
|
||||
catchupTimers.push(
|
||||
setTimeout(() => {
|
||||
@@ -84,16 +94,26 @@ function startCatchupSync() {
|
||||
}
|
||||
}
|
||||
|
||||
function scheduleSidebarLook() {
|
||||
if (!menuEl || sidebarLookScheduled) return;
|
||||
sidebarLookScheduled = true;
|
||||
requestAnimationFrame(() => {
|
||||
sidebarLookScheduled = false;
|
||||
if (menuEl) applySidebarLook(menuEl);
|
||||
});
|
||||
}
|
||||
|
||||
function onNativeMenuUpdated() {
|
||||
syncFromMenu(true);
|
||||
}
|
||||
|
||||
function scheduleSync() {
|
||||
if (syncTimer) clearTimeout(syncTimer);
|
||||
const delay = isPerformanceMode() ? 120 : 50;
|
||||
syncTimer = setTimeout(() => {
|
||||
syncTimer = null;
|
||||
syncFromMenu();
|
||||
}, 50);
|
||||
}, delay);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -325,11 +345,11 @@ export async function mountCustomSidebar(): Promise<boolean> {
|
||||
"sidebarWidth",
|
||||
"sidebarBlur",
|
||||
] as const) {
|
||||
registerSetting(key, () => applySidebarLook(menuEl));
|
||||
registerSetting(key, () => scheduleSidebarLook());
|
||||
}
|
||||
const resync = () => syncFromMenu(true);
|
||||
registerSetting("menuorder", resync);
|
||||
registerSetting("menuitems", resync);
|
||||
registerSetting("menuitems", () => applyMenuItemVisibility());
|
||||
|
||||
startCatchupSync();
|
||||
clearPendingClass();
|
||||
@@ -344,6 +364,7 @@ export function unmountCustomSidebar() {
|
||||
for (const t of catchupTimers) clearTimeout(t);
|
||||
catchupTimers = [];
|
||||
lastMenuFingerprint = "";
|
||||
catchupSessionStarted = false;
|
||||
|
||||
clearSettingListeners();
|
||||
|
||||
|
||||
@@ -12,9 +12,20 @@ export function getNativeMenuList(
|
||||
|
||||
function readLabelText(label: HTMLElement | null): string {
|
||||
if (!label) return "";
|
||||
const clone = label.cloneNode(true) as HTMLElement;
|
||||
clone.querySelectorAll("svg").forEach((svg) => svg.remove());
|
||||
return (clone.textContent ?? "").replace(/\s+/g, " ").trim();
|
||||
const cached = label.dataset.bsplusLabel;
|
||||
if (cached) return cached;
|
||||
|
||||
let text = "";
|
||||
for (const node of label.childNodes) {
|
||||
if (node.nodeType === Node.TEXT_NODE) {
|
||||
text += node.textContent ?? "";
|
||||
} else if (node instanceof HTMLElement && node.tagName !== "SVG") {
|
||||
text += node.textContent ?? "";
|
||||
}
|
||||
}
|
||||
const normalized = text.replace(/\s+/g, " ").trim();
|
||||
if (normalized) label.dataset.bsplusLabel = normalized;
|
||||
return normalized;
|
||||
}
|
||||
|
||||
function readIconHtml(label: HTMLElement | null): string {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { settingsState } from "@/seqta/utils/listeners/SettingsState";
|
||||
import { animationsEnabled } from "@/seqta/utils/performanceMode";
|
||||
import {
|
||||
findNativeMenuEntry,
|
||||
getNativeMenuList,
|
||||
@@ -45,11 +46,7 @@ function ensureActive(el: Element | null | undefined) {
|
||||
|
||||
function resetSidebarScroll() {
|
||||
const root = document.getElementById("bsplus-sidebar-root");
|
||||
if (!(root instanceof HTMLElement)) return;
|
||||
root.scrollTop = 0;
|
||||
requestAnimationFrame(() => {
|
||||
root.scrollTop = 0;
|
||||
});
|
||||
if (root instanceof HTMLElement) root.scrollTop = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -302,7 +299,7 @@ class SidebarState {
|
||||
this.drillStack = this.drillStack.slice(0, -1);
|
||||
resetSidebarScroll();
|
||||
|
||||
if (settingsState.animations !== true) return;
|
||||
if (!animationsEnabled()) return;
|
||||
|
||||
this.drillReturning = true;
|
||||
window.setTimeout(() => {
|
||||
@@ -376,7 +373,7 @@ class SidebarState {
|
||||
// SEQTA rewrites `.active` on the route change.
|
||||
if (this.isDrilling) {
|
||||
this.enterFrameKey = null;
|
||||
restoreCustomMenuActive();
|
||||
requestAnimationFrame(() => restoreCustomMenuActive());
|
||||
}
|
||||
|
||||
const native = findNativeMenuEntry(menu, item);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { settingsState } from "@/seqta/utils/listeners/SettingsState";
|
||||
import { isPerformanceMode } from "@/seqta/utils/performanceMode";
|
||||
|
||||
export type SidebarStyleId =
|
||||
| "classic"
|
||||
@@ -118,10 +119,9 @@ export function applySidebarStyleClass(
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply Look CSS variables + non-default density/indicator classes.
|
||||
* Safe to call with no menu (still sets width/blur/radius on `:root`).
|
||||
*/
|
||||
/** Safe to call with no menu (still sets width/blur/radius on `:root`). */
|
||||
let lastSidebarLookKey = "";
|
||||
|
||||
export function applySidebarLook(
|
||||
menu: HTMLElement | null | undefined = document.getElementById("menu"),
|
||||
) {
|
||||
@@ -129,7 +129,13 @@ export function applySidebarLook(
|
||||
const indicator = normalizeSidebarIndicator(settingsState.sidebarActiveIndicator);
|
||||
const width = normalizeSidebarWidth(settingsState.sidebarWidth);
|
||||
const radius = normalizeSidebarRadius(settingsState.sidebarCornerRadius);
|
||||
const blur = normalizeSidebarBlur(settingsState.sidebarBlur);
|
||||
const blur = isPerformanceMode()
|
||||
? 0
|
||||
: normalizeSidebarBlur(settingsState.sidebarBlur);
|
||||
|
||||
const lookKey = `${density}|${indicator}|${width}|${radius}|${blur}`;
|
||||
if (lookKey === lastSidebarLookKey) return;
|
||||
lastSidebarLookKey = lookKey;
|
||||
|
||||
const root = document.documentElement;
|
||||
root.style.setProperty("--bsplus-sidebar-width", `${SIDEBAR_WIDTH_PX[width]}px`);
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
import { mount, unmount } from "svelte";
|
||||
import { settingsState } from "@/seqta/utils/listeners/SettingsState";
|
||||
import { isSeqtaEngageExperience, isSeqtaLoginPage } from "@/seqta/utils/isSeqtaEngage";
|
||||
import { isPluginAllowedInPerformanceMode } from "@/seqta/utils/performanceMode";
|
||||
import { waitForSeqtaTitle } from "@/seqta/utils/waitForSeqtaShell";
|
||||
import TitleBar from "./TitleBar.svelte";
|
||||
import { titleBarState } from "./titleBarState.svelte";
|
||||
import { rafThrottle } from "@/seqta/utils/rafThrottle";
|
||||
import { isPerformanceMode } from "@/seqta/utils/performanceMode";
|
||||
|
||||
const ROOT_ID = "bsplus-title-root";
|
||||
const TITLE_CLASS = "bsplus-custom-title";
|
||||
@@ -30,6 +33,7 @@ function syncPageTitle() {
|
||||
}
|
||||
|
||||
function needsSearchChip() {
|
||||
if (!isPluginAllowedInPerformanceMode("global-search")) return false;
|
||||
const all = settingsState.getAll() as unknown as Record<string, unknown>;
|
||||
const plugin = all["plugin.global-search.settings"] as
|
||||
| { enabled?: boolean }
|
||||
@@ -54,9 +58,10 @@ export async function waitForCustomTitleBarReady(timeoutMs = 10000) {
|
||||
await mountCustomTitleBar();
|
||||
|
||||
const start = Date.now();
|
||||
const pollMs = isPerformanceMode() ? 100 : 50;
|
||||
while (Date.now() - start < timeoutMs) {
|
||||
if (isReady()) break;
|
||||
await new Promise((r) => setTimeout(r, 50));
|
||||
await new Promise((r) => setTimeout(r, pollMs));
|
||||
}
|
||||
document.documentElement.classList.remove(PENDING_CLASS);
|
||||
}
|
||||
@@ -64,7 +69,10 @@ export async function waitForCustomTitleBarReady(timeoutMs = 10000) {
|
||||
function observeHost(host: HTMLElement) {
|
||||
hostObserver?.disconnect();
|
||||
syncPageTitle();
|
||||
hostObserver = new MutationObserver(() => {
|
||||
const debouncedSync = rafThrottle(() => {
|
||||
syncPageTitle();
|
||||
});
|
||||
hostObserver = new MutationObserver((mutations) => {
|
||||
if (!document.getElementById(ROOT_ID)) {
|
||||
if (remountTimer) clearTimeout(remountTimer);
|
||||
remountTimer = setTimeout(() => {
|
||||
@@ -72,10 +80,21 @@ function observeHost(host: HTMLElement) {
|
||||
if (!settingsState.onoff || isSeqtaEngageExperience()) return;
|
||||
app = null;
|
||||
void mountCustomTitleBar();
|
||||
}, 50);
|
||||
}, isPerformanceMode() ? 120 : 50);
|
||||
return;
|
||||
}
|
||||
syncPageTitle();
|
||||
const titleChanged = mutations.some(
|
||||
(m) =>
|
||||
m.type === "characterData" ||
|
||||
(m.type === "childList" &&
|
||||
[...m.addedNodes, ...m.removedNodes].some(
|
||||
(n) =>
|
||||
n instanceof HTMLElement &&
|
||||
(n.matches?.('[data-testid="page-title"]') ||
|
||||
n.querySelector?.('[data-testid="page-title"]')),
|
||||
)),
|
||||
);
|
||||
if (titleChanged) debouncedSync();
|
||||
});
|
||||
hostObserver.observe(host, {
|
||||
childList: true,
|
||||
|
||||
@@ -3,23 +3,30 @@ import {
|
||||
closeExtensionPopup,
|
||||
SettingsClicked,
|
||||
} from "../Closers/closeExtensionPopup";
|
||||
import { SettingsResizer } from "@/seqta/ui/SettingsResizer";
|
||||
|
||||
let isSettingsRendered = false;
|
||||
let settingsLoadPromise: Promise<void> | null = null;
|
||||
let resizerAttached = false;
|
||||
|
||||
function extensionOutsideClickHandler(extensionPopup: HTMLElement) {
|
||||
return (event: MouseEvent) => {
|
||||
if (!SettingsClicked) return;
|
||||
|
||||
if (!(event.target as HTMLElement).closest("#AddedSettings")) {
|
||||
// Clicks inside the shadow tree retarget to the host — keep open.
|
||||
if (event.target == extensionPopup) return;
|
||||
changeSettingsClicked(closeExtensionPopup());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function ensureSettingsResizer() {
|
||||
if (resizerAttached) return;
|
||||
resizerAttached = true;
|
||||
void import("@/seqta/ui/SettingsResizer").then(({ SettingsResizer }) => {
|
||||
new SettingsResizer();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Mount the settings host on `document.body` so `position: fixed` covers the
|
||||
* viewport on both SEQTA Learn and SEQTA Engage (Engage often lacks `#container`
|
||||
@@ -34,8 +41,6 @@ export function addExtensionSettings() {
|
||||
|
||||
document.body.appendChild(extensionPopup);
|
||||
|
||||
new SettingsResizer();
|
||||
|
||||
const handler = extensionOutsideClickHandler(extensionPopup);
|
||||
document.body.addEventListener("click", handler, false);
|
||||
}
|
||||
@@ -43,25 +48,15 @@ export function addExtensionSettings() {
|
||||
async function loadSettingsUi(extensionPopup: HTMLElement): Promise<void> {
|
||||
if (isSettingsRendered) return;
|
||||
|
||||
ensureSettingsResizer();
|
||||
|
||||
const [{ default: renderSvelte }, { default: Settings }] = await Promise.all([
|
||||
import("@/interface/main"),
|
||||
import("@/interface/pages/settings.svelte"),
|
||||
]);
|
||||
|
||||
const shadow = extensionPopup.attachShadow({ mode: "open" });
|
||||
const mount = () => renderSvelte(Settings, shadow);
|
||||
|
||||
if ("requestIdleCallback" in window) {
|
||||
await new Promise<void>((resolve) => {
|
||||
requestIdleCallback(() => {
|
||||
mount();
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
} else {
|
||||
mount();
|
||||
}
|
||||
|
||||
renderSvelte(Settings, shadow);
|
||||
isSettingsRendered = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,35 +1,13 @@
|
||||
import { settingsState } from "@/seqta/utils/listeners/SettingsState";
|
||||
import { animate } from "motion";
|
||||
|
||||
import { settingsPopup } from "@/seqta/utils/settingsPopup";
|
||||
import { animateSettingsClose } from "@/seqta/utils/settingsPopupAnimation";
|
||||
|
||||
export let SettingsClicked = false;
|
||||
|
||||
export const closeExtensionPopup = (extensionPopup?: HTMLElement) => {
|
||||
if (!extensionPopup)
|
||||
extensionPopup = document.getElementById("ExtensionPopup")!;
|
||||
if (!extensionPopup) extensionPopup = document.getElementById("ExtensionPopup")!;
|
||||
|
||||
extensionPopup.classList.add("hide");
|
||||
if (settingsState.animations) {
|
||||
const panel = extensionPopup.shadowRoot?.querySelector<HTMLElement>(
|
||||
"[data-settings-panel]",
|
||||
);
|
||||
animate(1, 0, {
|
||||
onUpdate: (progress) => {
|
||||
extensionPopup.style.opacity = Math.max(0, progress).toString();
|
||||
},
|
||||
duration: 0.18,
|
||||
ease: "easeIn",
|
||||
});
|
||||
if (panel) {
|
||||
animate(
|
||||
panel,
|
||||
{ scale: [1, 0], opacity: [1, 0] },
|
||||
{ duration: 0.18, ease: "easeIn" },
|
||||
);
|
||||
}
|
||||
} else {
|
||||
extensionPopup.style.opacity = "0";
|
||||
if (extensionPopup) {
|
||||
animateSettingsClose(extensionPopup);
|
||||
}
|
||||
|
||||
settingsPopup.triggerClose();
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
import { settingsState } from "../listeners/SettingsState";
|
||||
import { fullMotionEffectsEnabled } from "@/seqta/utils/performanceMode";
|
||||
import {
|
||||
animatePopupClose,
|
||||
animatePopupOpen,
|
||||
} from "@/seqta/utils/popupAnimation";
|
||||
import { animate as motionAnimate, stagger } from "motion";
|
||||
|
||||
type AnimationTarget = string | Element | Element[] | NodeList | null;
|
||||
@@ -61,11 +66,15 @@ export async function closePopup() {
|
||||
return;
|
||||
}
|
||||
|
||||
await (motionAnimate as any)(
|
||||
[popup, background],
|
||||
{ opacity: [1, 0], scale: [1, 0.95] },
|
||||
{ duration: 0.25, easing: [0.22, 0.03, 0.26, 1] },
|
||||
);
|
||||
if (fullMotionEffectsEnabled()) {
|
||||
await (motionAnimate as any)(
|
||||
[popup, background],
|
||||
{ opacity: [1, 0], scale: [1, 0.95] },
|
||||
{ duration: 0.25, easing: [0.22, 0.03, 0.26, 1] },
|
||||
);
|
||||
} else {
|
||||
await animatePopupClose(background);
|
||||
}
|
||||
|
||||
background.remove();
|
||||
isClosing = false;
|
||||
@@ -160,27 +169,31 @@ export function openPopup({
|
||||
appContainer.append(background);
|
||||
|
||||
if (settingsState.animations) {
|
||||
(motionAnimate as any)(
|
||||
[container, background],
|
||||
{ scale: [0, 1] },
|
||||
{ type: "spring", stiffness: 220, damping: 18 },
|
||||
);
|
||||
|
||||
if (animateSelector) {
|
||||
const targets =
|
||||
typeof animateSelector === "string"
|
||||
? document.querySelectorAll(animateSelector)
|
||||
: animateSelector;
|
||||
|
||||
if (fullMotionEffectsEnabled()) {
|
||||
(motionAnimate as any)(
|
||||
targets!,
|
||||
{ opacity: [0, 1], y: [10, 0] },
|
||||
{
|
||||
delay: stagger(0.05, { startDelay: 0.1 }),
|
||||
duration: 0.5,
|
||||
easing: [0.22, 0.03, 0.26, 1],
|
||||
},
|
||||
[container, background],
|
||||
{ scale: [0, 1] },
|
||||
{ type: "spring", stiffness: 220, damping: 18 },
|
||||
);
|
||||
|
||||
if (animateSelector) {
|
||||
const targets =
|
||||
typeof animateSelector === "string"
|
||||
? document.querySelectorAll(animateSelector)
|
||||
: animateSelector;
|
||||
|
||||
(motionAnimate as any)(
|
||||
targets!,
|
||||
{ opacity: [0, 1], y: [10, 0] },
|
||||
{
|
||||
delay: stagger(0.05, { startDelay: 0.1 }),
|
||||
duration: 0.5,
|
||||
easing: [0.22, 0.03, 0.26, 1],
|
||||
},
|
||||
);
|
||||
}
|
||||
} else {
|
||||
animatePopupOpen(background);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
import { animate } from "motion";
|
||||
import { settingsState } from "@/seqta/utils/listeners/SettingsState";
|
||||
import { waitForElm } from "@/seqta/utils/waitForElm";
|
||||
|
||||
/**
|
||||
* Finds the SEQTA notifications dropdown panel (the list container next to the bell).
|
||||
*/
|
||||
function findNotificationPanel(): HTMLElement | null {
|
||||
const wrapper = document.querySelector(".connectedNotificationsWrapper");
|
||||
if (!wrapper) return null;
|
||||
@@ -24,56 +20,82 @@ function findNotificationPanel(): HTMLElement | null {
|
||||
}
|
||||
|
||||
function isPanelVisible(el: HTMLElement): boolean {
|
||||
return (
|
||||
el.getClientRects().length > 0 && getComputedStyle(el).visibility !== "hidden"
|
||||
);
|
||||
if (el.hidden || el.getAttribute("aria-hidden") === "true") return false;
|
||||
return el.offsetWidth > 0 || el.offsetHeight > 0;
|
||||
}
|
||||
|
||||
let lastVisible = false;
|
||||
/** Invalidates in-flight open animations when the panel closes or reopens. */
|
||||
let motionGeneration = 0;
|
||||
let observerStarted = false;
|
||||
let trackedPanel: HTMLElement | null = null;
|
||||
/** Ignore observer callbacks while we toggle animation classes. */
|
||||
let suppressSync = false;
|
||||
|
||||
function runOpenAnimation(panel: HTMLElement) {
|
||||
const myGen = ++motionGeneration;
|
||||
function setPanelOpen(panel: HTMLElement, open: boolean) {
|
||||
panel.classList.add("bsplus-notifications-panel");
|
||||
panel.style.removeProperty("opacity");
|
||||
panel.style.removeProperty("transform");
|
||||
|
||||
if (!settingsState.animations) {
|
||||
panel.style.opacity = "1";
|
||||
panel.style.transform = "scale(1)";
|
||||
panel.classList.toggle("bsplus-notifications-panel--open", open);
|
||||
return;
|
||||
}
|
||||
|
||||
panel.style.opacity = "0";
|
||||
panel.style.transform = "scale(0)";
|
||||
const isOpen = panel.classList.contains("bsplus-notifications-panel--open");
|
||||
if (open === isOpen) return;
|
||||
|
||||
requestAnimationFrame(() => {
|
||||
if (myGen !== motionGeneration) return;
|
||||
animate(0, 1, {
|
||||
onUpdate: (progress) => {
|
||||
panel.style.opacity = String(progress);
|
||||
panel.style.transform = `scale(${progress})`;
|
||||
},
|
||||
type: "spring",
|
||||
stiffness: 280,
|
||||
damping: 20,
|
||||
});
|
||||
});
|
||||
suppressSync = true;
|
||||
|
||||
if (open) {
|
||||
panel.classList.remove("bsplus-notifications-panel--open");
|
||||
void panel.offsetWidth;
|
||||
panel.classList.add("bsplus-notifications-panel--open");
|
||||
} else {
|
||||
panel.classList.remove("bsplus-notifications-panel--open");
|
||||
}
|
||||
|
||||
const release = () => {
|
||||
suppressSync = false;
|
||||
};
|
||||
panel.addEventListener("transitionend", release, { once: true });
|
||||
window.setTimeout(release, 280);
|
||||
}
|
||||
|
||||
function clearPanelMotionStyles(panel: HTMLElement) {
|
||||
motionGeneration++;
|
||||
panel.style.opacity = "";
|
||||
panel.style.transform = "";
|
||||
function syncPanelState() {
|
||||
if (suppressSync) return;
|
||||
|
||||
const panel = findNotificationPanel();
|
||||
|
||||
if (!panel) {
|
||||
if (lastVisible && trackedPanel?.isConnected) {
|
||||
setPanelOpen(trackedPanel, false);
|
||||
}
|
||||
lastVisible = false;
|
||||
trackedPanel = null;
|
||||
return;
|
||||
}
|
||||
|
||||
if (trackedPanel && trackedPanel !== panel) {
|
||||
setPanelOpen(trackedPanel, false);
|
||||
}
|
||||
trackedPanel = panel;
|
||||
|
||||
const visible = isPanelVisible(panel);
|
||||
if (visible === lastVisible) return;
|
||||
|
||||
setPanelOpen(panel, visible);
|
||||
lastVisible = visible;
|
||||
}
|
||||
|
||||
/**
|
||||
* Spring open / fade close for the native SEQTA notifications dropdown, matching ExtensionPopup.
|
||||
* CSS open/close for the native SEQTA notifications dropdown.
|
||||
*/
|
||||
export function attachNotificationsPanelAnimation() {
|
||||
void setupNotificationsPanelAnimation();
|
||||
}
|
||||
|
||||
async function setupNotificationsPanelAnimation() {
|
||||
if (observerStarted) return;
|
||||
|
||||
try {
|
||||
await waitForElm(".connectedNotificationsWrapper", true, 100, 60);
|
||||
} catch {
|
||||
@@ -83,46 +105,45 @@ async function setupNotificationsPanelAnimation() {
|
||||
const wrapper = document.querySelector(".connectedNotificationsWrapper");
|
||||
if (!wrapper) return;
|
||||
|
||||
const sync = () => {
|
||||
const panel = findNotificationPanel();
|
||||
// When SEQTA removes the dropdown from the DOM on close, we must reset
|
||||
// lastVisible — otherwise the next open still looks "already visible" and skips animation.
|
||||
if (!panel) {
|
||||
if (lastVisible) {
|
||||
lastVisible = false;
|
||||
motionGeneration++;
|
||||
}
|
||||
return;
|
||||
}
|
||||
observerStarted = true;
|
||||
|
||||
const visible = isPanelVisible(panel);
|
||||
if (visible === lastVisible) return;
|
||||
|
||||
if (visible) {
|
||||
runOpenAnimation(panel);
|
||||
} else {
|
||||
clearPanelMotionStyles(panel);
|
||||
}
|
||||
lastVisible = visible;
|
||||
let syncFrame = 0;
|
||||
const scheduleSync = () => {
|
||||
cancelAnimationFrame(syncFrame);
|
||||
syncFrame = requestAnimationFrame(() => {
|
||||
syncFrame = 0;
|
||||
syncPanelState();
|
||||
});
|
||||
};
|
||||
|
||||
const observer = new MutationObserver(() => {
|
||||
sync();
|
||||
const observer = new MutationObserver((mutations) => {
|
||||
if (
|
||||
suppressSync ||
|
||||
!mutations.some(
|
||||
(m) =>
|
||||
m.type === "childList" ||
|
||||
(m.type === "attributes" &&
|
||||
(m.attributeName === "hidden" || m.attributeName === "aria-hidden")),
|
||||
)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
scheduleSync();
|
||||
});
|
||||
observer.observe(wrapper, {
|
||||
subtree: true,
|
||||
childList: true,
|
||||
attributes: true,
|
||||
attributeFilter: ["style", "class"],
|
||||
attributeFilter: ["style", "class", "hidden", "aria-hidden"],
|
||||
});
|
||||
|
||||
document.addEventListener(
|
||||
wrapper.addEventListener(
|
||||
"click",
|
||||
() => {
|
||||
requestAnimationFrame(() => requestAnimationFrame(sync));
|
||||
requestAnimationFrame(() => requestAnimationFrame(scheduleSync));
|
||||
},
|
||||
true,
|
||||
);
|
||||
|
||||
sync();
|
||||
scheduleSync();
|
||||
}
|
||||
@@ -48,6 +48,8 @@ export function getDefaultSettingsState(): SettingsState {
|
||||
originalSelectedColor: "",
|
||||
DarkMode: true,
|
||||
animations: !isLowEndDevice,
|
||||
performanceMode: isLowEndDevice,
|
||||
performanceModePluginOverrides: {},
|
||||
assessmentsAverage: false,
|
||||
defaultPage: "home",
|
||||
homeUpcomingSubjectsMax: 5,
|
||||
|
||||
@@ -16,14 +16,14 @@ interface EventListener {
|
||||
unregister: () => void;
|
||||
}
|
||||
|
||||
|
||||
class EventManager {
|
||||
private static instance: EventManager;
|
||||
private listeners: Map<string, EventListener[]> = new Map();
|
||||
private mutationObservers: Map<Element, MutationObserver> = new Map();
|
||||
private pendingElements: Set<Element> = new Set();
|
||||
private firedOnceIds: Set<string> = new Set();
|
||||
private throttleTimeout: number = 5; // 5ms throttle
|
||||
private throttleTimer: number | undefined;
|
||||
private rafId = 0;
|
||||
private chunkSize: number = 50; // Process 50 elements per chunk
|
||||
|
||||
private constructor() {}
|
||||
@@ -146,26 +146,27 @@ class EventManager {
|
||||
}
|
||||
|
||||
private handleMutations(mutations: MutationRecord[]): void {
|
||||
mutations.forEach((mutation) => {
|
||||
if (mutation.type === "childList") {
|
||||
mutation.addedNodes.forEach((node) => {
|
||||
if (node.nodeType === Node.ELEMENT_NODE) {
|
||||
this.pendingElements.add(node as Element);
|
||||
}
|
||||
});
|
||||
for (const mutation of mutations) {
|
||||
if (mutation.type !== "childList") continue;
|
||||
for (const node of mutation.addedNodes) {
|
||||
if (node.nodeType === Node.ELEMENT_NODE) {
|
||||
this.pendingElements.add(node as Element);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
this.throttleCheckElements();
|
||||
if (this.pendingElements.size > 0) {
|
||||
this.schedulePendingCheck();
|
||||
}
|
||||
}
|
||||
|
||||
private throttleCheckElements(): void {
|
||||
if (this.throttleTimer) return;
|
||||
private schedulePendingCheck(): void {
|
||||
if (this.rafId) return;
|
||||
|
||||
this.throttleTimer = window.setTimeout(() => {
|
||||
this.processPendingElements();
|
||||
this.throttleTimer = undefined;
|
||||
}, this.throttleTimeout);
|
||||
this.rafId = requestAnimationFrame(() => {
|
||||
this.rafId = 0;
|
||||
void this.processPendingElements();
|
||||
});
|
||||
}
|
||||
|
||||
private async processPendingElements(): Promise<void> {
|
||||
@@ -189,7 +190,11 @@ class EventManager {
|
||||
}
|
||||
|
||||
private async checkElement(element: Element): Promise<void> {
|
||||
if (this.listeners.size === 0) return;
|
||||
|
||||
for (const [event, listeners] of this.listeners.entries()) {
|
||||
if (!listeners.length) continue;
|
||||
|
||||
for (const { id, options, callback } of listeners) {
|
||||
if (options.once && this.firedOnceIds.has(id)) continue;
|
||||
|
||||
|
||||
@@ -369,10 +369,16 @@ class StorageManager {
|
||||
};
|
||||
}
|
||||
|
||||
private notifyFrame = 0;
|
||||
|
||||
private notifySubscribers(): void {
|
||||
for (const subscriber of this.subscribers) {
|
||||
subscriber(this.data);
|
||||
}
|
||||
if (this.notifyFrame) return;
|
||||
this.notifyFrame = requestAnimationFrame(() => {
|
||||
this.notifyFrame = 0;
|
||||
for (const subscriber of this.subscribers) {
|
||||
subscriber(this.data);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,8 +6,9 @@ import { applySelectedFont } from "@/seqta/ui/fonts/Manager";
|
||||
import { renderShortcuts } from "@/seqta/utils/Render/renderShortcuts";
|
||||
import { FilterUpcomingAssessments } from "@/seqta/utils/FilterUpcomingAssessments";
|
||||
import { registerHomeUpcomingSettingsListeners } from "@/seqta/utils/Loaders/LoadHomePage";
|
||||
import { applyMenuItemVisibility } from "@/seqta/utils/menuItemVisibility";
|
||||
import { applyMenuItemVisibility, scheduleMenuItemVisibility } from "@/seqta/utils/menuItemVisibility";
|
||||
import { ChangeMenuItemPositions } from "@/seqta/utils/Openers/menuOrder";
|
||||
import { syncPerformanceModeEffects } from "@/seqta/utils/performanceMode";
|
||||
|
||||
import browser from "webextension-polyfill";
|
||||
import type { CustomShortcut } from "@/types/storage";
|
||||
@@ -36,6 +37,10 @@ export class StorageChangeHandler {
|
||||
"transparencyEffects",
|
||||
this.handleTransparencyEffectsChange.bind(this),
|
||||
);
|
||||
settingsState.register("performanceMode", () => syncPerformanceModeEffects());
|
||||
settingsState.register("performanceModePluginOverrides", () =>
|
||||
syncPerformanceModeEffects(),
|
||||
);
|
||||
settingsState.register(
|
||||
"subjectfilters",
|
||||
FilterUpcomingAssessments.bind(this),
|
||||
@@ -46,7 +51,7 @@ export class StorageChangeHandler {
|
||||
this.handleIconOnlySidebarChange.bind(this),
|
||||
);
|
||||
settingsState.register("selectedFont", () => applySelectedFont());
|
||||
settingsState.register("menuitems", () => applyMenuItemVisibility());
|
||||
settingsState.register("menuitems", () => scheduleMenuItemVisibility());
|
||||
settingsState.register("menuorder", (order) => {
|
||||
if (Array.isArray(order) && order.length > 0) {
|
||||
ChangeMenuItemPositions(order);
|
||||
@@ -85,7 +90,7 @@ export class StorageChangeHandler {
|
||||
}
|
||||
|
||||
private handleTransparencyEffectsChange(newValue: boolean) {
|
||||
if (newValue) {
|
||||
if (newValue && !settingsState.performanceMode) {
|
||||
document.documentElement.classList.add("transparencyEffects");
|
||||
} else {
|
||||
document.documentElement.classList.remove("transparencyEffects");
|
||||
|
||||
@@ -1,20 +1,29 @@
|
||||
import { settingsState } from "./listeners/SettingsState";
|
||||
import { rafThrottle } from "@/seqta/utils/rafThrottle";
|
||||
|
||||
const STYLE_ID = "bsplus-menuitem-visibility";
|
||||
let lastCss = "";
|
||||
|
||||
function buildMenuItemVisibilityCss(): string {
|
||||
let css = "";
|
||||
for (const [menuItem, config] of Object.entries(settingsState.menuitems ?? {})) {
|
||||
if (config && !config.toggle) {
|
||||
// Scope to the native SEQTA list only — the custom Svelte sidebar
|
||||
// filters visibility in JS and must not be forced hidden by this rule.
|
||||
css += `#menu > ul:not(#bsplus-sidebar-root) li[data-key=${menuItem}],#menu > ul:not(#bsplus-sidebar-root) section[data-key=${menuItem}]{display:var(--menuHidden) !important;}`;
|
||||
}
|
||||
}
|
||||
return css;
|
||||
}
|
||||
|
||||
/** Apply hide rules from `menuitems` (re-runnable after edit / storage sync). */
|
||||
export function applyMenuItemVisibility(): void {
|
||||
if (document.querySelector(".editmenuoption-container")) return;
|
||||
|
||||
try {
|
||||
let css = "";
|
||||
for (const [menuItem, config] of Object.entries(settingsState.menuitems ?? {})) {
|
||||
if (config && !config.toggle) {
|
||||
// Scope to the native SEQTA list only — the custom Svelte sidebar
|
||||
// filters visibility in JS and must not be forced hidden by this rule.
|
||||
css += `#menu > ul:not(#bsplus-sidebar-root) li[data-key=${menuItem}],#menu > ul:not(#bsplus-sidebar-root) section[data-key=${menuItem}]{display:var(--menuHidden) !important;transition:1s;}`;
|
||||
}
|
||||
}
|
||||
const css = buildMenuItemVisibilityCss();
|
||||
if (css === lastCss) return;
|
||||
lastCss = css;
|
||||
|
||||
let styleEl = document.getElementById(STYLE_ID) as HTMLStyleElement | null;
|
||||
if (!styleEl) {
|
||||
@@ -27,3 +36,6 @@ export function applyMenuItemVisibility(): void {
|
||||
console.error("[BetterSEQTA+] Failed to apply menu item visibility:", error);
|
||||
}
|
||||
}
|
||||
|
||||
/** Coalesce rapid menuitems updates (storage + sidebar edit). */
|
||||
export const scheduleMenuItemVisibility = rafThrottle(applyMenuItemVisibility);
|
||||
@@ -0,0 +1,85 @@
|
||||
import { settingsState } from "@/seqta/utils/listeners/SettingsState";
|
||||
import {
|
||||
adaptiveThemeTransitionEnabled,
|
||||
animationsEnabled,
|
||||
fullMotionEffectsEnabled,
|
||||
globalSearchIndexingEnabled,
|
||||
isPerformanceMode,
|
||||
isPluginAllowedInPerformanceMode,
|
||||
isPluginBlockedByPerformanceMode,
|
||||
isPluginForceEnabledInPerformanceMode,
|
||||
setPerformanceModePluginOverride,
|
||||
transparencyEnabled,
|
||||
} from "./performanceMode";
|
||||
|
||||
describe("performanceMode helpers", () => {
|
||||
beforeEach(() => {
|
||||
settingsState.performanceMode = false;
|
||||
settingsState.performanceModePluginOverrides = {};
|
||||
settingsState.animations = true;
|
||||
settingsState.transparencyEffects = false;
|
||||
settingsState.adaptiveThemeColourTransition = true;
|
||||
});
|
||||
|
||||
it("isPerformanceMode reflects settingsState", () => {
|
||||
expect(isPerformanceMode()).toBe(false);
|
||||
settingsState.performanceMode = true;
|
||||
expect(isPerformanceMode()).toBe(true);
|
||||
});
|
||||
|
||||
it("animationsEnabled stays on in performance mode when animations setting is on", () => {
|
||||
settingsState.animations = true;
|
||||
settingsState.performanceMode = true;
|
||||
expect(animationsEnabled()).toBe(true);
|
||||
});
|
||||
|
||||
it("fullMotionEffectsEnabled is false in performance mode", () => {
|
||||
settingsState.animations = true;
|
||||
settingsState.performanceMode = true;
|
||||
expect(fullMotionEffectsEnabled()).toBe(false);
|
||||
});
|
||||
|
||||
it("animationsEnabled respects animations setting when performance mode is off", () => {
|
||||
settingsState.animations = false;
|
||||
expect(animationsEnabled()).toBe(false);
|
||||
settingsState.animations = true;
|
||||
expect(animationsEnabled()).toBe(true);
|
||||
});
|
||||
|
||||
it("transparencyEnabled is false in performance mode", () => {
|
||||
settingsState.transparencyEffects = true;
|
||||
settingsState.performanceMode = true;
|
||||
expect(transparencyEnabled()).toBe(false);
|
||||
});
|
||||
|
||||
it("adaptiveThemeTransitionEnabled is false in performance mode", () => {
|
||||
settingsState.adaptiveThemeColourTransition = true;
|
||||
settingsState.performanceMode = true;
|
||||
expect(adaptiveThemeTransitionEnabled()).toBe(false);
|
||||
});
|
||||
|
||||
it("globalSearchIndexingEnabled blocks indexing when global search is paused", () => {
|
||||
expect(globalSearchIndexingEnabled(true)).toBe(true);
|
||||
settingsState.performanceMode = true;
|
||||
expect(globalSearchIndexingEnabled(true)).toBe(false);
|
||||
});
|
||||
|
||||
it("blocks heavy plugins unless force-enabled", () => {
|
||||
settingsState.performanceMode = true;
|
||||
expect(isPluginBlockedByPerformanceMode("global-search")).toBe(true);
|
||||
expect(isPluginAllowedInPerformanceMode("global-search")).toBe(false);
|
||||
|
||||
setPerformanceModePluginOverride("global-search", true);
|
||||
expect(isPluginForceEnabledInPerformanceMode("global-search")).toBe(true);
|
||||
expect(isPluginBlockedByPerformanceMode("global-search")).toBe(false);
|
||||
expect(isPluginAllowedInPerformanceMode("global-search")).toBe(true);
|
||||
|
||||
setPerformanceModePluginOverride("global-search", false);
|
||||
expect(isPluginBlockedByPerformanceMode("global-search")).toBe(true);
|
||||
});
|
||||
|
||||
it("does not block plugins when performance mode is off", () => {
|
||||
settingsState.performanceMode = false;
|
||||
expect(isPluginBlockedByPerformanceMode("assessments-average")).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,149 @@
|
||||
import { settingsState } from "@/seqta/utils/listeners/SettingsState";
|
||||
import { removeAnimatedBackgroundLayers } from "@/plugins/built-in/animatedBackground/backgroundLayers";
|
||||
import { applySidebarLook } from "@/seqta/ui/sidebar/sidebarStyles";
|
||||
import {
|
||||
PERFORMANCE_HEAVY_PLUGIN_IDS,
|
||||
PERFORMANCE_HEAVY_PLUGINS,
|
||||
} from "@/seqta/utils/performanceModeConfig";
|
||||
|
||||
export const PERFORMANCE_MODE_CLASS = "performanceMode";
|
||||
export const SIMPLE_UI_CLASS = "performanceModeSimpleUi";
|
||||
|
||||
/** Master toggle — reduces visual effects and background work for smoother SEQTA. */
|
||||
export function isPerformanceMode(): boolean {
|
||||
return settingsState.performanceMode === true;
|
||||
}
|
||||
|
||||
export function isSimpleAnalyticsUi(): boolean {
|
||||
return (
|
||||
isPerformanceMode() &&
|
||||
!isPluginForceEnabledInPerformanceMode("grade-analytics")
|
||||
);
|
||||
}
|
||||
|
||||
export function isPluginForceEnabledInPerformanceMode(pluginId: string): boolean {
|
||||
return settingsState.performanceModePluginOverrides?.[pluginId] === true;
|
||||
}
|
||||
|
||||
export function isPluginBlockedByPerformanceMode(pluginId: string): boolean {
|
||||
if (!isPerformanceMode()) return false;
|
||||
if (isPluginForceEnabledInPerformanceMode(pluginId)) return false;
|
||||
return PERFORMANCE_HEAVY_PLUGIN_IDS.has(pluginId);
|
||||
}
|
||||
|
||||
export function isPluginAllowedInPerformanceMode(pluginId: string): boolean {
|
||||
return !isPluginBlockedByPerformanceMode(pluginId);
|
||||
}
|
||||
|
||||
export function setPerformanceModePluginOverride(
|
||||
pluginId: string,
|
||||
forceEnable: boolean,
|
||||
): void {
|
||||
const current = { ...(settingsState.performanceModePluginOverrides ?? {}) };
|
||||
if (forceEnable) {
|
||||
current[pluginId] = true;
|
||||
} else {
|
||||
delete current[pluginId];
|
||||
}
|
||||
settingsState.performanceModePluginOverrides = current;
|
||||
}
|
||||
|
||||
export function animationsEnabled(): boolean {
|
||||
return settingsState.animations !== false;
|
||||
}
|
||||
|
||||
/** Expensive full-page effects (view transitions, clip-path theme morphs). */
|
||||
export function fullMotionEffectsEnabled(): boolean {
|
||||
return animationsEnabled() && !isPerformanceMode();
|
||||
}
|
||||
|
||||
export function transparencyEnabled(): boolean {
|
||||
return !isPerformanceMode() && settingsState.transparencyEffects === true;
|
||||
}
|
||||
|
||||
export function adaptiveThemeTransitionEnabled(): boolean {
|
||||
return (
|
||||
!isPerformanceMode() &&
|
||||
(settingsState.adaptiveThemeColourTransition ?? true)
|
||||
);
|
||||
}
|
||||
|
||||
export function globalSearchIndexingEnabled(settingEnabled: boolean): boolean {
|
||||
return isPluginAllowedInPerformanceMode("global-search") && settingEnabled;
|
||||
}
|
||||
|
||||
export function applyPerformanceModeClass(): void {
|
||||
const on = isPerformanceMode();
|
||||
document.documentElement.classList.toggle(PERFORMANCE_MODE_CLASS, on);
|
||||
document.documentElement.classList.toggle(SIMPLE_UI_CLASS, isPerformanceMode());
|
||||
}
|
||||
|
||||
export function applyPerformanceModeTransparency(): void {
|
||||
if (transparencyEnabled()) {
|
||||
document.documentElement.classList.add("transparencyEffects");
|
||||
} else {
|
||||
document.documentElement.classList.remove("transparencyEffects");
|
||||
}
|
||||
}
|
||||
|
||||
export function applyPerformanceModeSidebarLook(): void {
|
||||
applySidebarLook(document.getElementById("menu"));
|
||||
}
|
||||
|
||||
async function syncPerformanceModePlugins(): Promise<void> {
|
||||
try {
|
||||
const { pluginManager } = await import("@/plugins");
|
||||
const pluginIds = new Set<string>([
|
||||
...PERFORMANCE_HEAVY_PLUGINS.map((p) => p.id),
|
||||
...Object.keys(settingsState.performanceModePluginOverrides ?? {}),
|
||||
]);
|
||||
|
||||
for (const pluginId of pluginIds) {
|
||||
if (isPluginAllowedInPerformanceMode(pluginId)) {
|
||||
await pluginManager.startPlugin(pluginId);
|
||||
} else {
|
||||
await pluginManager.stopPlugin(pluginId);
|
||||
}
|
||||
}
|
||||
|
||||
if (isPerformanceMode()) {
|
||||
removeAnimatedBackgroundLayers();
|
||||
window.dispatchEvent(new CustomEvent("betterseqta-background-music-stop"));
|
||||
} else {
|
||||
const browser = (await import("webextension-polyfill")).default;
|
||||
const searchSettings = await browser.storage.local.get(
|
||||
"plugin.global-search.settings",
|
||||
);
|
||||
const gs = searchSettings["plugin.global-search.settings"] as
|
||||
| { runIndexingOnLoad?: boolean }
|
||||
| undefined;
|
||||
if (gs?.runIndexingOnLoad && isPluginAllowedInPerformanceMode("global-search")) {
|
||||
const { runIndexing } = await import(
|
||||
"@/plugins/built-in/globalSearch/src/indexing/indexer"
|
||||
);
|
||||
if (typeof requestIdleCallback === "function") {
|
||||
requestIdleCallback(() => void runIndexing(), { timeout: 5000 });
|
||||
} else {
|
||||
setTimeout(() => void runIndexing(), 2000);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn("[BetterSEQTA+] Performance mode plugin sync failed:", error);
|
||||
}
|
||||
}
|
||||
|
||||
/** Apply DOM + plugin side effects when performance mode changes or on boot. */
|
||||
export function syncPerformanceModeEffects(): void {
|
||||
applyPerformanceModeClass();
|
||||
applyPerformanceModeTransparency();
|
||||
applyPerformanceModeSidebarLook();
|
||||
|
||||
if (isPerformanceMode()) {
|
||||
removeAnimatedBackgroundLayers();
|
||||
}
|
||||
|
||||
void syncPerformanceModePlugins();
|
||||
}
|
||||
|
||||
export { PERFORMANCE_HEAVY_PLUGINS };
|
||||
@@ -0,0 +1,53 @@
|
||||
/** Heavy plugins paused while Performance Mode is on (unless force-enabled). */
|
||||
export type PerformanceHeavyPlugin = {
|
||||
id: string;
|
||||
name: string;
|
||||
description: string;
|
||||
};
|
||||
|
||||
export const PERFORMANCE_HEAVY_PLUGINS: readonly PerformanceHeavyPlugin[] = [
|
||||
{
|
||||
id: "global-search",
|
||||
name: "Global Search",
|
||||
description: "Background indexing, vector search, and fetch capture",
|
||||
},
|
||||
{
|
||||
id: "assessments-average",
|
||||
name: "Assessment Averages",
|
||||
description: "Weight extraction, overrides, and live grade calculations",
|
||||
},
|
||||
{
|
||||
id: "grade-analytics",
|
||||
name: "Grade Analytics",
|
||||
description: "Chart rendering and analytics sync",
|
||||
},
|
||||
{
|
||||
id: "notificationCollector",
|
||||
name: "Notification Collector",
|
||||
description: "Background notification polling",
|
||||
},
|
||||
{
|
||||
id: "enhanced-navigation",
|
||||
name: "Enhanced Navigation",
|
||||
description: "Extra scroll and navigation observers",
|
||||
},
|
||||
{
|
||||
id: "animated-background",
|
||||
name: "Animated Background",
|
||||
description: "Continuous CSS background animation layers",
|
||||
},
|
||||
{
|
||||
id: "background-music",
|
||||
name: "Background Music",
|
||||
description: "Audio playback and gesture unlock listeners",
|
||||
},
|
||||
{
|
||||
id: "messageFolders",
|
||||
name: "Message Folders",
|
||||
description: "Message DOM tagging and folder indexing",
|
||||
},
|
||||
] as const;
|
||||
|
||||
export const PERFORMANCE_HEAVY_PLUGIN_IDS = new Set(
|
||||
PERFORMANCE_HEAVY_PLUGINS.map((p) => p.id),
|
||||
);
|
||||
@@ -0,0 +1,54 @@
|
||||
import { settingsState } from "@/seqta/utils/listeners/SettingsState";
|
||||
import { fullMotionEffectsEnabled } from "@/seqta/utils/performanceMode";
|
||||
|
||||
const BACKDROP_CLASS = "bsplus-popup-css-animate";
|
||||
const OPEN_CLASS = "bsplus-popup-css-animate--open";
|
||||
const LITE_BACKDROP_CLASS = "bsplus-popup-backdrop--lite";
|
||||
|
||||
const CLOSE_FALLBACK_MS = 240;
|
||||
|
||||
/** CSS fade/scale path — used when animations are on but Motion springs are off (performance mode). */
|
||||
export function useCssPopupAnimation(): boolean {
|
||||
return settingsState.animations !== false && !fullMotionEffectsEnabled();
|
||||
}
|
||||
|
||||
export function preparePopupCssAnimation(background: HTMLElement): void {
|
||||
background.classList.add(BACKDROP_CLASS, LITE_BACKDROP_CLASS);
|
||||
}
|
||||
|
||||
export function animatePopupOpen(background: HTMLElement): void {
|
||||
if (!useCssPopupAnimation()) return;
|
||||
|
||||
preparePopupCssAnimation(background);
|
||||
background.classList.remove(OPEN_CLASS);
|
||||
|
||||
requestAnimationFrame(() => {
|
||||
void background.offsetWidth;
|
||||
background.classList.add(OPEN_CLASS);
|
||||
});
|
||||
}
|
||||
|
||||
export function animatePopupClose(background: HTMLElement): Promise<void> {
|
||||
if (!useCssPopupAnimation()) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
return new Promise((resolve) => {
|
||||
let settled = false;
|
||||
const finish = () => {
|
||||
if (settled) return;
|
||||
settled = true;
|
||||
background.removeEventListener("transitionend", onEnd);
|
||||
resolve();
|
||||
};
|
||||
|
||||
const onEnd = (event: TransitionEvent) => {
|
||||
if (event.target !== background || event.propertyName !== "opacity") return;
|
||||
finish();
|
||||
};
|
||||
|
||||
background.addEventListener("transitionend", onEnd);
|
||||
background.classList.remove(OPEN_CLASS);
|
||||
window.setTimeout(finish, CLOSE_FALLBACK_MS);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
/** Coalesce rapid callbacks to at most once per animation frame. */
|
||||
export function rafThrottle<T extends (...args: never[]) => void>(fn: T): T {
|
||||
let scheduled = false;
|
||||
let lastArgs: Parameters<T> | null = null;
|
||||
|
||||
return ((...args: Parameters<T>) => {
|
||||
lastArgs = args;
|
||||
if (scheduled) return;
|
||||
scheduled = true;
|
||||
requestAnimationFrame(() => {
|
||||
scheduled = false;
|
||||
if (lastArgs) fn(...lastArgs);
|
||||
lastArgs = null;
|
||||
});
|
||||
}) as T;
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
import { settingsState } from "@/seqta/utils/listeners/SettingsState";
|
||||
|
||||
const HOST_OPEN_CLASS = "bsplus-settings-host--open";
|
||||
const HOST_CLOSING_CLASS = "bsplus-settings-host--closing";
|
||||
const PANEL_OPEN_CLASS = "bsplus-settings-panel--open";
|
||||
|
||||
function settingsPanel(host: HTMLElement): HTMLElement | null {
|
||||
return host.shadowRoot?.querySelector<HTMLElement>("[data-settings-panel]") ?? null;
|
||||
}
|
||||
|
||||
export function animateSettingsOpen(host: HTMLElement): void {
|
||||
host.style.transform = "none";
|
||||
host.classList.remove(HOST_CLOSING_CLASS, "hide");
|
||||
|
||||
const panel = settingsPanel(host);
|
||||
if (!settingsState.animations) {
|
||||
host.style.opacity = "1";
|
||||
host.classList.add(HOST_OPEN_CLASS);
|
||||
panel?.classList.add(PANEL_OPEN_CLASS);
|
||||
return;
|
||||
}
|
||||
|
||||
host.style.opacity = "";
|
||||
host.classList.remove(HOST_OPEN_CLASS);
|
||||
panel?.classList.remove(PANEL_OPEN_CLASS);
|
||||
|
||||
requestAnimationFrame(() => {
|
||||
host.classList.add(HOST_OPEN_CLASS);
|
||||
panel?.classList.add(PANEL_OPEN_CLASS);
|
||||
});
|
||||
}
|
||||
|
||||
export function animateSettingsClose(host: HTMLElement): void {
|
||||
host.classList.add("hide");
|
||||
const panel = settingsPanel(host);
|
||||
|
||||
if (!settingsState.animations) {
|
||||
host.classList.remove(HOST_OPEN_CLASS, HOST_CLOSING_CLASS);
|
||||
panel?.classList.remove(PANEL_OPEN_CLASS);
|
||||
host.style.opacity = "0";
|
||||
return;
|
||||
}
|
||||
|
||||
host.classList.remove(HOST_OPEN_CLASS);
|
||||
host.classList.add(HOST_CLOSING_CLASS);
|
||||
panel?.classList.remove(PANEL_OPEN_CLASS);
|
||||
|
||||
const durationMs = document.documentElement.classList.contains("performanceMode")
|
||||
? 160
|
||||
: 200;
|
||||
|
||||
window.setTimeout(() => {
|
||||
host.classList.remove(HOST_CLOSING_CLASS);
|
||||
host.style.opacity = "0";
|
||||
}, durationMs);
|
||||
}
|
||||
|
||||
let prefetchStarted = false;
|
||||
|
||||
/** Warm settings chunks during idle time so the first open feels instant. */
|
||||
export function prefetchSettingsShell(): void {
|
||||
if (prefetchStarted) return;
|
||||
prefetchStarted = true;
|
||||
const run = () => {
|
||||
void import("@/interface/main");
|
||||
void import("@/interface/pages/settings/SettingsBody.svelte");
|
||||
void import("@/interface/pages/settings/sections/generalOptions.svelte");
|
||||
};
|
||||
if (typeof requestIdleCallback === "function") {
|
||||
requestIdleCallback(run, { timeout: 8000 });
|
||||
} else {
|
||||
window.setTimeout(run, 3000);
|
||||
}
|
||||
}
|
||||
@@ -3,19 +3,22 @@ import {
|
||||
closeExtensionPopup,
|
||||
SettingsClicked,
|
||||
} from "./Closers/closeExtensionPopup";
|
||||
import { animate } from "motion";
|
||||
import { settingsState } from "./listeners/SettingsState";
|
||||
import {
|
||||
animateSettingsOpen,
|
||||
prefetchSettingsShell,
|
||||
} from "./settingsPopupAnimation";
|
||||
import { renderSettingsIfNeeded } from "./Adders/AddExtensionSettings";
|
||||
import { delay } from "./delay";
|
||||
|
||||
export function setupSettingsButton() {
|
||||
const AddedSettings = document.getElementById("AddedSettings");
|
||||
if (!AddedSettings) return;
|
||||
|
||||
// Avoid stacking duplicate listeners if Engage remounts the toolbar.
|
||||
if (AddedSettings.dataset.bsplusSettingsBound === "1") return;
|
||||
AddedSettings.dataset.bsplusSettingsBound = "1";
|
||||
|
||||
prefetchSettingsShell();
|
||||
|
||||
AddedSettings.addEventListener("click", async () => {
|
||||
if (SettingsClicked) {
|
||||
closeExtensionPopup();
|
||||
@@ -28,7 +31,6 @@ export function setupSettingsButton() {
|
||||
export async function openSettingsPopup(): Promise<void> {
|
||||
if (SettingsClicked && document.getElementById("ExtensionPopup")) return;
|
||||
|
||||
// Re-query each time — Engage SPA navigations can recreate the host.
|
||||
let extensionPopup = document.getElementById("ExtensionPopup");
|
||||
if (!extensionPopup) {
|
||||
const { addExtensionSettings } = await import("./Adders/AddExtensionSettings");
|
||||
@@ -38,36 +40,6 @@ export async function openSettingsPopup(): Promise<void> {
|
||||
if (!extensionPopup) return;
|
||||
|
||||
await renderSettingsIfNeeded();
|
||||
await delay(30);
|
||||
|
||||
extensionPopup.style.transform = "none";
|
||||
const panel = extensionPopup.shadowRoot?.querySelector<HTMLElement>(
|
||||
"[data-settings-panel]",
|
||||
);
|
||||
if (settingsState.animations) {
|
||||
animate(0, 1, {
|
||||
onUpdate: (progress) => {
|
||||
extensionPopup.style.opacity = progress.toString();
|
||||
},
|
||||
type: "spring",
|
||||
stiffness: 280,
|
||||
damping: 20,
|
||||
});
|
||||
if (panel) {
|
||||
animate(
|
||||
panel,
|
||||
{ scale: [0, 1], opacity: [0, 1] },
|
||||
{ type: "spring", stiffness: 330, damping: 30 },
|
||||
);
|
||||
}
|
||||
} else {
|
||||
extensionPopup.style.opacity = "1";
|
||||
extensionPopup.style.transition = "opacity 0s linear";
|
||||
if (panel) {
|
||||
panel.style.scale = "1";
|
||||
panel.style.opacity = "1";
|
||||
}
|
||||
}
|
||||
extensionPopup.classList.remove("hide");
|
||||
animateSettingsOpen(extensionPopup);
|
||||
changeSettingsClicked(true);
|
||||
}
|
||||
@@ -114,9 +114,8 @@ async function observeEngageMenuIcons() {
|
||||
engageMenuIconObserver = new MutationObserver(() => {
|
||||
scheduleEngageMenuIconPass();
|
||||
});
|
||||
engageMenuIconObserver.observe(menu, {
|
||||
engageMenuIconObserver.observe(menuList, {
|
||||
childList: true,
|
||||
subtree: true,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -47,6 +47,10 @@ export interface SettingsState {
|
||||
themeOfTheMonthDisabled?: boolean;
|
||||
timeFormat?: string;
|
||||
animations: boolean;
|
||||
/** Reduces animations, blur, background work, and indexing for smoother SEQTA. */
|
||||
performanceMode?: boolean;
|
||||
/** Per-plugin force-enable while Performance Mode is active (`pluginId` → true). */
|
||||
performanceModePluginOverrides?: Record<string, boolean>;
|
||||
defaultPage: string;
|
||||
/** Max subjects with upcoming assessments on the home page; 0 = no limit. */
|
||||
homeUpcomingSubjectsMax?: number;
|
||||
|
||||
Reference in new issue
Block a user