From 0d35abb2f7ac78895c938275ce69f625b81a31df Mon Sep 17 00:00:00 2001 From: eleliauk <2831336720@qq.com> Date: Fri, 5 Jul 2024 08:58:17 +0800 Subject: [PATCH 01/13] =?UTF-8?q?feat:=E5=AE=8C=E6=88=90JSX=20=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E8=A1=A5=E5=85=A8=E9=83=A8=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/inula/src/types.ts | 1160 ++++++++++++++++++++++++++++++++++- 1 file changed, 1157 insertions(+), 3 deletions(-) diff --git a/packages/inula/src/types.ts b/packages/inula/src/types.ts index 67db6d32..cc881204 100644 --- a/packages/inula/src/types.ts +++ b/packages/inula/src/types.ts @@ -17,6 +17,7 @@ import { Component } from './renderer/components/BaseClassComponent'; import { MutableRef, RefCallBack, RefObject } from './renderer/hooks/HookType'; import * as Event from './EventTypes'; +import Element = JSX.Element; // // --------------------------------- Inula Base Types ---------------------------------- @@ -244,6 +245,1152 @@ export type JSXElementConstructor

= | ((props: P) => InulaElement | null) | (new (props: P) => Component); + +interface ClassAttributes extends Attributes { + ref : Ref; + key : Key | undefined; + jsx : boolean | undefined; +} +//让其他代码在值发生变化时得到通知 +interface SignalLike { + value: T; + peek(): T; + subscribe(fn: (value: T) => void): () => void; +} +export type Signalish = T | SignalLike; +export interface DOMAttributes{ + + // Image Events + onLoad?: GenericEventHandler | undefined; + onLoadCapture?: GenericEventHandler | undefined; + onError?: GenericEventHandler | undefined; + onErrorCapture?: GenericEventHandler | undefined; + + // Clipboard Events + onCopy?: ClipboardEventHandler | undefined; + onCopyCapture?: ClipboardEventHandler | undefined; + onCut?: ClipboardEventHandler | undefined; + onCutCapture?: ClipboardEventHandler | undefined; + onPaste?: ClipboardEventHandler | undefined; + onPasteCapture?: ClipboardEventHandler | undefined; + // Composition Events + onCompositionEnd?: CompositionEventHandler | undefined; + onCompositionEndCapture?: CompositionEventHandler | undefined; + onCompositionStart?: CompositionEventHandler | undefined; + onCompositionStartCapture?: CompositionEventHandler | undefined; + onCompositionUpdate?: CompositionEventHandler | undefined; + onCompositionUpdateCapture?: CompositionEventHandler | undefined; + + // Details Events + onToggle?: GenericEventHandler | undefined; + + // Dialog Events + onClose?: GenericEventHandler | undefined; + onCancel?: GenericEventHandler | undefined; + + // Focus Events + onFocus?: FocusEventHandler | undefined; + onFocusCapture?: FocusEventHandler | undefined; + onFocusIn?: FocusEventHandler | undefined; + onFocusInCapture?: FocusEventHandler | undefined; + onFocusOut?: FocusEventHandler | undefined; + onFocusOutCapture?: FocusEventHandler | undefined; + onBlur?: FocusEventHandler | undefined; + onBlurCapture?: FocusEventHandler | undefined; + + // Form Events + onChange?: GenericEventHandler | undefined; + onChangeCapture?: GenericEventHandler | undefined; + onInput?: FormEventHandler | undefined; + onInputCapture?: FormEventHandler | undefined; + onBeforeInput?: FormEventHandler | undefined; + onBeforeInputCapture?: FormEventHandler | undefined; + onSearch?: GenericEventHandler | undefined; + onSearchCapture?: GenericEventHandler | undefined; + onSubmit?: FormEventHandler | undefined; + onSubmitCapture?: FormEventHandler | undefined; + onInvalid?: GenericEventHandler | undefined; + onInvalidCapture?: GenericEventHandler | undefined; + onReset?: GenericEventHandler | undefined; + onResetCapture?: GenericEventHandler | undefined; + onFormData?: GenericEventHandler | undefined; + onFormDataCapture?: GenericEventHandler | undefined; + + // Keyboard Events + onKeyDown?: KeyboardEventHandler | undefined; + onKeyDownCapture?: KeyboardEventHandler | undefined; + onKeyPress?: KeyboardEventHandler | undefined; + onKeyPressCapture?: KeyboardEventHandler | undefined; + onKeyUp?: KeyboardEventHandler | undefined; + onKeyUpCapture?: KeyboardEventHandler | undefined; + + // Media Events + onAbort?: GenericEventHandler | undefined; + onAbortCapture?: GenericEventHandler | undefined; + onCanPlay?: GenericEventHandler | undefined; + onCanPlayCapture?: GenericEventHandler | undefined; + onCanPlayThrough?: GenericEventHandler | undefined; + onCanPlayThroughCapture?: GenericEventHandler | undefined; + onDurationChange?: GenericEventHandler | undefined; + onDurationChangeCapture?: GenericEventHandler | undefined; + onEmptied?: GenericEventHandler | undefined; + onEmptiedCapture?: GenericEventHandler | undefined; + onEncrypted?: GenericEventHandler | undefined; + onEncryptedCapture?: GenericEventHandler | undefined; + onEnded?: GenericEventHandler | undefined; + onEndedCapture?: GenericEventHandler | undefined; + onLoadedData?: GenericEventHandler | undefined; + onLoadedDataCapture?: GenericEventHandler | undefined; + onLoadedMetadata?: GenericEventHandler | undefined; + onLoadedMetadataCapture?: GenericEventHandler | undefined; + onLoadStart?: GenericEventHandler | undefined; + onLoadStartCapture?: GenericEventHandler | undefined; + onPause?: GenericEventHandler | undefined; + onPauseCapture?: GenericEventHandler | undefined; + onPlay?: GenericEventHandler | undefined; + onPlayCapture?: GenericEventHandler | undefined; + onPlaying?: GenericEventHandler | undefined; + onPlayingCapture?: GenericEventHandler | undefined; + onProgress?: GenericEventHandler | undefined; + onProgressCapture?: GenericEventHandler | undefined; + onRateChange?: GenericEventHandler | undefined; + onRateChangeCapture?: GenericEventHandler | undefined; + onSeeked?: GenericEventHandler | undefined; + onSeekedCapture?: GenericEventHandler | undefined; + onSeeking?: GenericEventHandler | undefined; + onSeekingCapture?: GenericEventHandler | undefined; + onStalled?: GenericEventHandler | undefined; + onStalledCapture?: GenericEventHandler | undefined; + onSuspend?: GenericEventHandler | undefined; + onSuspendCapture?: GenericEventHandler | undefined; + onTimeUpdate?: GenericEventHandler | undefined; + onTimeUpdateCapture?: GenericEventHandler | undefined; + onVolumeChange?: GenericEventHandler | undefined; + onVolumeChangeCapture?: GenericEventHandler | undefined; + onWaiting?: GenericEventHandler | undefined; + onWaitingCapture?: GenericEventHandler | undefined; + + // MouseEvents + onClick?: MouseEventHandler | undefined; + onClickCapture?: MouseEventHandler | undefined; + onContextMenu?: MouseEventHandler | undefined; + onContextMenuCapture?: MouseEventHandler | undefined; + onDblClick?: MouseEventHandler | undefined; + onDblClickCapture?: MouseEventHandler | undefined; + onDrag?: DragEventHandler | undefined; + onDragCapture?: DragEventHandler | undefined; + onDragEnd?: DragEventHandler | undefined; + onDragEndCapture?: DragEventHandler | undefined; + onDragEnter?: DragEventHandler | undefined; + onDragEnterCapture?: DragEventHandler | undefined; + onDragExit?: DragEventHandler | undefined; + onDragExitCapture?: DragEventHandler | undefined; + onDragLeave?: DragEventHandler | undefined; + onDragLeaveCapture?: DragEventHandler | undefined; + onDragOver?: DragEventHandler | undefined; + onDragOverCapture?: DragEventHandler | undefined; + onDragStart?: DragEventHandler | undefined; + onDragStartCapture?: DragEventHandler | undefined; + onDrop?: DragEventHandler | undefined; + onDropCapture?: DragEventHandler | undefined; + onMouseDown?: MouseEventHandler | undefined; + onMouseDownCapture?: MouseEventHandler | undefined; + onMouseEnter?: MouseEventHandler | undefined; + onMouseEnterCapture?: MouseEventHandler | undefined; + onMouseLeave?: MouseEventHandler | undefined; + onMouseLeaveCapture?: MouseEventHandler | undefined; + onMouseMove?: MouseEventHandler | undefined; + onMouseMoveCapture?: MouseEventHandler | undefined; + onMouseOut?: MouseEventHandler | undefined; + onMouseOutCapture?: MouseEventHandler | undefined; + onMouseOver?: MouseEventHandler | undefined; + onMouseOverCapture?: MouseEventHandler | undefined; + onMouseUp?: MouseEventHandler | undefined; + onMouseUpCapture?: MouseEventHandler | undefined; + + // Selection Events + onSelect?: GenericEventHandler | undefined; + onSelectCapture?: GenericEventHandler | undefined; + + // Touch Events + onTouchCancel?: TouchEventHandler | undefined; + onTouchCancelCapture?: TouchEventHandler | undefined; + onTouchEnd?: TouchEventHandler | undefined; + onTouchEndCapture?: TouchEventHandler | undefined; + onTouchMove?: TouchEventHandler | undefined; + onTouchMoveCapture?: TouchEventHandler | undefined; + onTouchStart?: TouchEventHandler | undefined; + onTouchStartCapture?: TouchEventHandler | undefined; + + // Pointer Events + onPointerOver?: PointerEventHandler | undefined; + onPointerOverCapture?: PointerEventHandler | undefined; + onPointerEnter?: PointerEventHandler | undefined; + onPointerEnterCapture?: PointerEventHandler | undefined; + onPointerDown?: PointerEventHandler | undefined; + onPointerDownCapture?: PointerEventHandler | undefined; + onPointerMove?: PointerEventHandler | undefined; + onPointerMoveCapture?: PointerEventHandler | undefined; + onPointerUp?: PointerEventHandler | undefined; + onPointerUpCapture?: PointerEventHandler | undefined; + onPointerCancel?: PointerEventHandler | undefined; + onPointerCancelCapture?: PointerEventHandler | undefined; + onPointerOut?: PointerEventHandler | undefined; + onPointerOutCapture?: PointerEventHandler | undefined; + onPointerLeave?: PointerEventHandler | undefined; + onPointerLeaveCapture?: PointerEventHandler | undefined; + onGotPointerCapture?: PointerEventHandler | undefined; + onGotPointerCaptureCapture?: PointerEventHandler | undefined; + onLostPointerCapture?: PointerEventHandler | undefined; + onLostPointerCaptureCapture?: PointerEventHandler | undefined; + + // UI Events + onScroll?: UIEventHandler | undefined; + onScrollEnd?: UIEventHandler | undefined; + onScrollCapture?: UIEventHandler | undefined; + + // Wheel Events + onWheel?: WheelEventHandler | undefined; + onWheelCapture?: WheelEventHandler | undefined; + + // Animation Events + onAnimationStart?: AnimationEventHandler | undefined; + onAnimationStartCapture?: AnimationEventHandler | undefined; + onAnimationEnd?: AnimationEventHandler | undefined; + onAnimationEndCapture?: AnimationEventHandler | undefined; + onAnimationIteration?: AnimationEventHandler | undefined; + onAnimationIterationCapture?: AnimationEventHandler | undefined; + + // Transition Events + onTransitionCancel?: TransitionEventHandler; + onTransitionCancelCapture?: TransitionEventHandler; + onTransitionEnd?: TransitionEventHandler; + onTransitionEndCapture?: TransitionEventHandler; + onTransitionRun?: TransitionEventHandler; + onTransitionRunCapture?: TransitionEventHandler; + onTransitionStart?: TransitionEventHandler; + onTransitionStartCapture?: TransitionEventHandler; + + // PictureInPicture Events + onEnterPictureInPicture?: ChangeEventHandler; + onEnterPictureInPictureCapture?: ChangeEventHandler; + onLeavePictureInPicture?: ChangeEventHandler; + onLeavePictureInPictureCapture?: ChangeEventHandler; + onResize?: ChangeEventHandler; + onResizeCapture?: ChangeEventHandler; +} + +export interface AriaAttributes { + /** Identifies the currently active element when DOM focus is on a composite widget, textbox, group, or application. */ + 'aria-activedescendant'?: Signalish; + /** Indicates whether assistive technologies will present all, or only parts of, the changed region based on the change notifications defined by the aria-relevant attribute. */ + 'aria-atomic'?: Signalish; + /** + * Indicates whether inputting text could trigger display of one or more predictions of the user's intended value for an input and specifies how predictions would be + * presented if they are made. + */ + 'aria-autocomplete'?: Signalish< + 'none' | 'inline' | 'list' | 'both' | undefined + >; + /** + * Defines a string value that labels the current element, which is intended to be converted into Braille. + * @see aria-label. + */ + 'aria-braillelabel'?: Signalish; + /** + * Defines a human-readable, author-localized abbreviated description for the role of an element, which is intended to be converted into Braille. + * @see aria-roledescription. + */ + 'aria-brailleroledescription'?: Signalish; + /** Indicates an element is being modified and that assistive technologies MAY want to wait until the modifications are complete before exposing them to the user. */ + 'aria-busy'?: Signalish; + /** + * Indicates the current "checked" state of checkboxes, radio buttons, and other widgets. + * @see aria-pressed + * @see aria-selected. + */ + 'aria-checked'?: Signalish; + /** + * Defines the total number of columns in a table, grid, or treegrid. + * @see aria-colindex. + */ + 'aria-colcount'?: Signalish; + /** + * Defines an element's column index or position with respect to the total number of columns within a table, grid, or treegrid. + * @see aria-colcount + * @see aria-colspan. + */ + 'aria-colindex'?: Signalish; + /** + * Defines a human readable text alternative of aria-colindex. + * @see aria-rowindextext. + */ + 'aria-colindextext'?: Signalish; + /** + * Defines the number of columns spanned by a cell or gridcell within a table, grid, or treegrid. + * @see aria-colindex + * @see aria-rowspan. + */ + 'aria-colspan'?: Signalish; + /** + * Identifies the element (or elements) whose contents or presence are controlled by the current element. + * @see aria-owns. + */ + 'aria-controls'?: Signalish; + /** Indicates the element that represents the current item within a container or set of related elements. */ + 'aria-current'?: Signalish< + Booleanish | 'page' | 'step' | 'location' | 'date' | 'time' | undefined + >; + /** + * Identifies the element (or elements) that describes the object. + * @see aria-labelledby + */ + 'aria-describedby'?: Signalish; + /** + * Defines a string value that describes or annotates the current element. + * @see related aria-describedby. + */ + 'aria-description'?: Signalish; + /** + * Identifies the element that provides a detailed, extended description for the object. + * @see aria-describedby. + */ + 'aria-details'?: Signalish; + /** + * Indicates that the element is perceivable but disabled, so it is not editable or otherwise operable. + * @see aria-hidden + * @see aria-readonly. + */ + 'aria-disabled'?: Signalish; + /** + * Indicates what functions can be performed when a dragged object is released on the drop target. + * @deprecated in ARIA 1.1 + */ + 'aria-dropeffect'?: Signalish< + 'none' | 'copy' | 'execute' | 'link' | 'move' | 'popup' | undefined + >; + /** + * Identifies the element that provides an error message for the object. + * @see aria-invalid + * @see aria-describedby. + */ + 'aria-errormessage'?: Signalish; + /** Indicates whether the element, or another grouping element it controls, is currently expanded or collapsed. */ + 'aria-expanded'?: Signalish; + /** + * Identifies the next element (or elements) in an alternate reading order of content which, at the user's discretion, + * allows assistive technology to override the general default of reading in document source order. + */ + 'aria-flowto'?: Signalish; + /** + * Indicates an element's "grabbed" state in a drag-and-drop operation. + * @deprecated in ARIA 1.1 + */ + 'aria-grabbed'?: Signalish; + /** Indicates the availability and type of interactive popup element, such as menu or dialog, that can be triggered by an element. */ + 'aria-haspopup'?: Signalish< + Booleanish | 'menu' | 'listbox' | 'tree' | 'grid' | 'dialog' | undefined + >; + /** + * Indicates whether the element is exposed to an accessibility API. + * @see aria-disabled. + */ + 'aria-hidden'?: Signalish; + /** + * Indicates the entered value does not conform to the format expected by the application. + * @see aria-errormessage. + */ + 'aria-invalid'?: Signalish; + /** Indicates keyboard shortcuts that an author has implemented to activate or give focus to an element. */ + 'aria-keyshortcuts'?: Signalish; + /** + * Defines a string value that labels the current element. + * @see aria-labelledby. + */ + 'aria-label'?: Signalish; + /** + * Identifies the element (or elements) that labels the current element. + * @see aria-describedby. + */ + 'aria-labelledby'?: Signalish; + /** Defines the hierarchical level of an element within a structure. */ + 'aria-level'?: Signalish; + /** Indicates that an element will be updated, and describes the types of updates the user agents, assistive technologies, and user can expect from the live region. */ + 'aria-live'?: Signalish<'off' | 'assertive' | 'polite' | undefined>; + /** Indicates whether an element is modal when displayed. */ + 'aria-modal'?: Signalish; + /** Indicates whether a text box accepts multiple lines of input or only a single line. */ + 'aria-multiline'?: Signalish; + /** Indicates that the user may select more than one item from the current selectable descendants. */ + 'aria-multiselectable'?: Signalish; + /** Indicates whether the element's orientation is horizontal, vertical, or unknown/ambiguous. */ + 'aria-orientation'?: Signalish<'horizontal' | 'vertical' | undefined>; + /** + * Identifies an element (or elements) in order to define a visual, functional, or contextual parent/child relationship + * between DOM elements where the DOM hierarchy cannot be used to represent the relationship. + * @see aria-controls. + */ + 'aria-owns'?: Signalish; + /** + * Defines a short hint (a word or short phrase) intended to aid the user with data entry when the control has no value. + * A hint could be a sample value or a brief description of the expected format. + */ + 'aria-placeholder'?: Signalish; + /** + * Defines an element's number or position in the current set of listitems or treeitems. Not required if all elements in the set are present in the DOM. + * @see aria-setsize. + */ + 'aria-posinset'?: Signalish; + /** + * Indicates the current "pressed" state of toggle buttons. + * @see aria-checked + * @see aria-selected. + */ + 'aria-pressed'?: Signalish; + /** + * Indicates that the element is not editable, but is otherwise operable. + * @see aria-disabled. + */ + 'aria-readonly'?: Signalish; + /** + * Indicates what notifications the user agent will trigger when the accessibility tree within a live region is modified. + * @see aria-atomic. + */ + 'aria-relevant'?: Signalish< + | 'additions' + | 'additions removals' + | 'additions text' + | 'all' + | 'removals' + | 'removals additions' + | 'removals text' + | 'text' + | 'text additions' + | 'text removals' + | undefined + >; + /** Indicates that user input is required on the element before a form may be submitted. */ + 'aria-required'?: Signalish; + /** Defines a human-readable, author-localized description for the role of an element. */ + 'aria-roledescription'?: Signalish; + /** + * Defines the total number of rows in a table, grid, or treegrid. + * @see aria-rowindex. + */ + 'aria-rowcount'?: Signalish; + /** + * Defines an element's row index or position with respect to the total number of rows within a table, grid, or treegrid. + * @see aria-rowcount + * @see aria-rowspan. + */ + 'aria-rowindex'?: Signalish; + /** + * Defines a human readable text alternative of aria-rowindex. + * @see aria-colindextext. + */ + 'aria-rowindextext'?: Signalish; + /** + * Defines the number of rows spanned by a cell or gridcell within a table, grid, or treegrid. + * @see aria-rowindex + * @see aria-colspan. + */ + 'aria-rowspan'?: Signalish; + /** + * Indicates the current "selected" state of various widgets. + * @see aria-checked + * @see aria-pressed. + */ + 'aria-selected'?: Signalish; + /** + * Defines the number of items in the current set of listitems or treeitems. Not required if all elements in the set are present in the DOM. + * @see aria-posinset. + */ + 'aria-setsize'?: Signalish; + /** Indicates if items in a table or grid are sorted in ascending or descending order. */ + 'aria-sort'?: Signalish< + 'none' | 'ascending' | 'descending' | 'other' | undefined + >; + /** Defines the maximum allowed value for a range widget. */ + 'aria-valuemax'?: Signalish; + /** Defines the minimum allowed value for a range widget. */ + 'aria-valuemin'?: Signalish; + /** + * Defines the current value for a range widget. + * @see aria-valuetext. + */ + 'aria-valuenow'?: Signalish; + /** Defines the human readable text alternative of aria-valuenow for a range widget. */ + 'aria-valuetext'?: Signalish; +} +// All the WAI-ARIA 1.2 role attribute values from https://www.w3.org/TR/wai-aria-1.2/#role_definitions +type WAIAriaRole = + | 'alert' + | 'alertdialog' + | 'application' + | 'article' + | 'banner' + | 'blockquote' + | 'button' + | 'caption' + | 'cell' + | 'checkbox' + | 'code' + | 'columnheader' + | 'combobox' + | 'command' + | 'complementary' + | 'composite' + | 'contentinfo' + | 'definition' + | 'deletion' + | 'dialog' + | 'directory' + | 'document' + | 'emphasis' + | 'feed' + | 'figure' + | 'form' + | 'generic' + | 'grid' + | 'gridcell' + | 'group' + | 'heading' + | 'img' + | 'input' + | 'insertion' + | 'landmark' + | 'link' + | 'list' + | 'listbox' + | 'listitem' + | 'log' + | 'main' + | 'marquee' + | 'math' + | 'meter' + | 'menu' + | 'menubar' + | 'menuitem' + | 'menuitemcheckbox' + | 'menuitemradio' + | 'navigation' + | 'none' + | 'note' + | 'option' + | 'paragraph' + | 'presentation' + | 'progressbar' + | 'radio' + | 'radiogroup' + | 'range' + | 'region' + | 'roletype' + | 'row' + | 'rowgroup' + | 'rowheader' + | 'scrollbar' + | 'search' + | 'searchbox' + | 'section' + | 'sectionhead' + | 'select' + | 'separator' + | 'slider' + | 'spinbutton' + | 'status' + | 'strong' + | 'structure' + | 'subscript' + | 'superscript' + | 'switch' + | 'tab' + | 'table' + | 'tablist' + | 'tabpanel' + | 'term' + | 'textbox' + | 'time' + | 'timer' + | 'toolbar' + | 'tooltip' + | 'tree' + | 'treegrid' + | 'treeitem' + | 'widget' + | 'window' + | 'none presentation'; + +// All the Digital Publishing WAI-ARIA 1.0 role attribute values from https://www.w3.org/TR/dpub-aria-1.0/#role_definitions +type DPubAriaRole = + | 'doc-abstract' + | 'doc-acknowledgments' + | 'doc-afterword' + | 'doc-appendix' + | 'doc-backlink' + | 'doc-biblioentry' + | 'doc-bibliography' + | 'doc-biblioref' + | 'doc-chapter' + | 'doc-colophon' + | 'doc-conclusion' + | 'doc-cover' + | 'doc-credit' + | 'doc-credits' + | 'doc-dedication' + | 'doc-endnote' + | 'doc-endnotes' + | 'doc-epigraph' + | 'doc-epilogue' + | 'doc-errata' + | 'doc-example' + | 'doc-footnote' + | 'doc-foreword' + | 'doc-glossary' + | 'doc-glossref' + | 'doc-index' + | 'doc-introduction' + | 'doc-noteref' + | 'doc-notice' + | 'doc-pagebreak' + | 'doc-pagelist' + | 'doc-part' + | 'doc-preface' + | 'doc-prologue' + | 'doc-pullquote' + | 'doc-qna' + | 'doc-subtitle' + | 'doc-tip' + | 'doc-toc'; +//用于处理HTML 属性或其他需要接受布尔值或布尔字符串的地方特别有用 +type Booleanish = boolean | 'true' | 'false'; +type AriaRole = WAIAriaRole | DPubAriaRole; +export interface HTMLAttributes + extends ClassAttributes, + DOMAttributes, + AriaAttributes { + // Standard HTML Attributes + accept?: string | undefined | SignalLike; + acceptCharset?: string | undefined | SignalLike; + 'accept-charset'?: HTMLAttributes['acceptCharset']; + accessKey?: string | undefined | SignalLike; + accesskey?: HTMLAttributes['accessKey']; + action?: string | undefined | SignalLike; + allow?: string | undefined | SignalLike; + allowFullScreen?: boolean | undefined | SignalLike; + allowTransparency?: boolean | undefined | SignalLike; + alt?: string | undefined | SignalLike; + as?: string | undefined | SignalLike; + async?: boolean | undefined | SignalLike; + autocomplete?: string | undefined | SignalLike; + autoComplete?: string | undefined | SignalLike; + autocorrect?: string | undefined | SignalLike; + autoCorrect?: string | undefined | SignalLike; + autofocus?: boolean | undefined | SignalLike; + autoFocus?: boolean | undefined | SignalLike; + autoPlay?: boolean | undefined | SignalLike; + autoplay?: boolean | undefined | SignalLike; + capture?: boolean | string | undefined | SignalLike; + cellPadding?: number | string | undefined | SignalLike; + cellSpacing?: number | string | undefined | SignalLike; + charSet?: string | undefined | SignalLike; + charset?: string | undefined | SignalLike; + challenge?: string | undefined | SignalLike; + checked?: boolean | undefined | SignalLike; + cite?: string | undefined | SignalLike; + class?: string | undefined | SignalLike; + className?: string | undefined | SignalLike; + cols?: number | undefined | SignalLike; + colSpan?: number | undefined | SignalLike; + colspan?: number | undefined | SignalLike; + content?: string | undefined | SignalLike; + contentEditable?: + | Booleanish + | '' + | 'plaintext-only' + | 'inherit' + | undefined + | SignalLike; + contenteditable?: HTMLAttributes['contentEditable']; + /** @deprecated See https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/contextmenu */ + contextMenu?: string | undefined | SignalLike; + /** @deprecated See https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/contextmenu */ + contextmenu?: string | undefined | SignalLike; + controls?: boolean | undefined | SignalLike; + controlsList?: string | undefined | SignalLike; + coords?: string | undefined | SignalLike; + crossOrigin?: string | undefined | SignalLike; + crossorigin?: string | undefined | SignalLike; + data?: string | undefined | SignalLike; + dateTime?: string | undefined | SignalLike; + datetime?: string | undefined | SignalLike; + default?: boolean | undefined | SignalLike; + defaultChecked?: boolean | undefined | SignalLike; + defaultValue?: string | undefined | SignalLike; + defer?: boolean | undefined | SignalLike; + dir?: + | 'auto' + | 'rtl' + | 'ltr' + | undefined + | SignalLike<'auto' | 'rtl' | 'ltr' | undefined>; + disabled?: boolean | undefined | SignalLike; + disableRemotePlayback?: + | boolean + | undefined + | SignalLike; + download?: any | undefined; + decoding?: + | 'sync' + | 'async' + | 'auto' + | undefined + | SignalLike<'sync' | 'async' | 'auto' | undefined>; + draggable?: boolean | undefined | SignalLike; + encType?: string | undefined | SignalLike; + enctype?: string | undefined | SignalLike; + enterkeyhint?: + | 'enter' + | 'done' + | 'go' + | 'next' + | 'previous' + | 'search' + | 'send' + | undefined + | SignalLike< + | 'enter' + | 'done' + | 'go' + | 'next' + | 'previous' + | 'search' + | 'send' + | undefined + >; + elementTiming?: string | undefined | SignalLike; + elementtiming?: HTMLAttributes['elementTiming']; + exportparts?: string | undefined | SignalLike; + for?: string | undefined | SignalLike; + form?: string | undefined | SignalLike; + formAction?: string | undefined | SignalLike; + formaction?: string | undefined | SignalLike; + formEncType?: string | undefined | SignalLike; + formenctype?: string | undefined | SignalLike; + formMethod?: string | undefined | SignalLike; + formmethod?: string | undefined | SignalLike; + formNoValidate?: boolean | undefined | SignalLike; + formnovalidate?: boolean | undefined | SignalLike; + formTarget?: string | undefined | SignalLike; + formtarget?: string | undefined | SignalLike; + frameBorder?: + | number + | string + | undefined + | SignalLike; + frameborder?: + | number + | string + | undefined + | SignalLike; + headers?: string | undefined | SignalLike; + height?: + | number + | string + | undefined + | SignalLike; + hidden?: + | boolean + | 'hidden' + | 'until-found' + | undefined + | SignalLike; + high?: number | undefined | SignalLike; + href?: string | undefined | SignalLike; + hrefLang?: string | undefined | SignalLike; + hreflang?: string | undefined | SignalLike; + htmlFor?: string | undefined | SignalLike; + httpEquiv?: string | undefined | SignalLike; + 'http-equiv'?: string | undefined | SignalLike; + icon?: string | undefined | SignalLike; + id?: string | undefined | SignalLike; + indeterminate?: boolean | undefined | SignalLike; + inert?: boolean | undefined | SignalLike; + inputMode?: string | undefined | SignalLike; + inputmode?: string | undefined | SignalLike; + integrity?: string | undefined | SignalLike; + is?: string | undefined | SignalLike; + keyParams?: string | undefined | SignalLike; + keyType?: string | undefined | SignalLike; + kind?: string | undefined | SignalLike; + label?: string | undefined | SignalLike; + lang?: string | undefined | SignalLike; + list?: string | undefined | SignalLike; + loading?: + | 'eager' + | 'lazy' + | undefined + | SignalLike<'eager' | 'lazy' | undefined>; + loop?: boolean | undefined | SignalLike; + low?: number | undefined | SignalLike; + manifest?: string | undefined | SignalLike; + marginHeight?: number | undefined | SignalLike; + marginWidth?: number | undefined | SignalLike; + max?: number | string | undefined | SignalLike; + maxLength?: number | undefined | SignalLike; + maxlength?: number | undefined | SignalLike; + media?: string | undefined | SignalLike; + mediaGroup?: string | undefined | SignalLike; + method?: string | undefined | SignalLike; + min?: number | string | undefined | SignalLike; + minLength?: number | undefined | SignalLike; + minlength?: number | undefined | SignalLike; + multiple?: boolean | undefined | SignalLike; + muted?: boolean | undefined | SignalLike; + name?: string | undefined | SignalLike; + nomodule?: boolean | undefined | SignalLike; + nonce?: string | undefined | SignalLike; + noValidate?: boolean | undefined | SignalLike; + novalidate?: boolean | undefined | SignalLike; + open?: boolean | undefined | SignalLike; + optimum?: number | undefined | SignalLike; + part?: string | undefined | SignalLike; + pattern?: string | undefined | SignalLike; + ping?: string | undefined | SignalLike; + placeholder?: string | undefined | SignalLike; + playsInline?: boolean | undefined | SignalLike; + playsinline?: boolean | undefined | SignalLike; + popover?: + | 'auto' + | 'hint' + | 'manual' + | boolean + | undefined + | SignalLike<'auto' | 'hint' | 'manual' | boolean | undefined>; + popovertarget?: string | undefined | SignalLike; + popoverTarget?: string | undefined | SignalLike; + popovertargetaction?: + | 'hide' + | 'show' + | 'toggle' + | undefined + | SignalLike<'hide' | 'show' | 'toggle' | undefined>; + popoverTargetAction?: + | 'hide' + | 'show' + | 'toggle' + | undefined + | SignalLike<'hide' | 'show' | 'toggle' | undefined>; + poster?: string | undefined | SignalLike; + preload?: string | undefined | SignalLike; + radioGroup?: string | undefined | SignalLike; + readonly?: boolean | undefined | SignalLike; + readOnly?: boolean | undefined | SignalLike; + referrerpolicy?: + | 'no-referrer' + | 'no-referrer-when-downgrade' + | 'origin' + | 'origin-when-cross-origin' + | 'same-origin' + | 'strict-origin' + | 'strict-origin-when-cross-origin' + | 'unsafe-url' + | undefined + | SignalLike< + | 'no-referrer' + | 'no-referrer-when-downgrade' + | 'origin' + | 'origin-when-cross-origin' + | 'same-origin' + | 'strict-origin' + | 'strict-origin-when-cross-origin' + | 'unsafe-url' + | undefined + >; + rel?: string | undefined | SignalLike; + required?: boolean | undefined | SignalLike; + reversed?: boolean | undefined | SignalLike; + role?: AriaRole | undefined | SignalLike; + rows?: number | undefined | SignalLike; + rowSpan?: number | undefined | SignalLike; + rowspan?: number | undefined | SignalLike; + sandbox?: string | undefined | SignalLike; + scope?: string | undefined | SignalLike; + scoped?: boolean | undefined | SignalLike; + scrolling?: string | undefined | SignalLike; + seamless?: boolean | undefined | SignalLike; + selected?: boolean | undefined | SignalLike; + shape?: string | undefined | SignalLike; + size?: number | undefined | SignalLike; + sizes?: string | undefined | SignalLike; + slot?: string | undefined | SignalLike; + span?: number | undefined | SignalLike; + spellcheck?: boolean | undefined | SignalLike; + spellCheck?: boolean | undefined | SignalLike; + src?: string | undefined | SignalLike; + srcSet?: string | undefined | SignalLike; + srcset?: string | undefined | SignalLike; + srcDoc?: string | undefined | SignalLike; + srcdoc?: string | undefined | SignalLike; + srcLang?: string | undefined | SignalLike; + srclang?: string | undefined | SignalLike; + start?: number | undefined | SignalLike; + step?: + | number + | string + | undefined + | SignalLike; + style?: + | string + | CSSProperties + | undefined + | SignalLike; + summary?: string | undefined | SignalLike; + tabIndex?: number | undefined | SignalLike; + tabindex?: number | undefined | SignalLike; + target?: string | undefined | SignalLike; + title?: string | undefined | SignalLike; + type?: string | undefined | SignalLike; + useMap?: string | undefined | SignalLike; + usemap?: string | undefined | SignalLike; + value?: + | string + | string[] + | number + | undefined + | SignalLike; + volume?: + | string + | number + | undefined + | SignalLike; + width?: + | number + | string + | undefined + | SignalLike; + wmode?: string | undefined | SignalLike; + wrap?: string | undefined | SignalLike; + + // Non-standard Attributes + autocapitalize?: + | 'off' + | 'none' + | 'on' + | 'sentences' + | 'words' + | 'characters' + | undefined + | SignalLike< + | 'off' + | 'none' + | 'on' + | 'sentences' + | 'words' + | 'characters' + | undefined + >; + autoCapitalize?: + | 'off' + | 'none' + | 'on' + | 'sentences' + | 'words' + | 'characters' + | undefined + | SignalLike< + | 'off' + | 'none' + | 'on' + | 'sentences' + | 'words' + | 'characters' + | undefined + >; + disablePictureInPicture?: + | boolean + | undefined + | SignalLike; + results?: number | undefined | SignalLike; + translate?: boolean | undefined | SignalLike; + + // RDFa Attributes + about?: string | undefined | SignalLike; + datatype?: string | undefined | SignalLike; + inlist?: any; + prefix?: string | undefined | SignalLike; + property?: string | undefined | SignalLike; + resource?: string | undefined | SignalLike; + typeof?: string | undefined | SignalLike; + vocab?: string | undefined | SignalLike; + + // Microdata Attributes + itemProp?: string | undefined | SignalLike; + itemprop?: string | undefined | SignalLike; + itemScope?: boolean | undefined | SignalLike; + itemscope?: boolean | undefined | SignalLike; + itemType?: string | undefined | SignalLike; + itemtype?: string | undefined | SignalLike; + itemID?: string | undefined | SignalLike; + itemid?: string | undefined | SignalLike; + itemRef?: string | undefined | SignalLike; + itemref?: string | undefined | SignalLike; +} + + +// eslint-disable-next-line @typescript-eslint/no-namespace +export declare namespace JSX { + // JSX内在元素的接口,该接口下声明了JSX中的内置标签及其具有的属性,如标签和标签的value属性 + interface IntrinsicElements { + // HTML + a: HTMLAttributes; + abbr: HTMLAttributes; + address: HTMLAttributes; + area: HTMLAttributes; + article: HTMLAttributes; + aside: HTMLAttributes; + audio: HTMLAttributes; + b: HTMLAttributes; + base: HTMLAttributes; + bdi: HTMLAttributes; + bdo: HTMLAttributes; + big: HTMLAttributes; + blockquote: HTMLAttributes; + body: HTMLAttributes; + br: HTMLAttributes; + button: HTMLAttributes; + canvas: HTMLAttributes; + caption: HTMLAttributes; + cite: HTMLAttributes; + code: HTMLAttributes; + col: HTMLAttributes; + colgroup: HTMLAttributes; + data: HTMLAttributes; + datalist: HTMLAttributes; + dd: HTMLAttributes; + del: HTMLAttributes; + details: HTMLAttributes; + dfn: HTMLAttributes; + dialog: HTMLAttributes; + div: HTMLAttributes; + dl: HTMLAttributes; + dt: HTMLAttributes; + em: HTMLAttributes; + embed: HTMLAttributes; + fieldset: HTMLAttributes; + figcaption: HTMLAttributes; + figure: HTMLAttributes; + footer: HTMLAttributes; + form: HTMLAttributes; + h1: HTMLAttributes; + h2: HTMLAttributes; + h3: HTMLAttributes; + h4: HTMLAttributes; + h5: HTMLAttributes; + h6: HTMLAttributes; + head: HTMLAttributes; + header: HTMLAttributes; + hgroup: HTMLAttributes; + hr: HTMLAttributes; + html: HTMLAttributes; + i: HTMLAttributes; + iframe: HTMLAttributes; + img: HTMLAttributes; + input: HTMLAttributes; + ins: HTMLAttributes; + kbd: HTMLAttributes; + keygen: HTMLAttributes; + label: HTMLAttributes; + legend: HTMLAttributes; + li: HTMLAttributes; + link: HTMLAttributes; + main: HTMLAttributes; + map: HTMLAttributes; + mark: HTMLAttributes; + marquee: HTMLAttributes; + menu: HTMLAttributes; + menuitem: HTMLAttributes; + meta: HTMLAttributes; + meter: HTMLAttributes; + nav: HTMLAttributes; + noscript: HTMLAttributes; + object: HTMLAttributes; + ol: HTMLAttributes; + optgroup: HTMLAttributes; + option: HTMLAttributes; + output: HTMLAttributes; + p: HTMLAttributes; + param: HTMLAttributes; + picture: HTMLAttributes; + pre: HTMLAttributes; + progress: HTMLAttributes; + q: HTMLAttributes; + rp: HTMLAttributes; + rt: HTMLAttributes; + ruby: HTMLAttributes; + s: HTMLAttributes; + samp: HTMLAttributes; + script: HTMLAttributes; + search: HTMLAttributes; + section: HTMLAttributes; + select: HTMLAttributes; + slot: HTMLAttributes; + small: HTMLAttributes; + source: HTMLAttributes; + span: HTMLAttributes; + strong: HTMLAttributes; + style: HTMLAttributes; + sub: HTMLAttributes; + summary: HTMLAttributes; + sup: HTMLAttributes; + table: HTMLAttributes; + tbody: HTMLAttributes; + td: HTMLAttributes; + template: HTMLAttributes; + textarea: HTMLAttributes; + tfoot: HTMLAttributes; + th: HTMLAttributes; + thead: HTMLAttributes; + time: HTMLAttributes; + title: HTMLAttributes; + tr: HTMLAttributes; + track: HTMLAttributes; + u: HTMLAttributes; + ul: HTMLAttributes; + var: HTMLAttributes; + video: HTMLAttributes; + wbr: HTMLAttributes; + + } + // 该接口声明了类组件中具有的属性 + interface IntrinsicClassAttributes { + ref : Ref; + key : any; + + } + // 该接口声明了函数式组建中具有的属性 + interface IntrinsicAttributes { + key : any; + ref : Ref; + } + // 该接口声明了JSX中组件的元素、属性和子元素的类型 + interface Element { + type ?: any; + props ?: any; + key?:any; + } + // 该接口定义了类组件所具有的属性、方法 + interface ElementClass { + setState(state: any, callback : () => void): void; + forceUpdate(callback : () => void): void; + render():any; + } + // 该接口用于确定组件props中子元素的名称 + interface ElementChildrenAttribute { + children?:any; + } +} + + // // --------------------------------- Inula Event Types---------------------------------- // @@ -409,7 +1556,12 @@ export interface MouseEvent extends UIEven // export type EventHandler> = { bivarianceHack(event: E): void }['bivarianceHack']; - +export type TargetedEvent< + Target extends EventTarget = EventTarget, + TypedEvent extends Event = Event +> = Omit & { + readonly currentTarget: Target; +}; export type ClipboardEventHandler = EventHandler>; export type CompositionEventHandler = EventHandler>; export type DragEventHandler = EventHandler>; @@ -423,8 +1575,10 @@ export type PointerEventHandler = EventHandler>; export type UIEventHandler = EventHandler>; export type WheelEventHandler = EventHandler>; export type AnimationEventHandler = EventHandler>; -export type TransitionEventHandler = EventHandler>; - +export type TransitionEventHandler = EventHandler> +type GenericEventHandler = ( + event: TargetedEvent +) => void; // // --------------------------------- Css Props---------------------------------- // -- Gitee From 33a0b59f6c2ee2a9b63e02b178b7349c756fdd38 Mon Sep 17 00:00:00 2001 From: eleliauk <2831336720@qq.com> Date: Sun, 7 Jul 2024 19:37:09 +0800 Subject: [PATCH 02/13] =?UTF-8?q?fix:=E5=8E=BB=E9=99=A4=E4=B8=80=E4=BA=9B?= =?UTF-8?q?=E5=B7=B2=E7=BB=8F=E5=BC=83=E7=94=A8=E7=9A=84=E6=A0=87=E7=AD=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/inula/src/renderer/vnode/VNodeCreator.ts | 2 +- packages/inula/src/types.ts | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/inula/src/renderer/vnode/VNodeCreator.ts b/packages/inula/src/renderer/vnode/VNodeCreator.ts index 7cff3478..2185ab58 100644 --- a/packages/inula/src/renderer/vnode/VNodeCreator.ts +++ b/packages/inula/src/renderer/vnode/VNodeCreator.ts @@ -75,7 +75,7 @@ export function getLazyVNodeTag(lazyComp: any): string { } else if (lazyComp !== undefined && lazyComp !== null && typeLazyMap[lazyComp.vtype]) { return typeLazyMap[lazyComp.vtype]; } - throw Error("Inula can't resolve the content of lazy"); + throw Error('Inula can\'t resolve the content of lazy'); } // 创建processing diff --git a/packages/inula/src/types.ts b/packages/inula/src/types.ts index cc881204..44edf150 100644 --- a/packages/inula/src/types.ts +++ b/packages/inula/src/types.ts @@ -1306,7 +1306,6 @@ export declare namespace JSX { main: HTMLAttributes; map: HTMLAttributes; mark: HTMLAttributes; - marquee: HTMLAttributes; menu: HTMLAttributes; menuitem: HTMLAttributes; meta: HTMLAttributes; @@ -1319,7 +1318,6 @@ export declare namespace JSX { option: HTMLAttributes; output: HTMLAttributes; p: HTMLAttributes; - param: HTMLAttributes; picture: HTMLAttributes; pre: HTMLAttributes; progress: HTMLAttributes; -- Gitee From c3918caa78a0abe90d7bf6b61f94bded0ebb2a4b Mon Sep 17 00:00:00 2001 From: eleliauk <2831336720@qq.com> Date: Mon, 8 Jul 2024 14:26:30 +0800 Subject: [PATCH 03/13] =?UTF-8?q?fix:prettier=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/inula/src/types.ts | 241 ++++++++++-------------------------- 1 file changed, 65 insertions(+), 176 deletions(-) diff --git a/packages/inula/src/types.ts b/packages/inula/src/types.ts index 44edf150..1cc6d908 100644 --- a/packages/inula/src/types.ts +++ b/packages/inula/src/types.ts @@ -245,11 +245,10 @@ export type JSXElementConstructor

