Skip to content

Commit

Permalink
Move DOM APIs to private directory
Browse files Browse the repository at this point in the history
Summary:
The new DOM APIs are completely private at the moment, so they make them a good candidate to test the new directory structure (and make sure everything works correctly in CI, etc.). This moves those files to `src/private/dom`.

Changelog: [internal]

Reviewed By: huntie

Differential Revision: D52875998

fbshipit-source-id: 91f2dab3f2cac0f657a9aed76c97f580f032e265
  • Loading branch information
rubennorte authored and facebook-github-bot committed Jan 19, 2024
1 parent a84f65c commit 0f8dcb2
Show file tree
Hide file tree
Showing 36 changed files with 61 additions and 333 deletions.
2 changes: 1 addition & 1 deletion packages/react-native/Libraries/Core/InitializeCore.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
const start = Date.now();

require('./setUpGlobals');
require('./setUpDOM');
require('../../src/private/core/setUpDOM');
require('./setUpPerformance');
require('./setUpErrorHandling');
require('./polyfillPromise');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
* @oncall react_native
*/

import type ReactNativeElement from '../DOM/Nodes/ReactNativeElement';
import type ReadOnlyElement from '../DOM/Nodes/ReadOnlyElement';
import type ReactNativeElement from '../../src/private/dom/nodes/ReactNativeElement';
import type ReadOnlyElement from '../../src/private/dom/nodes/ReadOnlyElement';
import type {
AppContainerRootViewRef,
DebuggingOverlayRef,
Expand Down Expand Up @@ -230,7 +230,7 @@ class DebuggingOverlayRegistry {

// Lazy import to avoid dependency cycle.
const ReactNativeElementClass =
require('../DOM/Nodes/ReactNativeElement').default;
require('../../src/private/dom/nodes/ReactNativeElement').default;
if (publicInstance instanceof ReactNativeElementClass) {
modernNodesUpdates.push({
id: instanceReactTag,
Expand Down Expand Up @@ -371,7 +371,7 @@ class DebuggingOverlayRegistry {

// Lazy import to avoid dependency cycle.
const ReactNativeElementClass =
require('../DOM/Nodes/ReactNativeElement').default;
require('../../src/private/dom/nodes/ReactNativeElement').default;

const reactNativeElements: Array<ReactNativeElement> = [];
const legacyPublicInstances: Array<NativeMethods> = [];
Expand Down
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 '../DOM/Nodes/ReactNativeElement';
import ReactNativeElement from '../../src/private/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 '../DOM/Nodes/ReactNativeElement';
import type ReactNativeElement from '../../src/private/dom/nodes/ReactNativeElement';
import type {NativeIntersectionObserverEntry} from './NativeIntersectionObserver';

import DOMRectReadOnly from '../DOM/Geometry/DOMRectReadOnly';
import DOMRectReadOnly from '../../src/private/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,13 +18,16 @@
* the notifications together.
*/

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

import {getInstanceHandle, getShadowNode} from '../DOM/Nodes/ReadOnlyNode';
import {
getInstanceHandle,
getShadowNode,
} from '../../src/private/dom/nodes/ReadOnlyNode';
import * as Systrace from '../Performance/Systrace';
import warnOnce from '../Utilities/warnOnce';
import {createIntersectionObserverEntry} from './IntersectionObserverEntry';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
* @format
*/

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

import {getShadowNode} from '../../DOM/Nodes/ReadOnlyNode';
import {getShadowNode} from '../../../src/private/dom/nodes/ReadOnlyNode';
import {getFabricUIManager} from '../../ReactNative/__mocks__/FabricUIManager';
import invariant from 'invariant';
import nullthrows from 'nullthrows';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import type {MutationObserverId} from './MutationObserverManager';
import type MutationRecord from './MutationRecord';

import ReactNativeElement from '../DOM/Nodes/ReactNativeElement';
import ReactNativeElement from '../../src/private/dom/nodes/ReactNativeElement';
import * as MutationObserverManager from './MutationObserverManager';

export type MutationObserverCallback = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* the notifications together.
*/

import type ReactNativeElement from '../DOM/Nodes/ReactNativeElement';
import type ReactNativeElement from '../../src/private/dom/nodes/ReactNativeElement';
import type MutationObserver, {
MutationObserverCallback,
} from './MutationObserver';
Expand All @@ -27,7 +27,7 @@ import type MutationRecord from './MutationRecord';
import {
getPublicInstanceFromInternalInstanceHandle,
getShadowNode,
} from '../DOM/Nodes/ReadOnlyNode';
} from '../../src/private/dom/nodes/ReadOnlyNode';
import * as Systrace from '../Performance/Systrace';
import warnOnce from '../Utilities/warnOnce';
import {createMutationRecord} from './MutationRecord';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@

// flowlint unsafe-getters-setters:off

import type ReactNativeElement from '../DOM/Nodes/ReactNativeElement';
import type ReadOnlyNode from '../DOM/Nodes/ReadOnlyNode';
import type ReactNativeElement from '../../src/private/dom/nodes/ReactNativeElement';
import type ReadOnlyNode from '../../src/private/dom/nodes/ReadOnlyNode';
import type {NativeMutationRecord} from './NativeMutationObserver';

import NodeList, {createNodeList} from '../DOM/OldStyleCollections/NodeList';
import NodeList, {
createNodeList,
} from '../../src/private/dom/oldstylecollections/NodeList';

export type MutationType = 'attributes' | 'characterData' | 'childList';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import type {
Spec,
} from '../NativeMutationObserver';

import ReadOnlyNode from '../../DOM/Nodes/ReadOnlyNode';
import ReadOnlyNode from '../../../src/private/dom/nodes/ReadOnlyNode';
import {
type NodeMock,
type UIManagerCommitHook,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
* instances and get some data from them (like their instance handle / fiber).
*/

import type ReactNativeElement from '../../DOM/Nodes/ReactNativeElement';
import type ReadOnlyText from '../../DOM/Nodes/ReadOnlyText';
import type ReactNativeElement from '../../../src/private/dom/nodes/ReactNativeElement';
import type ReadOnlyText from '../../../src/private/dom/nodes/ReadOnlyText';
import typeof ReactFabricType from '../../Renderer/shims/ReactFabric';
import type {
InternalInstanceHandle,
Expand Down Expand Up @@ -44,7 +44,7 @@ export function createPublicInstance(
// the right module to avoid eagerly loading both.
if (ReactNativeFeatureFlags.enableAccessToHostTreeInFabric()) {
PublicInstanceClass =
require('../../DOM/Nodes/ReactNativeElement').default;
require('../../../src/private/dom/nodes/ReactNativeElement').default;
} else {
PublicInstanceClass = require('./ReactFabricHostComponent').default;
}
Expand All @@ -57,7 +57,8 @@ export function createPublicTextInstance(
internalInstanceHandle: InternalInstanceHandle,
): ReadOnlyText {
if (ReadOnlyTextClass == null) {
ReadOnlyTextClass = require('../../DOM/Nodes/ReadOnlyText').default;
ReadOnlyTextClass =
require('../../../src/private/dom/nodes/ReadOnlyText').default;
}

return new ReadOnlyTextClass(internalInstanceHandle);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,8 @@ const FabricUIManagerMock: IFabricUIManagerMock = {

compareDocumentPosition: jest.fn((node: Node, otherNode: Node): number => {
/* eslint-disable no-bitwise */
const ReadOnlyNode = require('../../DOM/Nodes/ReadOnlyNode').default;
const ReadOnlyNode =
require('../../../src/private/dom/nodes/ReadOnlyNode').default;

// Quick check for node vs. itself
if (fromNode(node).reactTag === fromNode(otherNode).reactTag) {
Expand Down
Loading

0 comments on commit 0f8dcb2

Please sign in to comment.