Move geometry to its own directory outside dom (#49100)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49100

Changelog: [internal]

This API isn't part of the DOM standard so can be moved out.

Reviewed By: huntie

Differential Revision: D68896484

fbshipit-source-id: 5d275beb909ce5c5ce0eddb6c6e04cf7491aa1cb
This commit is contained in:
Rubén Norte
2025-02-03 09:15:31 -08:00
committed by Facebook GitHub Bot
parent 4348a57503
commit c8ecc32ece
16 changed files with 18 additions and 82 deletions
@@ -10497,53 +10497,6 @@ declare export default Spec;
"
`;
exports[`public API should not change unintentionally src/private/webapis/dom/geometry/DOMRect.js 1`] = `
"declare export default class DOMRect extends DOMRectReadOnly {
get x(): number;
set x(x: ?number): void;
get y(): number;
set y(y: ?number): void;
get width(): number;
set width(width: ?number): void;
get height(): number;
set height(height: ?number): void;
static fromRect(rect?: ?DOMRectInit): DOMRect;
}
"
`;
exports[`public API should not change unintentionally src/private/webapis/dom/geometry/DOMRectReadOnly.js 1`] = `
"export interface DOMRectInit {
x?: ?number;
y?: ?number;
width?: ?number;
height?: ?number;
}
declare export default class DOMRectReadOnly {
constructor(x: ?number, y: ?number, width: ?number, height: ?number): void;
get x(): number;
get y(): number;
get width(): number;
get height(): number;
get top(): number;
get right(): number;
get bottom(): number;
get left(): number;
toJSON(): {
x: number,
y: number,
width: number,
height: number,
top: number,
left: number,
bottom: number,
right: number,
};
static fromRect(rect?: ?DOMRectInit): DOMRectReadOnly;
}
"
`;
exports[`public API should not change unintentionally src/private/webapis/dom/nodes/ReactNativeDocument.js 1`] = `
"declare export default class ReactNativeDocument extends ReadOnlyNode {
constructor(
@@ -10701,23 +10654,6 @@ exports[`public API should not change unintentionally src/private/webapis/dom/no
"
`;
exports[`public API should not change unintentionally src/private/webapis/dom/oldstylecollections/ArrayLikeUtils.js 1`] = `
"export interface ArrayLike<T> extends Iterable<T> {
[indexer: number]: T;
+length: number;
}
declare export function createValueIterator<T>(
arrayLike: ArrayLike<T>
): Iterator<T>;
declare export function createKeyIterator<T>(
arrayLike: ArrayLike<T>
): Iterator<number>;
declare export function createEntriesIterator<T>(
arrayLike: ArrayLike<T>
): Iterator<[number, T]>;
"
`;
exports[`public API should not change unintentionally src/private/webapis/intersectionobserver/IntersectionObserver.js 1`] = `
"export type IntersectionObserverCallback = (
entries: Array<IntersectionObserverEntry>,
+2 -2
View File
@@ -21,12 +21,12 @@ export default function setUpDOM() {
polyfillGlobal(
'DOMRect',
() => require('../webapis/dom/geometry/DOMRect').default,
() => require('../webapis/geometry/DOMRect').default,
);
polyfillGlobal(
'DOMRectReadOnly',
() => require('../webapis/dom/geometry/DOMRectReadOnly').default,
() => require('../webapis/geometry/DOMRectReadOnly').default,
);
polyfillGlobal(
@@ -12,7 +12,7 @@
import type HTMLCollection from '../oldstylecollections/HTMLCollection';
import DOMRect from '../geometry/DOMRect';
import DOMRect from '../../geometry/DOMRect';
import {createHTMLCollection} from '../oldstylecollections/HTMLCollection';
import {
getInstanceHandle,
@@ -10,9 +10,9 @@
// flowlint unsafe-getters-setters:off
import type {ArrayLike} from './ArrayLikeUtils';
import type {ArrayLike} from '../../utils/ArrayLikeUtils';
import {createValueIterator} from './ArrayLikeUtils';
import {createValueIterator} from '../../utils/ArrayLikeUtils';
// IMPORTANT: The type definition for this module is defined in `HTMLCollection.js.flow`
// because Flow only supports indexers in classes in declaration files.
@@ -8,7 +8,7 @@
* @flow strict
*/
import type {ArrayLike} from './ArrayLikeUtils';
import type {ArrayLike} from '../../utils/ArrayLikeUtils';
declare export default class HTMLCollection<+T>
implements Iterable<T>, ArrayLike<T>
@@ -10,13 +10,13 @@
// flowlint unsafe-getters-setters:off
import type {ArrayLike} from './ArrayLikeUtils';
import type {ArrayLike} from '../../utils/ArrayLikeUtils';
import {
createEntriesIterator,
createKeyIterator,
createValueIterator,
} from './ArrayLikeUtils';
} from '../../utils/ArrayLikeUtils';
// IMPORTANT: The Flow type definition for this module is defined in `NodeList.js.flow`
// because Flow only supports indexers in classes in declaration files.
@@ -8,7 +8,7 @@
* @flow strict
*/
import type {ArrayLike} from './ArrayLikeUtils';
import type {ArrayLike} from '../../utils/ArrayLikeUtils';
declare export default class NodeList<+T> implements Iterable<T>, ArrayLike<T> {
// This property should've been read-only as well, but Flow doesn't handle
@@ -10,10 +10,10 @@
// flowlint unsafe-getters-setters:off
import type DOMRectReadOnly from '../geometry/DOMRectReadOnly';
import type {ArrayLike} from './ArrayLikeUtils';
import type {ArrayLike} from '../utils/ArrayLikeUtils';
import type DOMRectReadOnly from './DOMRectReadOnly';
import {createValueIterator} from './ArrayLikeUtils';
import {createValueIterator} from '../utils/ArrayLikeUtils';
// IMPORTANT: The Flow type definition for this module is defined in `DOMRectList.js.flow`
// because Flow only supports indexers in classes in declaration files.
@@ -8,8 +8,8 @@
* @flow strict
*/
import type DOMRectReadOnly from '../geometry/DOMRectReadOnly';
import type {ArrayLike} from './ArrayLikeUtils';
import type {ArrayLike} from '../utils/ArrayLikeUtils';
import type DOMRectReadOnly from './DOMRectReadOnly';
declare export default class DOMRectList
implements Iterable<DOMRectReadOnly>, ArrayLike<DOMRectReadOnly>
@@ -9,8 +9,8 @@
* @oncall react_native
*/
import DOMRectReadOnly from '../../geometry/DOMRectReadOnly';
import {createDOMRectList} from '../DOMRectList';
import DOMRectReadOnly from '../DOMRectReadOnly';
const domRectA = new DOMRectReadOnly();
const domRectB = new DOMRectReadOnly();
@@ -13,7 +13,7 @@
import type ReactNativeElement from '../dom/nodes/ReactNativeElement';
import type {NativeIntersectionObserverEntry} from './specs/NativeIntersectionObserver';
import DOMRectReadOnly from '../dom/geometry/DOMRectReadOnly';
import DOMRectReadOnly from '../geometry/DOMRectReadOnly';
/**
* The [`IntersectionObserverEntry`](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserverEntry)
@@ -13,7 +13,7 @@
/* eslint-disable lint/sort-imports */
import type IntersectionObserverType from '../IntersectionObserver';
import DOMRectReadOnly from '../../dom/geometry/DOMRectReadOnly';
import DOMRectReadOnly from '../../geometry/DOMRectReadOnly';
import Fantom from '@react-native/fantom';
import setUpIntersectionObserver from '../../../setup/setUpIntersectionObserver';
import ReactNativeElement from '../../dom/nodes/ReactNativeElement';
@@ -8,8 +8,8 @@
* @format
*/
import type DOMRectReadOnly from 'react-native/src/private/webapis/dom/geometry/DOMRectReadOnly';
import type ReadOnlyNode from 'react-native/src/private/webapis/dom/nodes/ReadOnlyNode';
import type DOMRectReadOnly from 'react-native/src/private/webapis/geometry/DOMRectReadOnly';
import ReactNativeElement from 'react-native/src/private/webapis/dom/nodes/ReactNativeElement';
import IntersectionObserver from 'react-native/src/private/webapis/intersectionobserver/IntersectionObserver';