From 972dad91e9a87c6baf99f2745d57f1d119aaa8ca Mon Sep 17 00:00:00 2001 From: mununki Date: Mon, 23 Sep 2024 14:23:22 +0900 Subject: [PATCH 1/2] deprecate v3 --- src/v3/ReactDOMStyle_V3.res | 8 +- src/v3/ReactDOM_V3.res | 21 +-- src/v3/ReactEvent_V3.res | 268 +++++++++++++++++++++--------------- src/v3/React_V3.res | 188 +++++++++++++------------ 4 files changed, 274 insertions(+), 211 deletions(-) diff --git a/src/v3/ReactDOMStyle_V3.res b/src/v3/ReactDOMStyle_V3.res index 19c04a4..93d9711 100644 --- a/src/v3/ReactDOMStyle_V3.res +++ b/src/v3/ReactDOMStyle_V3.res @@ -1,6 +1,6 @@ type t = ReactDOMStyle.t -@obj +@obj @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external make: ( ~azimuth: string=?, ~background: string=?, @@ -420,16 +420,18 @@ external make: ( ) => t = "" /* CSS2Properties: https://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSS2Properties */ -@val +@val @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external combine: (@as(json`{}`) _, t, t) => t = "Object.assign" +@deprecated("Jsx 3 is deprecated, use jsx 4 instead") external _dictToStyle: Js.Dict.t => t = "%identity" +@deprecated("Jsx 3 is deprecated, use jsx 4 instead") let unsafeAddProp = (style, key, value) => { let dict = Js.Dict.empty() Js.Dict.set(dict, key, value) combine(style, _dictToStyle(dict)) } -@val +@val @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external unsafeAddStyle: (@as(json`{}`) _, t, {..}) => t = "Object.assign" diff --git a/src/v3/ReactDOM_V3.res b/src/v3/ReactDOM_V3.res index 80dd3aa..cfbea88 100644 --- a/src/v3/ReactDOM_V3.res +++ b/src/v3/ReactDOM_V3.res @@ -6,33 +6,35 @@ calls and add the appropriate `require("react-dom")` in the file calling this `render` */ // Helper so that ReactDOM itself doesn't bring any runtime -@val @return(nullable) +@val @return(nullable) @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external querySelector: string => option = "document.querySelector" -@module("react-dom") +@module("react-dom") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external render: (React.element, Dom.element) => unit = "render" module Experimental = { type root = ReactDOM.Client.Root.t - @module("react-dom") + @module("react-dom") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external createRoot: Dom.element => root = "createRoot" - @module("react-dom") + @module("react-dom") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external createBlockingRoot: Dom.element => root = "createBlockingRoot" - @send external render: (root, React.element) => unit = "render" + @send @deprecated("Jsx 3 is deprecated, use jsx 4 instead") + external render: (root, React.element) => unit = "render" } -@module("react-dom") +@module("react-dom") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external hydrate: (React.element, Dom.element) => unit = "hydrate" -@module("react-dom") +@module("react-dom") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external createPortal: (React.element, Dom.element) => React.element = "createPortal" -@module("react-dom") +@module("react-dom") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external unmountComponentAtNode: Dom.element => unit = "unmountComponentAtNode" +@deprecated("Jsx 3 is deprecated, use jsx 4 instead") external domElementToObj: Dom.element => {..} = "%identity" type style = ReactDOMStyle.t @@ -44,7 +46,9 @@ module Ref = { type currentDomRef = React.ref> type callbackDomRef = Js.nullable => unit + @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external domRef: currentDomRef => domRef = "%identity" + @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external callbackDomRef: callbackDomRef => domRef = "%identity" } @@ -2108,6 +2112,7 @@ include Props // As we've removed `ReactDOMRe.createElement`, this enables patterns like // React.createElement(ReactDOM.stringToComponent(multiline ? "textarea" : "input"), ...) +@deprecated("Jsx 3 is deprecated, use jsx 4 instead") external stringToComponent: string => React.component = "%identity" module Style = ReactDOMStyle diff --git a/src/v3/ReactEvent_V3.res b/src/v3/ReactEvent_V3.res index da92752..b142d0b 100644 --- a/src/v3/ReactEvent_V3.res +++ b/src/v3/ReactEvent_V3.res @@ -5,55 +5,76 @@ module MakeEventWithType = ( type t }, ) => { - @get external bubbles: Type.t => bool = "bubbles" - @get external cancelable: Type.t => bool = "cancelable" - @get + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") + external bubbles: Type.t => bool = "bubbles" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") + external cancelable: Type.t => bool = "cancelable" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external currentTarget: Type.t => {..} = "currentTarget" /* Should return Dom.eventTarget */ - @get external defaultPrevented: Type.t => bool = "defaultPrevented" - @get external eventPhase: Type.t => int = "eventPhase" - @get external isTrusted: Type.t => bool = "isTrusted" - @get external nativeEvent: Type.t => {..} = "nativeEvent" /* Should return Dom.event */ - @send external preventDefault: Type.t => unit = "preventDefault" - @send + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") + external defaultPrevented: Type.t => bool = "defaultPrevented" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") + external eventPhase: Type.t => int = "eventPhase" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") + external isTrusted: Type.t => bool = "isTrusted" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") + external nativeEvent: Type.t => {..} = "nativeEvent" /* Should return Dom.event */ + @send @deprecated("Jsx 3 is deprecated, use jsx 4 instead") + external preventDefault: Type.t => unit = "preventDefault" + @send @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external isDefaultPrevented: Type.t => bool = "isDefaultPrevented" - @send external stopPropagation: Type.t => unit = "stopPropagation" - @send + @send @deprecated("Jsx 3 is deprecated, use jsx 4 instead") + external stopPropagation: Type.t => unit = "stopPropagation" + @send @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external isPropagationStopped: Type.t => bool = "isPropagationStopped" - @get external target: Type.t => {..} = "target" /* Should return Dom.eventTarget */ - @get external timeStamp: Type.t => float = "timeStamp" - @get external type_: Type.t => string = "type" - @send external persist: Type.t => unit = "persist" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") + external target: Type.t => {..} = "target" /* Should return Dom.eventTarget */ + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") + external timeStamp: Type.t => float = "timeStamp" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") + external type_: Type.t => string = "type" + @send @deprecated("Jsx 3 is deprecated, use jsx 4 instead") + external persist: Type.t => unit = "persist" } module Synthetic = { type tag = ReactEvent.Synthetic.tag type t = synthetic - @get external bubbles: synthetic<'a> => bool = "bubbles" - @get external cancelable: synthetic<'a> => bool = "cancelable" - @get + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") + external bubbles: synthetic<'a> => bool = "bubbles" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") + external cancelable: synthetic<'a> => bool = "cancelable" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external currentTarget: synthetic<'a> => {..} = "currentTarget" /* Should return Dom.eventTarget */ - @get + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external defaultPrevented: synthetic<'a> => bool = "defaultPrevented" - @get external eventPhase: synthetic<'a> => int = "eventPhase" - @get external isTrusted: synthetic<'a> => bool = "isTrusted" - @get + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") + external eventPhase: synthetic<'a> => int = "eventPhase" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") + external isTrusted: synthetic<'a> => bool = "isTrusted" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external nativeEvent: synthetic<'a> => {..} = "nativeEvent" /* Should return Dom.event */ - @send + @send @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external preventDefault: synthetic<'a> => unit = "preventDefault" - @send + @send @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external isDefaultPrevented: synthetic<'a> => bool = "isDefaultPrevented" - @send + @send @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external stopPropagation: synthetic<'a> => unit = "stopPropagation" - @send + @send @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external isPropagationStopped: synthetic<'a> => bool = "isPropagationStopped" - @get external target: synthetic<'a> => {..} = "target" /* Should return Dom.eventTarget */ - @get external timeStamp: synthetic<'a> => float = "timeStamp" - @get external type_: synthetic<'a> => string = "type" - @send external persist: synthetic<'a> => unit = "persist" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") + external target: synthetic<'a> => {..} = "target" /* Should return Dom.eventTarget */ + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") + external timeStamp: synthetic<'a> => float = "timeStamp" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") + external type_: synthetic<'a> => string = "type" + @send @deprecated("Jsx 3 is deprecated, use jsx 4 instead") + external persist: synthetic<'a> => unit = "persist" } /* Cast any event type to the general synthetic type. This is safe, since synthetic is more general */ +@deprecated("Jsx 3 is deprecated, use jsx 4 instead") external toSyntheticEvent: synthetic<'a> => Synthetic.t = "%identity" module Clipboard = { @@ -62,7 +83,9 @@ module Clipboard = { include MakeEventWithType({ type t = t }) - @get external clipboardData: t => {..} = "clipboardData" /* Should return Dom.dataTransfer */ + + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") + external clipboardData: t => {..} = "clipboardData" /* Should return Dom.dataTransfer */ } module Composition = { @@ -71,7 +94,7 @@ module Composition = { include MakeEventWithType({ type t = t }) - @get external data: t => string = "data" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external data: t => string = "data" } module Keyboard = { @@ -80,19 +103,22 @@ module Keyboard = { include MakeEventWithType({ type t = t }) - @get external altKey: t => bool = "altKey" - @get external charCode: t => int = "charCode" - @get external ctrlKey: t => bool = "ctrlKey" - @send + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external altKey: t => bool = "altKey" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") + external charCode: t => int = "charCode" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external ctrlKey: t => bool = "ctrlKey" + @send @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external getModifierState: (t, string) => bool = "getModifierState" - @get external key: t => string = "key" - @get external keyCode: t => int = "keyCode" - @get external locale: t => string = "locale" - @get external location: t => int = "location" - @get external metaKey: t => bool = "metaKey" - @get external repeat: t => bool = "repeat" - @get external shiftKey: t => bool = "shiftKey" - @get external which: t => int = "which" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external key: t => string = "key" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external keyCode: t => int = "keyCode" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external locale: t => string = "locale" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") + external location: t => int = "location" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external metaKey: t => bool = "metaKey" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external repeat: t => bool = "repeat" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") + external shiftKey: t => bool = "shiftKey" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external which: t => int = "which" } module Focus = { @@ -101,7 +127,7 @@ module Focus = { include MakeEventWithType({ type t = t }) - @get @return(nullable) + @get @return(nullable) @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external relatedTarget: t => option<{..}> = "relatedTarget" /* Should return Dom.eventTarget */ } @@ -119,24 +145,27 @@ module Mouse = { include MakeEventWithType({ type t = t }) - @get external altKey: t => bool = "altKey" - @get external button: t => int = "button" - @get external buttons: t => int = "buttons" - @get external clientX: t => int = "clientX" - @get external clientY: t => int = "clientY" - @get external ctrlKey: t => bool = "ctrlKey" - @send + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external altKey: t => bool = "altKey" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external button: t => int = "button" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external buttons: t => int = "buttons" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external clientX: t => int = "clientX" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external clientY: t => int = "clientY" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external ctrlKey: t => bool = "ctrlKey" + @send @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external getModifierState: (t, string) => bool = "getModifierState" - @get external metaKey: t => bool = "metaKey" - @get external movementX: t => int = "movementX" - @get external movementY: t => int = "movementY" - @get external pageX: t => int = "pageX" - @get external pageY: t => int = "pageY" - @get @return(nullable) + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external metaKey: t => bool = "metaKey" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") + external movementX: t => int = "movementX" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") + external movementY: t => int = "movementY" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external pageX: t => int = "pageX" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external pageY: t => int = "pageY" + @get @return(nullable) @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external relatedTarget: t => option<{..}> = "relatedTarget" /* Should return Dom.eventTarget */ - @get external screenX: t => int = "screenX" - @get external screenY: t => int = "screenY" - @get external shiftKey: t => bool = "shiftKey" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external screenX: t => int = "screenX" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external screenY: t => int = "screenY" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") + external shiftKey: t => bool = "shiftKey" } module Pointer = { @@ -147,43 +176,52 @@ module Pointer = { }) // UIEvent - @get external detail: t => int = "detail" - @get external view: t => Dom.window = "view" /* Should return DOMAbstractView/WindowProxy */ + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external detail: t => int = "detail" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") + external view: t => Dom.window = "view" /* Should return DOMAbstractView/WindowProxy */ // MouseEvent - @get external screenX: t => int = "screenX" - @get external screenY: t => int = "screenY" - @get external clientX: t => int = "clientX" - @get external clientY: t => int = "clientY" - @get external pageX: t => int = "pageX" - @get external pageY: t => int = "pageY" - @get external movementX: t => int = "movementX" - @get external movementY: t => int = "movementY" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external screenX: t => int = "screenX" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external screenY: t => int = "screenY" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external clientX: t => int = "clientX" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external clientY: t => int = "clientY" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external pageX: t => int = "pageX" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external pageY: t => int = "pageY" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") + external movementX: t => int = "movementX" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") + external movementY: t => int = "movementY" - @get external ctrlKey: t => bool = "ctrlKey" - @get external shiftKey: t => bool = "shiftKey" - @get external altKey: t => bool = "altKey" - @get external metaKey: t => bool = "metaKey" - @send + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external ctrlKey: t => bool = "ctrlKey" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") + external shiftKey: t => bool = "shiftKey" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external altKey: t => bool = "altKey" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external metaKey: t => bool = "metaKey" + @send @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external getModifierState: (t, string) => bool = "getModifierState" - @get external button: t => int = "button" - @get external buttons: t => int = "buttons" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external button: t => int = "button" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external buttons: t => int = "buttons" - @get @return(nullable) + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") @return(nullable) external relatedTarget: t => option<{..}> = "relatedTarget" /* Should return Dom.eventTarget */ // PointerEvent - @get external pointerId: t => Dom.eventPointerId = "pointerId" - @get external width: t => float = "width" - @get external height: t => float = "height" - @get external pressure: t => float = "pressure" - @get external tangentialPressure: t => float = "tangentialPressure" - @get external tiltX: t => int = "tiltX" - @get external tiltY: t => int = "tiltY" - @get external twist: t => int = "twist" - @get external pointerType: t => string = "pointerType" - @get external isPrimary: t => bool = "isPrimary" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") + external pointerId: t => Dom.eventPointerId = "pointerId" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external width: t => float = "width" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external height: t => float = "height" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") + external pressure: t => float = "pressure" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") + external tangentialPressure: t => float = "tangentialPressure" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external tiltX: t => int = "tiltX" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external tiltY: t => int = "tiltY" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external twist: t => int = "twist" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") + external pointerType: t => string = "pointerType" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") + external isPrimary: t => bool = "isPrimary" } module Selection = { @@ -200,15 +238,19 @@ module Touch = { include MakeEventWithType({ type t = t }) - @get external altKey: t => bool = "altKey" - @get external changedTouches: t => {..} = "changedTouches" /* Should return Dom.touchList */ - @get external ctrlKey: t => bool = "ctrlKey" - @send + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external altKey: t => bool = "altKey" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") + external changedTouches: t => {..} = "changedTouches" /* Should return Dom.touchList */ + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external ctrlKey: t => bool = "ctrlKey" + @send @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external getModifierState: (t, string) => bool = "getModifierState" - @get external metaKey: t => bool = "metaKey" - @get external shiftKey: t => bool = "shiftKey" - @get external targetTouches: t => {..} = "targetTouches" /* Should return Dom.touchList */ - @get external touches: t => {..} = "touches" /* Should return Dom.touchList */ + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external metaKey: t => bool = "metaKey" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") + external shiftKey: t => bool = "shiftKey" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") + external targetTouches: t => {..} = "targetTouches" /* Should return Dom.touchList */ + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") + external touches: t => {..} = "touches" /* Should return Dom.touchList */ } module UI = { @@ -217,8 +259,9 @@ module UI = { include MakeEventWithType({ type t = t }) - @get external detail: t => int = "detail" - @get external view: t => Dom.window = "view" /* Should return DOMAbstractView/WindowProxy */ + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external detail: t => int = "detail" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") + external view: t => Dom.window = "view" /* Should return DOMAbstractView/WindowProxy */ } module Wheel = { @@ -227,10 +270,11 @@ module Wheel = { include MakeEventWithType({ type t = t }) - @get external deltaMode: t => int = "deltaMode" - @get external deltaX: t => float = "deltaX" - @get external deltaY: t => float = "deltaY" - @get external deltaZ: t => float = "deltaZ" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") + external deltaMode: t => int = "deltaMode" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external deltaX: t => float = "deltaX" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external deltaY: t => float = "deltaY" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external deltaZ: t => float = "deltaZ" } module Media = { @@ -255,9 +299,12 @@ module Animation = { include MakeEventWithType({ type t = t }) - @get external animationName: t => string = "animationName" - @get external pseudoElement: t => string = "pseudoElement" - @get external elapsedTime: t => float = "elapsedTime" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") + external animationName: t => string = "animationName" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") + external pseudoElement: t => string = "pseudoElement" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") + external elapsedTime: t => float = "elapsedTime" } module Transition = { @@ -266,7 +313,10 @@ module Transition = { include MakeEventWithType({ type t = t }) - @get external propertyName: t => string = "propertyName" - @get external pseudoElement: t => string = "pseudoElement" - @get external elapsedTime: t => float = "elapsedTime" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") + external propertyName: t => string = "propertyName" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") + external pseudoElement: t => string = "pseudoElement" + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") + external elapsedTime: t => float = "elapsedTime" } diff --git a/src/v3/React_V3.res b/src/v3/React_V3.res index beeb4ac..4b4de7a 100644 --- a/src/v3/React_V3.res +++ b/src/v3/React_V3.res @@ -1,12 +1,16 @@ /** Binding to React.element enables the compatibility with v3 */ type element = React.element -@val external null: element = "null" +@deprecated("Jsx 3 is deprecated, use jsx 4 instead") @val external null: element = "null" +@deprecated("Jsx 3 is deprecated, use jsx 4 instead") external float: float => element = "%identity" +@deprecated("Jsx 3 is deprecated, use jsx 4 instead") external int: int => element = "%identity" +@deprecated("Jsx 3 is deprecated, use jsx 4 instead") external string: string => element = "%identity" +@deprecated("Jsx 3 is deprecated, use jsx 4 instead") external array: array => element = "%identity" type componentLike<'props, 'return> = React.componentLike<'props, 'return> @@ -14,15 +18,16 @@ type componentLike<'props, 'return> = React.componentLike<'props, 'return> type component<'props> = React.component<'props> /* this function exists to prepare for making `component` abstract */ +@deprecated("Jsx 3 is deprecated, use jsx 4 instead") external component: componentLike<'props, element> => component<'props> = "%identity" -@module("react") +@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external createElement: (component<'props>, 'props) => element = "createElement" -@module("react") +@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external cloneElement: (element, 'props) => element = "cloneElement" -@variadic @module("react") +@variadic @module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external createElementVariadic: (component<'props>, 'props, array) => element = "createElement" @@ -51,23 +56,23 @@ module Ref = { external setCurrent: (ref<'value>, 'value) => unit = "current" } -@module("react") +@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external createRef: unit => ref> = "createRef" module Children = { - @module("react") @scope("Children") + @module("react") @scope("Children") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external map: (element, element => element) => element = "map" - @module("react") @scope("Children") + @module("react") @scope("Children") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external mapWithIndex: (element, @uncurry (element, int) => element) => element = "map" - @module("react") @scope("Children") + @module("react") @scope("Children") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external forEach: (element, element => unit) => unit = "forEach" - @module("react") @scope("Children") + @module("react") @scope("Children") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external forEachWithIndex: (element, @uncurry (element, int) => unit) => unit = "forEach" - @module("react") @scope("Children") + @module("react") @scope("Children") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external count: element => int = "count" - @module("react") @scope("Children") + @module("react") @scope("Children") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external only: element => element = "only" - @module("react") @scope("Children") + @module("react") @scope("Children") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external toArray: element => array = "toArray" } @@ -81,53 +86,53 @@ module Context = { unit, ) => {"value": 'props, "children": element} = "" - @get + @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external provider: t<'props> => component<{"value": 'props, "children": element}> = "Provider" } -@module("react") +@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external createContext: 'a => Context.t<'a> = "createContext" -@module("react") +@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external forwardRef: (@uncurry ('props, Js.Nullable.t>) => element) => component<'props> = "forwardRef" -@module("react") +@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external memo: component<'props> => component<'props> = "memo" -@module("react") +@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external memoCustomCompareProps: ( component<'props>, @uncurry ('props, 'props) => bool, ) => component<'props> = "memo" module Fragment = { - @obj + @obj @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external makeProps: (~children: element, ~key: 'key=?, unit) => {"children": element} = "" - @module("react") + @module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external make: component<{ "children": element, }> = "Fragment" } module StrictMode = { - @obj + @obj @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external makeProps: (~children: element, ~key: 'key=?, unit) => {"children": element} = "" - @module("react") + @module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external make: component<{ "children": element, }> = "StrictMode" } module Suspense = { - @obj + @obj @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external makeProps: ( ~children: element=?, ~fallback: element=?, ~key: 'key=?, unit, ) => {"children": option, "fallback": option} = "" - @module("react") + @module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external make: component<{ "children": option, "fallback": option, @@ -142,205 +147,206 @@ module Suspense = { * them differently. Lazy initializer + callback which returns state is the * only way to safely have any type of state and be able to update it correctly. */ -@module("react") +@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external useState: (@uncurry (unit => 'state)) => ('state, ('state => 'state) => unit) = "useState" -@module("react") +@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external useReducer: (@uncurry ('state, 'action) => 'state, 'state) => ('state, 'action => unit) = "useReducer" -@module("react") +@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external useReducerWithMapState: ( @uncurry ('state, 'action) => 'state, 'initialState, @uncurry ('initialState => 'state), ) => ('state, 'action => unit) = "useReducer" -@module("react") +@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external useEffectOnEveryRender: (@uncurry (unit => option unit>)) => unit = "useEffect" -@module("react") +@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external useEffect: (@uncurry (unit => option unit>), 'deps) => unit = "useEffect" -@module("react") +@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external useEffect0: (@uncurry (unit => option unit>), @as(json`[]`) _) => unit = "useEffect" -@module("react") +@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external useEffect1: (@uncurry (unit => option unit>), array<'a>) => unit = "useEffect" -@module("react") +@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external useEffect2: (@uncurry (unit => option unit>), ('a, 'b)) => unit = "useEffect" -@module("react") +@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external useEffect3: (@uncurry (unit => option unit>), ('a, 'b, 'c)) => unit = "useEffect" -@module("react") +@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external useEffect4: (@uncurry (unit => option unit>), ('a, 'b, 'c, 'd)) => unit = "useEffect" -@module("react") +@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external useEffect5: (@uncurry (unit => option unit>), ('a, 'b, 'c, 'd, 'e)) => unit = "useEffect" -@module("react") +@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external useEffect6: (@uncurry (unit => option unit>), ('a, 'b, 'c, 'd, 'e, 'f)) => unit = "useEffect" -@module("react") +@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external useEffect7: ( @uncurry (unit => option unit>), ('a, 'b, 'c, 'd, 'e, 'f, 'g), ) => unit = "useEffect" -@module("react") +@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external useLayoutEffectOnEveryRender: (@uncurry (unit => option unit>)) => unit = "useLayoutEffect" -@module("react") +@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external useLayoutEffect: (@uncurry (unit => option unit>), 'deps) => unit = "useLayoutEffect" -@module("react") +@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external useLayoutEffect0: (@uncurry (unit => option unit>), @as(json`[]`) _) => unit = "useLayoutEffect" -@module("react") +@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external useLayoutEffect1: (@uncurry (unit => option unit>), array<'a>) => unit = "useLayoutEffect" -@module("react") +@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external useLayoutEffect2: (@uncurry (unit => option unit>), ('a, 'b)) => unit = "useLayoutEffect" -@module("react") +@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external useLayoutEffect3: (@uncurry (unit => option unit>), ('a, 'b, 'c)) => unit = "useLayoutEffect" -@module("react") +@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external useLayoutEffect4: (@uncurry (unit => option unit>), ('a, 'b, 'c, 'd)) => unit = "useLayoutEffect" -@module("react") +@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external useLayoutEffect5: (@uncurry (unit => option unit>), ('a, 'b, 'c, 'd, 'e)) => unit = "useLayoutEffect" -@module("react") +@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external useLayoutEffect6: ( @uncurry (unit => option unit>), ('a, 'b, 'c, 'd, 'e, 'f), ) => unit = "useLayoutEffect" -@module("react") +@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external useLayoutEffect7: ( @uncurry (unit => option unit>), ('a, 'b, 'c, 'd, 'e, 'f, 'g), ) => unit = "useLayoutEffect" -@module("react") +@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external useMemo: (@uncurry (unit => 'any), 'deps) => 'any = "useMemo" -@module("react") +@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external useMemo0: (@uncurry (unit => 'any), @as(json`[]`) _) => 'any = "useMemo" -@module("react") +@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external useMemo1: (@uncurry (unit => 'any), array<'a>) => 'any = "useMemo" -@module("react") +@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external useMemo2: (@uncurry (unit => 'any), ('a, 'b)) => 'any = "useMemo" -@module("react") +@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external useMemo3: (@uncurry (unit => 'any), ('a, 'b, 'c)) => 'any = "useMemo" -@module("react") +@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external useMemo4: (@uncurry (unit => 'any), ('a, 'b, 'c, 'd)) => 'any = "useMemo" -@module("react") +@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external useMemo5: (@uncurry (unit => 'any), ('a, 'b, 'c, 'd, 'e)) => 'any = "useMemo" -@module("react") +@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external useMemo6: (@uncurry (unit => 'any), ('a, 'b, 'c, 'd, 'e, 'f)) => 'any = "useMemo" -@module("react") +@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external useMemo7: (@uncurry (unit => 'any), ('a, 'b, 'c, 'd, 'e, 'f, 'g)) => 'any = "useMemo" -@module("react") +@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external useCallback: ('f, 'deps) => 'f = "useCallback" -@module("react") +@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external useCallback0: ('f, @as(json`[]`) _) => 'f = "useCallback" -@module("react") +@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external useCallback1: ('f, array<'a>) => 'f = "useCallback" -@module("react") +@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external useCallback2: ('f, ('a, 'b)) => 'f = "useCallback" -@module("react") +@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external useCallback3: ('f, ('a, 'b, 'c)) => 'f = "useCallback" -@module("react") +@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external useCallback4: ('f, ('a, 'b, 'c, 'd)) => 'f = "useCallback" -@module("react") +@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external useCallback5: ('f, ('a, 'b, 'c, 'd, 'e)) => 'f = "useCallback" -@module("react") +@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external useCallback6: ('callback, ('a, 'b, 'c, 'd, 'e, 'f)) => 'callback = "useCallback" -@module("react") +@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external useCallback7: ('callback, ('a, 'b, 'c, 'd, 'e, 'f, 'g)) => 'callback = "useCallback" -@module("react") +@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external useContext: Context.t<'any> => 'any = "useContext" -@module("react") external useRef: 'value => ref<'value> = "useRef" +@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") +external useRef: 'value => ref<'value> = "useRef" -@module("react") +@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external useImperativeHandleOnEveryRender: ( Js.Nullable.t>, @uncurry (unit => 'value), ) => unit = "useImperativeHandle" -@module("react") +@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external useImperativeHandle: ( Js.Nullable.t>, @uncurry (unit => 'value), 'deps, ) => unit = "useImperativeHandle" -@module("react") +@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external useImperativeHandle0: ( Js.Nullable.t>, @uncurry (unit => 'value), @as(json`[]`) _, ) => unit = "useImperativeHandle" -@module("react") +@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external useImperativeHandle1: ( Js.Nullable.t>, @uncurry (unit => 'value), array<'a>, ) => unit = "useImperativeHandle" -@module("react") +@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external useImperativeHandle2: ( Js.Nullable.t>, @uncurry (unit => 'value), ('a, 'b), ) => unit = "useImperativeHandle" -@module("react") +@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external useImperativeHandle3: ( Js.Nullable.t>, @uncurry (unit => 'value), ('a, 'b, 'c), ) => unit = "useImperativeHandle" -@module("react") +@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external useImperativeHandle4: ( Js.Nullable.t>, @uncurry (unit => 'value), ('a, 'b, 'c, 'd), ) => unit = "useImperativeHandle" -@module("react") +@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external useImperativeHandle5: ( Js.Nullable.t>, @uncurry (unit => 'value), ('a, 'b, 'c, 'd, 'e), ) => unit = "useImperativeHandle" -@module("react") +@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external useImperativeHandle6: ( Js.Nullable.t>, @uncurry (unit => 'value), ('a, 'b, 'c, 'd, 'e, 'f), ) => unit = "useImperativeHandle" -@module("react") +@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external useImperativeHandle7: ( Js.Nullable.t>, @uncurry (unit => 'value), @@ -348,56 +354,56 @@ external useImperativeHandle7: ( ) => unit = "useImperativeHandle" module Uncurried = { - @module("react") + @module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external useState: (@uncurry (unit => 'state)) => ('state, (. 'state => 'state) => unit) = "useState" - @module("react") + @module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external useReducer: ( @uncurry ('state, 'action) => 'state, 'state, ) => ('state, (. 'action) => unit) = "useReducer" - @module("react") + @module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external useReducerWithMapState: ( @uncurry ('state, 'action) => 'state, 'initialState, @uncurry ('initialState => 'state), ) => ('state, (. 'action) => unit) = "useReducer" - @module("react") + @module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external useCallback: ('f, 'deps) => 'f = "useCallback" - @module("react") + @module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external useCallback0: ('f, @as(json`[]`) _) => 'f = "useCallback" - @module("react") + @module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external useCallback1: ('f, array<'a>) => 'f = "useCallback" - @module("react") + @module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external useCallback2: ('f, ('a, 'b)) => 'f = "useCallback" - @module("react") + @module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external useCallback3: ('f, ('a, 'b, 'c)) => 'f = "useCallback" - @module("react") + @module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external useCallback4: ('f, ('a, 'b, 'c, 'd)) => 'f = "useCallback" - @module("react") + @module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external useCallback5: ('f, ('a, 'b, 'c, 'd, 'e)) => 'f = "useCallback" - @module("react") + @module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external useCallback6: ('callback, ('a, 'b, 'c, 'd, 'e, 'f)) => 'callback = "useCallback" - @module("react") + @module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external useCallback7: ('callback, ('a, 'b, 'c, 'd, 'e, 'f, 'g)) => 'callback = "useCallback" } -@module("react") +@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external useTransition: unit => (bool, (. unit => unit) => unit) = "useTransition" -@set +@set @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external setDisplayName: (component<'props>, string) => unit = "displayName" -@get @return(nullable) +@get @return(nullable) @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external displayName: component<'props> => option = "displayName" From d4a2b4bd162d4159145bfd19619518b58e028037 Mon Sep 17 00:00:00 2001 From: mununki Date: Mon, 23 Sep 2024 14:52:02 +0900 Subject: [PATCH 2/2] changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 00076d6..371bc4a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,10 @@ > - :house: [Internal] > - :nail_care: [Polish] +## 0.13.1 (Unreleased) + +- Deprecate JSX 3 https://github.com/rescript-lang/rescript-react/pull/120 + ## 0.13.0 #### :boom: Breaking Change