= | ((props: P) => InulaElement | null) | (new (props: P) => Component); - interface ClassAttributes extends Attributes { - ref : Ref; - key : Key | undefined; - jsx : boolean | undefined; + ref: Ref; + key: Key | undefined; + jsx: boolean | undefined; } //让其他代码在值发生变化时得到通知 interface SignalLike { @@ -258,8 +257,7 @@ interface SignalLike { subscribe(fn: (value: T) => void): () => void; } export type Signalish = T | SignalLike; -export interface DOMAttributes{ - +export interface DOMAttributes { // Image Events onLoad?: GenericEventHandler | undefined; onLoadCapture?: GenericEventHandler | undefined; @@ -302,13 +300,13 @@ export interface DOMAttributes{ onChange?: GenericEventHandler | undefined; onChangeCapture?: GenericEventHandler | undefined; onInput?: FormEventHandler | undefined; - onInputCapture?: FormEventHandler | undefined; + onInputCapture?: FormEventHandler | undefined; onBeforeInput?: FormEventHandler | undefined; onBeforeInputCapture?: FormEventHandler | undefined; onSearch?: GenericEventHandler | undefined; onSearchCapture?: GenericEventHandler | undefined; - onSubmit?: FormEventHandler | undefined; - onSubmitCapture?: FormEventHandler | undefined; + onSubmit?: FormEventHandler | undefined; + onSubmitCapture?: FormEventHandler | undefined; onInvalid?: GenericEventHandler | undefined; onInvalidCapture?: GenericEventHandler | undefined; onReset?: GenericEventHandler | undefined; @@ -472,12 +470,12 @@ export interface DOMAttributes{ onTransitionStartCapture?: TransitionEventHandler; // PictureInPicture Events - onEnterPictureInPicture?: ChangeEventHandler; - onEnterPictureInPictureCapture?: ChangeEventHandler; - onLeavePictureInPicture?: ChangeEventHandler; - onLeavePictureInPictureCapture?: ChangeEventHandler; - onResize?: ChangeEventHandler; - onResizeCapture?: ChangeEventHandler; + onEnterPictureInPicture?: ChangeEventHandler; + onEnterPictureInPictureCapture?: ChangeEventHandler; + onLeavePictureInPicture?: ChangeEventHandler; + onLeavePictureInPictureCapture?: ChangeEventHandler; + onResize?: ChangeEventHandler; + onResizeCapture?: ChangeEventHandler; } export interface AriaAttributes { @@ -489,9 +487,7 @@ export interface AriaAttributes { * Indicates whether inputting text could trigger display of one or more predictions of the user's intended value for an input and specifies how predictions would be * presented if they are made. */ - 'aria-autocomplete'?: Signalish< - 'none' | 'inline' | 'list' | 'both' | undefined - >; + 'aria-autocomplete'?: Signalish<'none' | 'inline' | 'list' | 'both' | undefined>; /** * Defines a string value that labels the current element, which is intended to be converted into Braille. * @see aria-label. @@ -538,9 +534,7 @@ export interface AriaAttributes { */ 'aria-controls'?: Signalish; /** Indicates the element that represents the current item within a container or set of related elements. */ - 'aria-current'?: Signalish< - Booleanish | 'page' | 'step' | 'location' | 'date' | 'time' | undefined - >; + 'aria-current'?: Signalish; /** * Identifies the element (or elements) that describes the object. * @see aria-labelledby @@ -566,9 +560,7 @@ export interface AriaAttributes { * Indicates what functions can be performed when a dragged object is released on the drop target. * @deprecated in ARIA 1.1 */ - 'aria-dropeffect'?: Signalish< - 'none' | 'copy' | 'execute' | 'link' | 'move' | 'popup' | undefined - >; + 'aria-dropeffect'?: Signalish<'none' | 'copy' | 'execute' | 'link' | 'move' | 'popup' | undefined>; /** * Identifies the element that provides an error message for the object. * @see aria-invalid @@ -588,9 +580,7 @@ export interface AriaAttributes { */ 'aria-grabbed'?: Signalish; /** Indicates the availability and type of interactive popup element, such as menu or dialog, that can be triggered by an element. */ - 'aria-haspopup'?: Signalish< - Booleanish | 'menu' | 'listbox' | 'tree' | 'grid' | 'dialog' | undefined - >; + 'aria-haspopup'?: Signalish; /** * Indicates whether the element is exposed to an accessibility API. * @see aria-disabled. @@ -707,9 +697,7 @@ export interface AriaAttributes { */ 'aria-setsize'?: Signalish; /** Indicates if items in a table or grid are sorted in ascending or descending order. */ - 'aria-sort'?: Signalish< - 'none' | 'ascending' | 'descending' | 'other' | undefined - >; + 'aria-sort'?: Signalish<'none' | 'ascending' | 'descending' | 'other' | undefined>; /** Defines the maximum allowed value for a range widget. */ 'aria-valuemax'?: Signalish; /** Defines the minimum allowed value for a range widget. */ @@ -927,24 +915,11 @@ export interface HTMLAttributes defaultChecked?: boolean | undefined | SignalLike; defaultValue?: string | undefined | SignalLike; defer?: boolean | undefined | SignalLike; - dir?: - | 'auto' - | 'rtl' - | 'ltr' - | undefined - | SignalLike<'auto' | 'rtl' | 'ltr' | undefined>; + dir?: 'auto' | 'rtl' | 'ltr' | undefined | SignalLike<'auto' | 'rtl' | 'ltr' | undefined>; disabled?: boolean | undefined | SignalLike; - disableRemotePlayback?: - | boolean - | undefined - | SignalLike; + disableRemotePlayback?: boolean | undefined | SignalLike; download?: any | undefined; - decoding?: - | 'sync' - | 'async' - | 'auto' - | undefined - | SignalLike<'sync' | 'async' | 'auto' | undefined>; + decoding?: 'sync' | 'async' | 'auto' | undefined | SignalLike<'sync' | 'async' | 'auto' | undefined>; draggable?: boolean | undefined | SignalLike; encType?: string | undefined | SignalLike; enctype?: string | undefined | SignalLike; @@ -957,16 +932,7 @@ export interface HTMLAttributes | 'search' | 'send' | undefined - | SignalLike< - | 'enter' - | 'done' - | 'go' - | 'next' - | 'previous' - | 'search' - | 'send' - | undefined - >; + | SignalLike<'enter' | 'done' | 'go' | 'next' | 'previous' | 'search' | 'send' | undefined>; elementTiming?: string | undefined | SignalLike; elementtiming?: HTMLAttributes['elementTiming']; exportparts?: string | undefined | SignalLike; @@ -982,28 +948,11 @@ export interface HTMLAttributes formnovalidate?: boolean | undefined | SignalLike; formTarget?: string | undefined | SignalLike; formtarget?: string | undefined | SignalLike; - frameBorder?: - | number - | string - | undefined - | SignalLike; - frameborder?: - | number - | string - | undefined - | SignalLike; + frameBorder?: number | string | undefined | SignalLike; + frameborder?: number | string | undefined | SignalLike; headers?: string | undefined | SignalLike; - height?: - | number - | string - | undefined - | SignalLike; - hidden?: - | boolean - | 'hidden' - | 'until-found' - | undefined - | SignalLike; + height?: number | string | undefined | SignalLike; + hidden?: boolean | 'hidden' | 'until-found' | undefined | SignalLike; high?: number | undefined | SignalLike; href?: string | undefined | SignalLike; hrefLang?: string | undefined | SignalLike; @@ -1025,11 +974,7 @@ export interface HTMLAttributes label?: string | undefined | SignalLike; lang?: string | undefined | SignalLike; list?: string | undefined | SignalLike; - loading?: - | 'eager' - | 'lazy' - | undefined - | SignalLike<'eager' | 'lazy' | undefined>; + loading?: 'eager' | 'lazy' | undefined | SignalLike<'eager' | 'lazy' | undefined>; loop?: boolean | undefined | SignalLike; low?: number | undefined | SignalLike; manifest?: string | undefined | SignalLike; @@ -1068,18 +1013,8 @@ export interface HTMLAttributes | SignalLike<'auto' | 'hint' | 'manual' | boolean | undefined>; popovertarget?: string | undefined | SignalLike; popoverTarget?: string | undefined | SignalLike; - popovertargetaction?: - | 'hide' - | 'show' - | 'toggle' - | undefined - | SignalLike<'hide' | 'show' | 'toggle' | undefined>; - popoverTargetAction?: - | 'hide' - | 'show' - | 'toggle' - | undefined - | SignalLike<'hide' | 'show' | 'toggle' | undefined>; + popovertargetaction?: 'hide' | 'show' | 'toggle' | undefined | SignalLike<'hide' | 'show' | 'toggle' | undefined>; + popoverTargetAction?: 'hide' | 'show' | 'toggle' | undefined | SignalLike<'hide' | 'show' | 'toggle' | undefined>; poster?: string | undefined | SignalLike; preload?: string | undefined | SignalLike; radioGroup?: string | undefined | SignalLike; @@ -1096,16 +1031,16 @@ export interface HTMLAttributes | 'unsafe-url' | undefined | SignalLike< - | 'no-referrer' - | 'no-referrer-when-downgrade' - | 'origin' - | 'origin-when-cross-origin' - | 'same-origin' - | 'strict-origin' - | 'strict-origin-when-cross-origin' - | 'unsafe-url' - | undefined - >; + | 'no-referrer' + | 'no-referrer-when-downgrade' + | 'origin' + | 'origin-when-cross-origin' + | 'same-origin' + | 'strict-origin' + | 'strict-origin-when-cross-origin' + | 'unsafe-url' + | undefined + >; rel?: string | undefined | SignalLike; required?: boolean | undefined | SignalLike; reversed?: boolean | undefined | SignalLike; @@ -1134,16 +1069,8 @@ export interface HTMLAttributes srcLang?: string | undefined | SignalLike; srclang?: string | undefined | SignalLike; start?: number | undefined | SignalLike; - step?: - | number - | string - | undefined - | SignalLike; - style?: - | string - | CSSProperties - | undefined - | SignalLike; + step?: number | string | undefined | SignalLike; + style?: string | CSSProperties | undefined | SignalLike; summary?: string | undefined | SignalLike; tabIndex?: number | undefined | SignalLike; tabindex?: number | undefined | SignalLike; @@ -1152,22 +1079,9 @@ export interface HTMLAttributes type?: string | undefined | SignalLike; useMap?: string | undefined | SignalLike; usemap?: string | undefined | SignalLike; - value?: - | string - | string[] - | number - | undefined - | SignalLike; - volume?: - | string - | number - | undefined - | SignalLike; - width?: - | number - | string - | undefined - | SignalLike; + value?: string | string[] | number | undefined | SignalLike; + volume?: string | number | undefined | SignalLike; + width?: number | string | undefined | SignalLike; wmode?: string | undefined | SignalLike; wrap?: string | undefined | SignalLike; @@ -1180,15 +1094,7 @@ export interface HTMLAttributes | 'words' | 'characters' | undefined - | SignalLike< - | 'off' - | 'none' - | 'on' - | 'sentences' - | 'words' - | 'characters' - | undefined - >; + | SignalLike<'off' | 'none' | 'on' | 'sentences' | 'words' | 'characters' | undefined>; autoCapitalize?: | 'off' | 'none' @@ -1197,19 +1103,8 @@ export interface HTMLAttributes | 'words' | 'characters' | undefined - | SignalLike< - | 'off' - | 'none' - | 'on' - | 'sentences' - | 'words' - | 'characters' - | undefined - >; - disablePictureInPicture?: - | boolean - | undefined - | SignalLike; + | SignalLike<'off' | 'none' | 'on' | 'sentences' | 'words' | 'characters' | undefined>; + disablePictureInPicture?: boolean | undefined | SignalLike; results?: number | undefined | SignalLike; translate?: boolean | undefined | SignalLike; @@ -1236,12 +1131,11 @@ export interface HTMLAttributes itemref?: string | undefined | SignalLike; } - // eslint-disable-next-line @typescript-eslint/no-namespace export declare namespace JSX { // JSX内在元素的接口,该接口下声明了JSX中的内置标签及其具有的属性,如标签和标签的value属性 interface IntrinsicElements { - // HTML + // HTML a: HTMLAttributes; abbr: HTMLAttributes; address: HTMLAttributes; @@ -1357,38 +1251,35 @@ export declare namespace JSX { var: HTMLAttributes; video: HTMLAttributes; wbr: HTMLAttributes; - } // 该接口声明了类组件中具有的属性 interface IntrinsicClassAttributes { - ref : Ref; - key : any; - + ref: Ref; + key: any; } // 该接口声明了函数式组建中具有的属性 interface IntrinsicAttributes { - key : any; - ref : Ref; + key: any; + ref: Ref; } // 该接口声明了JSX中组件的元素、属性和子元素的类型 interface Element { - type ?: any; - props ?: any; - key?:any; + type?: any; + props?: any; + key?: any; } // 该接口定义了类组件所具有的属性、方法 interface ElementClass { - setState(state: any, callback : () => void): void; - forceUpdate(callback : () => void): void; - render():any; + setState(state: any, callback: () => void): void; + forceUpdate(callback: () => void): void; + render(): any; } // 该接口用于确定组件props中子元素的名称 interface ElementChildrenAttribute { - children?:any; + children?: any; } } - // // --------------------------------- Inula Event Types---------------------------------- // @@ -1554,10 +1445,10 @@ export interface MouseEvent extends UIEven // export type EventHandler> = { bivarianceHack(event: E): void }['bivarianceHack']; -export type TargetedEvent< - Target extends EventTarget = EventTarget, - TypedEvent extends Event = Event -> = Omit & { +export type TargetedEvent = Omit< + TypedEvent, + 'currentTarget' +> & { readonly currentTarget: Target; }; export type ClipboardEventHandler = EventHandler>; @@ -1573,10 +1464,8 @@ export type PointerEventHandler = EventHandler>; export type UIEventHandler = EventHandler>; export type WheelEventHandler = EventHandler>; export type AnimationEventHandler = EventHandler>; -export type TransitionEventHandler = EventHandler> -type GenericEventHandler = ( - event: TargetedEvent -) => void; +export type TransitionEventHandler = EventHandler>; +type GenericEventHandler = (event: TargetedEvent) => void; // // --------------------------------- Css Props---------------------------------- // -- Gitee From 7b7787c1712e22c2a9cf86a6c30bf0728e3b6f61 Mon Sep 17 00:00:00 2001 From: eleliauk <2831336720@qq.com> Date: Tue, 20 Aug 2024 16:06:38 +0800 Subject: [PATCH 04/13] =?UTF-8?q?feat:=E6=96=B0=E5=A2=9E=E5=87=A0=E4=B8=AA?= =?UTF-8?q?=E5=87=BD=E6=95=B0=E7=9A=84=E5=87=BD=E6=95=B0=E9=87=8D=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/inula-cli/externals.d.ts | 1 - packages/inula-intl/babel.config.js | 5 +- packages/inula-intl/rollup.config.js | 2 +- packages/inula-request/babel.config.js | 8 +-- packages/inula-request/rollup.config.js | 23 +++++---- packages/inula/scripts/rollup/build-types.js | 3 ++ packages/inula/src/external/JSXElement.ts | 50 ++++++++++++++++--- .../inula/src/renderer/hooks/HookExternal.ts | 7 +-- packages/inula/src/types.ts | 1 - 9 files changed, 67 insertions(+), 33 deletions(-) diff --git a/packages/inula-cli/externals.d.ts b/packages/inula-cli/externals.d.ts index 2fe4981b..ab03cf87 100644 --- a/packages/inula-cli/externals.d.ts +++ b/packages/inula-cli/externals.d.ts @@ -14,4 +14,3 @@ */ declare module 'crequire'; - diff --git a/packages/inula-intl/babel.config.js b/packages/inula-intl/babel.config.js index 7f94d715..90df52a7 100644 --- a/packages/inula-intl/babel.config.js +++ b/packages/inula-intl/babel.config.js @@ -16,10 +16,7 @@ const { preset } = require('./jest.config'); module.exports = { presets: [ - [ - '@babel/preset-env', - { targets: { node: 'current' } }, - ], + ['@babel/preset-env', { targets: { node: 'current' } }], ['@babel/preset-typescript'], [ '@babel/preset-react', diff --git a/packages/inula-intl/rollup.config.js b/packages/inula-intl/rollup.config.js index 86cd6fb2..e0ed9912 100644 --- a/packages/inula-intl/rollup.config.js +++ b/packages/inula-intl/rollup.config.js @@ -40,7 +40,7 @@ export default { { file: path.resolve(output, 'intl.esm-browser.js'), format: 'esm', - } + }, ], plugins: [ nodeResolve({ diff --git a/packages/inula-request/babel.config.js b/packages/inula-request/babel.config.js index 383563ed..f373490c 100644 --- a/packages/inula-request/babel.config.js +++ b/packages/inula-request/babel.config.js @@ -14,11 +14,5 @@ */ module.exports = { - presets: [ - [ - '@babel/preset-env', - { targets: { node: 'current' }}, - ], - ['@babel/preset-typescript'], - ], + presets: [['@babel/preset-env', { targets: { node: 'current' } }], ['@babel/preset-typescript']], }; diff --git a/packages/inula-request/rollup.config.js b/packages/inula-request/rollup.config.js index e7e32556..b1ad23b7 100644 --- a/packages/inula-request/rollup.config.js +++ b/packages/inula-request/rollup.config.js @@ -21,16 +21,19 @@ import { babel } from '@rollup/plugin-babel'; export default { input: './index.ts', - output: [{ - file: 'dist/inulaRequest.js', - format: 'umd', - exports: 'named', - name: 'inulaRequest', - sourcemap: false, - }, { - file: 'dist/inulaRequest.esm-browser.js', - format: 'esm', - }], + output: [ + { + file: 'dist/inulaRequest.js', + format: 'umd', + exports: 'named', + name: 'inulaRequest', + sourcemap: false, + }, + { + file: 'dist/inulaRequest.esm-browser.js', + format: 'esm', + }, + ], plugins: [ resolve(), commonjs(), diff --git a/packages/inula/scripts/rollup/build-types.js b/packages/inula/scripts/rollup/build-types.js index 66a5e562..ae8a4eaa 100644 --- a/packages/inula/scripts/rollup/build-types.js +++ b/packages/inula/scripts/rollup/build-types.js @@ -42,6 +42,9 @@ function deleteFolder(filePath) { * @param folders {string[]} * @returns {{buildEnd(): void, name: string}} */ +//先明确什么 +//打包出来 +//ut的例子 export function cleanUp(folders) { return { name: 'clean-up', diff --git a/packages/inula/src/external/JSXElement.ts b/packages/inula/src/external/JSXElement.ts index 89a7a3c7..32bafe54 100644 --- a/packages/inula/src/external/JSXElement.ts +++ b/packages/inula/src/external/JSXElement.ts @@ -17,7 +17,19 @@ import { TYPE_COMMON_ELEMENT } from './JSXElementType'; import { getProcessingClassVNode } from '../renderer/GlobalVar'; import { Source } from '../renderer/Types'; import { BELONG_CLASS_VNODE_KEY } from '../renderer/vnode/VNode'; -import { InulaElement, KVObject } from '../types'; +import { + type BasicStateAction, + ChildrenType, + type Dispatch, + DOMAttributes, + HTMLAttributes, + InulaElement, + InulaNode, + JSX, + KVObject, +} from '../types'; +import type { Trigger } from '../renderer/hooks/HookType'; +import { useStateImpl } from '../renderer/hooks/UseStateHook'; /** * vtype 节点的类型,这里固定是element @@ -72,7 +84,7 @@ function mergeDefault(sourceObj, defaultObj) { // ['key', 'ref', '__source', '__self']属性不从setting获取 const keyArray = ['key', 'ref', '__source', '__self']; - +//这个没太懂 todo function buildElement(isClone, type, setting, children) { // setting中的值优先级最高,clone情况下从 type 中取值,创建情况下直接赋值为 null const key = setting && setting.key !== undefined ? String(setting.key) : isClone ? type.key : null; @@ -110,14 +122,41 @@ function buildElement(isClone, type, setting, children) { } // 创建Element结构体,供JSX编译时调用 -export function createElement(type, setting, ...children) { +//type 细节化 todo 参考react +//解决 例如 div a这样的 +export function createElement( + type: string, + setting: { [key: string]: any } | null, + ...children: InulaNode[] +): InulaElement; +//解决元素型 +export function createElement

