Skip to content

Commit

Permalink
fix: add route v1 compatibility type definitions (#895)
Browse files Browse the repository at this point in the history
  • Loading branch information
platosha authored Nov 4, 2024
1 parent e2e579c commit 7a889a9
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export * from './router.js';
export type * from './types.js';
export type * from './v1-compat.js';
export {
processNewChildren,
amend,
Expand Down
84 changes: 84 additions & 0 deletions src/v1-compat.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/* eslint-disable max-classes-per-file */

import type { MaybePromise } from './resolver/types';
import type { RouteContext, Route, ActionResult, ChildrenCallback, WebComponentInterface } from './types';

/**
* Action result describing an HTML element to render.
*
* @deprecated Use `HTMLElement`.
*/
export type ComponentResult = HTMLElement;

/**
* Route resolution context object, see {@link RouteContext}.
*
* @deprecated Use {@link RouteContext}.
*/
export type Context = RouteContext;

/**
* Route action callback function, see {@link Route.action}.
*
* @deprecated Use `NonNullable<Route['action']>`.
*/
export type ActionFn = (
this: Route,
context: RouteContext,
commands: Commands,
) => MaybePromise<ActionResult | RouteContext>;

/**
* Route children callback function, see {@link ChildrenCallback}.
*
* @deprecated Use {@link ChildrenCallback}.
*/
export type ChildrenFn = ChildrenCallback;

/**
* Web component route interface with {@link onBeforeEnter} callback.
*
* @deprecated Use {@link WebComponentInterface}.
*/
export interface BeforeEnterObserver {
/**
* See {@link WebComponentInterface.onBeforeEnter}
*/
onBeforeEnter: NonNullable<WebComponentInterface['onBeforeEnter']>;
}

/**
* Web component route interface with {@link onBeforeLeave} callback.
*
* @deprecated Use {@link WebComponentInterface}.
*/
export interface BeforeLeaveObserver {
/**
* See {@link WebComponentInterface.onBeforeLeave}
*/
onBeforeLeave: NonNullable<WebComponentInterface['onBeforeLeave']>;
}

/**
* Web component route interface with {@link onAfterEnter} callback.
*
* @deprecated Use {@link WebComponentInterface}.
*/
export interface AfterEnterObserver {
/**
* See {@link WebComponentInterface.onAfterEnter}
*/
onAfterEnter: NonNullable<WebComponentInterface['onAfterEnter']>;
}

/**
* Web component route interface with {@link onAfterLeave} callback.
*
* @deprecated Use {@link WebComponentInterface}.
*/
export interface AfterLeaveObserver {
/**
* See {@link WebComponentInterface.onAfterLeave}
*/
onAfterLeave: NonNullable<WebComponentInterface['onAfterLeave']>;
}

0 comments on commit 7a889a9

Please sign in to comment.