code-hike / codehike

Marvellous code walkthroughs
https://codehike.org
MIT License
4.51k stars 140 forks source link

Modify output of dist folder to merge all .d.ts files #186

Closed AeonFr closed 2 years ago

AeonFr commented 2 years ago

Merges all .d.ts files (closes #148)

I had to disable declaration in tsconfig to prevent rollup-plugin-typescript2 from creating the declarations.

Note: I also give a try in using @rollup/plugin-typescript, but it required much more configuration changes and had warnings I could not solve. I attach a screenshot of some of them. For example the sourcemap warning was no way to get rid of, not even adding output.sourcemap = true in rollupconfig as it says..

Screenshot 2022-05-20 at 19 05 38

This is the result: the new dist folder looks much cleaner.

Old:

Screenshot 2022-05-20 at 19 36 15

New:

image

This is the content of the new generated files:

Content of `index.d.ts` ```ts interface Data { [key: string]: unknown; } interface GenericNode { /** * The variant of a node. */ type: string; /** * Information from the ecosystem. */ data?: TData | undefined; /** * List representing the children of a node. */ children?: SuperNode[]; } interface BasicNode extends GenericNode { type: "thematicBreak" | "definition" | "link"; } interface CodeNode extends GenericNode { type: "code"; lang: string | undefined; value: string; meta: string | undefined; } interface JsxNode extends GenericNode { type: "mdxJsxFlowElement" | "mdxJsxTextElement"; /** * Component name (undefined for React.Fragment) */ name?: string; attributes?: { name: string; value: "string"; }[]; } interface EsmNode extends GenericNode { type: "mdxjsEsm"; value: string | undefined; } declare type SuperNode = BasicNode | JsxNode | EsmNode | CodeNode; declare type CodeHikeConfig = { theme: any; lineNumbers?: boolean; autoImport?: boolean; showExpandButton?: boolean; showCopyButton?: boolean; }; declare function transform(unsafeConfig: CodeHikeConfig): (tree: SuperNode) => Promise; declare type HighlightedToken = { content: string; props: { style?: React.CSSProperties; }; }; declare type HighlightedLine = { tokens: HighlightedToken[]; }; declare type Code = { lines: HighlightedLine[]; lang: string; }; declare function highlight({ code, lang, theme, }: { code: string; lang: string; theme: any; }): Promise; export { highlight, transform as remarkCodeHike }; ```
Content of `components.d.ts` ```ts import * as React$1 from 'react'; import React__default from 'react'; import { useSpring } from 'use-spring'; import { IRawTheme } from 'vscode-textmate'; import { CodeHikeConfig } from 'remark/config'; import { SandboxInfo } from '@codesandbox/sandpack-client'; declare type HighlightedToken = { content: string; props: { style?: React.CSSProperties; }; }; declare type HighlightedLine = { tokens: HighlightedToken[]; }; declare type Code$1 = { lines: HighlightedLine[]; lang: string; }; declare type FocusString = string | null | undefined; /** * A single theme setting. */ interface IRawThemeSetting { name?: string; scope?: string | string[]; settings: { fontStyle?: string; foreground?: string; background?: string; }; } /** * A TextMate theme. */ interface EditorTheme { name?: string; type?: string; colors?: Record; tokenColors?: IRawThemeSetting[]; settings?: IRawThemeSetting[]; semanticTokenColors?: any; semanticHighlighting?: boolean; } declare function Section({ children, ...props }: { children: React__default.ReactNode; }): JSX.Element; declare function SectionCode(): JSX.Element; declare function SectionLink({ focus, file, children, id, }: { focus: string; id: string; file?: string; children: React__default.ReactNode; }): JSX.Element; declare type AppClassName = string; declare type LibClassName = string; declare type Classes = Record; declare type Tab = { title: string; active: boolean; style: React__default.CSSProperties; }; declare type OutputPanel = { tabs: Tab[]; style: React__default.CSSProperties; children: React__default.ReactNode; }; declare type EditorFrameProps = { northPanel: OutputPanel; southPanel?: OutputPanel | null; theme: EditorTheme; terminalPanel?: React__default.ReactNode; height?: number; northButton?: React__default.ReactNode; southButton?: React__default.ReactNode; classes?: Classes; onTabClick?: (filename: string) => void; } & React__default.PropsWithoutRef; declare type CodeAnnotation = { focus: string; Component?: (props: { style?: React__default.CSSProperties; children: React__default.ReactNode; data: any; theme: EditorTheme; }) => React__default.ReactElement; data?: any; }; declare type CodeStep = { code: Code$1; focus: FocusString; annotations?: CodeAnnotation[]; }; declare type CodeConfig = { parentHeight?: any; minColumns?: number; minZoom?: number; maxZoom?: number; horizontalCenter?: boolean; theme: IRawTheme; lineNumbers?: boolean; showCopyButton?: boolean; showExpandButton?: boolean; }; declare type CodeFile = CodeStep & { name: string; }; declare type EditorPanel = { tabs: string[]; active: string; heightRatio: number; }; declare type EditorStep = { files: CodeFile[]; northPanel: EditorPanel; southPanel?: EditorPanel; terminal?: string; }; declare type SpringConfig = Parameters[1]; declare type DivProps = React__default.PropsWithoutRef; declare type EditorProps = EditorStep & { frameProps?: Partial; codeConfig: CodeConfig; springConfig?: SpringConfig; } & DivProps; declare function EditorSpring({ northPanel, southPanel, files, terminal, springConfig, ...props }: EditorProps): JSX.Element; declare function Code(props: EditorProps & Partial): JSX.Element; declare type PresetConfig = SandboxInfo; declare function Preview({ className, files, presetConfig, show, children, codeConfig, style, ...rest }: { className: string; files: EditorStep["files"]; presetConfig?: PresetConfig; show?: string; style?: React__default.CSSProperties; children?: React__default.ReactNode; codeConfig: { theme: EditorTheme; }; }): JSX.Element; declare function Spotlight({ children, editorSteps, codeConfig, start, presetConfig, }: { children: React__default.ReactNode; editorSteps: EditorStep[]; codeConfig: EditorProps["codeConfig"]; start?: number; presetConfig?: PresetConfig; }): JSX.Element; declare function Scrollycoding({ children, editorSteps, codeConfig, presetConfig, start, }: { children: React__default.ReactNode; editorSteps: EditorStep[]; codeConfig: EditorProps["codeConfig"]; start?: number; presetConfig?: PresetConfig; }): JSX.Element; declare function Slideshow({ children, editorSteps, codeConfig, presetConfig, code, }: { children: React__default.ReactNode; editorSteps: EditorStep[]; codeConfig: EditorProps["codeConfig"]; presetConfig?: PresetConfig; code?: EditorProps["codeConfig"]; }): JSX.Element; declare function Annotation(): string; declare const annotationsMap: Record; declare function InlineCode({ className, codeConfig, children, code, ...rest }: { className: string; code: Code$1; children?: React__default.ReactNode; codeConfig: { theme: EditorTheme; }; }): JSX.Element; declare type MiniBrowserStep = { /** * The url to display on the navigation bar. */ url?: string; /** * Override the url used for the iframe and "Open in new tab" button. */ loadUrl?: string; /** * Scale the content of the browser. */ zoom?: number; /** * Prepend the current origin to the url. */ prependOrigin?: boolean; /** * The content to display in the browser. If not provided, an iframe for the url will be displayed. */ children?: React__default.ReactNode; }; declare type Transition = "none" | "slide"; declare type MiniBrowserHikeProps = { progress?: number; backward?: boolean; classes?: Classes; steps?: MiniBrowserStep[]; transition?: Transition; theme: EditorTheme; } & React__default.PropsWithoutRef; declare type MiniBrowserProps = Omit & MiniBrowserStep; declare function MiniBrowser({ url, loadUrl, prependOrigin, children, zoom, ...rest }: MiniBrowserProps): JSX.Element; declare const CH: { Code: typeof Code; Section: typeof Section; SectionLink: typeof SectionLink; SectionCode: typeof SectionCode; Spotlight: typeof Spotlight; Scrollycoding: typeof Scrollycoding; Preview: typeof Preview; annotations: Record React$1.ReactElement>>; Annotation: typeof Annotation; Slideshow: typeof Slideshow; InlineCode: typeof InlineCode; }; declare const internal: { MiniBrowser: typeof MiniBrowser; EditorSpring: typeof EditorSpring; }; export { Annotation, CH, Code, InlineCode, Preview, Scrollycoding, Section, SectionCode, SectionLink, Slideshow, Spotlight, annotationsMap as annotations, internal }; ```

Version

Published prerelease version: v0.5.2-next.0

Changelog #### 🐛 Bug Fix #### 🏠 Internal - `@code-hike/mdx` - Modify output of dist folder to merge all .d.ts files [#186](https://github.com/code-hike/codehike/pull/186) ([@AeonFr](https://github.com/AeonFr) [@pomber](https://github.com/pomber)) #### Authors: 2 - Francisco Cano ([@AeonFr](https://github.com/AeonFr)) - Rodrigo Pombo ([@pomber](https://github.com/pomber))
vercel[bot] commented 2 years ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
chtest ✅ Ready (Inspect) Visit Preview May 21, 2022 at 10:08AM (UTC)
pomber commented 2 years ago

Thanks! I'll try to review it today

pomber commented 2 years ago

Looks good, thanks a lot!

github-actions[bot] commented 2 years ago

:rocket: PR was released in v0.5.2 :rocket: