Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/sad-teams-end.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': major
---

Deprecates exposed `astro:transitions` and `astro:transitions/client` internals - ([v6 upgrade guidance](https://deploy-preview-12322--astro-docs-2.netlify.app/en/guides/upgrade-to/v6/#deprecated-exposed-astrotransitions-and-astrotransitionsclient-internals))
44 changes: 3 additions & 41 deletions packages/astro/client.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
/// <reference types="vite/types/import-meta.d.ts" />
/// <reference path="./types/content.d.ts" />

/// <reference path="./types/actions.d.ts" />
/// <reference path="./types/content.d.ts" />
/// <reference path="./types/env.d.ts" />
/// <reference path="./types/fonts.d.ts" />
/// <reference path="./types/transitions.d.ts" />

interface ImportMetaEnv {
// TODO: remove in Astro 7
Expand Down Expand Up @@ -119,46 +121,6 @@ declare module '*.svg' {
export default Component;
}

declare module 'astro:transitions' {
type TransitionModule = typeof import('./dist/virtual-modules/transitions.js');
export const slide: TransitionModule['slide'];
export const fade: TransitionModule['fade'];
export const createAnimationScope: TransitionModule['createAnimationScope'];

type ClientRouterModule = typeof import('./components/ClientRouter.astro');
export const ClientRouter: ClientRouterModule['default'];
}

declare module 'astro:transitions/client' {
type TransitionRouterModule = typeof import('./dist/virtual-modules/transitions-router.js');
export const navigate: TransitionRouterModule['navigate'];
export const supportsViewTransitions: TransitionRouterModule['supportsViewTransitions'];
export const getFallback: TransitionRouterModule['getFallback'];
export const transitionEnabledOnThisPage: TransitionRouterModule['transitionEnabledOnThisPage'];

export type Fallback = import('./dist/virtual-modules/transitions-types.js').Fallback;
export type Direction = import('./dist/virtual-modules/transitions-types.ts').Direction;
// biome-ignore format: bug
export type NavigationTypeString = import('./dist/virtual-modules/transitions-types.js').NavigationTypeString;
export type Options = import('./dist/virtual-modules/transitions-types.js').Options;

type EventModule = typeof import('./dist/virtual-modules/transitions-events.js');
export const TRANSITION_BEFORE_PREPARATION: EventModule['TRANSITION_BEFORE_PREPARATION'];
export const TRANSITION_AFTER_PREPARATION: EventModule['TRANSITION_AFTER_PREPARATION'];
export const TRANSITION_BEFORE_SWAP: EventModule['TRANSITION_BEFORE_SWAP'];
export const TRANSITION_AFTER_SWAP: EventModule['TRANSITION_AFTER_SWAP'];
export const TRANSITION_PAGE_LOAD: EventModule['TRANSITION_PAGE_LOAD'];
// biome-ignore format: bug
export type TransitionBeforePreparationEvent = import('./dist/virtual-modules/transitions-events.js').TransitionBeforePreparationEvent;
// biome-ignore format: bug
export type TransitionBeforeSwapEvent = import('./dist/virtual-modules/transitions-events.js').TransitionBeforeSwapEvent;
export const isTransitionBeforePreparationEvent: EventModule['isTransitionBeforePreparationEvent'];
export const isTransitionBeforeSwapEvent: EventModule['isTransitionBeforeSwapEvent'];
// biome-ignore format: bug
type TransitionSwapFunctionModule = typeof import('./dist/virtual-modules/transitions-swap-functions.js');
export const swapFunctions: TransitionSwapFunctionModule['swapFunctions'];
}

declare module 'astro:prefetch' {
export { prefetch, PrefetchOptions } from 'astro/virtual-modules/prefetch.js';
}
Expand Down
1 change: 1 addition & 0 deletions packages/astro/src/runtime/server/transition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ export function renderTransition(
return scope;
}

/** @deprecated This will be removed in Astro 7 */
export function createAnimationScope(
transitionName: string,
animations: Record<string, TransitionAnimationPair>,
Expand Down
8 changes: 7 additions & 1 deletion packages/astro/src/transitions/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@ import { updateScrollPosition } from './router.js';
import { swap } from './swap-functions.js';
import type { Direction, NavigationTypeString } from './types.js';

/** @deprecated This will be removed in Astro 7 */
export const TRANSITION_BEFORE_PREPARATION = 'astro:before-preparation';
/** @deprecated This will be removed in Astro 7 */
export const TRANSITION_AFTER_PREPARATION = 'astro:after-preparation';
/** @deprecated This will be removed in Astro 7 */
export const TRANSITION_BEFORE_SWAP = 'astro:before-swap';
/** @deprecated This will be removed in Astro 7 */
export const TRANSITION_AFTER_SWAP = 'astro:after-swap';
/** @deprecated This will be removed in Astro 7 */
export const TRANSITION_PAGE_LOAD = 'astro:page-load';

type Events =
Expand Down Expand Up @@ -67,6 +72,7 @@ class BeforeEvent extends Event {
* TransitionBeforePreparationEvent

*/
/** @deprecated This will be removed in Astro 7 */
export const isTransitionBeforePreparationEvent = (
value: any,
): value is TransitionBeforePreparationEvent => value.type === TRANSITION_BEFORE_PREPARATION;
Expand Down Expand Up @@ -109,7 +115,7 @@ export class TransitionBeforePreparationEvent extends BeforeEvent {
/*
* TransitionBeforeSwapEvent
*/

/** @deprecated This will be removed in Astro 7 */
export const isTransitionBeforeSwapEvent = (value: any): value is TransitionBeforeSwapEvent =>
value.type === TRANSITION_BEFORE_SWAP;
export class TransitionBeforeSwapEvent extends BeforeEvent {
Expand Down
11 changes: 7 additions & 4 deletions packages/astro/src/transitions/router.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { internalFetchHeaders } from 'virtual:astro:adapter-config/client';
import type { TransitionBeforePreparationEvent } from './events.js';
import { doPreparation, doSwap, TRANSITION_AFTER_SWAP } from './events.js';
import {
doPreparation,
doSwap,
TRANSITION_AFTER_SWAP,
onPageLoad,
triggerEvent,
} from './events.js';
import { detectScriptExecuted } from './swap-functions.js';
import type { Direction, Fallback, Options } from './types.js';

Expand All @@ -9,7 +15,6 @@ type State = {
scrollX: number;
scrollY: number;
};
type Events = 'astro:page-load' | 'astro:after-swap';
type Navigation = { controller: AbortController };
type Transition = {
// The view transitions object (API and simulation)
Expand Down Expand Up @@ -47,8 +52,6 @@ let mostRecentTransition: Transition | undefined;
// This variable tells us where we came from
let originalLocation: URL;

const triggerEvent = (name: Events) => document.dispatchEvent(new Event(name));
const onPageLoad = () => triggerEvent('astro:page-load');
const announce = () => {
let div = document.createElement('div');
div.setAttribute('aria-live', 'assertive');
Expand Down
25 changes: 25 additions & 0 deletions packages/astro/types/transitions.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
declare module 'astro:transitions' {
export * from 'astro/virtual-modules/transitions.js';
export { default as ClientRouter } from 'astro/components/ClientRouter.astro';
}

declare module 'astro:transitions/client' {
export {
navigate,
supportsViewTransitions,
transitionEnabledOnThisPage,
} from 'astro/virtual-modules/transitions-router.js';
export * from 'astro/virtual-modules/transitions-types.js';
export {
TRANSITION_BEFORE_PREPARATION,
isTransitionBeforePreparationEvent,
TransitionBeforePreparationEvent,
TRANSITION_AFTER_PREPARATION,
TRANSITION_BEFORE_SWAP,
isTransitionBeforeSwapEvent,
TransitionBeforeSwapEvent,
TRANSITION_AFTER_SWAP,
TRANSITION_PAGE_LOAD,
} from 'astro/virtual-modules/transitions-events.js';
export { swapFunctions } from 'astro/virtual-modules/transitions-swap-functions.js';
}