(type: InulaElement

, setting?: P | null, ...children: InulaNode[]): InulaElement

; + +export function createElement

( + type: string | InulaElement

, + setting?: (P & { children?: InulaNode }) | null, + ...children: InulaNode[] +): InulaElement | InulaElement

{ return buildElement(false, type, setting, children); } +//只传入 element,克隆该元素,返回一个新的 InulaElement。 +export function cloneElement

(element: InulaElement

): InulaElement

; +//传入 element 和 setting,克隆元素并覆盖属性。 +export function cloneElement

(element: InulaElement

, setting: Partial

| null): InulaElement

; +//:传入 element、setting 和 children,克隆元素,覆盖属性并指定新的子节点。 +export function cloneElement

( + element: InulaElement

, + setting: Partial

| null, + ...children: InulaNode[] +): InulaElement

; -export function cloneElement(element, setting, ...children) { +export function cloneElement

( + element: InulaElement

, + setting?: Partial

| null, + ...children: InulaNode[] +): InulaElement

{ return buildElement(true, element, setting, children); } - // 检测结构体是否为合法的Element export function isValidElement

(element: KVObject | null | undefined): element is InulaElement

{ return !!(element && element.vtype === TYPE_COMMON_ELEMENT); @@ -128,6 +167,5 @@ export function jsx(type, setting, key) { if (setting.key === undefined && key !== undefined) { setting.key = key; } - return buildElement(false, type, setting, []); } diff --git a/packages/inula/src/renderer/hooks/HookExternal.ts b/packages/inula/src/renderer/hooks/HookExternal.ts index 44e2dc04..4c84e216 100644 --- a/packages/inula/src/renderer/hooks/HookExternal.ts +++ b/packages/inula/src/renderer/hooks/HookExternal.ts @@ -24,7 +24,7 @@ import { useReducerImpl } from './UseReducerHook'; import { useStateImpl } from './UseStateHook'; import { getNewContext } from '../components/context/Context'; import { getProcessingVNode } from '../GlobalVar'; -import type { MutableRef, RefCallBack, RefObject } from './HookType'; +import type { MutableRef, RefCallBack, RefObject, Trigger } from './HookType'; import type { BasicStateAction, @@ -45,10 +45,11 @@ export function useContext(Context: ContextType | Context): T { export function useState(initialState: (() => S) | S): [S, Dispatch>]; export function useState(): [S | undefined, Dispatch>]; -export function useState(initialState?: (() => S) | S): [S, Dispatch>] { +export function useState( + initialState?: (() => S) | S +): [S | undefined, Trigger<((arg0: S) => S | undefined) | S | undefined>] | void { return useStateImpl(initialState); } - export function useReducer, I>( reducer: R, initialArg: I, diff --git a/packages/inula/src/types.ts b/packages/inula/src/types.ts index 1cc6d908..6067afb0 100644 --- a/packages/inula/src/types.ts +++ b/packages/inula/src/types.ts @@ -1131,7 +1131,6 @@ export interface HTMLAttributes itemref?: string | undefined | SignalLike; } -// eslint-disable-next-line @typescript-eslint/no-namespace export declare namespace JSX { // JSX内在元素的接口,该接口下声明了JSX中的内置标签及其具有的属性,如标签和标签的value属性 interface IntrinsicElements { -- Gitee From a83b7c7828d6d2b02c11043451fbed0cdc91abaf Mon Sep 17 00:00:00 2001 From: eleliauk <2831336720@qq.com> Date: Wed, 28 Aug 2024 13:48:21 +0800 Subject: [PATCH 05/13] =?UTF-8?q?fix:=E8=A1=A5=E5=85=85=E4=B8=80=E4=BA=9Bc?= =?UTF-8?q?reateElement=E5=A4=84=E7=90=86=E7=9A=84=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/inula/scripts/rollup/build-types.js | 22 ++++++++- packages/inula/src/external/JSXElement.ts | 48 ++++++++++++------- .../inula/src/inulax/adapters/reduxReact.ts | 2 +- packages/inula/src/types.ts | 11 +++-- 4 files changed, 58 insertions(+), 25 deletions(-) diff --git a/packages/inula/scripts/rollup/build-types.js b/packages/inula/scripts/rollup/build-types.js index ae8a4eaa..5e5ef6ea 100644 --- a/packages/inula/scripts/rollup/build-types.js +++ b/packages/inula/scripts/rollup/build-types.js @@ -53,7 +53,27 @@ export function cleanUp(folders) { }, }; } +/** + * 自定义插件:处理生成的 .d.ts 文件 + * 例如,移除内部方法或不需要的类型定义。 + * @returns {{writeBundle(): void, name: string}} + */ +function processDTS() { + return { + name: 'process-dts', + writeBundle() { + const dtsFilePath = path.resolve('./build/@types/index.d.ts'); + if (fs.existsSync(dtsFilePath)) { + let dtsContent = fs.readFileSync(dtsFilePath, 'utf-8'); + dtsContent = dtsContent.replace(/^export\s+.*_.*;/gm, ''); + dtsContent = dtsContent.replace(/import\("openinula"\)/g, 'import { InulaNode } from "openinula"'); + // 写回处理后的 .d.ts 文件 + fs.writeFileSync(dtsFilePath, dtsContent, 'utf-8'); + } + }, + }; +} function buildTypeConfig() { return { input: ['./build/@types/index.d.ts'], @@ -61,7 +81,7 @@ function buildTypeConfig() { file: './build/@types/index.d.ts', format: 'es', }, - plugins: [dts(), cleanUp(['./build/@types/'])], + plugins: [dts(), processDTS(), cleanUp(['./build/@types/'])], }; } diff --git a/packages/inula/src/external/JSXElement.ts b/packages/inula/src/external/JSXElement.ts index 32bafe54..8c1f530d 100644 --- a/packages/inula/src/external/JSXElement.ts +++ b/packages/inula/src/external/JSXElement.ts @@ -15,21 +15,13 @@ import { TYPE_COMMON_ELEMENT } from './JSXElementType'; import { getProcessingClassVNode } from '../renderer/GlobalVar'; -import { Source } from '../renderer/Types'; +import { ContextType, Source } from '../renderer/Types'; import { BELONG_CLASS_VNODE_KEY } from '../renderer/vnode/VNode'; -import { - type BasicStateAction, - ChildrenType, - type Dispatch, - DOMAttributes, - HTMLAttributes, - InulaElement, - InulaNode, - JSX, - KVObject, -} from '../types'; -import type { Trigger } from '../renderer/hooks/HookType'; -import { useStateImpl } from '../renderer/hooks/UseStateHook'; +import { Context, ExoticComponent, InulaElement, InulaNode, KVObject, ConsumerProps, ProviderProps } from '../types'; +import { ReduxStoreHandler } from 'src/inulax/adapters/redux'; +import { Subscription } from 'src/inulax/adapters/subscription'; +import { OriginalComponent } from '../inulax/adapters/reduxReact'; +import { MergePropsP } from '../../build'; /** * vtype 节点的类型,这里固定是element @@ -123,17 +115,37 @@ function buildElement(isClone, type, setting, children) { // 创建Element结构体,供JSX编译时调用 //type 细节化 todo 参考react -//解决 例如 div a这样的 +export function createElement

( + //仍然需要修改 MergeProps定义问题 + type: OriginalComponent, + setting?: P | null, + ...children: InulaNode[] +): InulaElement

; + export function createElement( - type: string, + type: ExoticComponent>, + setting: { [p: string]: any } | null, + ...children: InulaNode[] +): InulaElement; + +export function createElement( + type: ExoticComponent>, setting: { [key: string]: any } | null, ...children: InulaNode[] ): InulaElement; -//解决元素型 + +// 重载签名 2:处理 InulaElement 类型 export function createElement

(type: InulaElement

, setting?: P | null, ...children: InulaNode[]): InulaElement

; +// 实现签名:与重载签名一致的实现 export function createElement

( - type: string | InulaElement

, + type: + | string + | InulaElement

+ | ExoticComponent> + | Context<{ store: ReduxStoreHandler; subscription: Subscription }> + | ExoticComponent> + | OriginalComponent, setting?: (P & { children?: InulaNode }) | null, ...children: InulaNode[] ): InulaElement | InulaElement

{ diff --git a/packages/inula/src/inulax/adapters/reduxReact.ts b/packages/inula/src/inulax/adapters/reduxReact.ts index 15badad2..112e1a9f 100644 --- a/packages/inula/src/inulax/adapters/reduxReact.ts +++ b/packages/inula/src/inulax/adapters/reduxReact.ts @@ -113,7 +113,7 @@ export type MergePropsP = ( ) => MergedProps; type WrappedComponent = (props: OwnProps) => ReturnType; -type OriginalComponent = (props: MergedProps) => ReturnType; +export type OriginalComponent = (props: MergedProps) => ReturnType; type Connector = (Component: OriginalComponent) => WrappedComponent; export type ConnectOption = { /** @deprecated */ diff --git a/packages/inula/src/types.ts b/packages/inula/src/types.ts index 6067afb0..9f33947d 100644 --- a/packages/inula/src/types.ts +++ b/packages/inula/src/types.ts @@ -17,7 +17,7 @@ import { Component } from './renderer/components/BaseClassComponent'; import { MutableRef, RefCallBack, RefObject } from './renderer/hooks/HookType'; import * as Event from './EventTypes'; -import Element = JSX.Element; +//import Element = JSX.Element; // // --------------------------------- Inula Base Types ---------------------------------- @@ -56,12 +56,12 @@ export interface ExoticComponent

{ (props: P): InulaElement | null; } -interface ProviderProps { +export interface ProviderProps { value: T; children?: InulaNode | undefined; } -interface ConsumerProps { +export interface ConsumerProps { children: (value: T) => InulaNode; } @@ -1131,9 +1131,10 @@ export interface HTMLAttributes itemref?: string | undefined | SignalLike; } +// eslint-disable-next-line @typescript-eslint/no-namespace export declare namespace JSX { // JSX内在元素的接口,该接口下声明了JSX中的内置标签及其具有的属性,如标签和标签的value属性 - interface IntrinsicElements { + export interface IntrinsicElements { // HTML a: HTMLAttributes; abbr: HTMLAttributes; @@ -1262,7 +1263,7 @@ export declare namespace JSX { ref: Ref; } // 该接口声明了JSX中组件的元素、属性和子元素的类型 - interface Element { + export interface Element { type?: any; props?: any; key?: any; -- Gitee From 2eb981a8015fd85fd50fb86ff7fc235511e39159 Mon Sep 17 00:00:00 2001 From: eleliauk <2831336720@qq.com> Date: Wed, 28 Aug 2024 16:31:37 +0800 Subject: [PATCH 06/13] =?UTF-8?q?fix:=E5=A2=9E=E5=8A=A0=E9=80=82=E9=85=8Di?= =?UTF-8?q?nulax=E7=9A=84createElement=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/inula/scripts/rollup/build-types.js | 1 + packages/inula/src/external/JSXElement.ts | 7 +++---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/inula/scripts/rollup/build-types.js b/packages/inula/scripts/rollup/build-types.js index 5e5ef6ea..940987e8 100644 --- a/packages/inula/scripts/rollup/build-types.js +++ b/packages/inula/scripts/rollup/build-types.js @@ -66,6 +66,7 @@ function processDTS() { if (fs.existsSync(dtsFilePath)) { let dtsContent = fs.readFileSync(dtsFilePath, 'utf-8'); dtsContent = dtsContent.replace(/^export\s+.*_.*;/gm, ''); + //todo 这块如何优化 index.ts 的全部函数 dtsContent = dtsContent.replace(/import\("openinula"\)/g, 'import { InulaNode } from "openinula"'); // 写回处理后的 .d.ts 文件 diff --git a/packages/inula/src/external/JSXElement.ts b/packages/inula/src/external/JSXElement.ts index 8c1f530d..d67e83c5 100644 --- a/packages/inula/src/external/JSXElement.ts +++ b/packages/inula/src/external/JSXElement.ts @@ -15,13 +15,12 @@ import { TYPE_COMMON_ELEMENT } from './JSXElementType'; import { getProcessingClassVNode } from '../renderer/GlobalVar'; -import { ContextType, Source } from '../renderer/Types'; +import { Source } from '../renderer/Types'; import { BELONG_CLASS_VNODE_KEY } from '../renderer/vnode/VNode'; import { Context, ExoticComponent, InulaElement, InulaNode, KVObject, ConsumerProps, ProviderProps } from '../types'; import { ReduxStoreHandler } from 'src/inulax/adapters/redux'; import { Subscription } from 'src/inulax/adapters/subscription'; import { OriginalComponent } from '../inulax/adapters/reduxReact'; -import { MergePropsP } from '../../build'; /** * vtype 节点的类型,这里固定是element @@ -117,7 +116,7 @@ function buildElement(isClone, type, setting, children) { //type 细节化 todo 参考react export function createElement

( //仍然需要修改 MergeProps定义问题 - type: OriginalComponent, + type: OriginalComponent

, setting?: P | null, ...children: InulaNode[] ): InulaElement

; @@ -145,7 +144,7 @@ export function createElement

( | ExoticComponent> | Context<{ store: ReduxStoreHandler; subscription: Subscription }> | ExoticComponent> - | OriginalComponent, + | OriginalComponent

, setting?: (P & { children?: InulaNode }) | null, ...children: InulaNode[] ): InulaElement | InulaElement

{ -- Gitee From a9f4afb46c41879fcc1b03a6da91042bccddde84 Mon Sep 17 00:00:00 2001 From: eleliauk <2831336720@qq.com> Date: Tue, 10 Sep 2024 10:37:55 +0800 Subject: [PATCH 07/13] =?UTF-8?q?fix:jsx=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/inula/src/external/JSXElement.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/inula/src/external/JSXElement.ts b/packages/inula/src/external/JSXElement.ts index d67e83c5..86579ff7 100644 --- a/packages/inula/src/external/JSXElement.ts +++ b/packages/inula/src/external/JSXElement.ts @@ -18,9 +18,9 @@ import { getProcessingClassVNode } from '../renderer/GlobalVar'; import { Source } from '../renderer/Types'; import { BELONG_CLASS_VNODE_KEY } from '../renderer/vnode/VNode'; import { Context, ExoticComponent, InulaElement, InulaNode, KVObject, ConsumerProps, ProviderProps } from '../types'; -import { ReduxStoreHandler } from 'src/inulax/adapters/redux'; -import { Subscription } from 'src/inulax/adapters/subscription'; import { OriginalComponent } from '../inulax/adapters/reduxReact'; +import { ReduxStoreHandler } from '../inulax/adapters/redux'; +import { Subscription } from '../inulax/adapters/subscription'; /** * vtype 节点的类型,这里固定是element @@ -76,7 +76,7 @@ function mergeDefault(sourceObj, defaultObj) { // ['key', 'ref', '__source', '__self']属性不从setting获取 const keyArray = ['key', 'ref', '__source', '__self']; //这个没太懂 todo -function buildElement(isClone, type, setting, children) { +function buildElement(isClone: boolean, type, setting, children: InulaNode[]) { // setting中的值优先级最高,clone情况下从 type 中取值,创建情况下直接赋值为 null const key = setting && setting.key !== undefined ? String(setting.key) : isClone ? type.key : null; const ref = setting && setting.ref !== undefined ? setting.ref : isClone ? type.ref : null; @@ -144,6 +144,7 @@ export function createElement

( | ExoticComponent> | Context<{ store: ReduxStoreHandler; subscription: Subscription }> | ExoticComponent> + // todo MergedProps 接口? | OriginalComponent

, setting?: (P & { children?: InulaNode }) | null, ...children: InulaNode[] @@ -160,7 +161,6 @@ export function cloneElement

( setting: Partial

| null, ...children: InulaNode[] ): InulaElement

; - export function cloneElement

( element: InulaElement

, setting?: Partial

| null, -- Gitee From 90db97b39faa4acc349b1af7c8dc9ef729ad68b2 Mon Sep 17 00:00:00 2001 From: eleliauk <2831336720@qq.com> Date: Mon, 16 Sep 2024 10:36:24 +0800 Subject: [PATCH 08/13] =?UTF-8?q?feat:=E4=BC=98=E5=8C=96=E6=89=93=E5=8C=85?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E5=AF=BC=E5=87=BA=E2=80=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/inula/scripts/rollup/build-types.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/packages/inula/scripts/rollup/build-types.js b/packages/inula/scripts/rollup/build-types.js index 940987e8..ca9c8f53 100644 --- a/packages/inula/scripts/rollup/build-types.js +++ b/packages/inula/scripts/rollup/build-types.js @@ -65,16 +65,30 @@ function processDTS() { const dtsFilePath = path.resolve('./build/@types/index.d.ts'); if (fs.existsSync(dtsFilePath)) { let dtsContent = fs.readFileSync(dtsFilePath, 'utf-8'); + + // 删除所有带有下划线的 export 声明 dtsContent = dtsContent.replace(/^export\s+.*_.*;/gm, ''); - //todo 这块如何优化 index.ts 的全部函数 + + // 替换特定的导入路径 dtsContent = dtsContent.replace(/import\("openinula"\)/g, 'import { InulaNode } from "openinula"'); - // 写回处理后的 .d.ts 文件 + // 处理 .d.ts 文件中所有导出的函数 + dtsContent = dtsContent.replace( + /export\s+(function|const|let|var|type|interface)\s+(\w+)\s*(:|\()/g, + (match, type, name) => { + if (type === 'function') { + return `export function ${name}`; + } + return match; + } + ); fs.writeFileSync(dtsFilePath, dtsContent, 'utf-8'); } }, }; } + +module.exports = processDTS; function buildTypeConfig() { return { input: ['./build/@types/index.d.ts'], -- Gitee From 9935a0f25cb6945723b7a1b2c69c093ff06c15e7 Mon Sep 17 00:00:00 2001 From: eleliauk <2831336720@qq.com> Date: Mon, 23 Sep 2024 14:31:36 +0800 Subject: [PATCH 09/13] =?UTF-8?q?fix:eslint=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/inula/src/inulax/adapters/reduxReact.ts | 2 +- packages/inula/src/types.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/inula/src/inulax/adapters/reduxReact.ts b/packages/inula/src/inulax/adapters/reduxReact.ts index 9c150f87..984d0924 100644 --- a/packages/inula/src/inulax/adapters/reduxReact.ts +++ b/packages/inula/src/inulax/adapters/reduxReact.ts @@ -114,7 +114,7 @@ export type MergePropsP = ( ) => MergedProps; type WrappedComponent = (props: OwnProps & WrapperInnerProps) => ReturnType; -type OriginalComponent = (props: MergedProps) => ReturnType; +export type OriginalComponent = (props: MergedProps) => ReturnType; type Connector = (Component: OriginalComponent) => WrappedComponent; export type ConnectOption = { /** @deprecated */ diff --git a/packages/inula/src/types.ts b/packages/inula/src/types.ts index 9f33947d..ac029df0 100644 --- a/packages/inula/src/types.ts +++ b/packages/inula/src/types.ts @@ -130,7 +130,7 @@ export type RefAttributes = Attributes & { ref?: Ref | null; }; -export type ComponentPropsWithRef = T extends new (props: infer P) => Component +export type ComponentPropsWithRef = T extends new (props: infer P) => Component ? PropsOmitRef

& RefAttributes> : PropsWithRef; -- Gitee From 1fd0ac096306b1f64169adb14cf06a9d8a817043 Mon Sep 17 00:00:00 2001 From: eleliauk <2831336720@qq.com> Date: Thu, 26 Sep 2024 08:29:26 +0800 Subject: [PATCH 10/13] =?UTF-8?q?feat:=E6=95=B4=E5=90=88=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/inula/scripts/rollup/build-types.js | 285 +++- packages/inula/src/external/JSXElement.ts | 139 +- packages/inula/src/jsx-type/baseAttr.ts | 1532 ++++++++++++++++++ packages/inula/src/jsx-type/baseElement.ts | 134 ++ packages/inula/src/jsx-type/index.ts | 463 ++++++ packages/inula/src/types.ts | 1143 +------------ 6 files changed, 2557 insertions(+), 1139 deletions(-) create mode 100644 packages/inula/src/jsx-type/baseAttr.ts create mode 100644 packages/inula/src/jsx-type/baseElement.ts create mode 100644 packages/inula/src/jsx-type/index.ts diff --git a/packages/inula/scripts/rollup/build-types.js b/packages/inula/scripts/rollup/build-types.js index ca9c8f53..c76bbd83 100644 --- a/packages/inula/scripts/rollup/build-types.js +++ b/packages/inula/scripts/rollup/build-types.js @@ -16,6 +16,11 @@ import fs from 'fs'; import path from 'path'; import dts from 'rollup-plugin-dts'; +import { parse } from '@babel/parser'; +import MagicString from 'magic-string'; +import assert from 'node:assert/strict'; + +const LIB_NAME = 'Inula'; function deleteFolder(filePath) { if (fs.existsSync(filePath)) { @@ -42,9 +47,6 @@ function deleteFolder(filePath) { * @param folders {string[]} * @returns {{buildEnd(): void, name: string}} */ -//先明确什么 -//打包出来 -//ut的例子 export function cleanUp(folders) { return { name: 'clean-up', @@ -53,42 +55,265 @@ export function cleanUp(folders) { }, }; } + +/** + * 获取AST语法树节点的名称 + * + * @param node AST语法树节点 + * @returns 节点的名称 + */ +function getNodeName(node) { + if (node.type === 'VariableDeclaration') { + node = node.declarations[0]; + if (!node.id) { + return ''; + } + return node.id.name; + } else if ( + node.type === 'TSTypeAliasDeclaration' || + node.type === 'TSInterfaceDeclaration' || + node.type === 'TSDeclareFunction' || + node.type === 'TSEnumDeclaration' || + node.type === 'ClassDeclaration' || + node.type === 'TSModuleDeclaration' + ) { + if (!node.id) { + return ''; + } + return node.id.name; + } + return ''; +} + +/** + * 判断AST语法树节点是否是Horizon变量节点 + * + * @param node AST语法树节点 + * @returns true 是 false 不是 + */ +function isHorizonVariable(node) { + if (node.type === 'VariableDeclaration') { + let tmpNode = node.declarations[0]; + if (!tmpNode.id) { + return false; + } + let exoprtName = tmpNode.id.name; + if (exoprtName === LIB_NAME) { + return true; + } + } + return false; +} + /** - * 自定义插件:处理生成的 .d.ts 文件 - * 例如,移除内部方法或不需要的类型定义。 - * @returns {{writeBundle(): void, name: string}} + * 为导出的类型节点加上前缀export + * + * @param node AST语法树节点 + * @param isExported 导出的类型名称集合 + * @param hasAliasExport 导出的重命名类型的集合 + * @param magicStr 原始的AST语法树对应的magic对象 + * @param parentDecl 当节点为VariableDeclaration类型的子节点时,该变量代表父亲节点,其他类型该参数不传 */ -function processDTS() { +function processDeclaration(node, isExported, hasAliasExport, magicStr, parentDecl) { + if (!node.id) { + return; + } + assert(node.id.type === 'Identifier'); + const name = node.id.name; + if (name.startsWith('_')) { + return; + } + if (isExported.has(name) && !hasAliasExport.has(name)) { + const start = (parentDecl || node).start; + assert(typeof start === 'number'); + magicStr.prependLeft(start, 'export '); + } +} + +/** + * 生成Horzion的namespace,达到可以Horzion.foo的效果 + * + * @example + * 原始文件内容: + * type foo + * type f001 + * type fooA$1 + * const Horzion { + * version + * } + * export { typeof foo, type f001, type fooA$1 as fooA, default Horzion} + * 修改后的文件内容: + * export type foo + * export type f001 + * type fooA$1 + * declare namespace Horzion { + * export { type foo }; + * export { type f001 }; + * export { type fooA$1 as fooA }; + * } + * export { type fooA$1 as fooA }; + * export default Horzion; + * @returns 修改后的文件内容 + */ +function patchNamespaceType() { return { - name: 'process-dts', - writeBundle() { - const dtsFilePath = path.resolve('./build/@types/index.d.ts'); - if (fs.existsSync(dtsFilePath)) { - let dtsContent = fs.readFileSync(dtsFilePath, 'utf-8'); - - // 删除所有带有下划线的 export 声明 - dtsContent = dtsContent.replace(/^export\s+.*_.*;/gm, ''); - - // 替换特定的导入路径 - dtsContent = dtsContent.replace(/import\("openinula"\)/g, 'import { InulaNode } from "openinula"'); - - // 处理 .d.ts 文件中所有导出的函数 - dtsContent = dtsContent.replace( - /export\s+(function|const|let|var|type|interface)\s+(\w+)\s*(:|\()/g, - (match, type, name) => { - if (type === 'function') { - return `export function ${name}`; + name: 'patch-types', + renderChunk(code) { + const magicCodeStr = new MagicString(code); + const ast = parse(code, { + plugins: ['typescript'], + sourceType: 'module', + }); + + const exportedSet = new Set(); + const hasAliasExportMap = new Map(); + const aliasTypeArr = []; + const exportTypeArr = []; + const moduleSet = new Set(); + + /** + * 第一部分: 遍历AST语法树获取所有的导出的类型名称放入isExported + * 获取所有的声明的namespace的名称放入moduleArr + * + * @example + * export { typeof foo } 会将foo放入isExported + * delcare namespace foo1 {} 会将foo1放入moduleArr + */ + for (const node of ast.program.body) { + if (node.type === 'TSModuleDeclaration') { + moduleSet.add(getNodeName(node)); + } + if (node.type === 'ExportNamedDeclaration' && !node.source) { + for (let i = 0; i < node.specifiers.length; i++) { + const spec = node.specifiers[i]; + if (spec.type === 'ExportSpecifier') { + exportedSet.add(spec.local.name); } - return match; } - ); - fs.writeFileSync(dtsFilePath, dtsContent, 'utf-8'); + } } + + /** + * 第二部分:遍历AST语法树 ,去除最后的export声明部分,并且删除Horizon变量的声明 + * 将除了namespace的导出声明外的所有导出类型放入exportTypeArr + * 将所有被重名的导出类型的名称放入aliasTypeArr + * 将所有被重名的导出类型的名称和别名放入hasAliasExport,key是类型的名称 value是导出类型的别名 + */ + for (const node of ast.program.body) { + if (node.type === 'VariableDeclaration') { + if (isHorizonVariable(node)) { + // 不导出Horizon变量,需要将Horizon的变量重命名为namespace + assert(typeof node.start === 'number'); + assert(typeof node.end === 'number'); + magicCodeStr.remove(node.start, node.end); + } + } else if (node.type === 'ExportNamedDeclaration' && !node.source) { + for (let i = 0; i < node.specifiers.length; i++) { + const spec = node.specifiers[i]; + if (spec.type === 'ExportSpecifier' && spec.local.name !== LIB_NAME) { + assert(spec.exported.type === 'Identifier'); + const exported = spec.exported.name; + if (!moduleSet.has(spec.local.name)) { + /** + * @example + * type foo + * namespace foo1{} + * export {type foo , foo1} + * + * 最后放入到exportTypeArr中的为type foo字符串 + */ + exportTypeArr.push(magicCodeStr.slice(spec.start, spec.end)); + } + if (exported !== spec.local.name) { + /** + * @example + * type foo + * type foo1 + * export {type foo as fooalias, type foo1} + * + * 最后放入aliasTypeArr为type foo as fooalias + * 放入hasAliasExport的key为foo, value为fooalias + */ + aliasTypeArr.push(magicCodeStr.slice(spec.start, spec.end)); + hasAliasExportMap.set(spec.local.name, exported); + } + } + } + assert(typeof node.start === 'number'); + assert(typeof node.end === 'number'); + magicCodeStr.remove(node.start, node.end); + } + } + + /** + * 第三部分:遍历AST语法树为所有需要导出的类型加上前缀 export + * + * @example + * + * type foo + * + * @returns + * + * export type foo + */ + for (const node of ast.program.body) { + if (node.type === 'VariableDeclaration') { + if (isHorizonVariable(node)) { + continue; + } + processDeclaration(node.declarations[0], exportedSet, hasAliasExportMap, magicCodeStr, node); + if (node.declarations.length > 1) { + assert(typeof node.start === 'number'); + assert(typeof node.end === 'number'); + throw new Error( + `unhandled declare const with more than one declarators:\n${code.slice(node.start, node.end)}` + ); + } + } else if ( + node.type === 'TSTypeAliasDeclaration' || + node.type === 'TSInterfaceDeclaration' || + node.type === 'TSDeclareFunction' || + node.type === 'TSEnumDeclaration' || + node.type === 'ClassDeclaration' || + node.type === 'TSModuleDeclaration' + ) { + processDeclaration(node, exportedSet, hasAliasExportMap, magicCodeStr); + } + } + + /** + * 第四部分:拼接名称为${HORIZON_NAME} 的namespace,并将它作为默认导出类型 + * 将所有的重命名的导出类型添加到末尾 + * + * @example + * + * 结果示例如下 + * export typeof foo + * export typeof foo$1 + * declare namespace Horizon { + * export {typeof foo} + * export {typeof foo$1 as fooalias} + * } + * + * export {typeof foo$1 as fooalias} + * export default Horizon + */ + magicCodeStr.append(`declare namespace ${LIB_NAME} {\n`); + exportTypeArr.forEach(ele => { + magicCodeStr.append(` export { ${ele} };\n`); + }); + magicCodeStr.append('}\n'); + aliasTypeArr.forEach(ele => { + magicCodeStr.append(`export { ${ele} };\n`); + }); + magicCodeStr.append(`export default ${LIB_NAME};`); + + code = magicCodeStr.toString(); + return code; }, }; } -module.exports = processDTS; function buildTypeConfig() { return { input: ['./build/@types/index.d.ts'], @@ -96,7 +321,7 @@ function buildTypeConfig() { file: './build/@types/index.d.ts', format: 'es', }, - plugins: [dts(), processDTS(), cleanUp(['./build/@types/'])], + plugins: [dts(), patchNamespaceType(), cleanUp(['./build/@types/'])], }; } diff --git a/packages/inula/src/external/JSXElement.ts b/packages/inula/src/external/JSXElement.ts index 86579ff7..5f55e6b0 100644 --- a/packages/inula/src/external/JSXElement.ts +++ b/packages/inula/src/external/JSXElement.ts @@ -17,10 +17,30 @@ import { TYPE_COMMON_ELEMENT } from './JSXElementType'; import { getProcessingClassVNode } from '../renderer/GlobalVar'; import { Source } from '../renderer/Types'; import { BELONG_CLASS_VNODE_KEY } from '../renderer/vnode/VNode'; -import { Context, ExoticComponent, InulaElement, InulaNode, KVObject, ConsumerProps, ProviderProps } from '../types'; -import { OriginalComponent } from '../inulax/adapters/reduxReact'; -import { ReduxStoreHandler } from '../inulax/adapters/redux'; -import { Subscription } from '../inulax/adapters/subscription'; +import { + Attributes, + ClassAttributes, + ClassType, + ClassicComponent, + ClassicComponentClass, + ComponentClass, + ComponentState, + FunctionComponentElement, + InulaCElement, + InulaElement, + InulaNode, + KVObject, +} from '../types'; +import { Component } from '../renderer/components/BaseClassComponent'; +import { DOMAttributes, HTMLAttributes, InputHTMLAttributes, SVGAttributes } from '../jsx-type/baseAttr'; +import { + DOMElement, + DetailedInulaHTMLElement, + InulaHTML, + InulaHTMLElement, + InulaSVG, + InulaSVGElement, +} from '../jsx-type'; /** * vtype 节点的类型,这里固定是element @@ -75,8 +95,8 @@ function mergeDefault(sourceObj, defaultObj) { // ['key', 'ref', '__source', '__self']属性不从setting获取 const keyArray = ['key', 'ref', '__source', '__self']; -//这个没太懂 todo -function buildElement(isClone: boolean, type, setting, children: InulaNode[]) { + +function buildElement(isClone, type, setting, children) { // setting中的值优先级最高,clone情况下从 type 中取值,创建情况下直接赋值为 null const key = setting && setting.key !== undefined ? String(setting.key) : isClone ? type.key : null; const ref = setting && setting.ref !== undefined ? setting.ref : isClone ? type.ref : null; @@ -112,62 +132,86 @@ function buildElement(isClone: boolean, type, setting, children: InulaNode[]) { return JSXElement(element, key, ref, vNode, props, src); } -// 创建Element结构体,供JSX编译时调用 -//type 细节化 todo 参考react -export function createElement

( - //仍然需要修改 MergeProps定义问题 - type: OriginalComponent

, - setting?: P | null, +export function createElement( + type: 'input', + props?: (InputHTMLAttributes & ClassAttributes) | null, ...children: InulaNode[] -): InulaElement

; +): DetailedInulaHTMLElement, HTMLInputElement>; -export function createElement( - type: ExoticComponent>, - setting: { [p: string]: any } | null, +export function createElement

, T extends HTMLElement>( + type: keyof InulaHTML, + props?: (ClassAttributes & P) | null, ...children: InulaNode[] -): InulaElement; +): DetailedInulaHTMLElement; -export function createElement( - type: ExoticComponent>, - setting: { [key: string]: any } | null, +export function createElement

, T extends SVGElement>( + type: keyof InulaSVG, + props?: (ClassAttributes & P) | null, ...children: InulaNode[] -): InulaElement; - -// 重载签名 2:处理 InulaElement 类型 -export function createElement

(type: InulaElement

, setting?: P | null, ...children: InulaNode[]): InulaElement

; - -// 实现签名:与重载签名一致的实现 -export function createElement

( - type: - | string - | InulaElement

- | ExoticComponent> - | Context<{ store: ReduxStoreHandler; subscription: Subscription }> - | ExoticComponent> - // todo MergedProps 接口? - | OriginalComponent

, - setting?: (P & { children?: InulaNode }) | null, +): InulaSVGElement; + +export function createElement

, T extends Element>( + type: string, + props?: (ClassAttributes & P) | null, + ...children: InulaNode[] +): DOMElement; + +export function createElement

( + type: ClassType, ClassicComponentClass

>, + props?: (ClassAttributes> & P) | null, ...children: InulaNode[] -): InulaElement | InulaElement

{ +): InulaCElement>; +export function createElement

, C extends ComponentClass

>( + type: ClassType, + props?: (ClassAttributes & P) | null, + ...children: InulaNode[] +): InulaCElement; + +// 创建Element结构体,供JSX编译时调用 +export function createElement(type, setting, ...children) { return buildElement(false, type, setting, children); } -//只传入 element,克隆该元素,返回一个新的 InulaElement。 -export function cloneElement

(element: InulaElement

): InulaElement

; -//传入 element 和 setting,克隆元素并覆盖属性。 -export function cloneElement

(element: InulaElement

, setting: Partial

| null): InulaElement

; -//:传入 element、setting 和 children,克隆元素,覆盖属性并指定新的子节点。 + +export function cloneElement

, T extends HTMLElement>( + element: DetailedInulaHTMLElement, + props?: P, + ...children: InulaNode[] +): DetailedInulaHTMLElement; +export function cloneElement

, T extends HTMLElement>( + element: InulaHTMLElement, + props?: P, + ...children: InulaNode[] +): InulaHTMLElement; +export function cloneElement

, T extends SVGElement>( + element: InulaSVGElement, + props?: P, + ...children: InulaNode[] +): InulaSVGElement; +export function cloneElement

, T extends Element>( + element: DOMElement, + props?: DOMAttributes & P, + ...children: InulaNode[] +): DOMElement; export function cloneElement

( - element: InulaElement

, - setting: Partial

| null, + element: FunctionComponentElement

, + props?: Partial

& Attributes, ...children: InulaNode[] -): InulaElement

; +): FunctionComponentElement

; +export function cloneElement>( + element: InulaCElement, + props?: Partial

& ClassAttributes, + ...children: InulaNode[] +): InulaCElement; export function cloneElement

( element: InulaElement

, - setting?: Partial

| null, + props?: Partial

& Attributes, ...children: InulaNode[] -): InulaElement

{ +): InulaElement

; + +export function cloneElement(element, setting, ...children) { return buildElement(true, element, setting, children); } + // 检测结构体是否为合法的Element export function isValidElement

(element: KVObject | null | undefined): element is InulaElement

{ return !!(element && element.vtype === TYPE_COMMON_ELEMENT); @@ -178,5 +222,6 @@ export function jsx(type, setting, key) { if (setting.key === undefined && key !== undefined) { setting.key = key; } + return buildElement(false, type, setting, []); } diff --git a/packages/inula/src/jsx-type/baseAttr.ts b/packages/inula/src/jsx-type/baseAttr.ts new file mode 100644 index 00000000..c7408125 --- /dev/null +++ b/packages/inula/src/jsx-type/baseAttr.ts @@ -0,0 +1,1532 @@ +/* + * Copyright (c) 2024 Huawei Technologies Co.,Ltd. + * + * openInula is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + */ + +import { + InulaAnimationEventHandler, + InulaChangeEventHandler, + ClassAttributes, + InulaClipboardEventHandler, + InulaCompositionEventHandler, + InulaDragEventHandler, + InulaFocusEventHandler, + InulaEventHandler, + InulaBoolean, + InulaCSSProperties, + InulaNode, + KVObject, + InulaKeyboardEventHandler, + InulaMouseEventHandler, + InulaPointerEventHandler, + InulaTouchEventHandler, + InulaTransitionEventHandler, + InulaUIEventHandler, + InulaWheelEventHandler, + InulaFormEventHandler, +} from '../types'; + +type HTMLAttributeReferrerPolicy = + | '' + | 'no-referrer' + | 'no-referrer-when-downgrade' + | 'origin' + | 'origin-when-cross-origin' + | 'same-origin' + | 'strict-origin' + | 'strict-origin-when-cross-origin' + | 'unsafe-url'; + +type HTMLAttributeAnchorTarget = '_self' | '_blank' | '_parent' | '_top' | (string & KVObject); + +type AriaRole = + // 文档结构角色 + | 'article' + | 'cell' + | 'columnheader' + | 'definition' + | 'directory' + | 'document' + | 'feed' + | 'figure' + | 'group' + | 'heading' + | 'img' + | 'list' + | 'listitem' + | 'math' + | 'none' + | 'note' + | 'presentation' + | 'row' + | 'rowgroup' + | 'rowheader' + | 'separator' + | 'term' + + // 小部件角色 + | 'alert' + | 'alertdialog' + | 'button' + | 'checkbox' + | 'dialog' + | 'gridcell' + | 'link' + | 'log' + | 'marquee' + | 'menuitem' + | 'menuitemcheckbox' + | 'menuitemradio' + | 'option' + | 'progressbar' + | 'radio' + | 'scrollbar' + | 'searchbox' + | 'slider' + | 'spinbutton' + | 'status' + | 'switch' + | 'tab' + | 'tabpanel' + | 'textbox' + | 'timer' + | 'tooltip' + | 'treeitem' + + // 复合小部件角色 + | 'combobox' + | 'grid' + | 'listbox' + | 'menu' + | 'menubar' + | 'radiogroup' + | 'tablist' + | 'tree' + | 'treegrid' + + // 地标角色 + | 'application' + | 'banner' + | 'complementary' + | 'contentinfo' + | 'form' + | 'main' + | 'navigation' + | 'region' + | 'search' + + // 实时区域角色 + | 'status' + | 'timer' + + // 窗口角色 + | 'alertdialog' + | 'dialog' + + // 通用角色 + | 'toolbar' + | 'table' + + // 允许自定义角色 + | (string & KVObject); + +export interface InulaSVGProps extends SVGAttributes, ClassAttributes {} + +export interface AudioHTMLAttributes extends MediaHTMLAttributes {} + +export interface AnchorHTMLAttributes extends HTMLAttributes { + // 链接目标相关属性 + download?: any; + href?: string; + hrefLang?: string; + target?: HTMLAttributeAnchorTarget; + + // 媒体相关属性 + media?: string; + ping?: string; + + // 链接关系和类型属性 + rel?: string; + type?: string; + + // 安全相关属性 + referrerPolicy?: HTMLAttributeReferrerPolicy; +} + +interface MediaHTMLAttributes extends HTMLAttributes { + // 媒体控制属性 + autoPlay?: boolean; + controls?: boolean; + controlsList?: string; + loop?: boolean; + muted?: boolean; + + // 媒体源属性 + src?: string; + crossOrigin?: string; + + // 媒体组属性 + mediaGroup?: string; + + // 预加载和播放设置 + preload?: string; + playsInline?: boolean; +} + +export interface MetaHTMLAttributes extends HTMLAttributes { + charSet?: string; + content?: string; + httpEquiv?: string; + name?: string; + media?: string; +} + +export interface MeterHTMLAttributes extends HTMLAttributes { + // 值和范围属性 + value?: string | ReadonlyArray | number; + min?: number | string; + max?: number | string; + low?: number; + high?: number; + optimum?: number; + + // 表单关联属性 + form?: string; +} + +export interface QuoteHTMLAttributes extends HTMLAttributes { + cite?: string; +} + +export interface ObjectHTMLAttributes extends HTMLAttributes { + // 数据源属性 + classID?: string; + data?: string; + type?: string; + + // 尺寸属性 + width?: number | string; + height?: number | string; + + // 表单相关属性 + form?: string; + name?: string; + + // 其他属性 + useMap?: string; + wmode?: string; +} + +export interface OlHTMLAttributes extends HTMLAttributes { + reversed?: boolean; + start?: number; + type?: '1' | 'a' | 'A' | 'i' | 'I'; +} + +export interface OptgroupHTMLAttributes extends HTMLAttributes { + disabled?: boolean; + label?: string; +} + +export interface OptionHTMLAttributes extends HTMLAttributes { + disabled?: boolean; + label?: string; + selected?: boolean; + value?: string | ReadonlyArray | number; +} + +export interface OutputHTMLAttributes extends HTMLAttributes { + form?: string; + htmlFor?: string; + name?: string; +} + +export interface ParamHTMLAttributes extends HTMLAttributes { + name?: string; + value?: string | ReadonlyArray | number; +} + +export interface ProgressHTMLAttributes extends HTMLAttributes { + max?: number | string; + value?: string | ReadonlyArray | number; +} + +export interface SlotHTMLAttributes extends HTMLAttributes { + name?: string; +} + +export interface ScriptHTMLAttributes extends HTMLAttributes { + // 脚本加载和执行属性 + async?: boolean; + defer?: boolean; + src?: string; + type?: string; + + // 完整性和安全属性 + integrity?: string; + nonce?: string; + crossOrigin?: string; + + // 模块相关属性 + noModule?: boolean; + + // 引用策略 + referrerPolicy?: HTMLAttributeReferrerPolicy; + + /** @deprecated */ + charSet?: string; +} + +export interface SelectHTMLAttributes extends HTMLAttributes { + // 基本属性 + autoComplete?: string; + name?: string; + + // 状态属性 + disabled?: boolean; + required?: boolean; + + // 多选属性 + multiple?: boolean; + + // 尺寸属性 + size?: number; + + // 表单关联 + form?: string; + + // 值属性 + value?: string | ReadonlyArray | number; + + // 焦点属性 + autoFocus?: boolean; + + // 事件处理 + onChange?: InulaChangeEventHandler; +} + +export interface SourceHTMLAttributes extends HTMLAttributes { + height?: number | string; + media?: string; + sizes?: string; + src?: string; + srcSet?: string; + type?: string; + width?: number | string; +} + +export interface StyleHTMLAttributes extends HTMLAttributes { + media?: string; + nonce?: string; + scoped?: boolean; + type?: string; +} + +export interface TableHTMLAttributes extends HTMLAttributes { + cellPadding?: number | string; + cellSpacing?: number | string; + summary?: string; + width?: number | string; +} + +export interface TextareaHTMLAttributes extends HTMLAttributes { + // 基本属性 + autoComplete?: string; + name?: string; + placeholder?: string; + + // 状态属性 + disabled?: boolean; + readOnly?: boolean; + required?: boolean; + + // 尺寸属性 + cols?: number; + rows?: number; + wrap?: string; + + // 焦点属性 + autoFocus?: boolean; + + // 内容限制属性 + maxLength?: number; + minLength?: number; + + // 方向属性 + dirName?: string; + + // 表单关联 + form?: string; + + // 值属性 + value?: string | ReadonlyArray | number; + + // 事件处理 + onChange?: InulaChangeEventHandler; +} + +export interface ThHTMLAttributes extends HTMLAttributes { + align?: 'left' | 'center' | 'right' | 'justify' | 'char'; + colSpan?: number; + headers?: string; + rowSpan?: number; + scope?: string; + abbr?: string; +} + +export interface TimeHTMLAttributes extends HTMLAttributes { + dateTime?: string; +} + +export interface TrackHTMLAttributes extends HTMLAttributes { + default?: boolean; + kind?: string; + label?: string; + src?: string; + srcLang?: string; +} + +export interface VideoHTMLAttributes extends MediaHTMLAttributes { + height?: number | string; + playsInline?: boolean; + poster?: string; + width?: number | string; + disablePictureInPicture?: boolean; + disableRemotePlayback?: boolean; +} + +export interface TdHTMLAttributes extends HTMLAttributes { + // 对齐和布局属性 + align?: 'left' | 'center' | 'right' | 'justify' | 'char'; + valign?: 'top' | 'middle' | 'bottom' | 'baseline'; + + // 单元格跨度属性 + colSpan?: number; + rowSpan?: number; + + // 表头关联属性 + headers?: string; + scope?: string; + + // 尺寸属性 + height?: number | string; + width?: number | string; + + abbr?: string; +} + +export interface SVGAttributes extends AriaAttributes, DOMAttributes { + // 核心属性 + id?: string; + lang?: string; + tabIndex?: number; + role?: AriaRole; + + // 样式相关属性 + className?: string; + style?: InulaCSSProperties; + + // 尺寸和位置属性 + height?: number | string; + width?: number | string; + x?: number | string; + y?: number | string; + + // 颜色和填充属性 + color?: string; + fill?: string; + fillOpacity?: number | string; + fillRule?: 'nonzero' | 'evenodd' | 'inherit'; + stroke?: string; + strokeDasharray?: string | number; + strokeDashoffset?: string | number; + strokeLinecap?: 'butt' | 'round' | 'square' | 'inherit'; + strokeLinejoin?: 'miter' | 'round' | 'bevel' | 'inherit'; + strokeMiterlimit?: number | string; + strokeOpacity?: number | string; + strokeWidth?: number | string; + + // 变换属性 + transform?: string; + + // 文本相关属性 + fontFamily?: string; + fontSize?: number | string; + textAnchor?: string; + + // 渐变相关属性 + gradientTransform?: string; + gradientUnits?: string; + + // 其他通用属性 + clipPath?: string; + clipRule?: number | string; + cursor?: number | string; + display?: number | string; + filter?: string; + mask?: string; + opacity?: number | string; + pointerEvents?: number | string; + visibility?: number | string; + + // SVG特定属性 + accentHeight?: number | string; + accumulate?: 'none' | 'sum'; + additive?: 'replace' | 'sum'; + alignmentBaseline?: + | 'auto' + | 'baseline' + | 'before-edge' + | 'text-before-edge' + | 'middle' + | 'central' + | 'after-edge' + | 'text-after-edge' + | 'ideographic' + | 'alphabetic' + | 'hanging' + | 'mathematical' + | 'inherit'; + allowReorder?: 'no' | 'yes'; + alphabetic?: number | string; + amplitude?: number | string; + arabicForm?: 'initial' | 'medial' | 'terminal' | 'isolated'; + ascent?: number | string; + attributeName?: string; + attributeType?: string; + autoReverse?: InulaBoolean; + azimuth?: number | string; + baseFrequency?: number | string; + baselineShift?: number | string; + baseProfile?: number | string; + bbox?: number | string; + begin?: number | string; + bias?: number | string; + by?: number | string; + calcMode?: number | string; + capHeight?: number | string; + clip?: number | string; + clipPathUnits?: number | string; + colorInterpolation?: number | string; + colorInterpolationFilters?: 'auto' | 'sRGB' | 'linearRGB' | 'inherit'; + colorProfile?: number | string; + colorRendering?: number | string; + contentScriptType?: number | string; + contentStyleType?: number | string; + diffuseConstant?: number | string; + direction?: number | string; + divisor?: number | string; + dominantBaseline?: number | string; + dur?: number | string; + dx?: number | string; + dy?: number | string; + edgeMode?: number | string; + elevation?: number | string; + enableBackground?: number | string; + end?: number | string; + exponent?: number | string; + externalResourcesRequired?: InulaBoolean; + filterRes?: number | string; + filterUnits?: number | string; + floodColor?: number | string; + floodOpacity?: number | string; + focusable?: InulaBoolean | 'auto'; + fontSizeAdjust?: number | string; + fontStretch?: number | string; + fontStyle?: number | string; + fontVariant?: number | string; + fontWeight?: number | string; + format?: number | string; + from?: number | string; + g1?: number | string; + g2?: number | string; + glyphName?: number | string; + glyphOrientationHorizontal?: number | string; + glyphOrientationVertical?: number | string; + fx?: number | string; + fy?: number | string; + glyphRef?: number | string; + hanging?: number | string; + horizAdvX?: number | string; + horizOriginX?: number | string; + href?: string; + ideographic?: number | string; + imageRendering?: number | string; + in2?: number | string; + in?: string; + intercept?: number | string; + k?: number | string; + k1?: number | string; + k2?: number | string; + k3?: number | string; + k4?: number | string; + kernelMatrix?: number | string; + kernelUnitLength?: number | string; + kerning?: number | string; + keyPoints?: number | string; + keySplines?: number | string; + keyTimes?: number | string; + lengthAdjust?: number | string; + letterSpacing?: number | string; + lightingColor?: number | string; + limitingConeAngle?: number | string; + local?: number | string; + markerEnd?: string; + markerHeight?: number | string; + markerMid?: string; + markerStart?: string; + markerUnits?: number | string; + markerWidth?: number | string; + maskContentUnits?: number | string; + maskUnits?: number | string; + mathematical?: number | string; + mode?: number | string; + numOctaves?: number | string; + offset?: number | string; + operator?: number | string; + order?: number | string; + orient?: number | string; + orientation?: number | string; + origin?: number | string; + overflow?: number | string; + overlinePosition?: number | string; + overlineThickness?: number | string; + paintOrder?: number | string; + panose1?: number | string; + path?: string; + pathLength?: number | string; + patternContentUnits?: string; + patternTransform?: number | string; + patternUnits?: string; + points?: string; + pointsAtX?: number | string; + pointsAtY?: number | string; + pointsAtZ?: number | string; + preserveAlpha?: InulaBoolean; + preserveAspectRatio?: string; + primitiveUnits?: number | string; + r?: number | string; + radius?: number | string; + refX?: number | string; + refY?: number | string; + renderingIntent?: number | string; + repeatCount?: number | string; + repeatDur?: number | string; + requiredExtensions?: number | string; + requiredFeatures?: number | string; + rx?: number | string; + ry?: number | string; + restart?: number | string; + result?: string; + rotate?: number | string; + scale?: number | string; + seed?: number | string; + shapeRendering?: number | string; + specularConstant?: number | string; + specularExponent?: number | string; + slope?: number | string; + spacing?: number | string; + speed?: number | string; + spreadMethod?: string; + startOffset?: number | string; + stdDeviation?: number | string; + stopColor?: string; + stopOpacity?: number | string; + stemh?: number | string; + stemv?: number | string; + stitchTiles?: number | string; + strikethroughPosition?: number | string; + strikethroughThickness?: number | string; + string?: number | string; + surfaceScale?: number | string; + systemLanguage?: number | string; + targetX?: number | string; + targetY?: number | string; + tableValues?: number | string; + textDecoration?: number | string; + textLength?: number | string; + textRendering?: number | string; + to?: number | string; + underlinePosition?: number | string; + underlineThickness?: number | string; + u1?: number | string; + u2?: number | string; + unicode?: number | string; + unicodeBidi?: number | string; + unicodeRange?: number | string; + unitsPerEm?: number | string; + vertOriginX?: number | string; + vertOriginY?: number | string; + vAlphabetic?: number | string; + values?: string; + vectorEffect?: number | string; + version?: string; + vertAdvY?: number | string; + vHanging?: number | string; + vIdeographic?: number | string; + viewBox?: string; + viewTarget?: number | string; + vMathematical?: number | string; + widths?: number | string; + wordSpacing?: number | string; + writingMode?: number | string; + x1?: number | string; + x2?: number | string; + xChannelSelector?: string; + xHeight?: number | string; + xlinkActuate?: string; + xlinkArcrole?: string; + xlinkHref?: string; + xlinkRole?: string; + xlinkShow?: string; + xlinkTitle?: string; + xlinkType?: string; + xmlBase?: string; + xmlLang?: string; + xmlns?: string; + xmlnsXlink?: string; + xmlSpace?: string; + y1?: number | string; + y2?: number | string; + yChannelSelector?: string; + z?: number | string; + zoomAndPan?: string; +} + +export interface WebViewHTMLAttributes extends HTMLAttributes { + // 源和内容属性 + src?: string; + httpreferrer?: string; + useragent?: string; + + // 功能和安全属性 + allowFullScreen?: boolean; + allowpopups?: boolean; + autoFocus?: boolean; + autosize?: boolean; + blinkfeatures?: string; + disableblinkfeatures?: string; + disableguestresize?: boolean; + disablewebsecurity?: boolean; + guestinstance?: string; + nodeintegration?: boolean; + partition?: string; + plugins?: boolean; + preload?: string; + webpreferences?: string; +} + +export interface AreaHTMLAttributes extends HTMLAttributes { + // 链接属性 + alt?: string; + coords?: string; + download?: any; + href?: string; + hrefLang?: string; + media?: string; + rel?: string; + shape?: string; + target?: string; + + // 安全属性 + referrerPolicy?: HTMLAttributeReferrerPolicy; +} + +export interface BaseHTMLAttributes extends HTMLAttributes { + href?: string; + target?: string; +} + +export interface BlockquoteHTMLAttributes extends HTMLAttributes { + cite?: string; +} + +export interface ButtonHTMLAttributes extends HTMLAttributes { + // 基本属性 + autoFocus?: boolean; + disabled?: boolean; + name?: string; + type?: 'submit' | 'reset' | 'button'; + value?: string | ReadonlyArray | number; + + // 表单关联属性 + form?: string; + formAction?: string; + formEncType?: string; + formMethod?: string; + formNoValidate?: boolean; + formTarget?: string; +} + +export interface CanvasHTMLAttributes extends HTMLAttributes { + height?: number | string; + width?: number | string; +} + +export interface ColHTMLAttributes extends HTMLAttributes { + span?: number; + width?: number | string; +} + +export interface ColgroupHTMLAttributes extends HTMLAttributes { + span?: number; +} + +export interface DataHTMLAttributes extends HTMLAttributes { + value?: string | ReadonlyArray | number; +} + +export interface DetailsHTMLAttributes extends HTMLAttributes { + open?: boolean; + onToggle?: InulaEventHandler; +} + +export interface DelHTMLAttributes extends HTMLAttributes { + cite?: string; + dateTime?: string; +} + +export interface DialogHTMLAttributes extends HTMLAttributes { + open?: boolean; +} + +export interface EmbedHTMLAttributes extends HTMLAttributes { + height?: number | string; + src?: string; + type?: string; + width?: number | string; +} + +export interface FieldsetHTMLAttributes extends HTMLAttributes { + disabled?: boolean; + form?: string; + name?: string; +} + +export interface FormHTMLAttributes extends HTMLAttributes { + // 表单提交属性 + action?: string; + method?: string; + target?: string; + + // 表单编码属性 + acceptCharset?: string; + encType?: string; + + // 表单行为属性 + autoComplete?: string; + name?: string; + noValidate?: boolean; +} + +export interface HtmlHTMLAttributes extends HTMLAttributes { + manifest?: string; +} + +export interface IframeHTMLAttributes extends HTMLAttributes { + // 内容源属性 + src?: string; + srcDoc?: string; + + // 安全属性 + sandbox?: string; + allow?: string; + allowFullScreen?: boolean; + allowTransparency?: boolean; + referrerPolicy?: HTMLAttributeReferrerPolicy; + + // 尺寸属性 + width?: number | string; + height?: number | string; + + // 加载行为属性 + loading?: 'eager' | 'lazy'; + name?: string; + /** @deprecated */ + frameBorder?: number | string; + /** @deprecated */ + marginHeight?: number; + /** @deprecated */ + marginWidth?: number; + /** @deprecated */ + scrolling?: string; + + seamless?: boolean; +} + +export interface ImgHTMLAttributes extends HTMLAttributes { + // 基本源属性 + alt?: string; + src?: string; + + // 响应式图像属性 + srcSet?: string; + sizes?: string; + + // 跨域和引用策略 + crossOrigin?: 'anonymous' | 'use-credentials' | ''; + referrerPolicy?: HTMLAttributeReferrerPolicy; + + // 尺寸属性 + height?: number | string; + width?: number | string; + + // 加载行为 + loading?: 'eager' | 'lazy'; + decoding?: 'async' | 'auto' | 'sync'; + + useMap?: string; +} + +export interface InsHTMLAttributes extends HTMLAttributes { + cite?: string; + dateTime?: string; +} + +type HTMLInputTypeAttribute = + | 'button' + | 'checkbox' + | 'color' + | 'date' + | 'datetime-local' + | 'email' + | 'file' + | 'hidden' + | 'image' + | 'month' + | 'number' + | 'password' + | 'radio' + | 'range' + | 'reset' + | 'search' + | 'submit' + | 'tel' + | 'text' + | 'time' + | 'url' + | 'week' + | (string & KVObject); + +export interface InputHTMLAttributes extends HTMLAttributes { + accept?: string; + alt?: string; + autoComplete?: string; + autoFocus?: boolean; + capture?: boolean | 'user' | 'environment'; // https://www.w3.org/TR/html-media-capture/#the-capture-attribute + checked?: boolean; + crossOrigin?: string; + disabled?: boolean; + enterKeyHint?: 'enter' | 'done' | 'go' | 'next' | 'previous' | 'search' | 'send'; + form?: string; + formAction?: string; + formEncType?: string; + formMethod?: string; + formNoValidate?: boolean; + formTarget?: string; + height?: number | string; + list?: string; + max?: number | string; + maxLength?: number; + min?: number | string; + minLength?: number; + multiple?: boolean; + name?: string; + pattern?: string; + placeholder?: string; + readOnly?: boolean; + required?: boolean; + size?: number; + src?: string; + step?: number | string; + type?: HTMLInputTypeAttribute; + value?: string | ReadonlyArray | number; + width?: number | string; + + onChange?: InulaChangeEventHandler; +} + +export interface KeygenHTMLAttributes extends HTMLAttributes { + // 基本属性 + autoFocus?: boolean; + challenge?: string; + disabled?: boolean; + form?: string; + keyType?: string; + keyParams?: string; + name?: string; +} + +export interface LabelHTMLAttributes extends HTMLAttributes { + form?: string; + htmlFor?: string; +} + +export interface LiHTMLAttributes extends HTMLAttributes { + value?: string | ReadonlyArray | number; +} + +export interface LinkHTMLAttributes extends HTMLAttributes { + // 核心属性 + href?: string; + rel?: string; + type?: string; + + // 资源加载属性 + as?: string; + crossOrigin?: string; + integrity?: string; + referrerPolicy?: HTMLAttributeReferrerPolicy; + + // 语言和字符集属性 + hrefLang?: string; + charSet?: string; + + // 媒体和样式属性 + media?: string; + sizes?: string; + + // 预加载和性能属性 + imageSrcSet?: string; +} + +export interface MapHTMLAttributes extends HTMLAttributes { + name?: string; +} + +export interface MenuHTMLAttributes extends HTMLAttributes { + type?: string; +} + +type InulaRole = + | 'application' + | 'alert' + | 'alertdialog' + | 'article' + | 'banner' + | 'button' + | 'cell' + | 'checkbox' + | 'columnheader' + | 'combobox' + | 'complementary' + | 'contentinfo' + | 'definition' + | 'dialog' + | 'directory' + | 'document' + | 'feed' + | 'figure' + | 'form' + | 'grid' + | 'gridcell' + | 'group' + | 'heading' + | 'img' + | 'link' + | 'list' + | 'listbox' + | 'listitem' + | 'log' + | 'main' + | 'marquee' + | 'math' + | 'menu' + | 'menubar' + | 'menuitem' + | 'menuitemcheckbox' + | 'menuitemradio' + | 'navigation' + | 'none' + | 'note' + | 'option' + | 'presentation' + | 'progressbar' + | 'radio' + | 'radiogroup' + | 'region' + | 'row' + | 'rowgroup' + | 'rowheader' + | 'scrollbar' + | 'search' + | 'searchbox' + | 'separator' + | 'slider' + | 'spinbutton' + | 'status' + | 'switch' + | 'tab' + | 'table' + | 'tablist' + | 'tabpanel' + | 'term' + | 'textbox' + | 'timer' + | 'toolbar' + | 'tooltip' + | 'tree' + | 'treegrid' + | 'treeitem' + | (string & KVObject); + +interface AriaAttributes { + // 角色和标识属性 + 'aria-activedescendant'?: string; + 'aria-atomic'?: InulaBoolean; + 'aria-autocomplete'?: 'none' | 'inline' | 'list' | 'both'; + 'aria-current'?: boolean | 'false' | 'true' | 'page' | 'step' | 'location' | 'date' | 'time'; + 'aria-haspopup'?: boolean | 'false' | 'true' | 'menu' | 'listbox' | 'tree' | 'grid' | 'dialog'; + 'aria-level'?: number; + 'aria-modal'?: InulaBoolean; + 'aria-multiline'?: InulaBoolean; + 'aria-multiselectable'?: InulaBoolean; + 'aria-orientation'?: 'horizontal' | 'vertical'; + 'aria-placeholder'?: string; + 'aria-roledescription'?: string; + + // 状态和属性 + 'aria-busy'?: InulaBoolean; + 'aria-checked'?: boolean | 'false' | 'mixed' | 'true'; + 'aria-disabled'?: InulaBoolean; + 'aria-expanded'?: InulaBoolean; + 'aria-hidden'?: InulaBoolean; + 'aria-invalid'?: boolean | 'false' | 'true' | 'grammar' | 'spelling'; + 'aria-pressed'?: boolean | 'false' | 'mixed' | 'true'; + 'aria-readonly'?: InulaBoolean; + 'aria-required'?: InulaBoolean; + 'aria-selected'?: InulaBoolean; + + // 关系属性 + 'aria-controls'?: string; + 'aria-describedby'?: string; + 'aria-details'?: string; + 'aria-errormessage'?: string; + 'aria-flowto'?: string; + 'aria-labelledby'?: string; + 'aria-owns'?: string; + + // 实时区域属性 + 'aria-live'?: 'off' | 'assertive' | 'polite'; + 'aria-relevant'?: + | 'additions' + | 'additions removals' + | 'additions text' + | 'all' + | 'removals' + | 'removals additions' + | 'removals text' + | 'text' + | 'text additions' + | 'text removals'; + + // 拖放属性 + /** @deprecated in ARIA 1.1 */ + 'aria-dropeffect'?: 'none' | 'copy' | 'execute' | 'link' | 'move' | 'popup'; + /** @deprecated in ARIA 1.1 */ + 'aria-grabbed'?: InulaBoolean; + + // 值属性 + 'aria-valuemax'?: number; + 'aria-valuemin'?: number; + 'aria-valuenow'?: number; + 'aria-valuetext'?: string; + + 'aria-colcount'?: number; + 'aria-colindex'?: number; + 'aria-colspan'?: number; + 'aria-keyshortcuts'?: string; + 'aria-label'?: string; + 'aria-posinset'?: number; + 'aria-rowcount'?: number; + 'aria-rowindex'?: number; + 'aria-rowspan'?: number; + 'aria-setsize'?: number; + 'aria-sort'?: 'none' | 'ascending' | 'descending' | 'other'; +} + +export interface HTMLAttributes extends AriaAttributes, DOMAttributes { + // 核心属性 + id?: string; + className?: string; + style?: InulaCSSProperties; + + // 全局属性 + accessKey?: string; + contentEditable?: InulaBoolean | 'inherit'; + contextMenu?: string; + dir?: string; + draggable?: InulaBoolean; + hidden?: boolean; + lang?: string; + spellCheck?: InulaBoolean; + tabIndex?: number; + title?: string; + translate?: 'yes' | 'no'; + + // 交互属性 + radioGroup?: string; // , + + // ARIA和可访问性 + role?: InulaRole; + + // 数据属性 + about?: string; + datatype?: string; + inlist?: any; + prefix?: string; + property?: string; + resource?: string; + typeof?: string; + vocab?: string; + + // 移动设备相关 + autoCapitalize?: string; + autoCorrect?: string; + autoSave?: string; + + // 其他属性 + color?: string; + itemProp?: string; + itemScope?: boolean; + itemType?: string; + itemID?: string; + itemRef?: string; + results?: number; + security?: string; + unselectable?: 'on' | 'off'; + + // 输入模式 + inputMode?: 'none' | 'text' | 'tel' | 'url' | 'email' | 'numeric' | 'decimal' | 'search'; + + // Web Components + is?: string; + + // 内部使用属性 + defaultChecked?: boolean; + defaultValue?: string | number | ReadonlyArray; + suppressContentEditableWarning?: boolean; + suppressHydrationWarning?: boolean; + + // 占位符属性 + placeholder?: string; +} + +export interface DOMAttributes { + children?: InulaNode; + dangerouslySetInnerHTML?: { + __html: string; + }; + + // 剪贴板事件 + onCopy?: InulaClipboardEventHandler; + onCopyCapture?: InulaClipboardEventHandler; + onCut?: InulaClipboardEventHandler; + onCutCapture?: InulaClipboardEventHandler; + onPaste?: InulaClipboardEventHandler; + onPasteCapture?: InulaClipboardEventHandler; + + // 剪贴板事件 + onCompositionEnd?: InulaCompositionEventHandler; + onCompositionEndCapture?: InulaCompositionEventHandler; + onCompositionStart?: InulaCompositionEventHandler; + onCompositionStartCapture?: InulaCompositionEventHandler; + onCompositionUpdate?: InulaCompositionEventHandler; + onCompositionUpdateCapture?: InulaCompositionEventHandler; + + // 焦点事件 + onFocus?: InulaFocusEventHandler; + onFocusCapture?: InulaFocusEventHandler; + onBlur?: InulaFocusEventHandler; + onBlurCapture?: InulaFocusEventHandler; + + // 表单事件 + onChange?: InulaFormEventHandler; + onChangeCapture?: InulaFormEventHandler; + onBeforeInput?: InulaFormEventHandler; + onBeforeInputCapture?: InulaFormEventHandler; + onInput?: InulaFormEventHandler; + onInputCapture?: InulaFormEventHandler; + onReset?: InulaFormEventHandler; + onResetCapture?: InulaFormEventHandler; + onSubmit?: InulaFormEventHandler; + onSubmitCapture?: InulaFormEventHandler; + onInvalid?: InulaFormEventHandler; + onInvalidCapture?: InulaFormEventHandler; + + // 图像事件 + onLoad?: InulaEventHandler; + onLoadCapture?: InulaEventHandler; + onError?: InulaEventHandler; + onErrorCapture?: InulaEventHandler; + + // 键盘事件 + onKeyDown?: InulaKeyboardEventHandler; + onKeyDownCapture?: InulaKeyboardEventHandler; + /** @deprecated */ + onKeyPress?: InulaKeyboardEventHandler; + /** @deprecated */ + onKeyPressCapture?: InulaKeyboardEventHandler; + onKeyUp?: InulaKeyboardEventHandler; + onKeyUpCapture?: InulaKeyboardEventHandler; + + // 媒体事件 + onAbort?: InulaEventHandler; + onAbortCapture?: InulaEventHandler; + onCanPlay?: InulaEventHandler; + onCanPlayCapture?: InulaEventHandler; + onCanPlayThrough?: InulaEventHandler; + onCanPlayThroughCapture?: InulaEventHandler; + onDurationChange?: InulaEventHandler; + onDurationChangeCapture?: InulaEventHandler; + onEmptied?: InulaEventHandler; + onEmptiedCapture?: InulaEventHandler; + onEncrypted?: InulaEventHandler; + onEncryptedCapture?: InulaEventHandler; + onEnded?: InulaEventHandler; + onEndedCapture?: InulaEventHandler; + onLoadedData?: InulaEventHandler; + onLoadedDataCapture?: InulaEventHandler; + onLoadedMetadata?: InulaEventHandler; + onLoadedMetadataCapture?: InulaEventHandler; + onLoadStart?: InulaEventHandler; + onLoadStartCapture?: InulaEventHandler; + onPause?: InulaEventHandler; + onPauseCapture?: InulaEventHandler; + onPlay?: InulaEventHandler; + onPlayCapture?: InulaEventHandler; + onPlaying?: InulaEventHandler; + onPlayingCapture?: InulaEventHandler; + onProgress?: InulaEventHandler; + onProgressCapture?: InulaEventHandler; + onRateChange?: InulaEventHandler; + onRateChangeCapture?: InulaEventHandler; + onSeeked?: InulaEventHandler; + onSeekedCapture?: InulaEventHandler; + onSeeking?: InulaEventHandler; + onSeekingCapture?: InulaEventHandler; + onStalled?: InulaEventHandler; + onStalledCapture?: InulaEventHandler; + onSuspend?: InulaEventHandler; + onSuspendCapture?: InulaEventHandler; + onTimeUpdate?: InulaEventHandler; + onTimeUpdateCapture?: InulaEventHandler; + onVolumeChange?: InulaEventHandler; + onVolumeChangeCapture?: InulaEventHandler; + onWaiting?: InulaEventHandler; + onWaitingCapture?: InulaEventHandler; + + //鼠标事件 + onAuxClick?: InulaMouseEventHandler; + onAuxClickCapture?: InulaMouseEventHandler; + onClick?: InulaMouseEventHandler; + onClickCapture?: InulaMouseEventHandler; + onContextMenu?: InulaMouseEventHandler; + onContextMenuCapture?: InulaMouseEventHandler; + onDoubleClick?: InulaMouseEventHandler; + onDoubleClickCapture?: InulaMouseEventHandler; + onDrag?: InulaDragEventHandler; + onDragCapture?: InulaDragEventHandler; + onDragEnd?: InulaDragEventHandler; + onDragEndCapture?: InulaDragEventHandler; + onDragEnter?: InulaDragEventHandler; + onDragEnterCapture?: InulaDragEventHandler; + onDragExit?: InulaDragEventHandler; + onDragExitCapture?: InulaDragEventHandler; + onDragLeave?: InulaDragEventHandler; + onDragLeaveCapture?: InulaDragEventHandler; + onDragOver?: InulaDragEventHandler; + onDragOverCapture?: InulaDragEventHandler; + onDragStart?: InulaDragEventHandler; + onDragStartCapture?: InulaDragEventHandler; + onDrop?: InulaDragEventHandler; + onDropCapture?: InulaDragEventHandler; + onMouseDown?: InulaMouseEventHandler; + onMouseDownCapture?: InulaMouseEventHandler; + onMouseEnter?: InulaMouseEventHandler; + onMouseLeave?: InulaMouseEventHandler; + onMouseMove?: InulaMouseEventHandler; + onMouseMoveCapture?: InulaMouseEventHandler; + onMouseOut?: InulaMouseEventHandler; + onMouseOutCapture?: InulaMouseEventHandler; + onMouseOver?: InulaMouseEventHandler; + onMouseOverCapture?: InulaMouseEventHandler; + onMouseUp?: InulaMouseEventHandler; + onMouseUpCapture?: InulaMouseEventHandler; + + // 选择事件 + onSelect?: InulaEventHandler; + onSelectCapture?: InulaEventHandler; + + // 触摸事件 + onTouchCancel?: InulaTouchEventHandler; + onTouchCancelCapture?: InulaTouchEventHandler; + onTouchEnd?: InulaTouchEventHandler; + onTouchEndCapture?: InulaTouchEventHandler; + onTouchMove?: InulaTouchEventHandler; + onTouchMoveCapture?: InulaTouchEventHandler; + onTouchStart?: InulaTouchEventHandler; + onTouchStartCapture?: InulaTouchEventHandler; + + // 指针事件 + onPointerDown?: InulaPointerEventHandler; + onPointerDownCapture?: InulaPointerEventHandler; + onPointerMove?: InulaPointerEventHandler; + onPointerMoveCapture?: InulaPointerEventHandler; + onPointerUp?: InulaPointerEventHandler; + onPointerUpCapture?: InulaPointerEventHandler; + onPointerCancel?: InulaPointerEventHandler; + onPointerCancelCapture?: InulaPointerEventHandler; + onPointerEnter?: InulaPointerEventHandler; + onPointerEnterCapture?: InulaPointerEventHandler; + onPointerLeave?: InulaPointerEventHandler; + onPointerLeaveCapture?: InulaPointerEventHandler; + onPointerOver?: InulaPointerEventHandler; + onPointerOverCapture?: InulaPointerEventHandler; + onPointerOut?: InulaPointerEventHandler; + onPointerOutCapture?: InulaPointerEventHandler; + onGotPointerCapture?: InulaPointerEventHandler; + onGotPointerCaptureCapture?: InulaPointerEventHandler; + onLostPointerCapture?: InulaPointerEventHandler; + onLostPointerCaptureCapture?: InulaPointerEventHandler; + + // UI 事件 + onScroll?: InulaUIEventHandler; + onScrollCapture?: InulaUIEventHandler; + + // 滚轮事件 + onWheel?: InulaWheelEventHandler; + onWheelCapture?: InulaWheelEventHandler; + + // 动画事件 + onAnimationStart?: InulaAnimationEventHandler; + onAnimationStartCapture?: InulaAnimationEventHandler; + onAnimationEnd?: InulaAnimationEventHandler; + onAnimationEndCapture?: InulaAnimationEventHandler; + onAnimationIteration?: InulaAnimationEventHandler; + onAnimationIterationCapture?: InulaAnimationEventHandler; + + // 过渡事件 + onTransitionEnd?: InulaTransitionEventHandler; + onTransitionEndCapture?: InulaTransitionEventHandler; +} + +export interface AllHTMLAttributes extends HTMLAttributes { + // 表单属性 + accept?: string; + acceptCharset?: string; + action?: string; + allowFullScreen?: boolean; + allowTransparency?: boolean; + alt?: string; + as?: string; + async?: boolean; + autoFocus?: boolean; + autoComplete?: string; + autoPlay?: boolean; + capture?: boolean | 'user' | 'environment'; + cellPadding?: number | string; + cellSpacing?: number | string; + charSet?: string; + challenge?: string; + checked?: boolean; + cite?: string; + classID?: string; + colSpan?: number; + cols?: number; + content?: string; + controls?: boolean; + coords?: string; + crossOrigin?: string; + data?: string; + dateTime?: string; + default?: boolean; + defer?: boolean; + disabled?: boolean; + download?: any; + encType?: string; + form?: string; + formAction?: string; + formEncType?: string; + formMethod?: string; + formNoValidate?: boolean; + formTarget?: string; + frameBorder?: number | string; + headers?: string; + height?: number | string; + high?: number; + href?: string; + hrefLang?: string; + htmlFor?: string; + httpEquiv?: string; + integrity?: string; + keyParams?: string; + keyType?: string; + kind?: string; + label?: string; + list?: string; + loop?: boolean; + low?: number; + manifest?: string; + marginHeight?: number; + marginWidth?: number; + max?: number | string; + maxLength?: number; + media?: string; + mediaGroup?: string; + method?: string; + min?: number | string; + minLength?: number; + multiple?: boolean; + muted?: boolean; + name?: string; + nonce?: string; + noValidate?: boolean; + open?: boolean; + optimum?: number; + pattern?: string; + placeholder?: string; + playsInline?: boolean; + poster?: string; + preload?: string; + readOnly?: boolean; + rel?: string; + required?: boolean; + reversed?: boolean; + rows?: number; + rowSpan?: number; + sandbox?: string; + scope?: string; + scoped?: boolean; + scrolling?: string; + seamless?: boolean; + selected?: boolean; + shape?: string; + size?: number; + sizes?: string; + span?: number; + src?: string; + srcDoc?: string; + srcLang?: string; + srcSet?: string; + start?: number; + step?: number | string; + summary?: string; + target?: string; + type?: string; + useMap?: string; + value?: string | ReadonlyArray | number; + width?: number | string; + wmode?: string; + wrap?: string; +} diff --git a/packages/inula/src/jsx-type/baseElement.ts b/packages/inula/src/jsx-type/baseElement.ts new file mode 100644 index 00000000..15edf1c6 --- /dev/null +++ b/packages/inula/src/jsx-type/baseElement.ts @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2024 Huawei Technologies Co.,Ltd. + * + * openInula is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + */ + +export interface HTMLElement extends Element {} +export interface HTMLAnchorElement extends HTMLElement {} +export interface HTMLAreaElement extends HTMLElement {} +export interface HTMLAudioElement extends HTMLElement {} +export interface HTMLBaseElement extends HTMLElement {} +export interface HTMLBodyElement extends HTMLElement {} +export interface HTMLBRElement extends HTMLElement {} +export interface HTMLButtonElement extends HTMLElement {} +export interface HTMLCanvasElement extends HTMLElement {} +export interface HTMLDataElement extends HTMLElement {} +export interface HTMLDataListElement extends HTMLElement {} +export interface HTMLDetailsElement extends HTMLElement {} +export interface HTMLDialogElement extends HTMLElement {} +export interface HTMLDivElement extends HTMLElement {} +export interface HTMLDListElement extends HTMLElement {} +export interface HTMLEmbedElement extends HTMLElement {} +export interface HTMLFieldSetElement extends HTMLElement {} +export interface HTMLFormElement extends HTMLElement {} +export interface HTMLHeadingElement extends HTMLElement {} +export interface HTMLHeadElement extends HTMLElement {} +export interface HTMLHRElement extends HTMLElement {} +export interface HTMLHtmlElement extends HTMLElement {} +export interface HTMLIFrameElement extends HTMLElement {} +export interface HTMLImageElement extends HTMLElement {} +export interface HTMLInputElement extends HTMLElement {} +export interface HTMLModElement extends HTMLElement {} +export interface HTMLLabelElement extends HTMLElement {} +export interface HTMLLegendElement extends HTMLElement {} +export interface HTMLLIElement extends HTMLElement {} +export interface HTMLLinkElement extends HTMLElement {} +export interface HTMLMapElement extends HTMLElement {} +export interface HTMLMetaElement extends HTMLElement {} +export interface HTMLMeterElement extends HTMLElement {} +export interface HTMLObjectElement extends HTMLElement {} +export interface HTMLOListElement extends HTMLElement {} +export interface HTMLOptGroupElement extends HTMLElement {} +export interface HTMLOptionElement extends HTMLElement {} +export interface HTMLOutputElement extends HTMLElement {} +export interface HTMLParagraphElement extends HTMLElement {} +export interface HTMLParamElement extends HTMLElement {} +export interface HTMLPreElement extends HTMLElement {} +export interface HTMLProgressElement extends HTMLElement {} +export interface HTMLQuoteElement extends HTMLElement {} +export interface HTMLSlotElement extends HTMLElement {} +export interface HTMLScriptElement extends HTMLElement {} +export interface HTMLSelectElement extends HTMLElement {} +export interface HTMLSourceElement extends HTMLElement {} +export interface HTMLSpanElement extends HTMLElement {} +export interface HTMLStyleElement extends HTMLElement {} +export interface HTMLTableElement extends HTMLElement {} +export interface HTMLTableColElement extends HTMLElement {} +export interface HTMLTableDataCellElement extends HTMLElement {} +export interface HTMLTableHeaderCellElement extends HTMLElement {} +export interface HTMLTableRowElement extends HTMLElement {} +export interface HTMLTableSectionElement extends HTMLElement {} +export interface HTMLTemplateElement extends HTMLElement {} +export interface HTMLTextAreaElement extends HTMLElement {} +export interface HTMLTimeElement extends HTMLElement {} +export interface HTMLTitleElement extends HTMLElement {} +export interface HTMLTrackElement extends HTMLElement {} +export interface HTMLUListElement extends HTMLElement {} +export interface HTMLVideoElement extends HTMLElement {} +export interface HTMLWebViewElement extends HTMLElement {} + +export interface SVGElement extends Element {} +export interface SVGSVGElement extends SVGElement {} +export interface SVGCircleElement extends SVGElement {} +export interface SVGClipPathElement extends SVGElement {} +export interface SVGDefsElement extends SVGElement {} +export interface SVGDescElement extends SVGElement {} +export interface SVGEllipseElement extends SVGElement {} +export interface SVGFEBlendElement extends SVGElement {} +export interface SVGFEColorMatrixElement extends SVGElement {} +export interface SVGFEComponentTransferElement extends SVGElement {} +export interface SVGFECompositeElement extends SVGElement {} +export interface SVGFEConvolveMatrixElement extends SVGElement {} +export interface SVGFEDiffuseLightingElement extends SVGElement {} +export interface SVGFEDisplacementMapElement extends SVGElement {} +export interface SVGFEDistantLightElement extends SVGElement {} +export interface SVGFEDropShadowElement extends SVGElement {} +export interface SVGFEFloodElement extends SVGElement {} +export interface SVGFEFuncAElement extends SVGElement {} +export interface SVGFEFuncBElement extends SVGElement {} +export interface SVGFEFuncGElement extends SVGElement {} +export interface SVGFEFuncRElement extends SVGElement {} +export interface SVGFEGaussianBlurElement extends SVGElement {} +export interface SVGFEImageElement extends SVGElement {} +export interface SVGFEMergeElement extends SVGElement {} +export interface SVGFEMergeNodeElement extends SVGElement {} +export interface SVGFEMorphologyElement extends SVGElement {} +export interface SVGFEOffsetElement extends SVGElement {} +export interface SVGFEPointLightElement extends SVGElement {} +export interface SVGFESpecularLightingElement extends SVGElement {} +export interface SVGFESpotLightElement extends SVGElement {} +export interface SVGFETileElement extends SVGElement {} +export interface SVGFETurbulenceElement extends SVGElement {} +export interface SVGFilterElement extends SVGElement {} +export interface SVGForeignObjectElement extends SVGElement {} +export interface SVGGElement extends SVGElement {} +export interface SVGImageElement extends SVGElement {} +export interface SVGLineElement extends SVGElement {} +export interface SVGLinearGradientElement extends SVGElement {} +export interface SVGMarkerElement extends SVGElement {} +export interface SVGMaskElement extends SVGElement {} +export interface SVGMetadataElement extends SVGElement {} +export interface SVGPathElement extends SVGElement {} +export interface SVGPatternElement extends SVGElement {} +export interface SVGPolygonElement extends SVGElement {} +export interface SVGPolylineElement extends SVGElement {} +export interface SVGRadialGradientElement extends SVGElement {} +export interface SVGRectElement extends SVGElement {} +export interface SVGStopElement extends SVGElement {} +export interface SVGSwitchElement extends SVGElement {} +export interface SVGSymbolElement extends SVGElement {} +export interface SVGTextElement extends SVGElement {} +export interface SVGTextPathElement extends SVGElement {} +export interface SVGTSpanElement extends SVGElement {} +export interface SVGUseElement extends SVGElement {} +export interface SVGViewElement extends SVGElement {} diff --git a/packages/inula/src/jsx-type/index.ts b/packages/inula/src/jsx-type/index.ts new file mode 100644 index 00000000..616b62b6 --- /dev/null +++ b/packages/inula/src/jsx-type/index.ts @@ -0,0 +1,463 @@ +/* + * Copyright (c) 2024 Huawei Technologies Co.,Ltd. + * + * openInula is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + */ + +import { ClassAttributes, InulaElement, InulaNode, LegacyRef } from '../types'; +import { + AllHTMLAttributes, + AnchorHTMLAttributes, + AreaHTMLAttributes, + AudioHTMLAttributes, + BaseHTMLAttributes, + BlockquoteHTMLAttributes, + ButtonHTMLAttributes, + CanvasHTMLAttributes, + ColHTMLAttributes, + ColgroupHTMLAttributes, + DOMAttributes, + DataHTMLAttributes, + DelHTMLAttributes, + DetailsHTMLAttributes, + DialogHTMLAttributes, + EmbedHTMLAttributes, + FieldsetHTMLAttributes, + FormHTMLAttributes, + HTMLAttributes, + HtmlHTMLAttributes, + IframeHTMLAttributes, + ImgHTMLAttributes, + InputHTMLAttributes, + InsHTMLAttributes, + KeygenHTMLAttributes, + LabelHTMLAttributes, + LiHTMLAttributes, + LinkHTMLAttributes, + MapHTMLAttributes, + MenuHTMLAttributes, + MetaHTMLAttributes, + MeterHTMLAttributes, + ObjectHTMLAttributes, + OlHTMLAttributes, + OptgroupHTMLAttributes, + OptionHTMLAttributes, + OutputHTMLAttributes, + ParamHTMLAttributes, + ProgressHTMLAttributes, + QuoteHTMLAttributes, + SVGAttributes, + InulaSVGProps, + ScriptHTMLAttributes, + SelectHTMLAttributes, + SlotHTMLAttributes, + SourceHTMLAttributes, + StyleHTMLAttributes, + TableHTMLAttributes, + TdHTMLAttributes, + TextareaHTMLAttributes, + ThHTMLAttributes, + TimeHTMLAttributes, + TrackHTMLAttributes, + VideoHTMLAttributes, + WebViewHTMLAttributes, +} from './baseAttr'; +import { HTMLWebViewElement } from './baseElement'; + +type DOMFactory

, T extends Element> = ( + props?: (ClassAttributes & P) | null, + ...children: InulaNode[] +) => DOMElement; + +interface InulaHTMLFactory

, T extends HTMLElement> extends DOMFactory { + (props?: (ClassAttributes & P) | null, ...children: InulaNode[]): DetailedInulaHTMLElement; +} + +export interface InulaHTMLElement extends DetailedInulaHTMLElement, T> {} + +export interface DOMElement

| SVGAttributes, T extends Element> + extends InulaElement { + ref: LegacyRef; +} + +export interface InulaSVGElement extends DOMElement, SVGElement> { + type: keyof InulaSVG; +} + +export interface InulaSVG { + animate: InulaSVGFactory; + circle: InulaSVGFactory; + clipPath: InulaSVGFactory; + defs: InulaSVGFactory; + desc: InulaSVGFactory; + ellipse: InulaSVGFactory; + feBlend: InulaSVGFactory; + feColorMatrix: InulaSVGFactory; + feComponentTransfer: InulaSVGFactory; + feComposite: InulaSVGFactory; + feConvolveMatrix: InulaSVGFactory; + feDiffuseLighting: InulaSVGFactory; + feDisplacementMap: InulaSVGFactory; + feDistantLight: InulaSVGFactory; + feDropShadow: InulaSVGFactory; + feFlood: InulaSVGFactory; + feFuncA: InulaSVGFactory; + feFuncB: InulaSVGFactory; + feFuncG: InulaSVGFactory; + feFuncR: InulaSVGFactory; + feImage: InulaSVGFactory; + feGaussianBlur: InulaSVGFactory; + feMerge: InulaSVGFactory; + feMergeNode: InulaSVGFactory; + feMorphology: InulaSVGFactory; + feOffset: InulaSVGFactory; + fePointLight: InulaSVGFactory; + feSpecularLighting: InulaSVGFactory; + feSpotLight: InulaSVGFactory; + feTile: InulaSVGFactory; + feTurbulence: InulaSVGFactory; + filter: InulaSVGFactory; + foreignObject: InulaSVGFactory; + g: InulaSVGFactory; + image: InulaSVGFactory; + line: InulaSVGFactory; + linearGradient: InulaSVGFactory; + marker: InulaSVGFactory; + mask: InulaSVGFactory; + view: InulaSVGFactory; + metadata: InulaSVGFactory; + path: InulaSVGFactory; + pattern: InulaSVGFactory; + polygon: InulaSVGFactory; + polyline: InulaSVGFactory; + radialGradient: InulaSVGFactory; + rect: InulaSVGFactory; + stop: InulaSVGFactory; + svg: InulaSVGFactory; + switch: InulaSVGFactory; + symbol: InulaSVGFactory; + text: InulaSVGFactory; + textPath: InulaSVGFactory; + tspan: InulaSVGFactory; + use: InulaSVGFactory; +} + +interface InulaSVGFactory extends DOMFactory, SVGElement> { + (props?: (ClassAttributes & SVGAttributes) | null, ...children: InulaNode[]): InulaSVGElement; +} + +export interface DetailedInulaHTMLElement

, T extends HTMLElement> extends DOMElement { + type: keyof BaseElement; +} + +export interface InulaHTML { + a: InulaHTMLFactory, HTMLAnchorElement>; + abbr: InulaHTMLFactory, HTMLElement>; + address: InulaHTMLFactory, HTMLElement>; + area: InulaHTMLFactory, HTMLAreaElement>; + article: InulaHTMLFactory, HTMLElement>; + aside: InulaHTMLFactory, HTMLElement>; + audio: InulaHTMLFactory, HTMLAudioElement>; + b: InulaHTMLFactory, HTMLElement>; + base: InulaHTMLFactory, HTMLBaseElement>; + bdi: InulaHTMLFactory, HTMLElement>; + bdo: InulaHTMLFactory, HTMLElement>; + big: InulaHTMLFactory, HTMLElement>; + blockquote: InulaHTMLFactory, HTMLQuoteElement>; + body: InulaHTMLFactory, HTMLBodyElement>; + br: InulaHTMLFactory, HTMLBRElement>; + button: InulaHTMLFactory, HTMLButtonElement>; + canvas: InulaHTMLFactory, HTMLCanvasElement>; + caption: InulaHTMLFactory, HTMLElement>; + cite: InulaHTMLFactory, HTMLElement>; + code: InulaHTMLFactory, HTMLElement>; + col: InulaHTMLFactory, HTMLTableColElement>; + colgroup: InulaHTMLFactory, HTMLTableColElement>; + data: InulaHTMLFactory, HTMLDataElement>; + datalist: InulaHTMLFactory, HTMLDataListElement>; + dd: InulaHTMLFactory, HTMLElement>; + del: InulaHTMLFactory, HTMLModElement>; + details: InulaHTMLFactory, HTMLDetailsElement>; + dfn: InulaHTMLFactory, HTMLElement>; + dialog: InulaHTMLFactory, HTMLDialogElement>; + div: InulaHTMLFactory, HTMLDivElement>; + dl: InulaHTMLFactory, HTMLDListElement>; + dt: InulaHTMLFactory, HTMLElement>; + em: InulaHTMLFactory, HTMLElement>; + embed: InulaHTMLFactory, HTMLEmbedElement>; + fieldset: InulaHTMLFactory, HTMLFieldSetElement>; + figcaption: InulaHTMLFactory, HTMLElement>; + figure: InulaHTMLFactory, HTMLElement>; + footer: InulaHTMLFactory, HTMLElement>; + form: InulaHTMLFactory, HTMLFormElement>; + h1: InulaHTMLFactory, HTMLHeadingElement>; + h2: InulaHTMLFactory, HTMLHeadingElement>; + h3: InulaHTMLFactory, HTMLHeadingElement>; + h4: InulaHTMLFactory, HTMLHeadingElement>; + h5: InulaHTMLFactory, HTMLHeadingElement>; + h6: InulaHTMLFactory, HTMLHeadingElement>; + head: InulaHTMLFactory, HTMLHeadElement>; + header: InulaHTMLFactory, HTMLElement>; + hgroup: InulaHTMLFactory, HTMLElement>; + hr: InulaHTMLFactory, HTMLHRElement>; + html: InulaHTMLFactory, HTMLHtmlElement>; + i: InulaHTMLFactory, HTMLElement>; + iframe: InulaHTMLFactory, HTMLIFrameElement>; + img: InulaHTMLFactory, HTMLImageElement>; + input: InulaHTMLFactory, HTMLInputElement>; + ins: InulaHTMLFactory, HTMLModElement>; + kbd: InulaHTMLFactory, HTMLElement>; + keygen: InulaHTMLFactory, HTMLElement>; + label: InulaHTMLFactory, HTMLLabelElement>; + legend: InulaHTMLFactory, HTMLLegendElement>; + li: InulaHTMLFactory, HTMLLIElement>; + link: InulaHTMLFactory, HTMLLinkElement>; + main: InulaHTMLFactory, HTMLElement>; + map: InulaHTMLFactory, HTMLMapElement>; + mark: InulaHTMLFactory, HTMLElement>; + menu: InulaHTMLFactory, HTMLElement>; + menuitem: InulaHTMLFactory, HTMLElement>; + meta: InulaHTMLFactory, HTMLMetaElement>; + meter: InulaHTMLFactory, HTMLMeterElement>; + nav: InulaHTMLFactory, HTMLElement>; + noscript: InulaHTMLFactory, HTMLElement>; + object: InulaHTMLFactory, HTMLObjectElement>; + ol: InulaHTMLFactory, HTMLOListElement>; + optgroup: InulaHTMLFactory, HTMLOptGroupElement>; + option: InulaHTMLFactory, HTMLOptionElement>; + output: InulaHTMLFactory, HTMLOutputElement>; + p: InulaHTMLFactory, HTMLParagraphElement>; + param: InulaHTMLFactory, HTMLParamElement>; + picture: InulaHTMLFactory, HTMLElement>; + pre: InulaHTMLFactory, HTMLPreElement>; + progress: InulaHTMLFactory, HTMLProgressElement>; + q: InulaHTMLFactory, HTMLQuoteElement>; + rp: InulaHTMLFactory, HTMLElement>; + rt: InulaHTMLFactory, HTMLElement>; + ruby: InulaHTMLFactory, HTMLElement>; + s: InulaHTMLFactory, HTMLElement>; + samp: InulaHTMLFactory, HTMLElement>; + slot: InulaHTMLFactory, HTMLSlotElement>; + script: InulaHTMLFactory, HTMLScriptElement>; + section: InulaHTMLFactory, HTMLElement>; + select: InulaHTMLFactory, HTMLSelectElement>; + small: InulaHTMLFactory, HTMLElement>; + source: InulaHTMLFactory, HTMLSourceElement>; + span: InulaHTMLFactory, HTMLSpanElement>; + strong: InulaHTMLFactory, HTMLElement>; + style: InulaHTMLFactory, HTMLStyleElement>; + sub: InulaHTMLFactory, HTMLElement>; + summary: InulaHTMLFactory, HTMLElement>; + sup: InulaHTMLFactory, HTMLElement>; + table: InulaHTMLFactory, HTMLTableElement>; + template: InulaHTMLFactory, HTMLTemplateElement>; + tbody: InulaHTMLFactory, HTMLTableSectionElement>; + td: InulaHTMLFactory, HTMLTableDataCellElement>; + textarea: InulaHTMLFactory, HTMLTextAreaElement>; + tfoot: InulaHTMLFactory, HTMLTableSectionElement>; + th: InulaHTMLFactory, HTMLTableHeaderCellElement>; + thead: InulaHTMLFactory, HTMLTableSectionElement>; + time: InulaHTMLFactory, HTMLTimeElement>; + title: InulaHTMLFactory, HTMLTitleElement>; + tr: InulaHTMLFactory, HTMLTableRowElement>; + track: InulaHTMLFactory, HTMLTrackElement>; + u: InulaHTMLFactory, HTMLElement>; + ul: InulaHTMLFactory, HTMLUListElement>; + var: InulaHTMLFactory, HTMLElement>; + video: InulaHTMLFactory, HTMLVideoElement>; + wbr: InulaHTMLFactory, HTMLElement>; + webview: InulaHTMLFactory, HTMLElement>; +} + +export type InulaHTMLProps, T> = ClassAttributes & E; + +export interface BaseElement { + // HTML + a: InulaHTMLProps, HTMLAnchorElement>; + abbr: InulaHTMLProps, HTMLElement>; + address: InulaHTMLProps, HTMLElement>; + area: InulaHTMLProps, HTMLAreaElement>; + article: InulaHTMLProps, HTMLElement>; + aside: InulaHTMLProps, HTMLElement>; + audio: InulaHTMLProps, HTMLAudioElement>; + b: InulaHTMLProps, HTMLElement>; + base: InulaHTMLProps, HTMLBaseElement>; + bdi: InulaHTMLProps, HTMLElement>; + bdo: InulaHTMLProps, HTMLElement>; + big: InulaHTMLProps, HTMLElement>; + blockquote: InulaHTMLProps, HTMLQuoteElement>; + body: InulaHTMLProps, HTMLBodyElement>; + br: InulaHTMLProps, HTMLBRElement>; + button: InulaHTMLProps, HTMLButtonElement>; + canvas: InulaHTMLProps, HTMLCanvasElement>; + caption: InulaHTMLProps, HTMLElement>; + cite: InulaHTMLProps, HTMLElement>; + code: InulaHTMLProps, HTMLElement>; + col: InulaHTMLProps, HTMLTableColElement>; + colgroup: InulaHTMLProps, HTMLTableColElement>; + data: InulaHTMLProps, HTMLDataElement>; + datalist: InulaHTMLProps, HTMLDataListElement>; + dd: InulaHTMLProps, HTMLElement>; + del: InulaHTMLProps, HTMLModElement>; + details: InulaHTMLProps, HTMLDetailsElement>; + dfn: InulaHTMLProps, HTMLElement>; + dialog: InulaHTMLProps, HTMLDialogElement>; + div: InulaHTMLProps, HTMLDivElement>; + dl: InulaHTMLProps, HTMLDListElement>; + dt: InulaHTMLProps, HTMLElement>; + em: InulaHTMLProps, HTMLElement>; + embed: InulaHTMLProps, HTMLEmbedElement>; + fieldset: InulaHTMLProps, HTMLFieldSetElement>; + figcaption: InulaHTMLProps, HTMLElement>; + figure: InulaHTMLProps, HTMLElement>; + footer: InulaHTMLProps, HTMLElement>; + form: InulaHTMLProps, HTMLFormElement>; + h1: InulaHTMLProps, HTMLHeadingElement>; + h2: InulaHTMLProps, HTMLHeadingElement>; + h3: InulaHTMLProps, HTMLHeadingElement>; + h4: InulaHTMLProps, HTMLHeadingElement>; + h5: InulaHTMLProps, HTMLHeadingElement>; + h6: InulaHTMLProps, HTMLHeadingElement>; + head: InulaHTMLProps, HTMLHeadElement>; + header: InulaHTMLProps, HTMLElement>; + hgroup: InulaHTMLProps, HTMLElement>; + hr: InulaHTMLProps, HTMLHRElement>; + html: InulaHTMLProps, HTMLHtmlElement>; + i: InulaHTMLProps, HTMLElement>; + iframe: InulaHTMLProps, HTMLIFrameElement>; + img: InulaHTMLProps, HTMLImageElement>; + input: InulaHTMLProps, HTMLInputElement>; + ins: InulaHTMLProps, HTMLModElement>; + kbd: InulaHTMLProps, HTMLElement>; + keygen: InulaHTMLProps, HTMLElement>; + label: InulaHTMLProps, HTMLLabelElement>; + legend: InulaHTMLProps, HTMLLegendElement>; + li: InulaHTMLProps, HTMLLIElement>; + link: InulaHTMLProps, HTMLLinkElement>; + main: InulaHTMLProps, HTMLElement>; + map: InulaHTMLProps, HTMLMapElement>; + mark: InulaHTMLProps, HTMLElement>; + menu: InulaHTMLProps, HTMLElement>; + menuitem: InulaHTMLProps, HTMLElement>; + meta: InulaHTMLProps, HTMLMetaElement>; + meter: InulaHTMLProps, HTMLMeterElement>; + nav: InulaHTMLProps, HTMLElement>; + noindex: InulaHTMLProps, HTMLElement>; + noscript: InulaHTMLProps, HTMLElement>; + object: InulaHTMLProps, HTMLObjectElement>; + ol: InulaHTMLProps, HTMLOListElement>; + optgroup: InulaHTMLProps, HTMLOptGroupElement>; + option: InulaHTMLProps, HTMLOptionElement>; + output: InulaHTMLProps, HTMLOutputElement>; + p: InulaHTMLProps, HTMLParagraphElement>; + param: InulaHTMLProps, HTMLParamElement>; + picture: InulaHTMLProps, HTMLElement>; + pre: InulaHTMLProps, HTMLPreElement>; + progress: InulaHTMLProps, HTMLProgressElement>; + q: InulaHTMLProps, HTMLQuoteElement>; + rp: InulaHTMLProps, HTMLElement>; + rt: InulaHTMLProps, HTMLElement>; + ruby: InulaHTMLProps, HTMLElement>; + s: InulaHTMLProps, HTMLElement>; + samp: InulaHTMLProps, HTMLElement>; + slot: InulaHTMLProps, HTMLSlotElement>; + script: InulaHTMLProps, HTMLScriptElement>; + section: InulaHTMLProps, HTMLElement>; + select: InulaHTMLProps, HTMLSelectElement>; + small: InulaHTMLProps, HTMLElement>; + source: InulaHTMLProps, HTMLSourceElement>; + span: InulaHTMLProps, HTMLSpanElement>; + strong: InulaHTMLProps, HTMLElement>; + style: InulaHTMLProps, HTMLStyleElement>; + sub: InulaHTMLProps, HTMLElement>; + summary: InulaHTMLProps, HTMLElement>; + sup: InulaHTMLProps, HTMLElement>; + table: InulaHTMLProps, HTMLTableElement>; + template: InulaHTMLProps, HTMLTemplateElement>; + tbody: InulaHTMLProps, HTMLTableSectionElement>; + td: InulaHTMLProps, HTMLTableDataCellElement>; + textarea: InulaHTMLProps, HTMLTextAreaElement>; + tfoot: InulaHTMLProps, HTMLTableSectionElement>; + th: InulaHTMLProps, HTMLTableHeaderCellElement>; + thead: InulaHTMLProps, HTMLTableSectionElement>; + time: InulaHTMLProps, HTMLTimeElement>; + title: InulaHTMLProps, HTMLTitleElement>; + tr: InulaHTMLProps, HTMLTableRowElement>; + track: InulaHTMLProps, HTMLTrackElement>; + u: InulaHTMLProps, HTMLElement>; + ul: InulaHTMLProps, HTMLUListElement>; + var: InulaHTMLProps, HTMLElement>; + video: InulaHTMLProps, HTMLVideoElement>; + wbr: InulaHTMLProps, HTMLElement>; + webview: InulaHTMLProps, HTMLWebViewElement>; + + // SVG + svg: InulaSVGProps; + + animate: InulaSVGProps; + animateMotion: InulaSVGProps; + animateTransform: InulaSVGProps; + circle: InulaSVGProps; + clipPath: InulaSVGProps; + defs: InulaSVGProps; + desc: InulaSVGProps; + ellipse: InulaSVGProps; + feBlend: InulaSVGProps; + feColorMatrix: InulaSVGProps; + feComponentTransfer: InulaSVGProps; + feComposite: InulaSVGProps; + feConvolveMatrix: InulaSVGProps; + feDiffuseLighting: InulaSVGProps; + feDisplacementMap: InulaSVGProps; + feDistantLight: InulaSVGProps; + feDropShadow: InulaSVGProps; + feFlood: InulaSVGProps; + feFuncA: InulaSVGProps; + feFuncB: InulaSVGProps; + feFuncG: InulaSVGProps; + feFuncR: InulaSVGProps; + feGaussianBlur: InulaSVGProps; + feImage: InulaSVGProps; + feMerge: InulaSVGProps; + feMergeNode: InulaSVGProps; + feMorphology: InulaSVGProps; + feOffset: InulaSVGProps; + fePointLight: InulaSVGProps; + feSpecularLighting: InulaSVGProps; + feSpotLight: InulaSVGProps; + feTile: InulaSVGProps; + feTurbulence: InulaSVGProps; + filter: InulaSVGProps; + foreignObject: InulaSVGProps; + g: InulaSVGProps; + image: InulaSVGProps; + line: InulaSVGProps; + linearGradient: InulaSVGProps; + marker: InulaSVGProps; + mask: InulaSVGProps; + metadata: InulaSVGProps; + mpath: InulaSVGProps; + path: InulaSVGProps; + pattern: InulaSVGProps; + polygon: InulaSVGProps; + polyline: InulaSVGProps; + radialGradient: InulaSVGProps; + rect: InulaSVGProps; + stop: InulaSVGProps; + switch: InulaSVGProps; + symbol: InulaSVGProps; + text: InulaSVGProps; + textPath: InulaSVGProps; + tspan: InulaSVGProps; + use: InulaSVGProps; + view: InulaSVGProps; +} diff --git a/packages/inula/src/types.ts b/packages/inula/src/types.ts index ac029df0..d318cbd3 100644 --- a/packages/inula/src/types.ts +++ b/packages/inula/src/types.ts @@ -17,7 +17,7 @@ import { Component } from './renderer/components/BaseClassComponent'; import { MutableRef, RefCallBack, RefObject } from './renderer/hooks/HookType'; import * as Event from './EventTypes'; -//import Element = JSX.Element; +import { BaseElement } from './jsx-type'; // // --------------------------------- Inula Base Types ---------------------------------- @@ -44,7 +44,9 @@ interface InulaErrorInfo { } // eslint-disable-next-line @typescript-eslint/ban-types -export type KVObject = {}; +export type KVObject = { + // vtype: number; +}; export type InulaFragment = Iterable; @@ -68,7 +70,6 @@ export interface ConsumerProps { export interface Context { Provider: ExoticComponent>; Consumer: ExoticComponent>; - // 兼容React displayName?: string | undefined; } @@ -78,6 +79,28 @@ export interface FunctionComponent

{ displayName?: string; } +export type ClassType, C extends ComponentClass

> = C & + (new (props: P, context?: any) => T); +export interface ClassicComponent

extends Component { + replaceState(nextState: S, callback?: () => void): void; + isMounted(): boolean; + getInitialState?(): S; +} + +export type InulaCElement> = ComponentElement; +interface ComponentElement> extends InulaElement> { + ref?: LegacyRef | undefined; +} + +export interface ClassicComponentClass

extends ComponentClass

{ + new (props: P, context?: any): ClassicComponent; + getDefaultProps?(): P; +} + +export interface FunctionComponentElement

extends InulaElement> { + ref?: ('ref' extends keyof P ? (P extends { ref?: infer R | undefined } ? R : never) : never) | undefined; +} + export interface ComponentClass

extends StaticLifecycle { new (props: P, context?: unknown): Component; @@ -120,7 +143,7 @@ export type PropsWithRef

= 'ref' extends keyof P : P : P; -type Attributes = { +export type Attributes = { key?: Key | null | undefined; }; @@ -130,7 +153,7 @@ export type RefAttributes = Attributes & { ref?: Ref | null; }; -export type ComponentPropsWithRef = T extends new (props: infer P) => Component +export type ComponentPropsWithRef = T extends new (props: infer P) => Component ? PropsOmitRef

& RefAttributes> : PropsWithRef; @@ -245,1041 +268,6 @@ export type JSXElementConstructor

= | ((props: P) => InulaElement | null) | (new (props: P) => Component); -interface ClassAttributes extends Attributes { - ref: Ref; - key: Key | undefined; - jsx: boolean | undefined; -} -//让其他代码在值发生变化时得到通知 -interface SignalLike { - value: T; - peek(): T; - subscribe(fn: (value: T) => void): () => void; -} -export type Signalish = T | SignalLike; -export interface DOMAttributes { - // Image Events - onLoad?: GenericEventHandler | undefined; - onLoadCapture?: GenericEventHandler | undefined; - onError?: GenericEventHandler | undefined; - onErrorCapture?: GenericEventHandler | undefined; - - // Clipboard Events - onCopy?: ClipboardEventHandler | undefined; - onCopyCapture?: ClipboardEventHandler | undefined; - onCut?: ClipboardEventHandler | undefined; - onCutCapture?: ClipboardEventHandler | undefined; - onPaste?: ClipboardEventHandler | undefined; - onPasteCapture?: ClipboardEventHandler | undefined; - // Composition Events - onCompositionEnd?: CompositionEventHandler | undefined; - onCompositionEndCapture?: CompositionEventHandler | undefined; - onCompositionStart?: CompositionEventHandler | undefined; - onCompositionStartCapture?: CompositionEventHandler | undefined; - onCompositionUpdate?: CompositionEventHandler | undefined; - onCompositionUpdateCapture?: CompositionEventHandler | undefined; - - // Details Events - onToggle?: GenericEventHandler | undefined; - - // Dialog Events - onClose?: GenericEventHandler | undefined; - onCancel?: GenericEventHandler | undefined; - - // Focus Events - onFocus?: FocusEventHandler | undefined; - onFocusCapture?: FocusEventHandler | undefined; - onFocusIn?: FocusEventHandler | undefined; - onFocusInCapture?: FocusEventHandler | undefined; - onFocusOut?: FocusEventHandler | undefined; - onFocusOutCapture?: FocusEventHandler | undefined; - onBlur?: FocusEventHandler | undefined; - onBlurCapture?: FocusEventHandler | undefined; - - // Form Events - onChange?: GenericEventHandler | undefined; - onChangeCapture?: GenericEventHandler | undefined; - onInput?: FormEventHandler | undefined; - onInputCapture?: FormEventHandler | undefined; - onBeforeInput?: FormEventHandler | undefined; - onBeforeInputCapture?: FormEventHandler | undefined; - onSearch?: GenericEventHandler | undefined; - onSearchCapture?: GenericEventHandler | undefined; - onSubmit?: FormEventHandler | undefined; - onSubmitCapture?: FormEventHandler | undefined; - onInvalid?: GenericEventHandler | undefined; - onInvalidCapture?: GenericEventHandler | undefined; - onReset?: GenericEventHandler | undefined; - onResetCapture?: GenericEventHandler | undefined; - onFormData?: GenericEventHandler | undefined; - onFormDataCapture?: GenericEventHandler | undefined; - - // Keyboard Events - onKeyDown?: KeyboardEventHandler | undefined; - onKeyDownCapture?: KeyboardEventHandler | undefined; - onKeyPress?: KeyboardEventHandler | undefined; - onKeyPressCapture?: KeyboardEventHandler | undefined; - onKeyUp?: KeyboardEventHandler | undefined; - onKeyUpCapture?: KeyboardEventHandler | undefined; - - // Media Events - onAbort?: GenericEventHandler | undefined; - onAbortCapture?: GenericEventHandler | undefined; - onCanPlay?: GenericEventHandler | undefined; - onCanPlayCapture?: GenericEventHandler | undefined; - onCanPlayThrough?: GenericEventHandler | undefined; - onCanPlayThroughCapture?: GenericEventHandler | undefined; - onDurationChange?: GenericEventHandler | undefined; - onDurationChangeCapture?: GenericEventHandler | undefined; - onEmptied?: GenericEventHandler | undefined; - onEmptiedCapture?: GenericEventHandler | undefined; - onEncrypted?: GenericEventHandler | undefined; - onEncryptedCapture?: GenericEventHandler | undefined; - onEnded?: GenericEventHandler | undefined; - onEndedCapture?: GenericEventHandler | undefined; - onLoadedData?: GenericEventHandler | undefined; - onLoadedDataCapture?: GenericEventHandler | undefined; - onLoadedMetadata?: GenericEventHandler | undefined; - onLoadedMetadataCapture?: GenericEventHandler | undefined; - onLoadStart?: GenericEventHandler | undefined; - onLoadStartCapture?: GenericEventHandler | undefined; - onPause?: GenericEventHandler | undefined; - onPauseCapture?: GenericEventHandler | undefined; - onPlay?: GenericEventHandler | undefined; - onPlayCapture?: GenericEventHandler | undefined; - onPlaying?: GenericEventHandler | undefined; - onPlayingCapture?: GenericEventHandler | undefined; - onProgress?: GenericEventHandler | undefined; - onProgressCapture?: GenericEventHandler | undefined; - onRateChange?: GenericEventHandler | undefined; - onRateChangeCapture?: GenericEventHandler | undefined; - onSeeked?: GenericEventHandler | undefined; - onSeekedCapture?: GenericEventHandler | undefined; - onSeeking?: GenericEventHandler | undefined; - onSeekingCapture?: GenericEventHandler | undefined; - onStalled?: GenericEventHandler | undefined; - onStalledCapture?: GenericEventHandler | undefined; - onSuspend?: GenericEventHandler | undefined; - onSuspendCapture?: GenericEventHandler | undefined; - onTimeUpdate?: GenericEventHandler | undefined; - onTimeUpdateCapture?: GenericEventHandler | undefined; - onVolumeChange?: GenericEventHandler | undefined; - onVolumeChangeCapture?: GenericEventHandler | undefined; - onWaiting?: GenericEventHandler | undefined; - onWaitingCapture?: GenericEventHandler | undefined; - - // MouseEvents - onClick?: MouseEventHandler | undefined; - onClickCapture?: MouseEventHandler | undefined; - onContextMenu?: MouseEventHandler | undefined; - onContextMenuCapture?: MouseEventHandler | undefined; - onDblClick?: MouseEventHandler | undefined; - onDblClickCapture?: MouseEventHandler | undefined; - onDrag?: DragEventHandler | undefined; - onDragCapture?: DragEventHandler | undefined; - onDragEnd?: DragEventHandler | undefined; - onDragEndCapture?: DragEventHandler | undefined; - onDragEnter?: DragEventHandler | undefined; - onDragEnterCapture?: DragEventHandler | undefined; - onDragExit?: DragEventHandler | undefined; - onDragExitCapture?: DragEventHandler | undefined; - onDragLeave?: DragEventHandler | undefined; - onDragLeaveCapture?: DragEventHandler | undefined; - onDragOver?: DragEventHandler | undefined; - onDragOverCapture?: DragEventHandler | undefined; - onDragStart?: DragEventHandler | undefined; - onDragStartCapture?: DragEventHandler | undefined; - onDrop?: DragEventHandler | undefined; - onDropCapture?: DragEventHandler | undefined; - onMouseDown?: MouseEventHandler | undefined; - onMouseDownCapture?: MouseEventHandler | undefined; - onMouseEnter?: MouseEventHandler | undefined; - onMouseEnterCapture?: MouseEventHandler | undefined; - onMouseLeave?: MouseEventHandler | undefined; - onMouseLeaveCapture?: MouseEventHandler | undefined; - onMouseMove?: MouseEventHandler | undefined; - onMouseMoveCapture?: MouseEventHandler | undefined; - onMouseOut?: MouseEventHandler | undefined; - onMouseOutCapture?: MouseEventHandler | undefined; - onMouseOver?: MouseEventHandler | undefined; - onMouseOverCapture?: MouseEventHandler | undefined; - onMouseUp?: MouseEventHandler | undefined; - onMouseUpCapture?: MouseEventHandler | undefined; - - // Selection Events - onSelect?: GenericEventHandler | undefined; - onSelectCapture?: GenericEventHandler | undefined; - - // Touch Events - onTouchCancel?: TouchEventHandler | undefined; - onTouchCancelCapture?: TouchEventHandler | undefined; - onTouchEnd?: TouchEventHandler | undefined; - onTouchEndCapture?: TouchEventHandler | undefined; - onTouchMove?: TouchEventHandler | undefined; - onTouchMoveCapture?: TouchEventHandler | undefined; - onTouchStart?: TouchEventHandler | undefined; - onTouchStartCapture?: TouchEventHandler | undefined; - - // Pointer Events - onPointerOver?: PointerEventHandler | undefined; - onPointerOverCapture?: PointerEventHandler | undefined; - onPointerEnter?: PointerEventHandler | undefined; - onPointerEnterCapture?: PointerEventHandler | undefined; - onPointerDown?: PointerEventHandler | undefined; - onPointerDownCapture?: PointerEventHandler | undefined; - onPointerMove?: PointerEventHandler | undefined; - onPointerMoveCapture?: PointerEventHandler | undefined; - onPointerUp?: PointerEventHandler | undefined; - onPointerUpCapture?: PointerEventHandler | undefined; - onPointerCancel?: PointerEventHandler | undefined; - onPointerCancelCapture?: PointerEventHandler | undefined; - onPointerOut?: PointerEventHandler | undefined; - onPointerOutCapture?: PointerEventHandler | undefined; - onPointerLeave?: PointerEventHandler | undefined; - onPointerLeaveCapture?: PointerEventHandler | undefined; - onGotPointerCapture?: PointerEventHandler | undefined; - onGotPointerCaptureCapture?: PointerEventHandler | undefined; - onLostPointerCapture?: PointerEventHandler | undefined; - onLostPointerCaptureCapture?: PointerEventHandler | undefined; - - // UI Events - onScroll?: UIEventHandler | undefined; - onScrollEnd?: UIEventHandler | undefined; - onScrollCapture?: UIEventHandler | undefined; - - // Wheel Events - onWheel?: WheelEventHandler | undefined; - onWheelCapture?: WheelEventHandler | undefined; - - // Animation Events - onAnimationStart?: AnimationEventHandler | undefined; - onAnimationStartCapture?: AnimationEventHandler | undefined; - onAnimationEnd?: AnimationEventHandler | undefined; - onAnimationEndCapture?: AnimationEventHandler | undefined; - onAnimationIteration?: AnimationEventHandler | undefined; - onAnimationIterationCapture?: AnimationEventHandler | undefined; - - // Transition Events - onTransitionCancel?: TransitionEventHandler; - onTransitionCancelCapture?: TransitionEventHandler; - onTransitionEnd?: TransitionEventHandler; - onTransitionEndCapture?: TransitionEventHandler; - onTransitionRun?: TransitionEventHandler; - onTransitionRunCapture?: TransitionEventHandler; - onTransitionStart?: TransitionEventHandler; - onTransitionStartCapture?: TransitionEventHandler; - - // PictureInPicture Events - onEnterPictureInPicture?: ChangeEventHandler; - onEnterPictureInPictureCapture?: ChangeEventHandler; - onLeavePictureInPicture?: ChangeEventHandler; - onLeavePictureInPictureCapture?: ChangeEventHandler; - onResize?: ChangeEventHandler; - onResizeCapture?: ChangeEventHandler; -} - -export interface AriaAttributes { - /** Identifies the currently active element when DOM focus is on a composite widget, textbox, group, or application. */ - 'aria-activedescendant'?: Signalish; - /** Indicates whether assistive technologies will present all, or only parts of, the changed region based on the change notifications defined by the aria-relevant attribute. */ - 'aria-atomic'?: Signalish; - /** - * Indicates whether inputting text could trigger display of one or more predictions of the user's intended value for an input and specifies how predictions would be - * presented if they are made. - */ - 'aria-autocomplete'?: Signalish<'none' | 'inline' | 'list' | 'both' | undefined>; - /** - * Defines a string value that labels the current element, which is intended to be converted into Braille. - * @see aria-label. - */ - 'aria-braillelabel'?: Signalish; - /** - * Defines a human-readable, author-localized abbreviated description for the role of an element, which is intended to be converted into Braille. - * @see aria-roledescription. - */ - 'aria-brailleroledescription'?: Signalish; - /** Indicates an element is being modified and that assistive technologies MAY want to wait until the modifications are complete before exposing them to the user. */ - 'aria-busy'?: Signalish; - /** - * Indicates the current "checked" state of checkboxes, radio buttons, and other widgets. - * @see aria-pressed - * @see aria-selected. - */ - 'aria-checked'?: Signalish; - /** - * Defines the total number of columns in a table, grid, or treegrid. - * @see aria-colindex. - */ - 'aria-colcount'?: Signalish; - /** - * Defines an element's column index or position with respect to the total number of columns within a table, grid, or treegrid. - * @see aria-colcount - * @see aria-colspan. - */ - 'aria-colindex'?: Signalish; - /** - * Defines a human readable text alternative of aria-colindex. - * @see aria-rowindextext. - */ - 'aria-colindextext'?: Signalish; - /** - * Defines the number of columns spanned by a cell or gridcell within a table, grid, or treegrid. - * @see aria-colindex - * @see aria-rowspan. - */ - 'aria-colspan'?: Signalish; - /** - * Identifies the element (or elements) whose contents or presence are controlled by the current element. - * @see aria-owns. - */ - 'aria-controls'?: Signalish; - /** Indicates the element that represents the current item within a container or set of related elements. */ - 'aria-current'?: Signalish; - /** - * Identifies the element (or elements) that describes the object. - * @see aria-labelledby - */ - 'aria-describedby'?: Signalish; - /** - * Defines a string value that describes or annotates the current element. - * @see related aria-describedby. - */ - 'aria-description'?: Signalish; - /** - * Identifies the element that provides a detailed, extended description for the object. - * @see aria-describedby. - */ - 'aria-details'?: Signalish; - /** - * Indicates that the element is perceivable but disabled, so it is not editable or otherwise operable. - * @see aria-hidden - * @see aria-readonly. - */ - 'aria-disabled'?: Signalish; - /** - * Indicates what functions can be performed when a dragged object is released on the drop target. - * @deprecated in ARIA 1.1 - */ - 'aria-dropeffect'?: Signalish<'none' | 'copy' | 'execute' | 'link' | 'move' | 'popup' | undefined>; - /** - * Identifies the element that provides an error message for the object. - * @see aria-invalid - * @see aria-describedby. - */ - 'aria-errormessage'?: Signalish; - /** Indicates whether the element, or another grouping element it controls, is currently expanded or collapsed. */ - 'aria-expanded'?: Signalish; - /** - * Identifies the next element (or elements) in an alternate reading order of content which, at the user's discretion, - * allows assistive technology to override the general default of reading in document source order. - */ - 'aria-flowto'?: Signalish; - /** - * Indicates an element's "grabbed" state in a drag-and-drop operation. - * @deprecated in ARIA 1.1 - */ - 'aria-grabbed'?: Signalish; - /** Indicates the availability and type of interactive popup element, such as menu or dialog, that can be triggered by an element. */ - 'aria-haspopup'?: Signalish; - /** - * Indicates whether the element is exposed to an accessibility API. - * @see aria-disabled. - */ - 'aria-hidden'?: Signalish; - /** - * Indicates the entered value does not conform to the format expected by the application. - * @see aria-errormessage. - */ - 'aria-invalid'?: Signalish; - /** Indicates keyboard shortcuts that an author has implemented to activate or give focus to an element. */ - 'aria-keyshortcuts'?: Signalish; - /** - * Defines a string value that labels the current element. - * @see aria-labelledby. - */ - 'aria-label'?: Signalish; - /** - * Identifies the element (or elements) that labels the current element. - * @see aria-describedby. - */ - 'aria-labelledby'?: Signalish; - /** Defines the hierarchical level of an element within a structure. */ - 'aria-level'?: Signalish; - /** Indicates that an element will be updated, and describes the types of updates the user agents, assistive technologies, and user can expect from the live region. */ - 'aria-live'?: Signalish<'off' | 'assertive' | 'polite' | undefined>; - /** Indicates whether an element is modal when displayed. */ - 'aria-modal'?: Signalish; - /** Indicates whether a text box accepts multiple lines of input or only a single line. */ - 'aria-multiline'?: Signalish; - /** Indicates that the user may select more than one item from the current selectable descendants. */ - 'aria-multiselectable'?: Signalish; - /** Indicates whether the element's orientation is horizontal, vertical, or unknown/ambiguous. */ - 'aria-orientation'?: Signalish<'horizontal' | 'vertical' | undefined>; - /** - * Identifies an element (or elements) in order to define a visual, functional, or contextual parent/child relationship - * between DOM elements where the DOM hierarchy cannot be used to represent the relationship. - * @see aria-controls. - */ - 'aria-owns'?: Signalish; - /** - * Defines a short hint (a word or short phrase) intended to aid the user with data entry when the control has no value. - * A hint could be a sample value or a brief description of the expected format. - */ - 'aria-placeholder'?: Signalish; - /** - * Defines an element's number or position in the current set of listitems or treeitems. Not required if all elements in the set are present in the DOM. - * @see aria-setsize. - */ - 'aria-posinset'?: Signalish; - /** - * Indicates the current "pressed" state of toggle buttons. - * @see aria-checked - * @see aria-selected. - */ - 'aria-pressed'?: Signalish; - /** - * Indicates that the element is not editable, but is otherwise operable. - * @see aria-disabled. - */ - 'aria-readonly'?: Signalish; - /** - * Indicates what notifications the user agent will trigger when the accessibility tree within a live region is modified. - * @see aria-atomic. - */ - 'aria-relevant'?: Signalish< - | 'additions' - | 'additions removals' - | 'additions text' - | 'all' - | 'removals' - | 'removals additions' - | 'removals text' - | 'text' - | 'text additions' - | 'text removals' - | undefined - >; - /** Indicates that user input is required on the element before a form may be submitted. */ - 'aria-required'?: Signalish; - /** Defines a human-readable, author-localized description for the role of an element. */ - 'aria-roledescription'?: Signalish; - /** - * Defines the total number of rows in a table, grid, or treegrid. - * @see aria-rowindex. - */ - 'aria-rowcount'?: Signalish; - /** - * Defines an element's row index or position with respect to the total number of rows within a table, grid, or treegrid. - * @see aria-rowcount - * @see aria-rowspan. - */ - 'aria-rowindex'?: Signalish; - /** - * Defines a human readable text alternative of aria-rowindex. - * @see aria-colindextext. - */ - 'aria-rowindextext'?: Signalish; - /** - * Defines the number of rows spanned by a cell or gridcell within a table, grid, or treegrid. - * @see aria-rowindex - * @see aria-colspan. - */ - 'aria-rowspan'?: Signalish; - /** - * Indicates the current "selected" state of various widgets. - * @see aria-checked - * @see aria-pressed. - */ - 'aria-selected'?: Signalish; - /** - * Defines the number of items in the current set of listitems or treeitems. Not required if all elements in the set are present in the DOM. - * @see aria-posinset. - */ - 'aria-setsize'?: Signalish; - /** Indicates if items in a table or grid are sorted in ascending or descending order. */ - 'aria-sort'?: Signalish<'none' | 'ascending' | 'descending' | 'other' | undefined>; - /** Defines the maximum allowed value for a range widget. */ - 'aria-valuemax'?: Signalish; - /** Defines the minimum allowed value for a range widget. */ - 'aria-valuemin'?: Signalish; - /** - * Defines the current value for a range widget. - * @see aria-valuetext. - */ - 'aria-valuenow'?: Signalish; - /** Defines the human readable text alternative of aria-valuenow for a range widget. */ - 'aria-valuetext'?: Signalish; -} -// All the WAI-ARIA 1.2 role attribute values from https://www.w3.org/TR/wai-aria-1.2/#role_definitions -type WAIAriaRole = - | 'alert' - | 'alertdialog' - | 'application' - | 'article' - | 'banner' - | 'blockquote' - | 'button' - | 'caption' - | 'cell' - | 'checkbox' - | 'code' - | 'columnheader' - | 'combobox' - | 'command' - | 'complementary' - | 'composite' - | 'contentinfo' - | 'definition' - | 'deletion' - | 'dialog' - | 'directory' - | 'document' - | 'emphasis' - | 'feed' - | 'figure' - | 'form' - | 'generic' - | 'grid' - | 'gridcell' - | 'group' - | 'heading' - | 'img' - | 'input' - | 'insertion' - | 'landmark' - | 'link' - | 'list' - | 'listbox' - | 'listitem' - | 'log' - | 'main' - | 'marquee' - | 'math' - | 'meter' - | 'menu' - | 'menubar' - | 'menuitem' - | 'menuitemcheckbox' - | 'menuitemradio' - | 'navigation' - | 'none' - | 'note' - | 'option' - | 'paragraph' - | 'presentation' - | 'progressbar' - | 'radio' - | 'radiogroup' - | 'range' - | 'region' - | 'roletype' - | 'row' - | 'rowgroup' - | 'rowheader' - | 'scrollbar' - | 'search' - | 'searchbox' - | 'section' - | 'sectionhead' - | 'select' - | 'separator' - | 'slider' - | 'spinbutton' - | 'status' - | 'strong' - | 'structure' - | 'subscript' - | 'superscript' - | 'switch' - | 'tab' - | 'table' - | 'tablist' - | 'tabpanel' - | 'term' - | 'textbox' - | 'time' - | 'timer' - | 'toolbar' - | 'tooltip' - | 'tree' - | 'treegrid' - | 'treeitem' - | 'widget' - | 'window' - | 'none presentation'; - -// All the Digital Publishing WAI-ARIA 1.0 role attribute values from https://www.w3.org/TR/dpub-aria-1.0/#role_definitions -type DPubAriaRole = - | 'doc-abstract' - | 'doc-acknowledgments' - | 'doc-afterword' - | 'doc-appendix' - | 'doc-backlink' - | 'doc-biblioentry' - | 'doc-bibliography' - | 'doc-biblioref' - | 'doc-chapter' - | 'doc-colophon' - | 'doc-conclusion' - | 'doc-cover' - | 'doc-credit' - | 'doc-credits' - | 'doc-dedication' - | 'doc-endnote' - | 'doc-endnotes' - | 'doc-epigraph' - | 'doc-epilogue' - | 'doc-errata' - | 'doc-example' - | 'doc-footnote' - | 'doc-foreword' - | 'doc-glossary' - | 'doc-glossref' - | 'doc-index' - | 'doc-introduction' - | 'doc-noteref' - | 'doc-notice' - | 'doc-pagebreak' - | 'doc-pagelist' - | 'doc-part' - | 'doc-preface' - | 'doc-prologue' - | 'doc-pullquote' - | 'doc-qna' - | 'doc-subtitle' - | 'doc-tip' - | 'doc-toc'; -//用于处理HTML 属性或其他需要接受布尔值或布尔字符串的地方特别有用 -type Booleanish = boolean | 'true' | 'false'; -type AriaRole = WAIAriaRole | DPubAriaRole; -export interface HTMLAttributes - extends ClassAttributes, - DOMAttributes, - AriaAttributes { - // Standard HTML Attributes - accept?: string | undefined | SignalLike; - acceptCharset?: string | undefined | SignalLike; - 'accept-charset'?: HTMLAttributes['acceptCharset']; - accessKey?: string | undefined | SignalLike; - accesskey?: HTMLAttributes['accessKey']; - action?: string | undefined | SignalLike; - allow?: string | undefined | SignalLike; - allowFullScreen?: boolean | undefined | SignalLike; - allowTransparency?: boolean | undefined | SignalLike; - alt?: string | undefined | SignalLike; - as?: string | undefined | SignalLike; - async?: boolean | undefined | SignalLike; - autocomplete?: string | undefined | SignalLike; - autoComplete?: string | undefined | SignalLike; - autocorrect?: string | undefined | SignalLike; - autoCorrect?: string | undefined | SignalLike; - autofocus?: boolean | undefined | SignalLike; - autoFocus?: boolean | undefined | SignalLike; - autoPlay?: boolean | undefined | SignalLike; - autoplay?: boolean | undefined | SignalLike; - capture?: boolean | string | undefined | SignalLike; - cellPadding?: number | string | undefined | SignalLike; - cellSpacing?: number | string | undefined | SignalLike; - charSet?: string | undefined | SignalLike; - charset?: string | undefined | SignalLike; - challenge?: string | undefined | SignalLike; - checked?: boolean | undefined | SignalLike; - cite?: string | undefined | SignalLike; - class?: string | undefined | SignalLike; - className?: string | undefined | SignalLike; - cols?: number | undefined | SignalLike; - colSpan?: number | undefined | SignalLike; - colspan?: number | undefined | SignalLike; - content?: string | undefined | SignalLike; - contentEditable?: - | Booleanish - | '' - | 'plaintext-only' - | 'inherit' - | undefined - | SignalLike; - contenteditable?: HTMLAttributes['contentEditable']; - /** @deprecated See https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/contextmenu */ - contextMenu?: string | undefined | SignalLike; - /** @deprecated See https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/contextmenu */ - contextmenu?: string | undefined | SignalLike; - controls?: boolean | undefined | SignalLike; - controlsList?: string | undefined | SignalLike; - coords?: string | undefined | SignalLike; - crossOrigin?: string | undefined | SignalLike; - crossorigin?: string | undefined | SignalLike; - data?: string | undefined | SignalLike; - dateTime?: string | undefined | SignalLike; - datetime?: string | undefined | SignalLike; - default?: boolean | undefined | SignalLike; - defaultChecked?: boolean | undefined | SignalLike; - defaultValue?: string | undefined | SignalLike; - defer?: boolean | undefined | SignalLike; - dir?: 'auto' | 'rtl' | 'ltr' | undefined | SignalLike<'auto' | 'rtl' | 'ltr' | undefined>; - disabled?: boolean | undefined | SignalLike; - disableRemotePlayback?: boolean | undefined | SignalLike; - download?: any | undefined; - decoding?: 'sync' | 'async' | 'auto' | undefined | SignalLike<'sync' | 'async' | 'auto' | undefined>; - draggable?: boolean | undefined | SignalLike; - encType?: string | undefined | SignalLike; - enctype?: string | undefined | SignalLike; - enterkeyhint?: - | 'enter' - | 'done' - | 'go' - | 'next' - | 'previous' - | 'search' - | 'send' - | undefined - | SignalLike<'enter' | 'done' | 'go' | 'next' | 'previous' | 'search' | 'send' | undefined>; - elementTiming?: string | undefined | SignalLike; - elementtiming?: HTMLAttributes['elementTiming']; - exportparts?: string | undefined | SignalLike; - for?: string | undefined | SignalLike; - form?: string | undefined | SignalLike; - formAction?: string | undefined | SignalLike; - formaction?: string | undefined | SignalLike; - formEncType?: string | undefined | SignalLike; - formenctype?: string | undefined | SignalLike; - formMethod?: string | undefined | SignalLike; - formmethod?: string | undefined | SignalLike; - formNoValidate?: boolean | undefined | SignalLike; - formnovalidate?: boolean | undefined | SignalLike; - formTarget?: string | undefined | SignalLike; - formtarget?: string | undefined | SignalLike; - frameBorder?: number | string | undefined | SignalLike; - frameborder?: number | string | undefined | SignalLike; - headers?: string | undefined | SignalLike; - height?: number | string | undefined | SignalLike; - hidden?: boolean | 'hidden' | 'until-found' | undefined | SignalLike; - high?: number | undefined | SignalLike; - href?: string | undefined | SignalLike; - hrefLang?: string | undefined | SignalLike; - hreflang?: string | undefined | SignalLike; - htmlFor?: string | undefined | SignalLike; - httpEquiv?: string | undefined | SignalLike; - 'http-equiv'?: string | undefined | SignalLike; - icon?: string | undefined | SignalLike; - id?: string | undefined | SignalLike; - indeterminate?: boolean | undefined | SignalLike; - inert?: boolean | undefined | SignalLike; - inputMode?: string | undefined | SignalLike; - inputmode?: string | undefined | SignalLike; - integrity?: string | undefined | SignalLike; - is?: string | undefined | SignalLike; - keyParams?: string | undefined | SignalLike; - keyType?: string | undefined | SignalLike; - kind?: string | undefined | SignalLike; - label?: string | undefined | SignalLike; - lang?: string | undefined | SignalLike; - list?: string | undefined | SignalLike; - loading?: 'eager' | 'lazy' | undefined | SignalLike<'eager' | 'lazy' | undefined>; - loop?: boolean | undefined | SignalLike; - low?: number | undefined | SignalLike; - manifest?: string | undefined | SignalLike; - marginHeight?: number | undefined | SignalLike; - marginWidth?: number | undefined | SignalLike; - max?: number | string | undefined | SignalLike; - maxLength?: number | undefined | SignalLike; - maxlength?: number | undefined | SignalLike; - media?: string | undefined | SignalLike; - mediaGroup?: string | undefined | SignalLike; - method?: string | undefined | SignalLike; - min?: number | string | undefined | SignalLike; - minLength?: number | undefined | SignalLike; - minlength?: number | undefined | SignalLike; - multiple?: boolean | undefined | SignalLike; - muted?: boolean | undefined | SignalLike; - name?: string | undefined | SignalLike; - nomodule?: boolean | undefined | SignalLike; - nonce?: string | undefined | SignalLike; - noValidate?: boolean | undefined | SignalLike; - novalidate?: boolean | undefined | SignalLike; - open?: boolean | undefined | SignalLike; - optimum?: number | undefined | SignalLike; - part?: string | undefined | SignalLike; - pattern?: string | undefined | SignalLike; - ping?: string | undefined | SignalLike; - placeholder?: string | undefined | SignalLike; - playsInline?: boolean | undefined | SignalLike; - playsinline?: boolean | undefined | SignalLike; - popover?: - | 'auto' - | 'hint' - | 'manual' - | boolean - | undefined - | SignalLike<'auto' | 'hint' | 'manual' | boolean | undefined>; - popovertarget?: string | undefined | SignalLike; - popoverTarget?: string | undefined | SignalLike; - popovertargetaction?: 'hide' | 'show' | 'toggle' | undefined | SignalLike<'hide' | 'show' | 'toggle' | undefined>; - popoverTargetAction?: 'hide' | 'show' | 'toggle' | undefined | SignalLike<'hide' | 'show' | 'toggle' | undefined>; - poster?: string | undefined | SignalLike; - preload?: string | undefined | SignalLike; - radioGroup?: string | undefined | SignalLike; - readonly?: boolean | undefined | SignalLike; - readOnly?: boolean | undefined | SignalLike; - referrerpolicy?: - | 'no-referrer' - | 'no-referrer-when-downgrade' - | 'origin' - | 'origin-when-cross-origin' - | 'same-origin' - | 'strict-origin' - | 'strict-origin-when-cross-origin' - | 'unsafe-url' - | undefined - | SignalLike< - | 'no-referrer' - | 'no-referrer-when-downgrade' - | 'origin' - | 'origin-when-cross-origin' - | 'same-origin' - | 'strict-origin' - | 'strict-origin-when-cross-origin' - | 'unsafe-url' - | undefined - >; - rel?: string | undefined | SignalLike; - required?: boolean | undefined | SignalLike; - reversed?: boolean | undefined | SignalLike; - role?: AriaRole | undefined | SignalLike; - rows?: number | undefined | SignalLike; - rowSpan?: number | undefined | SignalLike; - rowspan?: number | undefined | SignalLike; - sandbox?: string | undefined | SignalLike; - scope?: string | undefined | SignalLike; - scoped?: boolean | undefined | SignalLike; - scrolling?: string | undefined | SignalLike; - seamless?: boolean | undefined | SignalLike; - selected?: boolean | undefined | SignalLike; - shape?: string | undefined | SignalLike; - size?: number | undefined | SignalLike; - sizes?: string | undefined | SignalLike; - slot?: string | undefined | SignalLike; - span?: number | undefined | SignalLike; - spellcheck?: boolean | undefined | SignalLike; - spellCheck?: boolean | undefined | SignalLike; - src?: string | undefined | SignalLike; - srcSet?: string | undefined | SignalLike; - srcset?: string | undefined | SignalLike; - srcDoc?: string | undefined | SignalLike; - srcdoc?: string | undefined | SignalLike; - srcLang?: string | undefined | SignalLike; - srclang?: string | undefined | SignalLike; - start?: number | undefined | SignalLike; - step?: number | string | undefined | SignalLike; - style?: string | CSSProperties | undefined | SignalLike; - summary?: string | undefined | SignalLike; - tabIndex?: number | undefined | SignalLike; - tabindex?: number | undefined | SignalLike; - target?: string | undefined | SignalLike; - title?: string | undefined | SignalLike; - type?: string | undefined | SignalLike; - useMap?: string | undefined | SignalLike; - usemap?: string | undefined | SignalLike; - value?: string | string[] | number | undefined | SignalLike; - volume?: string | number | undefined | SignalLike; - width?: number | string | undefined | SignalLike; - wmode?: string | undefined | SignalLike; - wrap?: string | undefined | SignalLike; - - // Non-standard Attributes - autocapitalize?: - | 'off' - | 'none' - | 'on' - | 'sentences' - | 'words' - | 'characters' - | undefined - | SignalLike<'off' | 'none' | 'on' | 'sentences' | 'words' | 'characters' | undefined>; - autoCapitalize?: - | 'off' - | 'none' - | 'on' - | 'sentences' - | 'words' - | 'characters' - | undefined - | SignalLike<'off' | 'none' | 'on' | 'sentences' | 'words' | 'characters' | undefined>; - disablePictureInPicture?: boolean | undefined | SignalLike; - results?: number | undefined | SignalLike; - translate?: boolean | undefined | SignalLike; - - // RDFa Attributes - about?: string | undefined | SignalLike; - datatype?: string | undefined | SignalLike; - inlist?: any; - prefix?: string | undefined | SignalLike; - property?: string | undefined | SignalLike; - resource?: string | undefined | SignalLike; - typeof?: string | undefined | SignalLike; - vocab?: string | undefined | SignalLike; - - // Microdata Attributes - itemProp?: string | undefined | SignalLike; - itemprop?: string | undefined | SignalLike; - itemScope?: boolean | undefined | SignalLike; - itemscope?: boolean | undefined | SignalLike; - itemType?: string | undefined | SignalLike; - itemtype?: string | undefined | SignalLike; - itemID?: string | undefined | SignalLike; - itemid?: string | undefined | SignalLike; - itemRef?: string | undefined | SignalLike; - itemref?: string | undefined | SignalLike; -} - -// eslint-disable-next-line @typescript-eslint/no-namespace -export declare namespace JSX { - // JSX内在元素的接口,该接口下声明了JSX中的内置标签及其具有的属性,如标签和标签的value属性 - export interface IntrinsicElements { - // HTML - a: HTMLAttributes; - abbr: HTMLAttributes; - address: HTMLAttributes; - area: HTMLAttributes; - article: HTMLAttributes; - aside: HTMLAttributes; - audio: HTMLAttributes; - b: HTMLAttributes; - base: HTMLAttributes; - bdi: HTMLAttributes; - bdo: HTMLAttributes; - big: HTMLAttributes; - blockquote: HTMLAttributes; - body: HTMLAttributes; - br: HTMLAttributes; - button: HTMLAttributes; - canvas: HTMLAttributes; - caption: HTMLAttributes; - cite: HTMLAttributes; - code: HTMLAttributes; - col: HTMLAttributes; - colgroup: HTMLAttributes; - data: HTMLAttributes; - datalist: HTMLAttributes; - dd: HTMLAttributes; - del: HTMLAttributes; - details: HTMLAttributes; - dfn: HTMLAttributes; - dialog: HTMLAttributes; - div: HTMLAttributes; - dl: HTMLAttributes; - dt: HTMLAttributes; - em: HTMLAttributes; - embed: HTMLAttributes; - fieldset: HTMLAttributes; - figcaption: HTMLAttributes; - figure: HTMLAttributes; - footer: HTMLAttributes; - form: HTMLAttributes; - h1: HTMLAttributes; - h2: HTMLAttributes; - h3: HTMLAttributes; - h4: HTMLAttributes; - h5: HTMLAttributes; - h6: HTMLAttributes; - head: HTMLAttributes; - header: HTMLAttributes; - hgroup: HTMLAttributes; - hr: HTMLAttributes; - html: HTMLAttributes; - i: HTMLAttributes; - iframe: HTMLAttributes; - img: HTMLAttributes; - input: HTMLAttributes; - ins: HTMLAttributes; - kbd: HTMLAttributes; - keygen: HTMLAttributes; - label: HTMLAttributes; - legend: HTMLAttributes; - li: HTMLAttributes; - link: HTMLAttributes; - main: HTMLAttributes; - map: HTMLAttributes; - mark: HTMLAttributes; - menu: HTMLAttributes; - menuitem: HTMLAttributes; - meta: HTMLAttributes; - meter: HTMLAttributes; - nav: HTMLAttributes; - noscript: HTMLAttributes; - object: HTMLAttributes; - ol: HTMLAttributes; - optgroup: HTMLAttributes; - option: HTMLAttributes; - output: HTMLAttributes; - p: HTMLAttributes; - picture: HTMLAttributes; - pre: HTMLAttributes; - progress: HTMLAttributes; - q: HTMLAttributes; - rp: HTMLAttributes; - rt: HTMLAttributes; - ruby: HTMLAttributes; - s: HTMLAttributes; - samp: HTMLAttributes; - script: HTMLAttributes; - search: HTMLAttributes; - section: HTMLAttributes; - select: HTMLAttributes; - slot: HTMLAttributes; - small: HTMLAttributes; - source: HTMLAttributes; - span: HTMLAttributes; - strong: HTMLAttributes; - style: HTMLAttributes; - sub: HTMLAttributes; - summary: HTMLAttributes; - sup: HTMLAttributes; - table: HTMLAttributes; - tbody: HTMLAttributes; - td: HTMLAttributes; - template: HTMLAttributes; - textarea: HTMLAttributes; - tfoot: HTMLAttributes; - th: HTMLAttributes; - thead: HTMLAttributes; - time: HTMLAttributes; - title: HTMLAttributes; - tr: HTMLAttributes; - track: HTMLAttributes; - u: HTMLAttributes; - ul: HTMLAttributes; - var: HTMLAttributes; - video: HTMLAttributes; - wbr: HTMLAttributes; - } - // 该接口声明了类组件中具有的属性 - interface IntrinsicClassAttributes { - ref: Ref; - key: any; - } - // 该接口声明了函数式组建中具有的属性 - interface IntrinsicAttributes { - key: any; - ref: Ref; - } - // 该接口声明了JSX中组件的元素、属性和子元素的类型 - export interface Element { - type?: any; - props?: any; - key?: any; - } - // 该接口定义了类组件所具有的属性、方法 - interface ElementClass { - setState(state: any, callback: () => void): void; - forceUpdate(callback: () => void): void; - render(): any; - } - // 该接口用于确定组件props中子元素的名称 - interface ElementChildrenAttribute { - children?: any; - } -} - // // --------------------------------- Inula Event Types---------------------------------- // @@ -1308,7 +296,7 @@ interface InulaBaseEvent { } // eslint-disable-next-line -interface SyntheticEvent extends InulaBaseEvent {} +export interface SyntheticEvent extends InulaBaseEvent {} export interface ClipboardEvent extends SyntheticEvent { clipboardData: DataTransfer; @@ -1445,29 +433,60 @@ export interface MouseEvent extends UIEven // export type EventHandler> = { bivarianceHack(event: E): void }['bivarianceHack']; -export type TargetedEvent = Omit< - TypedEvent, - 'currentTarget' -> & { - readonly currentTarget: Target; -}; -export type ClipboardEventHandler = EventHandler>; -export type CompositionEventHandler = EventHandler>; -export type DragEventHandler = EventHandler>; -export type FocusEventHandler = EventHandler>; -export type FormEventHandler = EventHandler>; -export type ChangeEventHandler = EventHandler>; -export type KeyboardEventHandler = EventHandler>; -export type MouseEventHandler = EventHandler>; -export type TouchEventHandler = EventHandler>; -export type PointerEventHandler = EventHandler>; -export type UIEventHandler = EventHandler>; -export type WheelEventHandler = EventHandler>; -export type AnimationEventHandler = EventHandler>; -export type TransitionEventHandler = EventHandler>; -type GenericEventHandler = (event: TargetedEvent) => void; + +export type InulaClipboardEventHandler = EventHandler>; +export type InulaCompositionEventHandler = EventHandler>; +export type InulaDragEventHandler = EventHandler>; +export type InulaFocusEventHandler = EventHandler>; +export type InulaFormEventHandler = EventHandler>; +export type InulaChangeEventHandler = EventHandler>; +export type InulaKeyboardEventHandler = EventHandler>; +export type InulaMouseEventHandler = EventHandler>; +export type InulaTouchEventHandler = EventHandler>; +export type InulaPointerEventHandler = EventHandler>; +export type InulaUIEventHandler = EventHandler>; +export type InulaWheelEventHandler = EventHandler>; +export type InulaAnimationEventHandler = EventHandler>; +export type InulaTransitionEventHandler = EventHandler>; + // // --------------------------------- Css Props---------------------------------- // export type CSSProperties = Record; + +// +// --------------------------------- VDOM --------------------------------------- +// +export type LegacyRef = string | Ref; +export interface ClassAttributes extends Attributes { + ref?: LegacyRef | undefined; +} + +export interface InulaCSSProperties extends CSSProperties {} + +export type InulaBoolean = boolean | 'true' | 'false'; + +export type InulaEventHandler = EventHandler>; + +declare global { + // eslint-disable-next-line @typescript-eslint/no-namespace + namespace JSX { + interface IntrinsicAttributes extends Attributes {} + interface Element extends InulaElement {} + + interface ElementClass extends Component { + render(): InulaNode; + } + + interface ElementAttributesProperty { + props: KVObject; + } + interface ElementChildrenAttribute { + children: KVObject; + } + interface IntrinsicClassAttributes extends ClassAttributes {} + + type IntrinsicElements = BaseElement; + } +} -- Gitee From 4affb53053ae8b04740a0f0a4e1c8bdea3ad0f60 Mon Sep 17 00:00:00 2001 From: eleliauk <2831336720@qq.com> Date: Thu, 26 Sep 2024 08:33:54 +0800 Subject: [PATCH 11/13] =?UTF-8?q?fix:=E4=BF=AE=E6=94=B9=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/package.json b/package.json index 4b5bc71f..7b702acc 100644 --- a/package.json +++ b/package.json @@ -62,6 +62,8 @@ "@types/node": "^17.0.18", "@typescript-eslint/eslint-plugin": "^6.18.1", "@typescript-eslint/parser": "6.18.1", + "@babel/parser": "^7.24.7", + "magic-string": "^0.30.10", "babel-jest": "^29.7.0", "ejs": "^3.1.8", "eslint": "^8.56.0", @@ -79,6 +81,8 @@ "rollup-plugin-dts": "^6.1.0", "rollup-plugin-execute": "^1.1.1", "rollup-plugin-terser": "^7.0.2", + "rollup-plugin-esbuild": "^6.1.1", + "rollup-plugin-polyfill-node": "^0.13.0", "ts-jest": "^29.1.1", "typescript": "^4.9.5" }, -- Gitee From 987100fd87d14e025166bff9dc0feb2abebb2089 Mon Sep 17 00:00:00 2001 From: eleliauk <2831336720@qq.com> Date: Thu, 26 Sep 2024 08:39:15 +0800 Subject: [PATCH 12/13] =?UTF-8?q?feat:=E6=95=B4=E5=90=88=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .DS_Store | Bin 0 -> 6148 bytes .../Simple-app/templates/vite/README.md | 4 - .../Simple-app/templates/webpack/src/App.jsx | 49 ---------- .../templates/webpack/src/index.jsx | 19 ---- .../generators/Simple-reactive-app/index.js | 43 --------- .../generators/Simple-reactive-app/meta.json | 3 - .../templates/vite/README.md | 4 - .../templates/vite/index.html | 11 --- .../templates/vite/package.json | 25 ------ .../templates/vite/src/ReactiveComponent.jsx | 38 -------- .../templates/vite/src/index.css | 57 ------------ .../templates/vite/src/index.jsx | 47 ---------- .../templates/vite/vite.config.js | 29 ------ .../templates/webpack/package.json | 29 ------ .../templates/webpack/src/App.jsx | 49 ---------- .../webpack/src/ReactiveComponent.jsx | 38 -------- .../templates/webpack/src/index.html | 11 --- .../templates/webpack/src/index.jsx | 19 ---- .../templates/webpack/src/styles.css | 57 ------------ .../templates/webpack/webpack.config.js | 84 ------------------ .../src/builtInPlugins/command/build/build.ts | 51 ----------- .../builtInPlugins/command/dev/buildDev.ts | 4 +- .../command/generate/generate.ts | 2 +- packages/inula-intl/package.json | 4 +- packages/inula-router/package.json | 1 + packages/inula/scripts/rollup/build-types.js | 2 +- .../inula/src/inulax/adapters/reduxReact.ts | 2 +- packages/inula/src/jsx-type/baseAttr.ts | 19 +--- packages/inula/src/jsx-type/baseElement.ts | 15 ---- packages/inula/src/jsx-type/index.ts | 15 ---- .../inula/src/renderer/hooks/HookExternal.ts | 7 +- .../inula/src/renderer/vnode/VNodeCreator.ts | 2 +- packages/inula/src/types.ts | 8 +- 33 files changed, 17 insertions(+), 731 deletions(-) create mode 100644 .DS_Store delete mode 100644 packages/create-inula/lib/generators/Simple-app/templates/vite/README.md delete mode 100644 packages/create-inula/lib/generators/Simple-app/templates/webpack/src/App.jsx delete mode 100644 packages/create-inula/lib/generators/Simple-app/templates/webpack/src/index.jsx delete mode 100644 packages/create-inula/lib/generators/Simple-reactive-app/index.js delete mode 100644 packages/create-inula/lib/generators/Simple-reactive-app/meta.json delete mode 100644 packages/create-inula/lib/generators/Simple-reactive-app/templates/vite/README.md delete mode 100644 packages/create-inula/lib/generators/Simple-reactive-app/templates/vite/index.html delete mode 100644 packages/create-inula/lib/generators/Simple-reactive-app/templates/vite/package.json delete mode 100644 packages/create-inula/lib/generators/Simple-reactive-app/templates/vite/src/ReactiveComponent.jsx delete mode 100644 packages/create-inula/lib/generators/Simple-reactive-app/templates/vite/src/index.css delete mode 100644 packages/create-inula/lib/generators/Simple-reactive-app/templates/vite/src/index.jsx delete mode 100644 packages/create-inula/lib/generators/Simple-reactive-app/templates/vite/vite.config.js delete mode 100644 packages/create-inula/lib/generators/Simple-reactive-app/templates/webpack/package.json delete mode 100644 packages/create-inula/lib/generators/Simple-reactive-app/templates/webpack/src/App.jsx delete mode 100644 packages/create-inula/lib/generators/Simple-reactive-app/templates/webpack/src/ReactiveComponent.jsx delete mode 100644 packages/create-inula/lib/generators/Simple-reactive-app/templates/webpack/src/index.html delete mode 100644 packages/create-inula/lib/generators/Simple-reactive-app/templates/webpack/src/index.jsx delete mode 100644 packages/create-inula/lib/generators/Simple-reactive-app/templates/webpack/src/styles.css delete mode 100644 packages/create-inula/lib/generators/Simple-reactive-app/templates/webpack/webpack.config.js delete mode 100644 packages/inula-cli/src/builtInPlugins/command/build/build.ts diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..337e03f0ce5511da8d1ddbb8c40edc61859a791b GIT binary patch literal 6148 zcmeHK%Sr<=6g|;`^???2;YOGru;3qzeINy`VC!0KtEJj@#46%$_Wpyv;P<)Gb8oVk znbxg}+*@u=lDQ|jJz>Z+tTg+PHq~9ASJ#u8jIHXrU)mQ_zP{%3S=;915 z)NsyPi|r$_Cm0mi?*;Y>ju~A?lZ+0U`DnLSh%PgF#0;;w*UVTJa&xbR_zlJ-7%=jJ zxk&AaJJmezV~%%^E6#Jra>#hqf&6JczolV;S4N&!$WOI<%V@XB_$hsYedd+uj8(jF z)(OV>xgg4Ax!W1;Gr14Ub{6KBj2Digie^Vy<*GHAR|6-+1uLeSW*HS_94m_}#?0GX z|1N8tg?!OA%V*Q<7Zu={EmoF2z|0gd1x$gg0QT227J3CBme{Svx_lZ4 zCkhw`Og-`m&3P)(Q(d@XI8SGP6yoB5sYg$T3zrWUW_IC*;&gV7A89yT?9ob7z!b 请注意由于Vite插件有node版本限制,请使用`node -v`命令确认node版本大于等于node v18。 \ No newline at end of file diff --git a/packages/create-inula/lib/generators/Simple-app/templates/webpack/src/App.jsx b/packages/create-inula/lib/generators/Simple-app/templates/webpack/src/App.jsx deleted file mode 100644 index 75e326c4..00000000 --- a/packages/create-inula/lib/generators/Simple-app/templates/webpack/src/App.jsx +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Technologies Co.,Ltd. - * - * openInula is licensed under Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * - * http://license.coscl.org.cn/MulanPSL2 - * - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -import Inula from 'openinula'; -import './styles.css'; - -class App extends Inula.Component { - render() { - return ( -

-
-

欢迎来到 Inula 项目!

-

你已成功创建你的第一个 Inula 项目

-
-
-
-

开始吧

-

- 编辑 src/App.js 并保存以重新加载。 -

-
-
-

了解更多

-

- 要了解 Inula,查看{' '} - - Inula 官网 - -

-
-
-
- ); - } -} - -export default App; diff --git a/packages/create-inula/lib/generators/Simple-app/templates/webpack/src/index.jsx b/packages/create-inula/lib/generators/Simple-app/templates/webpack/src/index.jsx deleted file mode 100644 index c384f05a..00000000 --- a/packages/create-inula/lib/generators/Simple-app/templates/webpack/src/index.jsx +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Technologies Co.,Ltd. - * - * openInula is licensed under Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * - * http://license.coscl.org.cn/MulanPSL2 - * - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -import Inula from 'openinula'; -import App from './App'; - -Inula.render(, document.getElementById('root')); diff --git a/packages/create-inula/lib/generators/Simple-reactive-app/index.js b/packages/create-inula/lib/generators/Simple-reactive-app/index.js deleted file mode 100644 index 2d52bc4b..00000000 --- a/packages/create-inula/lib/generators/Simple-reactive-app/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Technologies Co.,Ltd. - * - * openInula is licensed under Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * - * http://license.coscl.org.cn/MulanPSL2 - * - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -const BasicGenerator = require('../../BasicGenerator'); - -class Generator extends BasicGenerator { - prompting() { - return this.prompt([ - { - type: 'list', - name: 'bundlerType', - message: 'Please select the build type', - choices: ['webpack', 'vite'], - }, - ]).then(props => { - this.prompts = props; - }); - } - - writing() { - const src = this.templatePath(this.prompts.bundlerType); - const dest = this.destinationPath(); - this.writeFiles(src, dest, { - context: { - ...this.prompts, - }, - }); - } -} - -module.exports = Generator; diff --git a/packages/create-inula/lib/generators/Simple-reactive-app/meta.json b/packages/create-inula/lib/generators/Simple-reactive-app/meta.json deleted file mode 100644 index 8f8f9e66..00000000 --- a/packages/create-inula/lib/generators/Simple-reactive-app/meta.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "description": "simple reactive app template." -} diff --git a/packages/create-inula/lib/generators/Simple-reactive-app/templates/vite/README.md b/packages/create-inula/lib/generators/Simple-reactive-app/templates/vite/README.md deleted file mode 100644 index 542c363a..00000000 --- a/packages/create-inula/lib/generators/Simple-reactive-app/templates/vite/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# openinula + vite - -该模板提供了 `openinula` 工作在 `vite`的基础配置。 -> 请注意由于Vite插件有node版本限制,请使用`node -v`命令确认node版本大于等于node v18。 \ No newline at end of file diff --git a/packages/create-inula/lib/generators/Simple-reactive-app/templates/vite/index.html b/packages/create-inula/lib/generators/Simple-reactive-app/templates/vite/index.html deleted file mode 100644 index 9f37946a..00000000 --- a/packages/create-inula/lib/generators/Simple-reactive-app/templates/vite/index.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - - My Inula App - - -
- - - diff --git a/packages/create-inula/lib/generators/Simple-reactive-app/templates/vite/package.json b/packages/create-inula/lib/generators/Simple-reactive-app/templates/vite/package.json deleted file mode 100644 index f74bdda6..00000000 --- a/packages/create-inula/lib/generators/Simple-reactive-app/templates/vite/package.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "name": "inula-vite-app", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "start": "vite", - "build": "vite build" - }, - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "openinula": "0.0.0-experimental-20231201" - }, - "devDependencies": { - "@babel/core": "^7.21.4", - "@babel/preset-env": "^7.21.4", - "@babel/preset-react": "^7.18.6", - "@vitejs/plugin-react": "^3.1.0", - "@vitejs/plugin-react-refresh": "^1.3.6", - "babel-plugin-import": "^1.13.6", - "vite": "^4.2.1" - } -} diff --git a/packages/create-inula/lib/generators/Simple-reactive-app/templates/vite/src/ReactiveComponent.jsx b/packages/create-inula/lib/generators/Simple-reactive-app/templates/vite/src/ReactiveComponent.jsx deleted file mode 100644 index cca83f05..00000000 --- a/packages/create-inula/lib/generators/Simple-reactive-app/templates/vite/src/ReactiveComponent.jsx +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Technologies Co.,Ltd. - * - * openInula is licensed under Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * - * http://license.coscl.org.cn/MulanPSL2 - * - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -import Inula, { useComputed, useReactive, useRef } from 'openinula'; - -function ReactiveComponent() { - const renderCount = ++useRef(0).current; - - const data = useReactive({ count: 0 }); - const countText = useComputed(() => { - return `计时: ${data.count.get()}`; - }); - - setInterval(() => { - data.count.set(c => c + 1); - }, 1000); - - return ( -
-
{countText}
-
组件渲染次数:{renderCount}
-
- ); -} - -export default ReactiveComponent; diff --git a/packages/create-inula/lib/generators/Simple-reactive-app/templates/vite/src/index.css b/packages/create-inula/lib/generators/Simple-reactive-app/templates/vite/src/index.css deleted file mode 100644 index f08fdb8a..00000000 --- a/packages/create-inula/lib/generators/Simple-reactive-app/templates/vite/src/index.css +++ /dev/null @@ -1,57 +0,0 @@ -* { - box-sizing: border-box; -} - -body, -html { - margin: 0; - padding: 0; - font-family: 'Montserrat', sans-serif; - line-height: 1.6; - color: #fff; - background: linear-gradient(120deg, #6a11cb 0%, #2575fc 100%); - height: 100vh; - display: flex; - align-items: center; - justify-content: center; -} - -.container { - text-align: center; -} - -.hero-title { - font-size: 3em; - margin-bottom: 20px; -} - -.hero-subtitle { - font-size: 1.5em; - margin-bottom: 50px; -} - -.content { - display: flex; - justify-content: space-between; - align-items: center; - margin: 1vh; -} - -.card { - background: rgba(255, 255, 255, 0.1); - border-radius: 5px; - padding: 20px; - width: 100%; - box-shadow: 0px 8px 15px rgba(0, 0, 0, 0.1); - backdrop-filter: blur(4px); -} - -.card h2, -.card p { - color: #fff; -} - -.card a { - color: #fff; - text-decoration: underline; -} diff --git a/packages/create-inula/lib/generators/Simple-reactive-app/templates/vite/src/index.jsx b/packages/create-inula/lib/generators/Simple-reactive-app/templates/vite/src/index.jsx deleted file mode 100644 index bab57690..00000000 --- a/packages/create-inula/lib/generators/Simple-reactive-app/templates/vite/src/index.jsx +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Technologies Co.,Ltd. - * - * openInula is licensed under Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * - * http://license.coscl.org.cn/MulanPSL2 - * - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -import Inula from 'openinula'; -import ReactiveComponent from './ReactiveComponent'; -import './index.css'; - -function App() { - return ( -
-
-

欢迎来到 Inula 项目!

-

你已成功创建你的第一个响应式 Inula 项目

-
-
-
- -
-
-
-
-

了解更多

-

- 要了解 Inula,查看{' '} - - Inula 官网 - -

-
-
-
- ); -} - -Inula.render(, document.getElementById('root')); diff --git a/packages/create-inula/lib/generators/Simple-reactive-app/templates/vite/vite.config.js b/packages/create-inula/lib/generators/Simple-reactive-app/templates/vite/vite.config.js deleted file mode 100644 index 43065ece..00000000 --- a/packages/create-inula/lib/generators/Simple-reactive-app/templates/vite/vite.config.js +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Technologies Co.,Ltd. - * - * openInula is licensed under Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * - * http://license.coscl.org.cn/MulanPSL2 - * - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -import react from '@vitejs/plugin-react'; - -let alias = { - react: 'openinula', // 新增 - 'react-dom': 'openinula', // 新增 - 'react/jsx-dev-runtime': 'openinula/jsx-dev-runtime', -}; - -export default { - plugins: [react()], - resolve: { - alias, - }, -}; diff --git a/packages/create-inula/lib/generators/Simple-reactive-app/templates/webpack/package.json b/packages/create-inula/lib/generators/Simple-reactive-app/templates/webpack/package.json deleted file mode 100644 index 783f626a..00000000 --- a/packages/create-inula/lib/generators/Simple-reactive-app/templates/webpack/package.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "name": "inula-webpack-app", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "start": "webpack serve --mode development", - "build": "webpack --mode production" - }, - "author": "", - "license": "ISC", - "dependencies": { - "openinula": "0.0.0-experimental-20231201" - }, - "devDependencies": { - "@babel/core": "^7.21.4", - "@babel/preset-env": "^7.21.4", - "@babel/preset-react": "^7.18.6", - "babel-loader": "^9.1.2", - "css-loader": "^6.7.3", - "file-loader": "^6.2.0", - "html-webpack-plugin": "^5.5.0", - "style-loader": "^3.3.2", - "url-loader": "^4.1.1", - "webpack": "^5.77.0", - "webpack-cli": "^5.0.1", - "webpack-dev-server": "^4.13.2" - } -} diff --git a/packages/create-inula/lib/generators/Simple-reactive-app/templates/webpack/src/App.jsx b/packages/create-inula/lib/generators/Simple-reactive-app/templates/webpack/src/App.jsx deleted file mode 100644 index a8b52c96..00000000 --- a/packages/create-inula/lib/generators/Simple-reactive-app/templates/webpack/src/App.jsx +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Technologies Co.,Ltd. - * - * openInula is licensed under Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * - * http://license.coscl.org.cn/MulanPSL2 - * - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -import Inula from 'openinula'; -import ReactiveComponent from './ReactiveComponent'; -import './styles.css'; - -class App extends Inula.Component { - render() { - return ( -
-
-

欢迎来到 Inula 项目!

-

你已成功创建你的第一个响应式 Inula 项目

-
-
-
- -
-
-
-
-

了解更多

-

- 要了解 Inula,查看{' '} - - Inula 官网 - -

-
-
-
- ); - } -} - -export default App; diff --git a/packages/create-inula/lib/generators/Simple-reactive-app/templates/webpack/src/ReactiveComponent.jsx b/packages/create-inula/lib/generators/Simple-reactive-app/templates/webpack/src/ReactiveComponent.jsx deleted file mode 100644 index cca83f05..00000000 --- a/packages/create-inula/lib/generators/Simple-reactive-app/templates/webpack/src/ReactiveComponent.jsx +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Technologies Co.,Ltd. - * - * openInula is licensed under Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * - * http://license.coscl.org.cn/MulanPSL2 - * - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -import Inula, { useComputed, useReactive, useRef } from 'openinula'; - -function ReactiveComponent() { - const renderCount = ++useRef(0).current; - - const data = useReactive({ count: 0 }); - const countText = useComputed(() => { - return `计时: ${data.count.get()}`; - }); - - setInterval(() => { - data.count.set(c => c + 1); - }, 1000); - - return ( -
-
{countText}
-
组件渲染次数:{renderCount}
-
- ); -} - -export default ReactiveComponent; diff --git a/packages/create-inula/lib/generators/Simple-reactive-app/templates/webpack/src/index.html b/packages/create-inula/lib/generators/Simple-reactive-app/templates/webpack/src/index.html deleted file mode 100644 index c966e725..00000000 --- a/packages/create-inula/lib/generators/Simple-reactive-app/templates/webpack/src/index.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - - Inula App - - -
- - - diff --git a/packages/create-inula/lib/generators/Simple-reactive-app/templates/webpack/src/index.jsx b/packages/create-inula/lib/generators/Simple-reactive-app/templates/webpack/src/index.jsx deleted file mode 100644 index c384f05a..00000000 --- a/packages/create-inula/lib/generators/Simple-reactive-app/templates/webpack/src/index.jsx +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Technologies Co.,Ltd. - * - * openInula is licensed under Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * - * http://license.coscl.org.cn/MulanPSL2 - * - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -import Inula from 'openinula'; -import App from './App'; - -Inula.render(, document.getElementById('root')); diff --git a/packages/create-inula/lib/generators/Simple-reactive-app/templates/webpack/src/styles.css b/packages/create-inula/lib/generators/Simple-reactive-app/templates/webpack/src/styles.css deleted file mode 100644 index f08fdb8a..00000000 --- a/packages/create-inula/lib/generators/Simple-reactive-app/templates/webpack/src/styles.css +++ /dev/null @@ -1,57 +0,0 @@ -* { - box-sizing: border-box; -} - -body, -html { - margin: 0; - padding: 0; - font-family: 'Montserrat', sans-serif; - line-height: 1.6; - color: #fff; - background: linear-gradient(120deg, #6a11cb 0%, #2575fc 100%); - height: 100vh; - display: flex; - align-items: center; - justify-content: center; -} - -.container { - text-align: center; -} - -.hero-title { - font-size: 3em; - margin-bottom: 20px; -} - -.hero-subtitle { - font-size: 1.5em; - margin-bottom: 50px; -} - -.content { - display: flex; - justify-content: space-between; - align-items: center; - margin: 1vh; -} - -.card { - background: rgba(255, 255, 255, 0.1); - border-radius: 5px; - padding: 20px; - width: 100%; - box-shadow: 0px 8px 15px rgba(0, 0, 0, 0.1); - backdrop-filter: blur(4px); -} - -.card h2, -.card p { - color: #fff; -} - -.card a { - color: #fff; - text-decoration: underline; -} diff --git a/packages/create-inula/lib/generators/Simple-reactive-app/templates/webpack/webpack.config.js b/packages/create-inula/lib/generators/Simple-reactive-app/templates/webpack/webpack.config.js deleted file mode 100644 index 8b46f7a5..00000000 --- a/packages/create-inula/lib/generators/Simple-reactive-app/templates/webpack/webpack.config.js +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Technologies Co.,Ltd. - * - * openInula is licensed under Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * - * http://license.coscl.org.cn/MulanPSL2 - * - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -const path = require('path'); -const HtmlWebpackPlugin = require('html-webpack-plugin'); - -module.exports = { - entry: './src/index.jsx', - output: { - path: path.resolve(__dirname, 'dist'), - filename: 'bundle.js', - }, - module: { - rules: [ - { - test: /\.(js|jsx)$/, - exclude: /node_modules/, - use: { - loader: 'babel-loader', - options: { - presets: [ - '@babel/preset-env', - [ - '@babel/preset-react', - { - runtime: 'automatic', // 新增 - importSource: 'openinula', // 新增 - }, - ], - ], - }, - }, - }, - { - test: /\.css$/, - use: ['style-loader', 'css-loader'], - }, - { - test: /\.(png|jpe?g|gif)$/i, - use: [ - { - loader: 'file-loader', - options: { - name: '[name].[ext]', - outputPath: 'images/', - publicPath: 'images/', - }, - }, - ], - }, - { - test: /\.(woff|woff2|eot|ttf|otf)$/, - use: ['file-loader'], - }, - ], - }, - plugins: [ - new HtmlWebpackPlugin({ - template: path.resolve(__dirname, 'src/index.html'), - filename: 'index.html', - }), - ], - devServer: { - static: path.join(__dirname, 'dist'), - compress: true, - port: 9000, - open: true, - }, - resolve: { - extensions: ['.mjs', '.js', '.mts', '.ts', '.jsx', '.tsx', '.json'], - }, -}; diff --git a/packages/inula-cli/src/builtInPlugins/command/build/build.ts b/packages/inula-cli/src/builtInPlugins/command/build/build.ts deleted file mode 100644 index ff9a89f8..00000000 --- a/packages/inula-cli/src/builtInPlugins/command/build/build.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Technologies Co.,Ltd. - * - * openInula is licensed under Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * - * http://license.coscl.org.cn/MulanPSL2 - * - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -import webpack from 'webpack'; -import { build } from 'vite'; - -export default (api: any) => { - api.registerCommand({ - name: 'build', - description: 'build application for production', - initialState: api.buildConfig, - fn: async function (args: any, state: any) { - switch (api.compileMode) { - case 'webpack': - if (state) { - api.applyHook({ name: 'beforeCompile', args: state }); - state.forEach((s: any) => { - webpack(s.config, (err: any, stats: any) => { - if (err || stats.hasErrors()) { - api.logger.error(`Build failed.err: ${err}, stats:${stats}`); - } - }); - }); - } else { - api.logger.error(`Build failed. Can't find build config.`); - } - break; - case 'vite': - if (state) { - api.applyHook({ name: 'beforeCompile' }); - build(state); - } else { - api.logger.error(`Build failed. Can't find build config.`); - } - break; - } - }, - }); -}; diff --git a/packages/inula-cli/src/builtInPlugins/command/dev/buildDev.ts b/packages/inula-cli/src/builtInPlugins/command/dev/buildDev.ts index 400fbe53..9ffccf76 100644 --- a/packages/inula-cli/src/builtInPlugins/command/dev/buildDev.ts +++ b/packages/inula-cli/src/builtInPlugins/command/dev/buildDev.ts @@ -57,7 +57,7 @@ export default (api: API) => { api.applyHook({ name: 'afterStartDevServer' }); }); } else { - api.logger.error('Can\'t find config'); + api.logger.error("Can't find config"); } break; case 'vite': @@ -70,7 +70,7 @@ export default (api: API) => { server.printUrls(); }); } else { - api.logger.error('Can\'t find config'); + api.logger.error("Can't find config"); } break; default: diff --git a/packages/inula-cli/src/builtInPlugins/command/generate/generate.ts b/packages/inula-cli/src/builtInPlugins/command/generate/generate.ts index 777aefe8..e71f4f96 100644 --- a/packages/inula-cli/src/builtInPlugins/command/generate/generate.ts +++ b/packages/inula-cli/src/builtInPlugins/command/generate/generate.ts @@ -33,7 +33,7 @@ export default (api: API) => { args._.shift(); } if (args._.length === 0) { - api.logger.warn('Can\'t find any generate options.'); + api.logger.warn("Can't find any generate options."); return; } diff --git a/packages/inula-intl/package.json b/packages/inula-intl/package.json index abb1877f..6474226c 100644 --- a/packages/inula-intl/package.json +++ b/packages/inula-intl/package.json @@ -35,8 +35,8 @@ "html-webpack-plugin": "^5.5.1", "jest-environment-jsdom": "^29.5.0", "jsdom": "^21.1.1", - "react": "18.2.0", - "react-dom": "18.2.0", + "react": "18.2.0-h3", + "react-dom": "18.2.0-h3", "rollup-plugin-livereload": "^2.0.5", "rollup-plugin-serve": "^1.1.0", "rollup-plugin-visualizer": "^5.10.0", diff --git a/packages/inula-router/package.json b/packages/inula-router/package.json index 1b0dea78..b11c0537 100644 --- a/packages/inula-router/package.json +++ b/packages/inula-router/package.json @@ -21,6 +21,7 @@ ], "license": "MulanPSL2", "devDependencies": { + "@cloudsop/horizon": "^0.0.58", "@testing-library/jest-dom": "^5.16.5", "@testing-library/react": "^14.0.0", "@testing-library/user-event": "^14.4.3", diff --git a/packages/inula/scripts/rollup/build-types.js b/packages/inula/scripts/rollup/build-types.js index c76bbd83..a695a00f 100644 --- a/packages/inula/scripts/rollup/build-types.js +++ b/packages/inula/scripts/rollup/build-types.js @@ -210,7 +210,7 @@ function patchNamespaceType() { } else if (node.type === 'ExportNamedDeclaration' && !node.source) { for (let i = 0; i < node.specifiers.length; i++) { const spec = node.specifiers[i]; - if (spec.type === 'ExportSpecifier' && spec.local.name !== LIB_NAME) { + if (spec.type === 'ExportSpecifier' && spec.local.name != LIB_NAME) { assert(spec.exported.type === 'Identifier'); const exported = spec.exported.name; if (!moduleSet.has(spec.local.name)) { diff --git a/packages/inula/src/inulax/adapters/reduxReact.ts b/packages/inula/src/inulax/adapters/reduxReact.ts index 984d0924..9c150f87 100644 --- a/packages/inula/src/inulax/adapters/reduxReact.ts +++ b/packages/inula/src/inulax/adapters/reduxReact.ts @@ -114,7 +114,7 @@ export type MergePropsP = ( ) => MergedProps; type WrappedComponent = (props: OwnProps & WrapperInnerProps) => ReturnType; -export type OriginalComponent = (props: MergedProps) => ReturnType; +type OriginalComponent = (props: MergedProps) => ReturnType; type Connector = (Component: OriginalComponent) => WrappedComponent; export type ConnectOption = { /** @deprecated */ diff --git a/packages/inula/src/jsx-type/baseAttr.ts b/packages/inula/src/jsx-type/baseAttr.ts index c7408125..e81ef2a4 100644 --- a/packages/inula/src/jsx-type/baseAttr.ts +++ b/packages/inula/src/jsx-type/baseAttr.ts @@ -1,18 +1,3 @@ -/* - * Copyright (c) 2024 Huawei Technologies Co.,Ltd. - * - * openInula is licensed under Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * - * http://license.coscl.org.cn/MulanPSL2 - * - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - */ - import { InulaAnimationEventHandler, InulaChangeEventHandler, @@ -21,9 +6,10 @@ import { InulaCompositionEventHandler, InulaDragEventHandler, InulaFocusEventHandler, - InulaEventHandler, + InulaFormEventHandler, InulaBoolean, InulaCSSProperties, + InulaEventHandler, InulaNode, KVObject, InulaKeyboardEventHandler, @@ -33,7 +19,6 @@ import { InulaTransitionEventHandler, InulaUIEventHandler, InulaWheelEventHandler, - InulaFormEventHandler, } from '../types'; type HTMLAttributeReferrerPolicy = diff --git a/packages/inula/src/jsx-type/baseElement.ts b/packages/inula/src/jsx-type/baseElement.ts index 15edf1c6..9d0f7339 100644 --- a/packages/inula/src/jsx-type/baseElement.ts +++ b/packages/inula/src/jsx-type/baseElement.ts @@ -1,18 +1,3 @@ -/* - * Copyright (c) 2024 Huawei Technologies Co.,Ltd. - * - * openInula is licensed under Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * - * http://license.coscl.org.cn/MulanPSL2 - * - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - */ - export interface HTMLElement extends Element {} export interface HTMLAnchorElement extends HTMLElement {} export interface HTMLAreaElement extends HTMLElement {} diff --git a/packages/inula/src/jsx-type/index.ts b/packages/inula/src/jsx-type/index.ts index 616b62b6..febfde4d 100644 --- a/packages/inula/src/jsx-type/index.ts +++ b/packages/inula/src/jsx-type/index.ts @@ -1,18 +1,3 @@ -/* - * Copyright (c) 2024 Huawei Technologies Co.,Ltd. - * - * openInula is licensed under Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * - * http://license.coscl.org.cn/MulanPSL2 - * - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - */ - import { ClassAttributes, InulaElement, InulaNode, LegacyRef } from '../types'; import { AllHTMLAttributes, diff --git a/packages/inula/src/renderer/hooks/HookExternal.ts b/packages/inula/src/renderer/hooks/HookExternal.ts index 4c84e216..44e2dc04 100644 --- a/packages/inula/src/renderer/hooks/HookExternal.ts +++ b/packages/inula/src/renderer/hooks/HookExternal.ts @@ -24,7 +24,7 @@ import { useReducerImpl } from './UseReducerHook'; import { useStateImpl } from './UseStateHook'; import { getNewContext } from '../components/context/Context'; import { getProcessingVNode } from '../GlobalVar'; -import type { MutableRef, RefCallBack, RefObject, Trigger } from './HookType'; +import type { MutableRef, RefCallBack, RefObject } from './HookType'; import type { BasicStateAction, @@ -45,11 +45,10 @@ export function useContext(Context: ContextType | Context): T { export function useState(initialState: (() => S) | S): [S, Dispatch>]; export function useState(): [S | undefined, Dispatch>]; -export function useState( - initialState?: (() => S) | S -): [S | undefined, Trigger<((arg0: S) => S | undefined) | S | undefined>] | void { +export function useState(initialState?: (() => S) | S): [S, Dispatch>] { return useStateImpl(initialState); } + export function useReducer, I>( reducer: R, initialArg: I, diff --git a/packages/inula/src/renderer/vnode/VNodeCreator.ts b/packages/inula/src/renderer/vnode/VNodeCreator.ts index 2185ab58..7cff3478 100644 --- a/packages/inula/src/renderer/vnode/VNodeCreator.ts +++ b/packages/inula/src/renderer/vnode/VNodeCreator.ts @@ -75,7 +75,7 @@ export function getLazyVNodeTag(lazyComp: any): string { } else if (lazyComp !== undefined && lazyComp !== null && typeLazyMap[lazyComp.vtype]) { return typeLazyMap[lazyComp.vtype]; } - throw Error('Inula can\'t resolve the content of lazy'); + throw Error("Inula can't resolve the content of lazy"); } // 创建processing diff --git a/packages/inula/src/types.ts b/packages/inula/src/types.ts index d318cbd3..458318ef 100644 --- a/packages/inula/src/types.ts +++ b/packages/inula/src/types.ts @@ -44,9 +44,7 @@ interface InulaErrorInfo { } // eslint-disable-next-line @typescript-eslint/ban-types -export type KVObject = { - // vtype: number; -}; +export type KVObject = {}; export type InulaFragment = Iterable; @@ -58,12 +56,12 @@ export interface ExoticComponent

{ (props: P): InulaElement | null; } -export interface ProviderProps { +interface ProviderProps { value: T; children?: InulaNode | undefined; } -export interface ConsumerProps { +interface ConsumerProps { children: (value: T) => InulaNode; } -- Gitee From c96df21a7272a87d128c8df08f0e3e898aacbcdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=A6=E6=83=B3=E8=B7=9F=E8=80=81=E7=99=BB=E4=B8=80?= =?UTF-8?q?=E6=A0=B7=E5=8E=89=E5=AE=B3?= <2831336720@qq.com> Date: Thu, 26 Sep 2024 00:41:17 +0000 Subject: [PATCH 13/13] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20.D?= =?UTF-8?q?S=5FStore?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .DS_Store | Bin 6148 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 337e03f0ce5511da8d1ddbb8c40edc61859a791b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHK%Sr<=6g|;`^???2;YOGru;3qzeINy`VC!0KtEJj@#46%$_Wpyv;P<)Gb8oVk znbxg}+*@u=lDQ|jJz>Z+tTg+PHq~9ASJ#u8jIHXrU)mQ_zP{%3S=;915 z)NsyPi|r$_Cm0mi?*;Y>ju~A?lZ+0U`DnLSh%PgF#0;;w*UVTJa&xbR_zlJ-7%=jJ zxk&AaJJmezV~%%^E6#Jra>#hqf&6JczolV;S4N&!$WOI<%V@XB_$hsYedd+uj8(jF z)(OV>xgg4Ax!W1;Gr14Ub{6KBj2Digie^Vy<*GHAR|6-+1uLeSW*HS_94m_}#?0GX z|1N8tg?!OA%V*Q<7Zu={EmoF2z|0gd1x$gg0QT227J3CBme{Svx_lZ4 zCkhw`Og-`m&3P)(Q(d@XI8SGP6yoB5sYg$T3zrWUW_IC*;&gV7A89yT?9ob7z!b