Skip to content

Commit 9af26ab

Browse files
committed
nice
1 parent 4c327fd commit 9af26ab

6 files changed

Lines changed: 264 additions & 43 deletions

File tree

‎src/app.css‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,35 @@ code, pre {
9999
.no-transition * {
100100
transition: none !important;
101101
}
102+
103+
/* Custom Scrollbar Styles - consistent across all browsers/OS */
104+
* {
105+
scrollbar-width: thin;
106+
scrollbar-color: var(--border) var(--bg-code);
107+
}
108+
109+
/* Webkit browsers (Chrome, Safari, Edge) */
110+
::-webkit-scrollbar {
111+
width: 8px;
112+
height: 8px;
113+
}
114+
115+
::-webkit-scrollbar-track {
116+
background: var(--bg-code);
117+
border-radius: var(--radius-sm);
118+
}
119+
120+
::-webkit-scrollbar-thumb {
121+
background: var(--border);
122+
border-radius: var(--radius-sm);
123+
border: 2px solid var(--bg-code);
124+
}
125+
126+
::-webkit-scrollbar-thumb:hover {
127+
background: var(--text-muted);
128+
}
129+
130+
/* Scrollbar corner (where horizontal and vertical meet) */
131+
::-webkit-scrollbar-corner {
132+
background: var(--bg-code);
133+
}

‎src/lib/components/steps/ExploitStep.svelte‎

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import { whisperToCaptions, extractExploitKeyframeTriggers, getAudioDuration, getAllWords, type WhisperOutput, type WhisperWord } from '$lib/utils/whisper-parser';
1010
import { comprehension, loadWhisperData } from '$lib/stores/comprehension.svelte';
1111
import { onMount, tick } from 'svelte';
12-
import { getExploitScrollTarget, scrollToTarget, resetScrollTracking, type ScrollTarget } from '$lib/utils/autoScroll';
12+
import { getExploitScrollTarget, scrollToTarget, resetScrollTracking } from '$lib/utils/autoScroll';
1313
1414
// Loading state for lazy loading
1515
let isLoading = $state(true);
@@ -293,11 +293,10 @@
293293
// Derive animation state from currentTime - build keyframes inline to ensure reactivity
294294
let animState = $derived(getAnimationState(exploitTimeline.currentTime, buildKeyframes(triggers), INITIAL_STATE));
295295
296-
// Derive the scroll target from animation state
296+
// Derive the scroll target from current time and triggers (narration-aware)
297297
let scrollTarget = $derived(getExploitScrollTarget({
298-
phase: animState.activeStage?.toString() ?? '',
299-
payloadSent: animState.packetVisible,
300-
serverCompromised: animState.serverStatusClass === 'danger'
298+
currentTime: exploitTimeline.currentTime,
299+
triggers: triggers
301300
}));
302301
303302
// Auto-scroll on mobile when animation phase changes
@@ -1042,4 +1041,42 @@
10421041
margin-bottom: 1rem;
10431042
font-size: 0.875rem;
10441043
}
1044+
1045+
/* Mobile: Constrain vulnerable code section to prevent overflow */
1046+
@media (max-width: 600px) {
1047+
.vulnerable-code-section {
1048+
margin-top: 1rem;
1049+
overflow: hidden;
1050+
}
1051+
1052+
.code-card {
1053+
border-radius: var(--radius-sm);
1054+
}
1055+
1056+
.code-header {
1057+
padding: 0.5rem 0.75rem;
1058+
font-size: 0.85rem;
1059+
}
1060+
1061+
.code-content {
1062+
padding: 0.5rem;
1063+
font-size: 0.55rem;
1064+
line-height: 1.4;
1065+
overflow-x: auto;
1066+
white-space: pre;
1067+
max-width: 100%;
1068+
}
1069+
}
1070+
1071+
@media (max-width: 380px) {
1072+
.code-content {
1073+
font-size: 0.45rem;
1074+
padding: 0.4rem;
1075+
}
1076+
1077+
.code-header {
1078+
padding: 0.4rem 0.6rem;
1079+
font-size: 0.65rem;
1080+
}
1081+
}
10451082
</style>

