Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
May 21, 2022

Conversation

AeonFr
Copy link
Contributor

@AeonFr AeonFr commented May 20, 2022

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`
interface Data {
    [key: string]: unknown;
}
interface GenericNode<TData extends object = Data> {
    /**
     * 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<TData extends object = Data> extends GenericNode<TData> {
    type: "thematicBreak" | "definition" | "link";
}
interface CodeNode<TData extends object = Data> extends GenericNode<TData> {
    type: "code";
    lang: string | undefined;
    value: string;
    meta: string | undefined;
}
interface JsxNode<TData extends object = Data> extends GenericNode<TData> {
    type: "mdxJsxFlowElement" | "mdxJsxTextElement";
    /**
     * Component name (undefined for React.Fragment)
     */
    name?: string;
    attributes?: {
        name: string;
        value: "string";
    }[];
}
interface EsmNode<TData extends object = Data> extends GenericNode<TData> {
    type: "mdxjsEsm";
    value: string | undefined;
}
declare type SuperNode<TData extends object = Data> = BasicNode<TData> | JsxNode<TData> | EsmNode<TData> | CodeNode<TData>;

declare type CodeHikeConfig = {
    theme: any;
    lineNumbers?: boolean;
    autoImport?: boolean;
    showExpandButton?: boolean;
    showCopyButton?: boolean;
};

declare function transform(unsafeConfig: CodeHikeConfig): (tree: SuperNode) => Promise<void>;

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<Code>;

export { highlight, transform as remarkCodeHike };
Content of `components.d.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<string, string>;
    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<LibClassName, AppClassName>;

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<JSX.IntrinsicElements["div"]>;

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<typeof useSpring>[1];
declare type DivProps = React__default.PropsWithoutRef<JSX.IntrinsicElements["div"]>;
declare type EditorProps = EditorStep & {
    frameProps?: Partial<EditorFrameProps>;
    codeConfig: CodeConfig;
    springConfig?: SpringConfig;
} & DivProps;
declare function EditorSpring({ northPanel, southPanel, files, terminal, springConfig, ...props }: EditorProps): JSX.Element;

declare function Code(props: EditorProps & Partial<CodeHikeConfig>): 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<string, CodeAnnotation["Component"]>;

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<JSX.IntrinsicElements["div"]>;

declare type MiniBrowserProps = Omit<MiniBrowserHikeProps, "progress" | "steps" | "backward"> & 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<string, (props: {
        style?: React$1.CSSProperties;
        children: React$1.ReactNode;
        data: any;
        theme: EditorTheme;
    }) => React$1.ReactElement<any, string | React$1.JSXElementConstructor<any>>>;
    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

Authors: 2

@vercel
Copy link

vercel bot commented May 20, 2022

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 pomber added release PR created automatically for new releases internal labels May 21, 2022
@pomber
Copy link
Contributor

pomber commented May 21, 2022

Thanks! I'll try to review it today

@pomber
Copy link
Contributor

pomber commented May 21, 2022

Looks good, thanks a lot!

@github-actions github-actions bot mentioned this pull request May 21, 2022
@AeonFr AeonFr deleted the merge-dts-files branch May 23, 2022 20:37
This was referenced May 24, 2022
@github-actions
Copy link
Contributor

🚀 PR was released in v0.5.2 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release PR created automatically for new releases
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Merge d.ts files from dist folder
2 participants