Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ function configureNext(
// conditionally enabled on iOS (pending fully shipping; this is a temporary state).
const FabricUIManager = getFabricUIManager();
if (FabricUIManager?.configureNextLayoutAnimation) {
global?.nativeFabricUIManager?.configureNextLayoutAnimation(
FabricUIManager.configureNextLayoutAnimation(
config,
onAnimationComplete,
onAnimationDidFail ??
Expand Down
64 changes: 59 additions & 5 deletions packages/react-native/Libraries/ReactNative/FabricUIManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,27 @@ import defineLazyObjectProperty from '../Utilities/defineLazyObjectProperty';

export type NodeSet = Array<Node>;
export type NodeProps = {...};
type EventHandler = (
target: ?InternalInstanceHandle,
type: string,
payload: {[string]: unknown},
) => void;
type Rect = {
x: number,
y: number,
width: number,
height: number,
};
type RelativeLayoutMetrics = {
left: number,
top: number,
width: number,
height: number,
};
type ViewTransition = {
ready: Promise<void>,
finished: Promise<void>,
};
export interface Spec {
readonly createNode: (
reactTag: number,
Expand All @@ -35,7 +56,6 @@ export interface Spec {
props: NodeProps,
instanceHandle: InternalInstanceHandle,
) => Node;
readonly cloneNode: (node: Node) => Node;
readonly cloneNodeWithNewChildren: (node: Node) => Node;
readonly cloneNodeWithNewProps: (node: Node, newProps: NodeProps) => Node;
readonly cloneNodeWithNewChildrenAndProps: (
Expand All @@ -46,10 +66,16 @@ export interface Spec {
readonly appendChild: (parentNode: Node, child: Node) => Node;
readonly appendChildToSet: (childSet: NodeSet, child: Node) => void;
readonly completeRoot: (rootTag: RootTag, childSet: NodeSet) => void;
readonly registerEventHandler: (eventHandler: EventHandler) => void;
readonly getRelativeLayoutMetrics: (
node: Node,
ancestorNode: Node,
) => RelativeLayoutMetrics;
readonly measure: (
node: Node | NativeElementReference,
callback: MeasureOnSuccessCallback,
) => void;
readonly measureInstance: (node: Node) => Rect;
readonly measureInWindow: (
node: Node | NativeElementReference,
callback: MeasureInWindowOnSuccessCallback,
Expand Down Expand Up @@ -100,6 +126,25 @@ export interface Spec {
isJSResponder: boolean,
blockNativeResponder: boolean,
) => void;
readonly applyViewTransitionName: (
node: Node,
transitionName: string,
className: string,
) => void;
readonly createViewTransitionInstance: (
transitionName: string,
pseudoElementTag: number,
) => void;
readonly cancelViewTransitionName: (
node: Node,
transitionName: string,
) => void;
readonly restoreViewTransitionName: (node: Node) => void;
readonly suspendOnActiveViewTransition: () => void;
readonly startViewTransitionReadyFinished: () => void;
readonly startViewTransition: (
mutationCallback: () => void,
) => ?ViewTransition;
readonly unstable_DefaultEventPriority: number;
readonly unstable_DiscreteEventPriority: number;
readonly unstable_ContinuousEventPriority: number;
Expand All @@ -112,27 +157,37 @@ let nativeFabricUIManagerProxy: ?Spec;
// This is a list of all the methods in global.nativeFabricUIManager that we'll
// cache in JavaScript, as the current implementation of the binding
// creates a new host function every time methods are accessed.
const CACHED_PROPERTIES = [
const CACHED_PROPERTIES: ReadonlyArray<keyof Spec> = [
'createNode',
'cloneNode',
'cloneNodeWithNewChildren',
'cloneNodeWithNewProps',
'cloneNodeWithNewChildrenAndProps',
'createChildSet',
'appendChild',
'appendChildToSet',
'completeRoot',
'registerEventHandler',
'getRelativeLayoutMetrics',
'measure',
'measureInstance',
'measureInWindow',
'measureLayout',
'configureNextLayoutAnimation',
'sendAccessibilityEvent',
'findShadowNodeByTag_DEPRECATED',
'setNativeProps',
'dispatchCommand',
'findNodeAtPoint',
'compareDocumentPosition',
'getBoundingClientRect',
'setIsJSResponder',
'applyViewTransitionName',
'createViewTransitionInstance',
'cancelViewTransitionName',
'restoreViewTransitionName',
'suspendOnActiveViewTransition',
'startViewTransitionReadyFinished',
'startViewTransition',
'unstable_DefaultEventPriority',
'unstable_DiscreteEventPriority',
'unstable_ContinuousEventPriority',
Expand Down Expand Up @@ -163,12 +218,11 @@ export function getFabricUIManager(): ?Spec {
*/
function createProxyWithCachedProperties(
implementation: Spec,
propertiesToCache: ReadonlyArray<string>,
propertiesToCache: ReadonlyArray<keyof Spec>,
): Spec {
const proxy = Object.create(implementation);
for (const propertyName of propertiesToCache) {
defineLazyObjectProperty(proxy, propertyName, {
// $FlowExpectedError[prop-missing]
get: () => implementation[propertyName],
});
}
Expand Down
Loading