@mittwald/flow-react-components 1.2.0-next.31 → 1.2.0-next.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/AGENTS.md CHANGED
@@ -158,6 +158,15 @@ Remote generation details:
158
158
  output, because the host has to call it: that needs an eager slot or
159
159
  `@flr-ignore-props`. `checkSerializableProps` **fails generation** on any such
160
160
  prop, so a new one cannot ship.
161
+ - **A function property's return value is a Promise on the host.** Functions do
162
+ cross — as thread proxies — but calling one is a round trip. Type the return
163
+ as `Promise<T> | T` and await it on the host (`ChartTooltip`'s formatters), or
164
+ keep the prop off the remote surface with `@flr-ignore-props` (`XAxis`/`YAxis`
165
+ `tickFormatter`). A host that reads the result synchronously gets the Promise
166
+ itself — recharts concatenated it into every tick as `[object Promise]`.
167
+ `checkSerializableProps` fails generation on a new one; the pre-existing set
168
+ is listed in `acknowledgedValueReturningProps`, which can neither grow nor go
169
+ stale.
161
170
  - `@flr-ignore-props` excludes props that must not cross the remote boundary —
162
171
  either because they cannot be serialized, or because they could do **too much
163
172
  on the host side**. A global ignore list lives in
package/MIGRATION.md CHANGED
@@ -1011,18 +1011,39 @@ Only function **references** are affected. An inline arrow
1011
1011
  (`onAction={() => …}`), a zero-parameter function, and anything already
1012
1012
  accepting `unknown` are all fine.
1013
1013
 
1014
- A codemod renames the prop. It deliberately does not wrap: whether the
1015
- referenced function declares a parameter cannot be decided from the source —
1016
- that needs type information and wrapping everything would silently drop the
1017
- arguments `Action` passes to handlers that do accept them.
1014
+ A codemod renames the prop and wraps the reference.
1015
+
1016
+ Whether a reference _needs_ wrapping is not decidable from the source — that
1017
+ needs type information. Performing the wrap does not need it: `() => fn()` calls
1018
+ what `Action` would have called, and `onAction` takes no arguments. So the wrap
1019
+ fixes the reference that needed it and changes nothing for the rest, which makes
1020
+ the decision unnecessary.
1021
+
1022
+ Wrapped: a plain identifier and a member expression (`close`,
1023
+ `controller.close`, `this.handleSave`). Left alone: an arrow function and a
1024
+ function expression, which already are the handler; a call (`makeHandler()`,
1025
+ `close.bind(controller)`), which produces it; and anything that is not one
1026
+ reference (`isOpen ? close : open`, `onClose ?? noop`, `controller?.close`).
1027
+
1028
+ Two wraps are worth a look afterwards. A handler that read the event `Action`
1029
+ forwards — undocumented, but it does forward the trigger's event — stops
1030
+ receiving it. And `onAction={props.onAction}`, where the reference may be
1031
+ `undefined`: passing it was fine, calling it is not, so TypeScript now reports
1032
+ the call and wants a guard.
1018
1033
 
1019
1034
  **Apply:** Rename the `action` prop on `Action` to `onAction`. Not only a
1020
1035
  rename: the new prop is typed `ActionFn` (`(...args: unknown[]) => unknown`), so
1021
1036
  a function _reference_ that declares a parameter no longer type-checks and needs
1022
1037
  wrapping — `onAction={() => controller.close()}` rather than
1023
- `onAction={controller.close}`. Check every site where you passed a reference
1024
- rather than an inline arrow; the codemod renames the prop but cannot decide this
1025
- one from the source.
1038
+ `onAction={controller.close}`. A codemod does both. It wraps every bare
1039
+ reference (`close`, `controller.close`), because the wrap is a no-op for a
1040
+ reference that did not need it. It leaves a value that already is the handler or
1041
+ produces one — an arrow function, a function expression, a call like
1042
+ `makeHandler()` or `close.bind(controller)` — and anything that is not one
1043
+ reference, such as `isOpen ? close : open` or `controller?.close`. Two wraps to
1044
+ look at afterwards: a handler that read the event `Action` forwards stops
1045
+ receiving it, and a possibly-undefined reference (`onAction={props.onAction}`)
1046
+ becomes a call TypeScript rejects — add the guard it asks for.
1026
1047
 
1027
1048
  ```shell
1028
1049
  npx @mittwald/flow-codemods@latest action-prop-to-on-action src