Skip to content

Commit

Permalink
render react, classic and automatic (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
smmoosavi authored Dec 3, 2024
1 parent 5bca138 commit 1f426ea
Show file tree
Hide file tree
Showing 35 changed files with 2,620 additions and 568 deletions.
7 changes: 0 additions & 7 deletions api-extractor.json → api-extractor-base.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",

"mainEntryPointFilePath": "<projectFolder>/.cache/dts/index.d.ts",

"apiReport": {
"enabled": false
},
"docModel": {
"enabled": false
},

"dtsRollup": {
"enabled": true,
"untrimmedFilePath": "<projectFolder>/index.d.ts"
},

"messages": {
"compilerMessageReporting": {
"default": {
Expand Down
10 changes: 10 additions & 0 deletions api-extractor-index.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",

"extends": "./api-extractor-base.json",
"mainEntryPointFilePath": "<projectFolder>/.cache/dts/index.d.ts",
"dtsRollup": {
"enabled": true,
"untrimmedFilePath": "<projectFolder>/index.d.ts"
}
}
10 changes: 10 additions & 0 deletions api-extractor-jsx-dev-runtime.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",

"extends": "./api-extractor-base.json",
"mainEntryPointFilePath": "<projectFolder>/.cache/dts/jsx-dev-runtime.d.ts",
"dtsRollup": {
"enabled": true,
"untrimmedFilePath": "<projectFolder>/jsx-dev-runtime.d.ts"
}
}
10 changes: 10 additions & 0 deletions api-extractor-jsx-runtime.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",

"extends": "./api-extractor-base.json",
"mainEntryPointFilePath": "<projectFolder>/.cache/dts/jsx-runtime.d.ts",
"dtsRollup": {
"enabled": true,
"untrimmedFilePath": "<projectFolder>/jsx-runtime.d.ts"
}
}
113 changes: 96 additions & 17 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,113 @@
import { JSXElementConstructor } from 'react';
import { ReactElement } from 'react';
import { ReactNode } from 'react';
import { XMLBuilder } from 'xmlbuilder2/lib/interfaces';
import { XMLBuilderCreateOptions } from 'xmlbuilder2/lib/interfaces';

export declare function CData(props: {
children: TextChildren;
}): ReactElement<any, string | JSXElementConstructor<any>>;
/**
*
* @public
*/
export declare function CData(props: { children: TextChildren }): null;

declare function Comment_2(props: {
children: TextChildren;
}): ReactElement<any, string | JSXElementConstructor<any>>;
/**
*
* @public
*/
declare function Comment_2(props: { children: TextChildren }): null;
export { Comment_2 as Comment };

export declare function Fragment(props: {
children?: ReactNode;
}): ReactElement<any, string | JSXElementConstructor<any>>;
/**
*
* @public
*/
export declare function createElement(
type: any,
props: any,
...children: any[]
): JsxXmlComponentElement | JsxXmlTagElement;

export declare function Ins(props: {
target: string;
content?: string;
}): ReactElement<any, string | JSXElementConstructor<any>>;
/**
*
* @public
*/
export declare function Fragment(props: { children?: ReactNode }): ReactNode;

/**
* @internal
*/
export declare function _getCurrentElement(): XMLBuilder;

/**
*
* @public
*/
export declare function Ins(props: { target: string; content?: string }): null;

/**
*
* @public
*/
declare function JSXXML(
type: any,
props: any,
...children: any[]
): JsxXmlComponentElement | JsxXmlTagElement;
export { JSXXML };
export { JSXXML as h };

declare const JsxXML: unique symbol;

/**
*
* @public
*/
export declare type JsxXmlComponentElement = {
$$typeof: typeof JsxXML;
builtin: false;
type: (props: any) => JsxXmlElement;
props: any;
};

/**
*
* @public
*/
export declare type JsxXmlElement = JsxXmlComponentElement | JsxXmlTagElement;

/**
*
* @public
*/
export declare type JsxXmlTagElement = {
$$typeof: typeof JsxXML;
builtin: false;
type: string;
attrs: any;
children: any;
};

/**
*
* @public
*/
export declare function render(
element: any,
element: ReactElement | JsxXmlElement,
options?: XMLBuilderCreateOptions,
): XMLBuilder;

declare type TextChild = string | number | boolean | null | undefined;
/**
* @public
*/
export declare type TextChild = string | number | boolean | null | undefined;

/**
* @public
*/
export declare type TextChildren = TextChild | TextChildren[];

declare type TextChildren = TextChild | TextChildren[];
/**
* @internal
*/
export declare function _withElement(cur: XMLBuilder, fn: () => void): void;

export {};
53 changes: 53 additions & 0 deletions jsx-dev-runtime.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { ReactNode } from 'react';

/**
*
* @public
*/
export declare function Fragment(props: { children?: ReactNode }): ReactNode;

/**
*
* @public
*/
export declare function jsxDEV(
type: any,
props: any,
key: any,
isStaticChildren: any,
source: any,
self: any,
): JsxXmlComponentElement | JsxXmlTagElement;

declare const JsxXML: unique symbol;

/**
*
* @public
*/
export declare type JsxXmlComponentElement = {
$$typeof: typeof JsxXML;
builtin: false;
type: (props: any) => JsxXmlElement;
props: any;
};

/**
*
* @public
*/
export declare type JsxXmlElement = JsxXmlComponentElement | JsxXmlTagElement;

/**
*
* @public
*/
export declare type JsxXmlTagElement = {
$$typeof: typeof JsxXML;
builtin: false;
type: string;
attrs: any;
children: any;
};

export {};
60 changes: 60 additions & 0 deletions jsx-runtime.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { ReactNode } from 'react';

/**
*
* @public
*/
export declare function Fragment(props: { children?: ReactNode }): ReactNode;

/**
*
* @public
*/
export declare function jsx(
type: any,
props: any,
key: any,
): JsxXmlComponentElement | JsxXmlTagElement;

/**
*
* @public
*/
export declare function jsxs(
type: any,
props: any,
key: any,
): JsxXmlComponentElement | JsxXmlTagElement;

declare const JsxXML: unique symbol;

/**
*
* @public
*/
export declare type JsxXmlComponentElement = {
$$typeof: typeof JsxXML;
builtin: false;
type: (props: any) => JsxXmlElement;
props: any;
};

/**
*
* @public
*/
export declare type JsxXmlElement = JsxXmlComponentElement | JsxXmlTagElement;

/**
*
* @public
*/
export declare type JsxXmlTagElement = {
$$typeof: typeof JsxXML;
builtin: false;
type: string;
attrs: any;
children: any;
};

export {};
17 changes: 16 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"src",
"dist",
"index.d.ts",
"jsx-runtime.d.ts",
"jsx-dev-runtime.d.ts",
"tsdoc-metadata.json"
],
"license": "MIT",
Expand All @@ -17,6 +19,16 @@
"types": "./index.d.ts",
"require": "./dist/index.cjs",
"import": "./dist/index.js"
},
"./jsx-runtime": {
"types": "./jsx-runtime.d.ts",
"require": "./dist/jsx-runtime.cjs",
"import": "./dist/jsx-runtime.js"
},
"./jsx-dev-runtime": {
"types": "./jsx-dev-runtime.d.ts",
"require": "./dist/jsx-dev-runtime.cjs",
"import": "./dist/jsx-dev-runtime.js"
}
},
"engines": {
Expand All @@ -30,7 +42,10 @@
"format:check": "prettier --check '**/*.{js,jsx,ts,tsx,json,yml,css,scss,md}'",
"test": "vitest --run --coverage",
"test:watch": "vitest",
"build:dts": "api-extractor run --local --verbose && prettier --write index.d.ts",
"build:dts:index": "api-extractor run --local --verbose --config api-extractor-index.json && prettier --write index.d.ts",
"build:dts:jsx-runtime": "api-extractor run --local --verbose --config api-extractor-jsx-runtime.json && prettier --write jsx-runtime.d.ts",
"build:dts:jsx-dev-runtime": "api-extractor run --local --verbose --config api-extractor-jsx-dev-runtime.json && prettier --write jsx-dev-runtime.d.ts",
"build:dts": "pnpm build:dts:index && pnpm build:dts:jsx-runtime && pnpm build:dts:jsx-dev-runtime",
"build": "tsc && vite build && pnpm build:dts",
"prepublishOnly": "pnpm build"
},
Expand Down
Loading

0 comments on commit 1f426ea

Please sign in to comment.