‎src/lib/components/steps/FixStep.svelte‎

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import { whisperToCaptions, extractFixKeyframeTriggers, getAudioDuration, getAllWords, type WhisperOutput, type WhisperWord } from '$lib/utils/whisper-parser';
1010
import { comprehension, loadWhisperData } from '$lib/stores/comprehension.svelte';
1111
import { onMount, tick } from 'svelte';
12-
import { scrollToTarget, resetScrollTracking, type ScrollTarget } from '$lib/utils/autoScroll';
12+
import { getFixScrollTarget, scrollToTarget, resetScrollTracking } from '$lib/utils/autoScroll';
1313
1414
// Loading state for lazy loading
1515
let isLoading = $state(true);
@@ -183,18 +183,15 @@
183183
// Derive animation state from currentTime - build keyframes inline to ensure reactivity
184184
let animState = $derived(getAnimationState(fixTimeline.currentTime, buildKeyframes(triggers), INITIAL_STATE));
185185
186-
// Derive the scroll target from animation state
187-
// FixStep doesn't have network animation, so we keep it simple
188-
let scrollTarget = $derived<ScrollTarget>(() => {
189-
if (animState.phase === 'remediation') {
190-
return 'explanation'; // Scroll to remediation cards
191-
}
192-
return 'browser'; // Default to code diff area
193-
});
186+
// Derive the scroll target from current time and triggers (narration-aware)
187+
let scrollTarget = $derived(getFixScrollTarget({
188+
currentTime: fixTimeline.currentTime,
189+
triggers: triggers
190+
}));
194191
195192
// Auto-scroll on mobile when animation phase changes
196193
$effect(() => {
197-
const target = scrollTarget();
194+
const target = scrollTarget;
198195
if (!fixTimeline.playing || !animationContainer) return;
199196
scrollToTarget(animationContainer, target, { minIntervalMs: 1500 });
200197
});

‎src/lib/components/steps/LessonsStep.svelte‎

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import { whisperToCaptions, extractLessonsKeyframeTriggers, getAudioDuration, getAllWords, type WhisperOutput, type WhisperWord } from '$lib/utils/whisper-parser';
99
import { comprehension, loadWhisperData } from '$lib/stores/comprehension.svelte';
1010
import { onMount, tick } from 'svelte';
11-
import { scrollToTarget, resetScrollTracking, type ScrollTarget } from '$lib/utils/autoScroll';
11+
import { getLessonsScrollTarget, scrollToTarget, resetScrollTracking } from '$lib/utils/autoScroll';
1212
1313
// Loading state for lazy loading
1414
let isLoading = $state(true);
@@ -145,18 +145,15 @@
145145
// Derive animation state from currentTime - build keyframes inline to ensure reactivity
146146
let animState = $derived(getAnimationState(lessonsTimeline.currentTime, buildKeyframes(triggers), INITIAL_STATE));
147147
148-
// Derive the scroll target from animation state
149-
// LessonsStep scrolls to cards as they become active, then to resources section
150-
let scrollTarget = $derived<ScrollTarget>(() => {
151-
if (animState.showResources) {
152-
return 'explanation'; // Scroll to resources at bottom
153-
}
154-
return 'browser'; // Default to lessons cards area
155-
});
148+
// Derive the scroll target from current time and triggers (narration-aware)
149+
let scrollTarget = $derived(getLessonsScrollTarget({
150+
currentTime: lessonsTimeline.currentTime,
151+
triggers: triggers
152+
}));
156153
157154
// Auto-scroll on mobile when animation phase changes
158155
$effect(() => {
159-
const target = scrollTarget();
156+
const target = scrollTarget;
160157
if (!lessonsTimeline.playing || !animationContainer) return;
161158
scrollToTarget(animationContainer, target, { minIntervalMs: 1500 });
162159
});

