From 2c1b0e832a1846ec6cd15f9ee43a3a5332f44305 Mon Sep 17 00:00:00 2001 From: Sibbngheid Date: Wed, 11 Sep 2024 00:57:41 +0300 Subject: [PATCH] Move global JSX namespace to separate export --- package.json | 8 +- src/jsx/index.ts | 129 +++++++++++++++++ src/jsx/runtime.ts | 2 +- src/jsx/types.ts | 247 ++++++++++++++++---------------- src/methods/create_directive.ts | 2 +- src/methods/template.ts | 2 +- src/types.ts | 6 +- 7 files changed, 267 insertions(+), 129 deletions(-) create mode 100644 src/jsx/index.ts diff --git a/package.json b/package.json index 6325773..fbb7af8 100755 --- a/package.json +++ b/package.json @@ -12,6 +12,10 @@ "import": "./dist/index.js", "types": "./dist/index.d.ts" }, + "./jsx": { + "import": "./dist/jsx/index.js", + "types": "./dist/jsx/index.d.ts" + }, "./jsx-runtime": { "import": "./dist/jsx/runtime.js", "types": "./dist/jsx/runtime.d.ts" @@ -89,8 +93,8 @@ "oby": "^15.1.1" }, "devDependencies": { - "@types/node": "^18.19.28", - "tsex": "^3.2.1", + "@types/node": "^22.5.4", + "tsex": "^4.0.2", "typescript": "^5.4.3" } } diff --git a/src/jsx/index.ts b/src/jsx/index.ts new file mode 100644 index 0000000..85e8ab7 --- /dev/null +++ b/src/jsx/index.ts @@ -0,0 +1,129 @@ + +/* IMPORT */ + +import type { JSX as JSXInternal } from "./types"; + +/* GLOBALS */ + +declare global { + namespace JSX { + type ArrayMaybe = JSXInternal.ArrayMaybe + type FunctionMaybe = JSXInternal.FunctionMaybe + type ObservableMaybe = JSXInternal.ObservableMaybe + type Nullable = JSXInternal.Nullable + type AllClassProperties = JSXInternal.AllClassProperties + type DOMCSSProperties = JSXInternal.DOMCSSProperties + type DOMCSSVariables = JSXInternal.DOMCSSVariables + type HTMLAttributeReferrerPolicy = JSXInternal.HTMLAttributeReferrerPolicy + type Child = JSXInternal.Child + type Children = JSXInternal.Children + type Class = JSXInternal.Class + type Component = JSXInternal.Component + type Element = JSXInternal.Element + type Ref = JSXInternal.Ref + type Refs = JSXInternal.Refs + type Style = JSXInternal.Style + type IntrinsicElement = JSXInternal.IntrinsicElement + interface ClassProperties extends JSXInternal.ClassProperties { } + interface StyleProperties extends JSXInternal.StyleProperties { } + type TargetedEvent = JSXInternal.TargetedEvent + type TargetedAnimationEvent = JSXInternal.TargetedAnimationEvent + type TargetedClipboardEvent = JSXInternal.TargetedClipboardEvent + type TargetedCompositionEvent = JSXInternal.TargetedCompositionEvent + type TargetedDragEvent = JSXInternal.TargetedDragEvent + type TargetedFocusEvent = JSXInternal.TargetedFocusEvent + type TargetedInputEvent = JSXInternal.TargetedInputEvent + type TargetedKeyboardEvent = JSXInternal.TargetedKeyboardEvent + type TargetedMouseEvent = JSXInternal.TargetedMouseEvent + type TargetedPointerEvent = JSXInternal.TargetedPointerEvent + type TargetedSubmitEvent = JSXInternal.TargetedSubmitEvent + type TargetedTouchEvent = JSXInternal.TargetedTouchEvent + type TargetedTransitionEvent = JSXInternal.TargetedTransitionEvent + type TargetedUIEvent = JSXInternal.TargetedUIEvent + type TargetedWheelEvent = JSXInternal.TargetedWheelEvent + type EventHandler = JSXInternal.EventHandler + type AnimationEventHandler = JSXInternal.AnimationEventHandler + type ClipboardEventHandler = JSXInternal.ClipboardEventHandler + type CompositionEventHandler = JSXInternal.CompositionEventHandler + type DragEventHandler = JSXInternal.DragEventHandler + type FocusEventHandler = JSXInternal.FocusEventHandler + type GenericEventHandler = JSXInternal.GenericEventHandler + type InputEventHandler = JSXInternal.InputEventHandler + type KeyboardEventHandler = JSXInternal.KeyboardEventHandler + type MouseEventHandler = JSXInternal.MouseEventHandler + type PointerEventHandler = JSXInternal.PointerEventHandler + type SubmitEventHandler = JSXInternal.SubmitEventHandler + type TouchEventHandler = JSXInternal.TouchEventHandler + type TransitionEventHandler = JSXInternal.TransitionEventHandler + type UIEventHandler = JSXInternal.UIEventHandler + type WheelEventHandler = JSXInternal.WheelEventHandler + interface ElementAttributesProperty extends JSXInternal.ElementAttributesProperty { } + interface ElementChildrenAttribute extends JSXInternal.ElementChildrenAttribute { } + interface IntrinsicAttributes extends JSXInternal.IntrinsicAttributes { } + interface AriaAttributes extends JSXInternal.AriaAttributes { } + interface Directives extends JSXInternal.Directives { } + type DirectiveAttributes = JSXInternal.DirectiveAttributes + interface EventAttributes extends JSXInternal.EventAttributes { } + interface ViewAttributes extends JSXInternal.ViewAttributes { } + interface DOMAttributes extends JSXInternal.DOMAttributes { } + interface VoidHTMLAttributes extends JSXInternal.VoidHTMLAttributes { } + interface HTMLAttributes extends JSXInternal.HTMLAttributes { } + interface SVGAttributes extends JSXInternal.SVGAttributes { } + interface AnchorHTMLAttributes extends JSXInternal.AnchorHTMLAttributes { } + interface AudioHTMLAttributes extends JSXInternal.AudioHTMLAttributes { } + interface AreaHTMLAttributes extends JSXInternal.AreaHTMLAttributes { } + interface BaseHTMLAttributes extends JSXInternal.BaseHTMLAttributes { } + interface BlockquoteHTMLAttributes extends JSXInternal.BlockquoteHTMLAttributes { } + interface BrHTMLAttributes extends JSXInternal.BrHTMLAttributes { } + interface ButtonHTMLAttributes extends JSXInternal.ButtonHTMLAttributes { } + interface CanvasHTMLAttributes extends JSXInternal.CanvasHTMLAttributes { } + interface ColHTMLAttributes extends JSXInternal.ColHTMLAttributes { } + interface ColgroupHTMLAttributes extends JSXInternal.ColgroupHTMLAttributes { } + interface DataHTMLAttributes extends JSXInternal.DataHTMLAttributes { } + interface DetailsHTMLAttributes extends JSXInternal.DetailsHTMLAttributes { } + interface DelHTMLAttributes extends JSXInternal.DelHTMLAttributes { } + interface DialogHTMLAttributes extends JSXInternal.DialogHTMLAttributes { } + interface EmbedHTMLAttributes extends JSXInternal.EmbedHTMLAttributes { } + interface FieldsetHTMLAttributes extends JSXInternal.FieldsetHTMLAttributes { } + interface FormHTMLAttributes extends JSXInternal.FormHTMLAttributes { } + interface HrHTMLAttributes extends JSXInternal.HrHTMLAttributes { } + interface HtmlHTMLAttributes extends JSXInternal.HtmlHTMLAttributes { } + interface IframeHTMLAttributes extends JSXInternal.IframeHTMLAttributes { } + interface ImgHTMLAttributes extends JSXInternal.ImgHTMLAttributes { } + interface InsHTMLAttributes extends JSXInternal.InsHTMLAttributes { } + interface InputHTMLAttributes extends JSXInternal.InputHTMLAttributes { } + interface KeygenHTMLAttributes extends JSXInternal.KeygenHTMLAttributes { } + interface LabelHTMLAttributes extends JSXInternal.LabelHTMLAttributes { } + interface LiHTMLAttributes extends JSXInternal.LiHTMLAttributes { } + interface LinkHTMLAttributes extends JSXInternal.LinkHTMLAttributes { } + interface MapHTMLAttributes extends JSXInternal.MapHTMLAttributes { } + interface MenuHTMLAttributes extends JSXInternal.MenuHTMLAttributes { } + interface MediaHTMLAttributes extends JSXInternal.MediaHTMLAttributes { } + interface MetaHTMLAttributes extends JSXInternal.MetaHTMLAttributes { } + interface MeterHTMLAttributes extends JSXInternal.MeterHTMLAttributes { } + interface QuoteHTMLAttributes extends JSXInternal.QuoteHTMLAttributes { } + interface ObjectHTMLAttributes extends JSXInternal.ObjectHTMLAttributes { } + interface OlHTMLAttributes extends JSXInternal.OlHTMLAttributes { } + interface OptgroupHTMLAttributes extends JSXInternal.OptgroupHTMLAttributes { } + interface OptionHTMLAttributes extends JSXInternal.OptionHTMLAttributes { } + interface OutputHTMLAttributes extends JSXInternal.OutputHTMLAttributes { } + interface ParamHTMLAttributes extends JSXInternal.ParamHTMLAttributes { } + interface ProgressHTMLAttributes extends JSXInternal.ProgressHTMLAttributes { } + interface SlotHTMLAttributes extends JSXInternal.SlotHTMLAttributes { } + interface ScriptHTMLAttributes extends JSXInternal.ScriptHTMLAttributes { } + interface SelectHTMLAttributes extends JSXInternal.SelectHTMLAttributes { } + interface SourceHTMLAttributes extends JSXInternal.SourceHTMLAttributes { } + interface StyleHTMLAttributes extends JSXInternal.StyleHTMLAttributes { } + interface TableHTMLAttributes extends JSXInternal.TableHTMLAttributes { } + interface TextareaHTMLAttributes extends JSXInternal.TextareaHTMLAttributes { } + interface TdHTMLAttributes extends JSXInternal.TdHTMLAttributes { } + interface ThHTMLAttributes extends JSXInternal.ThHTMLAttributes { } + interface TimeHTMLAttributes extends JSXInternal.TimeHTMLAttributes { } + interface TrackHTMLAttributes extends JSXInternal.TrackHTMLAttributes { } + interface VideoHTMLAttributes extends JSXInternal.VideoHTMLAttributes { } + interface WbrHTMLAttributes extends JSXInternal.WbrHTMLAttributes { } + interface WebViewHTMLAttributes extends JSXInternal.WebViewHTMLAttributes { } + interface IntrinsicElementsMap extends JSXInternal.IntrinsicElementsMap { } + interface IntrinsicElements extends JSXInternal.IntrinsicElements { } + } +} diff --git a/src/jsx/runtime.ts b/src/jsx/runtime.ts index fdf90b4..d948590 100644 --- a/src/jsx/runtime.ts +++ b/src/jsx/runtime.ts @@ -1,7 +1,6 @@ /* IMPORT */ -import './types'; import Fragment from '~/components/fragment'; import createElement from '~/methods/create_element'; import type {Component, Element} from '~/types'; @@ -18,4 +17,5 @@ const jsx =

