Skip to content

Commit

Permalink
Move IntersectionObserver to react-native/src/private (facebook#45792)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: facebook#45792

Changelog: [internal]

These files are safe to move because they haven't been enabled in OSS and people shouldn't be importing them directly.

Differential Revision: D60377868
  • Loading branch information
rubennorte authored and facebook-github-bot committed Jul 29, 2024
1 parent 8ee3d8e commit 671155f
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 113 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5424,84 +5424,6 @@ declare module.exports: TaskQueue;

exports[`public API should not change unintentionally Libraries/Interaction/TouchHistoryMath.js 1`] = `"UNTYPED MODULE"`;

exports[`public API should not change unintentionally Libraries/IntersectionObserver/IntersectionObserver.js 1`] = `
"export type IntersectionObserverCallback = (
entries: Array<IntersectionObserverEntry>,
observer: IntersectionObserver
) => mixed;
type IntersectionObserverInit = {
threshold?: number | $ReadOnlyArray<number>,
};
declare export default class IntersectionObserver {
_callback: IntersectionObserverCallback;
_thresholds: $ReadOnlyArray<number>;
_observationTargets: Set<ReactNativeElement>;
_intersectionObserverId: ?IntersectionObserverId;
constructor(
callback: IntersectionObserverCallback,
options?: IntersectionObserverInit
): void;
get root(): ReactNativeElement | null;
get rootMargin(): string;
get thresholds(): $ReadOnlyArray<number>;
observe(target: ReactNativeElement): void;
unobserve(target: ReactNativeElement): void;
disconnect(): void;
_getOrCreateIntersectionObserverId(): IntersectionObserverId;
__getObserverID(): ?IntersectionObserverId;
}
"
`;

exports[`public API should not change unintentionally Libraries/IntersectionObserver/IntersectionObserverEntry.js 1`] = `
"declare export default class IntersectionObserverEntry {
_nativeEntry: NativeIntersectionObserverEntry;
_target: ReactNativeElement;
constructor(
nativeEntry: NativeIntersectionObserverEntry,
target: ReactNativeElement
): void;
get boundingClientRect(): DOMRectReadOnly;
get intersectionRatio(): number;
get intersectionRect(): DOMRectReadOnly;
get isIntersecting(): boolean;
get rootBounds(): DOMRectReadOnly;
get target(): ReactNativeElement;
get time(): DOMHighResTimeStamp;
}
declare export function createIntersectionObserverEntry(
entry: NativeIntersectionObserverEntry,
target: ReactNativeElement
): IntersectionObserverEntry;
"
`;

exports[`public API should not change unintentionally Libraries/IntersectionObserver/IntersectionObserverManager.js 1`] = `
"export type IntersectionObserverId = number;
declare export function registerObserver(
observer: IntersectionObserver,
callback: IntersectionObserverCallback
): IntersectionObserverId;
declare export function unregisterObserver(
intersectionObserverId: IntersectionObserverId
): void;
declare export function observe({
intersectionObserverId: IntersectionObserverId,
target: ReactNativeElement,
}): void;
declare export function unobserve(
intersectionObserverId: number,
target: ReactNativeElement
): void;
"
`;

exports[`public API should not change unintentionally Libraries/IntersectionObserver/NativeIntersectionObserver.js 1`] = `
"export * from \\"../../src/private/specs/modules/NativeIntersectionObserver\\";
declare export default typeof NativeIntersectionObserver;
"
`;

exports[`public API should not change unintentionally Libraries/JSInspector/InspectorAgent.js 1`] = `
"export type EventSender = (name: string, params: mixed) => void;
declare class InspectorAgent {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const FILES_WITH_KNOWN_ERRORS = new Set([
'Libraries/Core/setUpDeveloperTools.js',
'Libraries/Core/setUpErrorHandling.js',
'Libraries/Core/setUpGlobals.js',
'Libraries/Core/setUpIntersectionObserver.js',
'src/private/setup/setUpIntersectionObserver.js',
'Libraries/Core/setUpMutationObserver.js',
'Libraries/Core/setUpNavigator.js',
'Libraries/Core/setUpPerformance.js',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
* @format
*/

import {polyfillGlobal} from '../Utilities/PolyfillFunctions';
import {polyfillGlobal} from '../../../Libraries/Utilities/PolyfillFunctions';

polyfillGlobal(
'IntersectionObserver',
() => require('../IntersectionObserver/IntersectionObserver').default,
() => require('../webapis/intersectionobserver/IntersectionObserver').default,
);
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import type IntersectionObserverEntry from './IntersectionObserverEntry';
import type {IntersectionObserverId} from './IntersectionObserverManager';

import ReactNativeElement from '../../src/private/webapis/dom/nodes/ReactNativeElement';
import ReactNativeElement from '../dom/nodes/ReactNativeElement';
import * as IntersectionObserverManager from './IntersectionObserverManager';

export type IntersectionObserverCallback = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@

// flowlint unsafe-getters-setters:off

import type ReactNativeElement from '../../src/private/webapis/dom/nodes/ReactNativeElement';
import type {NativeIntersectionObserverEntry} from './NativeIntersectionObserver';
import type ReactNativeElement from '../dom/nodes/ReactNativeElement';
import type {NativeIntersectionObserverEntry} from './specs/NativeIntersectionObserver';

import DOMRectReadOnly from '../../src/private/webapis/dom/geometry/DOMRectReadOnly';
import DOMRectReadOnly from '../dom/geometry/DOMRectReadOnly';

/**
* The [`IntersectionObserverEntry`](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserverEntry)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,17 @@
* the notifications together.
*/

import type ReactNativeElement from '../../src/private/webapis/dom/nodes/ReactNativeElement';
import type ReactNativeElement from '../dom/nodes/ReactNativeElement';
import type IntersectionObserver, {
IntersectionObserverCallback,
} from './IntersectionObserver';
import type IntersectionObserverEntry from './IntersectionObserverEntry';

import {
getInstanceHandle,
getShadowNode,
} from '../../src/private/webapis/dom/nodes/ReadOnlyNode';
import * as Systrace from '../Performance/Systrace';
import warnOnce from '../Utilities/warnOnce';
import * as Systrace from '../../../../Libraries/Performance/Systrace';
import warnOnce from '../../../../Libraries/Utilities/warnOnce';
import {getInstanceHandle, getShadowNode} from '../dom/nodes/ReadOnlyNode';
import {createIntersectionObserverEntry} from './IntersectionObserverEntry';
import NativeIntersectionObserver from './NativeIntersectionObserver';
import NativeIntersectionObserver from './specs/NativeIntersectionObserver';

export type IntersectionObserverId = number;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
* @format
*/

import type {TurboModule} from '../../../../Libraries/TurboModule/RCTExport';
import type {TurboModule} from '../../../../../Libraries/TurboModule/RCTExport';

import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboModuleRegistry';
import * as TurboModuleRegistry from '../../../../../Libraries/TurboModule/TurboModuleRegistry';

export type NativeIntersectionObserverEntry = {
intersectionObserverId: number,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@
* @format
*/

import type ReactNativeElement from '../../../src/private/webapis/dom/nodes/ReactNativeElement';
import type IntersectionObserver from '../IntersectionObserver';
import type ReactNativeElement from '../../../dom/nodes/ReactNativeElement';
import type IntersectionObserver from '../../IntersectionObserver';
import type {
NativeIntersectionObserverEntry,
NativeIntersectionObserverObserveOptions,
Spec,
} from '../NativeIntersectionObserver';

import {getShadowNode} from '../../../src/private/webapis/dom/nodes/ReadOnlyNode';
import {getFabricUIManager} from '../../ReactNative/__mocks__/FabricUIManager';
import {getFabricUIManager} from '../../../../../../Libraries/ReactNative/__mocks__/FabricUIManager';
import {getShadowNode} from '../../../dom/nodes/ReadOnlyNode';
import invariant from 'invariant';
import nullthrows from 'nullthrows';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
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 IntersectionObserver from 'react-native/Libraries/IntersectionObserver/IntersectionObserver';
import MutationObserver from 'react-native/Libraries/MutationObserver/MutationObserver';
import ReactNativeElement from 'react-native/src/private/webapis/dom/nodes/ReactNativeElement';
import IntersectionObserver from 'react-native/src/private/webapis/intersectionobserver/IntersectionObserver';

export type VisualElement = {
time: number,
Expand Down

0 comments on commit 671155f

Please sign in to comment.