@ssgoi/core
Version:
Core animation engine for SSGOI - Native app-like page transitions with spring physics
42 lines • 1.46 kB
TypeScript
/**
* Navigation Detector Strategy
*
* Collects out/in navigation events and provides navigation pairs.
* Each strategy handles the timing differently:
* - OutFirst: OUT must arrive before IN (for Svelte, Vue)
* - AnyOrder: OUT and IN can arrive in any order (for React)
*/
export type NavigationPair = {
from: string;
to: string;
};
export interface NavigationDetector {
/**
* Trigger navigation event
*/
trigger(path: string, type: "out" | "in"): void;
/**
* Get navigation pair when ready
* Returns null if should skip (e.g., page refresh in outFirst mode)
*/
get(type: "out" | "in"): Promise<NavigationPair | null>;
}
export type CreateNavigationDetector = () => NavigationDetector;
/**
* OutFirst Strategy
*
* OUT must arrive before IN. Best for frameworks with native destroy callbacks.
* - OUT triggers first, then IN completes the pair
* - If IN arrives without OUT, returns null (page refresh case)
*/
export declare function createOutFirstDetector(): NavigationDetector;
/**
* AnyOrder Strategy
*
* OUT and IN can arrive in any order. Best for frameworks using MutationObserver.
* - Either OUT or IN can arrive first
* - Both wait indefinitely for the other to complete the pair
* - If a new path arrives, cancels the previous pending transition
*/
export declare function createAnyOrderDetector(): NavigationDetector;
//# sourceMappingURL=navigation-detector-strategy.d.ts.map