( component: Component

, props?: P | null, key /* EXPORT */ +export * from './types'; export {jsx, jsx as jsxs, jsx as jsxDEV, Fragment}; diff --git a/src/jsx/types.ts b/src/jsx/types.ts index 482c20d..1cad3c9 100644 --- a/src/jsx/types.ts +++ b/src/jsx/types.ts @@ -3,117 +3,118 @@ /* GLOBALS */ +// @ts-ignore unused interface Element { cloneNode ( deep?: boolean ): Element } -interface HTMLElement { +interface HTMLElement extends EventTarget { cloneNode ( deep?: boolean ): HTMLElement } -interface SVGElement { +interface SVGElement extends EventTarget { cloneNode ( deep?: boolean ): SVGElement } /* JSX */ -declare namespace JSX { +export namespace JSX { /* HELPERS */ - type ArrayMaybe = T[] | T; + export type ArrayMaybe = T[] | T; - type FunctionMaybe = ({ (): T }) | T; + export type FunctionMaybe = ({ (): T }) | T; - type ObservableMaybe = ({ (): T }) | T; + export type ObservableMaybe = ({ (): T }) | T; - type Nullable = T | undefined | null; + export type Nullable = T | undefined | null; - type AllClassProperties = { + export type AllClassProperties = { [key: string]: FunctionMaybe> }; - type DOMCSSProperties = { + export type DOMCSSProperties = { [key in keyof Omit]?: FunctionMaybe> }; - type DOMCSSVariables = { + export type DOMCSSVariables = { [key: `--${string}`]: FunctionMaybe> }; - type HTMLAttributeReferrerPolicy = '' | 'no-referrer' | 'no-referrer-when-downgrade' | 'origin' | 'origin-when-cross-origin' | 'same-origin' | 'strict-origin' | 'strict-origin-when-cross-origin' | 'unsafe-url'; + export type HTMLAttributeReferrerPolicy = '' | 'no-referrer' | 'no-referrer-when-downgrade' | 'origin' | 'origin-when-cross-origin' | 'same-origin' | 'strict-origin' | 'strict-origin-when-cross-origin' | 'unsafe-url'; /* MAIN */ - type Child = null | undefined | boolean | bigint | number | string | symbol | Node | Array | (() => Child); + export type Child = null | undefined | boolean | bigint | number | string | symbol | Node | Array | (() => Child); - type Children = Child; + export type Children = Child; - type Class = FunctionMaybe | Class)[]>>; + export type Class = FunctionMaybe | Class)[]>>; - type Component

= ( props: P ) => Child; + export type Component

= ( props: P ) => Child; - type Element = Child; + export type Element = Child; - type Ref = (( value: T ) => void); + export type Ref = (( value: T ) => void); - type Refs = ArrayMaybe>> | Refs[]; + export type Refs = ArrayMaybe>> | Refs[]; - type Style = FunctionMaybe | Style)[]>>; + export type Style = FunctionMaybe | Style)[]>>; - type IntrinsicElement = IntrinsicElements[T]; + export type IntrinsicElement = IntrinsicElements[T]; - interface ClassProperties extends AllClassProperties {} + export interface ClassProperties extends AllClassProperties {} - interface StyleProperties extends DOMCSSProperties, DOMCSSVariables { + export interface StyleProperties extends DOMCSSProperties, DOMCSSVariables { zoom?: FunctionMaybe> } - type TargetedEvent = Omit & { readonly currentTarget: T }; - type TargetedAnimationEvent = TargetedEvent; - type TargetedClipboardEvent = TargetedEvent; - type TargetedCompositionEvent = TargetedEvent; - type TargetedDragEvent = TargetedEvent; - type TargetedFocusEvent = TargetedEvent; - type TargetedInputEvent = TargetedEvent; - type TargetedKeyboardEvent = TargetedEvent; - type TargetedMouseEvent = TargetedEvent; - type TargetedPointerEvent = TargetedEvent; - type TargetedSubmitEvent = TargetedEvent; - type TargetedTouchEvent = TargetedEvent; - type TargetedTransitionEvent = TargetedEvent; - type TargetedUIEvent = TargetedEvent; - type TargetedWheelEvent = TargetedEvent; - - type EventHandler = { ( this: never, event: Event ): void }; - type AnimationEventHandler = EventHandler>; - type ClipboardEventHandler = EventHandler>; - type CompositionEventHandler = EventHandler>; - type DragEventHandler = EventHandler>; - type FocusEventHandler = EventHandler>; - type GenericEventHandler = EventHandler>; - type InputEventHandler = EventHandler>; - type KeyboardEventHandler = EventHandler>; - type MouseEventHandler = EventHandler>; - type PointerEventHandler = EventHandler>; - type SubmitEventHandler = EventHandler>; - type TouchEventHandler = EventHandler>; - type TransitionEventHandler = EventHandler>; - type UIEventHandler = EventHandler>; - type WheelEventHandler = EventHandler>; - - interface ElementAttributesProperty { + export type TargetedEvent = Omit & { readonly currentTarget: T }; + export type TargetedAnimationEvent = TargetedEvent; + export type TargetedClipboardEvent = TargetedEvent; + export type TargetedCompositionEvent = TargetedEvent; + export type TargetedDragEvent = TargetedEvent; + export type TargetedFocusEvent = TargetedEvent; + export type TargetedInputEvent = TargetedEvent; + export type TargetedKeyboardEvent = TargetedEvent; + export type TargetedMouseEvent = TargetedEvent; + export type TargetedPointerEvent = TargetedEvent; + export type TargetedSubmitEvent = TargetedEvent; + export type TargetedTouchEvent = TargetedEvent; + export type TargetedTransitionEvent = TargetedEvent; + export type TargetedUIEvent = TargetedEvent; + export type TargetedWheelEvent = TargetedEvent; + + export type EventHandler = { ( this: never, event: Event ): void }; + export type AnimationEventHandler = EventHandler>; + export type ClipboardEventHandler = EventHandler>; + export type CompositionEventHandler = EventHandler>; + export type DragEventHandler = EventHandler>; + export type FocusEventHandler = EventHandler>; + export type GenericEventHandler = EventHandler>; + export type InputEventHandler = EventHandler>; + export type KeyboardEventHandler = EventHandler>; + export type MouseEventHandler = EventHandler>; + export type PointerEventHandler = EventHandler>; + export type SubmitEventHandler = EventHandler>; + export type TouchEventHandler = EventHandler>; + export type TransitionEventHandler = EventHandler>; + export type UIEventHandler = EventHandler>; + export type WheelEventHandler = EventHandler>; + + export interface ElementAttributesProperty { props: Record } - interface ElementChildrenAttribute { + export interface ElementChildrenAttribute { children: any } - interface IntrinsicAttributes { + export interface IntrinsicAttributes { } - interface AriaAttributes { + export interface AriaAttributes { ariaActiveDescendant?: FunctionMaybe>, ariaAtomic?: FunctionMaybe>, ariaAutoComplete?: FunctionMaybe>, @@ -167,18 +168,18 @@ declare namespace JSX { ariaValueText?: FunctionMaybe> } - interface Directives { + export interface Directives { //FIXME: remove these internal directives https://github.com/microsoft/TypeScript/issues/49536 __voby_internal1__: [], __voby_internal2__: [], // name: [arg1: unknown, arg2: unknown, ...argN: unknown] } - type DirectiveAttributes = { + export type DirectiveAttributes = { [Directive in keyof Directives as `use:${Directive}`]?: Directives[Directive] extends [infer U] ? U | [U] : Directives[Directive]; }; - interface EventAttributes { + export interface EventAttributes { /* IMAGE EVENTS */ onLoad?: ObservableMaybe>>, onLoadCapture?: ObservableMaybe>>, @@ -376,18 +377,18 @@ declare namespace JSX { onTransitionEndCapture?: ObservableMaybe>> } - interface ViewAttributes { + export interface ViewAttributes { children?: Children, dangerouslySetInnerHTML?: FunctionMaybe<{ __html: FunctionMaybe> }> } - interface DOMAttributes extends EventAttributes { + export interface DOMAttributes extends EventAttributes { } - interface VoidHTMLAttributes extends AriaAttributes, DOMAttributes, DirectiveAttributes { + export interface VoidHTMLAttributes extends AriaAttributes, DOMAttributes, DirectiveAttributes { ref?: Refs, accept?: FunctionMaybe>, @@ -562,11 +563,11 @@ declare namespace JSX { itemRef?: FunctionMaybe> } - interface HTMLAttributes extends VoidHTMLAttributes, ViewAttributes { + export interface HTMLAttributes extends VoidHTMLAttributes, ViewAttributes { } - interface SVGAttributes extends HTMLAttributes, DirectiveAttributes { + export interface SVGAttributes extends HTMLAttributes, DirectiveAttributes { ref?: Refs, accentHeight?: FunctionMaybe>, @@ -814,7 +815,7 @@ declare namespace JSX { 'xmlns:xlink'?: FunctionMaybe>, } - interface AnchorHTMLAttributes extends HTMLAttributes { + export interface AnchorHTMLAttributes extends HTMLAttributes { download?: FunctionMaybe>, href?: FunctionMaybe>, hrefLang?: FunctionMaybe>, @@ -826,11 +827,11 @@ declare namespace JSX { referrerPolicy?: FunctionMaybe> } - interface AudioHTMLAttributes extends MediaHTMLAttributes { + export interface AudioHTMLAttributes extends MediaHTMLAttributes { } - interface AreaHTMLAttributes extends VoidHTMLAttributes { + export interface AreaHTMLAttributes extends VoidHTMLAttributes { alt?: FunctionMaybe>, coords?: FunctionMaybe>, download?: FunctionMaybe>, @@ -843,20 +844,20 @@ declare namespace JSX { target?: FunctionMaybe> } - interface BaseHTMLAttributes extends VoidHTMLAttributes { + export interface BaseHTMLAttributes extends VoidHTMLAttributes { href?: FunctionMaybe>, target?: FunctionMaybe> } - interface BlockquoteHTMLAttributes extends HTMLAttributes { + export interface BlockquoteHTMLAttributes extends HTMLAttributes { cite?: FunctionMaybe> } - interface BrHTMLAttributes extends VoidHTMLAttributes { + export interface BrHTMLAttributes extends VoidHTMLAttributes { } - interface ButtonHTMLAttributes extends HTMLAttributes { + export interface ButtonHTMLAttributes extends HTMLAttributes { autoFocus?: FunctionMaybe>, disabled?: FunctionMaybe>, form?: FunctionMaybe>, @@ -870,52 +871,52 @@ declare namespace JSX { value?: FunctionMaybe | number>> } - interface CanvasHTMLAttributes extends HTMLAttributes { + export interface CanvasHTMLAttributes extends HTMLAttributes { height?: FunctionMaybe>, width?: FunctionMaybe> } - interface ColHTMLAttributes extends VoidHTMLAttributes { + export interface ColHTMLAttributes extends VoidHTMLAttributes { span?: FunctionMaybe>, width?: FunctionMaybe> } - interface ColgroupHTMLAttributes extends HTMLAttributes { + export interface ColgroupHTMLAttributes extends HTMLAttributes { span?: FunctionMaybe> } - interface DataHTMLAttributes extends HTMLAttributes { + export interface DataHTMLAttributes extends HTMLAttributes { value?: FunctionMaybe | number>> } - interface DetailsHTMLAttributes extends HTMLAttributes { + export interface DetailsHTMLAttributes extends HTMLAttributes { open?: FunctionMaybe>, onToggle?: ObservableMaybe>> } - interface DelHTMLAttributes extends HTMLAttributes { + export interface DelHTMLAttributes extends HTMLAttributes { cite?: FunctionMaybe>, dateTime?: FunctionMaybe> } - interface DialogHTMLAttributes extends HTMLAttributes { + export interface DialogHTMLAttributes extends HTMLAttributes { open?: FunctionMaybe> } - interface EmbedHTMLAttributes extends VoidHTMLAttributes { + export interface EmbedHTMLAttributes extends VoidHTMLAttributes { height?: FunctionMaybe>, src?: FunctionMaybe>, type?: FunctionMaybe>, width?: FunctionMaybe> } - interface FieldsetHTMLAttributes extends HTMLAttributes { + export interface FieldsetHTMLAttributes extends HTMLAttributes { disabled?: FunctionMaybe>, form?: FunctionMaybe>, name?: FunctionMaybe> } - interface FormHTMLAttributes extends HTMLAttributes { + export interface FormHTMLAttributes extends HTMLAttributes { acceptCharset?: FunctionMaybe>, action?: FunctionMaybe>, autoComplete?: FunctionMaybe>, @@ -926,15 +927,15 @@ declare namespace JSX { target?: FunctionMaybe> } - interface HrHTMLAttributes extends VoidHTMLAttributes { + export interface HrHTMLAttributes extends VoidHTMLAttributes { } - interface HtmlHTMLAttributes extends HTMLAttributes { + export interface HtmlHTMLAttributes extends HTMLAttributes { manifest?: FunctionMaybe> } - interface IframeHTMLAttributes extends HTMLAttributes { + export interface IframeHTMLAttributes extends HTMLAttributes { allow?: FunctionMaybe>, allowFullScreen?: FunctionMaybe>, allowTransparency?: FunctionMaybe>, @@ -957,7 +958,7 @@ declare namespace JSX { width?: FunctionMaybe> } - interface ImgHTMLAttributes extends VoidHTMLAttributes { + export interface ImgHTMLAttributes extends VoidHTMLAttributes { alt?: FunctionMaybe>, crossOrigin?: FunctionMaybe>, decoding?: FunctionMaybe>, @@ -971,12 +972,12 @@ declare namespace JSX { width?: FunctionMaybe> } - interface InsHTMLAttributes extends HTMLAttributes { + export interface InsHTMLAttributes extends HTMLAttributes { cite?: FunctionMaybe>, dateTime?: FunctionMaybe> } - interface InputHTMLAttributes extends VoidHTMLAttributes { + export interface InputHTMLAttributes extends VoidHTMLAttributes { accept?: FunctionMaybe>, alt?: FunctionMaybe>, autoComplete?: FunctionMaybe>, @@ -1014,7 +1015,7 @@ declare namespace JSX { onChange?: ObservableMaybe>> } - interface KeygenHTMLAttributes extends VoidHTMLAttributes { + export interface KeygenHTMLAttributes extends VoidHTMLAttributes { autoFocus?: FunctionMaybe>, challenge?: FunctionMaybe>, disabled?: FunctionMaybe>, @@ -1024,17 +1025,17 @@ declare namespace JSX { name?: FunctionMaybe> } - interface LabelHTMLAttributes extends HTMLAttributes { + export interface LabelHTMLAttributes extends HTMLAttributes { form?: FunctionMaybe>, htmlFor?: FunctionMaybe>, for?: FunctionMaybe> } - interface LiHTMLAttributes extends HTMLAttributes { + export interface LiHTMLAttributes extends HTMLAttributes { value?: FunctionMaybe | number>> } - interface LinkHTMLAttributes extends VoidHTMLAttributes { + export interface LinkHTMLAttributes extends VoidHTMLAttributes { as?: FunctionMaybe>, crossOrigin?: FunctionMaybe>, href?: FunctionMaybe>, @@ -1049,15 +1050,15 @@ declare namespace JSX { charSet?: FunctionMaybe> } - interface MapHTMLAttributes extends HTMLAttributes { + export interface MapHTMLAttributes extends HTMLAttributes { name?: FunctionMaybe> } - interface MenuHTMLAttributes extends HTMLAttributes { + export interface MenuHTMLAttributes extends HTMLAttributes { type?: FunctionMaybe> } - interface MediaHTMLAttributes extends HTMLAttributes { + export interface MediaHTMLAttributes extends HTMLAttributes { autoPlay?: FunctionMaybe>, controls?: FunctionMaybe>, controlsList?: FunctionMaybe>, @@ -1070,7 +1071,7 @@ declare namespace JSX { src?: FunctionMaybe> } - interface MetaHTMLAttributes extends VoidHTMLAttributes { + export interface MetaHTMLAttributes extends VoidHTMLAttributes { charSet?: FunctionMaybe>, content?: FunctionMaybe>, httpEquiv?: FunctionMaybe>, @@ -1078,7 +1079,7 @@ declare namespace JSX { media?: FunctionMaybe> } - interface MeterHTMLAttributes extends HTMLAttributes { + export interface MeterHTMLAttributes extends HTMLAttributes { form?: FunctionMaybe>, high?: FunctionMaybe>, low?: FunctionMaybe>, @@ -1088,11 +1089,11 @@ declare namespace JSX { value?: FunctionMaybe | number>> } - interface QuoteHTMLAttributes extends HTMLAttributes { + export interface QuoteHTMLAttributes extends HTMLAttributes { cite?: FunctionMaybe> } - interface ObjectHTMLAttributes extends HTMLAttributes { + export interface ObjectHTMLAttributes extends HTMLAttributes { classID?: FunctionMaybe>, data?: FunctionMaybe>, form?: FunctionMaybe>, @@ -1104,46 +1105,46 @@ declare namespace JSX { wmode?: FunctionMaybe> } - interface OlHTMLAttributes extends HTMLAttributes { + export interface OlHTMLAttributes extends HTMLAttributes { reversed?: FunctionMaybe>, start?: FunctionMaybe>, type?: FunctionMaybe> } - interface OptgroupHTMLAttributes extends HTMLAttributes { + export interface OptgroupHTMLAttributes extends HTMLAttributes { disabled?: FunctionMaybe>, label?: FunctionMaybe> } - interface OptionHTMLAttributes extends HTMLAttributes { + export interface OptionHTMLAttributes extends HTMLAttributes { disabled?: FunctionMaybe>, label?: FunctionMaybe>, selected?: FunctionMaybe>, value?: FunctionMaybe | number>> } - interface OutputHTMLAttributes extends HTMLAttributes { + export interface OutputHTMLAttributes extends HTMLAttributes { form?: FunctionMaybe>, htmlFor?: FunctionMaybe>, for?: FunctionMaybe>, name?: FunctionMaybe> } - interface ParamHTMLAttributes extends VoidHTMLAttributes { + export interface ParamHTMLAttributes extends VoidHTMLAttributes { name?: FunctionMaybe>, value?: FunctionMaybe | number>> } - interface ProgressHTMLAttributes extends HTMLAttributes { + export interface ProgressHTMLAttributes extends HTMLAttributes { max?: FunctionMaybe>, value?: FunctionMaybe | number>>, } - interface SlotHTMLAttributes extends HTMLAttributes { + export interface SlotHTMLAttributes extends HTMLAttributes { name?: FunctionMaybe> } - interface ScriptHTMLAttributes extends HTMLAttributes { + export interface ScriptHTMLAttributes extends HTMLAttributes { async?: FunctionMaybe>, /** @deprecated */ charSet?: FunctionMaybe>, @@ -1157,7 +1158,7 @@ declare namespace JSX { type?: FunctionMaybe> } - interface SelectHTMLAttributes extends HTMLAttributes { + export interface SelectHTMLAttributes extends HTMLAttributes { autoComplete?: FunctionMaybe>, autoFocus?: FunctionMaybe>, disabled?: FunctionMaybe>, @@ -1170,7 +1171,7 @@ declare namespace JSX { onChange?: ObservableMaybe>> } - interface SourceHTMLAttributes extends VoidHTMLAttributes { + export interface SourceHTMLAttributes extends VoidHTMLAttributes { height?: FunctionMaybe>, media?: FunctionMaybe>, sizes?: FunctionMaybe>, @@ -1180,21 +1181,21 @@ declare namespace JSX { width?: FunctionMaybe> } - interface StyleHTMLAttributes extends HTMLAttributes { + export interface StyleHTMLAttributes extends HTMLAttributes { media?: FunctionMaybe>, nonce?: FunctionMaybe>, scoped?: FunctionMaybe>, type?: FunctionMaybe> } - interface TableHTMLAttributes extends HTMLAttributes { + export interface TableHTMLAttributes extends HTMLAttributes { cellPadding?: FunctionMaybe>, cellSpacing?: FunctionMaybe>, summary?: FunctionMaybe>, width?: FunctionMaybe> } - interface TextareaHTMLAttributes extends VoidHTMLAttributes { + export interface TextareaHTMLAttributes extends VoidHTMLAttributes { autoComplete?: FunctionMaybe>, autoFocus?: FunctionMaybe>, cols?: FunctionMaybe>, @@ -1213,7 +1214,7 @@ declare namespace JSX { onChange?: ObservableMaybe>> } - interface TdHTMLAttributes extends HTMLAttributes { + export interface TdHTMLAttributes extends HTMLAttributes { align?: FunctionMaybe>, colSpan?: FunctionMaybe>, headers?: FunctionMaybe>, @@ -1225,7 +1226,7 @@ declare namespace JSX { valign?: FunctionMaybe> } - interface ThHTMLAttributes extends HTMLAttributes { + export interface ThHTMLAttributes extends HTMLAttributes { align?: FunctionMaybe>, colSpan?: FunctionMaybe>, headers?: FunctionMaybe>, @@ -1234,11 +1235,11 @@ declare namespace JSX { abbr?: FunctionMaybe> } - interface TimeHTMLAttributes extends HTMLAttributes { + export interface TimeHTMLAttributes extends HTMLAttributes { dateTime?: FunctionMaybe> } - interface TrackHTMLAttributes extends VoidHTMLAttributes { + export interface TrackHTMLAttributes extends VoidHTMLAttributes { default?: FunctionMaybe>, kind?: FunctionMaybe>, label?: FunctionMaybe>, @@ -1246,7 +1247,7 @@ declare namespace JSX { srcLang?: FunctionMaybe> } - interface VideoHTMLAttributes extends MediaHTMLAttributes { + export interface VideoHTMLAttributes extends MediaHTMLAttributes { height?: FunctionMaybe>, playsInline?: FunctionMaybe>, poster?: FunctionMaybe>, @@ -1255,11 +1256,11 @@ declare namespace JSX { disableRemotePlayback?: FunctionMaybe> } - interface WbrHTMLAttributes extends VoidHTMLAttributes { + export interface WbrHTMLAttributes extends VoidHTMLAttributes { } - interface WebViewHTMLAttributes extends HTMLAttributes { + export interface WebViewHTMLAttributes extends HTMLAttributes { allowFullScreen?: FunctionMaybe>, allowpopups?: FunctionMaybe>, autoFocus?: FunctionMaybe>, @@ -1279,7 +1280,7 @@ declare namespace JSX { webpreferences?: FunctionMaybe> } - interface IntrinsicElementsMap { + export interface IntrinsicElementsMap { // HTML a: HTMLAnchorElement, abbr: HTMLElement, @@ -1451,7 +1452,7 @@ declare namespace JSX { use: SVGUseElement } - interface IntrinsicElements { + export interface IntrinsicElements { // HTML a: AnchorHTMLAttributes, abbr: HTMLAttributes, diff --git a/src/methods/create_directive.ts b/src/methods/create_directive.ts index 895e8b7..0239a05 100644 --- a/src/methods/create_directive.ts +++ b/src/methods/create_directive.ts @@ -4,7 +4,7 @@ import {DIRECTIVES, SYMBOLS_DIRECTIVES} from '~/constants'; import resolve from '~/methods/resolve'; import {context} from '~/oby'; -import type {Child, DirectiveFunction, Directive, DirectiveData, DirectiveOptions, ExtractArray} from '~/types'; +import type {Child, DirectiveFunction, Directive, DirectiveData, DirectiveOptions, ExtractArray, JSX} from '~/types'; /* MAIN */ diff --git a/src/methods/template.ts b/src/methods/template.ts index 9df09e7..fc4ab06 100644 --- a/src/methods/template.ts +++ b/src/methods/template.ts @@ -301,7 +301,7 @@ const template =

( fn: (( props: P ) => Child) ): (( props: P ) => () = const clone = root.cloneNode ( true ); - return wrapElement ( reviver.bind ( undefined, clone, props ) ); + return wrapElement ( reviver.bind ( undefined, clone as Element, props ) ); // TSC }; diff --git a/src/types.ts b/src/types.ts index 74743e6..b45c501 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,4 +1,8 @@ +/* IMPORT */ + +import type { JSX } from "./jsx/runtime" + /* HELPERS */ declare const ContextWithDefaultSymbol: unique symbol; @@ -151,4 +155,4 @@ type Truthy = Exclude