‎src/lib/components/steps/RSCStep.svelte‎

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,29 @@
794794
}
795795
}
796796
797+
/* Comparison summary column layout at 720px */
798+
@media (max-width: 720px) {
799+
.comparison-summary {
800+
gap: 0.75rem;
801+
flex-direction: column;
802+
align-items: center;
803+
justify-content: center;
804+
}
805+
.comparison-card {
806+
width: 100%;
807+
max-width: 320px;
808+
padding: 0.75rem;
809+
margin: 0 auto;
810+
}
811+
.metric-value { font-size: 1.25rem; }
812+
.comparison-vs {
813+
font-size: 1rem;
814+
text-align: center;
815+
padding: 0.25rem 0;
816+
width: 100%;
817+
}
818+
}
819+
797820
@media (max-width: 600px) {
798821
.animation-container {
799822
padding: var(--animation-container-padding);
@@ -841,14 +864,6 @@
841864
}
842865
.nonblocking-icon { font-size: 1rem; }
843866
844-
.comparison-summary { gap: 0.5rem; }
845-
.comparison-card {
846-
width: 100%;
847-
padding: 0.75rem;
848-
}
849-
.metric-value { font-size: 1.25rem; }
850-
.comparison-vs { font-size: 1rem; }
851-
852867
.explanation-panel { padding: 1rem; }
853868
.explanation-title { font-size: 0.9rem; }
854869
.explanation-content { font-size: 0.8rem; }

‎src/lib/utils/autoScroll.ts‎

Lines changed: 153 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -145,25 +145,168 @@ export function getRSCScrollTarget(animState: {
145145
return 'browser';
146146
}
147147

148-
// Determine scroll target for Exploit step
149-
export function getExploitScrollTarget(animState: {
150-
phase: string;
151-
payloadSent: boolean;
152-
serverCompromised: boolean;
148+
// Exploit trigger times interface (matches ExploitKeyframeTriggers)
149+
export interface ExploitTriggerTimes {
150+
craftsRequest: number;
151+
normalPayload: number;
152+
prototypePollution: number;
153+
protoKey: number;
154+
serverReceives: number;
155+
goesWrong: number;
156+
noValidation: number;
157+
modifiesPrototype: number;
158+
poisoned: number;
159+
gadgetChain: number;
160+
constructorAccess: number;
161+
functionConstructor: number;
162+
executeCode: number;
163+
serverRuns: number;
164+
whoamiRoot: number;
165+
completeControl: number;
166+
consequences: number;
167+
}
168+
169+
// Default exploit triggers (fallback if whisper data not loaded)
170+
const DEFAULT_EXPLOIT_TRIGGERS: ExploitTriggerTimes = {
171+
craftsRequest: 3,
172+
normalPayload: 6,
173+
prototypePollution: 10,
174+
protoKey: 18,
175+
serverReceives: 25,
176+
goesWrong: 28,
177+
noValidation: 31,
178+
modifiesPrototype: 38,
179+
poisoned: 42,
180+
gadgetChain: 50,
181+
constructorAccess: 58,
182+
functionConstructor: 63,
183+
executeCode: 67,
184+
serverRuns: 71,
185+
whoamiRoot: 75,
186+
completeControl: 80,
187+
consequences: 83
188+
};
189+
190+
// Determine scroll target for Exploit step based on current time and trigger points
191+
// This is narration-aware: scroll targets match what the narrator is describing
192+
// Flow: Attacker Browser (crafting) → Network (sending) → Server (processing/poisoned/compromised) → Explanation (consequences)
193+
export function getExploitScrollTarget(params: {
194+
currentTime: number;
195+
triggers?: ExploitTriggerTimes | null;
153196
}): ScrollTarget {
154-
if (!animState.payloadSent) {
155-
return 'browser'; // Attacker browser
197+
const { currentTime, triggers } = params;
198+
const t = triggers ?? DEFAULT_EXPLOIT_TRIGGERS;
199+
200+
// Phase 1: Attacker crafting payload (0 to protoKey)
201+
// User should see the attacker browser and payload being constructed
202+
if (currentTime < t.protoKey) {
203+
return 'browser';
156204
}
157205

158-
if (animState.payloadSent && !animState.serverCompromised) {
206+
// Phase 2: Packet traveling to server (protoKey to serverReceives)
207+
// Brief network phase as request travels
208+
if (currentTime < t.serverReceives) {
159209
return 'network';
160210
}
161211

162-
if (animState.serverCompromised) {
212+
// Phase 3: Server processing, poisoning, and exploitation (serverReceives to consequences)
213+
// Most of the narration focuses on what happens on the server
214+
// This includes: receiving, validation failure, prototype pollution, gadget chain, RCE
215+
if (currentTime < t.consequences) {
163216
return 'server';
164217
}
165218

166-
return 'browser';
219+
// Phase 4: Consequences and impact (consequences onwards)
220+
// Show the real-world impact section at the end
221+
return 'explanation';
222+
}
223+
224+
// Fix step trigger times interface (matches FixKeyframeTriggers)
225+
export interface FixTriggerTimes {
226+
vulnerableCode: number;
227+
bracketNotation: number;
228+
fixAdds: number;
229+
hasOwnProperty: number;
230+
blocked: number;
231+
patchApplication: number;
232+
nextJs: number;
233+
reactDirect: number;
234+
verify: number;
235+
millions: number;
236+
}
237+
238+
// Default fix triggers (fallback if whisper data not loaded)
239+
const DEFAULT_FIX_TRIGGERS: FixTriggerTimes = {
240+
vulnerableCode: 5,
241+
bracketNotation: 10,
242+
fixAdds: 25,
243+
hasOwnProperty: 35,
244+
blocked: 48,
245+
patchApplication: 55,
246+
nextJs: 60,
247+
reactDirect: 70,
248+
verify: 80,
249+
millions: 90
250+
};
251+
252+
// Determine scroll target for Fix step based on current time and trigger points
253+
// Flow: Code diff (vulnerable → fixed) → Remediation cards
254+
export function getFixScrollTarget(params: {
255+
currentTime: number;
256+
triggers?: FixTriggerTimes | null;
257+
}): ScrollTarget {
258+
const { currentTime, triggers } = params;
259+
const t = triggers ?? DEFAULT_FIX_TRIGGERS;
260+
261+
// Phase 1: Code diff section - showing vulnerable and fixed code (0 to patchApplication)
262+
// User should see the before/after code diff
263+
if (currentTime < t.patchApplication) {
264+
return 'browser'; // Code diff container
265+
}
266+
267+
// Phase 2: Remediation section (patchApplication onwards)
268+
// Show the patching instructions and version cards
269+
return 'explanation';
270+
}
271+
272+
// Lessons step trigger times interface (matches LessonsKeyframeTriggers)
273+
export interface LessonsTriggerTimes {
274+
firstLesson: number;
275+
secondLesson: number;
276+
thirdLesson: number;
277+
fourthLesson: number;
278+
remember: number;
279+
bakedIn: number;
280+
}
281+
282+
// Default lessons triggers (fallback if whisper data not loaded)
283+
const DEFAULT_LESSONS_TRIGGERS: LessonsTriggerTimes = {
284+
firstLesson: 4,
285+
secondLesson: 12,
286+
thirdLesson: 20,
287+
fourthLesson: 28,
288+
remember: 36,
289+
bakedIn: 44
290+
};
291+
292+
// Determine scroll target for Lessons step based on current time and trigger points
293+
// Flow: Lesson cards (1-4) → Final quote/summary → Resources
294+
export function getLessonsScrollTarget(params: {
295+
currentTime: number;
296+
triggers?: LessonsTriggerTimes | null;
297+
}): ScrollTarget {
298+
const { currentTime, triggers } = params;
299+
const t = triggers ?? DEFAULT_LESSONS_TRIGGERS;
300+
301+
// Phase 1: Lessons cards (0 to remember)
302+
// User should see the lesson cards being highlighted
303+
if (currentTime < t.remember) {
304+
return 'browser'; // Lessons grid
305+
}
306+
307+
// Phase 2: Quote and resources (remember onwards)
308+
// Show the final summary and further reading
309+
return 'explanation';
167310
}
168311

169312
// Module-level state for scroll tracking

0 commit comments

Comments
 (0)