diff --git a/packages/create-remdx/template/remdx-env.d.ts b/packages/create-remdx/template/remdx-env.d.ts new file mode 100644 index 0000000..ef0b381 --- /dev/null +++ b/packages/create-remdx/template/remdx-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/packages/create-remdx/template/tsconfig.json b/packages/create-remdx/template/tsconfig.json index b8bcd00..c4f12eb 100644 --- a/packages/create-remdx/template/tsconfig.json +++ b/packages/create-remdx/template/tsconfig.json @@ -27,5 +27,5 @@ "target": "es2022" }, "exclude": ["dist/", "node_modules"], - "include": ["**/*.ts", "**/*.tsx"] + "include": ["remdx-env.d.ts", "**/*.ts", "**/*.tsx"] } diff --git a/packages/remdx/client.d.ts b/packages/remdx/client.d.ts index 1754296..0422692 100644 --- a/packages/remdx/client.d.ts +++ b/packages/remdx/client.d.ts @@ -1,9 +1,7 @@ -import type { MDXComponents, ReMDXSlide, Themes } from './types'; - declare module '*.re.mdx' { - let slides: ReadonlyArray; + let slides: ReadonlyArray; - export let Components: MDXComponents | undefined; - export let Themes: Themes | undefined; + export let Components: import('./types.jsx').MDXComponents | undefined; + export let Themes: import('./types.jsx').Themes | undefined; export default slides; } diff --git a/packages/remdx/src/deck.tsx b/packages/remdx/src/deck.tsx index 587b834..994fede 100644 --- a/packages/remdx/src/deck.tsx +++ b/packages/remdx/src/deck.tsx @@ -6,18 +6,13 @@ import { useEffect, } from 'react'; import { SwipeEventData } from 'react-swipeable'; +import { SlideTransition } from '../types.tsx'; import useAspectRatioFitting from './hooks/use-aspect-ratio-fitting.tsx'; import useDeckState from './hooks/use-deck-state.tsx'; import useLocationSync from './hooks/use-location-sync.tsx'; import useMousetrap from './hooks/use-mousetrap.tsx'; import { defaultTransition } from './transitions.tsx'; -export type SlideTransition = { - enter?: CSSProperties; - from?: CSSProperties; - leave?: CSSProperties; -}; - type DeckContextType = { activeView: { slideIndex: number; diff --git a/packages/remdx/src/slide.tsx b/packages/remdx/src/slide.tsx index 6b65ff1..48c71c7 100644 --- a/packages/remdx/src/slide.tsx +++ b/packages/remdx/src/slide.tsx @@ -9,7 +9,8 @@ import { } from 'react'; import { animated, useSpring } from 'react-spring'; import { useSwipeable } from 'react-swipeable'; -import { DeckContext, SlideTransition } from './deck.tsx'; +import { SlideTransition } from '../types.tsx'; +import { DeckContext } from './deck.tsx'; import { GOTO_FINAL_STEP } from './hooks/use-deck-state.tsx'; import { Transitions } from './transitions.tsx'; diff --git a/packages/remdx/src/transitions.tsx b/packages/remdx/src/transitions.tsx index bdef56b..a5a9714 100644 --- a/packages/remdx/src/transitions.tsx +++ b/packages/remdx/src/transitions.tsx @@ -1,4 +1,4 @@ -import { SlideTransition } from './deck.tsx'; +import { SlideTransition } from '../types.tsx'; export const defaultTransition: SlideTransition = { enter: { diff --git a/packages/remdx/types.tsx b/packages/remdx/types.tsx index 277310c..0fe70f8 100644 --- a/packages/remdx/types.tsx +++ b/packages/remdx/types.tsx @@ -1,13 +1,43 @@ -import { MDXProvider } from '@mdx-js/react'; import { CSSProperties } from 'react'; -import { SlideTransition } from './src/deck.tsx'; -type MDXProps = - typeof MDXProvider extends React.FC ? Props : never; +/** + * Configuration for `MDXProvider`. + */ +type MDXProps = { + /** + * Children (optional). + */ + children?: ReactNode | null | undefined; + /** + * Additional components to use or a function that creates them (optional). + */ + components?: Readonly | MergeComponents | null | undefined; + /** + * Turn off outer component context (default: `false`). + */ + disableParentContext?: boolean | null | undefined; +}; + +/** + * Provider for MDX context. + * + * @param {Readonly} properties + * Properties. + * @returns {JSX.Element} + * Element. + * @satisfies {Component} + */ +function MDXProvider(properties: Readonly): JSX.Element; export type MDXComponents = MDXProps['components']; export type Themes = Record; +export type SlideTransition = { + enter?: CSSProperties; + from?: CSSProperties; + leave?: CSSProperties; +}; + export type ReMDXSlide = { Component: () => JSX.Element; data: Record;