From c42ad42ed4793e02345230c0ed4fd4976b26eaa3 Mon Sep 17 00:00:00 2001 From: Christoph Knittel Date: Tue, 2 May 2023 11:20:47 +0200 Subject: [PATCH 01/34] Add React.lazy --- src/React.bs.js | 13 ++++++++++++- src/React.res | 7 +++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/React.bs.js b/src/React.bs.js index 0ce5c58..eb0afaf 100644 --- a/src/React.bs.js +++ b/src/React.bs.js @@ -1,6 +1,8 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +var Curry = require("rescript/lib/js/curry.js"); +var React = require("react"); var Ref = {}; @@ -20,6 +22,14 @@ var Experimental = { SuspenseList: SuspenseList }; +function lazy_(load) { + return React.lazy(async function (param) { + return { + default: await Curry._1(load, undefined) + }; + }); +} + var Uncurried = {}; exports.Ref = Ref; @@ -29,5 +39,6 @@ exports.Fragment = Fragment; exports.StrictMode = StrictMode; exports.Suspense = Suspense; exports.Experimental = Experimental; +exports.lazy_ = lazy_; exports.Uncurried = Uncurried; -/* No side effect */ +/* react Not a pure module */ diff --git a/src/React.res b/src/React.res index 9903177..cf4a7f5 100644 --- a/src/React.res +++ b/src/React.res @@ -143,6 +143,13 @@ module Experimental = { } } +type dynamicallyImportedModule<'a> = {default: component<'a>} + +@module("react") +external lazy_: (unit => promise>) => component<'a> = "lazy" + +let lazy_ = load => lazy_(async () => {default: await load()}) + /* HOOKS */ /* From 88689f6347009fefd433365680d4ad6443b6150a Mon Sep 17 00:00:00 2001 From: Christoph Knittel Date: Tue, 2 May 2023 10:42:56 +0200 Subject: [PATCH 02/34] Remove experimental SuspenseList component --- src/React.bs.js | 7 ------- src/React.res | 16 ---------------- src/v3/React_V3.bs.js | 7 ------- src/v3/React_V3.res | 22 ---------------------- 4 files changed, 52 deletions(-) diff --git a/src/React.bs.js b/src/React.bs.js index eb0afaf..08a9db0 100644 --- a/src/React.bs.js +++ b/src/React.bs.js @@ -16,12 +16,6 @@ var StrictMode = {}; var Suspense = {}; -var SuspenseList = {}; - -var Experimental = { - SuspenseList: SuspenseList -}; - function lazy_(load) { return React.lazy(async function (param) { return { @@ -38,7 +32,6 @@ exports.Context = Context; exports.Fragment = Fragment; exports.StrictMode = StrictMode; exports.Suspense = Suspense; -exports.Experimental = Experimental; exports.lazy_ = lazy_; exports.Uncurried = Uncurried; /* react Not a pure module */ diff --git a/src/React.res b/src/React.res index cf4a7f5..e2aba32 100644 --- a/src/React.res +++ b/src/React.res @@ -127,22 +127,6 @@ module Suspense = { external make: component> = "Suspense" } -module Experimental = { - module SuspenseList = { - type revealOrder - type tail - type props<'children, 'revealOrder, 'tail> = { - key?: string, - children?: 'children, - revealOrder?: 'revealOrder, - tail?: 'tail, - } - - @module("react") - external make: component> = "SuspenseList" - } -} - type dynamicallyImportedModule<'a> = {default: component<'a>} @module("react") diff --git a/src/v3/React_V3.bs.js b/src/v3/React_V3.bs.js index 0ce5c58..a858df8 100644 --- a/src/v3/React_V3.bs.js +++ b/src/v3/React_V3.bs.js @@ -14,12 +14,6 @@ var StrictMode = {}; var Suspense = {}; -var SuspenseList = {}; - -var Experimental = { - SuspenseList: SuspenseList -}; - var Uncurried = {}; exports.Ref = Ref; @@ -28,6 +22,5 @@ exports.Context = Context; exports.Fragment = Fragment; exports.StrictMode = StrictMode; exports.Suspense = Suspense; -exports.Experimental = Experimental; exports.Uncurried = Uncurried; /* No side effect */ diff --git a/src/v3/React_V3.res b/src/v3/React_V3.res index 74f167f..c411f92 100644 --- a/src/v3/React_V3.res +++ b/src/v3/React_V3.res @@ -134,28 +134,6 @@ module Suspense = { }> = "Suspense" } -module Experimental = { - module SuspenseList = { - type revealOrder = React.Experimental.SuspenseList.revealOrder - type tail = React.Experimental.SuspenseList.tail - @obj - external makeProps: ( - ~children: element=?, - ~revealOrder: [#forwards | #backwards | #together]=?, - ~tail: [#collapsed | #hidden]=?, - unit, - ) => {"children": option, "revealOrder": option, "tail": option} = - "" - - @module("react") - external make: component<{ - "children": option, - "revealOrder": option, - "tail": option, - }> = "SuspenseList" - } -} - /* HOOKS */ /* From 23f3573eb97091093b4560bc76603c5e3b7b9ca7 Mon Sep 17 00:00:00 2001 From: Christoph Knittel Date: Tue, 2 May 2023 10:42:35 +0200 Subject: [PATCH 03/34] Fix children type for Fragment, StrictMode and Suspense --- src/React.res | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/React.res b/src/React.res index e2aba32..c9b39a3 100644 --- a/src/React.res +++ b/src/React.res @@ -39,9 +39,9 @@ external jsxs: (component<'props>, 'props) => element = "jsxs" @module("react/jsx-runtime") external jsxsKeyed: (component<'props>, 'props, ~key: string=?, @ignore unit) => element = "jsxs" -type fragmentProps<'children> = {children?: 'children} +type fragmentProps = {children?: element} -@module("react/jsx-runtime") external jsxFragment: component> = "Fragment" +@module("react/jsx-runtime") external jsxFragment: component = "Fragment" type ref<'value> = {mutable current: 'value} @@ -104,27 +104,27 @@ external memoCustomCompareProps: ( @uncurry ('props, 'props) => bool, ) => component<'props> = "memo" -@module("react") external fragment: 'a = "Fragment" +@module("react") external fragment: component = "Fragment" module Fragment = { - type props<'children> = {key?: string, children: 'children} + type props = {key?: string, children: element} @module("react") - external make: component> = "Fragment" + external make: component = "Fragment" } module StrictMode = { - type props<'children> = {key?: string, children: 'children} + type props = {key?: string, children: element} @module("react") - external make: component> = "StrictMode" + external make: component = "StrictMode" } module Suspense = { - type props<'children, 'fallback> = {key?: string, children?: 'children, fallback?: 'fallback} + type props = {key?: string, children?: element, fallback?: element} @module("react") - external make: component> = "Suspense" + external make: component = "Suspense" } type dynamicallyImportedModule<'a> = {default: component<'a>} From 99669497fffe8fab13795a6578e2da6f9e1fdb44 Mon Sep 17 00:00:00 2001 From: Christoph Knittel Date: Wed, 3 May 2023 16:47:33 +0200 Subject: [PATCH 04/34] Update rescript compiler to 11.0.0-alpha.5 --- package-lock.json | 17 ++++++++++------- package.json | 2 +- src/ReactEvent.bs.js | 4 ++-- src/ReactTestUtils.bs.js | 4 ++-- src/v3/ReactEvent_V3.bs.js | 4 ++-- 5 files changed, 17 insertions(+), 14 deletions(-) diff --git a/package-lock.json b/package-lock.json index b2e50aa..4dc590a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,7 @@ "devDependencies": { "react": "^18.2.0", "react-dom": "^18.2.0", - "rescript": "^11.0.0-alpha.1" + "rescript": "^11.0.0-alpha.5" }, "peerDependencies": { "react": ">=18.0.0", @@ -59,15 +59,18 @@ } }, "node_modules/rescript": { - "version": "11.0.0-alpha.1", - "resolved": "https://registry.npmjs.org/rescript/-/rescript-11.0.0-alpha.1.tgz", - "integrity": "sha512-+01rdTX9FCOZrEJFVrk2XRgrIlGLf93EKsNwoW5iq0jQiKcYGCdHeSbJvVYF+cximgm+CmWhSkR42l+Il6t12A==", + "version": "11.0.0-alpha.5", + "resolved": "https://registry.npmjs.org/rescript/-/rescript-11.0.0-alpha.5.tgz", + "integrity": "sha512-RNy7HGAMI+3n0Urm3aHGxFNOMNAFg/SY6h1tU1/1ULm5DKgUR9qoh5iniBbEyWu/fve4bVO1E6cZhGQL696k9A==", "dev": true, "hasInstallScript": true, "bin": { "bsc": "bsc", "bstracing": "lib/bstracing", "rescript": "rescript" + }, + "engines": { + "node": ">=10" } }, "node_modules/scheduler": { @@ -116,9 +119,9 @@ } }, "rescript": { - "version": "11.0.0-alpha.1", - "resolved": "https://registry.npmjs.org/rescript/-/rescript-11.0.0-alpha.1.tgz", - "integrity": "sha512-+01rdTX9FCOZrEJFVrk2XRgrIlGLf93EKsNwoW5iq0jQiKcYGCdHeSbJvVYF+cximgm+CmWhSkR42l+Il6t12A==", + "version": "11.0.0-alpha.5", + "resolved": "https://registry.npmjs.org/rescript/-/rescript-11.0.0-alpha.5.tgz", + "integrity": "sha512-RNy7HGAMI+3n0Urm3aHGxFNOMNAFg/SY6h1tU1/1ULm5DKgUR9qoh5iniBbEyWu/fve4bVO1E6cZhGQL696k9A==", "dev": true }, "scheduler": { diff --git a/package.json b/package.json index 4d8ef37..9affe9a 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "devDependencies": { "react": "^18.2.0", "react-dom": "^18.2.0", - "rescript": "^11.0.0-alpha.1" + "rescript": "^11.0.0-alpha.5" }, "peerDependencies": { "react": ">=18.0.0", diff --git a/src/ReactEvent.bs.js b/src/ReactEvent.bs.js index c99d363..179cde2 100644 --- a/src/ReactEvent.bs.js +++ b/src/ReactEvent.bs.js @@ -30,7 +30,7 @@ var Media = {}; var $$Image = {}; -var Animation = {}; +var $$Animation = {}; var Transition = {}; @@ -48,6 +48,6 @@ exports.UI = UI; exports.Wheel = Wheel; exports.Media = Media; exports.$$Image = $$Image; -exports.Animation = Animation; +exports.$$Animation = $$Animation; exports.Transition = Transition; /* No side effect */ diff --git a/src/ReactTestUtils.bs.js b/src/ReactTestUtils.bs.js index c0c319a..8900461 100644 --- a/src/ReactTestUtils.bs.js +++ b/src/ReactTestUtils.bs.js @@ -8,14 +8,14 @@ var Caml_option = require("rescript/lib/js/caml_option.js"); var TestUtils = require("react-dom/test-utils"); function act(func) { - var reactFunc = function (param) { + var reactFunc = function () { Curry._1(func, undefined); }; TestUtils.act(reactFunc); } function actAsync(func) { - return TestUtils.act(function (param) { + return TestUtils.act(function () { return Curry._1(func, undefined); }); } diff --git a/src/v3/ReactEvent_V3.bs.js b/src/v3/ReactEvent_V3.bs.js index c99d363..179cde2 100644 --- a/src/v3/ReactEvent_V3.bs.js +++ b/src/v3/ReactEvent_V3.bs.js @@ -30,7 +30,7 @@ var Media = {}; var $$Image = {}; -var Animation = {}; +var $$Animation = {}; var Transition = {}; @@ -48,6 +48,6 @@ exports.UI = UI; exports.Wheel = Wheel; exports.Media = Media; exports.$$Image = $$Image; -exports.Animation = Animation; +exports.$$Animation = $$Animation; exports.Transition = Transition; /* No side effect */ From f5e0af475898aa3e9ff6c4066914f89b7dba3f55 Mon Sep 17 00:00:00 2001 From: Christoph Knittel Date: Wed, 3 May 2023 16:47:49 +0200 Subject: [PATCH 05/34] Update version to 0.12.0-alpha.2 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4dc590a..468e230 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@rescript/react", - "version": "0.12.0-alpha.1", + "version": "0.12.0-alpha.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@rescript/react", - "version": "0.12.0-alpha.1", + "version": "0.12.0-alpha.2", "license": "MIT", "devDependencies": { "react": "^18.2.0", diff --git a/package.json b/package.json index 9affe9a..c55fd45 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@rescript/react", - "version": "0.12.0-alpha.1", + "version": "0.12.0-alpha.2", "description": "React bindings for ReScript", "files": [ "README.md", From 94dc1e15a31714c5cbc0392f9f6bc98101c095a2 Mon Sep 17 00:00:00 2001 From: Christoph Knittel Date: Wed, 3 May 2023 16:53:50 +0200 Subject: [PATCH 06/34] Update CHANGELOG and README --- CHANGELOG.md | 40 +++++++++++++++++++++++++++++++++++++++- README.md | 7 ++++++- 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 85137a4..355012b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,47 @@ # Changelog +> **Tags:** +> +> - :boom: [Breaking Change] +> - :eyeglasses: [Spec Compliance] +> - :rocket: [New Feature] +> - :bug: [Bug Fix] +> - :memo: [Documentation] +> - :house: [Internal] +> - :nail_care: [Polish] + +## 0.12.0-alpha.2 + +#### :rocket: New Feature + +- Added `React.lazy_`. + +#### :boom: Breaking Change + +- Requires ReScript 11.0.0-alpha.6 or newer. + +#### :bug: Bug Fix + +- Fixed children type for `Fragment`, `StrictMode` and `Suspense`. + +#### :nail_care: Polish + +- Removed experimental `SuspenseList` component. + ## 0.12.0-alpha.1 +#### :rocket: New Feature + - Compatibility with ReScript 11 uncurried mode. -- Breaking: removed `React.callback` type. +- Added `gap` prop to `ReactDOMStyle.make`. + +#### :boom: Breaking Change + +- Removed `React.callback` type. + +#### :bug: Bug Fix + +- Updated `React_V3` compatibility module to define record field `current` for `ref`. ## 0.11.0 diff --git a/README.md b/README.md index 6c9237a..2aedca0 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,12 @@ If you want to try build your project with JSX v3, see [the V3 compatibility mod ### Requirements -- v0.11.0+ +- v0.12.0+: + + - ReScript Compiler v11.0+ + - ReactJS v18.0.0+ + +- v0.11.0 - ReScript Compiler v10.1+ - ReactJS v18.0.0+ From 2f84dbc9fc735de7c3174134b9d72df372108c4b Mon Sep 17 00:00:00 2001 From: woonki Date: Wed, 24 May 2023 23:30:04 +0900 Subject: [PATCH 07/34] Fix incorrect type definitions in useCallback (#97) * fix incorrect type definitions in useCallback * changelog * 'callback * remove useCallback0-7 * Revert "remove useCallback0-7" This reverts commit f1422b42e3d5af220bf307d36cc2d24cfefe58ef. * deprecate useCallback0-7, add 'dep * changelog * Update CHANGELOG.md Co-authored-by: Christoph Knittel * fix deprecation message * onEveryRender hooks binding * useEffectOnEveryRender in router * fix useEffect in router * Update CHANGELOG.md Co-authored-by: Christoph Knittel --------- Co-authored-by: Christoph Knittel --- CHANGELOG.md | 8 +++ src/React.res | 134 +++++++++++++++++++++++------------- src/RescriptReactRouter.res | 7 +- src/v3/React_V3.res | 121 +++++++++++++++++++------------- 4 files changed, 172 insertions(+), 98 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 355012b..6428fcf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,14 @@ #### :boom: Breaking Change - Requires ReScript 11.0.0-alpha.6 or newer. +- Deprecated use\*N functions in favor of changing the signature of the main hook function. + - For example, useEffect instead of useEffectN e.g. `useEffect3(f, (a, b, c))` -> `useEffect(f, (a, b, c))` + - The affected hooks include `useEffect`, `useLayoutEffect`, `useCallback`, `useMemo`, `useImperativeHandle`, `useInsertionEffect` + - With this change, it is now possible to pass any value as the second argument `'deps`. In case you pass an invalid value, you will get a warning from React at runtime. You should be using one of the following values for the dependency array: + - 0 dependencies: `[]` + - 1 dependency: `[a]` + - more than 1 dependency: `(a, b, ...)` +- For calling `useEffect`, `useLayoutEffect` etc. *without* a dependency array (meaning that the effect is executed on every render), there are now separate bindings `useEffectOnEveryRender`, `useLayoutEffectOnEveryRender` etc. #### :bug: Bug Fix diff --git a/src/React.res b/src/React.res index c9b39a3..fe9eb88 100644 --- a/src/React.res +++ b/src/React.res @@ -157,115 +157,121 @@ external useReducerWithMapState: ( ) => ('state, 'action => unit) = "useReducer" @module("react") -external useEffect: (@uncurry (unit => option unit>)) => unit = "useEffect" +external useEffectOnEveryRender: (@uncurry (unit => option unit>)) => unit = "useEffect" @module("react") +external useEffect: (@uncurry (unit => option unit>), 'deps) => unit = "useEffect" +@module("react") @deprecated("Please use useEffect or useEffectOnEveryRender instead") external useEffect0: (@uncurry (unit => option unit>), @as(json`[]`) _) => unit = "useEffect" -@module("react") +@module("react") @deprecated("Please use useEffect or useEffectOnEveryRender instead") external useEffect1: (@uncurry (unit => option unit>), array<'a>) => unit = "useEffect" -@module("react") +@module("react") @deprecated("Please use useEffect or useEffectOnEveryRender instead") external useEffect2: (@uncurry (unit => option unit>), ('a, 'b)) => unit = "useEffect" -@module("react") +@module("react") @deprecated("Please use useEffect or useEffectOnEveryRender instead") external useEffect3: (@uncurry (unit => option unit>), ('a, 'b, 'c)) => unit = "useEffect" -@module("react") +@module("react") @deprecated("Please use useEffect or useEffectOnEveryRender instead") external useEffect4: (@uncurry (unit => option unit>), ('a, 'b, 'c, 'd)) => unit = "useEffect" -@module("react") +@module("react") @deprecated("Please use useEffect or useEffectOnEveryRender instead") external useEffect5: (@uncurry (unit => option unit>), ('a, 'b, 'c, 'd, 'e)) => unit = "useEffect" -@module("react") +@module("react") @deprecated("Please use useEffect or useEffectOnEveryRender instead") external useEffect6: (@uncurry (unit => option unit>), ('a, 'b, 'c, 'd, 'e, 'f)) => unit = "useEffect" -@module("react") +@module("react") @deprecated("Please use useEffect or useEffectOnEveryRender instead") external useEffect7: ( @uncurry (unit => option unit>), ('a, 'b, 'c, 'd, 'e, 'f, 'g), ) => unit = "useEffect" @module("react") -external useLayoutEffect: (@uncurry (unit => option unit>)) => unit = "useLayoutEffect" +external useLayoutEffectOnEveryRender: (@uncurry (unit => option unit>)) => unit = + "useLayoutEffect" @module("react") +external useLayoutEffect: (@uncurry (unit => option unit>), 'deps) => unit = + "useLayoutEffect" +@module("react") @deprecated("Please use useLayoutEffect or useLayoutEffectOnEveryRender instead") external useLayoutEffect0: (@uncurry (unit => option unit>), @as(json`[]`) _) => unit = "useLayoutEffect" -@module("react") +@module("react") @deprecated("Please use useLayoutEffect or useLayoutEffectOnEveryRender instead") external useLayoutEffect1: (@uncurry (unit => option unit>), array<'a>) => unit = "useLayoutEffect" -@module("react") +@module("react") @deprecated("Please use useLayoutEffect or useLayoutEffectOnEveryRender instead") external useLayoutEffect2: (@uncurry (unit => option unit>), ('a, 'b)) => unit = "useLayoutEffect" -@module("react") +@module("react") @deprecated("Please use useLayoutEffect or useLayoutEffectOnEveryRender instead") external useLayoutEffect3: (@uncurry (unit => option unit>), ('a, 'b, 'c)) => unit = "useLayoutEffect" -@module("react") +@module("react") @deprecated("Please use useLayoutEffect or useLayoutEffectOnEveryRender instead") external useLayoutEffect4: (@uncurry (unit => option unit>), ('a, 'b, 'c, 'd)) => unit = "useLayoutEffect" -@module("react") +@module("react") @deprecated("Please use useLayoutEffect or useLayoutEffectOnEveryRender instead") external useLayoutEffect5: (@uncurry (unit => option unit>), ('a, 'b, 'c, 'd, 'e)) => unit = "useLayoutEffect" -@module("react") +@module("react") @deprecated("Please use useLayoutEffect or useLayoutEffectOnEveryRender instead") external useLayoutEffect6: ( @uncurry (unit => option unit>), ('a, 'b, 'c, 'd, 'e, 'f), ) => unit = "useLayoutEffect" -@module("react") +@module("react") @deprecated("Please use useLayoutEffect or useLayoutEffectOnEveryRender instead") external useLayoutEffect7: ( @uncurry (unit => option unit>), ('a, 'b, 'c, 'd, 'e, 'f, 'g), ) => unit = "useLayoutEffect" @module("react") -external useMemo: (@uncurry (unit => 'any)) => 'any = "useMemo" +external useMemo: (@uncurry (unit => 'any), 'deps) => 'any = "useMemo" -@module("react") +@module("react") @deprecated("Please use useMemo instead") external useMemo0: (@uncurry (unit => 'any), @as(json`[]`) _) => 'any = "useMemo" -@module("react") +@module("react") @deprecated("Please use useMemo instead") external useMemo1: (@uncurry (unit => 'any), array<'a>) => 'any = "useMemo" -@module("react") +@module("react") @deprecated("Please use useMemo instead") external useMemo2: (@uncurry (unit => 'any), ('a, 'b)) => 'any = "useMemo" -@module("react") +@module("react") @deprecated("Please use useMemo instead") external useMemo3: (@uncurry (unit => 'any), ('a, 'b, 'c)) => 'any = "useMemo" -@module("react") +@module("react") @deprecated("Please use useMemo instead") external useMemo4: (@uncurry (unit => 'any), ('a, 'b, 'c, 'd)) => 'any = "useMemo" -@module("react") +@module("react") @deprecated("Please use useMemo instead") external useMemo5: (@uncurry (unit => 'any), ('a, 'b, 'c, 'd, 'e)) => 'any = "useMemo" -@module("react") +@module("react") @deprecated("Please use useMemo instead") external useMemo6: (@uncurry (unit => 'any), ('a, 'b, 'c, 'd, 'e, 'f)) => 'any = "useMemo" -@module("react") +@module("react") @deprecated("Please use useMemo instead") external useMemo7: (@uncurry (unit => 'any), ('a, 'b, 'c, 'd, 'e, 'f, 'g)) => 'any = "useMemo" @module("react") -external useCallback: 'f => 'f = "useCallback" +external useCallback: ('f, 'deps) => 'f = "useCallback" -@module("react") +@module("react") @deprecated("Please use useCallback instead") external useCallback0: ('f, @as(json`[]`) _) => 'f = "useCallback" -@module("react") +@module("react") @deprecated("Please use useCallback instead") external useCallback1: ('f, array<'a>) => 'f = "useCallback" -@module("react") +@module("react") @deprecated("Please use useCallback instead") external useCallback2: ('f, ('a, 'b)) => 'f = "useCallback" -@module("react") +@module("react") @deprecated("Please use useCallback instead") external useCallback3: ('f, ('a, 'b, 'c)) => 'f = "useCallback" -@module("react") +@module("react") @deprecated("Please use useCallback instead") external useCallback4: ('f, ('a, 'b, 'c, 'd)) => 'f = "useCallback" -@module("react") +@module("react") @deprecated("Please use useCallback instead") external useCallback5: ('f, ('a, 'b, 'c, 'd, 'e)) => 'f = "useCallback" -@module("react") -external useCallback6: ('f, ('a, 'b, 'c, 'd, 'e, 'f)) => 'f = "useCallback" +@module("react") @deprecated("Please use useCallback instead") +external useCallback6: ('callback, ('a, 'b, 'c, 'd, 'e, 'f)) => 'callback = "useCallback" -@module("react") -external useCallback7: ('f, ('a, 'b, 'c, 'd, 'e, 'f, 'g)) => 'f = "useCallback" +@module("react") @deprecated("Please use useCallback instead") +external useCallback7: ('callback, ('a, 'b, 'c, 'd, 'e, 'f, 'g)) => 'callback = "useCallback" @module("react") external useContext: Context.t<'any> => 'any = "useContext" @@ -273,6 +279,20 @@ external useContext: Context.t<'any> => 'any = "useContext" @module("react") external useRef: 'value => ref<'value> = "useRef" @module("react") +external useImperativeHandleOnEveryRender: ( + Js.Nullable.t>, + @uncurry (unit => 'value), +) => unit = "useImperativeHandle" + +@module("react") +external useImperativeHandle: ( + Js.Nullable.t>, + @uncurry (unit => 'value), + 'deps, +) => unit = "useImperativeHandle" + +@module("react") +@deprecated("Please use useImperativeHandle or useImperativeHandleOnEveryRender instead") external useImperativeHandle0: ( Js.Nullable.t>, @uncurry (unit => 'value), @@ -280,6 +300,7 @@ external useImperativeHandle0: ( ) => unit = "useImperativeHandle" @module("react") +@deprecated("Please use useImperativeHandle or useImperativeHandleOnEveryRender instead") external useImperativeHandle1: ( Js.Nullable.t>, @uncurry (unit => 'value), @@ -287,6 +308,7 @@ external useImperativeHandle1: ( ) => unit = "useImperativeHandle" @module("react") +@deprecated("Please use useImperativeHandle or useImperativeHandleOnEveryRender instead") external useImperativeHandle2: ( Js.Nullable.t>, @uncurry (unit => 'value), @@ -294,6 +316,7 @@ external useImperativeHandle2: ( ) => unit = "useImperativeHandle" @module("react") +@deprecated("Please use useImperativeHandle or useImperativeHandleOnEveryRender instead") external useImperativeHandle3: ( Js.Nullable.t>, @uncurry (unit => 'value), @@ -301,6 +324,7 @@ external useImperativeHandle3: ( ) => unit = "useImperativeHandle" @module("react") +@deprecated("Please use useImperativeHandle or useImperativeHandleOnEveryRender instead") external useImperativeHandle4: ( Js.Nullable.t>, @uncurry (unit => 'value), @@ -308,6 +332,7 @@ external useImperativeHandle4: ( ) => unit = "useImperativeHandle" @module("react") +@deprecated("Please use useImperativeHandle or useImperativeHandleOnEveryRender instead") external useImperativeHandle5: ( Js.Nullable.t>, @uncurry (unit => 'value), @@ -315,6 +340,7 @@ external useImperativeHandle5: ( ) => unit = "useImperativeHandle" @module("react") +@deprecated("Please use useImperativeHandle or useImperativeHandleOnEveryRender instead") external useImperativeHandle6: ( Js.Nullable.t>, @uncurry (unit => 'value), @@ -322,6 +348,7 @@ external useImperativeHandle6: ( ) => unit = "useImperativeHandle" @module("react") +@deprecated("Please use useImperativeHandle or useImperativeHandleOnEveryRender instead") external useImperativeHandle7: ( Js.Nullable.t>, @uncurry (unit => 'value), @@ -336,34 +363,45 @@ external useImperativeHandle7: ( external useTransition: unit => (bool, (. unit => unit) => unit) = "useTransition" @module("react") -external useInsertionEffect: (@uncurry (unit => option unit>)) => unit = +external useInsertionEffectOnEveryRender: (@uncurry (unit => option unit>)) => unit = "useInsertionEffect" @module("react") +external useInsertionEffect: (@uncurry (unit => option unit>), 'deps) => unit = + "useInsertionEffect" +@module("react") +@deprecated("Please use useInsertionEffect or useInsertionEffectOnEveryRender instead") external useInsertionEffect0: (@uncurry (unit => option unit>), @as(json`[]`) _) => unit = "useInsertionEffect" @module("react") +@deprecated("Please use useInsertionEffect or useInsertionEffectOnEveryRender instead") external useInsertionEffect1: (@uncurry (unit => option unit>), array<'a>) => unit = "useInsertionEffect" @module("react") +@deprecated("Please use useInsertionEffect or useInsertionEffectOnEveryRender instead") external useInsertionEffect2: (@uncurry (unit => option unit>), ('a, 'b)) => unit = "useInsertionEffect" @module("react") +@deprecated("Please use useInsertionEffect or useInsertionEffectOnEveryRender instead") external useInsertionEffect3: (@uncurry (unit => option unit>), ('a, 'b, 'c)) => unit = "useInsertionEffect" @module("react") +@deprecated("Please use useInsertionEffect or useInsertionEffectOnEveryRender instead") external useInsertionEffect4: (@uncurry (unit => option unit>), ('a, 'b, 'c, 'd)) => unit = "useInsertionEffect" @module("react") +@deprecated("Please use useInsertionEffect or useInsertionEffectOnEveryRender instead") external useInsertionEffect5: ( @uncurry (unit => option unit>), ('a, 'b, 'c, 'd, 'e), ) => unit = "useInsertionEffect" @module("react") +@deprecated("Please use useInsertionEffect or useInsertionEffectOnEveryRender instead") external useInsertionEffect6: ( @uncurry (unit => option unit>), ('a, 'b, 'c, 'd, 'e, 'f), ) => unit = "useInsertionEffect" @module("react") +@deprecated("Please use useInsertionEffect or useInsertionEffectOnEveryRender instead") external useInsertionEffect7: ( @uncurry (unit => option unit>), ('a, 'b, 'c, 'd, 'e, 'f, 'g), @@ -401,31 +439,31 @@ module Uncurried = { ) => ('state, (. 'action) => unit) = "useReducer" @module("react") - external useCallback: 'f => 'f = "useCallback" + external useCallback: ('f, 'deps) => 'f = "useCallback" - @module("react") + @module("react") @deprecated("Please use useCallback instead") external useCallback0: ('f, @as(json`[]`) _) => 'f = "useCallback" - @module("react") + @module("react") @deprecated("Please use useCallback instead") external useCallback1: ('f, array<'a>) => 'f = "useCallback" - @module("react") + @module("react") @deprecated("Please use useCallback instead") external useCallback2: ('f, ('a, 'b)) => 'f = "useCallback" - @module("react") + @module("react") @deprecated("Please use useCallback instead") external useCallback3: ('f, ('a, 'b, 'c)) => 'f = "useCallback" - @module("react") + @module("react") @deprecated("Please use useCallback instead") external useCallback4: ('f, ('a, 'b, 'c, 'd)) => 'f = "useCallback" - @module("react") + @module("react") @deprecated("Please use useCallback instead") external useCallback5: ('f, ('a, 'b, 'c, 'd, 'e)) => 'f = "useCallback" - @module("react") - external useCallback6: ('f, ('a, 'b, 'c, 'd, 'e, 'f)) => 'f = "useCallback" + @module("react") @deprecated("Please use useCallback instead") + external useCallback6: ('callback, ('a, 'b, 'c, 'd, 'e, 'f)) => 'callback = "useCallback" - @module("react") - external useCallback7: ('f, ('a, 'b, 'c, 'd, 'e, 'f, 'g)) => 'f = "useCallback" + @module("react") @deprecated("Please use useCallback instead") + external useCallback7: ('callback, ('a, 'b, 'c, 'd, 'e, 'f, 'g)) => 'callback = "useCallback" } @set diff --git a/src/RescriptReactRouter.res b/src/RescriptReactRouter.res index 6560dfc..24e3222 100644 --- a/src/RescriptReactRouter.res +++ b/src/RescriptReactRouter.res @@ -62,7 +62,8 @@ let arrayToList = a => { let pathParse = str => switch str { | "" - | "/" => list{} + | "/" => + list{} | raw => /* remove the preceeding /, which every pathname seems to have */ let raw = Js.String.sliceToEnd(~from=1, raw) @@ -190,7 +191,7 @@ let useUrl = (~serverUrl=?, ()) => { } ) - React.useEffect0(() => { + React.useEffect(() => { let watcherId = watchUrl(url => setUrl(_ => url)) // check for updates that may have occured between the initial state and @@ -201,7 +202,7 @@ let useUrl = (~serverUrl=?, ()) => { } Some(() => unwatchUrl(watcherId)) - }) + }, []) url } diff --git a/src/v3/React_V3.res b/src/v3/React_V3.res index c411f92..33c3efb 100644 --- a/src/v3/React_V3.res +++ b/src/v3/React_V3.res @@ -157,115 +157,121 @@ external useReducerWithMapState: ( ) => ('state, 'action => unit) = "useReducer" @module("react") -external useEffect: (@uncurry (unit => option unit>)) => unit = "useEffect" +external useEffectOnEveryRender: (@uncurry (unit => option unit>)) => unit = "useEffect" @module("react") +external useEffect: (@uncurry (unit => option unit>), 'deps) => unit = "useEffect" +@module("react") @deprecated("Please use useEffect or useEffectOnEveryRender instead") external useEffect0: (@uncurry (unit => option unit>), @as(json`[]`) _) => unit = "useEffect" -@module("react") +@module("react") @deprecated("Please use useEffect or useEffectOnEveryRender instead") external useEffect1: (@uncurry (unit => option unit>), array<'a>) => unit = "useEffect" -@module("react") +@module("react") @deprecated("Please use useEffect or useEffectOnEveryRender instead") external useEffect2: (@uncurry (unit => option unit>), ('a, 'b)) => unit = "useEffect" -@module("react") +@module("react") @deprecated("Please use useEffect or useEffectOnEveryRender instead") external useEffect3: (@uncurry (unit => option unit>), ('a, 'b, 'c)) => unit = "useEffect" -@module("react") +@module("react") @deprecated("Please use useEffect or useEffectOnEveryRender instead") external useEffect4: (@uncurry (unit => option unit>), ('a, 'b, 'c, 'd)) => unit = "useEffect" -@module("react") +@module("react") @deprecated("Please use useEffect or useEffectOnEveryRender instead") external useEffect5: (@uncurry (unit => option unit>), ('a, 'b, 'c, 'd, 'e)) => unit = "useEffect" -@module("react") +@module("react") @deprecated("Please use useEffect or useEffectOnEveryRender instead") external useEffect6: (@uncurry (unit => option unit>), ('a, 'b, 'c, 'd, 'e, 'f)) => unit = "useEffect" -@module("react") +@module("react") @deprecated("Please use useEffect or useEffectOnEveryRender instead") external useEffect7: ( @uncurry (unit => option unit>), ('a, 'b, 'c, 'd, 'e, 'f, 'g), ) => unit = "useEffect" @module("react") -external useLayoutEffect: (@uncurry (unit => option unit>)) => unit = "useLayoutEffect" +external useLayoutEffectOnEveryRender: (@uncurry (unit => option unit>)) => unit = + "useLayoutEffect" @module("react") +external useLayoutEffect: (@uncurry (unit => option unit>), 'deps) => unit = + "useLayoutEffect" +@module("react") @deprecated("Please use useLayoutEffect or useLayoutEffectOnEveryRender instead") external useLayoutEffect0: (@uncurry (unit => option unit>), @as(json`[]`) _) => unit = "useLayoutEffect" -@module("react") +@module("react") @deprecated("Please use useLayoutEffect or useLayoutEffectOnEveryRender instead") external useLayoutEffect1: (@uncurry (unit => option unit>), array<'a>) => unit = "useLayoutEffect" -@module("react") +@module("react") @deprecated("Please use useLayoutEffect or useLayoutEffectOnEveryRender instead") external useLayoutEffect2: (@uncurry (unit => option unit>), ('a, 'b)) => unit = "useLayoutEffect" -@module("react") +@module("react") @deprecated("Please use useLayoutEffect or useLayoutEffectOnEveryRender instead") external useLayoutEffect3: (@uncurry (unit => option unit>), ('a, 'b, 'c)) => unit = "useLayoutEffect" -@module("react") +@module("react") @deprecated("Please use useLayoutEffect or useLayoutEffectOnEveryRender instead") external useLayoutEffect4: (@uncurry (unit => option unit>), ('a, 'b, 'c, 'd)) => unit = "useLayoutEffect" -@module("react") +@module("react") @deprecated("Please use useLayoutEffect or useLayoutEffectOnEveryRender instead") external useLayoutEffect5: (@uncurry (unit => option unit>), ('a, 'b, 'c, 'd, 'e)) => unit = "useLayoutEffect" -@module("react") +@module("react") @deprecated("Please use useLayoutEffect or useLayoutEffectOnEveryRender instead") external useLayoutEffect6: ( @uncurry (unit => option unit>), ('a, 'b, 'c, 'd, 'e, 'f), ) => unit = "useLayoutEffect" -@module("react") +@module("react") @deprecated("Please use useLayoutEffect or useLayoutEffectOnEveryRender instead") external useLayoutEffect7: ( @uncurry (unit => option unit>), ('a, 'b, 'c, 'd, 'e, 'f, 'g), ) => unit = "useLayoutEffect" @module("react") -external useMemo: (@uncurry (unit => 'any)) => 'any = "useMemo" +external useMemo: (@uncurry (unit => 'any), 'deps) => 'any = "useMemo" -@module("react") +@module("react") @deprecated("Please use useMemo instead") external useMemo0: (@uncurry (unit => 'any), @as(json`[]`) _) => 'any = "useMemo" -@module("react") +@module("react") @deprecated("Please use useMemo instead") external useMemo1: (@uncurry (unit => 'any), array<'a>) => 'any = "useMemo" -@module("react") +@module("react") @deprecated("Please use useMemo instead") external useMemo2: (@uncurry (unit => 'any), ('a, 'b)) => 'any = "useMemo" -@module("react") +@module("react") @deprecated("Please use useMemo instead") external useMemo3: (@uncurry (unit => 'any), ('a, 'b, 'c)) => 'any = "useMemo" -@module("react") +@module("react") @deprecated("Please use useMemo instead") external useMemo4: (@uncurry (unit => 'any), ('a, 'b, 'c, 'd)) => 'any = "useMemo" -@module("react") +@module("react") @deprecated("Please use useMemo instead") external useMemo5: (@uncurry (unit => 'any), ('a, 'b, 'c, 'd, 'e)) => 'any = "useMemo" -@module("react") +@module("react") @deprecated("Please use useMemo instead") external useMemo6: (@uncurry (unit => 'any), ('a, 'b, 'c, 'd, 'e, 'f)) => 'any = "useMemo" -@module("react") +@module("react") @deprecated("Please use useMemo instead") external useMemo7: (@uncurry (unit => 'any), ('a, 'b, 'c, 'd, 'e, 'f, 'g)) => 'any = "useMemo" @module("react") -external useCallback: 'f => 'f = "useCallback" +external useCallback: ('f, 'deps) => 'f = "useCallback" -@module("react") +@module("react") @deprecated("Please use useCallback instead") external useCallback0: ('f, @as(json`[]`) _) => 'f = "useCallback" -@module("react") +@module("react") @deprecated("Please use useCallback instead") external useCallback1: ('f, array<'a>) => 'f = "useCallback" -@module("react") +@module("react") @deprecated("Please use useCallback instead") external useCallback2: ('f, ('a, 'b)) => 'f = "useCallback" -@module("react") +@module("react") @deprecated("Please use useCallback instead") external useCallback3: ('f, ('a, 'b, 'c)) => 'f = "useCallback" -@module("react") +@module("react") @deprecated("Please use useCallback instead") external useCallback4: ('f, ('a, 'b, 'c, 'd)) => 'f = "useCallback" -@module("react") +@module("react") @deprecated("Please use useCallback instead") external useCallback5: ('f, ('a, 'b, 'c, 'd, 'e)) => 'f = "useCallback" -@module("react") -external useCallback6: ('f, ('a, 'b, 'c, 'd, 'e, 'f)) => 'f = "useCallback" +@module("react") @deprecated("Please use useCallback instead") +external useCallback6: ('callback, ('a, 'b, 'c, 'd, 'e, 'f)) => 'callback = "useCallback" -@module("react") -external useCallback7: ('f, ('a, 'b, 'c, 'd, 'e, 'f, 'g)) => 'f = "useCallback" +@module("react") @deprecated("Please use useCallback instead") +external useCallback7: ('callback, ('a, 'b, 'c, 'd, 'e, 'f, 'g)) => 'callback = "useCallback" @module("react") external useContext: Context.t<'any> => 'any = "useContext" @@ -273,6 +279,20 @@ external useContext: Context.t<'any> => 'any = "useContext" @module("react") external useRef: 'value => ref<'value> = "useRef" @module("react") +external useImperativeHandleOnEveryRender: ( + Js.Nullable.t>, + @uncurry (unit => 'value), +) => unit = "useImperativeHandle" + +@module("react") +external useImperativeHandle: ( + Js.Nullable.t>, + @uncurry (unit => 'value), + 'deps, +) => unit = "useImperativeHandle" + +@module("react") +@deprecated("Please use useImperativeHandle or useImperativeHandleOnEveryRender instead") external useImperativeHandle0: ( Js.Nullable.t>, @uncurry (unit => 'value), @@ -280,6 +300,7 @@ external useImperativeHandle0: ( ) => unit = "useImperativeHandle" @module("react") +@deprecated("Please use useImperativeHandle or useImperativeHandleOnEveryRender instead") external useImperativeHandle1: ( Js.Nullable.t>, @uncurry (unit => 'value), @@ -287,6 +308,7 @@ external useImperativeHandle1: ( ) => unit = "useImperativeHandle" @module("react") +@deprecated("Please use useImperativeHandle or useImperativeHandleOnEveryRender instead") external useImperativeHandle2: ( Js.Nullable.t>, @uncurry (unit => 'value), @@ -294,6 +316,7 @@ external useImperativeHandle2: ( ) => unit = "useImperativeHandle" @module("react") +@deprecated("Please use useImperativeHandle or useImperativeHandleOnEveryRender instead") external useImperativeHandle3: ( Js.Nullable.t>, @uncurry (unit => 'value), @@ -301,6 +324,7 @@ external useImperativeHandle3: ( ) => unit = "useImperativeHandle" @module("react") +@deprecated("Please use useImperativeHandle or useImperativeHandleOnEveryRender instead") external useImperativeHandle4: ( Js.Nullable.t>, @uncurry (unit => 'value), @@ -308,6 +332,7 @@ external useImperativeHandle4: ( ) => unit = "useImperativeHandle" @module("react") +@deprecated("Please use useImperativeHandle or useImperativeHandleOnEveryRender instead") external useImperativeHandle5: ( Js.Nullable.t>, @uncurry (unit => 'value), @@ -315,6 +340,7 @@ external useImperativeHandle5: ( ) => unit = "useImperativeHandle" @module("react") +@deprecated("Please use useImperativeHandle or useImperativeHandleOnEveryRender instead") external useImperativeHandle6: ( Js.Nullable.t>, @uncurry (unit => 'value), @@ -322,6 +348,7 @@ external useImperativeHandle6: ( ) => unit = "useImperativeHandle" @module("react") +@deprecated("Please use useImperativeHandle or useImperativeHandleOnEveryRender instead") external useImperativeHandle7: ( Js.Nullable.t>, @uncurry (unit => 'value), @@ -347,31 +374,31 @@ module Uncurried = { ) => ('state, (. 'action) => unit) = "useReducer" @module("react") - external useCallback: 'f => 'f = "useCallback" + external useCallback: ('f, 'deps) => 'f = "useCallback" - @module("react") + @module("react") @deprecated("Please use useCallback instead") external useCallback0: ('f, @as(json`[]`) _) => 'f = "useCallback" - @module("react") + @module("react") @deprecated("Please use useCallback instead") external useCallback1: ('f, array<'a>) => 'f = "useCallback" - @module("react") + @module("react") @deprecated("Please use useCallback instead") external useCallback2: ('f, ('a, 'b)) => 'f = "useCallback" - @module("react") + @module("react") @deprecated("Please use useCallback instead") external useCallback3: ('f, ('a, 'b, 'c)) => 'f = "useCallback" - @module("react") + @module("react") @deprecated("Please use useCallback instead") external useCallback4: ('f, ('a, 'b, 'c, 'd)) => 'f = "useCallback" - @module("react") + @module("react") @deprecated("Please use useCallback instead") external useCallback5: ('f, ('a, 'b, 'c, 'd, 'e)) => 'f = "useCallback" - @module("react") - external useCallback6: ('f, ('a, 'b, 'c, 'd, 'e, 'f)) => 'f = "useCallback" + @module("react") @deprecated("Please use useCallback instead") + external useCallback6: ('callback, ('a, 'b, 'c, 'd, 'e, 'f)) => 'callback = "useCallback" - @module("react") - external useCallback7: ('f, ('a, 'b, 'c, 'd, 'e, 'f, 'g)) => 'f = "useCallback" + @module("react") @deprecated("Please use useCallback instead") + external useCallback7: ('callback, ('a, 'b, 'c, 'd, 'e, 'f, 'g)) => 'callback = "useCallback" } @module("react") From 83cefbff9c188d8c33594031e696e86b9c1a85d8 Mon Sep 17 00:00:00 2001 From: Christoph Knittel Date: Wed, 24 May 2023 21:04:20 +0200 Subject: [PATCH 08/34] Fix changelog (#98) --- CHANGELOG.md | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6428fcf..4bcc147 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,15 +10,10 @@ > - :house: [Internal] > - :nail_care: [Polish] -## 0.12.0-alpha.2 - -#### :rocket: New Feature - -- Added `React.lazy_`. +## 0.12.0-alpha.3 #### :boom: Breaking Change -- Requires ReScript 11.0.0-alpha.6 or newer. - Deprecated use\*N functions in favor of changing the signature of the main hook function. - For example, useEffect instead of useEffectN e.g. `useEffect3(f, (a, b, c))` -> `useEffect(f, (a, b, c))` - The affected hooks include `useEffect`, `useLayoutEffect`, `useCallback`, `useMemo`, `useImperativeHandle`, `useInsertionEffect` @@ -26,7 +21,17 @@ - 0 dependencies: `[]` - 1 dependency: `[a]` - more than 1 dependency: `(a, b, ...)` -- For calling `useEffect`, `useLayoutEffect` etc. *without* a dependency array (meaning that the effect is executed on every render), there are now separate bindings `useEffectOnEveryRender`, `useLayoutEffectOnEveryRender` etc. +- For calling `useEffect`, `useLayoutEffect` etc. _without_ a dependency array (meaning that the effect is executed on every render), there are now separate bindings `useEffectOnEveryRender`, `useLayoutEffectOnEveryRender` etc. + +## 0.12.0-alpha.2 + +#### :rocket: New Feature + +- Added `React.lazy_`. + +#### :boom: Breaking Change + +- Requires ReScript 11.0.0-alpha.6 or newer. #### :bug: Bug Fix From 9dc8de38287ffaf822cb9a65183d88cc72043c2e Mon Sep 17 00:00:00 2001 From: Glenn Slotte Date: Sun, 11 Jun 2023 05:38:14 +0200 Subject: [PATCH 09/34] chore: add linguist hints for rescript (#99) --- .gitattributes | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..6c0db7d --- /dev/null +++ b/.gitattributes @@ -0,0 +1,3 @@ +# Tell github that .res and .resi files are ReScript +*.res linguist-language=ReScript +*.resi linguist-language=ReScript From a51c2758771f83acde93eae8c002cccf79938b53 Mon Sep 17 00:00:00 2001 From: Christoph Knittel Date: Mon, 3 Jul 2023 11:41:39 +0200 Subject: [PATCH 10/34] Update version to 0.12.0-alpha.3 (#100) --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 468e230..bd3054c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@rescript/react", - "version": "0.12.0-alpha.2", + "version": "0.12.0-alpha.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@rescript/react", - "version": "0.12.0-alpha.2", + "version": "0.12.0-alpha.3", "license": "MIT", "devDependencies": { "react": "^18.2.0", diff --git a/package.json b/package.json index c55fd45..7468f3d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@rescript/react", - "version": "0.12.0-alpha.2", + "version": "0.12.0-alpha.3", "description": "React bindings for ReScript", "files": [ "README.md", From 3a4c307d129d20edb292d0c6aa80d1ad9a1e8e0b Mon Sep 17 00:00:00 2001 From: Christoph Knittel Date: Thu, 2 Nov 2023 09:04:02 +0100 Subject: [PATCH 11/34] Remove dependency on Belt (#103) --- src/ReactTestUtils.bs.js | 37 ++++++++++++++++++++++--------------- src/ReactTestUtils.res | 29 +++++++++++++++-------------- 2 files changed, 37 insertions(+), 29 deletions(-) diff --git a/src/ReactTestUtils.bs.js b/src/ReactTestUtils.bs.js index 8900461..9913094 100644 --- a/src/ReactTestUtils.bs.js +++ b/src/ReactTestUtils.bs.js @@ -2,8 +2,6 @@ 'use strict'; var Curry = require("rescript/lib/js/curry.js"); -var Belt_Array = require("rescript/lib/js/belt_Array.js"); -var Belt_Option = require("rescript/lib/js/belt_Option.js"); var Caml_option = require("rescript/lib/js/caml_option.js"); var TestUtils = require("react-dom/test-utils"); @@ -52,15 +50,15 @@ function findByAllSelector(element, selector) { } function findBySelectorAndTextContent(element, selector, content) { - return Belt_Array.getBy(Array.from(element.querySelectorAll(selector)), (function (node) { - return node.textContent === content; - })); + return Caml_option.undefined_to_opt(Array.from(element.querySelectorAll(selector)).find(function (node) { + return node.textContent === content; + })); } function findBySelectorAndPartialTextContent(element, selector, content) { - return Belt_Array.getBy(Array.from(element.querySelectorAll(selector)), (function (node) { - return node.textContent.includes(content); - })); + return Caml_option.undefined_to_opt(Array.from(element.querySelectorAll(selector)).find(function (node) { + return node.textContent.includes(content); + })); } var DOM = { @@ -72,21 +70,30 @@ var DOM = { function prepareContainer(container, param) { var containerElement = document.createElement("div"); - Belt_Option.map(document.body, (function (body) { - return body.appendChild(containerElement); - })); + var body = document.body; + if (body !== undefined) { + Caml_option.valFromOption(body).appendChild(containerElement); + } container.contents = Caml_option.some(containerElement); } function cleanupContainer(container, param) { - Belt_Option.map(container.contents, (function (prim) { - prim.remove(); - })); + var contents = container.contents; + if (contents !== undefined) { + Caml_option.valFromOption(contents).remove(); + } container.contents = undefined; } function getContainer(container) { - return Belt_Option.getExn(container.contents); + var contents = container.contents; + if (contents !== undefined) { + return Caml_option.valFromOption(contents); + } + throw { + RE_EXN_ID: "Not_found", + Error: new Error() + }; } exports.act = act; diff --git a/src/ReactTestUtils.res b/src/ReactTestUtils.res index be30345..5b3bc09 100644 --- a/src/ReactTestUtils.res +++ b/src/ReactTestUtils.res @@ -94,8 +94,6 @@ external appendChild: (Dom.element, Dom.element) => Dom.element = "appendChild" let querySelectorAll = (element, string) => Js.Array.from(querySelectorAll(element, string)) module DOM = { - open Belt - @return(nullable) @get external value: Dom.element => option = "value" @@ -104,30 +102,33 @@ module DOM = { let findByAllSelector = (element, selector) => querySelectorAll(element, selector) let findBySelectorAndTextContent = (element, selector, content) => - querySelectorAll(element, selector)->Array.getBy(node => node->textContent === content) + querySelectorAll(element, selector)->Js.Array2.find(node => node->textContent === content) let findBySelectorAndPartialTextContent = (element, selector, content) => - querySelectorAll(element, selector)->Array.getBy(node => + querySelectorAll(element, selector)->Js.Array2.find(node => node->textContent->Js.String2.includes(content) ) } let prepareContainer = (container: ref>, ()) => { - open Belt - let containerElement = document->createElement("div") - let _ = document->body->Option.map(body => body->appendChild(containerElement)) + switch document->body { + | Some(body) => body->appendChild(containerElement)->ignore + | None => () + } container := Some(containerElement) } let cleanupContainer = (container: ref>, ()) => { - open Belt - - let _ = container.contents->Option.map(remove) + switch container.contents { + | Some(contents) => remove(contents) + | None => () + } container := None } -let getContainer = container => { - open Belt - container.contents->Option.getExn -} +let getContainer = container => + switch container.contents { + | Some(contents) => contents + | None => raise(Not_found) + } From 8e486d5f23e15b964fbc822e7d8056f2edc52e23 Mon Sep 17 00:00:00 2001 From: Christoph Knittel Date: Wed, 10 Jan 2024 17:22:11 +0100 Subject: [PATCH 12/34] Update README, link to documentation (#107) --- README.md | 54 ++++++++---------------------------------------------- 1 file changed, 8 insertions(+), 46 deletions(-) diff --git a/README.md b/README.md index 2aedca0..62b25b0 100644 --- a/README.md +++ b/README.md @@ -1,55 +1,17 @@ ## @rescript/react -> The Official ReScript Bindings for ReactJS - -- [Documentation](https://rescript-lang.org/docs/react/latest/introduction) - -### Installation - -#### React-JSX transformation V4 - -- [Documentation](https://github.com/rescript-lang/syntax/blob/master/cli/JSXV4.md) - -The ReScript compiler v10.1+ is required. - -``` -npm install @rescript/react --save -``` - -In your `bsconfig.json`: - -``` -{ - "jsx": { "version": 4, "mode": "classic" }, - "bs-dependencies": ["@rescript/react"] -} -``` - -If you want to try [the new jsx transform](https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html) which was introduced in React v17, set the `"mode": "automatic"`. - -If you want to try build your project with JSX v3, see [the V3 compatibility mode](https://github.com/rescript-lang/syntax/blob/master/cli/JSXV4.md) - -**Quick Links:** +> The Official [ReScript](https://rescript-lang.org) Bindings for [ReactJS](https://react.dev/) - [Introduction](https://rescript-lang.org/docs/react/latest/introduction) +- [Installation](https://rescript-lang.org/docs/react/latest/installation) -### Requirements - -- v0.12.0+: - - - ReScript Compiler v11.0+ - - ReactJS v18.0.0+ - -- v0.11.0 - - - ReScript Compiler v10.1+ - - ReactJS v18.0.0+ - -- v0.10.3 +### Versions - - bs-platform v8.3+ - - ReactJS v16.8.1+ - - **Optimized for ReScript syntax usage** +| @rescript/react | ReScript | ReactJS | Documentation | +| --------------- | -------- | ------- | ----------------------------------------------------------------- | +| 0.12.0+ | 11.0+ | 18.0.0+ | [Link](https://rescript-lang.org/docs/react/latest/introduction) | +| 0.11.0 | 10.1 | 18.0.0+ | [Link](https://rescript-lang.org/docs/react/v0.11.0/introduction) | +| 0.10.3 | 8.3 | 16.8.1+ | [Link](https://rescript-lang.org/docs/react/v0.10.0/introduction) | ### Development From a8a4a2f2468b8bcc837c6fb6c5cb141c32531e5e Mon Sep 17 00:00:00 2001 From: Christoph Knittel Date: Wed, 10 Jan 2024 18:32:46 +0100 Subject: [PATCH 13/34] Set version to 0.12.0 and use ReScript 11.0.0 release version (#108) --- CHANGELOG.md | 4 ++++ package-lock.json | 18 +++++++++--------- package.json | 4 ++-- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4bcc147..2393ba7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,10 @@ > - :house: [Internal] > - :nail_care: [Polish] +## 0.12.0 + +- Requires ReScript 11.0.0 or newer. + ## 0.12.0-alpha.3 #### :boom: Breaking Change diff --git a/package-lock.json b/package-lock.json index bd3054c..59995e2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,17 +1,17 @@ { "name": "@rescript/react", - "version": "0.12.0-alpha.3", + "version": "0.12.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@rescript/react", - "version": "0.12.0-alpha.3", + "version": "0.12.0", "license": "MIT", "devDependencies": { "react": "^18.2.0", "react-dom": "^18.2.0", - "rescript": "^11.0.0-alpha.5" + "rescript": "^11.0.0" }, "peerDependencies": { "react": ">=18.0.0", @@ -59,9 +59,9 @@ } }, "node_modules/rescript": { - "version": "11.0.0-alpha.5", - "resolved": "https://registry.npmjs.org/rescript/-/rescript-11.0.0-alpha.5.tgz", - "integrity": "sha512-RNy7HGAMI+3n0Urm3aHGxFNOMNAFg/SY6h1tU1/1ULm5DKgUR9qoh5iniBbEyWu/fve4bVO1E6cZhGQL696k9A==", + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/rescript/-/rescript-11.0.0.tgz", + "integrity": "sha512-uIUwDZZmDUb7ymGkBiiGioxMg8hXh1mze/2k/qhYQcZGgi7PrLHQIW9AksM7gb9WnpjCAvFsA8U2VgC0nA468w==", "dev": true, "hasInstallScript": true, "bin": { @@ -119,9 +119,9 @@ } }, "rescript": { - "version": "11.0.0-alpha.5", - "resolved": "https://registry.npmjs.org/rescript/-/rescript-11.0.0-alpha.5.tgz", - "integrity": "sha512-RNy7HGAMI+3n0Urm3aHGxFNOMNAFg/SY6h1tU1/1ULm5DKgUR9qoh5iniBbEyWu/fve4bVO1E6cZhGQL696k9A==", + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/rescript/-/rescript-11.0.0.tgz", + "integrity": "sha512-uIUwDZZmDUb7ymGkBiiGioxMg8hXh1mze/2k/qhYQcZGgi7PrLHQIW9AksM7gb9WnpjCAvFsA8U2VgC0nA468w==", "dev": true }, "scheduler": { diff --git a/package.json b/package.json index 7468f3d..fd6ae94 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@rescript/react", - "version": "0.12.0-alpha.3", + "version": "0.12.0", "description": "React bindings for ReScript", "files": [ "README.md", @@ -30,7 +30,7 @@ "devDependencies": { "react": "^18.2.0", "react-dom": "^18.2.0", - "rescript": "^11.0.0-alpha.5" + "rescript": "^11.0.0" }, "peerDependencies": { "react": ">=18.0.0", From bc0d138e2a8efc7e50a39e41f9213504d74ccf8f Mon Sep 17 00:00:00 2001 From: Florian Hammerschmidt Date: Fri, 9 Feb 2024 15:06:44 +0100 Subject: [PATCH 14/34] Undeprecate numbered hooks for a smoother upgrading experience (#109) * Set version to 0.12.1 * Deactivate uncurried mode to prevent formatter from removing uncurried dots * Undeprecate numbered hooks for a smoother upgrading experience --- CHANGELOG.md | 4 ++ bsconfig.json | 3 +- package-lock.json | 4 +- package.json | 2 +- src/React.res | 96 +++++++++++++++-------------------- src/RescriptReactRouter.bs.js | 2 +- src/v3/React_V3.res | 88 +++++++++++++++----------------- 7 files changed, 90 insertions(+), 109 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2393ba7..1eb12ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,10 @@ > - :house: [Internal] > - :nail_care: [Polish] +## 0.12.1 + +- Undeprecate numbered hooks for a smoother upgrading experience. + ## 0.12.0 - Requires ReScript 11.0.0 or newer. diff --git a/bsconfig.json b/bsconfig.json index 599e1f6..c13a738 100644 --- a/bsconfig.json +++ b/bsconfig.json @@ -8,5 +8,6 @@ "package-specs": [{ "module": "commonjs", "in-source": true }], "suffix": ".bs.js", "bs-dev-dependencies": [], - "bsc-flags": [] + "bsc-flags": [], + "uncurried": false } diff --git a/package-lock.json b/package-lock.json index 59995e2..2f68573 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@rescript/react", - "version": "0.12.0", + "version": "0.12.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@rescript/react", - "version": "0.12.0", + "version": "0.12.1", "license": "MIT", "devDependencies": { "react": "^18.2.0", diff --git a/package.json b/package.json index fd6ae94..2cf0397 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@rescript/react", - "version": "0.12.0", + "version": "0.12.1", "description": "React bindings for ReScript", "files": [ "README.md", diff --git a/src/React.res b/src/React.res index fe9eb88..5915094 100644 --- a/src/React.res +++ b/src/React.res @@ -160,25 +160,25 @@ external useReducerWithMapState: ( external useEffectOnEveryRender: (@uncurry (unit => option unit>)) => unit = "useEffect" @module("react") external useEffect: (@uncurry (unit => option unit>), 'deps) => unit = "useEffect" -@module("react") @deprecated("Please use useEffect or useEffectOnEveryRender instead") +@module("react") external useEffect0: (@uncurry (unit => option unit>), @as(json`[]`) _) => unit = "useEffect" -@module("react") @deprecated("Please use useEffect or useEffectOnEveryRender instead") +@module("react") external useEffect1: (@uncurry (unit => option unit>), array<'a>) => unit = "useEffect" -@module("react") @deprecated("Please use useEffect or useEffectOnEveryRender instead") +@module("react") external useEffect2: (@uncurry (unit => option unit>), ('a, 'b)) => unit = "useEffect" -@module("react") @deprecated("Please use useEffect or useEffectOnEveryRender instead") +@module("react") external useEffect3: (@uncurry (unit => option unit>), ('a, 'b, 'c)) => unit = "useEffect" -@module("react") @deprecated("Please use useEffect or useEffectOnEveryRender instead") +@module("react") external useEffect4: (@uncurry (unit => option unit>), ('a, 'b, 'c, 'd)) => unit = "useEffect" -@module("react") @deprecated("Please use useEffect or useEffectOnEveryRender instead") +@module("react") external useEffect5: (@uncurry (unit => option unit>), ('a, 'b, 'c, 'd, 'e)) => unit = "useEffect" -@module("react") @deprecated("Please use useEffect or useEffectOnEveryRender instead") +@module("react") external useEffect6: (@uncurry (unit => option unit>), ('a, 'b, 'c, 'd, 'e, 'f)) => unit = "useEffect" -@module("react") @deprecated("Please use useEffect or useEffectOnEveryRender instead") +@module("react") external useEffect7: ( @uncurry (unit => option unit>), ('a, 'b, 'c, 'd, 'e, 'f, 'g), @@ -190,30 +190,30 @@ external useLayoutEffectOnEveryRender: (@uncurry (unit => option unit>)) @module("react") external useLayoutEffect: (@uncurry (unit => option unit>), 'deps) => unit = "useLayoutEffect" -@module("react") @deprecated("Please use useLayoutEffect or useLayoutEffectOnEveryRender instead") +@module("react") external useLayoutEffect0: (@uncurry (unit => option unit>), @as(json`[]`) _) => unit = "useLayoutEffect" -@module("react") @deprecated("Please use useLayoutEffect or useLayoutEffectOnEveryRender instead") +@module("react") external useLayoutEffect1: (@uncurry (unit => option unit>), array<'a>) => unit = "useLayoutEffect" -@module("react") @deprecated("Please use useLayoutEffect or useLayoutEffectOnEveryRender instead") +@module("react") external useLayoutEffect2: (@uncurry (unit => option unit>), ('a, 'b)) => unit = "useLayoutEffect" -@module("react") @deprecated("Please use useLayoutEffect or useLayoutEffectOnEveryRender instead") +@module("react") external useLayoutEffect3: (@uncurry (unit => option unit>), ('a, 'b, 'c)) => unit = "useLayoutEffect" -@module("react") @deprecated("Please use useLayoutEffect or useLayoutEffectOnEveryRender instead") +@module("react") external useLayoutEffect4: (@uncurry (unit => option unit>), ('a, 'b, 'c, 'd)) => unit = "useLayoutEffect" -@module("react") @deprecated("Please use useLayoutEffect or useLayoutEffectOnEveryRender instead") +@module("react") external useLayoutEffect5: (@uncurry (unit => option unit>), ('a, 'b, 'c, 'd, 'e)) => unit = "useLayoutEffect" -@module("react") @deprecated("Please use useLayoutEffect or useLayoutEffectOnEveryRender instead") +@module("react") external useLayoutEffect6: ( @uncurry (unit => option unit>), ('a, 'b, 'c, 'd, 'e, 'f), ) => unit = "useLayoutEffect" -@module("react") @deprecated("Please use useLayoutEffect or useLayoutEffectOnEveryRender instead") +@module("react") external useLayoutEffect7: ( @uncurry (unit => option unit>), ('a, 'b, 'c, 'd, 'e, 'f, 'g), @@ -222,55 +222,55 @@ external useLayoutEffect7: ( @module("react") external useMemo: (@uncurry (unit => 'any), 'deps) => 'any = "useMemo" -@module("react") @deprecated("Please use useMemo instead") +@module("react") external useMemo0: (@uncurry (unit => 'any), @as(json`[]`) _) => 'any = "useMemo" -@module("react") @deprecated("Please use useMemo instead") +@module("react") external useMemo1: (@uncurry (unit => 'any), array<'a>) => 'any = "useMemo" -@module("react") @deprecated("Please use useMemo instead") +@module("react") external useMemo2: (@uncurry (unit => 'any), ('a, 'b)) => 'any = "useMemo" -@module("react") @deprecated("Please use useMemo instead") +@module("react") external useMemo3: (@uncurry (unit => 'any), ('a, 'b, 'c)) => 'any = "useMemo" -@module("react") @deprecated("Please use useMemo instead") +@module("react") external useMemo4: (@uncurry (unit => 'any), ('a, 'b, 'c, 'd)) => 'any = "useMemo" -@module("react") @deprecated("Please use useMemo instead") +@module("react") external useMemo5: (@uncurry (unit => 'any), ('a, 'b, 'c, 'd, 'e)) => 'any = "useMemo" -@module("react") @deprecated("Please use useMemo instead") +@module("react") external useMemo6: (@uncurry (unit => 'any), ('a, 'b, 'c, 'd, 'e, 'f)) => 'any = "useMemo" -@module("react") @deprecated("Please use useMemo instead") +@module("react") external useMemo7: (@uncurry (unit => 'any), ('a, 'b, 'c, 'd, 'e, 'f, 'g)) => 'any = "useMemo" @module("react") external useCallback: ('f, 'deps) => 'f = "useCallback" -@module("react") @deprecated("Please use useCallback instead") +@module("react") external useCallback0: ('f, @as(json`[]`) _) => 'f = "useCallback" -@module("react") @deprecated("Please use useCallback instead") +@module("react") external useCallback1: ('f, array<'a>) => 'f = "useCallback" -@module("react") @deprecated("Please use useCallback instead") +@module("react") external useCallback2: ('f, ('a, 'b)) => 'f = "useCallback" -@module("react") @deprecated("Please use useCallback instead") +@module("react") external useCallback3: ('f, ('a, 'b, 'c)) => 'f = "useCallback" -@module("react") @deprecated("Please use useCallback instead") +@module("react") external useCallback4: ('f, ('a, 'b, 'c, 'd)) => 'f = "useCallback" -@module("react") @deprecated("Please use useCallback instead") +@module("react") external useCallback5: ('f, ('a, 'b, 'c, 'd, 'e)) => 'f = "useCallback" -@module("react") @deprecated("Please use useCallback instead") +@module("react") external useCallback6: ('callback, ('a, 'b, 'c, 'd, 'e, 'f)) => 'callback = "useCallback" -@module("react") @deprecated("Please use useCallback instead") +@module("react") external useCallback7: ('callback, ('a, 'b, 'c, 'd, 'e, 'f, 'g)) => 'callback = "useCallback" @module("react") @@ -292,7 +292,6 @@ external useImperativeHandle: ( ) => unit = "useImperativeHandle" @module("react") -@deprecated("Please use useImperativeHandle or useImperativeHandleOnEveryRender instead") external useImperativeHandle0: ( Js.Nullable.t>, @uncurry (unit => 'value), @@ -300,7 +299,6 @@ external useImperativeHandle0: ( ) => unit = "useImperativeHandle" @module("react") -@deprecated("Please use useImperativeHandle or useImperativeHandleOnEveryRender instead") external useImperativeHandle1: ( Js.Nullable.t>, @uncurry (unit => 'value), @@ -308,7 +306,6 @@ external useImperativeHandle1: ( ) => unit = "useImperativeHandle" @module("react") -@deprecated("Please use useImperativeHandle or useImperativeHandleOnEveryRender instead") external useImperativeHandle2: ( Js.Nullable.t>, @uncurry (unit => 'value), @@ -316,7 +313,6 @@ external useImperativeHandle2: ( ) => unit = "useImperativeHandle" @module("react") -@deprecated("Please use useImperativeHandle or useImperativeHandleOnEveryRender instead") external useImperativeHandle3: ( Js.Nullable.t>, @uncurry (unit => 'value), @@ -324,7 +320,6 @@ external useImperativeHandle3: ( ) => unit = "useImperativeHandle" @module("react") -@deprecated("Please use useImperativeHandle or useImperativeHandleOnEveryRender instead") external useImperativeHandle4: ( Js.Nullable.t>, @uncurry (unit => 'value), @@ -332,7 +327,6 @@ external useImperativeHandle4: ( ) => unit = "useImperativeHandle" @module("react") -@deprecated("Please use useImperativeHandle or useImperativeHandleOnEveryRender instead") external useImperativeHandle5: ( Js.Nullable.t>, @uncurry (unit => 'value), @@ -340,7 +334,6 @@ external useImperativeHandle5: ( ) => unit = "useImperativeHandle" @module("react") -@deprecated("Please use useImperativeHandle or useImperativeHandleOnEveryRender instead") external useImperativeHandle6: ( Js.Nullable.t>, @uncurry (unit => 'value), @@ -348,7 +341,6 @@ external useImperativeHandle6: ( ) => unit = "useImperativeHandle" @module("react") -@deprecated("Please use useImperativeHandle or useImperativeHandleOnEveryRender instead") external useImperativeHandle7: ( Js.Nullable.t>, @uncurry (unit => 'value), @@ -369,39 +361,31 @@ external useInsertionEffectOnEveryRender: (@uncurry (unit => option unit external useInsertionEffect: (@uncurry (unit => option unit>), 'deps) => unit = "useInsertionEffect" @module("react") -@deprecated("Please use useInsertionEffect or useInsertionEffectOnEveryRender instead") external useInsertionEffect0: (@uncurry (unit => option unit>), @as(json`[]`) _) => unit = "useInsertionEffect" @module("react") -@deprecated("Please use useInsertionEffect or useInsertionEffectOnEveryRender instead") external useInsertionEffect1: (@uncurry (unit => option unit>), array<'a>) => unit = "useInsertionEffect" @module("react") -@deprecated("Please use useInsertionEffect or useInsertionEffectOnEveryRender instead") external useInsertionEffect2: (@uncurry (unit => option unit>), ('a, 'b)) => unit = "useInsertionEffect" @module("react") -@deprecated("Please use useInsertionEffect or useInsertionEffectOnEveryRender instead") external useInsertionEffect3: (@uncurry (unit => option unit>), ('a, 'b, 'c)) => unit = "useInsertionEffect" @module("react") -@deprecated("Please use useInsertionEffect or useInsertionEffectOnEveryRender instead") external useInsertionEffect4: (@uncurry (unit => option unit>), ('a, 'b, 'c, 'd)) => unit = "useInsertionEffect" @module("react") -@deprecated("Please use useInsertionEffect or useInsertionEffectOnEveryRender instead") external useInsertionEffect5: ( @uncurry (unit => option unit>), ('a, 'b, 'c, 'd, 'e), ) => unit = "useInsertionEffect" @module("react") -@deprecated("Please use useInsertionEffect or useInsertionEffectOnEveryRender instead") external useInsertionEffect6: ( @uncurry (unit => option unit>), ('a, 'b, 'c, 'd, 'e, 'f), ) => unit = "useInsertionEffect" @module("react") -@deprecated("Please use useInsertionEffect or useInsertionEffectOnEveryRender instead") external useInsertionEffect7: ( @uncurry (unit => option unit>), ('a, 'b, 'c, 'd, 'e, 'f, 'g), @@ -441,28 +425,28 @@ module Uncurried = { @module("react") external useCallback: ('f, 'deps) => 'f = "useCallback" - @module("react") @deprecated("Please use useCallback instead") + @module("react") external useCallback0: ('f, @as(json`[]`) _) => 'f = "useCallback" - @module("react") @deprecated("Please use useCallback instead") + @module("react") external useCallback1: ('f, array<'a>) => 'f = "useCallback" - @module("react") @deprecated("Please use useCallback instead") + @module("react") external useCallback2: ('f, ('a, 'b)) => 'f = "useCallback" - @module("react") @deprecated("Please use useCallback instead") + @module("react") external useCallback3: ('f, ('a, 'b, 'c)) => 'f = "useCallback" - @module("react") @deprecated("Please use useCallback instead") + @module("react") external useCallback4: ('f, ('a, 'b, 'c, 'd)) => 'f = "useCallback" - @module("react") @deprecated("Please use useCallback instead") + @module("react") external useCallback5: ('f, ('a, 'b, 'c, 'd, 'e)) => 'f = "useCallback" - @module("react") @deprecated("Please use useCallback instead") + @module("react") external useCallback6: ('callback, ('a, 'b, 'c, 'd, 'e, 'f)) => 'callback = "useCallback" - @module("react") @deprecated("Please use useCallback instead") + @module("react") external useCallback7: ('callback, ('a, 'b, 'c, 'd, 'e, 'f, 'g)) => 'callback = "useCallback" } diff --git a/src/RescriptReactRouter.bs.js b/src/RescriptReactRouter.bs.js index de69385..c90df30 100644 --- a/src/RescriptReactRouter.bs.js +++ b/src/RescriptReactRouter.bs.js @@ -153,7 +153,7 @@ function urlNotEqual(a, b) { function url(serverUrlString, param) { return { path: path(serverUrlString, undefined), - hash: hash(undefined), + hash: hash(), search: search(serverUrlString, undefined) }; } diff --git a/src/v3/React_V3.res b/src/v3/React_V3.res index 33c3efb..beeb4ac 100644 --- a/src/v3/React_V3.res +++ b/src/v3/React_V3.res @@ -160,25 +160,25 @@ external useReducerWithMapState: ( external useEffectOnEveryRender: (@uncurry (unit => option unit>)) => unit = "useEffect" @module("react") external useEffect: (@uncurry (unit => option unit>), 'deps) => unit = "useEffect" -@module("react") @deprecated("Please use useEffect or useEffectOnEveryRender instead") +@module("react") external useEffect0: (@uncurry (unit => option unit>), @as(json`[]`) _) => unit = "useEffect" -@module("react") @deprecated("Please use useEffect or useEffectOnEveryRender instead") +@module("react") external useEffect1: (@uncurry (unit => option unit>), array<'a>) => unit = "useEffect" -@module("react") @deprecated("Please use useEffect or useEffectOnEveryRender instead") +@module("react") external useEffect2: (@uncurry (unit => option unit>), ('a, 'b)) => unit = "useEffect" -@module("react") @deprecated("Please use useEffect or useEffectOnEveryRender instead") +@module("react") external useEffect3: (@uncurry (unit => option unit>), ('a, 'b, 'c)) => unit = "useEffect" -@module("react") @deprecated("Please use useEffect or useEffectOnEveryRender instead") +@module("react") external useEffect4: (@uncurry (unit => option unit>), ('a, 'b, 'c, 'd)) => unit = "useEffect" -@module("react") @deprecated("Please use useEffect or useEffectOnEveryRender instead") +@module("react") external useEffect5: (@uncurry (unit => option unit>), ('a, 'b, 'c, 'd, 'e)) => unit = "useEffect" -@module("react") @deprecated("Please use useEffect or useEffectOnEveryRender instead") +@module("react") external useEffect6: (@uncurry (unit => option unit>), ('a, 'b, 'c, 'd, 'e, 'f)) => unit = "useEffect" -@module("react") @deprecated("Please use useEffect or useEffectOnEveryRender instead") +@module("react") external useEffect7: ( @uncurry (unit => option unit>), ('a, 'b, 'c, 'd, 'e, 'f, 'g), @@ -190,30 +190,30 @@ external useLayoutEffectOnEveryRender: (@uncurry (unit => option unit>)) @module("react") external useLayoutEffect: (@uncurry (unit => option unit>), 'deps) => unit = "useLayoutEffect" -@module("react") @deprecated("Please use useLayoutEffect or useLayoutEffectOnEveryRender instead") +@module("react") external useLayoutEffect0: (@uncurry (unit => option unit>), @as(json`[]`) _) => unit = "useLayoutEffect" -@module("react") @deprecated("Please use useLayoutEffect or useLayoutEffectOnEveryRender instead") +@module("react") external useLayoutEffect1: (@uncurry (unit => option unit>), array<'a>) => unit = "useLayoutEffect" -@module("react") @deprecated("Please use useLayoutEffect or useLayoutEffectOnEveryRender instead") +@module("react") external useLayoutEffect2: (@uncurry (unit => option unit>), ('a, 'b)) => unit = "useLayoutEffect" -@module("react") @deprecated("Please use useLayoutEffect or useLayoutEffectOnEveryRender instead") +@module("react") external useLayoutEffect3: (@uncurry (unit => option unit>), ('a, 'b, 'c)) => unit = "useLayoutEffect" -@module("react") @deprecated("Please use useLayoutEffect or useLayoutEffectOnEveryRender instead") +@module("react") external useLayoutEffect4: (@uncurry (unit => option unit>), ('a, 'b, 'c, 'd)) => unit = "useLayoutEffect" -@module("react") @deprecated("Please use useLayoutEffect or useLayoutEffectOnEveryRender instead") +@module("react") external useLayoutEffect5: (@uncurry (unit => option unit>), ('a, 'b, 'c, 'd, 'e)) => unit = "useLayoutEffect" -@module("react") @deprecated("Please use useLayoutEffect or useLayoutEffectOnEveryRender instead") +@module("react") external useLayoutEffect6: ( @uncurry (unit => option unit>), ('a, 'b, 'c, 'd, 'e, 'f), ) => unit = "useLayoutEffect" -@module("react") @deprecated("Please use useLayoutEffect or useLayoutEffectOnEveryRender instead") +@module("react") external useLayoutEffect7: ( @uncurry (unit => option unit>), ('a, 'b, 'c, 'd, 'e, 'f, 'g), @@ -222,55 +222,55 @@ external useLayoutEffect7: ( @module("react") external useMemo: (@uncurry (unit => 'any), 'deps) => 'any = "useMemo" -@module("react") @deprecated("Please use useMemo instead") +@module("react") external useMemo0: (@uncurry (unit => 'any), @as(json`[]`) _) => 'any = "useMemo" -@module("react") @deprecated("Please use useMemo instead") +@module("react") external useMemo1: (@uncurry (unit => 'any), array<'a>) => 'any = "useMemo" -@module("react") @deprecated("Please use useMemo instead") +@module("react") external useMemo2: (@uncurry (unit => 'any), ('a, 'b)) => 'any = "useMemo" -@module("react") @deprecated("Please use useMemo instead") +@module("react") external useMemo3: (@uncurry (unit => 'any), ('a, 'b, 'c)) => 'any = "useMemo" -@module("react") @deprecated("Please use useMemo instead") +@module("react") external useMemo4: (@uncurry (unit => 'any), ('a, 'b, 'c, 'd)) => 'any = "useMemo" -@module("react") @deprecated("Please use useMemo instead") +@module("react") external useMemo5: (@uncurry (unit => 'any), ('a, 'b, 'c, 'd, 'e)) => 'any = "useMemo" -@module("react") @deprecated("Please use useMemo instead") +@module("react") external useMemo6: (@uncurry (unit => 'any), ('a, 'b, 'c, 'd, 'e, 'f)) => 'any = "useMemo" -@module("react") @deprecated("Please use useMemo instead") +@module("react") external useMemo7: (@uncurry (unit => 'any), ('a, 'b, 'c, 'd, 'e, 'f, 'g)) => 'any = "useMemo" @module("react") external useCallback: ('f, 'deps) => 'f = "useCallback" -@module("react") @deprecated("Please use useCallback instead") +@module("react") external useCallback0: ('f, @as(json`[]`) _) => 'f = "useCallback" -@module("react") @deprecated("Please use useCallback instead") +@module("react") external useCallback1: ('f, array<'a>) => 'f = "useCallback" -@module("react") @deprecated("Please use useCallback instead") +@module("react") external useCallback2: ('f, ('a, 'b)) => 'f = "useCallback" -@module("react") @deprecated("Please use useCallback instead") +@module("react") external useCallback3: ('f, ('a, 'b, 'c)) => 'f = "useCallback" -@module("react") @deprecated("Please use useCallback instead") +@module("react") external useCallback4: ('f, ('a, 'b, 'c, 'd)) => 'f = "useCallback" -@module("react") @deprecated("Please use useCallback instead") +@module("react") external useCallback5: ('f, ('a, 'b, 'c, 'd, 'e)) => 'f = "useCallback" -@module("react") @deprecated("Please use useCallback instead") +@module("react") external useCallback6: ('callback, ('a, 'b, 'c, 'd, 'e, 'f)) => 'callback = "useCallback" -@module("react") @deprecated("Please use useCallback instead") +@module("react") external useCallback7: ('callback, ('a, 'b, 'c, 'd, 'e, 'f, 'g)) => 'callback = "useCallback" @module("react") @@ -292,7 +292,6 @@ external useImperativeHandle: ( ) => unit = "useImperativeHandle" @module("react") -@deprecated("Please use useImperativeHandle or useImperativeHandleOnEveryRender instead") external useImperativeHandle0: ( Js.Nullable.t>, @uncurry (unit => 'value), @@ -300,7 +299,6 @@ external useImperativeHandle0: ( ) => unit = "useImperativeHandle" @module("react") -@deprecated("Please use useImperativeHandle or useImperativeHandleOnEveryRender instead") external useImperativeHandle1: ( Js.Nullable.t>, @uncurry (unit => 'value), @@ -308,7 +306,6 @@ external useImperativeHandle1: ( ) => unit = "useImperativeHandle" @module("react") -@deprecated("Please use useImperativeHandle or useImperativeHandleOnEveryRender instead") external useImperativeHandle2: ( Js.Nullable.t>, @uncurry (unit => 'value), @@ -316,7 +313,6 @@ external useImperativeHandle2: ( ) => unit = "useImperativeHandle" @module("react") -@deprecated("Please use useImperativeHandle or useImperativeHandleOnEveryRender instead") external useImperativeHandle3: ( Js.Nullable.t>, @uncurry (unit => 'value), @@ -324,7 +320,6 @@ external useImperativeHandle3: ( ) => unit = "useImperativeHandle" @module("react") -@deprecated("Please use useImperativeHandle or useImperativeHandleOnEveryRender instead") external useImperativeHandle4: ( Js.Nullable.t>, @uncurry (unit => 'value), @@ -332,7 +327,6 @@ external useImperativeHandle4: ( ) => unit = "useImperativeHandle" @module("react") -@deprecated("Please use useImperativeHandle or useImperativeHandleOnEveryRender instead") external useImperativeHandle5: ( Js.Nullable.t>, @uncurry (unit => 'value), @@ -340,7 +334,6 @@ external useImperativeHandle5: ( ) => unit = "useImperativeHandle" @module("react") -@deprecated("Please use useImperativeHandle or useImperativeHandleOnEveryRender instead") external useImperativeHandle6: ( Js.Nullable.t>, @uncurry (unit => 'value), @@ -348,7 +341,6 @@ external useImperativeHandle6: ( ) => unit = "useImperativeHandle" @module("react") -@deprecated("Please use useImperativeHandle or useImperativeHandleOnEveryRender instead") external useImperativeHandle7: ( Js.Nullable.t>, @uncurry (unit => 'value), @@ -376,28 +368,28 @@ module Uncurried = { @module("react") external useCallback: ('f, 'deps) => 'f = "useCallback" - @module("react") @deprecated("Please use useCallback instead") + @module("react") external useCallback0: ('f, @as(json`[]`) _) => 'f = "useCallback" - @module("react") @deprecated("Please use useCallback instead") + @module("react") external useCallback1: ('f, array<'a>) => 'f = "useCallback" - @module("react") @deprecated("Please use useCallback instead") + @module("react") external useCallback2: ('f, ('a, 'b)) => 'f = "useCallback" - @module("react") @deprecated("Please use useCallback instead") + @module("react") external useCallback3: ('f, ('a, 'b, 'c)) => 'f = "useCallback" - @module("react") @deprecated("Please use useCallback instead") + @module("react") external useCallback4: ('f, ('a, 'b, 'c, 'd)) => 'f = "useCallback" - @module("react") @deprecated("Please use useCallback instead") + @module("react") external useCallback5: ('f, ('a, 'b, 'c, 'd, 'e)) => 'f = "useCallback" - @module("react") @deprecated("Please use useCallback instead") + @module("react") external useCallback6: ('callback, ('a, 'b, 'c, 'd, 'e, 'f)) => 'callback = "useCallback" - @module("react") @deprecated("Please use useCallback instead") + @module("react") external useCallback7: ('callback, ('a, 'b, 'c, 'd, 'e, 'f, 'g)) => 'callback = "useCallback" } From 6c4b9c64241a234ddf1be5f4922ad736e61f18e0 Mon Sep 17 00:00:00 2001 From: Josh Vlk Date: Fri, 17 May 2024 10:53:12 -0400 Subject: [PATCH 15/34] Rename bsconfig.json to rescript.json --- bsconfig.json => rescript.json | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename bsconfig.json => rescript.json (100%) diff --git a/bsconfig.json b/rescript.json similarity index 100% rename from bsconfig.json rename to rescript.json From 733447c429c6856a96fe4f5b0d9deff3b6f89313 Mon Sep 17 00:00:00 2001 From: Christoph Knittel Date: Sat, 25 May 2024 15:50:10 +0200 Subject: [PATCH 16/34] Fix @uncurry usage (#114) --- src/React.res | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/React.res b/src/React.res index 5915094..0da49ad 100644 --- a/src/React.res +++ b/src/React.res @@ -394,14 +394,14 @@ external useInsertionEffect7: ( @module("react") external useSyncExternalStore: ( ~subscribe: @uncurry ((unit => unit) => (. unit) => unit), - ~getSnapshot: @uncurry unit => 'state, + ~getSnapshot: @uncurry (unit => 'state), ) => 'state = "useSyncExternalStore" @module("react") external useSyncExternalStoreWithServerSnapshot: ( ~subscribe: @uncurry ((unit => unit) => (. unit) => unit), - ~getSnapshot: @uncurry unit => 'state, - ~getServerSnapshot: @uncurry unit => 'state, + ~getSnapshot: @uncurry (unit => 'state), + ~getServerSnapshot: @uncurry (unit => 'state), ) => 'state = "useSyncExternalStore" module Uncurried = { From a6e311aab8b3af304d15cd25b408cb2e0006f7d4 Mon Sep 17 00:00:00 2001 From: cwstra Date: Sun, 26 May 2024 03:39:50 -0400 Subject: [PATCH 17/34] `bsconfig.json` -> `rescript.json` (#115) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2cf0397..eb3bdf9 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "README.md", "CHANGELOG.md", "LICENSE", - "bsconfig.json", + "rescript.json", "src/**/*.res", "src/**/*.resi" ], From 15c7f0d9e57814a9b97efb885d3ac754fd68d8a5 Mon Sep 17 00:00:00 2001 From: Christoph Knittel Date: Sun, 26 May 2024 19:08:43 +0200 Subject: [PATCH 18/34] Version 0.12.2 (#116) --- CHANGELOG.md | 5 +++++ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1eb12ac..3bb79f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,11 @@ > - :house: [Internal] > - :nail_care: [Polish] +## 0.12.2 + +- Fix incorrect usage of `@uncurry`. +- bsconfig.json -> rescript.json. + ## 0.12.1 - Undeprecate numbered hooks for a smoother upgrading experience. diff --git a/package-lock.json b/package-lock.json index 2f68573..92a87b1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@rescript/react", - "version": "0.12.1", + "version": "0.12.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@rescript/react", - "version": "0.12.1", + "version": "0.12.2", "license": "MIT", "devDependencies": { "react": "^18.2.0", diff --git a/package.json b/package.json index eb3bdf9..ca31a6c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@rescript/react", - "version": "0.12.1", + "version": "0.12.2", "description": "React bindings for ReScript", "files": [ "README.md", From 1b852bcf2fb10dc2244f109f6aa4e60ca83ff2a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paul=20Tsnobiladz=C3=A9?= Date: Fri, 7 Jun 2024 16:19:09 +0200 Subject: [PATCH 19/34] remove hardcoded require --- CHANGELOG.md | 6 ++++++ src/RescriptReactErrorBoundary.bs.js | 11 ++++++++--- src/RescriptReactErrorBoundary.res | 10 ++++++++-- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3bb79f0..b68eb7f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,12 @@ > - :house: [Internal] > - :nail_care: [Polish] +## 0.12.3 [Unreleased] + +#### :bug: Bug Fix + +- Remove hardcoded `require` so it works in both common js and ES module modes. (https://github.com/rescript-lang/rescript-react/pull/117) + ## 0.12.2 - Fix incorrect usage of `@uncurry`. diff --git a/src/RescriptReactErrorBoundary.bs.js b/src/RescriptReactErrorBoundary.bs.js index 3a0c291..fe5f73e 100644 --- a/src/RescriptReactErrorBoundary.bs.js +++ b/src/RescriptReactErrorBoundary.bs.js @@ -1,9 +1,14 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; - var React = require("react"); +var noOp = (function (_x) {}); + +var reactComponentClass = React.Component; + +noOp(reactComponentClass); + var ErrorBoundary = (function (Component) { function ErrorBoundary(props) { Component.call(this); @@ -19,10 +24,10 @@ var ErrorBoundary = (function (Component) { : this.props.children; }; return ErrorBoundary; -})(React.Component); +})(reactComponentClass); ; var make = ErrorBoundary; exports.make = make; -/* Not a pure module */ +/* reactComponentClass Not a pure module */ diff --git a/src/RescriptReactErrorBoundary.res b/src/RescriptReactErrorBoundary.res index 7f7019c..3caa0e8 100644 --- a/src/RescriptReactErrorBoundary.res +++ b/src/RescriptReactErrorBoundary.res @@ -10,8 +10,14 @@ type params<'error> = { info: info, } +type reactComponentClass +@module("react") external component: reactComponentClass = "Component" +let noOp: reactComponentClass => unit = %raw(`function (_x) {}`) +let reactComponentClass = component +// this is so that the compiler doesn't optimize away the previous line +noOp(reactComponentClass) + %%raw(` -var React = require("react"); var ErrorBoundary = (function (Component) { function ErrorBoundary(props) { @@ -28,7 +34,7 @@ var ErrorBoundary = (function (Component) { : this.props.children; }; return ErrorBoundary; -})(React.Component); +})(reactComponentClass); `) @react.component @val From 543ce149abe127437f4b6af8967a4c72c4a079ea Mon Sep 17 00:00:00 2001 From: Christoph Knittel Date: Wed, 24 Jul 2024 08:02:14 +0200 Subject: [PATCH 20/34] Get rid of %external usage (#118) --- src/RescriptReactRouter.bs.js | 37 ++++++++++++++++++----------------- src/RescriptReactRouter.res | 20 ++++++++++++------- 2 files changed, 32 insertions(+), 25 deletions(-) diff --git a/src/RescriptReactRouter.bs.js b/src/RescriptReactRouter.bs.js index c90df30..a86a821 100644 --- a/src/RescriptReactRouter.bs.js +++ b/src/RescriptReactRouter.bs.js @@ -5,6 +5,7 @@ var Curry = require("rescript/lib/js/curry.js"); var React = require("react"); var Js_array = require("rescript/lib/js/js_array.js"); var Js_string = require("rescript/lib/js/js_string.js"); +var Caml_option = require("rescript/lib/js/caml_option.js"); function safeMakeEvent(eventName) { if (typeof Event === "function") { @@ -48,22 +49,22 @@ function pathParse(str) { } function path(serverUrlString, param) { - var match = typeof window === "undefined" ? undefined : window; + var match = globalThis.window; if (serverUrlString !== undefined) { return pathParse(serverUrlString); } else if (match !== undefined) { - return pathParse(match.location.pathname); + return pathParse(Caml_option.valFromOption(match).location.pathname); } else { return /* [] */0; } } function hash(param) { - var $$window = typeof window === "undefined" ? undefined : window; + var $$window = globalThis.window; if ($$window === undefined) { return ""; } - var raw = $$window.location.hash; + var raw = Caml_option.valFromOption($$window).location.hash; switch (raw) { case "" : case "#" : @@ -89,33 +90,33 @@ function searchParse(str) { } function search(serverUrlString, param) { - var match = typeof window === "undefined" ? undefined : window; + var match = globalThis.window; if (serverUrlString !== undefined) { return searchParse(serverUrlString); } else if (match !== undefined) { - return searchParse(match.location.search); + return searchParse(Caml_option.valFromOption(match).location.search); } else { return ""; } } function push(path) { - var match = typeof history === "undefined" ? undefined : history; - var match$1 = typeof window === "undefined" ? undefined : window; + var match = globalThis.history; + var match$1 = globalThis.window; if (match !== undefined && match$1 !== undefined) { - match.pushState(null, "", path); - match$1.dispatchEvent(safeMakeEvent("popstate")); + Caml_option.valFromOption(match).pushState(null, "", path); + Caml_option.valFromOption(match$1).dispatchEvent(safeMakeEvent("popstate")); return ; } } function replace(path) { - var match = typeof history === "undefined" ? undefined : history; - var match$1 = typeof window === "undefined" ? undefined : window; + var match = globalThis.history; + var match$1 = globalThis.window; if (match !== undefined && match$1 !== undefined) { - match.replaceState(null, "", path); - match$1.dispatchEvent(safeMakeEvent("popstate")); + Caml_option.valFromOption(match).replaceState(null, "", path); + Caml_option.valFromOption(match$1).dispatchEvent(safeMakeEvent("popstate")); return ; } @@ -159,7 +160,7 @@ function url(serverUrlString, param) { } function watchUrl(callback) { - var $$window = typeof window === "undefined" ? undefined : window; + var $$window = globalThis.window; if ($$window === undefined) { return function (param) { @@ -168,14 +169,14 @@ function watchUrl(callback) { var watcherID = function (param) { Curry._1(callback, url(undefined, undefined)); }; - $$window.addEventListener("popstate", watcherID); + Caml_option.valFromOption($$window).addEventListener("popstate", watcherID); return watcherID; } function unwatchUrl(watcherID) { - var $$window = typeof window === "undefined" ? undefined : window; + var $$window = globalThis.window; if ($$window !== undefined) { - $$window.removeEventListener("popstate", watcherID); + Caml_option.valFromOption($$window).removeEventListener("popstate", watcherID); return ; } diff --git a/src/RescriptReactRouter.res b/src/RescriptReactRouter.res index 24e3222..e960d0c 100644 --- a/src/RescriptReactRouter.res +++ b/src/RescriptReactRouter.res @@ -1,3 +1,9 @@ +@scope("globalThis") +external window: option = "window" + +@scope("globalThis") +external history: option = "history" + @get external location: Dom.window => Dom.location = "location" /* actually the cb is Dom.event => unit, but let's restrict the access for now */ @@ -81,13 +87,13 @@ let pathParse = str => raw |> Js.String.split("/") |> Js.Array.filter(item => String.length(item) != 0) |> arrayToList } let path = (~serverUrlString=?, ()) => - switch (serverUrlString, %external(window)) { + switch (serverUrlString, window) { | (None, None) => list{} | (Some(serverUrlString), _) => pathParse(serverUrlString) | (_, Some(window: Dom.window)) => pathParse(window |> location |> pathname) } let hash = () => - switch %external(window) { + switch window { | None => "" | Some(window: Dom.window) => switch window |> location |> hash { @@ -111,14 +117,14 @@ let searchParse = str => } let search = (~serverUrlString=?, ()) => - switch (serverUrlString, %external(window)) { + switch (serverUrlString, window) { | (None, None) => "" | (Some(serverUrlString), _) => searchParse(serverUrlString) | (_, Some(window: Dom.window)) => searchParse(window |> location |> search) } let push = path => - switch (%external(history), %external(window)) { + switch (history, window) { | (None, _) | (_, None) => () | (Some(history: Dom.history), Some(window: Dom.window)) => @@ -127,7 +133,7 @@ let push = path => } let replace = path => - switch (%external(history), %external(window)) { + switch (history, window) { | (None, _) | (_, None) => () | (Some(history: Dom.history), Some(window: Dom.window)) => @@ -169,7 +175,7 @@ let url = (~serverUrlString=?, ()) => { let dangerouslyGetInitialUrl = url let watchUrl = callback => - switch %external(window) { + switch window { | None => () => () | Some(window: Dom.window) => let watcherID = () => callback(url()) @@ -178,7 +184,7 @@ let watchUrl = callback => } let unwatchUrl = watcherID => - switch %external(window) { + switch window { | None => () | Some(window: Dom.window) => removeEventListener(window, "popstate", watcherID) } From 654aa4bc3d9acbf4c088dd98550e94dceb0b54ea Mon Sep 17 00:00:00 2001 From: Christoph Knittel Date: Thu, 25 Jul 2024 07:41:57 +0200 Subject: [PATCH 21/34] Version 0.13.0 (#119) --- CHANGELOG.md | 6 +++++- package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b68eb7f..00076d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,11 @@ > - :house: [Internal] > - :nail_care: [Polish] -## 0.12.3 [Unreleased] +## 0.13.0 + +#### :boom: Breaking Change + +- Replace usages of `%external` by binding to `globalThis`. This is to support upcoming ReScript 12 versions. For older browsers, it may be necessary to polyfill `globalThis`. #### :bug: Bug Fix diff --git a/package-lock.json b/package-lock.json index 92a87b1..e5e9032 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@rescript/react", - "version": "0.12.2", + "version": "0.13.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@rescript/react", - "version": "0.12.2", + "version": "0.13.0", "license": "MIT", "devDependencies": { "react": "^18.2.0", diff --git a/package.json b/package.json index ca31a6c..e82f7f1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@rescript/react", - "version": "0.12.2", + "version": "0.13.0", "description": "React bindings for ReScript", "files": [ "README.md", From 479679f1baf5bcd04d80005ad48b91e2281e3cd7 Mon Sep 17 00:00:00 2001 From: woonki Date: Sat, 22 Feb 2025 18:01:27 +0900 Subject: [PATCH 22/34] Deprecate JSX 3 (#120) * deprecate v3 * changelog --- CHANGELOG.md | 4 + src/v3/ReactDOMStyle_V3.res | 8 +- src/v3/ReactDOM_V3.res | 21 +-- src/v3/ReactEvent_V3.res | 268 +++++++++++++++++++++--------------- src/v3/React_V3.res | 188 +++++++++++++------------ 5 files changed, 278 insertions(+), 211 deletions(-) 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 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 50c4073519d936b3001f0b2099d5e6e23a8f6587 Mon Sep 17 00:00:00 2001 From: Christoph Knittel Date: Sat, 22 Feb 2025 18:59:38 +0100 Subject: [PATCH 23/34] ReScriptReactRouter: get rid of pipe last (#126) --- src/RescriptReactRouter.bs.js | 18 ++++++++---------- src/RescriptReactRouter.res | 24 ++++++++++++------------ 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/src/RescriptReactRouter.bs.js b/src/RescriptReactRouter.bs.js index a86a821..3ca19e8 100644 --- a/src/RescriptReactRouter.bs.js +++ b/src/RescriptReactRouter.bs.js @@ -3,8 +3,6 @@ var Curry = require("rescript/lib/js/curry.js"); var React = require("react"); -var Js_array = require("rescript/lib/js/js_array.js"); -var Js_string = require("rescript/lib/js/js_string.js"); var Caml_option = require("rescript/lib/js/caml_option.js"); function safeMakeEvent(eventName) { @@ -22,14 +20,14 @@ function pathParse(str) { case "/" : return /* [] */0; default: - var raw = Js_string.sliceToEnd(1, str); + var raw = str.slice(1); var match = raw[raw.length - 1 | 0]; - var raw$1 = match === "/" ? Js_string.slice(0, -1, raw) : raw; - var match$1 = Js_string.splitAtMost("?", 2, raw$1); + var raw$1 = match === "/" ? raw.slice(0, -1) : raw; + var match$1 = raw$1.split("?", 2); var raw$2 = match$1.length !== 2 ? raw$1 : match$1[0]; - var a = Js_array.filter((function (item) { - return item.length !== 0; - }), Js_string.split("/", raw$2)); + var a = raw$2.split("/").filter(function (item) { + return item.length !== 0; + }); var _i = a.length - 1 | 0; var _res = /* [] */0; while(true) { @@ -70,7 +68,7 @@ function hash(param) { case "#" : return ""; default: - return Js_string.sliceToEnd(1, raw); + return raw.slice(1); } } @@ -80,7 +78,7 @@ function searchParse(str) { case "?" : return ""; default: - var match = Js_string.splitAtMost("?", 2, str); + var match = str.split("?", 2); if (match.length !== 2) { return ""; } else { diff --git a/src/RescriptReactRouter.res b/src/RescriptReactRouter.res index e960d0c..80f3d75 100644 --- a/src/RescriptReactRouter.res +++ b/src/RescriptReactRouter.res @@ -55,9 +55,9 @@ let arrayToList = a => { if i < 0 { res } else { - tolist(i - 1, list{Array.unsafe_get(a, i), ...res}) + tolist(i - 1, list{a->Js.Array2.unsafe_get(i), ...res}) } - tolist(Array.length(a) - 1, list{}) + tolist(a->Js.Array2.length - 1, list{}) } /* if we ever roll our own parser in the future, make sure you test all url combinations e.g. foo.com/?#bar @@ -72,37 +72,37 @@ let pathParse = str => list{} | raw => /* remove the preceeding /, which every pathname seems to have */ - let raw = Js.String.sliceToEnd(~from=1, raw) + let raw = raw->Js.String2.sliceToEnd(~from=1) /* remove the trailing /, which some pathnames might have. Ugh */ - let raw = switch Js.String.get(raw, Js.String.length(raw) - 1) { - | "/" => Js.String.slice(~from=0, ~to_=-1, raw) + let raw = switch raw->Js.String2.get(raw->Js.String2.length - 1) { + | "/" => raw->Js.String2.slice(~from=0, ~to_=-1) | _ => raw } /* remove search portion if present in string */ - let raw = switch raw |> Js.String.splitAtMost("?", ~limit=2) { + let raw = switch raw->Js.String2.splitAtMost("?", ~limit=2) { | [path, _] => path | _ => raw } - raw |> Js.String.split("/") |> Js.Array.filter(item => String.length(item) != 0) |> arrayToList + raw->Js.String2.split("/")->Js.Array2.filter(item => item->Js.String2.length != 0)->arrayToList } let path = (~serverUrlString=?, ()) => switch (serverUrlString, window) { | (None, None) => list{} | (Some(serverUrlString), _) => pathParse(serverUrlString) - | (_, Some(window: Dom.window)) => pathParse(window |> location |> pathname) + | (_, Some(window: Dom.window)) => pathParse(window->location->pathname) } let hash = () => switch window { | None => "" | Some(window: Dom.window) => - switch window |> location |> hash { + switch window->location->hash { | "" | "#" => "" | raw => /* remove the preceeding #, which every hash seems to have. Why is this even included in location.hash?? */ - raw |> Js.String.sliceToEnd(~from=1) + raw->Js.String2.sliceToEnd(~from=1) } } let searchParse = str => @@ -110,7 +110,7 @@ let searchParse = str => | "" | "?" => "" | raw => - switch raw |> Js.String.splitAtMost("?", ~limit=2) { + switch raw->Js.String2.splitAtMost("?", ~limit=2) { | [_, search] => search | _ => "" } @@ -120,7 +120,7 @@ let search = (~serverUrlString=?, ()) => switch (serverUrlString, window) { | (None, None) => "" | (Some(serverUrlString), _) => searchParse(serverUrlString) - | (_, Some(window: Dom.window)) => searchParse(window |> location |> search) + | (_, Some(window: Dom.window)) => searchParse(window->location->search) } let push = path => From e2e82e703e255b4d9b7284d08961a32542faa139 Mon Sep 17 00:00:00 2001 From: Christoph Knittel Date: Sat, 22 Feb 2025 19:13:15 +0100 Subject: [PATCH 24/34] Deprecate ReactDOMStyle.make (#127) --- src/ReactDOMStyle.res | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ReactDOMStyle.res b/src/ReactDOMStyle.res index 02b8b49..0f57b7a 100644 --- a/src/ReactDOMStyle.res +++ b/src/ReactDOMStyle.res @@ -1,6 +1,6 @@ type t = JsxDOMStyle.t -@obj +@deprecated("Please directly construct the style record instead") @obj external make: ( ~azimuth: string=?, ~backdropFilter: string=?, From 501d3694f5b5d1b795b764be7b90083539948105 Mon Sep 17 00:00:00 2001 From: Christoph Knittel Date: Sun, 23 Feb 2025 12:27:38 +0100 Subject: [PATCH 25/34] Version 0.13.1 (#128) --- CHANGELOG.md | 11 +++++++++-- package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 371bc4a..516f062 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,9 +10,16 @@ > - :house: [Internal] > - :nail_care: [Polish] -## 0.13.1 (Unreleased) +## 0.13.1 -- Deprecate JSX 3 https://github.com/rescript-lang/rescript-react/pull/120 +#### :boom: Breaking Change + +- Deprecate JSX 3. https://github.com/rescript-lang/rescript-react/pull/120 +- Deprecate ReactDOMStyle.make. https://github.com/rescript-lang/rescript-react/pull/127 + +#### :nail_care: Polish + +- ReScriptReactRouter: get rid of pipe last. https://github.com/rescript-lang/rescript-react/pull/126 ## 0.13.0 diff --git a/package-lock.json b/package-lock.json index e5e9032..99bed8f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@rescript/react", - "version": "0.13.0", + "version": "0.13.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@rescript/react", - "version": "0.13.0", + "version": "0.13.1", "license": "MIT", "devDependencies": { "react": "^18.2.0", diff --git a/package.json b/package.json index e82f7f1..6668fec 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@rescript/react", - "version": "0.13.0", + "version": "0.13.1", "description": "React bindings for ReScript", "files": [ "README.md", From c73c9bec8d838c92ab4576b8e6be1b652439ae50 Mon Sep 17 00:00:00 2001 From: Christoph Knittel Date: Sat, 22 Feb 2025 17:00:30 +0100 Subject: [PATCH 26/34] Remove v3 legacy modules --- src/legacy/ReactDOMRe.res | 19 - src/legacy/ReasonReact.res | 6 - src/v3/ReactDOMStyle_V3.bs.js | 12 - src/v3/ReactDOMStyle_V3.res | 437 ------- src/v3/ReactDOM_V3.bs.js | 17 - src/v3/ReactDOM_V3.res | 2118 --------------------------------- src/v3/ReactEvent_V3.bs.js | 53 - src/v3/ReactEvent_V3.res | 322 ----- src/v3/ReactEvent_V3.resi | 471 -------- src/v3/ReactV3.bs.js | 21 - src/v3/ReactV3.res | 35 - src/v3/React_V3.bs.js | 26 - src/v3/React_V3.res | 409 ------- 13 files changed, 3946 deletions(-) delete mode 100644 src/legacy/ReactDOMRe.res delete mode 100644 src/legacy/ReasonReact.res delete mode 100644 src/v3/ReactDOMStyle_V3.bs.js delete mode 100644 src/v3/ReactDOMStyle_V3.res delete mode 100644 src/v3/ReactDOM_V3.bs.js delete mode 100644 src/v3/ReactDOM_V3.res delete mode 100644 src/v3/ReactEvent_V3.bs.js delete mode 100644 src/v3/ReactEvent_V3.res delete mode 100644 src/v3/ReactEvent_V3.resi delete mode 100644 src/v3/ReactV3.bs.js delete mode 100644 src/v3/ReactV3.res delete mode 100644 src/v3/React_V3.bs.js delete mode 100644 src/v3/React_V3.res diff --git a/src/legacy/ReactDOMRe.res b/src/legacy/ReactDOMRe.res deleted file mode 100644 index c528baa..0000000 --- a/src/legacy/ReactDOMRe.res +++ /dev/null @@ -1,19 +0,0 @@ -/** -This module is kept for ReScript react-jsx v3 compatibility -We removed all functionality that is not needed for JSX usage -**/ -include ReactDOM_V3.Props - -@variadic @module("react") -external createDOMElementVariadic: ( - string, - ~props: ReactDOM_V3.domProps=?, - array, -) => React.element = "createElement" - -@variadic @module("react") -external createElement: ( - string, - ~props: ReactDOM_V3.domProps=?, - array, -) => React.element = "createElement" diff --git a/src/legacy/ReasonReact.res b/src/legacy/ReasonReact.res deleted file mode 100644 index 95ec6eb..0000000 --- a/src/legacy/ReasonReact.res +++ /dev/null @@ -1,6 +0,0 @@ -/** -This module is kept for ReScript react-jsx v3 compatibility -We removed all functionality that is not needed for JSX usage -**/ - -@module("react") external fragment: 'a = "Fragment" diff --git a/src/v3/ReactDOMStyle_V3.bs.js b/src/v3/ReactDOMStyle_V3.bs.js deleted file mode 100644 index 18702c8..0000000 --- a/src/v3/ReactDOMStyle_V3.bs.js +++ /dev/null @@ -1,12 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function unsafeAddProp(style, key, value) { - var dict = {}; - dict[key] = value; - return Object.assign({}, style, dict); -} - -exports.unsafeAddProp = unsafeAddProp; -/* No side effect */ diff --git a/src/v3/ReactDOMStyle_V3.res b/src/v3/ReactDOMStyle_V3.res deleted file mode 100644 index 93d9711..0000000 --- a/src/v3/ReactDOMStyle_V3.res +++ /dev/null @@ -1,437 +0,0 @@ -type t = ReactDOMStyle.t - -@obj @deprecated("Jsx 3 is deprecated, use jsx 4 instead") -external make: ( - ~azimuth: string=?, - ~background: string=?, - ~backgroundAttachment: string=?, - ~backgroundColor: string=?, - ~backgroundImage: string=?, - ~backgroundPosition: string=?, - ~backgroundRepeat: string=?, - ~border: string=?, - ~borderCollapse: string=?, - ~borderColor: string=?, - ~borderSpacing: string=?, - ~borderStyle: string=?, - ~borderTop: string=?, - ~borderRight: string=?, - ~borderBottom: string=?, - ~borderLeft: string=?, - ~borderTopColor: string=?, - ~borderRightColor: string=?, - ~borderBottomColor: string=?, - ~borderLeftColor: string=?, - ~borderTopStyle: string=?, - ~borderRightStyle: string=?, - ~borderBottomStyle: string=?, - ~borderLeftStyle: string=?, - ~borderTopWidth: string=?, - ~borderRightWidth: string=?, - ~borderBottomWidth: string=?, - ~borderLeftWidth: string=?, - ~borderWidth: string=?, - ~bottom: string=?, - ~captionSide: string=?, - ~clear: string=?, - ~clip: string=?, - ~color: string=?, - ~content: string=?, - ~counterIncrement: string=?, - ~counterReset: string=?, - ~cue: string=?, - ~cueAfter: string=?, - ~cueBefore: string=?, - ~cursor: string=?, - ~direction: string=?, - ~display: string=?, - ~elevation: string=?, - ~emptyCells: string=?, - ~float: string=?, - ~font: string=?, - ~fontFamily: string=?, - ~fontSize: string=?, - ~fontSizeAdjust: string=?, - ~fontStretch: string=?, - ~fontStyle: string=?, - ~fontVariant: string=?, - ~fontWeight: string=?, - ~height: string=?, - ~left: string=?, - ~letterSpacing: string=?, - ~lineHeight: string=?, - ~listStyle: string=?, - ~listStyleImage: string=?, - ~listStylePosition: string=?, - ~listStyleType: string=?, - ~margin: string=?, - ~marginTop: string=?, - ~marginRight: string=?, - ~marginBottom: string=?, - ~marginLeft: string=?, - ~markerOffset: string=?, - ~marks: string=?, - ~maxHeight: string=?, - ~maxWidth: string=?, - ~minHeight: string=?, - ~minWidth: string=?, - ~orphans: string=?, - ~outline: string=?, - ~outlineColor: string=?, - ~outlineStyle: string=?, - ~outlineWidth: string=?, - ~overflow: string=?, - ~overflowX: string=?, - ~overflowY: string=?, - ~padding: string=?, - ~paddingTop: string=?, - ~paddingRight: string=?, - ~paddingBottom: string=?, - ~paddingLeft: string=?, - ~page: string=?, - ~pageBreakAfter: string=?, - ~pageBreakBefore: string=?, - ~pageBreakInside: string=?, - ~pause: string=?, - ~pauseAfter: string=?, - ~pauseBefore: string=?, - ~pitch: string=?, - ~pitchRange: string=?, - ~playDuring: string=?, - ~position: string=?, - ~quotes: string=?, - ~richness: string=?, - ~right: string=?, - ~size: string=?, - ~speak: string=?, - ~speakHeader: string=?, - ~speakNumeral: string=?, - ~speakPunctuation: string=?, - ~speechRate: string=?, - ~stress: string=?, - ~tableLayout: string=?, - ~textAlign: string=?, - ~textDecoration: string=?, - ~textIndent: string=?, - ~textShadow: string=?, - ~textTransform: string=?, - ~top: string=?, - ~unicodeBidi: string=?, - ~verticalAlign: string=?, - ~visibility: string=?, - ~voiceFamily: string=?, - ~volume: string=?, - ~whiteSpace: string=?, - ~widows: string=?, - ~width: string=?, - ~wordSpacing: string=?, - ~zIndex: string=?, - ~opacity: /* Below properties based on https://www.w3.org/Style/CSS/all-properties */ - /* Color Level 3 - REC */ - string=?, - ~backgroundOrigin: /* Backgrounds and Borders Level 3 - CR */ - /* backgroundRepeat - already defined by CSS2Properties */ - /* backgroundAttachment - already defined by CSS2Properties */ - string=?, - ~backgroundSize: string=?, - ~backgroundClip: string=?, - ~borderRadius: string=?, - ~borderTopLeftRadius: string=?, - ~borderTopRightRadius: string=?, - ~borderBottomLeftRadius: string=?, - ~borderBottomRightRadius: string=?, - ~borderImage: string=?, - ~borderImageSource: string=?, - ~borderImageSlice: string=?, - ~borderImageWidth: string=?, - ~borderImageOutset: string=?, - ~borderImageRepeat: string=?, - ~boxShadow: string=?, - ~columns: /* Multi-column Layout - CR */ - string=?, - ~columnCount: string=?, - ~columnFill: string=?, - ~columnGap: string=?, - ~columnRule: string=?, - ~columnRuleColor: string=?, - ~columnRuleStyle: string=?, - ~columnRuleWidth: string=?, - ~columnSpan: string=?, - ~columnWidth: string=?, - ~breakAfter: string=?, - ~breakBefore: string=?, - ~breakInside: string=?, - ~rest: /* Speech - CR */ - string=?, - ~restAfter: string=?, - ~restBefore: string=?, - ~speakAs: string=?, - ~voiceBalance: string=?, - ~voiceDuration: string=?, - ~voicePitch: string=?, - ~voiceRange: string=?, - ~voiceRate: string=?, - ~voiceStress: string=?, - ~voiceVolume: string=?, - ~objectFit: /* Image Values and Replaced Content Level 3 - CR */ - string=?, - ~objectPosition: string=?, - ~imageResolution: string=?, - ~imageOrientation: string=?, - ~alignContent: /* Flexible Box Layout - CR */ - string=?, - ~alignItems: string=?, - ~alignSelf: string=?, - ~flex: string=?, - ~flexBasis: string=?, - ~flexDirection: string=?, - ~flexFlow: string=?, - ~flexGrow: string=?, - ~flexShrink: string=?, - ~flexWrap: string=?, - ~justifyContent: string=?, - ~order: string=?, - ~textDecorationColor: /* Text Decoration Level 3 - CR */ - /* textDecoration - already defined by CSS2Properties */ - string=?, - ~textDecorationLine: string=?, - ~textDecorationSkip: string=?, - ~textDecorationStyle: string=?, - ~textEmphasis: string=?, - ~textEmphasisColor: string=?, - ~textEmphasisPosition: string=?, - ~textEmphasisStyle: string=?, - ~textUnderlinePosition: /* textShadow - already defined by CSS2Properties */ - string=?, - ~fontFeatureSettings: /* Fonts Level 3 - CR */ - string=?, - ~fontKerning: string=?, - ~fontLanguageOverride: string=?, - ~fontSynthesis: /* fontSizeAdjust - already defined by CSS2Properties */ - /* fontStretch - already defined by CSS2Properties */ - string=?, - ~forntVariantAlternates: string=?, - ~fontVariantCaps: string=?, - ~fontVariantEastAsian: string=?, - ~fontVariantLigatures: string=?, - ~fontVariantNumeric: string=?, - ~fontVariantPosition: string=?, - ~all: /* Cascading and Inheritance Level 3 - CR */ - string=?, - ~glyphOrientationVertical: /* Writing Modes Level 3 - CR */ - string=?, - ~textCombineUpright: string=?, - ~textOrientation: string=?, - ~writingMode: string=?, - ~shapeImageThreshold: /* Shapes Level 1 - CR */ - string=?, - ~shapeMargin: string=?, - ~shapeOutside: string=?, - ~clipPath: /* Masking Level 1 - CR */ - string=?, - ~clipRule: string=?, - ~mask: string=?, - ~maskBorder: string=?, - ~maskBorderMode: string=?, - ~maskBorderOutset: string=?, - ~maskBorderRepeat: string=?, - ~maskBorderSlice: string=?, - ~maskBorderSource: string=?, - ~maskBorderWidth: string=?, - ~maskClip: string=?, - ~maskComposite: string=?, - ~maskImage: string=?, - ~maskMode: string=?, - ~maskOrigin: string=?, - ~maskPosition: string=?, - ~maskRepeat: string=?, - ~maskSize: string=?, - ~maskType: string=?, - ~backgroundBlendMode: /* Compositing and Blending Level 1 - CR */ - string=?, - ~isolation: string=?, - ~mixBlendMode: string=?, - ~boxDecorationBreak: /* Fragmentation Level 3 - CR */ - string=?, - ~boxSizing: /* breakAfter - already defined by Multi-column Layout */ - /* breakBefore - already defined by Multi-column Layout */ - /* breakInside - already defined by Multi-column Layout */ - /* Basic User Interface Level 3 - CR */ - string=?, - ~caretColor: string=?, - ~navDown: string=?, - ~navLeft: string=?, - ~navRight: string=?, - ~navUp: string=?, - ~outlineOffset: string=?, - ~resize: string=?, - ~textOverflow: string=?, - ~grid: /* Grid Layout Level 1 - CR */ - string=?, - ~gridArea: string=?, - ~gridAutoColumns: string=?, - ~gridAutoFlow: string=?, - ~gridAutoRows: string=?, - ~gridColumn: string=?, - ~gridColumnEnd: string=?, - ~gridColumnGap: string=?, - ~gridColumnStart: string=?, - ~gridGap: string=?, - ~gridRow: string=?, - ~gridRowEnd: string=?, - ~gridRowGap: string=?, - ~gridRowStart: string=?, - ~gridTemplate: string=?, - ~gridTemplateAreas: string=?, - ~gridTemplateColumns: string=?, - ~gridTemplateRows: string=?, - ~willChange: /* Will Change Level 1 - CR */ - string=?, - ~hangingPunctuation: /* Text Level 3 - LC */ - string=?, - ~hyphens: string=?, - ~lineBreak: /* letterSpacing - already defined by CSS2Properties */ - string=?, - ~overflowWrap: string=?, - ~tabSize: string=?, - ~textAlignLast: /* textAlign - already defined by CSS2Properties */ - string=?, - ~textJustify: string=?, - ~wordBreak: string=?, - ~wordWrap: string=?, - ~animation: /* Animations - WD */ - string=?, - ~animationDelay: string=?, - ~animationDirection: string=?, - ~animationDuration: string=?, - ~animationFillMode: string=?, - ~animationIterationCount: string=?, - ~animationName: string=?, - ~animationPlayState: string=?, - ~animationTimingFunction: string=?, - ~transition: /* Transitions - WD */ - string=?, - ~transitionDelay: string=?, - ~transitionDuration: string=?, - ~transitionProperty: string=?, - ~transitionTimingFunction: string=?, - ~backfaceVisibility: /* Transforms Level 1 - WD */ - string=?, - ~perspective: string=?, - ~perspectiveOrigin: string=?, - ~transform: string=?, - ~transformOrigin: string=?, - ~transformStyle: string=?, - ~justifyItems: /* Box Alignment Level 3 - WD */ - /* alignContent - already defined by Flexible Box Layout */ - /* alignItems - already defined by Flexible Box Layout */ - string=?, - ~justifySelf: string=?, - ~placeContent: string=?, - ~placeItems: string=?, - ~placeSelf: string=?, - ~appearance: /* Basic User Interface Level 4 - FPWD */ - string=?, - ~caret: string=?, - ~caretAnimation: string=?, - ~caretShape: string=?, - ~userSelect: string=?, - ~maxLines: /* Overflow Level 3 - WD */ - string=?, - ~marqueeDirection: /* Basix Box Model - WD */ - string=?, - ~marqueeLoop: string=?, - ~marqueeSpeed: string=?, - ~marqueeStyle: string=?, - ~overflowStyle: string=?, - ~rotation: string=?, - ~rotationPoint: string=?, - ~alignmentBaseline: /* SVG 1.1 - REC */ - string=?, - ~baselineShift: string=?, - ~clip: string=?, - ~clipPath: string=?, - ~clipRule: string=?, - ~colorInterpolation: string=?, - ~colorInterpolationFilters: string=?, - ~colorProfile: string=?, - ~colorRendering: string=?, - ~cursor: string=?, - ~dominantBaseline: string=?, - ~fill: string=?, - ~fillOpacity: string=?, - ~fillRule: string=?, - ~filter: string=?, - ~floodColor: string=?, - ~floodOpacity: string=?, - ~glyphOrientationHorizontal: string=?, - ~glyphOrientationVertical: string=?, - ~imageRendering: string=?, - ~kerning: string=?, - ~lightingColor: string=?, - ~markerEnd: string=?, - ~markerMid: string=?, - ~markerStart: string=?, - ~pointerEvents: string=?, - ~shapeRendering: string=?, - ~stopColor: string=?, - ~stopOpacity: string=?, - ~stroke: string=?, - ~strokeDasharray: string=?, - ~strokeDashoffset: string=?, - ~strokeLinecap: string=?, - ~strokeLinejoin: string=?, - ~strokeMiterlimit: string=?, - ~strokeOpacity: string=?, - ~strokeWidth: string=?, - ~textAnchor: string=?, - ~textRendering: string=?, - ~rubyAlign: /* Ruby Layout Level 1 - WD */ - string=?, - ~rubyMerge: string=?, - ~rubyPosition: string=?, - /* Lists and Counters Level 3 - WD */ - /* listStyle - already defined by CSS2Properties */ - /* listStyleImage - already defined by CSS2Properties */ - /* listStylePosition - already defined by CSS2Properties */ - /* listStyleType - already defined by CSS2Properties */ - /* counterIncrement - already defined by CSS2Properties */ - /* counterReset - already defined by CSS2Properties */ - /* Not added yet - * ------------- - * Generated Content for Paged Media - WD - * Generated Content Level 3 - WD - * Line Grid Level 1 - WD - * Regions - WD - * Inline Layout Level 3 - WD - * Round Display Level 1 - WD - * Image Values and Replaced Content Level 4 - WD - * Positioned Layout Level 3 - WD - * Filter Effects Level 1 - -WD - * Exclusions Level 1 - WD - * Text Level 4 - FPWD - * SVG Markers - FPWD - * Motion Path Level 1 - FPWD - * Color Level 4 - FPWD - * SVG Strokes - FPWD - * Table Level 3 - FPWD - */ - unit, -) => t = "" - -/* CSS2Properties: https://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSS2Properties */ -@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 @deprecated("Jsx 3 is deprecated, use jsx 4 instead") -external unsafeAddStyle: (@as(json`{}`) _, t, {..}) => t = "Object.assign" diff --git a/src/v3/ReactDOM_V3.bs.js b/src/v3/ReactDOM_V3.bs.js deleted file mode 100644 index e2bdd8a..0000000 --- a/src/v3/ReactDOM_V3.bs.js +++ /dev/null @@ -1,17 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -var Experimental = {}; - -var Ref = {}; - -var Props = {}; - -var Style; - -exports.Experimental = Experimental; -exports.Ref = Ref; -exports.Props = Props; -exports.Style = Style; -/* No side effect */ diff --git a/src/v3/ReactDOM_V3.res b/src/v3/ReactDOM_V3.res deleted file mode 100644 index cfbea88..0000000 --- a/src/v3/ReactDOM_V3.res +++ /dev/null @@ -1,2118 +0,0 @@ -/* First time reading a ReScript file? */ -/* `external` is the foreign function call in OCaml. */ -/* here we're saying `I guarantee that on the JS side, we have a `render` function in the module "react-dom" - that takes in a reactElement, a dom element, and returns unit (nothing) */ -/* It's like `let`, except you're pointing the implementation to the JS side. The compiler will inline these - 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) @deprecated("Jsx 3 is deprecated, use jsx 4 instead") -external querySelector: string => option = "document.querySelector" - -@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") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") - external createRoot: Dom.element => root = "createRoot" - - @module("react-dom") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") - external createBlockingRoot: Dom.element => root = "createBlockingRoot" - - @send @deprecated("Jsx 3 is deprecated, use jsx 4 instead") - external render: (root, React.element) => unit = "render" -} - -@module("react-dom") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") -external hydrate: (React.element, Dom.element) => unit = "hydrate" - -@module("react-dom") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") -external createPortal: (React.element, Dom.element) => React.element = "createPortal" - -@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 - -type domRef = ReactDOM.domRef - -module Ref = { - type t = domRef - 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" -} - -module Props = { - /* This list isn't exhaustive. We'll add more as we go. */ - /* - * Watch out! There are two props types and the only difference is the type of ref. - * Please keep in sync. - */ - @deriving(abstract) - type domProps = { - @optional - key: string, - @optional - ref: domRef, - /* accessibility */ - /* https://www.w3.org/TR/wai-aria-1.1/ */ - /* https://accessibilityresources.org/ is a great resource for these */ - /* [@optional] [@as "aria-current"] ariaCurrent: page|step|location|date|time|true|false, */ - @optional @as("aria-details") - ariaDetails: string, - @optional @as("aria-disabled") - ariaDisabled: bool, - @optional @as("aria-hidden") - ariaHidden: bool, - /* [@optional] [@as "aria-invalid"] ariaInvalid: grammar|false|spelling|true, */ - @optional @as("aria-keyshortcuts") - ariaKeyshortcuts: string, - @optional @as("aria-label") - ariaLabel: string, - @optional @as("aria-roledescription") - ariaRoledescription: string, - /* Widget Attributes */ - /* [@optional] [@as "aria-autocomplete"] ariaAutocomplete: inline|list|both|none, */ - /* [@optional] [@as "aria-checked"] ariaChecked: true|false|mixed, /* https://www.w3.org/TR/wai-aria-1.1/#valuetype_tristate */ */ - @optional @as("aria-expanded") - ariaExpanded: bool, - /* [@optional] [@as "aria-haspopup"] ariaHaspopup: false|true|menu|listbox|tree|grid|dialog, */ - @optional @as("aria-level") - ariaLevel: int, - @optional @as("aria-modal") - ariaModal: bool, - @optional @as("aria-multiline") - ariaMultiline: bool, - @optional @as("aria-multiselectable") - ariaMultiselectable: bool, - /* [@optional] [@as "aria-orientation"] ariaOrientation: horizontal|vertical|undefined, */ - @optional @as("aria-placeholder") - ariaPlaceholder: string, - /* [@optional] [@as "aria-pressed"] ariaPressed: true|false|mixed, /* https://www.w3.org/TR/wai-aria-1.1/#valuetype_tristate */ */ - @optional @as("aria-readonly") - ariaReadonly: bool, - @optional @as("aria-required") - ariaRequired: bool, - @optional @as("aria-selected") - ariaSelected: bool, - @optional @as("aria-sort") - ariaSort: string, - @optional @as("aria-valuemax") - ariaValuemax: float, - @optional @as("aria-valuemin") - ariaValuemin: float, - @optional @as("aria-valuenow") - ariaValuenow: float, - @optional @as("aria-valuetext") - ariaValuetext: string, - /* Live Region Attributes */ - @optional @as("aria-atomic") - ariaAtomic: bool, - @optional @as("aria-busy") - ariaBusy: bool, - /* [@optional] [@as "aria-live"] ariaLive: off|polite|assertive|rude, */ - @optional @as("aria-relevant") - ariaRelevant: string, - /* Drag-and-Drop Attributes */ - /* [@optional] [@as "aria-dropeffect"] ariaDropeffect: copy|move|link|execute|popup|none, */ - @optional @as("aria-grabbed") - ariaGrabbed: bool, - /* Relationship Attributes */ - @optional @as("aria-activedescendant") - ariaActivedescendant: string, - @optional @as("aria-colcount") - ariaColcount: int, - @optional @as("aria-colindex") - ariaColindex: int, - @optional @as("aria-colspan") - ariaColspan: int, - @optional @as("aria-controls") - ariaControls: string, - @optional @as("aria-describedby") - ariaDescribedby: string, - @optional @as("aria-errormessage") - ariaErrormessage: string, - @optional @as("aria-flowto") - ariaFlowto: string, - @optional @as("aria-labelledby") - ariaLabelledby: string, - @optional @as("aria-owns") - ariaOwns: string, - @optional @as("aria-posinset") - ariaPosinset: int, - @optional @as("aria-rowcount") - ariaRowcount: int, - @optional @as("aria-rowindex") - ariaRowindex: int, - @optional @as("aria-rowspan") - ariaRowspan: int, - @optional @as("aria-setsize") - ariaSetsize: int, - /* react textarea/input */ - @optional - defaultChecked: bool, - @optional - defaultValue: string, - /* global html attributes */ - @optional - accessKey: string, - @optional - className: string /* substitute for "class" */, - @optional - contentEditable: bool, - @optional - contextMenu: string, - @optional - dir: string /* "ltr", "rtl" or "auto" */, - @optional - draggable: bool, - @optional - hidden: bool, - @optional - id: string, - @optional - lang: string, - @optional - role: string /* ARIA role */, - @optional - style: style, - @optional - spellCheck: bool, - @optional - tabIndex: int, - @optional - title: string, - /* html5 microdata */ - @optional - itemID: string, - @optional - itemProp: string, - @optional - itemRef: string, - @optional - itemScope: bool, - @optional - itemType: string /* uri */, - /* tag-specific html attributes */ - @optional - accept: string, - @optional - acceptCharset: string, - @optional - action: string /* uri */, - @optional - allowFullScreen: bool, - @optional - alt: string, - @optional - async: bool, - @optional - autoComplete: string /* has a fixed, but large-ish, set of possible values */, - @optional - autoCapitalize: string /* Mobile Safari specific */, - @optional - autoFocus: bool, - @optional - autoPlay: bool, - @optional - challenge: string, - @optional - charSet: string, - @optional - checked: bool, - @optional - cite: string /* uri */, - @optional - crossOrigin: string /* anonymous, use-credentials */, - @optional - cols: int, - @optional - colSpan: int, - @optional - content: string, - @optional - controls: bool, - @optional - coords: string /* set of values specifying the coordinates of a region */, - @optional - data: string /* uri */, - @optional - dateTime: string /* "valid date string with optional time" */, - @optional - default: bool, - @optional - defer: bool, - @optional - disabled: bool, - @optional - download: string /* should really be either a boolean, signifying presence, or a string */, - @optional - encType: string /* "application/x-www-form-urlencoded", "multipart/form-data" or "text/plain" */, - @optional - form: string, - @optional - formAction: string /* uri */, - @optional - formTarget: string /* "_blank", "_self", etc. */, - @optional - formMethod: string /* "post", "get", "put" */, - @optional - headers: string, - @optional - height: string /* in html5 this can only be a number, but in html4 it can ba a percentage as well */, - @optional - high: int, - @optional - href: string /* uri */, - @optional - hrefLang: string, - @optional - htmlFor: string /* substitute for "for" */, - @optional - httpEquiv: string /* has a fixed set of possible values */, - @optional - icon: string /* uri? */, - @optional - inputMode: string /* "verbatim", "latin", "numeric", etc. */, - @optional - integrity: string, - @optional - keyType: string, - @optional - kind: string /* has a fixed set of possible values */, - @optional - label: string, - @optional - list: string, - @optional - loading: [#"lazy" | #eager], - @optional - loop: bool, - @optional - low: int, - @optional - manifest: string /* uri */, - @optional - max: string /* should be int or Js.Date.t */, - @optional - maxLength: int, - @optional - media: string /* a valid media query */, - @optional - mediaGroup: string, - @optional - method: string /* "post" or "get" */, - @optional - min: string, - @optional - minLength: int, - @optional - multiple: bool, - @optional - muted: bool, - @optional - name: string, - @optional - nonce: string, - @optional - noValidate: bool, - @optional @as("open") - open_: bool /* use this one. Previous one is deprecated */, - @optional - optimum: int, - @optional - pattern: string /* valid Js RegExp */, - @optional - placeholder: string, - @optional - playsInline: bool, - @optional - poster: string /* uri */, - @optional - preload: string /* "none", "metadata" or "auto" (and "" as a synonym for "auto") */, - @optional - radioGroup: string, - @optional - readOnly: bool, - @optional - rel: string /* a space- or comma-separated (depending on the element) list of a fixed set of "link types" */, - @optional - required: bool, - @optional - reversed: bool, - @optional - rows: int, - @optional - rowSpan: int, - @optional - sandbox: string /* has a fixed set of possible values */, - @optional - scope: string /* has a fixed set of possible values */, - @optional - scoped: bool, - @optional - scrolling: string /* html4 only, "auto", "yes" or "no" */, - /* seamless - supported by React, but removed from the html5 spec */ - @optional - selected: bool, - @optional - shape: string, - @optional - size: int, - @optional - sizes: string, - @optional - span: int, - @optional - src: string /* uri */, - @optional - srcDoc: string, - @optional - srcLang: string, - @optional - srcSet: string, - @optional - start: int, - @optional - step: float, - @optional - summary: string /* deprecated */, - @optional - target: string, - @optional @as("type") - type_: string /* has a fixed but large-ish set of possible values */ /* use this one. Previous one is deprecated */, - @optional - useMap: string, - @optional - value: string, - @optional - width: string /* in html5 this can only be a number, but in html4 it can ba a percentage as well */, - @optional - wrap: string /* "hard" or "soft" */, - /* Clipboard events */ - @optional - onCopy: ReactEvent.Clipboard.t => unit, - @optional - onCut: ReactEvent.Clipboard.t => unit, - @optional - onPaste: ReactEvent.Clipboard.t => unit, - /* Composition events */ - @optional - onCompositionEnd: ReactEvent.Composition.t => unit, - @optional - onCompositionStart: ReactEvent.Composition.t => unit, - @optional - onCompositionUpdate: ReactEvent.Composition.t => unit, - /* Keyboard events */ - @optional - onKeyDown: ReactEvent.Keyboard.t => unit, - @optional - onKeyPress: ReactEvent.Keyboard.t => unit, - @optional - onKeyUp: ReactEvent.Keyboard.t => unit, - /* Focus events */ - @optional - onFocus: ReactEvent.Focus.t => unit, - @optional - onBlur: ReactEvent.Focus.t => unit, - /* Form events */ - @optional - onChange: ReactEvent.Form.t => unit, - @optional - onInput: ReactEvent.Form.t => unit, - @optional - onSubmit: ReactEvent.Form.t => unit, - @optional - onInvalid: ReactEvent.Form.t => unit, - /* Mouse events */ - @optional - onClick: ReactEvent.Mouse.t => unit, - @optional - onContextMenu: ReactEvent.Mouse.t => unit, - @optional - onDoubleClick: ReactEvent.Mouse.t => unit, - @optional - onDrag: ReactEvent.Mouse.t => unit, - @optional - onDragEnd: ReactEvent.Mouse.t => unit, - @optional - onDragEnter: ReactEvent.Mouse.t => unit, - @optional - onDragExit: ReactEvent.Mouse.t => unit, - @optional - onDragLeave: ReactEvent.Mouse.t => unit, - @optional - onDragOver: ReactEvent.Mouse.t => unit, - @optional - onDragStart: ReactEvent.Mouse.t => unit, - @optional - onDrop: ReactEvent.Mouse.t => unit, - @optional - onMouseDown: ReactEvent.Mouse.t => unit, - @optional - onMouseEnter: ReactEvent.Mouse.t => unit, - @optional - onMouseLeave: ReactEvent.Mouse.t => unit, - @optional - onMouseMove: ReactEvent.Mouse.t => unit, - @optional - onMouseOut: ReactEvent.Mouse.t => unit, - @optional - onMouseOver: ReactEvent.Mouse.t => unit, - @optional - onMouseUp: ReactEvent.Mouse.t => unit, - /* Selection events */ - @optional - onSelect: ReactEvent.Selection.t => unit, - /* Touch events */ - @optional - onTouchCancel: ReactEvent.Touch.t => unit, - @optional - onTouchEnd: ReactEvent.Touch.t => unit, - @optional - onTouchMove: ReactEvent.Touch.t => unit, - @optional - onTouchStart: ReactEvent.Touch.t => unit, - // Pointer events - @optional - onPointerOver: ReactEvent.Pointer.t => unit, - @optional - onPointerEnter: ReactEvent.Pointer.t => unit, - @optional - onPointerDown: ReactEvent.Pointer.t => unit, - @optional - onPointerMove: ReactEvent.Pointer.t => unit, - @optional - onPointerUp: ReactEvent.Pointer.t => unit, - @optional - onPointerCancel: ReactEvent.Pointer.t => unit, - @optional - onPointerOut: ReactEvent.Pointer.t => unit, - @optional - onPointerLeave: ReactEvent.Pointer.t => unit, - @optional - onGotPointerCapture: ReactEvent.Pointer.t => unit, - @optional - onLostPointerCapture: ReactEvent.Pointer.t => unit, - /* UI events */ - @optional - onScroll: ReactEvent.UI.t => unit, - /* Wheel events */ - @optional - onWheel: ReactEvent.Wheel.t => unit, - /* Media events */ - @optional - onAbort: ReactEvent.Media.t => unit, - @optional - onCanPlay: ReactEvent.Media.t => unit, - @optional - onCanPlayThrough: ReactEvent.Media.t => unit, - @optional - onDurationChange: ReactEvent.Media.t => unit, - @optional - onEmptied: ReactEvent.Media.t => unit, - @optional - onEncrypted: ReactEvent.Media.t => unit, - @optional - onEnded: ReactEvent.Media.t => unit, - @optional - onError: ReactEvent.Media.t => unit, - @optional - onLoadedData: ReactEvent.Media.t => unit, - @optional - onLoadedMetadata: ReactEvent.Media.t => unit, - @optional - onLoadStart: ReactEvent.Media.t => unit, - @optional - onPause: ReactEvent.Media.t => unit, - @optional - onPlay: ReactEvent.Media.t => unit, - @optional - onPlaying: ReactEvent.Media.t => unit, - @optional - onProgress: ReactEvent.Media.t => unit, - @optional - onRateChange: ReactEvent.Media.t => unit, - @optional - onSeeked: ReactEvent.Media.t => unit, - @optional - onSeeking: ReactEvent.Media.t => unit, - @optional - onStalled: ReactEvent.Media.t => unit, - @optional - onSuspend: ReactEvent.Media.t => unit, - @optional - onTimeUpdate: ReactEvent.Media.t => unit, - @optional - onVolumeChange: ReactEvent.Media.t => unit, - @optional - onWaiting: ReactEvent.Media.t => unit, - /* Image events */ - @optional - onLoad: ReactEvent.Image.t => unit /* duplicate */ /* ~onError: ReactEvent.Image.t => unit=?, */, - /* Animation events */ - @optional - onAnimationStart: ReactEvent.Animation.t => unit, - @optional - onAnimationEnd: ReactEvent.Animation.t => unit, - @optional - onAnimationIteration: ReactEvent.Animation.t => unit, - /* Transition events */ - @optional - onTransitionEnd: ReactEvent.Transition.t => unit, - /* svg */ - @optional - accentHeight: string, - @optional - accumulate: string, - @optional - additive: string, - @optional - alignmentBaseline: string, - @optional - allowReorder: string, - @optional - alphabetic: string, - @optional - amplitude: string, - @optional - arabicForm: string, - @optional - ascent: string, - @optional - attributeName: string, - @optional - attributeType: string, - @optional - autoReverse: string, - @optional - azimuth: string, - @optional - baseFrequency: string, - @optional - baseProfile: string, - @optional - baselineShift: string, - @optional - bbox: string, - @optional @as("begin") - begin_: string /* use this one. Previous one is deprecated */, - @optional - bias: string, - @optional - by: string, - @optional - calcMode: string, - @optional - capHeight: string, - @optional - clip: string, - @optional - clipPath: string, - @optional - clipPathUnits: string, - @optional - clipRule: string, - @optional - colorInterpolation: string, - @optional - colorInterpolationFilters: string, - @optional - colorProfile: string, - @optional - colorRendering: string, - @optional - contentScriptType: string, - @optional - contentStyleType: string, - @optional - cursor: string, - @optional - cx: string, - @optional - cy: string, - @optional - d: string, - @optional - decelerate: string, - @optional - descent: string, - @optional - diffuseConstant: string, - @optional - direction: string, - @optional - display: string, - @optional - divisor: string, - @optional - dominantBaseline: string, - @optional - dur: string, - @optional - dx: string, - @optional - dy: string, - @optional - edgeMode: string, - @optional - elevation: string, - @optional - enableBackground: string, - @optional @as("end") - end_: string /* use this one. Previous one is deprecated */, - @optional - exponent: string, - @optional - externalResourcesRequired: string, - @optional - fill: string, - @optional - fillOpacity: string, - @optional - fillRule: string, - @optional - filter: string, - @optional - filterRes: string, - @optional - filterUnits: string, - @optional - floodColor: string, - @optional - floodOpacity: string, - @optional - focusable: string, - @optional - fontFamily: string, - @optional - fontSize: string, - @optional - fontSizeAdjust: string, - @optional - fontStretch: string, - @optional - fontStyle: string, - @optional - fontVariant: string, - @optional - fontWeight: string, - @optional - fomat: string, - @optional - from: string, - @optional - fx: string, - @optional - fy: string, - @optional - g1: string, - @optional - g2: string, - @optional - glyphName: string, - @optional - glyphOrientationHorizontal: string, - @optional - glyphOrientationVertical: string, - @optional - glyphRef: string, - @optional - gradientTransform: string, - @optional - gradientUnits: string, - @optional - hanging: string, - @optional - horizAdvX: string, - @optional - horizOriginX: string, - @optional - ideographic: string, - @optional - imageRendering: string, - @optional @as("in") - in_: string /* use this one. Previous one is deprecated */, - @optional - in2: string, - @optional - intercept: string, - @optional - k: string, - @optional - k1: string, - @optional - k2: string, - @optional - k3: string, - @optional - k4: string, - @optional - kernelMatrix: string, - @optional - kernelUnitLength: string, - @optional - kerning: string, - @optional - keyPoints: string, - @optional - keySplines: string, - @optional - keyTimes: string, - @optional - lengthAdjust: string, - @optional - letterSpacing: string, - @optional - lightingColor: string, - @optional - limitingConeAngle: string, - @optional - local: string, - @optional - markerEnd: string, - @optional - markerHeight: string, - @optional - markerMid: string, - @optional - markerStart: string, - @optional - markerUnits: string, - @optional - markerWidth: string, - @optional - mask: string, - @optional - maskContentUnits: string, - @optional - maskUnits: string, - @optional - mathematical: string, - @optional - mode: string, - @optional - numOctaves: string, - @optional - offset: string, - @optional - opacity: string, - @optional - operator: string, - @optional - order: string, - @optional - orient: string, - @optional - orientation: string, - @optional - origin: string, - @optional - overflow: string, - @optional - overflowX: string, - @optional - overflowY: string, - @optional - overlinePosition: string, - @optional - overlineThickness: string, - @optional - paintOrder: string, - @optional - panose1: string, - @optional - pathLength: string, - @optional - patternContentUnits: string, - @optional - patternTransform: string, - @optional - patternUnits: string, - @optional - pointerEvents: string, - @optional - points: string, - @optional - pointsAtX: string, - @optional - pointsAtY: string, - @optional - pointsAtZ: string, - @optional - preserveAlpha: string, - @optional - preserveAspectRatio: string, - @optional - primitiveUnits: string, - @optional - r: string, - @optional - radius: string, - @optional - refX: string, - @optional - refY: string, - @optional - renderingIntent: string, - @optional - repeatCount: string, - @optional - repeatDur: string, - @optional - requiredExtensions: string, - @optional - requiredFeatures: string, - @optional - restart: string, - @optional - result: string, - @optional - rotate: string, - @optional - rx: string, - @optional - ry: string, - @optional - scale: string, - @optional - seed: string, - @optional - shapeRendering: string, - @optional - slope: string, - @optional - spacing: string, - @optional - specularConstant: string, - @optional - specularExponent: string, - @optional - speed: string, - @optional - spreadMethod: string, - @optional - startOffset: string, - @optional - stdDeviation: string, - @optional - stemh: string, - @optional - stemv: string, - @optional - stitchTiles: string, - @optional - stopColor: string, - @optional - stopOpacity: string, - @optional - strikethroughPosition: string, - @optional - strikethroughThickness: string, - @optional - string: string, - @optional - stroke: string, - @optional - strokeDasharray: string, - @optional - strokeDashoffset: string, - @optional - strokeLinecap: string, - @optional - strokeLinejoin: string, - @optional - strokeMiterlimit: string, - @optional - strokeOpacity: string, - @optional - strokeWidth: string, - @optional - surfaceScale: string, - @optional - systemLanguage: string, - @optional - tableValues: string, - @optional - targetX: string, - @optional - targetY: string, - @optional - textAnchor: string, - @optional - textDecoration: string, - @optional - textLength: string, - @optional - textRendering: string, - @optional @as("to") - to_: string /* use this one. Previous one is deprecated */, - @optional - transform: string, - @optional - u1: string, - @optional - u2: string, - @optional - underlinePosition: string, - @optional - underlineThickness: string, - @optional - unicode: string, - @optional - unicodeBidi: string, - @optional - unicodeRange: string, - @optional - unitsPerEm: string, - @optional - vAlphabetic: string, - @optional - vHanging: string, - @optional - vIdeographic: string, - @optional - vMathematical: string, - @optional - values: string, - @optional - vectorEffect: string, - @optional - version: string, - @optional - vertAdvX: string, - @optional - vertAdvY: string, - @optional - vertOriginX: string, - @optional - vertOriginY: string, - @optional - viewBox: string, - @optional - viewTarget: string, - @optional - visibility: string, - /* width::string? => */ - @optional - widths: string, - @optional - wordSpacing: string, - @optional - writingMode: string, - @optional - x: string, - @optional - x1: string, - @optional - x2: string, - @optional - xChannelSelector: string, - @optional - xHeight: string, - @optional - xlinkActuate: string, - @optional - xlinkArcrole: string, - @optional - xlinkHref: string, - @optional - xlinkRole: string, - @optional - xlinkShow: string, - @optional - xlinkTitle: string, - @optional - xlinkType: string, - @optional - xmlns: string, - @optional - xmlnsXlink: string, - @optional - xmlBase: string, - @optional - xmlLang: string, - @optional - xmlSpace: string, - @optional - y: string, - @optional - y1: string, - @optional - y2: string, - @optional - yChannelSelector: string, - @optional - z: string, - @optional - zoomAndPan: string, - /* RDFa */ - @optional - about: string, - @optional - datatype: string, - @optional - inlist: string, - @optional - prefix: string, - @optional - property: string, - @optional - resource: string, - @optional - typeof: string, - @optional - vocab: string, - /* react-specific */ - @optional - dangerouslySetInnerHTML: {"__html": string}, - @optional - suppressContentEditableWarning: bool, - } - - /* This list isn't exhaustive. We'll add more as we go. */ - /* - * Watch out! There are two props types and the only difference is the type of ref. - * Please keep in sync. - */ - @deriving(abstract) - type props = { - @optional - key: string, - @optional - ref: Js.nullable => unit, - /* accessibility */ - /* https://www.w3.org/TR/wai-aria-1.1/ */ - /* https://accessibilityresources.org/ is a great resource for these */ - /* [@optional] [@as "aria-current"] ariaCurrent: page|step|location|date|time|true|false, */ - @optional @as("aria-details") - ariaDetails: string, - @optional @as("aria-disabled") - ariaDisabled: bool, - @optional @as("aria-hidden") - ariaHidden: bool, - /* [@optional] [@as "aria-invalid"] ariaInvalid: grammar|false|spelling|true, */ - @optional @as("aria-keyshortcuts") - ariaKeyshortcuts: string, - @optional @as("aria-label") - ariaLabel: string, - @optional @as("aria-roledescription") - ariaRoledescription: string, - /* Widget Attributes */ - /* [@optional] [@as "aria-autocomplete"] ariaAutocomplete: inline|list|both|none, */ - /* [@optional] [@as "aria-checked"] ariaChecked: true|false|mixed, /* https://www.w3.org/TR/wai-aria-1.1/#valuetype_tristate */ */ - @optional @as("aria-expanded") - ariaExpanded: bool, - /* [@optional] [@as "aria-haspopup"] ariaHaspopup: false|true|menu|listbox|tree|grid|dialog, */ - @optional @as("aria-level") - ariaLevel: int, - @optional @as("aria-modal") - ariaModal: bool, - @optional @as("aria-multiline") - ariaMultiline: bool, - @optional @as("aria-multiselectable") - ariaMultiselectable: bool, - /* [@optional] [@as "aria-orientation"] ariaOrientation: horizontal|vertical|undefined, */ - @optional @as("aria-placeholder") - ariaPlaceholder: string, - /* [@optional] [@as "aria-pressed"] ariaPressed: true|false|mixed, /* https://www.w3.org/TR/wai-aria-1.1/#valuetype_tristate */ */ - @optional @as("aria-readonly") - ariaReadonly: bool, - @optional @as("aria-required") - ariaRequired: bool, - @optional @as("aria-selected") - ariaSelected: bool, - @optional @as("aria-sort") - ariaSort: string, - @optional @as("aria-valuemax") - ariaValuemax: float, - @optional @as("aria-valuemin") - ariaValuemin: float, - @optional @as("aria-valuenow") - ariaValuenow: float, - @optional @as("aria-valuetext") - ariaValuetext: string, - /* Live Region Attributes */ - @optional @as("aria-atomic") - ariaAtomic: bool, - @optional @as("aria-busy") - ariaBusy: bool, - /* [@optional] [@as "aria-live"] ariaLive: off|polite|assertive|rude, */ - @optional @as("aria-relevant") - ariaRelevant: string, - /* Drag-and-Drop Attributes */ - /* [@optional] [@as "aria-dropeffect"] ariaDropeffect: copy|move|link|execute|popup|none, */ - @optional @as("aria-grabbed") - ariaGrabbed: bool, - /* Relationship Attributes */ - @optional @as("aria-activedescendant") - ariaActivedescendant: string, - @optional @as("aria-colcount") - ariaColcount: int, - @optional @as("aria-colindex") - ariaColindex: int, - @optional @as("aria-colspan") - ariaColspan: int, - @optional @as("aria-controls") - ariaControls: string, - @optional @as("aria-describedby") - ariaDescribedby: string, - @optional @as("aria-errormessage") - ariaErrormessage: string, - @optional @as("aria-flowto") - ariaFlowto: string, - @optional @as("aria-labelledby") - ariaLabelledby: string, - @optional @as("aria-owns") - ariaOwns: string, - @optional @as("aria-posinset") - ariaPosinset: int, - @optional @as("aria-rowcount") - ariaRowcount: int, - @optional @as("aria-rowindex") - ariaRowindex: int, - @optional @as("aria-rowspan") - ariaRowspan: int, - @optional @as("aria-setsize") - ariaSetsize: int, - /* react textarea/input */ - @optional - defaultChecked: bool, - @optional - defaultValue: string, - /* global html attributes */ - @optional - accessKey: string, - @optional - className: string /* substitute for "class" */, - @optional - contentEditable: bool, - @optional - contextMenu: string, - @optional - dir: string /* "ltr", "rtl" or "auto" */, - @optional - draggable: bool, - @optional - hidden: bool, - @optional - id: string, - @optional - lang: string, - @optional - role: string /* ARIA role */, - @optional - style: style, - @optional - spellCheck: bool, - @optional - tabIndex: int, - @optional - title: string, - /* html5 microdata */ - @optional - itemID: string, - @optional - itemProp: string, - @optional - itemRef: string, - @optional - itemScope: bool, - @optional - itemType: string /* uri */, - /* tag-specific html attributes */ - @optional - accept: string, - @optional - acceptCharset: string, - @optional - action: string /* uri */, - @optional - allow: string, - @optional - allowFullScreen: bool, - @optional - alt: string, - @optional - async: bool, - @optional - autoComplete: string /* has a fixed, but large-ish, set of possible values */, - @optional - autoCapitalize: string /* Mobile Safari specific */, - @optional - autoFocus: bool, - @optional - autoPlay: bool, - @optional - challenge: string, - @optional - charSet: string, - @optional - checked: bool, - @optional - cite: string /* uri */, - @optional - crossorigin: bool, - @optional - cols: int, - @optional - colSpan: int, - @optional - content: string, - @optional - controls: bool, - @optional - coords: string /* set of values specifying the coordinates of a region */, - @optional - data: string /* uri */, - @optional - dateTime: string /* "valid date string with optional time" */, - @optional - default: bool, - @optional - defer: bool, - @optional - disabled: bool, - @optional - download: string /* should really be either a boolean, signifying presence, or a string */, - @optional - encType: string /* "application/x-www-form-urlencoded", "multipart/form-data" or "text/plain" */, - @optional - form: string, - @optional - formAction: string /* uri */, - @optional - formTarget: string /* "_blank", "_self", etc. */, - @optional - formMethod: string /* "post", "get", "put" */, - @optional - frameBorder: int /* deprecated, prefer to use css border instead */, - @optional - headers: string, - @optional - height: string /* in html5 this can only be a number, but in html4 it can ba a percentage as well */, - @optional - high: int, - @optional - href: string /* uri */, - @optional - hrefLang: string, - @optional - htmlFor: string /* substitute for "for" */, - @optional - httpEquiv: string /* has a fixed set of possible values */, - @optional - icon: string /* uri? */, - @optional - inputMode: string /* "verbatim", "latin", "numeric", etc. */, - @optional - integrity: string, - @optional - keyType: string, - @optional - kind: string /* has a fixed set of possible values */, - @optional - label: string, - @optional - list: string, - @optional - loop: bool, - @optional - low: int, - @optional - manifest: string /* uri */, - @optional - max: string /* should be int or Js.Date.t */, - @optional - maxLength: int, - @optional - media: string /* a valid media query */, - @optional - mediaGroup: string, - @optional - method: string /* "post" or "get" */, - @optional - min: string, - @optional - minLength: int, - @optional - multiple: bool, - @optional - muted: bool, - @optional - name: string, - @optional - nonce: string, - @optional - noValidate: bool, - @optional @as("open") - open_: bool /* use this one. Previous one is deprecated */, - @optional - optimum: int, - @optional - pattern: string /* valid Js RegExp */, - @optional - placeholder: string, - @optional - poster: string /* uri */, - @optional - preload: string /* "none", "metadata" or "auto" (and "" as a synonym for "auto") */, - @optional - radioGroup: string, - @optional - readOnly: bool, - @optional - rel: string /* a space- or comma-separated (depending on the element) list of a fixed set of "link types" */, - @optional - required: bool, - @optional - reversed: bool, - @optional - rows: int, - @optional - rowSpan: int, - @optional - sandbox: string /* has a fixed set of possible values */, - @optional - scope: string /* has a fixed set of possible values */, - @optional - scoped: bool, - @optional - scrolling: string /* html4 only, "auto", "yes" or "no" */, - /* seamless - supported by React, but removed from the html5 spec */ - @optional - selected: bool, - @optional - shape: string, - @optional - size: int, - @optional - sizes: string, - @optional - span: int, - @optional - src: string /* uri */, - @optional - srcDoc: string, - @optional - srcLang: string, - @optional - srcSet: string, - @optional - start: int, - @optional - step: float, - @optional - summary: string /* deprecated */, - @optional - target: string, - @optional @as("type") - type_: string /* has a fixed but large-ish set of possible values */ /* use this one. Previous one is deprecated */, - @optional - useMap: string, - @optional - value: string, - @optional - width: string /* in html5 this can only be a number, but in html4 it can ba a percentage as well */, - @optional - wrap: string /* "hard" or "soft" */, - /* Clipboard events */ - @optional - onCopy: ReactEvent.Clipboard.t => unit, - @optional - onCut: ReactEvent.Clipboard.t => unit, - @optional - onPaste: ReactEvent.Clipboard.t => unit, - /* Composition events */ - @optional - onCompositionEnd: ReactEvent.Composition.t => unit, - @optional - onCompositionStart: ReactEvent.Composition.t => unit, - @optional - onCompositionUpdate: ReactEvent.Composition.t => unit, - /* Keyboard events */ - @optional - onKeyDown: ReactEvent.Keyboard.t => unit, - @optional - onKeyPress: ReactEvent.Keyboard.t => unit, - @optional - onKeyUp: ReactEvent.Keyboard.t => unit, - /* Focus events */ - @optional - onFocus: ReactEvent.Focus.t => unit, - @optional - onBlur: ReactEvent.Focus.t => unit, - /* Form events */ - @optional - onChange: ReactEvent.Form.t => unit, - @optional - onInput: ReactEvent.Form.t => unit, - @optional - onSubmit: ReactEvent.Form.t => unit, - @optional - onInvalid: ReactEvent.Form.t => unit, - /* Mouse events */ - @optional - onClick: ReactEvent.Mouse.t => unit, - @optional - onContextMenu: ReactEvent.Mouse.t => unit, - @optional - onDoubleClick: ReactEvent.Mouse.t => unit, - @optional - onDrag: ReactEvent.Mouse.t => unit, - @optional - onDragEnd: ReactEvent.Mouse.t => unit, - @optional - onDragEnter: ReactEvent.Mouse.t => unit, - @optional - onDragExit: ReactEvent.Mouse.t => unit, - @optional - onDragLeave: ReactEvent.Mouse.t => unit, - @optional - onDragOver: ReactEvent.Mouse.t => unit, - @optional - onDragStart: ReactEvent.Mouse.t => unit, - @optional - onDrop: ReactEvent.Mouse.t => unit, - @optional - onMouseDown: ReactEvent.Mouse.t => unit, - @optional - onMouseEnter: ReactEvent.Mouse.t => unit, - @optional - onMouseLeave: ReactEvent.Mouse.t => unit, - @optional - onMouseMove: ReactEvent.Mouse.t => unit, - @optional - onMouseOut: ReactEvent.Mouse.t => unit, - @optional - onMouseOver: ReactEvent.Mouse.t => unit, - @optional - onMouseUp: ReactEvent.Mouse.t => unit, - /* Selection events */ - @optional - onSelect: ReactEvent.Selection.t => unit, - /* Touch events */ - @optional - onTouchCancel: ReactEvent.Touch.t => unit, - @optional - onTouchEnd: ReactEvent.Touch.t => unit, - @optional - onTouchMove: ReactEvent.Touch.t => unit, - @optional - onTouchStart: ReactEvent.Touch.t => unit, - // Pointer events - @optional - onPointerOver: ReactEvent.Pointer.t => unit, - @optional - onPointerEnter: ReactEvent.Pointer.t => unit, - @optional - onPointerDown: ReactEvent.Pointer.t => unit, - @optional - onPointerMove: ReactEvent.Pointer.t => unit, - @optional - onPointerUp: ReactEvent.Pointer.t => unit, - @optional - onPointerCancel: ReactEvent.Pointer.t => unit, - @optional - onPointerOut: ReactEvent.Pointer.t => unit, - @optional - onPointerLeave: ReactEvent.Pointer.t => unit, - @optional - onGotPointerCapture: ReactEvent.Pointer.t => unit, - @optional - onLostPointerCapture: ReactEvent.Pointer.t => unit, - /* UI events */ - @optional - onScroll: ReactEvent.UI.t => unit, - /* Wheel events */ - @optional - onWheel: ReactEvent.Wheel.t => unit, - /* Media events */ - @optional - onAbort: ReactEvent.Media.t => unit, - @optional - onCanPlay: ReactEvent.Media.t => unit, - @optional - onCanPlayThrough: ReactEvent.Media.t => unit, - @optional - onDurationChange: ReactEvent.Media.t => unit, - @optional - onEmptied: ReactEvent.Media.t => unit, - @optional - onEncrypetd: ReactEvent.Media.t => unit, - @optional - onEnded: ReactEvent.Media.t => unit, - @optional - onError: ReactEvent.Media.t => unit, - @optional - onLoadedData: ReactEvent.Media.t => unit, - @optional - onLoadedMetadata: ReactEvent.Media.t => unit, - @optional - onLoadStart: ReactEvent.Media.t => unit, - @optional - onPause: ReactEvent.Media.t => unit, - @optional - onPlay: ReactEvent.Media.t => unit, - @optional - onPlaying: ReactEvent.Media.t => unit, - @optional - onProgress: ReactEvent.Media.t => unit, - @optional - onRateChange: ReactEvent.Media.t => unit, - @optional - onSeeked: ReactEvent.Media.t => unit, - @optional - onSeeking: ReactEvent.Media.t => unit, - @optional - onStalled: ReactEvent.Media.t => unit, - @optional - onSuspend: ReactEvent.Media.t => unit, - @optional - onTimeUpdate: ReactEvent.Media.t => unit, - @optional - onVolumeChange: ReactEvent.Media.t => unit, - @optional - onWaiting: ReactEvent.Media.t => unit, - /* Image events */ - @optional - onLoad: ReactEvent.Image.t => unit /* duplicate */ /* ~onError: ReactEvent.Image.t => unit=?, */, - /* Animation events */ - @optional - onAnimationStart: ReactEvent.Animation.t => unit, - @optional - onAnimationEnd: ReactEvent.Animation.t => unit, - @optional - onAnimationIteration: ReactEvent.Animation.t => unit, - /* Transition events */ - @optional - onTransitionEnd: ReactEvent.Transition.t => unit, - /* svg */ - @optional - accentHeight: string, - @optional - accumulate: string, - @optional - additive: string, - @optional - alignmentBaseline: string, - @optional - allowReorder: string, - @optional - alphabetic: string, - @optional - amplitude: string, - @optional - arabicForm: string, - @optional - ascent: string, - @optional - attributeName: string, - @optional - attributeType: string, - @optional - autoReverse: string, - @optional - azimuth: string, - @optional - baseFrequency: string, - @optional - baseProfile: string, - @optional - baselineShift: string, - @optional - bbox: string, - @optional @as("begin") - begin_: string /* use this one. Previous one is deprecated */, - @optional - bias: string, - @optional - by: string, - @optional - calcMode: string, - @optional - capHeight: string, - @optional - clip: string, - @optional - clipPath: string, - @optional - clipPathUnits: string, - @optional - clipRule: string, - @optional - colorInterpolation: string, - @optional - colorInterpolationFilters: string, - @optional - colorProfile: string, - @optional - colorRendering: string, - @optional - contentScriptType: string, - @optional - contentStyleType: string, - @optional - cursor: string, - @optional - cx: string, - @optional - cy: string, - @optional - d: string, - @optional - decelerate: string, - @optional - descent: string, - @optional - diffuseConstant: string, - @optional - direction: string, - @optional - display: string, - @optional - divisor: string, - @optional - dominantBaseline: string, - @optional - dur: string, - @optional - dx: string, - @optional - dy: string, - @optional - edgeMode: string, - @optional - elevation: string, - @optional - enableBackground: string, - @optional @as("end") - end_: string /* use this one. Previous one is deprecated */, - @optional - exponent: string, - @optional - externalResourcesRequired: string, - @optional - fill: string, - @optional - fillOpacity: string, - @optional - fillRule: string, - @optional - filter: string, - @optional - filterRes: string, - @optional - filterUnits: string, - @optional - floodColor: string, - @optional - floodOpacity: string, - @optional - focusable: string, - @optional - fontFamily: string, - @optional - fontSize: string, - @optional - fontSizeAdjust: string, - @optional - fontStretch: string, - @optional - fontStyle: string, - @optional - fontVariant: string, - @optional - fontWeight: string, - @optional - fomat: string, - @optional - from: string, - @optional - fx: string, - @optional - fy: string, - @optional - g1: string, - @optional - g2: string, - @optional - glyphName: string, - @optional - glyphOrientationHorizontal: string, - @optional - glyphOrientationVertical: string, - @optional - glyphRef: string, - @optional - gradientTransform: string, - @optional - gradientUnits: string, - @optional - hanging: string, - @optional - horizAdvX: string, - @optional - horizOriginX: string, - @optional - ideographic: string, - @optional - imageRendering: string, - @optional @as("in") - in_: string /* use this one. Previous one is deprecated */, - @optional - in2: string, - @optional - intercept: string, - @optional - k: string, - @optional - k1: string, - @optional - k2: string, - @optional - k3: string, - @optional - k4: string, - @optional - kernelMatrix: string, - @optional - kernelUnitLength: string, - @optional - kerning: string, - @optional - keyPoints: string, - @optional - keySplines: string, - @optional - keyTimes: string, - @optional - lengthAdjust: string, - @optional - letterSpacing: string, - @optional - lightingColor: string, - @optional - limitingConeAngle: string, - @optional - local: string, - @optional - markerEnd: string, - @optional - markerHeight: string, - @optional - markerMid: string, - @optional - markerStart: string, - @optional - markerUnits: string, - @optional - markerWidth: string, - @optional - mask: string, - @optional - maskContentUnits: string, - @optional - maskUnits: string, - @optional - mathematical: string, - @optional - mode: string, - @optional - numOctaves: string, - @optional - offset: string, - @optional - opacity: string, - @optional - operator: string, - @optional - order: string, - @optional - orient: string, - @optional - orientation: string, - @optional - origin: string, - @optional - overflow: string, - @optional - overflowX: string, - @optional - overflowY: string, - @optional - overlinePosition: string, - @optional - overlineThickness: string, - @optional - paintOrder: string, - @optional - panose1: string, - @optional - pathLength: string, - @optional - patternContentUnits: string, - @optional - patternTransform: string, - @optional - patternUnits: string, - @optional - pointerEvents: string, - @optional - points: string, - @optional - pointsAtX: string, - @optional - pointsAtY: string, - @optional - pointsAtZ: string, - @optional - preserveAlpha: string, - @optional - preserveAspectRatio: string, - @optional - primitiveUnits: string, - @optional - r: string, - @optional - radius: string, - @optional - refX: string, - @optional - refY: string, - @optional - renderingIntent: string, - @optional - repeatCount: string, - @optional - repeatDur: string, - @optional - requiredExtensions: string, - @optional - requiredFeatures: string, - @optional - restart: string, - @optional - result: string, - @optional - rotate: string, - @optional - rx: string, - @optional - ry: string, - @optional - scale: string, - @optional - seed: string, - @optional - shapeRendering: string, - @optional - slope: string, - @optional - spacing: string, - @optional - specularConstant: string, - @optional - specularExponent: string, - @optional - speed: string, - @optional - spreadMethod: string, - @optional - startOffset: string, - @optional - stdDeviation: string, - @optional - stemh: string, - @optional - stemv: string, - @optional - stitchTiles: string, - @optional - stopColor: string, - @optional - stopOpacity: string, - @optional - strikethroughPosition: string, - @optional - strikethroughThickness: string, - @optional - string: string, - @optional - stroke: string, - @optional - strokeDasharray: string, - @optional - strokeDashoffset: string, - @optional - strokeLinecap: string, - @optional - strokeLinejoin: string, - @optional - strokeMiterlimit: string, - @optional - strokeOpacity: string, - @optional - strokeWidth: string, - @optional - surfaceScale: string, - @optional - systemLanguage: string, - @optional - tableValues: string, - @optional - targetX: string, - @optional - targetY: string, - @optional - textAnchor: string, - @optional - textDecoration: string, - @optional - textLength: string, - @optional - textRendering: string, - @optional @as("to") - to_: string /* use this one. Previous one is deprecated */, - @optional - transform: string, - @optional - u1: string, - @optional - u2: string, - @optional - underlinePosition: string, - @optional - underlineThickness: string, - @optional - unicode: string, - @optional - unicodeBidi: string, - @optional - unicodeRange: string, - @optional - unitsPerEm: string, - @optional - vAlphabetic: string, - @optional - vHanging: string, - @optional - vIdeographic: string, - @optional - vMathematical: string, - @optional - values: string, - @optional - vectorEffect: string, - @optional - version: string, - @optional - vertAdvX: string, - @optional - vertAdvY: string, - @optional - vertOriginX: string, - @optional - vertOriginY: string, - @optional - viewBox: string, - @optional - viewTarget: string, - @optional - visibility: string, - /* width::string? => */ - @optional - widths: string, - @optional - wordSpacing: string, - @optional - writingMode: string, - @optional - x: string, - @optional - x1: string, - @optional - x2: string, - @optional - xChannelSelector: string, - @optional - xHeight: string, - @optional - xlinkActuate: string, - @optional - xlinkArcrole: string, - @optional - xlinkHref: string, - @optional - xlinkRole: string, - @optional - xlinkShow: string, - @optional - xlinkTitle: string, - @optional - xlinkType: string, - @optional - xmlns: string, - @optional - xmlnsXlink: string, - @optional - xmlBase: string, - @optional - xmlLang: string, - @optional - xmlSpace: string, - @optional - y: string, - @optional - y1: string, - @optional - y2: string, - @optional - yChannelSelector: string, - @optional - z: string, - @optional - zoomAndPan: string, - /* RDFa */ - @optional - about: string, - @optional - datatype: string, - @optional - inlist: string, - @optional - prefix: string, - @optional - property: string, - @optional - resource: string, - @optional - typeof: string, - @optional - vocab: string, - /* react-specific */ - @optional - dangerouslySetInnerHTML: {"__html": string}, - @optional - suppressContentEditableWarning: bool, - } -} - -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.bs.js b/src/v3/ReactEvent_V3.bs.js deleted file mode 100644 index 179cde2..0000000 --- a/src/v3/ReactEvent_V3.bs.js +++ /dev/null @@ -1,53 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -var Synthetic = {}; - -var Clipboard = {}; - -var Composition = {}; - -var Keyboard = {}; - -var Focus = {}; - -var Form = {}; - -var Mouse = {}; - -var Pointer = {}; - -var $$Selection = {}; - -var $$Touch = {}; - -var UI = {}; - -var Wheel = {}; - -var Media = {}; - -var $$Image = {}; - -var $$Animation = {}; - -var Transition = {}; - -exports.Synthetic = Synthetic; -exports.Clipboard = Clipboard; -exports.Composition = Composition; -exports.Keyboard = Keyboard; -exports.Focus = Focus; -exports.Form = Form; -exports.Mouse = Mouse; -exports.Pointer = Pointer; -exports.$$Selection = $$Selection; -exports.$$Touch = $$Touch; -exports.UI = UI; -exports.Wheel = Wheel; -exports.Media = Media; -exports.$$Image = $$Image; -exports.$$Animation = $$Animation; -exports.Transition = Transition; -/* No side effect */ diff --git a/src/v3/ReactEvent_V3.res b/src/v3/ReactEvent_V3.res deleted file mode 100644 index b142d0b..0000000 --- a/src/v3/ReactEvent_V3.res +++ /dev/null @@ -1,322 +0,0 @@ -type synthetic<'a> = ReactEvent.synthetic<'a> - -module MakeEventWithType = ( - Type: { - type t - }, -) => { - @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 @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 @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 @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 @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 @deprecated("Jsx 3 is deprecated, use jsx 4 instead") - external defaultPrevented: synthetic<'a> => bool = "defaultPrevented" - @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 @deprecated("Jsx 3 is deprecated, use jsx 4 instead") - external preventDefault: synthetic<'a> => unit = "preventDefault" - @send @deprecated("Jsx 3 is deprecated, use jsx 4 instead") - external isDefaultPrevented: synthetic<'a> => bool = "isDefaultPrevented" - @send @deprecated("Jsx 3 is deprecated, use jsx 4 instead") - external stopPropagation: synthetic<'a> => unit = "stopPropagation" - @send @deprecated("Jsx 3 is deprecated, use jsx 4 instead") - external isPropagationStopped: synthetic<'a> => bool = "isPropagationStopped" - @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 = { - type tag = ReactEvent.Clipboard.tag - type t = synthetic - include MakeEventWithType({ - type t = t - }) - - @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") - external clipboardData: t => {..} = "clipboardData" /* Should return Dom.dataTransfer */ -} - -module Composition = { - type tag = ReactEvent.Composition.tag - type t = synthetic - include MakeEventWithType({ - type t = t - }) - @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") external data: t => string = "data" -} - -module Keyboard = { - type tag = ReactEvent.Keyboard.tag - type t = synthetic - include MakeEventWithType({ - type t = t - }) - @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 @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 = { - type tag = ReactEvent.Focus.tag - type t = synthetic - include MakeEventWithType({ - type t = t - }) - @get @return(nullable) @deprecated("Jsx 3 is deprecated, use jsx 4 instead") - external relatedTarget: t => option<{..}> = "relatedTarget" /* Should return Dom.eventTarget */ -} - -module Form = { - type tag = ReactEvent.Form.tag - type t = synthetic - include MakeEventWithType({ - type t = t - }) -} - -module Mouse = { - type tag = ReactEvent.Mouse.tag - type t = synthetic - include MakeEventWithType({ - type t = t - }) - @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 @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 @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 = { - type tag = ReactEvent.Pointer.tag - type t = synthetic - include MakeEventWithType({ - type t = t - }) - - // UIEvent - @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 @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 @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 @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") @return(nullable) - external relatedTarget: t => option<{..}> = "relatedTarget" /* Should return Dom.eventTarget */ - - // PointerEvent - @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 = { - type tag = ReactEvent.Selection.tag - type t = synthetic - include MakeEventWithType({ - type t = t - }) -} - -module Touch = { - type tag = ReactEvent.Touch.tag - type t = synthetic - include MakeEventWithType({ - type t = t - }) - @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 @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 = { - type tag = ReactEvent.UI.tag - type t = synthetic - include MakeEventWithType({ - type t = t - }) - @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 = { - type tag = ReactEvent.Wheel.tag - type t = synthetic - include MakeEventWithType({ - type t = t - }) - @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 = { - type tag = ReactEvent.Media.tag - type t = synthetic - include MakeEventWithType({ - type t = t - }) -} - -module Image = { - type tag = ReactEvent.Image.tag - type t = synthetic - include MakeEventWithType({ - type t = t - }) -} - -module Animation = { - type tag = ReactEvent.Animation.tag - type t = synthetic - include MakeEventWithType({ - type t = t - }) - @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 = { - type tag = ReactEvent.Transition.tag - type t = synthetic - include MakeEventWithType({ - type t = t - }) - @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/ReactEvent_V3.resi b/src/v3/ReactEvent_V3.resi deleted file mode 100644 index e4ac845..0000000 --- a/src/v3/ReactEvent_V3.resi +++ /dev/null @@ -1,471 +0,0 @@ -/* This is the whole synthetic event system of ReactJS/ReasonReact. The first module `Synthetic` represents - the generic synthetic event. The rest are the specific ones. - - In each module, the type `t` commonly means "the type of that module" (OCaml convention). In our case, e.g. - `ReactEvent.Mouse.t` represents a ReactJS synthetic mouse event. You'd use it to type your props: - - ``` - type props = { - onClick: ReactEvent.Mouse.t => unit - }; - ``` - - All the methods and properties of a type of event are in the module, as seen below. - - Each module also has a `tag` type. You can ignore it; they're only needed by their `t` type. This way, we - get to allow a base `Synthetic` event module with generic methods. So e.g. even a mouse event (`Mouse.t`) - get to be passed to a generic handler: - - ``` - let handleClick = ({state, props}, event) => { - ReactEvent.Mouse.preventDefault(event); - ... - }; - let handleSubmit = ({state, props}, event) => { - // this handler can be triggered by either a Keyboard or a Mouse event; - // conveniently use the generic preventDefault - ReactEvent.Synthetic.preventDefault(event); - ... - }; - - let render = (_) => ; - ``` - - How to translate idioms from ReactJS: - - 1. myMouseEvent.preventDefault() -> ReactEvent.Mouse.preventDefault(myMouseEvent) - 2. myKeyboardEvent.which -> ReactEvent.Keyboard.which(myKeyboardEvent) - */ -type synthetic<'a> = ReactEvent.synthetic<'a> - -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 - external currentTarget: synthetic<'a> => {..} = "currentTarget" - @get - external defaultPrevented: synthetic<'a> => bool = "defaultPrevented" - @get external eventPhase: synthetic<'a> => int = "eventPhase" - @get external isTrusted: synthetic<'a> => bool = "isTrusted" - @get - external nativeEvent: synthetic<'a> => {..} = "nativeEvent" - @send - external preventDefault: synthetic<'a> => unit = "preventDefault" - @send - external isDefaultPrevented: synthetic<'a> => bool = "isDefaultPrevented" - @send - external stopPropagation: synthetic<'a> => unit = "stopPropagation" - @send - external isPropagationStopped: synthetic<'a> => bool = "isPropagationStopped" - @get external target: synthetic<'a> => {..} = "target" - @get external timeStamp: synthetic<'a> => float = "timeStamp" - @get external type_: synthetic<'a> => string = "type" - @send external persist: synthetic<'a> => unit = "persist" -} - -/* Cast any event type to the general synthetic type. This is safe, since synthetic is more general */ -external toSyntheticEvent: synthetic<'a> => Synthetic.t = "%identity" - -module Clipboard: { - type tag = ReactEvent.Clipboard.tag - type t = synthetic - @get external bubbles: t => bool = "bubbles" - @get external cancelable: t => bool = "cancelable" - @get external currentTarget: t => {..} = "currentTarget" - @get external defaultPrevented: t => bool = "defaultPrevented" - @get external eventPhase: t => int = "eventPhase" - @get external isTrusted: t => bool = "isTrusted" - @get external nativeEvent: t => {..} = "nativeEvent" - @send external preventDefault: t => unit = "preventDefault" - @send external isDefaultPrevented: t => bool = "isDefaultPrevented" - @send external stopPropagation: t => unit = "stopPropagation" - @send external isPropagationStopped: t => bool = "isPropagationStopped" - @get external target: t => {..} = "target" - @get external timeStamp: t => float = "timeStamp" - @get external type_: t => string = "type" - @send external persist: t => unit = "persist" - @get external clipboardData: t => {..} = "clipboardData" /* Should return Dom.dataTransfer */ -} - -module Composition: { - type tag = ReactEvent.Composition.tag - type t = synthetic - @get external bubbles: t => bool = "bubbles" - @get external cancelable: t => bool = "cancelable" - @get external currentTarget: t => {..} = "currentTarget" - @get external defaultPrevented: t => bool = "defaultPrevented" - @get external eventPhase: t => int = "eventPhase" - @get external isTrusted: t => bool = "isTrusted" - @get external nativeEvent: t => {..} = "nativeEvent" - @send external preventDefault: t => unit = "preventDefault" - @send external isDefaultPrevented: t => bool = "isDefaultPrevented" - @send external stopPropagation: t => unit = "stopPropagation" - @send external isPropagationStopped: t => bool = "isPropagationStopped" - @get external target: t => {..} = "target" - @get external timeStamp: t => float = "timeStamp" - @get external type_: t => string = "type" - @send external persist: t => unit = "persist" - @get external data: t => string = "data" -} - -module Keyboard: { - type tag = ReactEvent.Keyboard.tag - type t = synthetic - @get external bubbles: t => bool = "bubbles" - @get external cancelable: t => bool = "cancelable" - @get external currentTarget: t => {..} = "currentTarget" - @get external defaultPrevented: t => bool = "defaultPrevented" - @get external eventPhase: t => int = "eventPhase" - @get external isTrusted: t => bool = "isTrusted" - @get external nativeEvent: t => {..} = "nativeEvent" - @send external preventDefault: t => unit = "preventDefault" - @send external isDefaultPrevented: t => bool = "isDefaultPrevented" - @send external stopPropagation: t => unit = "stopPropagation" - @send external isPropagationStopped: t => bool = "isPropagationStopped" - @get external target: t => {..} = "target" - @get external timeStamp: t => float = "timeStamp" - @get external type_: t => string = "type" - @send external persist: t => unit = "persist" - @get external altKey: t => bool = "altKey" - @get external charCode: t => int = "charCode" - @get external ctrlKey: t => bool = "ctrlKey" - @send - 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" -} - -module Focus: { - type tag = ReactEvent.Focus.tag - type t = synthetic - @get external bubbles: t => bool = "bubbles" - @get external cancelable: t => bool = "cancelable" - @get external currentTarget: t => {..} = "currentTarget" - @get external defaultPrevented: t => bool = "defaultPrevented" - @get external eventPhase: t => int = "eventPhase" - @get external isTrusted: t => bool = "isTrusted" - @get external nativeEvent: t => {..} = "nativeEvent" - @send external preventDefault: t => unit = "preventDefault" - @send external isDefaultPrevented: t => bool = "isDefaultPrevented" - @send external stopPropagation: t => unit = "stopPropagation" - @send external isPropagationStopped: t => bool = "isPropagationStopped" - @get external target: t => {..} = "target" - @get external timeStamp: t => float = "timeStamp" - @get external type_: t => string = "type" - @send external persist: t => unit = "persist" - @get @return(nullable) - external relatedTarget: t => option<{..}> = "relatedTarget" /* Should return Dom.eventTarget */ -} - -module Form: { - type tag = ReactEvent.Form.tag - type t = synthetic - @get external bubbles: t => bool = "bubbles" - @get external cancelable: t => bool = "cancelable" - @get external currentTarget: t => {..} = "currentTarget" - @get external defaultPrevented: t => bool = "defaultPrevented" - @get external eventPhase: t => int = "eventPhase" - @get external isTrusted: t => bool = "isTrusted" - @get external nativeEvent: t => {..} = "nativeEvent" - @send external preventDefault: t => unit = "preventDefault" - @send external isDefaultPrevented: t => bool = "isDefaultPrevented" - @send external stopPropagation: t => unit = "stopPropagation" - @send external isPropagationStopped: t => bool = "isPropagationStopped" - @get external target: t => {..} = "target" - @get external timeStamp: t => float = "timeStamp" - @get external type_: t => string = "type" - @send external persist: t => unit = "persist" -} - -module Mouse: { - type tag = ReactEvent.Mouse.tag - type t = synthetic - @get external bubbles: t => bool = "bubbles" - @get external cancelable: t => bool = "cancelable" - @get external currentTarget: t => {..} = "currentTarget" - @get external defaultPrevented: t => bool = "defaultPrevented" - @get external eventPhase: t => int = "eventPhase" - @get external isTrusted: t => bool = "isTrusted" - @get external nativeEvent: t => {..} = "nativeEvent" - @send external preventDefault: t => unit = "preventDefault" - @send external isDefaultPrevented: t => bool = "isDefaultPrevented" - @send external stopPropagation: t => unit = "stopPropagation" - @send external isPropagationStopped: t => bool = "isPropagationStopped" - @get external target: t => {..} = "target" - @get external timeStamp: t => float = "timeStamp" - @get external type_: t => string = "type" - @send external persist: t => unit = "persist" - @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 - 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) - 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" -} - -module Pointer: { - type tag = ReactEvent.Pointer.tag - type t = synthetic - - // Event - @get external type_: t => string = "type" - @get external target: t => {..} = "target" - @get external currentTarget: t => {..} = "currentTarget" - - @get external eventPhase: t => int = "eventPhase" - - @send external stopPropagation: t => unit = "stopPropagation" // aka cancelBubble - @get external bubbles: t => bool = "bubbles" - @get external cancelable: t => bool = "cancelable" - @send external preventDefault: t => unit = "preventDefault" - @get external defaultPrevented: t => bool = "defaultPrevented" - - @get external isTrusted: t => bool = "isTrusted" - @get external timeStamp: t => float = "timeStamp" - - // SyntheticEvent - @get external nativeEvent: t => {..} = "nativeEvent" - @send external isDefaultPrevented: t => bool = "isDefaultPrevented" - @send external isPropagationStopped: t => bool = "isPropagationStopped" - @send external persist: t => unit = "persist" - - // UIEvent - @get external detail: t => int = "detail" - @get 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 external ctrlKey: t => bool = "ctrlKey" - @get external shiftKey: t => bool = "shiftKey" - @get external altKey: t => bool = "altKey" - @get external metaKey: t => bool = "metaKey" - @send - external getModifierState: (t, string) => bool = "getModifierState" - - @get external button: t => int = "button" - @get external buttons: t => int = "buttons" - - @get @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" -} - -module Selection: { - type tag = ReactEvent.Selection.tag - type t = synthetic - @get external bubbles: t => bool = "bubbles" - @get external cancelable: t => bool = "cancelable" - @get external currentTarget: t => {..} = "currentTarget" - @get external defaultPrevented: t => bool = "defaultPrevented" - @get external eventPhase: t => int = "eventPhase" - @get external isTrusted: t => bool = "isTrusted" - @get external nativeEvent: t => {..} = "nativeEvent" - @send external preventDefault: t => unit = "preventDefault" - @send external isDefaultPrevented: t => bool = "isDefaultPrevented" - @send external stopPropagation: t => unit = "stopPropagation" - @send external isPropagationStopped: t => bool = "isPropagationStopped" - @get external target: t => {..} = "target" - @get external timeStamp: t => float = "timeStamp" - @get external type_: t => string = "type" - @send external persist: t => unit = "persist" -} - -module Touch: { - type tag = ReactEvent.Touch.tag - type t = synthetic - @get external bubbles: t => bool = "bubbles" - @get external cancelable: t => bool = "cancelable" - @get external currentTarget: t => {..} = "currentTarget" - @get external defaultPrevented: t => bool = "defaultPrevented" - @get external eventPhase: t => int = "eventPhase" - @get external isTrusted: t => bool = "isTrusted" - @get external nativeEvent: t => {..} = "nativeEvent" - @send external preventDefault: t => unit = "preventDefault" - @send external isDefaultPrevented: t => bool = "isDefaultPrevented" - @send external stopPropagation: t => unit = "stopPropagation" - @send external isPropagationStopped: t => bool = "isPropagationStopped" - @get external target: t => {..} = "target" - @get external timeStamp: t => float = "timeStamp" - @get external type_: t => string = "type" - @send external persist: t => unit = "persist" - @get external altKey: t => bool = "altKey" - @get external changedTouches: t => {..} = "changedTouches" /* Should return Dom.touchList */ - @get external ctrlKey: t => bool = "ctrlKey" - @send - 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 */ -} - -module UI: { - type tag = ReactEvent.UI.tag - type t = synthetic - @get external bubbles: t => bool = "bubbles" - @get external cancelable: t => bool = "cancelable" - @get external currentTarget: t => {..} = "currentTarget" - @get external defaultPrevented: t => bool = "defaultPrevented" - @get external eventPhase: t => int = "eventPhase" - @get external isTrusted: t => bool = "isTrusted" - @get external nativeEvent: t => {..} = "nativeEvent" - @send external preventDefault: t => unit = "preventDefault" - @send external isDefaultPrevented: t => bool = "isDefaultPrevented" - @send external stopPropagation: t => unit = "stopPropagation" - @send external isPropagationStopped: t => bool = "isPropagationStopped" - @get external target: t => {..} = "target" - @get external timeStamp: t => float = "timeStamp" - @get external type_: t => string = "type" - @send external persist: t => unit = "persist" - @get external detail: t => int = "detail" - @get external view: t => Dom.window = "view" /* Should return DOMAbstractView/WindowProxy */ -} - -module Wheel: { - type tag = ReactEvent.Wheel.tag - type t = synthetic - @get external bubbles: t => bool = "bubbles" - @get external cancelable: t => bool = "cancelable" - @get external currentTarget: t => {..} = "currentTarget" - @get external defaultPrevented: t => bool = "defaultPrevented" - @get external eventPhase: t => int = "eventPhase" - @get external isTrusted: t => bool = "isTrusted" - @get external nativeEvent: t => {..} = "nativeEvent" - @send external preventDefault: t => unit = "preventDefault" - @send external isDefaultPrevented: t => bool = "isDefaultPrevented" - @send external stopPropagation: t => unit = "stopPropagation" - @send external isPropagationStopped: t => bool = "isPropagationStopped" - @get external target: t => {..} = "target" - @get external timeStamp: t => float = "timeStamp" - @get external type_: t => string = "type" - @send external persist: t => unit = "persist" - @get external deltaMode: t => int = "deltaMode" - @get external deltaX: t => float = "deltaX" - @get external deltaY: t => float = "deltaY" - @get external deltaZ: t => float = "deltaZ" -} - -module Media: { - type tag = ReactEvent.Media.tag - type t = synthetic - @get external bubbles: t => bool = "bubbles" - @get external cancelable: t => bool = "cancelable" - @get external currentTarget: t => {..} = "currentTarget" - @get external defaultPrevented: t => bool = "defaultPrevented" - @get external eventPhase: t => int = "eventPhase" - @get external isTrusted: t => bool = "isTrusted" - @get external nativeEvent: t => {..} = "nativeEvent" - @send external preventDefault: t => unit = "preventDefault" - @send external isDefaultPrevented: t => bool = "isDefaultPrevented" - @send external stopPropagation: t => unit = "stopPropagation" - @send external isPropagationStopped: t => bool = "isPropagationStopped" - @get external target: t => {..} = "target" - @get external timeStamp: t => float = "timeStamp" - @get external type_: t => string = "type" - @send external persist: t => unit = "persist" -} - -module Image: { - type tag = ReactEvent.Image.tag - type t = synthetic - @get external bubbles: t => bool = "bubbles" - @get external cancelable: t => bool = "cancelable" - @get external currentTarget: t => {..} = "currentTarget" - @get external defaultPrevented: t => bool = "defaultPrevented" - @get external eventPhase: t => int = "eventPhase" - @get external isTrusted: t => bool = "isTrusted" - @get external nativeEvent: t => {..} = "nativeEvent" - @send external preventDefault: t => unit = "preventDefault" - @send external isDefaultPrevented: t => bool = "isDefaultPrevented" - @send external stopPropagation: t => unit = "stopPropagation" - @send external isPropagationStopped: t => bool = "isPropagationStopped" - @get external target: t => {..} = "target" - @get external timeStamp: t => float = "timeStamp" - @get external type_: t => string = "type" - @send external persist: t => unit = "persist" -} - -module Animation: { - type tag = ReactEvent.Animation.tag - type t = synthetic - @get external bubbles: t => bool = "bubbles" - @get external cancelable: t => bool = "cancelable" - @get external currentTarget: t => {..} = "currentTarget" - @get external defaultPrevented: t => bool = "defaultPrevented" - @get external eventPhase: t => int = "eventPhase" - @get external isTrusted: t => bool = "isTrusted" - @get external nativeEvent: t => {..} = "nativeEvent" - @send external preventDefault: t => unit = "preventDefault" - @send external isDefaultPrevented: t => bool = "isDefaultPrevented" - @send external stopPropagation: t => unit = "stopPropagation" - @send external isPropagationStopped: t => bool = "isPropagationStopped" - @get external target: t => {..} = "target" - @get external timeStamp: t => float = "timeStamp" - @get external type_: t => string = "type" - @send external persist: t => unit = "persist" - @get external animationName: t => string = "animationName" - @get external pseudoElement: t => string = "pseudoElement" - @get external elapsedTime: t => float = "elapsedTime" -} - -module Transition: { - type tag = ReactEvent.Transition.tag - type t = synthetic - @get external bubbles: t => bool = "bubbles" - @get external cancelable: t => bool = "cancelable" - @get external currentTarget: t => {..} = "currentTarget" - @get external defaultPrevented: t => bool = "defaultPrevented" - @get external eventPhase: t => int = "eventPhase" - @get external isTrusted: t => bool = "isTrusted" - @get external nativeEvent: t => {..} = "nativeEvent" - @send external preventDefault: t => unit = "preventDefault" - @send external isDefaultPrevented: t => bool = "isDefaultPrevented" - @send external stopPropagation: t => unit = "stopPropagation" - @send external isPropagationStopped: t => bool = "isPropagationStopped" - @get external target: t => {..} = "target" - @get external timeStamp: t => float = "timeStamp" - @get external type_: t => string = "type" - @send external persist: t => unit = "persist" - @get external propertyName: t => string = "propertyName" - @get external pseudoElement: t => string = "pseudoElement" - @get external elapsedTime: t => float = "elapsedTime" -} diff --git a/src/v3/ReactV3.bs.js b/src/v3/ReactV3.bs.js deleted file mode 100644 index e083669..0000000 --- a/src/v3/ReactV3.bs.js +++ /dev/null @@ -1,21 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -var React_V3 = require("./React_V3.bs.js"); -var ReactDOM_V3 = require("./ReactDOM_V3.bs.js"); -var ReactEvent_V3 = require("./ReactEvent_V3.bs.js"); -var ReactDOMStyle_V3 = require("./ReactDOMStyle_V3.bs.js"); - -var React = React_V3; - -var ReactDOM = ReactDOM_V3; - -var ReactDOMStyle = ReactDOMStyle_V3; - -var ReactEvent = ReactEvent_V3; - -exports.React = React; -exports.ReactDOM = ReactDOM; -exports.ReactDOMStyle = ReactDOMStyle; -exports.ReactEvent = ReactEvent; -/* No side effect */ diff --git a/src/v3/ReactV3.res b/src/v3/ReactV3.res deleted file mode 100644 index 9c7dff5..0000000 --- a/src/v3/ReactV3.res +++ /dev/null @@ -1,35 +0,0 @@ -/*** -ReactV3 module is for the backward compatibility. - -`open ReactV3` enables using the rescript-react for V3. - -```rescript -module C = { - @@jsxConfig({version: 3}) - open ReactV3 - - @react.component - let make = ... -} -``` -or in project level, -- open ReactV3 globally -- install the compiler>=10.1 -- install the rescript-react>=0.11.0 -*/ - -module React = { - include React_V3 -} - -module ReactDOM = { - include ReactDOM_V3 -} - -module ReactDOMStyle = { - include ReactDOMStyle_V3 -} - -module ReactEvent = { - include ReactEvent_V3 -} diff --git a/src/v3/React_V3.bs.js b/src/v3/React_V3.bs.js deleted file mode 100644 index a858df8..0000000 --- a/src/v3/React_V3.bs.js +++ /dev/null @@ -1,26 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -var Ref = {}; - -var Children = {}; - -var Context = {}; - -var Fragment = {}; - -var StrictMode = {}; - -var Suspense = {}; - -var Uncurried = {}; - -exports.Ref = Ref; -exports.Children = Children; -exports.Context = Context; -exports.Fragment = Fragment; -exports.StrictMode = StrictMode; -exports.Suspense = Suspense; -exports.Uncurried = Uncurried; -/* No side effect */ diff --git a/src/v3/React_V3.res b/src/v3/React_V3.res deleted file mode 100644 index 4b4de7a..0000000 --- a/src/v3/React_V3.res +++ /dev/null @@ -1,409 +0,0 @@ -/** Binding to React.element enables the compatibility with v3 */ -type element = React.element - -@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> - -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") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") -external createElement: (component<'props>, 'props) => element = "createElement" - -@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") -external cloneElement: (element, 'props) => element = "cloneElement" - -@variadic @module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") -external createElementVariadic: (component<'props>, 'props, array) => element = - "createElement" - -@module("react") @deprecated("Please use JSX syntax directly.") -external jsxKeyed: (component<'props>, 'props, string) => element = "jsx" - -@module("react") @deprecated("Please use JSX syntax directly.") -external jsx: (component<'props>, 'props) => element = "jsx" - -@module("react") @deprecated("Please use JSX syntax directly.") -external jsxs: (component<'props>, 'props) => element = "jsxs" - -@module("react") @deprecated("Please use JSX syntax directly.") -external jsxsKeyed: (component<'props>, 'props, string) => element = "jsxs" - -type ref<'value> = React.ref<'value> = {mutable current: 'value} - -module Ref = { - @deprecated("Please use the type React.ref instead") - type t<'value> = ref<'value> - - @deprecated("Please directly read from ref.current instead") @get - external current: ref<'value> => 'value = "current" - - @deprecated("Please directly assign to ref.current instead") @set - external setCurrent: (ref<'value>, 'value) => unit = "current" -} - -@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") -external createRef: unit => ref> = "createRef" - -module 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") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") - external mapWithIndex: (element, @uncurry (element, int) => element) => element = "map" - @module("react") @scope("Children") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") - external forEach: (element, element => unit) => unit = "forEach" - @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") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") - external count: element => int = "count" - @module("react") @scope("Children") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") - external only: element => element = "only" - @module("react") @scope("Children") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") - external toArray: element => array = "toArray" -} - -module Context = { - type t<'props> = React.Context.t<'props> - - @obj - external makeProps: ( - ~value: 'props, - ~children: element, - unit, - ) => {"value": 'props, "children": element} = "" - - @get @deprecated("Jsx 3 is deprecated, use jsx 4 instead") - external provider: t<'props> => component<{"value": 'props, "children": element}> = "Provider" -} - -@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") -external createContext: 'a => Context.t<'a> = "createContext" - -@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") -external forwardRef: (@uncurry ('props, Js.Nullable.t>) => element) => component<'props> = - "forwardRef" - -@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") -external memo: component<'props> => component<'props> = "memo" - -@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 @deprecated("Jsx 3 is deprecated, use jsx 4 instead") - external makeProps: (~children: element, ~key: 'key=?, unit) => {"children": element} = "" - @module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") - external make: component<{ - "children": element, - }> = "Fragment" -} - -module StrictMode = { - @obj @deprecated("Jsx 3 is deprecated, use jsx 4 instead") - external makeProps: (~children: element, ~key: 'key=?, unit) => {"children": element} = "" - @module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") - external make: component<{ - "children": element, - }> = "StrictMode" -} - -module Suspense = { - @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") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") - external make: component<{ - "children": option, - "fallback": option, - }> = "Suspense" -} - -/* HOOKS */ - -/* - * Yeah, we know this api isn't great. tl;dr: useReducer instead. - * It's because useState can take functions or non-function values and treats - * 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") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") -external useState: (@uncurry (unit => 'state)) => ('state, ('state => 'state) => unit) = "useState" - -@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") -external useReducer: (@uncurry ('state, 'action) => 'state, 'state) => ('state, 'action => unit) = - "useReducer" - -@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") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") -external useEffectOnEveryRender: (@uncurry (unit => option unit>)) => unit = "useEffect" -@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") -external useEffect: (@uncurry (unit => option unit>), 'deps) => unit = "useEffect" -@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") -external useEffect0: (@uncurry (unit => option unit>), @as(json`[]`) _) => unit = - "useEffect" -@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") -external useEffect1: (@uncurry (unit => option unit>), array<'a>) => unit = "useEffect" -@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") -external useEffect2: (@uncurry (unit => option unit>), ('a, 'b)) => unit = "useEffect" -@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") -external useEffect3: (@uncurry (unit => option unit>), ('a, 'b, 'c)) => unit = "useEffect" -@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") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") -external useEffect5: (@uncurry (unit => option unit>), ('a, 'b, 'c, 'd, 'e)) => unit = - "useEffect" -@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") @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") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") -external useLayoutEffectOnEveryRender: (@uncurry (unit => option unit>)) => unit = - "useLayoutEffect" -@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") -external useLayoutEffect: (@uncurry (unit => option unit>), 'deps) => unit = - "useLayoutEffect" -@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") -external useLayoutEffect0: (@uncurry (unit => option unit>), @as(json`[]`) _) => unit = - "useLayoutEffect" -@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") -external useLayoutEffect1: (@uncurry (unit => option unit>), array<'a>) => unit = - "useLayoutEffect" -@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") -external useLayoutEffect2: (@uncurry (unit => option unit>), ('a, 'b)) => unit = - "useLayoutEffect" -@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") -external useLayoutEffect3: (@uncurry (unit => option unit>), ('a, 'b, 'c)) => unit = - "useLayoutEffect" -@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") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") -external useLayoutEffect5: (@uncurry (unit => option unit>), ('a, 'b, 'c, 'd, 'e)) => unit = - "useLayoutEffect" -@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") @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") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") -external useMemo: (@uncurry (unit => 'any), 'deps) => 'any = "useMemo" - -@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") -external useMemo0: (@uncurry (unit => 'any), @as(json`[]`) _) => 'any = "useMemo" - -@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") -external useMemo1: (@uncurry (unit => 'any), array<'a>) => 'any = "useMemo" - -@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") -external useMemo2: (@uncurry (unit => 'any), ('a, 'b)) => 'any = "useMemo" - -@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") -external useMemo3: (@uncurry (unit => 'any), ('a, 'b, 'c)) => 'any = "useMemo" - -@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") -external useMemo4: (@uncurry (unit => 'any), ('a, 'b, 'c, 'd)) => 'any = "useMemo" - -@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") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") -external useMemo6: (@uncurry (unit => 'any), ('a, 'b, 'c, 'd, 'e, 'f)) => 'any = "useMemo" - -@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") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") -external useCallback: ('f, 'deps) => 'f = "useCallback" - -@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") -external useCallback0: ('f, @as(json`[]`) _) => 'f = "useCallback" - -@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") -external useCallback1: ('f, array<'a>) => 'f = "useCallback" - -@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") -external useCallback2: ('f, ('a, 'b)) => 'f = "useCallback" - -@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") -external useCallback3: ('f, ('a, 'b, 'c)) => 'f = "useCallback" - -@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") -external useCallback4: ('f, ('a, 'b, 'c, 'd)) => 'f = "useCallback" - -@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") -external useCallback5: ('f, ('a, 'b, 'c, 'd, 'e)) => 'f = "useCallback" - -@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") -external useCallback6: ('callback, ('a, 'b, 'c, 'd, 'e, 'f)) => 'callback = "useCallback" - -@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") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") -external useContext: Context.t<'any> => 'any = "useContext" - -@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") -external useRef: 'value => ref<'value> = "useRef" - -@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") -external useImperativeHandleOnEveryRender: ( - Js.Nullable.t>, - @uncurry (unit => 'value), -) => unit = "useImperativeHandle" - -@module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") -external useImperativeHandle: ( - Js.Nullable.t>, - @uncurry (unit => 'value), - 'deps, -) => unit = "useImperativeHandle" - -@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") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") -external useImperativeHandle1: ( - Js.Nullable.t>, - @uncurry (unit => 'value), - array<'a>, -) => unit = "useImperativeHandle" - -@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") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") -external useImperativeHandle3: ( - Js.Nullable.t>, - @uncurry (unit => 'value), - ('a, 'b, 'c), -) => unit = "useImperativeHandle" - -@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") @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") @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") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") -external useImperativeHandle7: ( - Js.Nullable.t>, - @uncurry (unit => 'value), - ('a, 'b, 'c, 'd, 'e, 'f, 'g), -) => unit = "useImperativeHandle" - -module Uncurried = { - @module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") - external useState: (@uncurry (unit => 'state)) => ('state, (. 'state => 'state) => unit) = - "useState" - - @module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") - external useReducer: ( - @uncurry ('state, 'action) => 'state, - 'state, - ) => ('state, (. 'action) => unit) = "useReducer" - - @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") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") - external useCallback: ('f, 'deps) => 'f = "useCallback" - - @module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") - external useCallback0: ('f, @as(json`[]`) _) => 'f = "useCallback" - - @module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") - external useCallback1: ('f, array<'a>) => 'f = "useCallback" - - @module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") - external useCallback2: ('f, ('a, 'b)) => 'f = "useCallback" - - @module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") - external useCallback3: ('f, ('a, 'b, 'c)) => 'f = "useCallback" - - @module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") - external useCallback4: ('f, ('a, 'b, 'c, 'd)) => 'f = "useCallback" - - @module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") - external useCallback5: ('f, ('a, 'b, 'c, 'd, 'e)) => 'f = "useCallback" - - @module("react") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") - external useCallback6: ('callback, ('a, 'b, 'c, 'd, 'e, 'f)) => 'callback = "useCallback" - - @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") @deprecated("Jsx 3 is deprecated, use jsx 4 instead") -external useTransition: unit => (bool, (. unit => unit) => unit) = "useTransition" - -@set @deprecated("Jsx 3 is deprecated, use jsx 4 instead") -external setDisplayName: (component<'props>, string) => unit = "displayName" - -@get @return(nullable) @deprecated("Jsx 3 is deprecated, use jsx 4 instead") -external displayName: component<'props> => option = "displayName" From 72f75cc0caa9408fee1ebf2522c0df7b3dfaa33d Mon Sep 17 00:00:00 2001 From: Christoph Knittel Date: Sun, 23 Feb 2025 12:32:38 +0100 Subject: [PATCH 27/34] Remove deprecated stuff --- src/React.res | 11 - src/ReactDOM.res | 1054 ----------------------------------------- src/ReactDOMStyle.res | 421 ---------------- 3 files changed, 1486 deletions(-) diff --git a/src/React.res b/src/React.res index 0da49ad..89f4d5b 100644 --- a/src/React.res +++ b/src/React.res @@ -45,17 +45,6 @@ type fragmentProps = {children?: element} type ref<'value> = {mutable current: 'value} -module Ref = { - @deprecated("Please use the type React.ref instead") - type t<'value> = ref<'value> - - @deprecated("Please directly read from ref.current instead") @get - external current: ref<'value> => 'value = "current" - - @deprecated("Please directly assign to ref.current instead") @set - external setCurrent: (ref<'value>, 'value) => unit = "current" -} - @module("react") external createRef: unit => ref> = "createRef" diff --git a/src/ReactDOM.res b/src/ReactDOM.res index 72bce53..04c39c2 100644 --- a/src/ReactDOM.res +++ b/src/ReactDOM.res @@ -9,12 +9,6 @@ @val @return(nullable) external querySelector: string => option = "document.querySelector" -@module("react-dom") -@deprecated( - "ReactDOM.render is no longer supported in React 18. Use ReactDOM.Client.createRoot instead." -) -external render: (React.element, Dom.element) => unit = "render" - module Client = { module Root = { type t @@ -31,21 +25,9 @@ module Client = { external hydrateRoot: (Dom.element, React.element) => Root.t = "hydrateRoot" } -@module("react-dom") -@deprecated( - "ReactDOM.hydrate is no longer supported in React 18. Use ReactDOM.Client.hydrateRoot instead." -) -external hydrate: (React.element, Dom.element) => unit = "hydrate" - @module("react-dom") external createPortal: (React.element, Dom.element) => React.element = "createPortal" -@module("react-dom") -@deprecated( - "ReactDOM.unmountComponentAtNode is no longer supported in React 18. Use ReactDOM.Client.Root.unmount instead." -) -external unmountComponentAtNode: Dom.element => unit = "unmountComponentAtNode" - external domElementToObj: Dom.element => {..} = "%identity" type style = ReactDOMStyle.t @@ -63,1038 +45,6 @@ module Ref = { type domProps = JsxDOM.domProps -@deprecated("Please use type ReactDOM.domProps") -type props = JsxDOM.domProps - -module Props = { - @deprecated("Please use type ReactDOM.domProps") - type domProps = JsxDOM.domProps - - /** DEPRECATED */ - @deriving(abstract) - @deprecated("Please use type ReactDOM.domProps") - type props = { - @optional - key: string, - @optional - ref: Js.nullable => unit, - /* accessibility */ - /* https://www.w3.org/TR/wai-aria-1.1/ */ - /* https://accessibilityresources.org/ is a great resource for these */ - /* [@optional] [@as "aria-current"] ariaCurrent: page|step|location|date|time|true|false, */ - @optional @as("aria-details") - ariaDetails: string, - @optional @as("aria-disabled") - ariaDisabled: bool, - @optional @as("aria-hidden") - ariaHidden: bool, - /* [@optional] [@as "aria-invalid"] ariaInvalid: grammar|false|spelling|true, */ - @optional @as("aria-keyshortcuts") - ariaKeyshortcuts: string, - @optional @as("aria-label") - ariaLabel: string, - @optional @as("aria-roledescription") - ariaRoledescription: string, - /* Widget Attributes */ - /* [@optional] [@as "aria-autocomplete"] ariaAutocomplete: inline|list|both|none, */ - /* [@optional] [@as "aria-checked"] ariaChecked: true|false|mixed, /* https://www.w3.org/TR/wai-aria-1.1/#valuetype_tristate */ */ - @optional @as("aria-expanded") - ariaExpanded: bool, - /* [@optional] [@as "aria-haspopup"] ariaHaspopup: false|true|menu|listbox|tree|grid|dialog, */ - @optional @as("aria-level") - ariaLevel: int, - @optional @as("aria-modal") - ariaModal: bool, - @optional @as("aria-multiline") - ariaMultiline: bool, - @optional @as("aria-multiselectable") - ariaMultiselectable: bool, - /* [@optional] [@as "aria-orientation"] ariaOrientation: horizontal|vertical|undefined, */ - @optional @as("aria-placeholder") - ariaPlaceholder: string, - /* [@optional] [@as "aria-pressed"] ariaPressed: true|false|mixed, /* https://www.w3.org/TR/wai-aria-1.1/#valuetype_tristate */ */ - @optional @as("aria-readonly") - ariaReadonly: bool, - @optional @as("aria-required") - ariaRequired: bool, - @optional @as("aria-selected") - ariaSelected: bool, - @optional @as("aria-sort") - ariaSort: string, - @optional @as("aria-valuemax") - ariaValuemax: float, - @optional @as("aria-valuemin") - ariaValuemin: float, - @optional @as("aria-valuenow") - ariaValuenow: float, - @optional @as("aria-valuetext") - ariaValuetext: string, - /* Live Region Attributes */ - @optional @as("aria-atomic") - ariaAtomic: bool, - @optional @as("aria-busy") - ariaBusy: bool, - /* [@optional] [@as "aria-live"] ariaLive: off|polite|assertive|rude, */ - @optional @as("aria-relevant") - ariaRelevant: string, - /* Drag-and-Drop Attributes */ - /* [@optional] [@as "aria-dropeffect"] ariaDropeffect: copy|move|link|execute|popup|none, */ - @optional @as("aria-grabbed") - ariaGrabbed: bool, - /* Relationship Attributes */ - @optional @as("aria-activedescendant") - ariaActivedescendant: string, - @optional @as("aria-colcount") - ariaColcount: int, - @optional @as("aria-colindex") - ariaColindex: int, - @optional @as("aria-colspan") - ariaColspan: int, - @optional @as("aria-controls") - ariaControls: string, - @optional @as("aria-describedby") - ariaDescribedby: string, - @optional @as("aria-errormessage") - ariaErrormessage: string, - @optional @as("aria-flowto") - ariaFlowto: string, - @optional @as("aria-labelledby") - ariaLabelledby: string, - @optional @as("aria-owns") - ariaOwns: string, - @optional @as("aria-posinset") - ariaPosinset: int, - @optional @as("aria-rowcount") - ariaRowcount: int, - @optional @as("aria-rowindex") - ariaRowindex: int, - @optional @as("aria-rowspan") - ariaRowspan: int, - @optional @as("aria-setsize") - ariaSetsize: int, - /* react textarea/input */ - @optional - defaultChecked: bool, - @optional - defaultValue: string, - /* global html attributes */ - @optional - accessKey: string, - @optional - className: string /* substitute for "class" */, - @optional - contentEditable: bool, - @optional - contextMenu: string, - @optional - dir: string /* "ltr", "rtl" or "auto" */, - @optional - draggable: bool, - @optional - hidden: bool, - @optional - id: string, - @optional - lang: string, - @optional - role: string /* ARIA role */, - @optional - style: style, - @optional - spellCheck: bool, - @optional - tabIndex: int, - @optional - title: string, - /* html5 microdata */ - @optional - itemID: string, - @optional - itemProp: string, - @optional - itemRef: string, - @optional - itemScope: bool, - @optional - itemType: string /* uri */, - /* tag-specific html attributes */ - @optional - accept: string, - @optional - acceptCharset: string, - @optional - action: string /* uri */, - @optional - allow: string, - @optional - allowFullScreen: bool, - @optional - alt: string, - @optional - async: bool, - @optional - autoComplete: string /* has a fixed, but large-ish, set of possible values */, - @optional - autoCapitalize: string /* Mobile Safari specific */, - @optional - autoFocus: bool, - @optional - autoPlay: bool, - @optional - challenge: string, - @optional - charSet: string, - @optional - checked: bool, - @optional - cite: string /* uri */, - @optional - crossorigin: bool, - @optional - cols: int, - @optional - colSpan: int, - @optional - content: string, - @optional - controls: bool, - @optional - coords: string /* set of values specifying the coordinates of a region */, - @optional - data: string /* uri */, - @optional - dateTime: string /* "valid date string with optional time" */, - @optional - default: bool, - @optional - defer: bool, - @optional - disabled: bool, - @optional - download: string /* should really be either a boolean, signifying presence, or a string */, - @optional - encType: string /* "application/x-www-form-urlencoded", "multipart/form-data" or "text/plain" */, - @optional - form: string, - @optional - formAction: string /* uri */, - @optional - formTarget: string /* "_blank", "_self", etc. */, - @optional - formMethod: string /* "post", "get", "put" */, - @optional - frameBorder: int /* deprecated, prefer to use css border instead */, - @optional - headers: string, - @optional - height: string /* in html5 this can only be a number, but in html4 it can ba a percentage as well */, - @optional - high: int, - @optional - href: string /* uri */, - @optional - hrefLang: string, - @optional - htmlFor: string /* substitute for "for" */, - @optional - httpEquiv: string /* has a fixed set of possible values */, - @optional - icon: string /* uri? */, - @optional - inputMode: string /* "verbatim", "latin", "numeric", etc. */, - @optional - integrity: string, - @optional - keyType: string, - @optional - kind: string /* has a fixed set of possible values */, - @optional - label: string, - @optional - list: string, - @optional - loop: bool, - @optional - low: int, - @optional - manifest: string /* uri */, - @optional - max: string /* should be int or Js.Date.t */, - @optional - maxLength: int, - @optional - media: string /* a valid media query */, - @optional - mediaGroup: string, - @optional - method: string /* "post" or "get" */, - @optional - min: string, - @optional - minLength: int, - @optional - multiple: bool, - @optional - muted: bool, - @optional - name: string, - @optional - nonce: string, - @optional - noValidate: bool, - @optional @as("open") - open_: bool /* use this one. Previous one is deprecated */, - @optional - optimum: int, - @optional - pattern: string /* valid Js RegExp */, - @optional - placeholder: string, - @optional - poster: string /* uri */, - @optional - preload: string /* "none", "metadata" or "auto" (and "" as a synonym for "auto") */, - @optional - radioGroup: string, - @optional - readOnly: bool, - @optional - rel: string /* a space- or comma-separated (depending on the element) list of a fixed set of "link types" */, - @optional - required: bool, - @optional - reversed: bool, - @optional - rows: int, - @optional - rowSpan: int, - @optional - sandbox: string /* has a fixed set of possible values */, - @optional - scope: string /* has a fixed set of possible values */, - @optional - scoped: bool, - @optional - scrolling: string /* html4 only, "auto", "yes" or "no" */, - /* seamless - supported by React, but removed from the html5 spec */ - @optional - selected: bool, - @optional - shape: string, - @optional - size: int, - @optional - sizes: string, - @optional - span: int, - @optional - src: string /* uri */, - @optional - srcDoc: string, - @optional - srcLang: string, - @optional - srcSet: string, - @optional - start: int, - @optional - step: float, - @optional - summary: string /* deprecated */, - @optional - target: string, - @optional @as("type") - type_: string /* has a fixed but large-ish set of possible values */ /* use this one. Previous one is deprecated */, - @optional - useMap: string, - @optional - value: string, - @optional - width: string /* in html5 this can only be a number, but in html4 it can ba a percentage as well */, - @optional - wrap: string /* "hard" or "soft" */, - /* Clipboard events */ - @optional - onCopy: ReactEvent.Clipboard.t => unit, - @optional - onCut: ReactEvent.Clipboard.t => unit, - @optional - onPaste: ReactEvent.Clipboard.t => unit, - /* Composition events */ - @optional - onCompositionEnd: ReactEvent.Composition.t => unit, - @optional - onCompositionStart: ReactEvent.Composition.t => unit, - @optional - onCompositionUpdate: ReactEvent.Composition.t => unit, - /* Keyboard events */ - @optional - onKeyDown: ReactEvent.Keyboard.t => unit, - @optional - onKeyPress: ReactEvent.Keyboard.t => unit, - @optional - onKeyUp: ReactEvent.Keyboard.t => unit, - /* Focus events */ - @optional - onFocus: ReactEvent.Focus.t => unit, - @optional - onBlur: ReactEvent.Focus.t => unit, - /* Form events */ - @optional - onChange: ReactEvent.Form.t => unit, - @optional - onInput: ReactEvent.Form.t => unit, - @optional - onSubmit: ReactEvent.Form.t => unit, - @optional - onInvalid: ReactEvent.Form.t => unit, - /* Mouse events */ - @optional - onClick: ReactEvent.Mouse.t => unit, - @optional - onContextMenu: ReactEvent.Mouse.t => unit, - @optional - onDoubleClick: ReactEvent.Mouse.t => unit, - @optional - onDrag: ReactEvent.Mouse.t => unit, - @optional - onDragEnd: ReactEvent.Mouse.t => unit, - @optional - onDragEnter: ReactEvent.Mouse.t => unit, - @optional - onDragExit: ReactEvent.Mouse.t => unit, - @optional - onDragLeave: ReactEvent.Mouse.t => unit, - @optional - onDragOver: ReactEvent.Mouse.t => unit, - @optional - onDragStart: ReactEvent.Mouse.t => unit, - @optional - onDrop: ReactEvent.Mouse.t => unit, - @optional - onMouseDown: ReactEvent.Mouse.t => unit, - @optional - onMouseEnter: ReactEvent.Mouse.t => unit, - @optional - onMouseLeave: ReactEvent.Mouse.t => unit, - @optional - onMouseMove: ReactEvent.Mouse.t => unit, - @optional - onMouseOut: ReactEvent.Mouse.t => unit, - @optional - onMouseOver: ReactEvent.Mouse.t => unit, - @optional - onMouseUp: ReactEvent.Mouse.t => unit, - /* Selection events */ - @optional - onSelect: ReactEvent.Selection.t => unit, - /* Touch events */ - @optional - onTouchCancel: ReactEvent.Touch.t => unit, - @optional - onTouchEnd: ReactEvent.Touch.t => unit, - @optional - onTouchMove: ReactEvent.Touch.t => unit, - @optional - onTouchStart: ReactEvent.Touch.t => unit, - // Pointer events - @optional - onPointerOver: ReactEvent.Pointer.t => unit, - @optional - onPointerEnter: ReactEvent.Pointer.t => unit, - @optional - onPointerDown: ReactEvent.Pointer.t => unit, - @optional - onPointerMove: ReactEvent.Pointer.t => unit, - @optional - onPointerUp: ReactEvent.Pointer.t => unit, - @optional - onPointerCancel: ReactEvent.Pointer.t => unit, - @optional - onPointerOut: ReactEvent.Pointer.t => unit, - @optional - onPointerLeave: ReactEvent.Pointer.t => unit, - @optional - onGotPointerCapture: ReactEvent.Pointer.t => unit, - @optional - onLostPointerCapture: ReactEvent.Pointer.t => unit, - /* UI events */ - @optional - onScroll: ReactEvent.UI.t => unit, - /* Wheel events */ - @optional - onWheel: ReactEvent.Wheel.t => unit, - /* Media events */ - @optional - onAbort: ReactEvent.Media.t => unit, - @optional - onCanPlay: ReactEvent.Media.t => unit, - @optional - onCanPlayThrough: ReactEvent.Media.t => unit, - @optional - onDurationChange: ReactEvent.Media.t => unit, - @optional - onEmptied: ReactEvent.Media.t => unit, - @optional - onEncrypetd: ReactEvent.Media.t => unit, - @optional - onEnded: ReactEvent.Media.t => unit, - @optional - onError: ReactEvent.Media.t => unit, - @optional - onLoadedData: ReactEvent.Media.t => unit, - @optional - onLoadedMetadata: ReactEvent.Media.t => unit, - @optional - onLoadStart: ReactEvent.Media.t => unit, - @optional - onPause: ReactEvent.Media.t => unit, - @optional - onPlay: ReactEvent.Media.t => unit, - @optional - onPlaying: ReactEvent.Media.t => unit, - @optional - onProgress: ReactEvent.Media.t => unit, - @optional - onRateChange: ReactEvent.Media.t => unit, - @optional - onSeeked: ReactEvent.Media.t => unit, - @optional - onSeeking: ReactEvent.Media.t => unit, - @optional - onStalled: ReactEvent.Media.t => unit, - @optional - onSuspend: ReactEvent.Media.t => unit, - @optional - onTimeUpdate: ReactEvent.Media.t => unit, - @optional - onVolumeChange: ReactEvent.Media.t => unit, - @optional - onWaiting: ReactEvent.Media.t => unit, - /* Image events */ - @optional - onLoad: ReactEvent.Image.t => unit /* duplicate */ /* ~onError: ReactEvent.Image.t => unit=?, */, - /* Animation events */ - @optional - onAnimationStart: ReactEvent.Animation.t => unit, - @optional - onAnimationEnd: ReactEvent.Animation.t => unit, - @optional - onAnimationIteration: ReactEvent.Animation.t => unit, - /* Transition events */ - @optional - onTransitionEnd: ReactEvent.Transition.t => unit, - /* svg */ - @optional - accentHeight: string, - @optional - accumulate: string, - @optional - additive: string, - @optional - alignmentBaseline: string, - @optional - allowReorder: string, - @optional - alphabetic: string, - @optional - amplitude: string, - @optional - arabicForm: string, - @optional - ascent: string, - @optional - attributeName: string, - @optional - attributeType: string, - @optional - autoReverse: string, - @optional - azimuth: string, - @optional - baseFrequency: string, - @optional - baseProfile: string, - @optional - baselineShift: string, - @optional - bbox: string, - @optional @as("begin") - begin_: string /* use this one. Previous one is deprecated */, - @optional - bias: string, - @optional - by: string, - @optional - calcMode: string, - @optional - capHeight: string, - @optional - clip: string, - @optional - clipPath: string, - @optional - clipPathUnits: string, - @optional - clipRule: string, - @optional - colorInterpolation: string, - @optional - colorInterpolationFilters: string, - @optional - colorProfile: string, - @optional - colorRendering: string, - @optional - contentScriptType: string, - @optional - contentStyleType: string, - @optional - cursor: string, - @optional - cx: string, - @optional - cy: string, - @optional - d: string, - @optional - decelerate: string, - @optional - descent: string, - @optional - diffuseConstant: string, - @optional - direction: string, - @optional - display: string, - @optional - divisor: string, - @optional - dominantBaseline: string, - @optional - dur: string, - @optional - dx: string, - @optional - dy: string, - @optional - edgeMode: string, - @optional - elevation: string, - @optional - enableBackground: string, - @optional @as("end") - end_: string /* use this one. Previous one is deprecated */, - @optional - exponent: string, - @optional - externalResourcesRequired: string, - @optional - fill: string, - @optional - fillOpacity: string, - @optional - fillRule: string, - @optional - filter: string, - @optional - filterRes: string, - @optional - filterUnits: string, - @optional - floodColor: string, - @optional - floodOpacity: string, - @optional - focusable: string, - @optional - fontFamily: string, - @optional - fontSize: string, - @optional - fontSizeAdjust: string, - @optional - fontStretch: string, - @optional - fontStyle: string, - @optional - fontVariant: string, - @optional - fontWeight: string, - @optional - fomat: string, - @optional - from: string, - @optional - fx: string, - @optional - fy: string, - @optional - g1: string, - @optional - g2: string, - @optional - glyphName: string, - @optional - glyphOrientationHorizontal: string, - @optional - glyphOrientationVertical: string, - @optional - glyphRef: string, - @optional - gradientTransform: string, - @optional - gradientUnits: string, - @optional - hanging: string, - @optional - horizAdvX: string, - @optional - horizOriginX: string, - @optional - ideographic: string, - @optional - imageRendering: string, - @optional @as("in") - in_: string /* use this one. Previous one is deprecated */, - @optional - in2: string, - @optional - intercept: string, - @optional - k: string, - @optional - k1: string, - @optional - k2: string, - @optional - k3: string, - @optional - k4: string, - @optional - kernelMatrix: string, - @optional - kernelUnitLength: string, - @optional - kerning: string, - @optional - keyPoints: string, - @optional - keySplines: string, - @optional - keyTimes: string, - @optional - lengthAdjust: string, - @optional - letterSpacing: string, - @optional - lightingColor: string, - @optional - limitingConeAngle: string, - @optional - local: string, - @optional - markerEnd: string, - @optional - markerHeight: string, - @optional - markerMid: string, - @optional - markerStart: string, - @optional - markerUnits: string, - @optional - markerWidth: string, - @optional - mask: string, - @optional - maskContentUnits: string, - @optional - maskUnits: string, - @optional - mathematical: string, - @optional - mode: string, - @optional - numOctaves: string, - @optional - offset: string, - @optional - opacity: string, - @optional - operator: string, - @optional - order: string, - @optional - orient: string, - @optional - orientation: string, - @optional - origin: string, - @optional - overflow: string, - @optional - overflowX: string, - @optional - overflowY: string, - @optional - overlinePosition: string, - @optional - overlineThickness: string, - @optional - paintOrder: string, - @optional - panose1: string, - @optional - pathLength: string, - @optional - patternContentUnits: string, - @optional - patternTransform: string, - @optional - patternUnits: string, - @optional - pointerEvents: string, - @optional - points: string, - @optional - pointsAtX: string, - @optional - pointsAtY: string, - @optional - pointsAtZ: string, - @optional - preserveAlpha: string, - @optional - preserveAspectRatio: string, - @optional - primitiveUnits: string, - @optional - r: string, - @optional - radius: string, - @optional - refX: string, - @optional - refY: string, - @optional - renderingIntent: string, - @optional - repeatCount: string, - @optional - repeatDur: string, - @optional - requiredExtensions: string, - @optional - requiredFeatures: string, - @optional - restart: string, - @optional - result: string, - @optional - rotate: string, - @optional - rx: string, - @optional - ry: string, - @optional - scale: string, - @optional - seed: string, - @optional - shapeRendering: string, - @optional - slope: string, - @optional - spacing: string, - @optional - specularConstant: string, - @optional - specularExponent: string, - @optional - speed: string, - @optional - spreadMethod: string, - @optional - startOffset: string, - @optional - stdDeviation: string, - @optional - stemh: string, - @optional - stemv: string, - @optional - stitchTiles: string, - @optional - stopColor: string, - @optional - stopOpacity: string, - @optional - strikethroughPosition: string, - @optional - strikethroughThickness: string, - @optional - string: string, - @optional - stroke: string, - @optional - strokeDasharray: string, - @optional - strokeDashoffset: string, - @optional - strokeLinecap: string, - @optional - strokeLinejoin: string, - @optional - strokeMiterlimit: string, - @optional - strokeOpacity: string, - @optional - strokeWidth: string, - @optional - surfaceScale: string, - @optional - systemLanguage: string, - @optional - tableValues: string, - @optional - targetX: string, - @optional - targetY: string, - @optional - textAnchor: string, - @optional - textDecoration: string, - @optional - textLength: string, - @optional - textRendering: string, - @optional @as("to") - to_: string /* use this one. Previous one is deprecated */, - @optional - transform: string, - @optional - u1: string, - @optional - u2: string, - @optional - underlinePosition: string, - @optional - underlineThickness: string, - @optional - unicode: string, - @optional - unicodeBidi: string, - @optional - unicodeRange: string, - @optional - unitsPerEm: string, - @optional - vAlphabetic: string, - @optional - vHanging: string, - @optional - vIdeographic: string, - @optional - vMathematical: string, - @optional - values: string, - @optional - vectorEffect: string, - @optional - version: string, - @optional - vertAdvX: string, - @optional - vertAdvY: string, - @optional - vertOriginX: string, - @optional - vertOriginY: string, - @optional - viewBox: string, - @optional - viewTarget: string, - @optional - visibility: string, - /* width::string? => */ - @optional - widths: string, - @optional - wordSpacing: string, - @optional - writingMode: string, - @optional - x: string, - @optional - x1: string, - @optional - x2: string, - @optional - xChannelSelector: string, - @optional - xHeight: string, - @optional - xlinkActuate: string, - @optional - xlinkArcrole: string, - @optional - xlinkHref: string, - @optional - xlinkRole: string, - @optional - xlinkShow: string, - @optional - xlinkTitle: string, - @optional - xlinkType: string, - @optional - xmlns: string, - @optional - xmlnsXlink: string, - @optional - xmlBase: string, - @optional - xmlLang: string, - @optional - xmlSpace: string, - @optional - y: string, - @optional - y1: string, - @optional - y2: string, - @optional - yChannelSelector: string, - @optional - z: string, - @optional - zoomAndPan: string, - /* RDFa */ - @optional - about: string, - @optional - datatype: string, - @optional - inlist: string, - @optional - prefix: string, - @optional - property: string, - @optional - resource: string, - @optional - typeof: string, - @optional - vocab: string, - /* react-specific */ - @optional - dangerouslySetInnerHTML: {"__html": string}, - @optional - suppressContentEditableWarning: bool, - } -} - @variadic @module("react") external createElement: (string, ~props: domProps=?, array) => React.element = "createElement" @@ -1120,8 +70,4 @@ external jsxs: (string, JsxDOM.domProps) => Jsx.element = "jsxs" @module("react/jsx-runtime") external jsxsKeyed: (string, JsxDOM.domProps, ~key: string=?, @ignore unit) => Jsx.element = "jsxs" -// Currently, not used by JSX ppx -@deprecated("Please use ReactDOM.createElement instead.") -external stringToComponent: string => React.component<'a> = "%identity" - module Style = ReactDOMStyle diff --git a/src/ReactDOMStyle.res b/src/ReactDOMStyle.res index 0f57b7a..ae68d03 100644 --- a/src/ReactDOMStyle.res +++ b/src/ReactDOMStyle.res @@ -1,426 +1,5 @@ type t = JsxDOMStyle.t -@deprecated("Please directly construct the style record instead") @obj -external make: ( - ~azimuth: string=?, - ~backdropFilter: string=?, - ~background: string=?, - ~backgroundAttachment: string=?, - ~backgroundColor: string=?, - ~backgroundImage: string=?, - ~backgroundPosition: string=?, - ~backgroundRepeat: string=?, - ~border: string=?, - ~borderCollapse: string=?, - ~borderColor: string=?, - ~borderSpacing: string=?, - ~borderStyle: string=?, - ~borderTop: string=?, - ~borderRight: string=?, - ~borderBottom: string=?, - ~borderLeft: string=?, - ~borderTopColor: string=?, - ~borderRightColor: string=?, - ~borderBottomColor: string=?, - ~borderLeftColor: string=?, - ~borderTopStyle: string=?, - ~borderRightStyle: string=?, - ~borderBottomStyle: string=?, - ~borderLeftStyle: string=?, - ~borderTopWidth: string=?, - ~borderRightWidth: string=?, - ~borderBottomWidth: string=?, - ~borderLeftWidth: string=?, - ~borderWidth: string=?, - ~bottom: string=?, - ~captionSide: string=?, - ~clear: string=?, - ~clip: string=?, - ~color: string=?, - ~content: string=?, - ~counterIncrement: string=?, - ~counterReset: string=?, - ~cue: string=?, - ~cueAfter: string=?, - ~cueBefore: string=?, - ~cursor: string=?, - ~direction: string=?, - ~display: string=?, - ~elevation: string=?, - ~emptyCells: string=?, - ~float: string=?, - ~font: string=?, - ~fontFamily: string=?, - ~fontSize: string=?, - ~fontSizeAdjust: string=?, - ~fontStretch: string=?, - ~fontStyle: string=?, - ~fontVariant: string=?, - ~fontWeight: string=?, - ~height: string=?, - ~left: string=?, - ~letterSpacing: string=?, - ~lineHeight: string=?, - ~listStyle: string=?, - ~listStyleImage: string=?, - ~listStylePosition: string=?, - ~listStyleType: string=?, - ~margin: string=?, - ~marginTop: string=?, - ~marginRight: string=?, - ~marginBottom: string=?, - ~marginLeft: string=?, - ~markerOffset: string=?, - ~marks: string=?, - ~maxHeight: string=?, - ~maxWidth: string=?, - ~minHeight: string=?, - ~minWidth: string=?, - ~orphans: string=?, - ~outline: string=?, - ~outlineColor: string=?, - ~outlineStyle: string=?, - ~outlineWidth: string=?, - ~overflow: string=?, - ~overflowX: string=?, - ~overflowY: string=?, - ~padding: string=?, - ~paddingTop: string=?, - ~paddingRight: string=?, - ~paddingBottom: string=?, - ~paddingLeft: string=?, - ~page: string=?, - ~pageBreakAfter: string=?, - ~pageBreakBefore: string=?, - ~pageBreakInside: string=?, - ~pause: string=?, - ~pauseAfter: string=?, - ~pauseBefore: string=?, - ~pitch: string=?, - ~pitchRange: string=?, - ~playDuring: string=?, - ~position: string=?, - ~quotes: string=?, - ~richness: string=?, - ~right: string=?, - ~size: string=?, - ~speak: string=?, - ~speakHeader: string=?, - ~speakNumeral: string=?, - ~speakPunctuation: string=?, - ~speechRate: string=?, - ~stress: string=?, - ~tableLayout: string=?, - ~textAlign: string=?, - ~textDecoration: string=?, - ~textIndent: string=?, - ~textShadow: string=?, - ~textTransform: string=?, - ~top: string=?, - ~unicodeBidi: string=?, - ~verticalAlign: string=?, - ~visibility: string=?, - ~voiceFamily: string=?, - ~volume: string=?, - ~whiteSpace: string=?, - ~widows: string=?, - ~width: string=?, - ~wordSpacing: string=?, - ~zIndex: string=?, - ~opacity: /* Below properties based on https://www.w3.org/Style/CSS/all-properties */ - /* Color Level 3 - REC */ - string=?, - ~backgroundOrigin: /* Backgrounds and Borders Level 3 - CR */ - /* backgroundRepeat - already defined by CSS2Properties */ - /* backgroundAttachment - already defined by CSS2Properties */ - string=?, - ~backgroundSize: string=?, - ~backgroundClip: string=?, - ~borderRadius: string=?, - ~borderTopLeftRadius: string=?, - ~borderTopRightRadius: string=?, - ~borderBottomLeftRadius: string=?, - ~borderBottomRightRadius: string=?, - ~borderImage: string=?, - ~borderImageSource: string=?, - ~borderImageSlice: string=?, - ~borderImageWidth: string=?, - ~borderImageOutset: string=?, - ~borderImageRepeat: string=?, - ~boxShadow: string=?, - ~columns: /* Multi-column Layout - CR */ - string=?, - ~columnCount: string=?, - ~columnFill: string=?, - ~columnGap: string=?, - ~columnRule: string=?, - ~columnRuleColor: string=?, - ~columnRuleStyle: string=?, - ~columnRuleWidth: string=?, - ~columnSpan: string=?, - ~columnWidth: string=?, - ~breakAfter: string=?, - ~breakBefore: string=?, - ~breakInside: string=?, - ~rest: /* Speech - CR */ - string=?, - ~restAfter: string=?, - ~restBefore: string=?, - ~speakAs: string=?, - ~voiceBalance: string=?, - ~voiceDuration: string=?, - ~voicePitch: string=?, - ~voiceRange: string=?, - ~voiceRate: string=?, - ~voiceStress: string=?, - ~voiceVolume: string=?, - ~objectFit: /* Image Values and Replaced Content Level 3 - CR */ - string=?, - ~objectPosition: string=?, - ~imageResolution: string=?, - ~imageOrientation: string=?, - ~alignContent: /* Flexible Box Layout - CR */ - string=?, - ~alignItems: string=?, - ~alignSelf: string=?, - ~flex: string=?, - ~flexBasis: string=?, - ~flexDirection: string=?, - ~flexFlow: string=?, - ~flexGrow: string=?, - ~flexShrink: string=?, - ~flexWrap: string=?, - ~justifyContent: string=?, - ~order: string=?, - ~gap: string=?, - ~textDecorationColor: /* Text Decoration Level 3 - CR */ - /* textDecoration - already defined by CSS2Properties */ - string=?, - ~textDecorationLine: string=?, - ~textDecorationSkip: string=?, - ~textDecorationStyle: string=?, - ~textEmphasis: string=?, - ~textEmphasisColor: string=?, - ~textEmphasisPosition: string=?, - ~textEmphasisStyle: string=?, - ~textUnderlinePosition: /* textShadow - already defined by CSS2Properties */ - string=?, - ~fontFeatureSettings: /* Fonts Level 3 - CR */ - string=?, - ~fontKerning: string=?, - ~fontLanguageOverride: string=?, - ~fontSynthesis: /* fontSizeAdjust - already defined by CSS2Properties */ - /* fontStretch - already defined by CSS2Properties */ - string=?, - ~forntVariantAlternates: string=?, - ~fontVariantCaps: string=?, - ~fontVariantEastAsian: string=?, - ~fontVariantLigatures: string=?, - ~fontVariantNumeric: string=?, - ~fontVariantPosition: string=?, - ~all: /* Cascading and Inheritance Level 3 - CR */ - string=?, - ~glyphOrientationVertical: /* Writing Modes Level 3 - CR */ - string=?, - ~textCombineUpright: string=?, - ~textOrientation: string=?, - ~writingMode: string=?, - ~shapeImageThreshold: /* Shapes Level 1 - CR */ - string=?, - ~shapeMargin: string=?, - ~shapeOutside: string=?, - ~clipPath: /* Masking Level 1 - CR */ - string=?, - ~clipRule: string=?, - ~mask: string=?, - ~maskBorder: string=?, - ~maskBorderMode: string=?, - ~maskBorderOutset: string=?, - ~maskBorderRepeat: string=?, - ~maskBorderSlice: string=?, - ~maskBorderSource: string=?, - ~maskBorderWidth: string=?, - ~maskClip: string=?, - ~maskComposite: string=?, - ~maskImage: string=?, - ~maskMode: string=?, - ~maskOrigin: string=?, - ~maskPosition: string=?, - ~maskRepeat: string=?, - ~maskSize: string=?, - ~maskType: string=?, - ~backgroundBlendMode: /* Compositing and Blending Level 1 - CR */ - string=?, - ~isolation: string=?, - ~mixBlendMode: string=?, - ~boxDecorationBreak: /* Fragmentation Level 3 - CR */ - string=?, - ~boxSizing: /* breakAfter - already defined by Multi-column Layout */ - /* breakBefore - already defined by Multi-column Layout */ - /* breakInside - already defined by Multi-column Layout */ - /* Basic User Interface Level 3 - CR */ - string=?, - ~caretColor: string=?, - ~navDown: string=?, - ~navLeft: string=?, - ~navRight: string=?, - ~navUp: string=?, - ~outlineOffset: string=?, - ~resize: string=?, - ~textOverflow: string=?, - ~grid: /* Grid Layout Level 1 - CR */ - string=?, - ~gridArea: string=?, - ~gridAutoColumns: string=?, - ~gridAutoFlow: string=?, - ~gridAutoRows: string=?, - ~gridColumn: string=?, - ~gridColumnEnd: string=?, - ~gridColumnGap: string=?, - ~gridColumnStart: string=?, - ~gridGap: string=?, - ~gridRow: string=?, - ~gridRowEnd: string=?, - ~gridRowGap: string=?, - ~gridRowStart: string=?, - ~gridTemplate: string=?, - ~gridTemplateAreas: string=?, - ~gridTemplateColumns: string=?, - ~gridTemplateRows: string=?, - ~willChange: /* Will Change Level 1 - CR */ - string=?, - ~hangingPunctuation: /* Text Level 3 - LC */ - string=?, - ~hyphens: string=?, - ~lineBreak: /* letterSpacing - already defined by CSS2Properties */ - string=?, - ~overflowWrap: string=?, - ~tabSize: string=?, - ~textAlignLast: /* textAlign - already defined by CSS2Properties */ - string=?, - ~textJustify: string=?, - ~wordBreak: string=?, - ~wordWrap: string=?, - ~animation: /* Animations - WD */ - string=?, - ~animationDelay: string=?, - ~animationDirection: string=?, - ~animationDuration: string=?, - ~animationFillMode: string=?, - ~animationIterationCount: string=?, - ~animationName: string=?, - ~animationPlayState: string=?, - ~animationTimingFunction: string=?, - ~transition: /* Transitions - WD */ - string=?, - ~transitionDelay: string=?, - ~transitionDuration: string=?, - ~transitionProperty: string=?, - ~transitionTimingFunction: string=?, - ~backfaceVisibility: /* Transforms Level 1 - WD */ - string=?, - ~perspective: string=?, - ~perspectiveOrigin: string=?, - ~transform: string=?, - ~transformOrigin: string=?, - ~transformStyle: string=?, - ~justifyItems: /* Box Alignment Level 3 - WD */ - /* alignContent - already defined by Flexible Box Layout */ - /* alignItems - already defined by Flexible Box Layout */ - string=?, - ~justifySelf: string=?, - ~placeContent: string=?, - ~placeItems: string=?, - ~placeSelf: string=?, - ~appearance: /* Basic User Interface Level 4 - FPWD */ - string=?, - ~caret: string=?, - ~caretAnimation: string=?, - ~caretShape: string=?, - ~userSelect: string=?, - ~maxLines: /* Overflow Level 3 - WD */ - string=?, - ~marqueeDirection: /* Basix Box Model - WD */ - string=?, - ~marqueeLoop: string=?, - ~marqueeSpeed: string=?, - ~marqueeStyle: string=?, - ~overflowStyle: string=?, - ~rotation: string=?, - ~rotationPoint: string=?, - ~alignmentBaseline: /* SVG 1.1 - REC */ - string=?, - ~baselineShift: string=?, - ~clip: string=?, - ~clipPath: string=?, - ~clipRule: string=?, - ~colorInterpolation: string=?, - ~colorInterpolationFilters: string=?, - ~colorProfile: string=?, - ~colorRendering: string=?, - ~cursor: string=?, - ~dominantBaseline: string=?, - ~fill: string=?, - ~fillOpacity: string=?, - ~fillRule: string=?, - ~filter: string=?, - ~floodColor: string=?, - ~floodOpacity: string=?, - ~glyphOrientationHorizontal: string=?, - ~glyphOrientationVertical: string=?, - ~imageRendering: string=?, - ~kerning: string=?, - ~lightingColor: string=?, - ~markerEnd: string=?, - ~markerMid: string=?, - ~markerStart: string=?, - ~pointerEvents: string=?, - ~shapeRendering: string=?, - ~stopColor: string=?, - ~stopOpacity: string=?, - ~stroke: string=?, - ~strokeDasharray: string=?, - ~strokeDashoffset: string=?, - ~strokeLinecap: string=?, - ~strokeLinejoin: string=?, - ~strokeMiterlimit: string=?, - ~strokeOpacity: string=?, - ~strokeWidth: string=?, - ~textAnchor: string=?, - ~textRendering: string=?, - ~rubyAlign: /* Ruby Layout Level 1 - WD */ - string=?, - ~rubyMerge: string=?, - ~rubyPosition: string=?, - /* Lists and Counters Level 3 - WD */ - /* listStyle - already defined by CSS2Properties */ - /* listStyleImage - already defined by CSS2Properties */ - /* listStylePosition - already defined by CSS2Properties */ - /* listStyleType - already defined by CSS2Properties */ - /* counterIncrement - already defined by CSS2Properties */ - /* counterReset - already defined by CSS2Properties */ - /* Not added yet - * ------------- - * Generated Content for Paged Media - WD - * Generated Content Level 3 - WD - * Line Grid Level 1 - WD - * Regions - WD - * Inline Layout Level 3 - WD - * Round Display Level 1 - WD - * Image Values and Replaced Content Level 4 - WD - * Positioned Layout Level 3 - WD - * Filter Effects Level 1 - -WD - * Exclusions Level 1 - WD - * Text Level 4 - FPWD - * SVG Markers - FPWD - * Motion Path Level 1 - FPWD - * Color Level 4 - FPWD - * SVG Strokes - FPWD - * Table Level 3 - FPWD - */ - unit, -) => t = "" - /* CSS2Properties: https://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSS2Properties */ @val external combine: (@as(json`{}`) _, t, t) => t = "Object.assign" From 2f7a5fa687cf0146e89be996f59279de67a602d1 Mon Sep 17 00:00:00 2001 From: Christoph Knittel Date: Sat, 22 Feb 2025 17:01:32 +0100 Subject: [PATCH 28/34] Remove support for curried mode --- README.md | 11 +- rescript.json | 3 +- src/React.bs.js | 5 +- src/React.res | 199 ++++++++++++++-------------------- src/ReactTestUtils.bs.js | 5 +- src/ReactTestUtils.res | 8 +- src/RescriptReactRouter.bs.js | 27 +++-- 7 files changed, 108 insertions(+), 150 deletions(-) diff --git a/README.md b/README.md index 62b25b0..5adebb1 100644 --- a/README.md +++ b/README.md @@ -7,11 +7,12 @@ ### Versions -| @rescript/react | ReScript | ReactJS | Documentation | -| --------------- | -------- | ------- | ----------------------------------------------------------------- | -| 0.12.0+ | 11.0+ | 18.0.0+ | [Link](https://rescript-lang.org/docs/react/latest/introduction) | -| 0.11.0 | 10.1 | 18.0.0+ | [Link](https://rescript-lang.org/docs/react/v0.11.0/introduction) | -| 0.10.3 | 8.3 | 16.8.1+ | [Link](https://rescript-lang.org/docs/react/v0.10.0/introduction) | +| @rescript/react | ReScript | ReactJS | Documentation | +| --------------- | ---------------------------------- | ------- | ----------------------------------------------------------------- | +| next (master) | 11.0+ (JSX4 + uncurried mode only) | 18.0.0+ | | +| 0.12.x, 0.13.x | 11.0+ | 18.0.0+ | [Link](https://rescript-lang.org/docs/react/latest/introduction) | +| 0.11.0 | 10.1 | 18.0.0+ | [Link](https://rescript-lang.org/docs/react/v0.11.0/introduction) | +| 0.10.3 | 8.3 | 16.8.1+ | [Link](https://rescript-lang.org/docs/react/v0.10.0/introduction) | ### Development diff --git a/rescript.json b/rescript.json index c13a738..599e1f6 100644 --- a/rescript.json +++ b/rescript.json @@ -8,6 +8,5 @@ "package-specs": [{ "module": "commonjs", "in-source": true }], "suffix": ".bs.js", "bs-dev-dependencies": [], - "bsc-flags": [], - "uncurried": false + "bsc-flags": [] } diff --git a/src/React.bs.js b/src/React.bs.js index 08a9db0..c2471b6 100644 --- a/src/React.bs.js +++ b/src/React.bs.js @@ -1,7 +1,6 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; -var Curry = require("rescript/lib/js/curry.js"); var React = require("react"); var Ref = {}; @@ -17,9 +16,9 @@ var StrictMode = {}; var Suspense = {}; function lazy_(load) { - return React.lazy(async function (param) { + return React.lazy(async function () { return { - default: await Curry._1(load, undefined) + default: await load() }; }); } diff --git a/src/React.res b/src/React.res index 89f4d5b..0beaa59 100644 --- a/src/React.res +++ b/src/React.res @@ -52,11 +52,11 @@ module Children = { @module("react") @scope("Children") external map: (element, element => element) => element = "map" @module("react") @scope("Children") - external mapWithIndex: (element, @uncurry (element, int) => element) => element = "map" + external mapWithIndex: (element, (element, int) => element) => element = "map" @module("react") @scope("Children") external forEach: (element, element => unit) => unit = "forEach" @module("react") @scope("Children") - external forEachWithIndex: (element, @uncurry (element, int) => unit) => unit = "forEach" + external forEachWithIndex: (element, (element, int) => unit) => unit = "forEach" @module("react") @scope("Children") external count: element => int = "count" @module("react") @scope("Children") @@ -81,7 +81,7 @@ module Context = { external createContext: 'a => Context.t<'a> = "createContext" @module("react") -external forwardRef: (@uncurry ('props, Js.Nullable.t>) => element) => component<'props> = +external forwardRef: (('props, Js.Nullable.t>) => element) => component<'props> = "forwardRef" @module("react") @@ -90,7 +90,7 @@ external memo: component<'props> => component<'props> = "memo" @module("react") external memoCustomCompareProps: ( component<'props>, - @uncurry ('props, 'props) => bool, + ('props, 'props) => bool, ) => component<'props> = "memo" @module("react") external fragment: component = "Fragment" @@ -132,108 +132,93 @@ let lazy_ = load => lazy_(async () => {default: await load()}) * only way to safely have any type of state and be able to update it correctly. */ @module("react") -external useState: (@uncurry (unit => 'state)) => ('state, ('state => 'state) => unit) = "useState" +external useState: (unit => 'state) => ('state, ('state => 'state) => unit) = "useState" @module("react") -external useReducer: (@uncurry ('state, 'action) => 'state, 'state) => ('state, 'action => unit) = +external useReducer: (('state, 'action) => 'state, 'state) => ('state, 'action => unit) = "useReducer" @module("react") external useReducerWithMapState: ( - @uncurry ('state, 'action) => 'state, + ('state, 'action) => 'state, 'initialState, - @uncurry ('initialState => 'state), + 'initialState => 'state, ) => ('state, 'action => unit) = "useReducer" @module("react") -external useEffectOnEveryRender: (@uncurry (unit => option unit>)) => unit = "useEffect" +external useEffectOnEveryRender: (unit => option unit>) => unit = "useEffect" @module("react") -external useEffect: (@uncurry (unit => option unit>), 'deps) => unit = "useEffect" +external useEffect: (unit => option unit>, 'deps) => unit = "useEffect" @module("react") -external useEffect0: (@uncurry (unit => option unit>), @as(json`[]`) _) => unit = - "useEffect" +external useEffect0: (unit => option unit>, @as(json`[]`) _) => unit = "useEffect" @module("react") -external useEffect1: (@uncurry (unit => option unit>), array<'a>) => unit = "useEffect" +external useEffect1: (unit => option unit>, array<'a>) => unit = "useEffect" @module("react") -external useEffect2: (@uncurry (unit => option unit>), ('a, 'b)) => unit = "useEffect" +external useEffect2: (unit => option unit>, ('a, 'b)) => unit = "useEffect" @module("react") -external useEffect3: (@uncurry (unit => option unit>), ('a, 'b, 'c)) => unit = "useEffect" +external useEffect3: (unit => option unit>, ('a, 'b, 'c)) => unit = "useEffect" @module("react") -external useEffect4: (@uncurry (unit => option unit>), ('a, 'b, 'c, 'd)) => unit = - "useEffect" +external useEffect4: (unit => option unit>, ('a, 'b, 'c, 'd)) => unit = "useEffect" @module("react") -external useEffect5: (@uncurry (unit => option unit>), ('a, 'b, 'c, 'd, 'e)) => unit = - "useEffect" +external useEffect5: (unit => option unit>, ('a, 'b, 'c, 'd, 'e)) => unit = "useEffect" @module("react") -external useEffect6: (@uncurry (unit => option unit>), ('a, 'b, 'c, 'd, 'e, 'f)) => unit = - "useEffect" +external useEffect6: (unit => option unit>, ('a, 'b, 'c, 'd, 'e, 'f)) => unit = "useEffect" @module("react") -external useEffect7: ( - @uncurry (unit => option unit>), - ('a, 'b, 'c, 'd, 'e, 'f, 'g), -) => unit = "useEffect" +external useEffect7: (unit => option unit>, ('a, 'b, 'c, 'd, 'e, 'f, 'g)) => unit = + "useEffect" @module("react") -external useLayoutEffectOnEveryRender: (@uncurry (unit => option unit>)) => unit = - "useLayoutEffect" +external useLayoutEffectOnEveryRender: (unit => option unit>) => unit = "useLayoutEffect" @module("react") -external useLayoutEffect: (@uncurry (unit => option unit>), 'deps) => unit = - "useLayoutEffect" +external useLayoutEffect: (unit => option unit>, 'deps) => unit = "useLayoutEffect" @module("react") -external useLayoutEffect0: (@uncurry (unit => option unit>), @as(json`[]`) _) => unit = +external useLayoutEffect0: (unit => option unit>, @as(json`[]`) _) => unit = "useLayoutEffect" @module("react") -external useLayoutEffect1: (@uncurry (unit => option unit>), array<'a>) => unit = - "useLayoutEffect" +external useLayoutEffect1: (unit => option unit>, array<'a>) => unit = "useLayoutEffect" @module("react") -external useLayoutEffect2: (@uncurry (unit => option unit>), ('a, 'b)) => unit = - "useLayoutEffect" +external useLayoutEffect2: (unit => option unit>, ('a, 'b)) => unit = "useLayoutEffect" @module("react") -external useLayoutEffect3: (@uncurry (unit => option unit>), ('a, 'b, 'c)) => unit = - "useLayoutEffect" +external useLayoutEffect3: (unit => option unit>, ('a, 'b, 'c)) => unit = "useLayoutEffect" @module("react") -external useLayoutEffect4: (@uncurry (unit => option unit>), ('a, 'b, 'c, 'd)) => unit = +external useLayoutEffect4: (unit => option unit>, ('a, 'b, 'c, 'd)) => unit = "useLayoutEffect" @module("react") -external useLayoutEffect5: (@uncurry (unit => option unit>), ('a, 'b, 'c, 'd, 'e)) => unit = +external useLayoutEffect5: (unit => option unit>, ('a, 'b, 'c, 'd, 'e)) => unit = "useLayoutEffect" @module("react") -external useLayoutEffect6: ( - @uncurry (unit => option unit>), - ('a, 'b, 'c, 'd, 'e, 'f), -) => unit = "useLayoutEffect" +external useLayoutEffect6: (unit => option unit>, ('a, 'b, 'c, 'd, 'e, 'f)) => unit = + "useLayoutEffect" @module("react") -external useLayoutEffect7: ( - @uncurry (unit => option unit>), - ('a, 'b, 'c, 'd, 'e, 'f, 'g), -) => unit = "useLayoutEffect" +external useLayoutEffect7: (unit => option unit>, ('a, 'b, 'c, 'd, 'e, 'f, 'g)) => unit = + "useLayoutEffect" @module("react") -external useMemo: (@uncurry (unit => 'any), 'deps) => 'any = "useMemo" +external useMemo: (unit => 'any, 'deps) => 'any = "useMemo" @module("react") -external useMemo0: (@uncurry (unit => 'any), @as(json`[]`) _) => 'any = "useMemo" +external useMemo0: (unit => 'any, @as(json`[]`) _) => 'any = "useMemo" @module("react") -external useMemo1: (@uncurry (unit => 'any), array<'a>) => 'any = "useMemo" +external useMemo1: (unit => 'any, array<'a>) => 'any = "useMemo" @module("react") -external useMemo2: (@uncurry (unit => 'any), ('a, 'b)) => 'any = "useMemo" +external useMemo2: (unit => 'any, ('a, 'b)) => 'any = "useMemo" @module("react") -external useMemo3: (@uncurry (unit => 'any), ('a, 'b, 'c)) => 'any = "useMemo" +external useMemo3: (unit => 'any, ('a, 'b, 'c)) => 'any = "useMemo" @module("react") -external useMemo4: (@uncurry (unit => 'any), ('a, 'b, 'c, 'd)) => 'any = "useMemo" +external useMemo4: (unit => 'any, ('a, 'b, 'c, 'd)) => 'any = "useMemo" @module("react") -external useMemo5: (@uncurry (unit => 'any), ('a, 'b, 'c, 'd, 'e)) => 'any = "useMemo" +external useMemo5: (unit => 'any, ('a, 'b, 'c, 'd, 'e)) => 'any = "useMemo" @module("react") -external useMemo6: (@uncurry (unit => 'any), ('a, 'b, 'c, 'd, 'e, 'f)) => 'any = "useMemo" +external useMemo6: (unit => 'any, ('a, 'b, 'c, 'd, 'e, 'f)) => 'any = "useMemo" @module("react") -external useMemo7: (@uncurry (unit => 'any), ('a, 'b, 'c, 'd, 'e, 'f, 'g)) => 'any = "useMemo" +external useMemo7: (unit => 'any, ('a, 'b, 'c, 'd, 'e, 'f, 'g)) => 'any = "useMemo" @module("react") external useCallback: ('f, 'deps) => 'f = "useCallback" @@ -268,71 +253,57 @@ external useContext: Context.t<'any> => 'any = "useContext" @module("react") external useRef: 'value => ref<'value> = "useRef" @module("react") -external useImperativeHandleOnEveryRender: ( - Js.Nullable.t>, - @uncurry (unit => 'value), -) => unit = "useImperativeHandle" +external useImperativeHandleOnEveryRender: (Js.Nullable.t>, unit => 'value) => unit = + "useImperativeHandle" @module("react") -external useImperativeHandle: ( - Js.Nullable.t>, - @uncurry (unit => 'value), - 'deps, -) => unit = "useImperativeHandle" +external useImperativeHandle: (Js.Nullable.t>, unit => 'value, 'deps) => unit = + "useImperativeHandle" @module("react") external useImperativeHandle0: ( Js.Nullable.t>, - @uncurry (unit => 'value), + unit => 'value, @as(json`[]`) _, ) => unit = "useImperativeHandle" @module("react") -external useImperativeHandle1: ( - Js.Nullable.t>, - @uncurry (unit => 'value), - array<'a>, -) => unit = "useImperativeHandle" +external useImperativeHandle1: (Js.Nullable.t>, unit => 'value, array<'a>) => unit = + "useImperativeHandle" @module("react") -external useImperativeHandle2: ( - Js.Nullable.t>, - @uncurry (unit => 'value), - ('a, 'b), -) => unit = "useImperativeHandle" +external useImperativeHandle2: (Js.Nullable.t>, unit => 'value, ('a, 'b)) => unit = + "useImperativeHandle" @module("react") -external useImperativeHandle3: ( - Js.Nullable.t>, - @uncurry (unit => 'value), - ('a, 'b, 'c), -) => unit = "useImperativeHandle" +external useImperativeHandle3: (Js.Nullable.t>, unit => 'value, ('a, 'b, 'c)) => unit = + "useImperativeHandle" @module("react") external useImperativeHandle4: ( Js.Nullable.t>, - @uncurry (unit => 'value), + unit => 'value, ('a, 'b, 'c, 'd), ) => unit = "useImperativeHandle" @module("react") external useImperativeHandle5: ( Js.Nullable.t>, - @uncurry (unit => 'value), + unit => 'value, ('a, 'b, 'c, 'd, 'e), ) => unit = "useImperativeHandle" @module("react") external useImperativeHandle6: ( Js.Nullable.t>, - @uncurry (unit => 'value), + unit => 'value, ('a, 'b, 'c, 'd, 'e, 'f), ) => unit = "useImperativeHandle" @module("react") external useImperativeHandle7: ( Js.Nullable.t>, - @uncurry (unit => 'value), + unit => 'value, ('a, 'b, 'c, 'd, 'e, 'f, 'g), ) => unit = "useImperativeHandle" @@ -341,75 +312,65 @@ external useImperativeHandle7: ( @module("react") external useDeferredValue: 'value => 'value = "useDeferredValue" @module("react") -external useTransition: unit => (bool, (. unit => unit) => unit) = "useTransition" +external useTransition: unit => (bool, (unit => unit) => unit) = "useTransition" @module("react") -external useInsertionEffectOnEveryRender: (@uncurry (unit => option unit>)) => unit = +external useInsertionEffectOnEveryRender: (unit => option unit>) => unit = "useInsertionEffect" @module("react") -external useInsertionEffect: (@uncurry (unit => option unit>), 'deps) => unit = - "useInsertionEffect" +external useInsertionEffect: (unit => option unit>, 'deps) => unit = "useInsertionEffect" @module("react") -external useInsertionEffect0: (@uncurry (unit => option unit>), @as(json`[]`) _) => unit = +external useInsertionEffect0: (unit => option unit>, @as(json`[]`) _) => unit = "useInsertionEffect" @module("react") -external useInsertionEffect1: (@uncurry (unit => option unit>), array<'a>) => unit = +external useInsertionEffect1: (unit => option unit>, array<'a>) => unit = "useInsertionEffect" @module("react") -external useInsertionEffect2: (@uncurry (unit => option unit>), ('a, 'b)) => unit = +external useInsertionEffect2: (unit => option unit>, ('a, 'b)) => unit = "useInsertionEffect" @module("react") -external useInsertionEffect3: (@uncurry (unit => option unit>), ('a, 'b, 'c)) => unit = +external useInsertionEffect3: (unit => option unit>, ('a, 'b, 'c)) => unit = "useInsertionEffect" @module("react") -external useInsertionEffect4: (@uncurry (unit => option unit>), ('a, 'b, 'c, 'd)) => unit = +external useInsertionEffect4: (unit => option unit>, ('a, 'b, 'c, 'd)) => unit = "useInsertionEffect" @module("react") -external useInsertionEffect5: ( - @uncurry (unit => option unit>), - ('a, 'b, 'c, 'd, 'e), -) => unit = "useInsertionEffect" +external useInsertionEffect5: (unit => option unit>, ('a, 'b, 'c, 'd, 'e)) => unit = + "useInsertionEffect" @module("react") -external useInsertionEffect6: ( - @uncurry (unit => option unit>), - ('a, 'b, 'c, 'd, 'e, 'f), -) => unit = "useInsertionEffect" +external useInsertionEffect6: (unit => option unit>, ('a, 'b, 'c, 'd, 'e, 'f)) => unit = + "useInsertionEffect" @module("react") -external useInsertionEffect7: ( - @uncurry (unit => option unit>), - ('a, 'b, 'c, 'd, 'e, 'f, 'g), -) => unit = "useInsertionEffect" +external useInsertionEffect7: (unit => option unit>, ('a, 'b, 'c, 'd, 'e, 'f, 'g)) => unit = + "useInsertionEffect" @module("react") external useSyncExternalStore: ( - ~subscribe: @uncurry ((unit => unit) => (. unit) => unit), - ~getSnapshot: @uncurry (unit => 'state), + ~subscribe: (unit => unit) => unit => unit, + ~getSnapshot: unit => 'state, ) => 'state = "useSyncExternalStore" @module("react") external useSyncExternalStoreWithServerSnapshot: ( - ~subscribe: @uncurry ((unit => unit) => (. unit) => unit), - ~getSnapshot: @uncurry (unit => 'state), - ~getServerSnapshot: @uncurry (unit => 'state), + ~subscribe: (unit => unit) => unit => unit, + ~getSnapshot: unit => 'state, + ~getServerSnapshot: unit => 'state, ) => 'state = "useSyncExternalStore" module Uncurried = { @module("react") - external useState: (@uncurry (unit => 'state)) => ('state, (. 'state => 'state) => unit) = - "useState" + external useState: (unit => 'state) => ('state, ('state => 'state) => unit) = "useState" @module("react") - external useReducer: ( - @uncurry ('state, 'action) => 'state, - 'state, - ) => ('state, (. 'action) => unit) = "useReducer" + external useReducer: (('state, 'action) => 'state, 'state) => ('state, 'action => unit) = + "useReducer" @module("react") external useReducerWithMapState: ( - @uncurry ('state, 'action) => 'state, + ('state, 'action) => 'state, 'initialState, - @uncurry ('initialState => 'state), - ) => ('state, (. 'action) => unit) = "useReducer" + 'initialState => 'state, + ) => ('state, 'action => unit) = "useReducer" @module("react") external useCallback: ('f, 'deps) => 'f = "useCallback" diff --git a/src/ReactTestUtils.bs.js b/src/ReactTestUtils.bs.js index 9913094..7ddadac 100644 --- a/src/ReactTestUtils.bs.js +++ b/src/ReactTestUtils.bs.js @@ -1,20 +1,19 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; -var Curry = require("rescript/lib/js/curry.js"); var Caml_option = require("rescript/lib/js/caml_option.js"); var TestUtils = require("react-dom/test-utils"); function act(func) { var reactFunc = function () { - Curry._1(func, undefined); + func(); }; TestUtils.act(reactFunc); } function actAsync(func) { return TestUtils.act(function () { - return Curry._1(func, undefined); + return func(); }); } diff --git a/src/ReactTestUtils.res b/src/ReactTestUtils.res index 5b3bc09..a6c2b5e 100644 --- a/src/ReactTestUtils.res +++ b/src/ReactTestUtils.res @@ -3,10 +3,10 @@ type undefined = Js.undefined let undefined: undefined = Js.Undefined.empty @module("react-dom/test-utils") -external reactAct: ((. unit) => undefined) => unit = "act" +external reactAct: (unit => undefined) => unit = "act" let act: (unit => unit) => unit = func => { - let reactFunc = (. ()) => { + let reactFunc = () => { func() undefined } @@ -14,10 +14,10 @@ let act: (unit => unit) => unit = func => { } @module("react-dom/test-utils") -external reactActAsync: ((. unit) => Js.Promise.t<'a>) => Js.Promise.t = "act" +external reactActAsync: (unit => Js.Promise.t<'a>) => Js.Promise.t = "act" let actAsync = func => { - let reactFunc = (. ()) => func() + let reactFunc = () => func() reactActAsync(reactFunc) } diff --git a/src/RescriptReactRouter.bs.js b/src/RescriptReactRouter.bs.js index 3ca19e8..eb542b6 100644 --- a/src/RescriptReactRouter.bs.js +++ b/src/RescriptReactRouter.bs.js @@ -1,7 +1,6 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; -var Curry = require("rescript/lib/js/curry.js"); var React = require("react"); var Caml_option = require("rescript/lib/js/caml_option.js"); @@ -57,7 +56,7 @@ function path(serverUrlString, param) { } } -function hash(param) { +function hash() { var $$window = globalThis.window; if ($$window === undefined) { return ""; @@ -160,12 +159,12 @@ function url(serverUrlString, param) { function watchUrl(callback) { var $$window = globalThis.window; if ($$window === undefined) { - return function (param) { + return function () { }; } - var watcherID = function (param) { - Curry._1(callback, url(undefined, undefined)); + var watcherID = function () { + callback(url(undefined, undefined)); }; Caml_option.valFromOption($$window).addEventListener("popstate", watcherID); return watcherID; @@ -181,7 +180,7 @@ function unwatchUrl(watcherID) { } function useUrl(serverUrl, param) { - var match = React.useState(function (param) { + var match = React.useState(function () { if (serverUrl !== undefined) { return serverUrl; } else { @@ -190,19 +189,19 @@ function useUrl(serverUrl, param) { }); var setUrl = match[1]; var url$1 = match[0]; - React.useEffect((function (param) { + React.useEffect((function () { var watcherId = watchUrl(function (url) { - Curry._1(setUrl, (function (param) { - return url; - })); + setUrl(function (param) { + return url; + }); }); var newUrl = url(undefined, undefined); if (urlNotEqual(newUrl, url$1)) { - Curry._1(setUrl, (function (param) { - return newUrl; - })); + setUrl(function (param) { + return newUrl; + }); } - return (function (param) { + return (function () { unwatchUrl(watcherId); }); }), []); From 78c2fcbb7a1179ecf104c5081924c454c9699d26 Mon Sep 17 00:00:00 2001 From: Christoph Knittel Date: Sun, 4 May 2025 11:50:40 +0200 Subject: [PATCH 29/34] React 19 APIs (#133) * React.promise * React.useTransition * React.useActionState * React.useOptimistic * React.use * React.act * React.useDeferredValue now takes initial value * ReactDOM: ref cleanup function * ReactDOM: Resource Preloading APIse * ReactDOM.useFormStatus * JS output changes * Add external for basic support for formAction * Add `usePromise` for `use(promise)` `use(context)` seems to exactly replicate the `useContext(context)` logic, and we want to maximize retro-compability (ie. not switch from `useContext` to `use` for that under the hood). simply adding `usePromise(promise)` seems to be the simplest, least invasive way to add the functionality. * proposal: make FormData more usable to get values this **kinda** goes against the zero-cost philosophy, but I don't see a world where users would not have to reimplement those. * useOptimistic optionnal updateFn * dom static prerender and prerenderToNodeStream --------- Co-authored-by: Matthias Le Brun Co-authored-by: Freddy Harris --- src/React.bs.js | 3 - src/React.res | 42 ++++++++- src/ReactDOM.bs.js | 43 +++++++++- src/ReactDOM.res | 178 ++++++++++++++++++++++++++++++++++++++- src/ReactDOMStatic.bs.js | 2 + src/ReactDOMStatic.res | 30 +++++++ 6 files changed, 288 insertions(+), 10 deletions(-) create mode 100644 src/ReactDOMStatic.bs.js create mode 100644 src/ReactDOMStatic.res diff --git a/src/React.bs.js b/src/React.bs.js index c2471b6..ef827dd 100644 --- a/src/React.bs.js +++ b/src/React.bs.js @@ -3,8 +3,6 @@ var React = require("react"); -var Ref = {}; - var Children = {}; var Context = {}; @@ -25,7 +23,6 @@ function lazy_(load) { var Uncurried = {}; -exports.Ref = Ref; exports.Children = Children; exports.Context = Context; exports.Fragment = Fragment; diff --git a/src/React.res b/src/React.res index 0beaa59..f1f6831 100644 --- a/src/React.res +++ b/src/React.res @@ -5,6 +5,7 @@ type element = Jsx.element external float: float => element = "%identity" external int: int => element = "%identity" external string: string => element = "%identity" +external promise: promise => element = "%identity" external array: array => element = "%identity" @@ -250,6 +251,9 @@ external useCallback7: ('callback, ('a, 'b, 'c, 'd, 'e, 'f, 'g)) => 'callback = @module("react") external useContext: Context.t<'any> => 'any = "useContext" +@module("react") +external usePromise: promise<'a> => 'a = "use" + @module("react") external useRef: 'value => ref<'value> = "useRef" @module("react") @@ -309,10 +313,9 @@ external useImperativeHandle7: ( @module("react") external useId: unit => string = "useId" -@module("react") external useDeferredValue: 'value => 'value = "useDeferredValue" - +/** `useDeferredValue` is a React Hook that lets you defer updating a part of the UI. */ @module("react") -external useTransition: unit => (bool, (unit => unit) => unit) = "useTransition" +external useDeferredValue: ('value, ~initialValue: 'value=?) => 'value = "useDeferredValue" @module("react") external useInsertionEffectOnEveryRender: (unit => option unit>) => unit = @@ -405,3 +408,36 @@ external setDisplayName: (component<'props>, string) => unit = "displayName" @get @return(nullable) external displayName: component<'props> => option = "displayName" + +// Actions + +type transitionFunction = unit => promise + +type transitionStartFunction = transitionFunction => unit + +/** `useTransition` is a React Hook that lets you render a part of the UI in the background. */ +@module("react") +external useTransition: unit => (bool, transitionStartFunction) = "useTransition" + +type action<'state, 'payload> = ('state, 'payload) => promise<'state> + +type formAction<'formData> = 'formData => promise + +/** `useActionState` is a Hook that allows you to update state based on the result of a form action. */ +@module("react") +external useActionState: ( + action<'state, 'payload>, + 'state, + ~permalink: string=?, +) => ('state, formAction<'payload>, bool) = "useActionState" + +/** `useOptimistic` is a React Hook that lets you optimistically update the UI. */ +@module("react") +external useOptimistic: ( + 'state, + ~updateFn: ('state, 'action) => 'state=?, +) => ('state, 'action => unit) = "useOptimistic" + +/** `act` is a test helper to apply pending React updates before making assertions. */ +@module("react") +external act: (unit => promise) => promise = "act" diff --git a/src/ReactDOM.bs.js b/src/ReactDOM.bs.js index b65084d..fa51640 100644 --- a/src/ReactDOM.bs.js +++ b/src/ReactDOM.bs.js @@ -1,6 +1,7 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +var Caml_option = require("rescript/lib/js/caml_option.js"); var Root = {}; @@ -8,14 +9,50 @@ var Client = { Root: Root }; -var Ref = {}; +function getString(formData, name) { + var value = formData.get(name); + if (!(value == null) && typeof value === "string") { + return Caml_option.some(value); + } + +} + +function getFile(formData, name) { + var value = formData.get(name); + if (!(value == null) && typeof value !== "string") { + return Caml_option.some(value); + } + +} + +function getAll(t, string) { + return t.getAll(string).map(function (value) { + if (typeof value === "string") { + return { + TAG: "String", + _0: value + }; + } else { + return { + TAG: "File", + _0: value + }; + } + }); +} -var Props = {}; +var $$FormData = { + getString: getString, + getFile: getFile, + getAll: getAll +}; + +var Ref = {}; var Style; exports.Client = Client; +exports.$$FormData = $$FormData; exports.Ref = Ref; -exports.Props = Props; exports.Style = Style; /* No side effect */ diff --git a/src/ReactDOM.res b/src/ReactDOM.res index 04c39c2..fbd564b 100644 --- a/src/ReactDOM.res +++ b/src/ReactDOM.res @@ -25,6 +25,52 @@ module Client = { external hydrateRoot: (Dom.element, React.element) => Root.t = "hydrateRoot" } +// Very rudimentary form data bindings +module FormData = { + type t + type file + + type formValue = + | String(string) + | File(file) + + @new external make: unit => t = "FormData" + + @send external append: (t, string, ~filename: string=?) => unit = "append" + @send external delete: (t, string) => unit = "delete" + @return(nullable) @send external getUnsafe: (t, string) => option<'a> = "get" + @send external getAllUnsafe: (t, string) => array<'a> = "getAll" + + let getString = (formData, name) => { + switch formData->getUnsafe(name) { + | Some(value) => Js.typeof(value) === "string" ? Some(value) : None + | _ => None + } + } + + external _asFile: 'a => file = "%identity" + + let getFile = (formData, name) => { + switch formData->getUnsafe(name) { + | Some(value) => Js.typeof(value) === "string" ? None : Some(value->_asFile) + | _ => None + } + } + + let getAll = (t, string) => { + t + ->getAllUnsafe(string) + ->Js.Array2.map(value => { + Js.typeof(value) === "string" ? String(value) : File(value->_asFile) + }) + } + + @send external set: (string, string) => unit = "set" + @send external has: string => bool = "has" + // @send external keys: t => Iterator.t = "keys"; + // @send external values: t => Iterator.t = "values"; +} + @module("react-dom") external createPortal: (React.element, Dom.element) => React.element = "createPortal" @@ -37,12 +83,142 @@ type domRef = JsxDOM.domRef module Ref = { type t = domRef type currentDomRef = React.ref> - type callbackDomRef = Js.nullable => unit + type callbackDomRef = Js.nullable => option unit> external domRef: currentDomRef => domRef = "%identity" external callbackDomRef: callbackDomRef => domRef = "%identity" } +// Hooks + +type formStatus<'state> = { + /** If true, this means the parent
is pending submission. Otherwise, false. */ + pending: bool, + /** An object implementing the FormData interface that contains the data the parent is submitting. If there is no active submission or no parent , it will be null. */ + data: FormData.t, + /** This represents whether the parent is submitting with either a GET or POST HTTP method. By default, a will use the GET method and can be specified by the method property. */ + method: [#get | #post], + /** A reference to the function passed to the action prop on the parent . If there is no parent , the property is null. If there is a URI value provided to the action prop, or no action prop specified, status.action will be null. */ + action: React.action<'state, FormData.t>, +} + +external formAction: React.formAction => string = "%identity" + +/** `useFormStatus` is a Hook that gives you status information of the last form submission. */ +@module("react-dom") +external useFormStatus: unit => formStatus<'state> = "useFormStatus" + +// Resource Preloading APIs + +/** The CORS policy to use. */ +type crossOrigin = [ + | #anonymous + | #"use-credentials" +] + +/** The Referrer header to send when fetching. */ +type referrerPolicy = [ + | #"referrer-when-downgrade" + | #"no-referrer" + | #origin + | #"origin-when-cross-origin" + | #"unsafe-url" +] + +/** Suggests a relative priority for fetching the resource. */ +type fetchPriority = [#auto | #high | #low] + +/** `prefetchDNS` lets you eagerly look up the IP of a server that you expect to load resources from. */ +@module("react-dom") +external prefetchDNS: string => unit = "prefetchDNS" + +/** `preconnect` lets you eagerly connect to a server that you expect to load resources from. */ +@module("react-dom") +external preconnect: string => unit = "preconnect" + +type preloadOptions = { + /** The type of resource. */ + @as("as") + as_: [ + | #audio + | #document + | #embed + | #fetch + | #font + | #image + | #object + | #script + | #style + | #track + | #video + | #worker + ], + /** The CORS policy to use. It is required when as is set to "fetch". */ + crossOrigin?: crossOrigin, + /** The Referrer header to send when fetching. */ + referrerPolicy?: referrerPolicy, + /** A cryptographic hash of the resource, to verify its authenticity. */ + integrity?: string, + /** The MIME type of the resource. */ + @as("type") + type_?: string, + /** A cryptographic nonce to allow the resource when using a strict Content Security Policy. */ + nonce?: string, + /** Suggests a relative priority for fetching the resource. */ + fetchPriority?: fetchPriority, + /** For use only with as: "image". Specifies the source set of the image. */ + imageSrcSet?: string, + /** For use only with as: "image". Specifies the sizes of the image. */ + imageSizes?: string, +} + +/** `preload` lets you eagerly fetch a resource such as a stylesheet, font, or external script that you expect to use. */ +@module("react-dom") +external preload: (string, preloadOptions) => unit = "preload" + +type preloadModuleOptions = { + /** The type of resource. */ + @as("as") + as_: [#script], + /** The CORS policy to use. It is required when as is set to "fetch". */ + crossOrigin?: crossOrigin, + /** A cryptographic hash of the resource, to verify its authenticity. */ + integrity?: string, + /** A cryptographic nonce to allow the resource when using a strict Content Security Policy. */ + nonce?: string, +} + +/** `preloadModule` lets you eagerly fetch an ESM module that you expect to use. */ +@module("react-dom") +external preloadModule: (string, preloadModuleOptions) => unit = "preloadModule" + +type preinitOptions = { + /** The type of resource. */ + @as("as") + as_: [#script | #style], + /** Required with stylesheets. Says where to insert the stylesheet relative to others. Stylesheets with higher precedence can override those with lower precedence. */ + precedence?: [#reset | #low | #medium | #high], + /** The CORS policy to use. It is required when as is set to "fetch". */ + crossOrigin?: crossOrigin, + /** The Referrer header to send when fetching. */ + referrerPolicy?: referrerPolicy, + /** A cryptographic hash of the resource, to verify its authenticity. */ + integrity?: string, + nonce?: string, + /** Suggests a relative priority for fetching the resource. */ + fetchPriority?: fetchPriority, +} + +/** `preinit` lets you eagerly fetch and evaluate a stylesheet or external script. */ +@module("react-dom") +external preinit: (string, preinitOptions) => unit = "preinit" + +/** To preinit an ESM module, call the `preinitModule` function from react-dom. */ +@module("react-dom") +external preinitModule: (string, preloadModuleOptions) => unit = "preinitModule" + +// Runtime + type domProps = JsxDOM.domProps @variadic @module("react") diff --git a/src/ReactDOMStatic.bs.js b/src/ReactDOMStatic.bs.js new file mode 100644 index 0000000..d856702 --- /dev/null +++ b/src/ReactDOMStatic.bs.js @@ -0,0 +1,2 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE +/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ diff --git a/src/ReactDOMStatic.res b/src/ReactDOMStatic.res new file mode 100644 index 0000000..7988fbb --- /dev/null +++ b/src/ReactDOMStatic.res @@ -0,0 +1,30 @@ +type abortSignal // WebAPI.EventAPI.abortSignal + +type nodeStream // NodeJs.Stream.stream + +type readableStream // WebAPI.FileAPI.readableStream + +type prerenderOptions<'error> = { + bootstrapScriptContent?: string, + bootstrapScripts?: array, + bootstrapModules?: array, + identifierPrefix?: string, + namespaceURI?: string, + onError?: 'error => unit, + progressiveChunkSize?: int, + signal?: abortSignal, +} + +type staticResult = {prelude: readableStream} + +@module("react-dom/static") +external prerender: (React.element, ~options: prerenderOptions<'error>=?) => promise = + "prerender" + +type staticResultNode = {prelude: nodeStream} + +@module("react-dom/static") +external prerenderToNodeStream: ( + React.element, + ~options: prerenderOptions<'error>=?, +) => promise = "prerenderToNodeStream" From caed8c9c74359daba2b8ae70cdfe594ec190325e Mon Sep 17 00:00:00 2001 From: Christoph Knittel Date: Sun, 4 May 2025 17:38:27 +0200 Subject: [PATCH 30/34] Version 0.14.0-rc.1, update README (#139) * Version 0.14.0-rc.1 * Update README * Bump react dev/peer dependencies to 19 --- README.md | 6 +-- package-lock.json | 105 ++++++++++++++-------------------------------- package.json | 10 ++--- 3 files changed, 40 insertions(+), 81 deletions(-) diff --git a/README.md b/README.md index 5adebb1..1f5761d 100644 --- a/README.md +++ b/README.md @@ -9,9 +9,9 @@ | @rescript/react | ReScript | ReactJS | Documentation | | --------------- | ---------------------------------- | ------- | ----------------------------------------------------------------- | -| next (master) | 11.0+ (JSX4 + uncurried mode only) | 18.0.0+ | | -| 0.12.x, 0.13.x | 11.0+ | 18.0.0+ | [Link](https://rescript-lang.org/docs/react/latest/introduction) | -| 0.11.0 | 10.1 | 18.0.0+ | [Link](https://rescript-lang.org/docs/react/v0.11.0/introduction) | +| 0.14.x | 11.0+ (JSX4 + uncurried mode only) | 19 | | +| 0.12.x, 0.13.x | 11.0+ | 18 | [Link](https://rescript-lang.org/docs/react/latest/introduction) | +| 0.11.0 | 10.1 | 18 | [Link](https://rescript-lang.org/docs/react/v0.11.0/introduction) | | 0.10.3 | 8.3 | 16.8.1+ | [Link](https://rescript-lang.org/docs/react/v0.10.0/introduction) | ### Development diff --git a/package-lock.json b/package-lock.json index 99bed8f..26294ad 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,61 +1,44 @@ { "name": "@rescript/react", - "version": "0.13.1", + "version": "0.14.0-rc.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@rescript/react", - "version": "0.13.1", + "version": "0.14.0-rc.1", "license": "MIT", "devDependencies": { - "react": "^18.2.0", - "react-dom": "^18.2.0", + "react": "^19.1.0", + "react-dom": "^19.1.0", "rescript": "^11.0.0" }, "peerDependencies": { - "react": ">=18.0.0", - "react-dom": ">=18.0.0" - } - }, - "node_modules/js-tokens": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", - "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", - "dev": true - }, - "node_modules/loose-envify": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", - "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", - "dev": true, - "dependencies": { - "js-tokens": "^3.0.0 || ^4.0.0" + "react": ">=19.0.0", + "react-dom": ">=19.0.0" } }, "node_modules/react": { - "version": "18.2.0", - "resolved": "https://registry.npmjs.org/react/-/react-18.2.0.tgz", - "integrity": "sha512-/3IjMdb2L9QbBdWiW5e3P2/npwMBaU9mHCSCUzNln0ZCYbcfTsGbTJrU/kGemdH2IWmB2ioZ+zkxtmq6g09fGQ==", + "version": "19.1.0", + "resolved": "https://registry.npmjs.org/react/-/react-19.1.0.tgz", + "integrity": "sha512-FS+XFBNvn3GTAWq26joslQgWNoFu08F4kl0J4CgdNKADkdSGXQyTCnKteIAJy96Br6YbpEU1LSzV5dYtjMkMDg==", "dev": true, - "dependencies": { - "loose-envify": "^1.1.0" - }, + "license": "MIT", "engines": { "node": ">=0.10.0" } }, "node_modules/react-dom": { - "version": "18.2.0", - "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.2.0.tgz", - "integrity": "sha512-6IMTriUmvsjHUjNtEDudZfuDQUoWXVxKHhlEGSk81n4YFS+r/Kl99wXiwlVXtPBtJenozv2P+hxDsw9eA7Xo6g==", + "version": "19.1.0", + "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.1.0.tgz", + "integrity": "sha512-Xs1hdnE+DyKgeHJeJznQmYMIBG3TKIHJJT95Q58nHLSrElKlGQqDTR2HQ9fx5CN/Gk6Vh/kupBTDLU11/nDk/g==", "dev": true, + "license": "MIT", "dependencies": { - "loose-envify": "^1.1.0", - "scheduler": "^0.23.0" + "scheduler": "^0.26.0" }, "peerDependencies": { - "react": "^18.2.0" + "react": "^19.1.0" } }, "node_modules/rescript": { @@ -74,48 +57,27 @@ } }, "node_modules/scheduler": { - "version": "0.23.0", - "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.23.0.tgz", - "integrity": "sha512-CtuThmgHNg7zIZWAXi3AsyIzA3n4xx7aNyjwC2VJldO2LMVDhFK+63xGqq6CsJH4rTAt6/M+N4GhZiDYPx9eUw==", + "version": "0.26.0", + "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.26.0.tgz", + "integrity": "sha512-NlHwttCI/l5gCPR3D1nNXtWABUmBwvZpEQiD4IXSbIDq8BzLIK/7Ir5gTFSGZDUu37K5cMNp0hFtzO38sC7gWA==", "dev": true, - "dependencies": { - "loose-envify": "^1.1.0" - } + "license": "MIT" } }, "dependencies": { - "js-tokens": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", - "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", - "dev": true - }, - "loose-envify": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", - "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", - "dev": true, - "requires": { - "js-tokens": "^3.0.0 || ^4.0.0" - } - }, "react": { - "version": "18.2.0", - "resolved": "https://registry.npmjs.org/react/-/react-18.2.0.tgz", - "integrity": "sha512-/3IjMdb2L9QbBdWiW5e3P2/npwMBaU9mHCSCUzNln0ZCYbcfTsGbTJrU/kGemdH2IWmB2ioZ+zkxtmq6g09fGQ==", - "dev": true, - "requires": { - "loose-envify": "^1.1.0" - } + "version": "19.1.0", + "resolved": "https://registry.npmjs.org/react/-/react-19.1.0.tgz", + "integrity": "sha512-FS+XFBNvn3GTAWq26joslQgWNoFu08F4kl0J4CgdNKADkdSGXQyTCnKteIAJy96Br6YbpEU1LSzV5dYtjMkMDg==", + "dev": true }, "react-dom": { - "version": "18.2.0", - "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.2.0.tgz", - "integrity": "sha512-6IMTriUmvsjHUjNtEDudZfuDQUoWXVxKHhlEGSk81n4YFS+r/Kl99wXiwlVXtPBtJenozv2P+hxDsw9eA7Xo6g==", + "version": "19.1.0", + "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.1.0.tgz", + "integrity": "sha512-Xs1hdnE+DyKgeHJeJznQmYMIBG3TKIHJJT95Q58nHLSrElKlGQqDTR2HQ9fx5CN/Gk6Vh/kupBTDLU11/nDk/g==", "dev": true, "requires": { - "loose-envify": "^1.1.0", - "scheduler": "^0.23.0" + "scheduler": "^0.26.0" } }, "rescript": { @@ -125,13 +87,10 @@ "dev": true }, "scheduler": { - "version": "0.23.0", - "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.23.0.tgz", - "integrity": "sha512-CtuThmgHNg7zIZWAXi3AsyIzA3n4xx7aNyjwC2VJldO2LMVDhFK+63xGqq6CsJH4rTAt6/M+N4GhZiDYPx9eUw==", - "dev": true, - "requires": { - "loose-envify": "^1.1.0" - } + "version": "0.26.0", + "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.26.0.tgz", + "integrity": "sha512-NlHwttCI/l5gCPR3D1nNXtWABUmBwvZpEQiD4IXSbIDq8BzLIK/7Ir5gTFSGZDUu37K5cMNp0hFtzO38sC7gWA==", + "dev": true } } } diff --git a/package.json b/package.json index 6668fec..3dfa787 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@rescript/react", - "version": "0.13.1", + "version": "0.14.0-rc.1", "description": "React bindings for ReScript", "files": [ "README.md", @@ -28,12 +28,12 @@ }, "homepage": "https://rescript-lang.org/docs/react/latest/introduction", "devDependencies": { - "react": "^18.2.0", - "react-dom": "^18.2.0", + "react": "^19.1.0", + "react-dom": "^19.1.0", "rescript": "^11.0.0" }, "peerDependencies": { - "react": ">=18.0.0", - "react-dom": ">=18.0.0" + "react": ">=19.0.0", + "react-dom": ">=19.0.0" } } From a59d15d57751b2478f3f02d11e6de5911cdc53b0 Mon Sep 17 00:00:00 2001 From: Christoph Knittel Date: Sun, 4 May 2025 18:00:39 +0200 Subject: [PATCH 31/34] Update CHANGELOG (#140) --- CHANGELOG.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 516f062..7c22049 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,18 @@ > - :house: [Internal] > - :nail_care: [Polish] +## 0.14.0-rc.1 + +#### :rocket: New Feature + +- Bindings for new React 19 APIs. https://github.com/rescript-lang/rescript-react/pull/133 + +#### :boom: Breaking Change + +- Bumped React peer dependency to 19.0. https://github.com/rescript-lang/rescript-react/pull/139 +- Removed legacy JSX v3 modules and deprecated functions. https://github.com/rescript-lang/rescript-react/pull/129 +- Removed support for curried mode. https://github.com/rescript-lang/rescript-react/pull/131 + ## 0.13.1 #### :boom: Breaking Change From 056ce1c687d591876b0acc86dc3f02627b3d4768 Mon Sep 17 00:00:00 2001 From: Christoph Knittel Date: Wed, 4 Jun 2025 09:27:52 +0200 Subject: [PATCH 32/34] @ocaml.doc -> proper doc comments (#141) --- src/RescriptReactErrorBoundary.res | 4 ++-- src/RescriptReactErrorBoundary.resi | 4 ++-- src/RescriptReactRouter.resi | 22 ++++++++-------------- 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/src/RescriptReactErrorBoundary.res b/src/RescriptReactErrorBoundary.res index 3caa0e8..cb00d25 100644 --- a/src/RescriptReactErrorBoundary.res +++ b/src/RescriptReactErrorBoundary.res @@ -1,8 +1,8 @@ -@ocaml.doc(" +/*** * Important note on this module: * As soon as React provides a mechanism for error-catching using functional component, * this is likely to be deprecated and/or move to user space. - ") + */ type info = {componentStack: string} type params<'error> = { diff --git a/src/RescriptReactErrorBoundary.resi b/src/RescriptReactErrorBoundary.resi index 3bc8071..0ebdbc8 100644 --- a/src/RescriptReactErrorBoundary.resi +++ b/src/RescriptReactErrorBoundary.resi @@ -1,8 +1,8 @@ -@ocaml.doc(" +/*** * Important note on this module: * As soon as React provides a mechanism for error-catching using functional component, * this is likely to be deprecated and/or move to user space. - ") + */ type info = {componentStack: string} type params<'error> = { diff --git a/src/RescriptReactRouter.resi b/src/RescriptReactRouter.resi index 654235e..25357f3 100644 --- a/src/RescriptReactRouter.resi +++ b/src/RescriptReactRouter.resi @@ -1,11 +1,7 @@ -@ocaml.doc( - "update the url with the string path. Example: `push(\"/book/1\")`, `push(\"/books#title\")` " -) +/** update the url with the string path. Example: `push(\"/book/1\")`, `push(\"/books#title\")` */ let push: string => unit -@ocaml.doc( - "update the url with the string path. modifies the current history entry instead of creating a new one. Example: `replace(\"/book/1\")`, `replace(\"/books#title\")` " -) +/** update the url with the string path. modifies the current history entry instead of creating a new one. Example: `replace(\"/book/1\")`, `replace(\"/books#title\")` */ let replace: string => unit type watcherID type url = { @@ -17,15 +13,13 @@ type url = { search: string, } -@ocaml.doc( - "start watching for URL changes. Returns a subscription token. Upon url change, calls the callback and passes it the url record " -) +/** start watching for URL changes. Returns a subscription token. Upon url change, calls the callback and passes it the url record */ let watchUrl: (url => unit) => watcherID -@ocaml.doc(" stop watching for URL changes ") +/** stop watching for URL changes */ let unwatchUrl: watcherID => unit -@ocaml.doc("this is marked as \"dangerous\" because you technically shouldn't +/** this is marked as \"dangerous\" because you technically shouldn't be accessing the URL outside of watchUrl's callback; you'd read a potentially stale url, instead of the fresh one inside watchUrl. @@ -37,10 +31,10 @@ let unwatchUrl: watcherID => unit So, the correct (and idiomatic) usage of this helper is to only use it in a component that's also subscribed to watchUrl. Please see https://github.com/reasonml-community/reason-react-example/blob/master/src/todomvc/TodoItem.re - for an example.") + for an example. */ let dangerouslyGetInitialUrl: (~serverUrlString: string=?, unit) => url -@ocaml.doc("hook for watching url changes. +/** hook for watching url changes. * serverUrl is used for ssr. it allows you to specify the url without relying on browser apis existing/working as expected - ") + */ let useUrl: (~serverUrl: url=?, unit) => url From 71c239a206b60f6953b4ec79ce48ccb7ebc3048d Mon Sep 17 00:00:00 2001 From: Stephanos Komnenos Date: Thu, 3 Jul 2025 15:00:04 +0800 Subject: [PATCH 33/34] Keep `useTransition` backward compatibility and add `startTransition` (#142) * Keep `useTransition` backward compatibility * Add `startTransition` --- src/React.res | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/React.res b/src/React.res index f1f6831..0676012 100644 --- a/src/React.res +++ b/src/React.res @@ -411,13 +411,23 @@ external displayName: component<'props> => option = "displayName" // Actions -type transitionFunction = unit => promise - +type transitionFunction = unit => unit type transitionStartFunction = transitionFunction => unit +type transitionFunctionAsync = unit => promise +type transitionStartFunctionAsync = transitionFunctionAsync => unit + +/** `startTransition` lets you render a part of the UI in the background. */ +@module("react") +external startTransition: transitionStartFunction = "startTransition" +@module("react") +external startTransitionAsync: transitionStartFunctionAsync = "startTransition" + /** `useTransition` is a React Hook that lets you render a part of the UI in the background. */ @module("react") external useTransition: unit => (bool, transitionStartFunction) = "useTransition" +@module("react") +external useTransitionAsync: unit => (bool, transitionStartFunctionAsync) = "useTransition" type action<'state, 'payload> = ('state, 'payload) => promise<'state> From c8c3d05724e767a3bfe22173dcf3e98140e1a6ca Mon Sep 17 00:00:00 2001 From: Christoph Knittel Date: Tue, 22 Jul 2025 10:03:25 +0200 Subject: [PATCH 34/34] Version 0.14.0 (#144) --- CHANGELOG.md | 6 ++++++ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c22049..6817d6e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,12 @@ > - :house: [Internal] > - :nail_care: [Polish] +## 0.14.0 + +#### :nail_care: Polish + +- Keep `useTransition` backward compatibility and add `startTransition`. https://github.com/rescript-lang/rescript-react/pull/142 + ## 0.14.0-rc.1 #### :rocket: New Feature diff --git a/package-lock.json b/package-lock.json index 26294ad..ce2aa29 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@rescript/react", - "version": "0.14.0-rc.1", + "version": "0.14.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@rescript/react", - "version": "0.14.0-rc.1", + "version": "0.14.0", "license": "MIT", "devDependencies": { "react": "^19.1.0", diff --git a/package.json b/package.json index 3dfa787..11c8dda 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@rescript/react", - "version": "0.14.0-rc.1", + "version": "0.14.0", "description": "React bindings for ReScript", "files": [ "README.md",