perf: enforce journey budgets and reference traces

This commit is contained in:
2026-09-02 07:48:02 +03:00
parent 8089d061ec
commit f4cf9fc77e
25 changed files with 1432 additions and 23 deletions

View File

@@ -1,6 +1,9 @@
import type { SectionId } from "@/content/types";
import type { JourneySource } from "./types";
declare const __PORTFOLIO_TEST_BUILD__: boolean;
const TEST_BUILD = typeof __PORTFOLIO_TEST_BUILD__ !== 'undefined' && __PORTFOLIO_TEST_BUILD__;
export interface NavigationState {
epoch: number;
source: JourneySource;
@@ -162,6 +165,10 @@ export function createNavigationController(
source,
destinationId,
};
if (TEST_BUILD) window.__PORTFOLIO_PERFORMANCE__?.noteNavigationEpoch(currentState.epoch);
if (TEST_BUILD && source === 'explicit-navigation' && (destinationId === 'toolkit' || destinationId === 'contact')) {
window.__PORTFOLIO_PERFORMANCE__?.recordActionMutation(destinationId);
}
emit();
return currentState.epoch;
};
@@ -184,6 +191,7 @@ export function createNavigationController(
) {
return;
}
if (TEST_BUILD && window.__PORTFOLIO_PERFORMANCE__?.holdNavigationSettlement(epoch)) return;
cancelSettle();
frameId = runtime.requestFrame(() => {
frameId = undefined;
@@ -202,6 +210,7 @@ export function createNavigationController(
id: SectionId,
target: HTMLElement,
): void => {
if (TEST_BUILD) window.__PORTFOLIO_PERFORMANCE__?.registerNavigationSettlement(epoch);
settleTimerId = runtime.setTimer(() => {
settleTimerId = undefined;
if (