diff --git a/.clang-format-ignore b/.clang-format-ignore
index c955f0ad4d5d..8d232f8c190b 100644
--- a/.clang-format-ignore
+++ b/.clang-format-ignore
@@ -1,3 +1,6 @@
+**/Pods/**
+**/build/**
+**/node_modules/**
packages/react-native/React/I18n/FBXXHashUtils.h
packages/react-native/ReactAndroid/src/main/jni/first-party/yogajni/**
packages/react-native/ReactAndroid/src/main/jni/third-party/**
diff --git a/.github/workflow-scripts/__tests__/reportFormattingErrors-test.js b/.github/workflow-scripts/__tests__/reportFormattingErrors-test.js
new file mode 100644
index 000000000000..4a9bb9024e4f
--- /dev/null
+++ b/.github/workflow-scripts/__tests__/reportFormattingErrors-test.js
@@ -0,0 +1,110 @@
+/**
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ *
+ * @format
+ */
+
+'use strict';
+
+const {
+ changedFilesFromPatch,
+ commentableRightLines,
+ parsePatch,
+} = require('../reportFormattingErrors');
+
+describe('reportFormattingErrors', () => {
+ test('converts formatter hunks into minimal suggestions', () => {
+ const patch = `diff --git a/example.js b/example.js
+--- a/example.js
++++ b/example.js
+@@ -10,3 +10,3 @@
+ unchanged
+-const value={answer:42};
++const value = {answer: 42};
+ unchanged
+`;
+
+ expect(parsePatch(patch)).toEqual([
+ {
+ path: 'example.js',
+ startLine: 11,
+ endLine: 11,
+ replacement: 'const value = {answer: 42};',
+ },
+ ]);
+ });
+
+ test('tracks lines that can receive right-side review comments', () => {
+ const lines = commentableRightLines(`@@ -4,2 +4,3 @@
+ context
+-old
++new
++added
+`);
+
+ expect([...lines]).toEqual([4, 5, 6]);
+ });
+
+ test.each(['../../../etc/passwd', '/absolute/path', `\0evil`])(
+ 'rejects unsafe patch path %p',
+ unsafePath => {
+ const patch = `diff --git a/file b/file
+--- a/file
++++ b/${unsafePath}
+@@ -1 +1 @@
+-old
++new
+`;
+
+ expect(parsePatch(patch)).toEqual([]);
+ expect(changedFilesFromPatch(patch)).toEqual([]);
+ },
+ );
+
+ test('parses multiple files without carrying hunk state across headers', () => {
+ const patch = `diff --git a/one.js b/one.js
+--- a/one.js
++++ b/one.js
+@@ -1 +1 @@
+-one
++first
+diff --git a/two.js b/two.js
+--- a/two.js
++++ b/two.js
+@@ -2 +2 @@
+-two
++second
+`;
+
+ expect(parsePatch(patch)).toEqual([
+ {path: 'one.js', startLine: 1, endLine: 1, replacement: 'first'},
+ {path: 'two.js', startLine: 2, endLine: 2, replacement: 'second'},
+ ]);
+ expect(changedFilesFromPatch(patch)).toEqual(['one.js', 'two.js']);
+ });
+
+ test('reports files even when a hunk cannot become a suggestion', () => {
+ const patch = `diff --git a/example.js b/example.js
+--- a/example.js
++++ b/example.js
+@@ -1 +1 @@
+-old
++\`\`\`unsafe suggestion fence
+`;
+
+ expect(parsePatch(patch)).toEqual([]);
+ expect(changedFilesFromPatch(patch)).toEqual(['example.js']);
+ });
+
+ test('ignores non-hunk lines when collecting commentable lines', () => {
+ const lines = commentableRightLines(`@@ -4 +4 @@
++new
+index 123..456 100644
+`);
+
+ expect([...lines]).toEqual([4]);
+ });
+});
diff --git a/.github/workflow-scripts/reportFormattingErrors.js b/.github/workflow-scripts/reportFormattingErrors.js
new file mode 100644
index 000000000000..6d755a43095b
--- /dev/null
+++ b/.github/workflow-scripts/reportFormattingErrors.js
@@ -0,0 +1,331 @@
+/**
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ *
+ * @noflow
+ * @format
+ */
+
+'use strict';
+
+const fs = require('node:fs');
+const path = require('node:path');
+
+const MARKER = '';
+const MAX_ARTIFACT_BYTES = 1024 * 1024;
+const MAX_COMMENTS = 20;
+const MAX_REPLACEMENT_LINES = 100;
+
+function readBoundedFile(file) {
+ return fs.readFileSync(file, 'utf8').slice(0, MAX_ARTIFACT_BYTES);
+}
+
+function safePatchPath(candidate) {
+ return candidate !== '' &&
+ !candidate.includes('\0') &&
+ !candidate.split('/').includes('..') &&
+ !path.posix.isAbsolute(candidate)
+ ? candidate
+ : null;
+}
+
+function changedFilesFromPatch(patch) {
+ return [
+ ...new Set(
+ patch
+ .split('\n')
+ .filter(line => line.startsWith('+++ b/'))
+ .map(line => safePatchPath(line.slice(6)))
+ .filter(Boolean),
+ ),
+ ];
+}
+
+function parsePatch(patch) {
+ const changes = [];
+ let file = null;
+ let hunk = null;
+
+ function finishHunk() {
+ const completedHunk = hunk;
+ hunk = null;
+ if (file == null || completedHunk == null) {
+ return;
+ }
+ let prefix = 0;
+ while (
+ prefix < completedHunk.oldLines.length &&
+ prefix < completedHunk.newLines.length &&
+ completedHunk.oldLines[prefix] === completedHunk.newLines[prefix]
+ ) {
+ prefix++;
+ }
+ let suffix = 0;
+ while (
+ suffix < completedHunk.oldLines.length - prefix &&
+ suffix < completedHunk.newLines.length - prefix &&
+ completedHunk.oldLines[completedHunk.oldLines.length - suffix - 1] ===
+ completedHunk.newLines[completedHunk.newLines.length - suffix - 1]
+ ) {
+ suffix++;
+ }
+ const oldLines = completedHunk.oldLines.slice(
+ prefix,
+ completedHunk.oldLines.length - suffix,
+ );
+ const newLines = completedHunk.newLines.slice(
+ prefix,
+ completedHunk.newLines.length - suffix,
+ );
+ if (
+ oldLines.length > 0 &&
+ oldLines.length <= MAX_REPLACEMENT_LINES &&
+ newLines.length <= MAX_REPLACEMENT_LINES &&
+ !newLines.some(line => line.includes('```'))
+ ) {
+ const startLine = completedHunk.oldStart + prefix;
+ changes.push({
+ path: file,
+ startLine,
+ endLine: startLine + oldLines.length - 1,
+ replacement: newLines.join('\n'),
+ });
+ }
+ }
+
+ for (const line of patch.split('\n')) {
+ if (line.startsWith('diff --git ')) {
+ finishHunk();
+ file = null;
+ } else if (line.startsWith('+++ b/')) {
+ const candidate = line.slice(6);
+ file = safePatchPath(candidate);
+ } else if (line.startsWith('@@ ')) {
+ finishHunk();
+ const match = /^@@ -(\d+)(?:,(\d+))? \+\d+(?:,(\d+))? @@/.exec(line);
+ hunk =
+ match == null
+ ? null
+ : {
+ oldStart: Number(match[1]),
+ oldRemaining: Number(match[2] ?? 1),
+ newRemaining: Number(match[3] ?? 1),
+ oldLines: [],
+ newLines: [],
+ };
+ } else if (hunk != null && !line.startsWith('\\ No newline')) {
+ if (line.startsWith(' ')) {
+ hunk.oldLines.push(line.slice(1));
+ hunk.newLines.push(line.slice(1));
+ hunk.oldRemaining--;
+ hunk.newRemaining--;
+ } else if (line.startsWith('-')) {
+ hunk.oldLines.push(line.slice(1));
+ hunk.oldRemaining--;
+ } else if (line.startsWith('+')) {
+ hunk.newLines.push(line.slice(1));
+ hunk.newRemaining--;
+ }
+ if (hunk.oldRemaining === 0 && hunk.newRemaining === 0) {
+ finishHunk();
+ }
+ }
+ }
+ finishHunk();
+ return changes;
+}
+
+function commentableRightLines(patch) {
+ const lines = new Set();
+ let newLine = 0;
+ for (const line of (patch ?? '').split('\n')) {
+ const match = /^@@ -\d+(?:,\d+)? \+(\d+)(?:,\d+)? @@/.exec(line);
+ if (match != null) {
+ newLine = Number(match[1]);
+ } else if (line.startsWith('+') || line.startsWith(' ')) {
+ lines.add(newLine++);
+ }
+ }
+ return lines;
+}
+
+async function deletePreviousComments(github, owner, repo, pullNumber) {
+ const issueComments = await github.paginate(github.rest.issues.listComments, {
+ owner,
+ repo,
+ issue_number: pullNumber,
+ per_page: 100,
+ });
+ for (const comment of issueComments) {
+ if (
+ comment.user?.login === 'github-actions[bot]' &&
+ comment.body?.includes(MARKER)
+ ) {
+ await github.rest.issues.deleteComment({
+ owner,
+ repo,
+ comment_id: comment.id,
+ });
+ }
+ }
+
+ const reviewComments = await github.paginate(
+ github.rest.pulls.listReviewComments,
+ {owner, repo, pull_number: pullNumber, per_page: 100},
+ );
+ for (const comment of reviewComments) {
+ if (
+ comment.user?.login === 'github-actions[bot]' &&
+ comment.body?.includes(MARKER)
+ ) {
+ await github.rest.pulls.deleteReviewComment({
+ owner,
+ repo,
+ comment_id: comment.id,
+ });
+ }
+ }
+}
+
+module.exports = async function reportFormattingErrors({
+ github,
+ context,
+ core,
+}) {
+ const run = context.payload.workflow_run;
+ const pullRequests = run.pull_requests ?? [];
+
+ const metadata = JSON.parse(readBoundedFile('.format-results/metadata.json'));
+ const pullNumber = Number(metadata.PR_NUMBER);
+ const headSha = metadata.HEAD_SHA;
+ if (
+ metadata.EVENT_NAME !== 'pull_request' ||
+ !Number.isSafeInteger(pullNumber) ||
+ !/^[0-9a-f]{40}$/.test(headSha)
+ ) {
+ throw new Error('Formatting artifact metadata does not match this run.');
+ }
+ if (
+ pullRequests.length > 0 &&
+ !pullRequests.some(pullRequest => pullRequest.number === pullNumber)
+ ) {
+ throw new Error(
+ 'Formatting artifact pull request does not match this run.',
+ );
+ }
+
+ const {owner, repo} = context.repo;
+ const {data: pullRequest} = await github.rest.pulls.get({
+ owner,
+ repo,
+ pull_number: pullNumber,
+ });
+ if (pullRequest.head.sha !== headSha) {
+ core.info(
+ 'Ignoring a stale formatting result for an older pull request revision.',
+ );
+ return;
+ }
+
+ await deletePreviousComments(github, owner, repo, pullNumber);
+ if (run.conclusion !== 'failure') {
+ return;
+ }
+
+ const patchFile = '.format-results/format.patch';
+ const patch = fs.existsSync(patchFile) ? readBoundedFile(patchFile) : '';
+ const outputFile = '.format-results/output.txt';
+ const output = fs.existsSync(outputFile) ? readBoundedFile(outputFile) : '';
+ const files = await github.paginate(github.rest.pulls.listFiles, {
+ owner,
+ repo,
+ pull_number: pullNumber,
+ per_page: 100,
+ });
+ const pullPatches = new Map(files.map(file => [file.filename, file.patch]));
+ const parsedChanges = parsePatch(patch);
+ const eligibleSuggestions = parsedChanges.filter(change => {
+ const commentable = commentableRightLines(pullPatches.get(change.path));
+ for (let line = change.startLine; line <= change.endLine; line++) {
+ if (!commentable.has(line)) {
+ return false;
+ }
+ }
+ return true;
+ });
+ const suggestions = eligibleSuggestions.slice(0, MAX_COMMENTS);
+
+ let postedSuggestions = 0;
+ for (const suggestion of suggestions) {
+ try {
+ const location =
+ suggestion.startLine === suggestion.endLine
+ ? {}
+ : {
+ start_line: suggestion.startLine,
+ start_side: 'RIGHT',
+ };
+ await github.rest.pulls.createReviewComment({
+ owner,
+ repo,
+ pull_number: pullNumber,
+ commit_id: headSha,
+ path: suggestion.path,
+ ...location,
+ line: suggestion.endLine,
+ side: 'RIGHT',
+ body: `${MARKER}\n\`yarn format\` suggests:\n\n\`\`\`suggestion\n${suggestion.replacement}\n\`\`\``,
+ });
+ postedSuggestions++;
+ } catch (error) {
+ core.warning(
+ `Could not attach a suggestion to ${suggestion.path}: ${error}`,
+ );
+ }
+ }
+
+ const changedFiles = changedFilesFromPatch(patch).filter(file =>
+ pullPatches.has(file),
+ );
+ const details =
+ changedFiles.length > 0
+ ? changedFiles
+ .map(
+ file =>
+ `- \`${file.replaceAll('`', '\\`').replaceAll('\n', ' ')}\``,
+ )
+ .join('\n')
+ : 'The formatter stopped before producing a patch. See the workflow log.';
+ const outputExcerpt = output
+ .slice(-4000)
+ .replaceAll('```', '``\\`')
+ .replaceAll('<', '<');
+ const body = `${MARKER}
+## Formatting required
+
+Run \`yarn format\` from the repository root and commit the result.
+
+${details}
+
+${postedSuggestions} inline suggestion${postedSuggestions === 1 ? '' : 's'} posted${eligibleSuggestions.length > MAX_COMMENTS ? ` (${eligibleSuggestions.length - MAX_COMMENTS} more omitted)` : ''}. Suggestions can only be attached to lines visible in the pull request diff.
+
+Formatter output
+
+\`\`\`text
+${outputExcerpt}
+\`\`\`
+ `;
+
+ await github.rest.issues.createComment({
+ owner,
+ repo,
+ issue_number: pullNumber,
+ body,
+ });
+};
+
+module.exports.parsePatch = parsePatch;
+module.exports.commentableRightLines = commentableRightLines;
+module.exports.changedFilesFromPatch = changedFilesFromPatch;
diff --git a/.github/workflows/format-report.yml b/.github/workflows/format-report.yml
new file mode 100644
index 000000000000..63c6cdc07c35
--- /dev/null
+++ b/.github/workflows/format-report.yml
@@ -0,0 +1,38 @@
+name: Format Report
+
+on:
+ workflow_run:
+ workflows: [Format]
+ types: [completed]
+
+permissions:
+ actions: read
+ contents: read
+ issues: write
+ pull-requests: write
+
+jobs:
+ report:
+ runs-on: ubuntu-latest
+ if: >-
+ github.repository == 'react/react-native' &&
+ github.event.workflow_run.event == 'pull_request'
+ steps:
+ - name: Check out trusted reporter
+ uses: actions/checkout@v6
+ - name: Download formatting report
+ id: download
+ continue-on-error: true
+ uses: actions/download-artifact@v7
+ with:
+ name: format-results
+ path: .format-results
+ run-id: ${{ github.event.workflow_run.id }}
+ github-token: ${{ github.token }}
+ - name: Comment on formatting failures
+ if: steps.download.outcome == 'success'
+ uses: actions/github-script@v8
+ with:
+ script: |
+ const reportFormattingErrors = require('./.github/workflow-scripts/reportFormattingErrors');
+ await reportFormattingErrors({github, context, core});
diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml
new file mode 100644
index 000000000000..d1a3397159f2
--- /dev/null
+++ b/.github/workflows/format.yml
@@ -0,0 +1,78 @@
+name: Format
+
+on:
+ workflow_dispatch:
+ pull_request:
+ push:
+ branches:
+ - main
+ - '*-stable'
+
+permissions:
+ contents: read
+
+jobs:
+ format:
+ runs-on: macos-15
+ if: github.repository == 'react/react-native'
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v6
+ with:
+ ref: ${{ github.event.pull_request.head.sha || github.sha }}
+ - name: Setup Node.js
+ uses: ./.github/actions/setup-node
+ - name: Initialize report
+ shell: bash
+ env:
+ EVENT_NAME: ${{ github.event_name }}
+ HEAD_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
+ PR_NUMBER: ${{ github.event.pull_request.number || '' }}
+ run: |
+ mkdir -p .format-results
+ node -e "const {EVENT_NAME, HEAD_SHA, PR_NUMBER} = process.env; require('fs').writeFileSync('.format-results/metadata.json', JSON.stringify({EVENT_NAME, HEAD_SHA, PR_NUMBER}))"
+ - name: Setup Java
+ uses: actions/setup-java@v5
+ with:
+ distribution: temurin
+ java-version: 17
+ - name: Setup Python
+ uses: actions/setup-python@v5
+ with:
+ python-version: '3.12'
+ - name: Install dependencies
+ uses: ./.github/actions/yarn-install
+ - name: Check formatting
+ id: format
+ continue-on-error: true
+ shell: bash
+ run: |
+ set +e
+ {
+ status=0
+ for formatter in javascript cpp kotlin java python swift; do
+ yarn "format-$formatter" || status=1
+ done
+ exit "$status"
+ } 2>&1 | tee .format-results/output.txt
+ format_status=${PIPESTATUS[0]}
+ set -e
+ git diff --no-ext-diff --no-color --unified=3 -- . \
+ ':(exclude)packages/react-native/package.json' \
+ ':(exclude)yarn.lock' > .format-results/format.patch
+ if [[ $format_status -ne 0 || -s .format-results/format.patch ]]; then
+ exit 1
+ fi
+ - name: Upload formatting report
+ if: always() && github.event_name == 'pull_request'
+ uses: actions/upload-artifact@v6
+ with:
+ name: format-results
+ path: .format-results/
+ retention-days: 1
+ - name: Report formatting failure
+ if: steps.format.outcome == 'failure'
+ shell: bash
+ run: |
+ echo '::error::Formatting is invalid. Run `yarn format` and commit the result.'
+ exit 1
diff --git a/.github/workflows/test-all.yml b/.github/workflows/test-all.yml
index 237f4ad66f70..501a90b59c93 100644
--- a/.github/workflows/test-all.yml
+++ b/.github/workflows/test-all.yml
@@ -553,9 +553,6 @@ jobs:
- name: Run shellcheck
shell: bash
run: ./.github/workflow-scripts/analyze_scripts.sh
- - name: Prettier
- shell: bash
- run: yarn run format-check
- name: markdownlint
shell: bash
run: yarn run lint-markdown
diff --git a/.swift-format b/.swift-format
new file mode 100644
index 000000000000..6688179cb243
--- /dev/null
+++ b/.swift-format
@@ -0,0 +1,78 @@
+{
+ "indentConditionalCompilationBlocks": false,
+ "indentSwitchCaseLabels": false,
+ "indentation": {
+ "spaces": 2
+ },
+ "lineBreakAroundMultilineExpressionChainComponents": false,
+ "lineBreakBeforeControlFlowKeywords": false,
+ "lineBreakBeforeEachArgument": false,
+ "lineBreakBeforeEachGenericRequirement": false,
+ "lineBreakBetweenDeclarationAttributes": false,
+ "lineLength": 2000,
+ "maximumBlankLines": 1,
+ "multiElementCollectionTrailingCommas": true,
+ "orderedImports": {
+ "includeConditionalImports": false,
+ "shouldGroupImports": false
+ },
+ "noAssignmentInExpressions": {
+ "allowedFunctions": [
+ "XCTAssertNoThrow"
+ ]
+ },
+ "prioritizeKeepingFunctionOutputTogether": true,
+ "reflowMultilineStringLiterals": {
+ "never": {}
+ },
+ "respectsExistingLineBreaks": true,
+ "rules": {
+ "AllPublicDeclarationsHaveDocumentation": false,
+ "AlwaysUseLiteralForEmptyCollectionInit": false,
+ "AlwaysUseLowerCamelCase": false,
+ "AmbiguousTrailingClosureOverload": false,
+ "AvoidRetroactiveConformances": false,
+ "BeginDocumentationCommentWithOneLineSummary": false,
+ "DoNotUseSemicolons": true,
+ "DontRepeatTypeInStaticProperties": false,
+ "FileScopedDeclarationPrivacy": false,
+ "FullyIndirectEnum": false,
+ "GroupNumericLiterals": false,
+ "IdentifiersMustBeASCII": false,
+ "NeverForceUnwrap": false,
+ "NeverUseForceTry": false,
+ "NeverUseImplicitlyUnwrappedOptionals": false,
+ "NoAccessLevelOnExtensionDeclaration": false,
+ "NoAssignmentInExpressions": true,
+ "NoBlockComments": false,
+ "NoCasesWithOnlyFallthrough": false,
+ "NoEmptyLinesOpeningClosingBraces": false,
+ "NoEmptyTrailingClosureParentheses": false,
+ "NoLabelsInCasePatterns": false,
+ "NoLeadingUnderscores": false,
+ "NoParensAroundConditions": true,
+ "NoPlaygroundLiterals": false,
+ "NoVoidReturnOnFunctionSignature": true,
+ "OmitExplicitReturns": false,
+ "OneCasePerLine": false,
+ "OneVariableDeclarationPerLine": true,
+ "OnlyOneTrailingClosureArgument": false,
+ "OrderedImports": true,
+ "ReplaceForEachWithForLoop": false,
+ "ReturnVoidInsteadOfEmptyTuple": true,
+ "TypeNamesShouldBeCapitalized": false,
+ "UseEarlyExits": false,
+ "UseExplicitNilCheckInConditions": false,
+ "UseLetInEveryBoundCaseVariable": false,
+ "UseShorthandTypeNames": false,
+ "UseSingleLinePropertyGetter": false,
+ "UseSynthesizedInitializer": false,
+ "UseTripleSlashForDocumentationComments": false,
+ "UseWhereClausesInForLoops": false,
+ "ValidateDocumentationComments": false
+ },
+ "spacesAroundRangeFormationOperators": false,
+ "spacesBeforeEndOfLineComments": 1,
+ "tabWidth": 8,
+ "version": 1
+}
diff --git a/build.gradle.kts b/build.gradle.kts
index 19fcc1df1a66..e1320dc6d06c 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -13,7 +13,6 @@ plugins {
alias(libs.plugins.kotlin.android) apply false
alias(libs.plugins.binary.compatibility.validator) apply true
alias(libs.plugins.android.test) apply false
- alias(libs.plugins.ktfmt) apply true
}
val reactAndroidProperties = java.util.Properties()
@@ -176,42 +175,3 @@ if (hermesSubstitution != null) {
}
}
}
-
-ktfmt {
- blockIndent.set(2)
- continuationIndent.set(4)
- maxWidth.set(100)
- removeUnusedImports.set(false)
- manageTrailingCommas.set(false)
-}
-
-// Configure ktfmt tasks to include gradle-plugin
-listOf("ktfmtCheck", "ktfmtFormat").forEach { taskName ->
- tasks.named(taskName) { dependsOn(gradle.includedBuild("gradle-plugin").task(":$taskName")) }
-}
-
-allprojects {
- // Apply exclusions for specific files that should not be formatted
- val excludePatterns = listOf(
- "**/build/**",
- "**/hermes-engine/**",
- "**/internal/featureflags/**",
- "**/systeminfo/ReactNativeVersion.kt",
- )
- listOf(
- com.ncorti.ktfmt.gradle.tasks.KtfmtCheckTask::class,
- com.ncorti.ktfmt.gradle.tasks.KtfmtFormatTask::class,
- )
- .forEach { tasks.withType(it) { exclude(excludePatterns) } }
-
- // Disable the problematic ktfmt script tasks due to symbolic link issues in subprojects
- afterEvaluate {
- listOf("ktfmtCheckScripts", "ktfmtFormatScripts").forEach {
- tasks.findByName(it)?.enabled = false
- }
- }
-}
-
-// We intentionally disable the `ktfmtCheck` tasks as the formatting is primarly handled inside
-// fbsource
-allprojects { tasks.withType() { enabled = false } }
diff --git a/package.json b/package.json
index cdba8ff29db9..61d664d3d1e4 100644
--- a/package.json
+++ b/package.json
@@ -9,22 +9,30 @@
"build-android": "./gradlew :packages:react-native:ReactAndroid:build",
"build": "node ./scripts/build/build.js",
"build-types": "node ./scripts/js-api/build-types",
- "clang-format": "node ./scripts/clang-format.js",
"clean": "node ./scripts/build/clean.js",
"cxx-api-build": "python -m scripts.cxx-api.parser",
"cxx-api-validate": "python -m scripts.cxx-api.parser --validate",
"flow-check": "flow full-check",
"flow": "flow",
- "format-check": "prettier --list-different \"./**/*.{js,md,yml,ts,tsx}\"",
- "format": "npm run prettier && npm run clang-format",
+ "format-check": "yarn format-check-javascript && yarn format-check-cpp && yarn format-check-kotlin && yarn format-check-java && yarn format-check-python && yarn format-check-swift",
+ "format-check-cpp": "node ./scripts/clang-format.js --check",
+ "format-check-java": "node ./scripts/format-java.js --check",
+ "format-check-javascript": "prettier --check \"./**/*.{cjs,cts,flow,js,jsx,md,mjs,mts,ts,tsx,yaml,yml}\"",
+ "format-check-kotlin": "node ./scripts/format-kotlin.js --check",
+ "format-check-python": "node ./scripts/format-python.js --check",
+ "format-check-swift": "node ./scripts/format-swift.js --check",
+ "format": "yarn format-javascript && yarn format-cpp && yarn format-kotlin && yarn format-java && yarn format-python && yarn format-swift",
+ "format-cpp": "node ./scripts/clang-format.js",
+ "format-java": "node ./scripts/format-java.js",
+ "format-javascript": "prettier --write \"./**/*.{cjs,cts,flow,js,jsx,md,mjs,mts,ts,tsx,yaml,yml}\"",
+ "format-kotlin": "node ./scripts/format-kotlin.js",
+ "format-python": "node ./scripts/format-python.js",
+ "format-swift": "node ./scripts/format-swift.js",
"featureflags": "yarn --cwd packages/react-native featureflags",
"js-api-diff": "node ./scripts/js-api/diff-api-snapshot",
- "lint-kotlin-check": "./gradlew ktfmtCheck",
- "lint-kotlin": "./gradlew ktfmtFormat",
"lint-markdown": "markdownlint-cli2 2>&1",
"lint": "eslint --max-warnings 0 .",
"preinstall": "node ./scripts/try-set-hermes-compiler-prebuilt.js",
- "prettier": "prettier --write \"./**/*.{js,md,yml,ts,tsx}\"",
"shellcheck": "./.github/workflow-scripts/analyze_scripts.sh",
"start": "yarn --cwd packages/rn-tester start",
"set-version": "node ./scripts/releases/set-version.js",
@@ -91,6 +99,7 @@
"flow-eslint": "0.331.0",
"flow-parser": "0.331.0",
"flow-transform": "0.331.0",
+ "google-java-format": "1.4.0",
"ini": "^5.0.0",
"inquirer": "^7.1.0",
"jest": "^29.7.0",
@@ -99,6 +108,7 @@
"jest-junit": "^16.0.0",
"jest-snapshot": "^29.7.0",
"jsonc-parser": "2.2.1",
+ "ktfmt": "0.59.0",
"markdownlint-cli2": "^0.17.2",
"markdownlint-rule-relative-links": "^3.0.0",
"memfs": "^4.38.2",
diff --git a/packages/gradle-plugin/build.gradle.kts b/packages/gradle-plugin/build.gradle.kts
index 80021f061fb7..4a0905d7d41e 100644
--- a/packages/gradle-plugin/build.gradle.kts
+++ b/packages/gradle-plugin/build.gradle.kts
@@ -5,10 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/
-plugins {
- alias(libs.plugins.kotlin.jvm).apply(false)
- alias(libs.plugins.ktfmt).apply(true)
-}
+plugins { alias(libs.plugins.kotlin.jvm).apply(false) }
tasks.register("build") {
dependsOn(
@@ -27,25 +24,3 @@ tasks.register("clean") {
":shared:clean",
)
}
-
-tasks.named("ktfmtCheck") {
- dependsOn(
- ":react-native-gradle-plugin:ktfmtCheck",
- ":settings-plugin:ktfmtCheck",
- ":shared-testutil:ktfmtCheck",
- ":shared:ktfmtCheck",
- )
-}
-
-tasks.named("ktfmtFormat") {
- dependsOn(
- ":react-native-gradle-plugin:ktfmtFormat",
- ":settings-plugin:ktfmtFormat",
- ":shared-testutil:ktfmtFormat",
- ":shared:ktfmtFormat",
- )
-}
-
-// We intentionally disable the `ktfmtCheck` tasks as the formatting is primarly handled inside
-// fbsource
-allprojects { tasks.withType() { enabled = false } }
diff --git a/packages/gradle-plugin/gradle/libs.versions.toml b/packages/gradle-plugin/gradle/libs.versions.toml
index 65dd0b10f53f..8446ff11b096 100644
--- a/packages/gradle-plugin/gradle/libs.versions.toml
+++ b/packages/gradle-plugin/gradle/libs.versions.toml
@@ -6,7 +6,6 @@ javapoet = "1.13.0"
junit = "4.13.2"
kotlin = "2.2.0"
assertj = "3.25.1"
-ktfmt = "0.22.0"
[libraries]
kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
@@ -19,4 +18,3 @@ assertj = { module = "org.assertj:assertj-core", version.ref = "assertj" }
[plugins]
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
-ktfmt = { id = "com.ncorti.ktfmt.gradle", version.ref = "ktfmt" }
diff --git a/packages/gradle-plugin/react-native-gradle-plugin/build.gradle.kts b/packages/gradle-plugin/react-native-gradle-plugin/build.gradle.kts
index 1450a701a71a..1f083f522185 100644
--- a/packages/gradle-plugin/react-native-gradle-plugin/build.gradle.kts
+++ b/packages/gradle-plugin/react-native-gradle-plugin/build.gradle.kts
@@ -12,7 +12,6 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
alias(libs.plugins.kotlin.jvm)
- alias(libs.plugins.ktfmt)
id("java-gradle-plugin")
}
diff --git a/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactPlugin.kt b/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactPlugin.kt
index f3b5072dce93..992271bbf8f0 100644
--- a/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactPlugin.kt
+++ b/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactPlugin.kt
@@ -200,42 +200,44 @@ class ReactPlugin : Plugin {
}
// We create the tasks to produce schema from JS files and generate artifacts from schema.
- val generateCodegenArtifactsTask = registerCodegenTasks(
- project = project,
- rootExtension = rootExtension,
- generatedSrcDir = generatedSrcDir,
- packageJsonFile = { findPackageJsonFile(project, rootExtension.root) },
- schemaTaskName = "generateCodegenSchemaFromJavaScript",
- artifactsTaskName = "generateCodegenArtifactsFromSchema",
- configureJsRoot = { task, packageJson ->
- // We're reading the package.json at configuration time to properly feed
- // the `jsRootDir` @Input property of this task & the onlyIf. Therefore, the
- // parsePackageJson should be invoked inside this lambda.
- val parsedPackageJson = packageJson?.let { JsonUtils.fromPackageJson(it) }
- val jsSrcsDirInPackageJson = parsedPackageJson?.codegenConfig?.jsSrcsDir
-
- if (packageJson != null && jsSrcsDirInPackageJson != null) {
- task.jsRootDir.set(File(packageJson.parentFile, jsSrcsDirInPackageJson))
- } else {
- task.jsRootDir.set(localExtension.jsRootDir)
- }
- },
- configureCodegenArtifacts = { task, _ ->
- task.codegenJavaPackageName.set(localExtension.codegenJavaPackageName)
- task.libraryName.set(localExtension.libraryName)
- },
- onlyIf = { packageJson ->
- // Please note that needsCodegenFromPackageJson is triggering a read of the
- // package.json at configuration time as we need to feed the onlyIf condition of this
- // task. Therefore, needsCodegenFromPackageJson needs to be invoked inside this
- // lambda.
- val needsCodegenFromPackageJson = project.needsCodegenFromPackageJson(rootExtension.root)
- val parsedPackageJson = packageJson?.let { JsonUtils.fromPackageJson(it) }
- val includesGeneratedCode =
- parsedPackageJson?.codegenConfig?.includesGeneratedCode ?: false
- (isLibrary || needsCodegenFromPackageJson) && !includesGeneratedCode
- },
- )
+ val generateCodegenArtifactsTask =
+ registerCodegenTasks(
+ project = project,
+ rootExtension = rootExtension,
+ generatedSrcDir = generatedSrcDir,
+ packageJsonFile = { findPackageJsonFile(project, rootExtension.root) },
+ schemaTaskName = "generateCodegenSchemaFromJavaScript",
+ artifactsTaskName = "generateCodegenArtifactsFromSchema",
+ configureJsRoot = { task, packageJson ->
+ // We're reading the package.json at configuration time to properly feed
+ // the `jsRootDir` @Input property of this task & the onlyIf. Therefore, the
+ // parsePackageJson should be invoked inside this lambda.
+ val parsedPackageJson = packageJson?.let { JsonUtils.fromPackageJson(it) }
+ val jsSrcsDirInPackageJson = parsedPackageJson?.codegenConfig?.jsSrcsDir
+
+ if (packageJson != null && jsSrcsDirInPackageJson != null) {
+ task.jsRootDir.set(File(packageJson.parentFile, jsSrcsDirInPackageJson))
+ } else {
+ task.jsRootDir.set(localExtension.jsRootDir)
+ }
+ },
+ configureCodegenArtifacts = { task, _ ->
+ task.codegenJavaPackageName.set(localExtension.codegenJavaPackageName)
+ task.libraryName.set(localExtension.libraryName)
+ },
+ onlyIf = { packageJson ->
+ // Please note that needsCodegenFromPackageJson is triggering a read of the
+ // package.json at configuration time as we need to feed the onlyIf condition of this
+ // task. Therefore, needsCodegenFromPackageJson needs to be invoked inside this
+ // lambda.
+ val needsCodegenFromPackageJson =
+ project.needsCodegenFromPackageJson(rootExtension.root)
+ val parsedPackageJson = packageJson?.let { JsonUtils.fromPackageJson(it) }
+ val includesGeneratedCode =
+ parsedPackageJson?.codegenConfig?.includesGeneratedCode ?: false
+ (isLibrary || needsCodegenFromPackageJson) && !includesGeneratedCode
+ },
+ )
// We update the android configuration to include the generated sources.
// This is equivalent to this DSL:
@@ -353,13 +355,14 @@ class ReactPlugin : Plugin {
project.rootProject.layout.buildDirectory.file("generated/autolinking/autolinking.json")
val pureCxxDependencies =
getPureCxxCodegenDependencies(rootGeneratedAutolinkingFile.get().asFile)
- val pureCxxCodegenTasks = configurePureCxxDependenciesCodegen(
- project,
- extension,
- rootExtension,
- generatedPureCxxSourceDir,
- pureCxxDependencies,
- )
+ val pureCxxCodegenTasks =
+ configurePureCxxDependenciesCodegen(
+ project,
+ extension,
+ rootExtension,
+ generatedPureCxxSourceDir,
+ pureCxxDependencies,
+ )
// We add a task called generateAutolinkingPackageList to do not clash with the existing task
// called generatePackageList. This can to be renamed once we unlink the rn <-> cli
diff --git a/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/BundleHermesCTask.kt b/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/BundleHermesCTask.kt
index 1ed09caa17de..89ba3656a3e6 100644
--- a/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/BundleHermesCTask.kt
+++ b/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/BundleHermesCTask.kt
@@ -109,12 +109,13 @@ abstract class BundleHermesCTask : DefaultTask() {
val reactNativeDir = reactNativeDir.get().asFile
val composeScriptFile = File(reactNativeDir, "scripts/compose-source-maps.js")
- val composeSourceMapsCommand = getComposeSourceMapsCommand(
- composeScriptFile,
- packagerSourceMap,
- compilerSourceMap,
- outputSourceMap,
- )
+ val composeSourceMapsCommand =
+ getComposeSourceMapsCommand(
+ composeScriptFile,
+ packagerSourceMap,
+ compilerSourceMap,
+ outputSourceMap,
+ )
runCommand(composeSourceMapsCommand)
}
}
diff --git a/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/AgpConfiguratorUtils.kt b/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/AgpConfiguratorUtils.kt
index 36a52185a6d0..a7581e039324 100644
--- a/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/AgpConfiguratorUtils.kt
+++ b/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/AgpConfiguratorUtils.kt
@@ -122,9 +122,7 @@ internal object AgpConfiguratorUtils {
manifestFile
.takeIf { it.exists() }
?.let { file ->
- getPackageNameFromManifest(file)?.let { packageName ->
- ext.namespace = packageName
- }
+ getPackageNameFromManifest(file)?.let { packageName -> ext.namespace = packageName }
}
}
}
diff --git a/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/DependencyUtils.kt b/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/DependencyUtils.kt
index eff5ca58f566..ef34f68e684e 100644
--- a/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/DependencyUtils.kt
+++ b/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/DependencyUtils.kt
@@ -145,10 +145,10 @@ internal object DependencyUtils {
}
if (!coordinates.hermesVersionString.isMavenArtifactVersionPublished()) {
setOf(
- DEFAULT_INTERNAL_REACT_PUBLISHING_GROUP,
- DEFAULT_INTERNAL_HERMES_PUBLISHING_GROUP,
- coordinates.hermesGroupString,
- )
+ DEFAULT_INTERNAL_REACT_PUBLISHING_GROUP,
+ DEFAULT_INTERNAL_HERMES_PUBLISHING_GROUP,
+ coordinates.hermesGroupString,
+ )
.forEach { group ->
content.excludeVersion(group, "hermes-engine", UNPUBLISHED_MAVEN_VERSION)
content.excludeVersion(group, "hermes-android", UNPUBLISHED_MAVEN_VERSION)
diff --git a/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/PathUtils.kt b/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/PathUtils.kt
index 70c0912c327f..8e5ecb38f0ea 100644
--- a/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/PathUtils.kt
+++ b/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/PathUtils.kt
@@ -28,11 +28,12 @@ import org.gradle.api.file.DirectoryProperty
internal fun detectedEntryFile(
config: ReactExtension,
envVariableOverride: String? = null,
-): File = detectEntryFile(
- entryFile = config.entryFile.orNull?.asFile,
- reactRoot = config.root.get().asFile,
- envVariableOverride = envVariableOverride,
-)
+): File =
+ detectEntryFile(
+ entryFile = config.entryFile.orNull?.asFile,
+ reactRoot = config.root.get().asFile,
+ envVariableOverride = envVariableOverride,
+ )
/**
* Computes the CLI file for React Native. The Algo follows this order:
@@ -41,11 +42,12 @@ internal fun detectedEntryFile(
* 3. The `node_modules/react-native/cli.js` file if exists
* 4. Fails otherwise
*/
-internal fun detectedCliFile(config: ReactExtension): File = detectCliFile(
- project = config.project,
- reactNativeRoot = config.root.get().asFile,
- preconfiguredCliFile = config.cliFile.asFile.orNull,
-)
+internal fun detectedCliFile(config: ReactExtension): File =
+ detectCliFile(
+ project = config.project,
+ reactNativeRoot = config.root.get().asFile,
+ preconfiguredCliFile = config.cliFile.asFile.orNull,
+ )
/**
* Computes the `hermesc` command location. The Algo follows this order:
diff --git a/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/ReactExtensionTest.kt b/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/ReactExtensionTest.kt
index 11a164afaecc..3c7743844d49 100644
--- a/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/ReactExtensionTest.kt
+++ b/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/ReactExtensionTest.kt
@@ -20,14 +20,15 @@ class ReactExtensionTest {
@Test
fun getGradleDependenciesToApply_withEmptyFile_returnsEmptyMap() {
- val validJsonFile = createJsonFile(
- """
- {
- "reactNativeVersion": "1000.0.0"
- }
- """
- .trimIndent(),
- )
+ val validJsonFile =
+ createJsonFile(
+ """
+ {
+ "reactNativeVersion": "1000.0.0"
+ }
+ """
+ .trimIndent(),
+ )
val deps = getGradleDependenciesToApply(validJsonFile)
assertThat(deps).isEmpty()
@@ -35,26 +36,27 @@ class ReactExtensionTest {
@Test
fun getGradleDependenciesToApply_withOneDependency_returnsValidDep() {
- val validJsonFile = createJsonFile(
- """
- {
- "reactNativeVersion": "1000.0.0",
- "dependencies": {
- "@react-native/oss-library-example": {
- "root": "./node_modules/@react-native/oss-library-example",
- "name": "@react-native/oss-library-example",
- "platforms": {
- "android": {
- "sourceDir": "src/main/java",
- "packageImportPath": "com.facebook.react"
+ val validJsonFile =
+ createJsonFile(
+ """
+ {
+ "reactNativeVersion": "1000.0.0",
+ "dependencies": {
+ "@react-native/oss-library-example": {
+ "root": "./node_modules/@react-native/oss-library-example",
+ "name": "@react-native/oss-library-example",
+ "platforms": {
+ "android": {
+ "sourceDir": "src/main/java",
+ "packageImportPath": "com.facebook.react"
+ }
+ }
}
}
}
- }
- }
- """
- .trimIndent(),
- )
+ """
+ .trimIndent(),
+ )
val deps = getGradleDependenciesToApply(validJsonFile)
assertThat(deps).containsExactly("implementation" to ":react-native_oss-library-example")
@@ -62,27 +64,28 @@ class ReactExtensionTest {
@Test
fun getGradleDependenciesToApply_withDependencyConfiguration_returnsValidConfiguration() {
- val validJsonFile = createJsonFile(
- """
- {
- "reactNativeVersion": "1000.0.0",
- "dependencies": {
- "@react-native/oss-library-example": {
- "root": "./node_modules/@react-native/oss-library-example",
- "name": "@react-native/oss-library-example",
- "platforms": {
- "android": {
- "sourceDir": "src/main/java",
- "packageImportPath": "com.facebook.react",
- "dependencyConfiguration": "compileOnly"
+ val validJsonFile =
+ createJsonFile(
+ """
+ {
+ "reactNativeVersion": "1000.0.0",
+ "dependencies": {
+ "@react-native/oss-library-example": {
+ "root": "./node_modules/@react-native/oss-library-example",
+ "name": "@react-native/oss-library-example",
+ "platforms": {
+ "android": {
+ "sourceDir": "src/main/java",
+ "packageImportPath": "com.facebook.react",
+ "dependencyConfiguration": "compileOnly"
+ }
+ }
}
}
}
- }
- }
- """
- .trimIndent(),
- )
+ """
+ .trimIndent(),
+ )
val deps = getGradleDependenciesToApply(validJsonFile)
assertThat(deps).containsExactly("compileOnly" to ":react-native_oss-library-example")
@@ -90,27 +93,28 @@ class ReactExtensionTest {
@Test
fun getGradleDependenciesToApply_withBuildTypes_returnsValidConfiguration() {
- val validJsonFile = createJsonFile(
- """
- {
- "reactNativeVersion": "1000.0.0",
- "dependencies": {
- "@react-native/oss-library-example": {
- "root": "./node_modules/@react-native/oss-library-example",
- "name": "@react-native/oss-library-example",
- "platforms": {
- "android": {
- "sourceDir": "src/main/java",
- "packageImportPath": "com.facebook.react",
- "buildTypes": ["debug", "release"]
+ val validJsonFile =
+ createJsonFile(
+ """
+ {
+ "reactNativeVersion": "1000.0.0",
+ "dependencies": {
+ "@react-native/oss-library-example": {
+ "root": "./node_modules/@react-native/oss-library-example",
+ "name": "@react-native/oss-library-example",
+ "platforms": {
+ "android": {
+ "sourceDir": "src/main/java",
+ "packageImportPath": "com.facebook.react",
+ "buildTypes": ["debug", "release"]
+ }
+ }
}
}
}
- }
- }
- """
- .trimIndent(),
- )
+ """
+ .trimIndent(),
+ )
val deps = getGradleDependenciesToApply(validJsonFile)
assertThat(deps)
@@ -122,36 +126,37 @@ class ReactExtensionTest {
@Test
fun getGradleDependenciesToApply_withMultipleDependencies_returnsValidConfiguration() {
- val validJsonFile = createJsonFile(
- """
- {
- "reactNativeVersion": "1000.0.0",
- "dependencies": {
- "@react-native/oss-library-example": {
- "root": "./node_modules/@react-native/oss-library-example",
- "name": "@react-native/oss-library-example",
- "platforms": {
- "android": {
- "sourceDir": "src/main/java",
- "packageImportPath": "com.facebook.react"
- }
- }
- },
- "@react-native/another-library-for-testing": {
- "root": "./node_modules/@react-native/another-library-for-testing",
- "name": "@react-native/another-library-for-testing",
- "platforms": {
- "android": {
- "sourceDir": "src/main/java",
- "packageImportPath": "com.facebook.react"
+ val validJsonFile =
+ createJsonFile(
+ """
+ {
+ "reactNativeVersion": "1000.0.0",
+ "dependencies": {
+ "@react-native/oss-library-example": {
+ "root": "./node_modules/@react-native/oss-library-example",
+ "name": "@react-native/oss-library-example",
+ "platforms": {
+ "android": {
+ "sourceDir": "src/main/java",
+ "packageImportPath": "com.facebook.react"
+ }
+ }
+ },
+ "@react-native/another-library-for-testing": {
+ "root": "./node_modules/@react-native/another-library-for-testing",
+ "name": "@react-native/another-library-for-testing",
+ "platforms": {
+ "android": {
+ "sourceDir": "src/main/java",
+ "packageImportPath": "com.facebook.react"
+ }
+ }
}
}
}
- }
- }
- """
- .trimIndent(),
- )
+ """
+ .trimIndent(),
+ )
val deps = getGradleDependenciesToApply(validJsonFile)
assertThat(deps)
@@ -163,29 +168,30 @@ class ReactExtensionTest {
@Test
fun getGradleDependenciesToApply_withiOSOnlyLibrary_returnsEmptyDepsMap() {
- val validJsonFile = createJsonFile(
- """
- {
- "reactNativeVersion": "1000.0.0",
- "dependencies": {
- "@react-native/oss-library-example": {
- "root": "./node_modules/@react-native/oss-library-example",
- "name": "@react-native/oss-library-example",
- "platforms": {
- "ios": {
- "podspecPath": "./node_modules/@react-native/oss-library-example/oss-library-example.podspec",
- "version": "0.0.0",
- "configurations": [],
- "scriptPhases": []
- },
- "android": null
+ val validJsonFile =
+ createJsonFile(
+ """
+ {
+ "reactNativeVersion": "1000.0.0",
+ "dependencies": {
+ "@react-native/oss-library-example": {
+ "root": "./node_modules/@react-native/oss-library-example",
+ "name": "@react-native/oss-library-example",
+ "platforms": {
+ "ios": {
+ "podspecPath": "./node_modules/@react-native/oss-library-example/oss-library-example.podspec",
+ "version": "0.0.0",
+ "configurations": [],
+ "scriptPhases": []
+ },
+ "android": null
+ }
+ }
}
}
- }
- }
- """
- .trimIndent(),
- )
+ """
+ .trimIndent(),
+ )
val deps = getGradleDependenciesToApply(validJsonFile)
assertThat(deps).isEmpty()
@@ -193,37 +199,38 @@ class ReactExtensionTest {
@Test
fun getGradleDependenciesToApply_withIsPureCxxDeps_filtersCorrectly() {
- val validJsonFile = createJsonFile(
- """
- {
- "reactNativeVersion": "1000.0.0",
- "dependencies": {
- "@react-native/oss-library-example": {
- "root": "./node_modules/@react-native/android-example",
- "name": "@react-native/android-example",
- "platforms": {
- "android": {
- "sourceDir": "src/main/java",
- "packageImportPath": "com.facebook.react"
- }
- }
- },
- "@react-native/another-library-for-testing": {
- "root": "./node_modules/@react-native/cxx-testing",
- "name": "@react-native/cxx-testing",
- "platforms": {
- "android": {
- "sourceDir": "src/main/java",
- "packageImportPath": "com.facebook.react",
- "isPureCxxDependency": true
+ val validJsonFile =
+ createJsonFile(
+ """
+ {
+ "reactNativeVersion": "1000.0.0",
+ "dependencies": {
+ "@react-native/oss-library-example": {
+ "root": "./node_modules/@react-native/android-example",
+ "name": "@react-native/android-example",
+ "platforms": {
+ "android": {
+ "sourceDir": "src/main/java",
+ "packageImportPath": "com.facebook.react"
+ }
+ }
+ },
+ "@react-native/another-library-for-testing": {
+ "root": "./node_modules/@react-native/cxx-testing",
+ "name": "@react-native/cxx-testing",
+ "platforms": {
+ "android": {
+ "sourceDir": "src/main/java",
+ "packageImportPath": "com.facebook.react",
+ "isPureCxxDependency": true
+ }
+ }
}
}
}
- }
- }
- """
- .trimIndent(),
- )
+ """
+ .trimIndent(),
+ )
val deps = getGradleDependenciesToApply(validJsonFile)
assertThat(deps).containsExactly("implementation" to ":react-native_android-example")
diff --git a/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/ReactPluginTest.kt b/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/ReactPluginTest.kt
index 68978242bb79..19c854290f3d 100644
--- a/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/ReactPluginTest.kt
+++ b/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/ReactPluginTest.kt
@@ -27,8 +27,9 @@ class ReactPluginTest {
val withoutCodegenConfig = createPackageWithoutCodegenConfig("without-codegen-config")
val missingNonPureCxxPackage = File(tempFolder.root, "missing-non-pure-cxx-package")
- val autolinkingFile = createAutolinkingFile(
- """
+ val autolinkingFile =
+ createAutolinkingFile(
+ """
{
"reactNativeVersion": "1000.0.0",
"dependencies": {
@@ -105,8 +106,8 @@ class ReactPluginTest {
}
}
"""
- .trimIndent(),
- )
+ .trimIndent(),
+ )
val result = ReactPlugin().getPureCxxCodegenDependencies(autolinkingFile)
@@ -126,11 +127,12 @@ class ReactPluginTest {
@Test
fun taskNameSuffixForDependency_withNonAlphanumericCharacters_encodesThem() {
- val dependency = ModelAutolinkingDependenciesJson(
- root = "./node_modules/@foo/bar-baz",
- name = "@foo/bar-baz",
- platforms = null,
- )
+ val dependency =
+ ModelAutolinkingDependenciesJson(
+ root = "./node_modules/@foo/bar-baz",
+ name = "@foo/bar-baz",
+ platforms = null,
+ )
val result = ReactPlugin().taskNameSuffixForDependency(dependency)
@@ -142,11 +144,12 @@ class ReactPluginTest {
val plugin = ReactPlugin()
val suffixes =
listOf("@foo/bar", "foo.bar", "foo-bar", "foo_bar", "foo_45_bar").map { name ->
- val dependency = ModelAutolinkingDependenciesJson(
- root = "./node_modules/$name",
- name = name,
- platforms = null,
- )
+ val dependency =
+ ModelAutolinkingDependenciesJson(
+ root = "./node_modules/$name",
+ name = name,
+ platforms = null,
+ )
plugin.taskNameSuffixForDependency(dependency)
}
@@ -156,11 +159,12 @@ class ReactPluginTest {
@Test
fun taskNameSuffixForDependency_withLocalModuleRoot_usesPackageName() {
- val dependency = ModelAutolinkingDependenciesJson(
- root = "./modules/local-module",
- name = "local-module",
- platforms = null,
- )
+ val dependency =
+ ModelAutolinkingDependenciesJson(
+ root = "./modules/local-module",
+ name = "local-module",
+ platforms = null,
+ )
val result = ReactPlugin().taskNameSuffixForDependency(dependency)
diff --git a/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/model/ModelAutolinkingDependenciesJsonTest.kt b/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/model/ModelAutolinkingDependenciesJsonTest.kt
index d865dec77d56..4563c7e721d5 100644
--- a/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/model/ModelAutolinkingDependenciesJsonTest.kt
+++ b/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/model/ModelAutolinkingDependenciesJsonTest.kt
@@ -36,13 +36,13 @@ class ModelAutolinkingDependenciesJsonTest {
assertThat(ModelAutolinkingDependenciesJson("", "@react-native/package", null).nameCleansed)
.isEqualTo("react-native_package")
assertThat(
- ModelAutolinkingDependenciesJson(
- "",
- "@this*is~a(more)complicated/example!of~weird)packages",
- null,
+ ModelAutolinkingDependenciesJson(
+ "",
+ "@this*is~a(more)complicated/example!of~weird)packages",
+ null,
+ )
+ .nameCleansed,
)
- .nameCleansed,
- )
.isEqualTo("this_is_a_more_complicated_example_of_weird_packages")
}
}
diff --git a/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/GenerateAutolinkingNewArchitecturesFileTaskTest.kt b/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/GenerateAutolinkingNewArchitecturesFileTaskTest.kt
index 9449b007fc10..618cb36d075b 100644
--- a/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/GenerateAutolinkingNewArchitecturesFileTaskTest.kt
+++ b/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/GenerateAutolinkingNewArchitecturesFileTaskTest.kt
@@ -85,12 +85,13 @@ class GenerateAutolinkingNewArchitecturesFileTaskTest {
@Test
fun filterAndroidPackages_withValidAndroidObject_returnsIt() {
val task = createTestTask()
- val android = ModelAutolinkingDependenciesPlatformAndroidJson(
- sourceDir = "./a/directory/android",
- packageImportPath = "import com.facebook.react.aPackage;",
- packageInstance = "new APackage()",
- buildTypes = emptyList(),
- )
+ val android =
+ ModelAutolinkingDependenciesPlatformAndroidJson(
+ sourceDir = "./a/directory/android",
+ packageImportPath = "import com.facebook.react.aPackage;",
+ packageInstance = "new APackage()",
+ buildTypes = emptyList(),
+ )
val result =
task.filterAndroidPackages(
@@ -115,15 +116,16 @@ class GenerateAutolinkingNewArchitecturesFileTaskTest {
@Test
fun cmakeListsPathForDependency_withCmakeListsPath_returnsIt() {
val task = createTestTask()
- val dependency = ModelAutolinkingDependenciesPlatformAndroidJson(
- sourceDir = "./a/directory",
- packageImportPath = "import com.facebook.react.aPackage;",
- packageInstance = "new APackage()",
- buildTypes = emptyList(),
- libraryName = "aPackage",
- cmakeListsPath = "./a/directory/CMakeLists.txt",
- isPureCxxDependency = true,
- )
+ val dependency =
+ ModelAutolinkingDependenciesPlatformAndroidJson(
+ sourceDir = "./a/directory",
+ packageImportPath = "import com.facebook.react.aPackage;",
+ packageInstance = "new APackage()",
+ buildTypes = emptyList(),
+ libraryName = "aPackage",
+ cmakeListsPath = "./a/directory/CMakeLists.txt",
+ isPureCxxDependency = true,
+ )
assertThat(task.cmakeListsPathForDependency(dependency))
.isEqualTo("./a/directory/CMakeLists.txt")
@@ -136,14 +138,15 @@ class GenerateAutolinkingNewArchitecturesFileTaskTest {
createTestTask {
it.generatedPureCxxSourceDirectory.set(generatedPureCxxSourceDirectory)
}
- val dependency = ModelAutolinkingDependenciesPlatformAndroidJson(
- sourceDir = "./a/directory",
- packageImportPath = "import com.facebook.react.aPackage;",
- packageInstance = "new APackage()",
- buildTypes = emptyList(),
- libraryName = "aPackage",
- isPureCxxDependency = true,
- )
+ val dependency =
+ ModelAutolinkingDependenciesPlatformAndroidJson(
+ sourceDir = "./a/directory",
+ packageImportPath = "import com.facebook.react.aPackage;",
+ packageInstance = "new APackage()",
+ buildTypes = emptyList(),
+ libraryName = "aPackage",
+ isPureCxxDependency = true,
+ )
assertThat(task.cmakeListsPathForDependency(dependency))
.isEqualTo(
@@ -154,14 +157,15 @@ class GenerateAutolinkingNewArchitecturesFileTaskTest {
@Test
fun cmakeListsPathForDependency_withMissingGeneratedDirectory_returnsNull() {
val task = createTestTask()
- val dependency = ModelAutolinkingDependenciesPlatformAndroidJson(
- sourceDir = "./a/directory",
- packageImportPath = "import com.facebook.react.aPackage;",
- packageInstance = "new APackage()",
- buildTypes = emptyList(),
- libraryName = "aPackage",
- isPureCxxDependency = true,
- )
+ val dependency =
+ ModelAutolinkingDependenciesPlatformAndroidJson(
+ sourceDir = "./a/directory",
+ packageImportPath = "import com.facebook.react.aPackage;",
+ packageInstance = "new APackage()",
+ buildTypes = emptyList(),
+ libraryName = "aPackage",
+ isPureCxxDependency = true,
+ )
assertThat(task.cmakeListsPathForDependency(dependency)).isNull()
}
@@ -173,14 +177,15 @@ class GenerateAutolinkingNewArchitecturesFileTaskTest {
createTestTask {
it.generatedPureCxxSourceDirectory.set(generatedPureCxxSourceDirectory)
}
- val dependency = ModelAutolinkingDependenciesPlatformAndroidJson(
- sourceDir = "./a/directory",
- packageImportPath = "import com.facebook.react.aPackage;",
- packageInstance = "new APackage()",
- buildTypes = emptyList(),
- libraryName = "aPackage",
- isPureCxxDependency = false,
- )
+ val dependency =
+ ModelAutolinkingDependenciesPlatformAndroidJson(
+ sourceDir = "./a/directory",
+ packageImportPath = "import com.facebook.react.aPackage;",
+ packageInstance = "new APackage()",
+ buildTypes = emptyList(),
+ libraryName = "aPackage",
+ isPureCxxDependency = false,
+ )
assertThat(task.cmakeListsPathForDependency(dependency)).isNull()
}
@@ -498,27 +503,28 @@ class GenerateAutolinkingNewArchitecturesFileTaskTest {
assertThat(sanitizeCmakeListsPath(input)).isEqualTo("./a/dir\\ ectory/")
}
- private val testDependencies = listOf(
- ModelAutolinkingDependenciesPlatformAndroidJson(
- sourceDir = "./a/directory",
- packageImportPath = "import com.facebook.react.aPackage;",
- packageInstance = "new APackage()",
- buildTypes = emptyList(),
- libraryName = "aPackage",
- componentDescriptors = emptyList(),
- cmakeListsPath = "./a/directory/CMakeLists.txt",
- ),
- ModelAutolinkingDependenciesPlatformAndroidJson(
- sourceDir = "./another/directory",
- packageImportPath = "import com.facebook.react.anotherPackage;",
- packageInstance = "new AnotherPackage()",
- buildTypes = emptyList(),
- libraryName = "anotherPackage",
- componentDescriptors = listOf("AnotherPackageComponentDescriptor"),
- cmakeListsPath = "./another/directory/with spaces/CMakeLists.txt",
- cxxModuleCMakeListsPath = "./another/directory/cxx/CMakeLists.txt",
- cxxModuleHeaderName = "AnotherCxxModule",
- cxxModuleCMakeListsModuleName = "another_cxxModule",
- ),
- )
+ private val testDependencies =
+ listOf(
+ ModelAutolinkingDependenciesPlatformAndroidJson(
+ sourceDir = "./a/directory",
+ packageImportPath = "import com.facebook.react.aPackage;",
+ packageInstance = "new APackage()",
+ buildTypes = emptyList(),
+ libraryName = "aPackage",
+ componentDescriptors = emptyList(),
+ cmakeListsPath = "./a/directory/CMakeLists.txt",
+ ),
+ ModelAutolinkingDependenciesPlatformAndroidJson(
+ sourceDir = "./another/directory",
+ packageImportPath = "import com.facebook.react.anotherPackage;",
+ packageInstance = "new AnotherPackage()",
+ buildTypes = emptyList(),
+ libraryName = "anotherPackage",
+ componentDescriptors = listOf("AnotherPackageComponentDescriptor"),
+ cmakeListsPath = "./another/directory/with spaces/CMakeLists.txt",
+ cxxModuleCMakeListsPath = "./another/directory/cxx/CMakeLists.txt",
+ cxxModuleHeaderName = "AnotherCxxModule",
+ cxxModuleCMakeListsModuleName = "another_cxxModule",
+ ),
+ )
}
diff --git a/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/GeneratePackageListTaskTest.kt b/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/GeneratePackageListTaskTest.kt
index 789d7a75df20..261ca070d906 100644
--- a/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/GeneratePackageListTaskTest.kt
+++ b/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/GeneratePackageListTaskTest.kt
@@ -151,12 +151,13 @@ class GeneratePackageListTaskTest {
@Test
fun filterAndroidPackages_withValidAndroidObject_returnsIt() {
val task = createTestTask()
- val android = ModelAutolinkingDependenciesPlatformAndroidJson(
- sourceDir = "./a/directory/android",
- packageImportPath = "import com.facebook.react.aPackage;",
- packageInstance = "new APackage()",
- buildTypes = emptyList(),
- )
+ val android =
+ ModelAutolinkingDependenciesPlatformAndroidJson(
+ sourceDir = "./a/directory/android",
+ packageImportPath = "import com.facebook.react.aPackage;",
+ packageInstance = "new APackage()",
+ buildTypes = emptyList(),
+ )
val result =
task.filterAndroidPackages(
@@ -182,13 +183,14 @@ class GeneratePackageListTaskTest {
@Test
fun filterAndroidPackages_withIsPureCxxDependencyObject_returnsIt() {
val task = createTestTask()
- val android = ModelAutolinkingDependenciesPlatformAndroidJson(
- sourceDir = "./a/directory/android",
- packageImportPath = "import com.facebook.react.aPackage;",
- packageInstance = "new APackage()",
- buildTypes = emptyList(),
- isPureCxxDependency = true,
- )
+ val android =
+ ModelAutolinkingDependenciesPlatformAndroidJson(
+ sourceDir = "./a/directory/android",
+ packageImportPath = "import com.facebook.react.aPackage;",
+ packageInstance = "new APackage()",
+ buildTypes = emptyList(),
+ isPureCxxDependency = true,
+ )
val result =
task.filterAndroidPackages(
@@ -364,26 +366,27 @@ class GeneratePackageListTaskTest {
)
}
- private val testDependencies = mapOf(
- "@react-native/a-package" to
- ModelAutolinkingDependenciesPlatformAndroidJson(
- sourceDir = "./a/directory",
- packageImportPath = "import com.facebook.react.APackage;",
- packageInstance = "new APackage()",
- buildTypes = emptyList(),
- libraryName = "aPackage",
- componentDescriptors = emptyList(),
- cmakeListsPath = "./a/directory/CMakeLists.txt",
- ),
- "@react-native/another-package" to
- ModelAutolinkingDependenciesPlatformAndroidJson(
- sourceDir = "./another/directory",
- packageImportPath = "import com.facebook.react.AnotherPackage;",
- packageInstance = "new AnotherPackage()",
- buildTypes = emptyList(),
- libraryName = "anotherPackage",
- componentDescriptors = emptyList(),
- cmakeListsPath = "./another/directory/CMakeLists.txt",
- ),
- )
+ private val testDependencies =
+ mapOf(
+ "@react-native/a-package" to
+ ModelAutolinkingDependenciesPlatformAndroidJson(
+ sourceDir = "./a/directory",
+ packageImportPath = "import com.facebook.react.APackage;",
+ packageInstance = "new APackage()",
+ buildTypes = emptyList(),
+ libraryName = "aPackage",
+ componentDescriptors = emptyList(),
+ cmakeListsPath = "./a/directory/CMakeLists.txt",
+ ),
+ "@react-native/another-package" to
+ ModelAutolinkingDependenciesPlatformAndroidJson(
+ sourceDir = "./another/directory",
+ packageImportPath = "import com.facebook.react.AnotherPackage;",
+ packageInstance = "new AnotherPackage()",
+ buildTypes = emptyList(),
+ libraryName = "anotherPackage",
+ componentDescriptors = emptyList(),
+ cmakeListsPath = "./another/directory/CMakeLists.txt",
+ ),
+ )
}
diff --git a/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/internal/utils/PrefabPreprocessingEntryTest.kt b/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/internal/utils/PrefabPreprocessingEntryTest.kt
index dbff6173649e..b83c26d46875 100644
--- a/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/internal/utils/PrefabPreprocessingEntryTest.kt
+++ b/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/internal/utils/PrefabPreprocessingEntryTest.kt
@@ -14,10 +14,11 @@ class PrefabPreprocessingEntryTest {
@Test
fun secondaryConstructor_createsAList() {
- val sampleEntry = PrefabPreprocessingEntry(
- libraryName = "justALibrary",
- pathToPrefixCouple = "aPath" to "andAPrefix",
- )
+ val sampleEntry =
+ PrefabPreprocessingEntry(
+ libraryName = "justALibrary",
+ pathToPrefixCouple = "aPath" to "andAPrefix",
+ )
assertThat(sampleEntry.pathToPrefixCouples.size).isEqualTo(1)
assertThat(sampleEntry.pathToPrefixCouples[0].first).isEqualTo("aPath")
diff --git a/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/DependencyUtilsTest.kt b/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/DependencyUtilsTest.kt
index 620aa4079f71..eceb18ad0744 100644
--- a/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/DependencyUtilsTest.kt
+++ b/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/DependencyUtilsTest.kt
@@ -45,10 +45,10 @@ class DependencyUtilsTest {
configureRepositories(project, false)
assertThat(
- project.repositories.firstOrNull {
- it is MavenArtifactRepository && it.url == localMavenURI
- },
- )
+ project.repositories.firstOrNull {
+ it is MavenArtifactRepository && it.url == localMavenURI
+ },
+ )
.isNotNull()
}
@@ -60,10 +60,10 @@ class DependencyUtilsTest {
configureRepositories(project, false)
assertThat(
- project.repositories.firstOrNull {
- it is MavenArtifactRepository && it.url == repositoryURI
- },
- )
+ project.repositories.firstOrNull {
+ it is MavenArtifactRepository && it.url == repositoryURI
+ },
+ )
.isNotNull()
}
@@ -76,10 +76,10 @@ class DependencyUtilsTest {
configureRepositories(project, false)
assertThat(
- project.repositories.firstOrNull {
- it is MavenArtifactRepository && it.url == repositoryURI
- },
- )
+ project.repositories.firstOrNull {
+ it is MavenArtifactRepository && it.url == repositoryURI
+ },
+ )
.isNotNull()
}
@@ -127,10 +127,10 @@ class DependencyUtilsTest {
configureRepositories(project, false)
assertThat(
- project.repositories.firstOrNull {
- it is MavenArtifactRepository && it.url == repositoryURI
- },
- )
+ project.repositories.firstOrNull {
+ it is MavenArtifactRepository && it.url == repositoryURI
+ },
+ )
.isNotNull()
}
@@ -142,10 +142,10 @@ class DependencyUtilsTest {
configureRepositories(project, false)
assertThat(
- project.repositories.firstOrNull {
- it is MavenArtifactRepository && it.url == repositoryURI
- },
- )
+ project.repositories.firstOrNull {
+ it is MavenArtifactRepository && it.url == repositoryURI
+ },
+ )
.isNotNull()
}
@@ -163,10 +163,10 @@ class DependencyUtilsTest {
assertThat(project.repositories).hasSize(1)
assertThat(
- project.repositories.firstOrNull {
- it is MavenArtifactRepository && it.url == repositoryURI
- },
- )
+ project.repositories.firstOrNull {
+ it is MavenArtifactRepository && it.url == repositoryURI
+ },
+ )
.isNotNull()
}
@@ -179,10 +179,10 @@ class DependencyUtilsTest {
configureRepositories(project, false)
assertThat(
- project.repositories.firstOrNull {
- it is MavenArtifactRepository && it.url == repositoryURI
- },
- )
+ project.repositories.firstOrNull {
+ it is MavenArtifactRepository && it.url == repositoryURI
+ },
+ )
.isNull()
// We test both with scoped and unscoped property
@@ -192,10 +192,10 @@ class DependencyUtilsTest {
configureRepositories(project, false)
assertThat(
- project.repositories.firstOrNull {
- it is MavenArtifactRepository && it.url == repositoryURI
- },
- )
+ project.repositories.firstOrNull {
+ it is MavenArtifactRepository && it.url == repositoryURI
+ },
+ )
.isNull()
}
@@ -208,10 +208,10 @@ class DependencyUtilsTest {
configureRepositories(project, false)
assertThat(
- project.repositories.firstOrNull {
- it is MavenArtifactRepository && it.url == repositoryURI
- },
- )
+ project.repositories.firstOrNull {
+ it is MavenArtifactRepository && it.url == repositoryURI
+ },
+ )
.isNotNull()
// We test both with scoped and unscoped property
@@ -221,10 +221,10 @@ class DependencyUtilsTest {
configureRepositories(project, false)
assertThat(
- project.repositories.firstOrNull {
- it is MavenArtifactRepository && it.url == repositoryURI
- },
- )
+ project.repositories.firstOrNull {
+ it is MavenArtifactRepository && it.url == repositoryURI
+ },
+ )
.isNotNull()
}
@@ -236,10 +236,10 @@ class DependencyUtilsTest {
configureRepositories(project, false)
assertThat(
- project.repositories.firstOrNull {
- it is MavenArtifactRepository && it.url == repositoryURI
- },
- )
+ project.repositories.firstOrNull {
+ it is MavenArtifactRepository && it.url == repositoryURI
+ },
+ )
.isNull()
}
@@ -251,10 +251,10 @@ class DependencyUtilsTest {
configureRepositories(project, true)
assertThat(
- project.repositories.firstOrNull {
- it is MavenArtifactRepository && it.url == repositoryURI
- },
- )
+ project.repositories.firstOrNull {
+ it is MavenArtifactRepository && it.url == repositoryURI
+ },
+ )
.isNotNull()
}
@@ -309,10 +309,10 @@ class DependencyUtilsTest {
configureRepositories(project, false)
assertThat(
- project.repositories.firstOrNull {
- it is MavenArtifactRepository && it.url == mavenMirrorURI
- },
- )
+ project.repositories.firstOrNull {
+ it is MavenArtifactRepository && it.url == mavenMirrorURI
+ },
+ )
.isNull()
}
@@ -324,10 +324,10 @@ class DependencyUtilsTest {
configureRepositories(project, false)
assertThat(
- project.repositories.firstOrNull {
- it is MavenArtifactRepository && it.url == mavenMirrorURI
- },
- )
+ project.repositories.firstOrNull {
+ it is MavenArtifactRepository && it.url == mavenMirrorURI
+ },
+ )
.isNotNull()
}
@@ -340,10 +340,10 @@ class DependencyUtilsTest {
configureRepositories(project, false)
assertThat(
- project.repositories.firstOrNull {
- it is MavenArtifactRepository && it.url == mavenMirrorURI
- },
- )
+ project.repositories.firstOrNull {
+ it is MavenArtifactRepository && it.url == mavenMirrorURI
+ },
+ )
.isNull()
}
@@ -409,16 +409,16 @@ class DependencyUtilsTest {
configureRepositories(appProject, false)
assertThat(
- appProject.repositories.firstOrNull {
- it is MavenArtifactRepository && it.url == repositoryURI
- },
- )
+ appProject.repositories.firstOrNull {
+ it is MavenArtifactRepository && it.url == repositoryURI
+ },
+ )
.isNotNull()
assertThat(
- libProject.repositories.firstOrNull {
- it is MavenArtifactRepository && it.url == repositoryURI
- },
- )
+ libProject.repositories.firstOrNull {
+ it is MavenArtifactRepository && it.url == repositoryURI
+ },
+ )
.isNotNull()
}
@@ -439,10 +439,10 @@ class DependencyUtilsTest {
// We need to make sure we have Maven Central defined twice, one by the library,
// and another is the override by RNGP.
assertThat(
- libProject.repositories.count {
- it is MavenArtifactRepository && it.url == repositoryURI
- },
- )
+ libProject.repositories.count {
+ it is MavenArtifactRepository && it.url == repositoryURI
+ },
+ )
.isEqualTo(2)
}
@@ -463,10 +463,8 @@ class DependencyUtilsTest {
val forcedModules = project.configurations.first().resolutionStrategy.forcedModules
assertThat(
- forcedModules.any {
- it.toString() == "com.facebook.react:react-android:1000.0.0"
- },
- )
+ forcedModules.any { it.toString() == "com.facebook.react:react-android:1000.0.0" },
+ )
.isTrue()
assertThat(forcedModules.any { it.toString() == "com.facebook.hermes:hermes-android:4.5.6" })
.isTrue()
@@ -474,10 +472,10 @@ class DependencyUtilsTest {
val dependencySubstitutions =
getDependencySubstitutions(DependencyUtils.Coordinates("1000.0.0", "4.5.6"))
assertThat(
- dependencySubstitutions.any {
- it.second == "com.facebook.react:react-android:1000.0.0"
- },
- )
+ dependencySubstitutions.any {
+ it.second == "com.facebook.react:react-android:1000.0.0"
+ },
+ )
.isTrue()
}
@@ -539,14 +537,14 @@ class DependencyUtilsTest {
assertThat(appForcedModules.any { it.toString() == "io.github.test:react-android:1.2.3" })
.isTrue()
assertThat(
- appForcedModules.any { it.toString() == "io.github.test.hermes:hermes-android:4.5.6" },
- )
+ appForcedModules.any { it.toString() == "io.github.test.hermes:hermes-android:4.5.6" },
+ )
.isTrue()
assertThat(libForcedModules.any { it.toString() == "io.github.test:react-android:1.2.3" })
.isTrue()
assertThat(
- libForcedModules.any { it.toString() == "io.github.test.hermes:hermes-android:4.5.6" },
- )
+ libForcedModules.any { it.toString() == "io.github.test.hermes:hermes-android:4.5.6" },
+ )
.isTrue()
}
@@ -559,41 +557,42 @@ class DependencyUtilsTest {
assertThat("com.facebook.react:react-android:0.42.0")
.isEqualTo(dependencySubstitutions[0].second)
assertThat(
- "The react-native artifact was deprecated in favor of react-android due to https://github.com/facebook/react-native/issues/35210.",
- )
+ "The react-native artifact was deprecated in favor of react-android due to https://github.com/facebook/react-native/issues/35210.",
+ )
.isEqualTo(dependencySubstitutions[0].third)
assertThat("com.facebook.react:hermes-engine").isEqualTo(dependencySubstitutions[1].first)
assertThat("com.facebook.hermes:hermes-android:0.42.0")
.isEqualTo(dependencySubstitutions[1].second)
assertThat(
- "The hermes-engine artifact was deprecated in favor of hermes-android due to https://github.com/facebook/react-native/issues/35210.",
- )
+ "The hermes-engine artifact was deprecated in favor of hermes-android due to https://github.com/facebook/react-native/issues/35210.",
+ )
.isEqualTo(dependencySubstitutions[1].third)
}
@Test
fun getDependencySubstitutions_withCustomGroup_substitutesCorrectly() {
- val dependencySubstitutions = getDependencySubstitutions(
- DependencyUtils.Coordinates(
- "0.42.0",
- "0.42.0",
- "io.github.test",
- "io.github.test.hermes",
- ),
- )
+ val dependencySubstitutions =
+ getDependencySubstitutions(
+ DependencyUtils.Coordinates(
+ "0.42.0",
+ "0.42.0",
+ "io.github.test",
+ "io.github.test.hermes",
+ ),
+ )
assertThat("com.facebook.react:react-native").isEqualTo(dependencySubstitutions[0].first)
assertThat("io.github.test:react-android:0.42.0").isEqualTo(dependencySubstitutions[0].second)
assertThat(
- "The react-native artifact was deprecated in favor of react-android due to https://github.com/facebook/react-native/issues/35210.",
- )
+ "The react-native artifact was deprecated in favor of react-android due to https://github.com/facebook/react-native/issues/35210.",
+ )
.isEqualTo(dependencySubstitutions[0].third)
assertThat("com.facebook.react:hermes-engine").isEqualTo(dependencySubstitutions[1].first)
assertThat("io.github.test.hermes:hermes-android:0.42.0")
.isEqualTo(dependencySubstitutions[1].second)
assertThat(
- "The hermes-engine artifact was deprecated in favor of hermes-android due to https://github.com/facebook/react-native/issues/35210.",
- )
+ "The hermes-engine artifact was deprecated in favor of hermes-android due to https://github.com/facebook/react-native/issues/35210.",
+ )
.isEqualTo(dependencySubstitutions[1].third)
assertThat("com.facebook.react:hermes-android").isEqualTo(dependencySubstitutions[2].first)
assertThat("io.github.test.hermes:hermes-android:0.42.0")
@@ -879,13 +878,14 @@ class DependencyUtilsTest {
@Test
fun isNightly_returnsTrue_forValidNightlyVersions() {
- val trueCases = listOf(
- "0.85.0-nightly-20260128-36f07a1b2",
- "0.82.0-nightly-date-commit",
- "0.0.0-20230505-2109-9b69263a1",
- "0.0.0-date-commit",
- "0.0.0-nightly-",
- )
+ val trueCases =
+ listOf(
+ "0.85.0-nightly-20260128-36f07a1b2",
+ "0.82.0-nightly-date-commit",
+ "0.0.0-20230505-2109-9b69263a1",
+ "0.0.0-date-commit",
+ "0.0.0-nightly-",
+ )
trueCases.forEach { version ->
assert(version.isNightly()) { "Expected '$version' to be detected as nightly" }
@@ -894,16 +894,17 @@ class DependencyUtilsTest {
@Test
fun isNightly_returnsFalse_forNonNightlyVersions() {
- val falseCases = listOf(
- "0.83.0", // Standard version
- "0.0.1",
- "nightly", // Missing hyphens
- "0.83.0-nightly", // Missing trailing hyphen
- "any-nightly", // Missing trailing hyphen
- "nightly-build", // Missing leading hyphen
- "", // Empty string
- " ", // Blank string
- )
+ val falseCases =
+ listOf(
+ "0.83.0", // Standard version
+ "0.0.1",
+ "nightly", // Missing hyphens
+ "0.83.0-nightly", // Missing trailing hyphen
+ "any-nightly", // Missing trailing hyphen
+ "nightly-build", // Missing leading hyphen
+ "", // Empty string
+ " ", // Blank string
+ )
falseCases.forEach { version ->
assert(!version.isNightly()) { "Expected '$version' to NOT be detected as nightly" }
diff --git a/packages/gradle-plugin/settings-plugin/build.gradle.kts b/packages/gradle-plugin/settings-plugin/build.gradle.kts
index 39a1e490d4aa..15b8ed13087f 100644
--- a/packages/gradle-plugin/settings-plugin/build.gradle.kts
+++ b/packages/gradle-plugin/settings-plugin/build.gradle.kts
@@ -12,7 +12,6 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
alias(libs.plugins.kotlin.jvm)
- alias(libs.plugins.ktfmt)
id("java-gradle-plugin")
}
diff --git a/packages/gradle-plugin/settings-plugin/src/test/kotlin/com/facebook/react/ReactSettingsExtensionTest.kt b/packages/gradle-plugin/settings-plugin/src/test/kotlin/com/facebook/react/ReactSettingsExtensionTest.kt
index 5ed5e5111464..f85bd5d2b43a 100644
--- a/packages/gradle-plugin/settings-plugin/src/test/kotlin/com/facebook/react/ReactSettingsExtensionTest.kt
+++ b/packages/gradle-plugin/settings-plugin/src/test/kotlin/com/facebook/react/ReactSettingsExtensionTest.kt
@@ -26,28 +26,30 @@ class ReactSettingsExtensionTest {
@Test
fun computeSha256_worksCorrectly() {
- val validFile = createJsonFile(
- """
- {
- "value": "¯\\_(ツ)_/¯"
- }
- """
- .trimIndent(),
- )
+ val validFile =
+ createJsonFile(
+ """
+ {
+ "value": "¯\\_(ツ)_/¯"
+ }
+ """
+ .trimIndent(),
+ )
assertThat(computeSha256(validFile))
.isEqualTo("838aa9a72a16fdd55b0d49b510a82e264a30f59333b5fdd97c7798a29146f6a8")
}
@Test
fun getLibrariesToAutolink_withEmptyFile_returnsEmptyMap() {
- val validJsonFile = createJsonFile(
- """
- {
- "reactNativeVersion": "1000.0.0"
- }
- """
- .trimIndent(),
- )
+ val validJsonFile =
+ createJsonFile(
+ """
+ {
+ "reactNativeVersion": "1000.0.0"
+ }
+ """
+ .trimIndent(),
+ )
val map = getLibrariesToAutolink(validJsonFile)
assertThat(map.keys).isEmpty()
@@ -55,44 +57,45 @@ class ReactSettingsExtensionTest {
@Test
fun getLibrariesToAutolink_withLibraryToAutolink_returnsValidMap() {
- val validJsonFile = createJsonFile(
- """
- {
- "reactNativeVersion": "1000.0.0",
- "dependencies": {
- "@react-native/oss-library-example": {
- "root": "./node_modules/@react-native/oss-library-example",
- "name": "@react-native/oss-library-example",
- "platforms": {
- "ios": {
- "podspecPath": "./node_modules/@react-native/oss-library-example/OSSLibraryExample.podspec",
- "version": "0.0.1",
- "configurations": [],
- "scriptPhases": []
- },
- "android": {
- "sourceDir": "./node_modules/@react-native/oss-library-example/android",
- "packageImportPath": "import com.facebook.react.osslibraryexample.OSSLibraryExamplePackage;",
- "packageInstance": "new OSSLibraryExamplePackage()",
- "buildTypes": ["staging", "debug", "release"],
- "libraryName": "OSSLibraryExampleSpec",
- "componentDescriptors": [
- "SampleNativeComponentComponentDescriptor"
- ],
- "cmakeListsPath": "./node_modules/@react-native/oss-library-example/android/build/generated/source/codegen/jni/CMakeLists.txt",
- "cxxModuleCMakeListsModuleName": null,
- "cxxModuleCMakeListsPath": null,
- "cxxModuleHeaderName": null,
- "dependencyConfiguration": "implementation",
- "isPureCxxDependency": false
+ val validJsonFile =
+ createJsonFile(
+ """
+ {
+ "reactNativeVersion": "1000.0.0",
+ "dependencies": {
+ "@react-native/oss-library-example": {
+ "root": "./node_modules/@react-native/oss-library-example",
+ "name": "@react-native/oss-library-example",
+ "platforms": {
+ "ios": {
+ "podspecPath": "./node_modules/@react-native/oss-library-example/OSSLibraryExample.podspec",
+ "version": "0.0.1",
+ "configurations": [],
+ "scriptPhases": []
+ },
+ "android": {
+ "sourceDir": "./node_modules/@react-native/oss-library-example/android",
+ "packageImportPath": "import com.facebook.react.osslibraryexample.OSSLibraryExamplePackage;",
+ "packageInstance": "new OSSLibraryExamplePackage()",
+ "buildTypes": ["staging", "debug", "release"],
+ "libraryName": "OSSLibraryExampleSpec",
+ "componentDescriptors": [
+ "SampleNativeComponentComponentDescriptor"
+ ],
+ "cmakeListsPath": "./node_modules/@react-native/oss-library-example/android/build/generated/source/codegen/jni/CMakeLists.txt",
+ "cxxModuleCMakeListsModuleName": null,
+ "cxxModuleCMakeListsPath": null,
+ "cxxModuleHeaderName": null,
+ "dependencyConfiguration": "implementation",
+ "isPureCxxDependency": false
+ }
+ }
}
}
}
- }
- }
- """
- .trimIndent(),
- )
+ """
+ .trimIndent(),
+ )
val map = getLibrariesToAutolink(validJsonFile)
assertThat(map.keys).containsExactly(":react-native_oss-library-example")
@@ -102,28 +105,29 @@ class ReactSettingsExtensionTest {
@Test
fun getLibrariesToAutolink_withiOSOnlyLibrary_returnsEmptyMap() {
- val validJsonFile = createJsonFile(
- """
- {
- "reactNativeVersion": "1000.0.0",
- "dependencies": {
- "@react-native/oss-library-example": {
- "root": "./node_modules/@react-native/oss-library-example",
- "name": "@react-native/oss-library-example",
- "platforms": {
- "ios": {
- "podspecPath": "./node_modules/@react-native/oss-library-example/OSSLibraryExample.podspec",
- "version": "0.0.1",
- "configurations": [],
- "scriptPhases": []
+ val validJsonFile =
+ createJsonFile(
+ """
+ {
+ "reactNativeVersion": "1000.0.0",
+ "dependencies": {
+ "@react-native/oss-library-example": {
+ "root": "./node_modules/@react-native/oss-library-example",
+ "name": "@react-native/oss-library-example",
+ "platforms": {
+ "ios": {
+ "podspecPath": "./node_modules/@react-native/oss-library-example/OSSLibraryExample.podspec",
+ "version": "0.0.1",
+ "configurations": [],
+ "scriptPhases": []
+ }
+ }
}
}
}
- }
- }
- """
- .trimIndent(),
- )
+ """
+ .trimIndent(),
+ )
val map = getLibrariesToAutolink(validJsonFile)
assertThat(map.keys).isEmpty()
@@ -355,12 +359,13 @@ class ReactSettingsExtensionTest {
}
tempFolder.newFile("yarn.lock").apply { writeText("I'm a lockfile") }
val lockfiles = project.files("yarn.lock")
- val invalidConfigFile = createJsonFile(
- """
- {}
- """
- .trimIndent(),
- )
+ val invalidConfigFile =
+ createJsonFile(
+ """
+ {}
+ """
+ .trimIndent(),
+ )
assertThat(ReactSettingsExtension.isCacheDirty(invalidConfigFile, buildFolder, lockfiles))
.isTrue()
@@ -376,14 +381,15 @@ class ReactSettingsExtensionTest {
}
tempFolder.newFile("yarn.lock").apply { writeText("I'm a lockfile") }
val lockfiles = project.files("yarn.lock")
- val invalidConfigFile = createJsonFile(
- """
- {
- "reactNativeVersion": "1000.0.0"
- }
- """
- .trimIndent(),
- )
+ val invalidConfigFile =
+ createJsonFile(
+ """
+ {
+ "reactNativeVersion": "1000.0.0"
+ }
+ """
+ .trimIndent(),
+ )
assertThat(ReactSettingsExtension.isCacheDirty(invalidConfigFile, buildFolder, lockfiles))
.isTrue()
@@ -399,15 +405,16 @@ class ReactSettingsExtensionTest {
}
tempFolder.newFile("yarn.lock").apply { writeText("I'm a lockfile") }
val lockfiles = project.files("yarn.lock")
- val invalidConfigFile = createJsonFile(
- """
- {
- "reactNativeVersion": "1000.0.0",
- "dependencies": {}
- }
- """
- .trimIndent(),
- )
+ val invalidConfigFile =
+ createJsonFile(
+ """
+ {
+ "reactNativeVersion": "1000.0.0",
+ "dependencies": {}
+ }
+ """
+ .trimIndent(),
+ )
assertThat(ReactSettingsExtension.isCacheDirty(invalidConfigFile, buildFolder, lockfiles))
.isTrue()
@@ -423,28 +430,29 @@ class ReactSettingsExtensionTest {
}
tempFolder.newFile("yarn.lock").apply { writeText("I'm a lockfile") }
val lockfiles = project.files("yarn.lock")
- val invalidConfigFile = createJsonFile(
- """
- {
- "reactNativeVersion": "1000.0.0",
- "dependencies": {
- "@react-native/oss-library-example": {
- "root": "./node_modules/@react-native/oss-library-example",
- "name": "@react-native/oss-library-example",
- "platforms": {
- "ios": {
- "podspecPath": "./node_modules/@react-native/oss-library-example/OSSLibraryExample.podspec",
- "version": "0.0.1",
- "configurations": [],
- "scriptPhases": []
+ val invalidConfigFile =
+ createJsonFile(
+ """
+ {
+ "reactNativeVersion": "1000.0.0",
+ "dependencies": {
+ "@react-native/oss-library-example": {
+ "root": "./node_modules/@react-native/oss-library-example",
+ "name": "@react-native/oss-library-example",
+ "platforms": {
+ "ios": {
+ "podspecPath": "./node_modules/@react-native/oss-library-example/OSSLibraryExample.podspec",
+ "version": "0.0.1",
+ "configurations": [],
+ "scriptPhases": []
+ }
+ }
}
}
}
- }
- }
- """
- .trimIndent(),
- )
+ """
+ .trimIndent(),
+ )
assertThat(ReactSettingsExtension.isCacheDirty(invalidConfigFile, buildFolder, lockfiles))
.isTrue()
diff --git a/packages/gradle-plugin/shared-testutil/build.gradle.kts b/packages/gradle-plugin/shared-testutil/build.gradle.kts
index 34591e06e8c5..edfb1a55ac5e 100644
--- a/packages/gradle-plugin/shared-testutil/build.gradle.kts
+++ b/packages/gradle-plugin/shared-testutil/build.gradle.kts
@@ -10,10 +10,7 @@ import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
-plugins {
- alias(libs.plugins.kotlin.jvm)
- alias(libs.plugins.ktfmt)
-}
+plugins { alias(libs.plugins.kotlin.jvm) }
repositories { mavenCentral() }
diff --git a/packages/gradle-plugin/shared/build.gradle.kts b/packages/gradle-plugin/shared/build.gradle.kts
index 0f62f3310afc..29ab1ea03bd2 100644
--- a/packages/gradle-plugin/shared/build.gradle.kts
+++ b/packages/gradle-plugin/shared/build.gradle.kts
@@ -10,10 +10,7 @@ import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
-plugins {
- alias(libs.plugins.kotlin.jvm)
- alias(libs.plugins.ktfmt)
-}
+plugins { alias(libs.plugins.kotlin.jvm) }
repositories { mavenCentral() }
diff --git a/packages/gradle-plugin/shared/src/main/kotlin/com/facebook/react/utils/JsonUtils.kt b/packages/gradle-plugin/shared/src/main/kotlin/com/facebook/react/utils/JsonUtils.kt
index ab632f223483..6a6eeba7b932 100644
--- a/packages/gradle-plugin/shared/src/main/kotlin/com/facebook/react/utils/JsonUtils.kt
+++ b/packages/gradle-plugin/shared/src/main/kotlin/com/facebook/react/utils/JsonUtils.kt
@@ -23,21 +23,21 @@ object JsonUtils {
fun fromAutolinkingConfigJson(input: File): ModelAutolinkingConfigJson? =
input.bufferedReader().use { reader ->
runCatching {
- // We sanitize the output of the `config` command as it could contain debug logs
- // such as:
- //
- // > AwesomeProject@0.0.1 npx
- // > rnc-cli config
- //
- // which will render the JSON invalid.
- val content =
- reader
- .readLines()
- .filterNot { line -> line.startsWith(">") }
- .joinToString("\n")
- .trim()
- gsonConverter.fromJson(content, ModelAutolinkingConfigJson::class.java)
- }
+ // We sanitize the output of the `config` command as it could contain debug logs
+ // such as:
+ //
+ // > AwesomeProject@0.0.1 npx
+ // > rnc-cli config
+ //
+ // which will render the JSON invalid.
+ val content =
+ reader
+ .readLines()
+ .filterNot { line -> line.startsWith(">") }
+ .joinToString("\n")
+ .trim()
+ gsonConverter.fromJson(content, ModelAutolinkingConfigJson::class.java)
+ }
.getOrNull()
}
}
diff --git a/packages/gradle-plugin/shared/src/test/kotlin/com/facebook/react/utils/JsonUtilsTest.kt b/packages/gradle-plugin/shared/src/test/kotlin/com/facebook/react/utils/JsonUtilsTest.kt
index 3baeaad1982f..9d330d44470a 100644
--- a/packages/gradle-plugin/shared/src/test/kotlin/com/facebook/react/utils/JsonUtilsTest.kt
+++ b/packages/gradle-plugin/shared/src/test/kotlin/com/facebook/react/utils/JsonUtilsTest.kt
@@ -36,23 +36,24 @@ class JsonUtilsTest {
@Test
fun fromPackageJson_withOldJsonConfig_returnsAnEmptyLibrary() {
- val oldJsonConfig = createJsonFile(
- """
- {
- "name": "yet another npm package",
- "codegenConfig": {
- "libraries": [
- {
- "name": "an awesome library",
- "jsSrcsDir": "../js/",
- "android": {}
+ val oldJsonConfig =
+ createJsonFile(
+ """
+ {
+ "name": "yet another npm package",
+ "codegenConfig": {
+ "libraries": [
+ {
+ "name": "an awesome library",
+ "jsSrcsDir": "../js/",
+ "android": {}
+ }
+ ]
}
- ]
- }
- }
- """
- .trimIndent(),
- )
+ }
+ """
+ .trimIndent(),
+ )
val parsed = JsonUtils.fromPackageJson(oldJsonConfig)!!
@@ -63,24 +64,25 @@ class JsonUtilsTest {
@Test
fun fromPackageJson_withValidJson_parsesCorrectly() {
- val validJson = createJsonFile(
- """
- {
- "name": "yet another npm package",
- "codegenConfig": {
- "name": "an awesome library",
- "jsSrcsDir": "../js/",
- "android": {
- "javaPackageName": "com.awesome.library"
- },
- "ios": {
- "other ios only keys": "which are ignored during parsing"
+ val validJson =
+ createJsonFile(
+ """
+ {
+ "name": "yet another npm package",
+ "codegenConfig": {
+ "name": "an awesome library",
+ "jsSrcsDir": "../js/",
+ "android": {
+ "javaPackageName": "com.awesome.library"
+ },
+ "ios": {
+ "other ios only keys": "which are ignored during parsing"
+ }
+ }
}
- }
- }
- """
- .trimIndent(),
- )
+ """
+ .trimIndent(),
+ )
val parsed = JsonUtils.fromPackageJson(validJson)!!
@@ -108,14 +110,15 @@ class JsonUtilsTest {
@Test
fun fromReactNativePackageJson_withValidJson_parsesJsonCorrectly() {
- val validJson = createJsonFile(
- """
- {
- "version": "1000.0.0"
- }
- """
- .trimIndent(),
- )
+ val validJson =
+ createJsonFile(
+ """
+ {
+ "version": "1000.0.0"
+ }
+ """
+ .trimIndent(),
+ )
val parsed = JsonUtils.fromPackageJson(validJson)!!
assertThat("1000.0.0").isEqualTo(parsed.version)
@@ -130,14 +133,15 @@ class JsonUtilsTest {
@Test
fun fromAutolinkingConfigJson_withSimpleJson_returnsIt() {
- val validJson = createJsonFile(
- """
- {
- "reactNativeVersion": "1000.0.0"
- }
- """
- .trimIndent(),
- )
+ val validJson =
+ createJsonFile(
+ """
+ {
+ "reactNativeVersion": "1000.0.0"
+ }
+ """
+ .trimIndent(),
+ )
val parsed = JsonUtils.fromAutolinkingConfigJson(validJson)!!
assertThat("1000.0.0").isEqualTo(parsed.reactNativeVersion)
@@ -145,35 +149,36 @@ class JsonUtilsTest {
@Test
fun fromAutolinkingConfigJson_withProjectSpecified_canParseIt() {
- val validJson = createJsonFile(
- """
- {
- "reactNativeVersion": "1000.0.0",
- "project": {
- "ios": {
- "sourceDir": "./packages/rn-tester",
- "xcodeProject": {
- "name": "RNTesterPods.xcworkspace",
- "isWorkspace": true
- },
- "automaticPodsInstallation": false
- },
- "android": {
- "sourceDir": "./packages/rn-tester",
- "appName": "RN-Tester",
- "packageName": "com.facebook.react.uiapp",
- "applicationId": "com.facebook.react.uiapp",
- "mainActivity": ".RNTesterActivity",
- "watchModeCommandParams": [
- "--mode HermesDebug"
- ],
- "dependencyConfiguration": "implementation"
+ val validJson =
+ createJsonFile(
+ """
+ {
+ "reactNativeVersion": "1000.0.0",
+ "project": {
+ "ios": {
+ "sourceDir": "./packages/rn-tester",
+ "xcodeProject": {
+ "name": "RNTesterPods.xcworkspace",
+ "isWorkspace": true
+ },
+ "automaticPodsInstallation": false
+ },
+ "android": {
+ "sourceDir": "./packages/rn-tester",
+ "appName": "RN-Tester",
+ "packageName": "com.facebook.react.uiapp",
+ "applicationId": "com.facebook.react.uiapp",
+ "mainActivity": ".RNTesterActivity",
+ "watchModeCommandParams": [
+ "--mode HermesDebug"
+ ],
+ "dependencyConfiguration": "implementation"
+ }
+ }
}
- }
- }
- """
- .trimIndent(),
- )
+ """
+ .trimIndent(),
+ )
val parsed = JsonUtils.fromAutolinkingConfigJson(validJson)!!
assertThat("./packages/rn-tester").isEqualTo(parsed.project!!.android!!.sourceDir)
@@ -189,39 +194,40 @@ class JsonUtilsTest {
@Test
fun fromAutolinkingConfigJson_withInfoLogs_sanitizeAndParseIt() {
@Suppress("JsonStandardCompliance")
- val validJson = createJsonFile(
- """
-
- > AwesomeProject@0.0.1 npx
- > rnc-cli config
-
- {
- "reactNativeVersion": "1000.0.0",
- "project": {
- "ios": {
- "sourceDir": "./packages/rn-tester",
- "xcodeProject": {
- "name": "RNTesterPods.xcworkspace",
- "isWorkspace": true
- },
- "automaticPodsInstallation": false
- },
- "android": {
- "sourceDir": "./packages/rn-tester",
- "appName": "RN-Tester",
- "packageName": "com.facebook.react.uiapp",
- "applicationId": "com.facebook.react.uiapp",
- "mainActivity": ".RNTesterActivity",
- "watchModeCommandParams": [
- "--mode HermesDebug"
- ],
- "dependencyConfiguration": "implementation"
- }
- }
- }
- """
- .trimIndent(),
- )
+ val validJson =
+ createJsonFile(
+ """
+
+ > AwesomeProject@0.0.1 npx
+ > rnc-cli config
+
+ {
+ "reactNativeVersion": "1000.0.0",
+ "project": {
+ "ios": {
+ "sourceDir": "./packages/rn-tester",
+ "xcodeProject": {
+ "name": "RNTesterPods.xcworkspace",
+ "isWorkspace": true
+ },
+ "automaticPodsInstallation": false
+ },
+ "android": {
+ "sourceDir": "./packages/rn-tester",
+ "appName": "RN-Tester",
+ "packageName": "com.facebook.react.uiapp",
+ "applicationId": "com.facebook.react.uiapp",
+ "mainActivity": ".RNTesterActivity",
+ "watchModeCommandParams": [
+ "--mode HermesDebug"
+ ],
+ "dependencyConfiguration": "implementation"
+ }
+ }
+ }
+ """
+ .trimIndent(),
+ )
val parsed = JsonUtils.fromAutolinkingConfigJson(validJson)!!
assertThat("./packages/rn-tester").isEqualTo(parsed.project!!.android!!.sourceDir)
@@ -236,44 +242,45 @@ class JsonUtilsTest {
@Test
fun fromAutolinkingConfigJson_withDependenciesSpecified_canParseIt() {
- val validJson = createJsonFile(
- """
- {
- "reactNativeVersion": "1000.0.0",
- "dependencies": {
- "@react-native/oss-library-example": {
- "root": "./node_modules/@react-native/oss-library-example",
- "name": "@react-native/oss-library-example",
- "platforms": {
- "ios": {
- "podspecPath": "./node_modules/@react-native/oss-library-example/OSSLibraryExample.podspec",
- "version": "0.0.1",
- "configurations": [],
- "scriptPhases": []
- },
- "android": {
- "sourceDir": "./node_modules/@react-native/oss-library-example/android",
- "packageImportPath": "import com.facebook.react.osslibraryexample.OSSLibraryExamplePackage;",
- "packageInstance": "new OSSLibraryExamplePackage()",
- "buildTypes": ["staging", "debug", "release"],
- "libraryName": "OSSLibraryExampleSpec",
- "componentDescriptors": [
- "SampleNativeComponentComponentDescriptor"
- ],
- "cmakeListsPath": "./node_modules/@react-native/oss-library-example/android/build/generated/source/codegen/jni/CMakeLists.txt",
- "cxxModuleCMakeListsModuleName": null,
- "cxxModuleCMakeListsPath": null,
- "cxxModuleHeaderName": null,
- "dependencyConfiguration": "implementation",
- "isPureCxxDependency": false
+ val validJson =
+ createJsonFile(
+ """
+ {
+ "reactNativeVersion": "1000.0.0",
+ "dependencies": {
+ "@react-native/oss-library-example": {
+ "root": "./node_modules/@react-native/oss-library-example",
+ "name": "@react-native/oss-library-example",
+ "platforms": {
+ "ios": {
+ "podspecPath": "./node_modules/@react-native/oss-library-example/OSSLibraryExample.podspec",
+ "version": "0.0.1",
+ "configurations": [],
+ "scriptPhases": []
+ },
+ "android": {
+ "sourceDir": "./node_modules/@react-native/oss-library-example/android",
+ "packageImportPath": "import com.facebook.react.osslibraryexample.OSSLibraryExamplePackage;",
+ "packageInstance": "new OSSLibraryExamplePackage()",
+ "buildTypes": ["staging", "debug", "release"],
+ "libraryName": "OSSLibraryExampleSpec",
+ "componentDescriptors": [
+ "SampleNativeComponentComponentDescriptor"
+ ],
+ "cmakeListsPath": "./node_modules/@react-native/oss-library-example/android/build/generated/source/codegen/jni/CMakeLists.txt",
+ "cxxModuleCMakeListsModuleName": null,
+ "cxxModuleCMakeListsPath": null,
+ "cxxModuleHeaderName": null,
+ "dependencyConfiguration": "implementation",
+ "isPureCxxDependency": false
+ }
+ }
}
}
}
- }
- }
- """
- .trimIndent(),
- )
+ """
+ .trimIndent(),
+ )
val parsed = JsonUtils.fromAutolinkingConfigJson(validJson)!!
assertThat("./node_modules/@react-native/oss-library-example")
@@ -325,8 +332,8 @@ class JsonUtilsTest {
.componentDescriptors,
)
assertThat(
- "./node_modules/@react-native/oss-library-example/android/build/generated/source/codegen/jni/CMakeLists.txt",
- )
+ "./node_modules/@react-native/oss-library-example/android/build/generated/source/codegen/jni/CMakeLists.txt",
+ )
.isEqualTo(
parsed.dependencies!!["@react-native/oss-library-example"]!!
.platforms!!
@@ -334,25 +341,25 @@ class JsonUtilsTest {
.cmakeListsPath,
)
assertThat(
- parsed.dependencies!!["@react-native/oss-library-example"]!!
- .platforms!!
- .android!!
- .cxxModuleHeaderName,
- )
+ parsed.dependencies!!["@react-native/oss-library-example"]!!
+ .platforms!!
+ .android!!
+ .cxxModuleHeaderName,
+ )
.isNull()
assertThat(
- parsed.dependencies!!["@react-native/oss-library-example"]!!
- .platforms!!
- .android!!
- .cxxModuleCMakeListsPath,
- )
+ parsed.dependencies!!["@react-native/oss-library-example"]!!
+ .platforms!!
+ .android!!
+ .cxxModuleCMakeListsPath,
+ )
.isNull()
assertThat(
- parsed.dependencies!!["@react-native/oss-library-example"]!!
- .platforms!!
- .android!!
- .cxxModuleCMakeListsModuleName,
- )
+ parsed.dependencies!!["@react-native/oss-library-example"]!!
+ .platforms!!
+ .android!!
+ .cxxModuleCMakeListsModuleName,
+ )
.isNull()
assertThat("implementation")
.isEqualTo(
@@ -362,11 +369,11 @@ class JsonUtilsTest {
.dependencyConfiguration,
)
assertThat(
- parsed.dependencies!!["@react-native/oss-library-example"]!!
- .platforms!!
- .android!!
- .isPureCxxDependency!!,
- )
+ parsed.dependencies!!["@react-native/oss-library-example"]!!
+ .platforms!!
+ .android!!
+ .isPureCxxDependency!!,
+ )
.isFalse()
}
diff --git a/packages/react-native-popup-menu-android/android/src/main/java/com/facebook/react/popupmenu/PopupMenuPackage.kt b/packages/react-native-popup-menu-android/android/src/main/java/com/facebook/react/popupmenu/PopupMenuPackage.kt
index 5878a21d8834..00fe43200f05 100644
--- a/packages/react-native-popup-menu-android/android/src/main/java/com/facebook/react/popupmenu/PopupMenuPackage.kt
+++ b/packages/react-native-popup-menu-android/android/src/main/java/com/facebook/react/popupmenu/PopupMenuPackage.kt
@@ -18,9 +18,11 @@ import com.facebook.react.uimanager.ViewManager
@ReactModuleList(nativeModules = arrayOf())
public class PopupMenuPackage() : BaseReactPackage(), ViewManagerOnDemandReactPackage {
- private val viewManagersMap: Map = mapOf(
- ReactPopupMenuManager.REACT_CLASS to ModuleSpec.viewManagerSpec({ ReactPopupMenuManager() }),
- )
+ private val viewManagersMap: Map =
+ mapOf(
+ ReactPopupMenuManager.REACT_CLASS to
+ ModuleSpec.viewManagerSpec({ ReactPopupMenuManager() }),
+ )
override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
return null
diff --git a/packages/react-native-popup-menu-android/android/src/main/java/com/facebook/react/popupmenu/ReactPopupMenuManager.kt b/packages/react-native-popup-menu-android/android/src/main/java/com/facebook/react/popupmenu/ReactPopupMenuManager.kt
index 756bfa702ab4..17b3376d558d 100644
--- a/packages/react-native-popup-menu-android/android/src/main/java/com/facebook/react/popupmenu/ReactPopupMenuManager.kt
+++ b/packages/react-native-popup-menu-android/android/src/main/java/com/facebook/react/popupmenu/ReactPopupMenuManager.kt
@@ -53,10 +53,11 @@ public class ReactPopupMenuManager :
public companion object {
public const val REACT_CLASS: String = "AndroidPopupMenu"
private const val REGISTRATION_NAME = "registrationName"
- private val DIRECT_EVENT_TYPE_CONSTANT = mapOf(
- PopupMenuSelectionEvent.EVENT_NAME to
- mapOf(REGISTRATION_NAME to "onPopupMenuSelectionChange"),
- PopupMenuDismissEvent.EVENT_NAME to mapOf(REGISTRATION_NAME to "onPopupMenuDismiss"),
- )
+ private val DIRECT_EVENT_TYPE_CONSTANT =
+ mapOf(
+ PopupMenuSelectionEvent.EVENT_NAME to
+ mapOf(REGISTRATION_NAME to "onPopupMenuSelectionChange"),
+ PopupMenuDismissEvent.EVENT_NAME to mapOf(REGISTRATION_NAME to "onPopupMenuDismiss"),
+ )
}
}
diff --git a/packages/react-native/ReactAndroid/build.gradle.kts b/packages/react-native/ReactAndroid/build.gradle.kts
index 8a27e3e4f470..0dfe5a30aa4a 100644
--- a/packages/react-native/ReactAndroid/build.gradle.kts
+++ b/packages/react-native/ReactAndroid/build.gradle.kts
@@ -18,7 +18,6 @@ plugins {
id("com.facebook.react")
alias(libs.plugins.android.library)
alias(libs.plugins.download)
- alias(libs.plugins.ktfmt)
}
version = project.findProperty("VERSION_NAME")?.toString()!!
@@ -309,10 +308,11 @@ val preparePrefab by
outputDir.set(prefabHeadersDir)
}
-val createNativeDepsDirectories by tasks.registering {
- downloadsDir.mkdirs()
- thirdPartyNdkDir.mkdirs()
-}
+val createNativeDepsDirectories by
+ tasks.registering {
+ downloadsDir.mkdirs()
+ thirdPartyNdkDir.mkdirs()
+ }
val downloadBoostDest = File(downloadsDir, "boost_${BOOST_VERSION}.tar.gz")
val downloadBoost by
@@ -453,21 +453,23 @@ val prepareGlog by
}
// Tasks used by Fantom to download the Native 3p dependencies used.
-val prepareNative3pDependencies by tasks.registering {
- dependsOn(
- prepareBoost,
- prepareDoubleConversion,
- prepareFastFloat,
- prepareFmt,
- prepareFolly,
- prepareGlog,
- )
-}
+val prepareNative3pDependencies by
+ tasks.registering {
+ dependsOn(
+ prepareBoost,
+ prepareDoubleConversion,
+ prepareFastFloat,
+ prepareFmt,
+ prepareFolly,
+ prepareGlog,
+ )
+ }
-val prepareKotlinBuildScriptModel by tasks.registering {
- // This task is run when Gradle Sync is running.
- // We create it here so we can let it depend on preBuild inside the android{}
-}
+val prepareKotlinBuildScriptModel by
+ tasks.registering {
+ // This task is run when Gradle Sync is running.
+ // We create it here so we can let it depend on preBuild inside the android{}
+ }
// As ReactAndroid builds from source, the codegen needs to be built before it can be invoked.
// This is not the case for users of React Native, as we ship a compiled version of the codegen.
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/debug/tags/ReactDebugOverlayTags.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/debug/tags/ReactDebugOverlayTags.kt
index 40089646df04..faf64f2a64fe 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/debug/tags/ReactDebugOverlayTags.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/debug/tags/ReactDebugOverlayTags.kt
@@ -28,9 +28,10 @@ internal object ReactDebugOverlayTags {
val NATIVE_MODULE: DebugOverlayTag =
DebugOverlayTag("Native Module", "Native Module init", Color.rgb(0x80, 0x00, 0x80))
@JvmField
- val UI_MANAGER: DebugOverlayTag = DebugOverlayTag(
- "UI Manager",
- "UI Manager View Operations (requires restart\nwarning: this is spammy)",
- Color.CYAN,
- )
+ val UI_MANAGER: DebugOverlayTag =
+ DebugOverlayTag(
+ "UI Manager",
+ "UI Manager View Operations (requires restart\nwarning: this is spammy)",
+ Color.CYAN,
+ )
}
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactAndroidHWInputDeviceHelper.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactAndroidHWInputDeviceHelper.kt
index 22388c9fbef4..42e01e8304c2 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactAndroidHWInputDeviceHelper.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactAndroidHWInputDeviceHelper.kt
@@ -75,26 +75,27 @@ internal class ReactAndroidHWInputDeviceHelper {
* Contains a mapping between handled KeyEvents and the corresponding navigation event that
* should be fired when the KeyEvent is received.
*/
- private val KEY_EVENTS_ACTIONS: Map = mapOf(
- KeyEvent.KEYCODE_DPAD_CENTER to "select",
- KeyEvent.KEYCODE_ENTER to "select",
- KeyEvent.KEYCODE_SPACE to "select",
- KeyEvent.KEYCODE_MEDIA_PLAY to "play",
- KeyEvent.KEYCODE_MEDIA_PAUSE to "pause",
- KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE to "playPause",
- KeyEvent.KEYCODE_MEDIA_REWIND to "rewind",
- KeyEvent.KEYCODE_MEDIA_FAST_FORWARD to "fastForward",
- KeyEvent.KEYCODE_MEDIA_STOP to "stop",
- KeyEvent.KEYCODE_MEDIA_NEXT to "next",
- KeyEvent.KEYCODE_MEDIA_PREVIOUS to "previous",
- KeyEvent.KEYCODE_DPAD_UP to "up",
- KeyEvent.KEYCODE_DPAD_RIGHT to "right",
- KeyEvent.KEYCODE_DPAD_DOWN to "down",
- KeyEvent.KEYCODE_DPAD_LEFT to "left",
- KeyEvent.KEYCODE_INFO to "info",
- KeyEvent.KEYCODE_MENU to "menu",
- KeyEvent.KEYCODE_CHANNEL_UP to "channelUp",
- KeyEvent.KEYCODE_CHANNEL_DOWN to "channelDown",
- )
+ private val KEY_EVENTS_ACTIONS: Map =
+ mapOf(
+ KeyEvent.KEYCODE_DPAD_CENTER to "select",
+ KeyEvent.KEYCODE_ENTER to "select",
+ KeyEvent.KEYCODE_SPACE to "select",
+ KeyEvent.KEYCODE_MEDIA_PLAY to "play",
+ KeyEvent.KEYCODE_MEDIA_PAUSE to "pause",
+ KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE to "playPause",
+ KeyEvent.KEYCODE_MEDIA_REWIND to "rewind",
+ KeyEvent.KEYCODE_MEDIA_FAST_FORWARD to "fastForward",
+ KeyEvent.KEYCODE_MEDIA_STOP to "stop",
+ KeyEvent.KEYCODE_MEDIA_NEXT to "next",
+ KeyEvent.KEYCODE_MEDIA_PREVIOUS to "previous",
+ KeyEvent.KEYCODE_DPAD_UP to "up",
+ KeyEvent.KEYCODE_DPAD_RIGHT to "right",
+ KeyEvent.KEYCODE_DPAD_DOWN to "down",
+ KeyEvent.KEYCODE_DPAD_LEFT to "left",
+ KeyEvent.KEYCODE_INFO to "info",
+ KeyEvent.KEYCODE_MENU to "menu",
+ KeyEvent.KEYCODE_CHANNEL_UP to "channelUp",
+ KeyEvent.KEYCODE_CHANNEL_DOWN to "channelDown",
+ )
}
}
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/animated/InterpolationAnimatedNode.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/animated/InterpolationAnimatedNode.kt
index 22cfaeb6f423..7d7eda1086c1 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/animated/InterpolationAnimatedNode.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/animated/InterpolationAnimatedNode.kt
@@ -260,15 +260,16 @@ internal class InterpolationAnimatedNode(config: ReadableMap) : ValueAnimatedNod
val m = numericPattern.matcher(pattern)
var i = 0
while (m.find() && i < outputRange[rangeIndex].size) {
- val v = interpolate(
- value,
- inputRange[rangeIndex],
- inputRange[rangeIndex + 1],
- outputRange[rangeIndex][i],
- outputRange[rangeIndex + 1][i],
- extrapolateLeft,
- extrapolateRight,
- )
+ val v =
+ interpolate(
+ value,
+ inputRange[rangeIndex],
+ inputRange[rangeIndex + 1],
+ outputRange[rangeIndex][i],
+ outputRange[rangeIndex + 1][i],
+ extrapolateLeft,
+ extrapolateRight,
+ )
val intVal = v.toInt()
m.appendReplacement(sb, if (intVal.toDouble() != v) v.toString() else intVal.toString())
i++
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/animated/NativeAnimatedNodesManager.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/animated/NativeAnimatedNodesManager.kt
index 919d55de20a4..d094c8be26b5 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/animated/NativeAnimatedNodesManager.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/animated/NativeAnimatedNodesManager.kt
@@ -756,9 +756,10 @@ public class NativeAnimatedNodesManager(
// or disconnected regions, indicating a partially-set-up animation graph, which is not
// fatal and can stay a warning.
val reason = if (cyclesDetected > 0) ("cycles ($cyclesDetected)") else "disconnected regions"
- val ex = IllegalStateException(
- ("Looks like animated nodes graph has ${reason}, there are $activeNodesCount but toposort visited only $updatedNodesCount"),
- )
+ val ex =
+ IllegalStateException(
+ ("Looks like animated nodes graph has ${reason}, there are $activeNodesCount but toposort visited only $updatedNodesCount"),
+ )
// TODO T71377544: investigate these SoftExceptions and see if we can remove entirely
// or fix the root cause
ReactSoftExceptionLogger.logSoftException(TAG, ReactNoCrashSoftException(ex))
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/queue/MessageQueueThreadImpl.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/queue/MessageQueueThreadImpl.kt
index 4e29037207a5..dbc15af9927b 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/queue/MessageQueueThreadImpl.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/queue/MessageQueueThreadImpl.kt
@@ -142,17 +142,18 @@ private constructor(
exceptionHandler: QueueThreadExceptionHandler,
): MessageQueueThreadImpl {
val looperFuture = SimpleSettableFuture()
- val bgThread = Thread(
- null,
- {
- Process.setThreadPriority(Process.THREAD_PRIORITY_DISPLAY)
- Looper.prepare()
- looperFuture.set(Looper.myLooper())
- Looper.loop()
- },
- "mqt_$name",
- stackSize,
- )
+ val bgThread =
+ Thread(
+ null,
+ {
+ Process.setThreadPriority(Process.THREAD_PRIORITY_DISPLAY)
+ Looper.prepare()
+ looperFuture.set(Looper.myLooper())
+ Looper.loop()
+ },
+ "mqt_$name",
+ stackSize,
+ )
bgThread.start()
val looper =
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/queue/ReactQueueConfigurationSpec.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/queue/ReactQueueConfigurationSpec.kt
index 1d6f3e7cac22..310ec3249ef0 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/queue/ReactQueueConfigurationSpec.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/queue/ReactQueueConfigurationSpec.kt
@@ -44,9 +44,10 @@ public constructor(
public fun builder(): Builder = Builder()
@JvmStatic
- public fun createDefault(): ReactQueueConfigurationSpec = ReactQueueConfigurationSpec(
- newBackgroundThreadSpec("native_modules"),
- newBackgroundThreadSpec("js"),
- )
+ public fun createDefault(): ReactQueueConfigurationSpec =
+ ReactQueueConfigurationSpec(
+ newBackgroundThreadSpec("native_modules"),
+ newBackgroundThreadSpec("js"),
+ )
}
}
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/defaults/DefaultReactHost.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/defaults/DefaultReactHost.kt
index 8a01895c6cf0..a2b934f830f3 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/defaults/DefaultReactHost.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/defaults/DefaultReactHost.kt
@@ -87,25 +87,27 @@ public object DefaultReactHost {
}
val defaultTmmDelegateBuilder = DefaultTurboModuleManagerDelegate.Builder()
cxxReactPackageProviders.forEach { defaultTmmDelegateBuilder.addCxxReactPackage(it) }
- val defaultReactHostDelegate = DefaultReactHostDelegate(
- jsMainModulePath = jsMainModulePath,
- jsBundleLoader = bundleLoader,
- reactPackages = packageList,
- jsRuntimeFactory = jsRuntimeFactory ?: HermesInstance(),
- bindingsInstaller = bindingsInstaller,
- turboModuleManagerDelegateBuilder = defaultTmmDelegateBuilder,
- exceptionHandler = exceptionHandler,
- )
+ val defaultReactHostDelegate =
+ DefaultReactHostDelegate(
+ jsMainModulePath = jsMainModulePath,
+ jsBundleLoader = bundleLoader,
+ reactPackages = packageList,
+ jsRuntimeFactory = jsRuntimeFactory ?: HermesInstance(),
+ bindingsInstaller = bindingsInstaller,
+ turboModuleManagerDelegateBuilder = defaultTmmDelegateBuilder,
+ exceptionHandler = exceptionHandler,
+ )
val componentFactory = ComponentFactory()
DefaultComponentsRegistry.register(componentFactory)
// TODO: T164788699 find alternative of accessing ReactHostImpl for initialising reactHost
- val newReactHost = ReactHostImpl(
- context,
- defaultReactHostDelegate,
- componentFactory,
- true /* allowPackagerServerAccess */,
- useDevSupport,
- )
+ val newReactHost =
+ ReactHostImpl(
+ context,
+ defaultReactHostDelegate,
+ componentFactory,
+ true /* allowPackagerServerAccess */,
+ useDevSupport,
+ )
reactHost = newReactHost
return newReactHost
}
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/defaults/DefaultTurboModuleManagerDelegate.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/defaults/DefaultTurboModuleManagerDelegate.kt
index 53b675fe6472..bac72fb13d31 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/defaults/DefaultTurboModuleManagerDelegate.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/defaults/DefaultTurboModuleManagerDelegate.kt
@@ -59,11 +59,12 @@ private constructor(
override fun build(
context: ReactApplicationContext,
packages: List,
- ): DefaultTurboModuleManagerDelegate = DefaultTurboModuleManagerDelegate(
- context,
- packages,
- cxxReactPackageProviders.flatMap { provider -> provider(context) },
- )
+ ): DefaultTurboModuleManagerDelegate =
+ DefaultTurboModuleManagerDelegate(
+ context,
+ packages,
+ cxxReactPackageProviders.flatMap { provider -> provider(context) },
+ )
}
private companion object {
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DebugOverlayController.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DebugOverlayController.kt
index 261af4d5fd6a..068c4e1824cf 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DebugOverlayController.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DebugOverlayController.kt
@@ -61,10 +61,11 @@ internal class DebugOverlayController(private val reactContext: ReactContext) {
fun requestPermission(context: Context) {
// Get permission to show debug overlay in dev builds.
if (!Settings.canDrawOverlays(context)) {
- val intent = Intent(
- Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
- Uri.parse("package:" + context.packageName),
- )
+ val intent =
+ Intent(
+ Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
+ Uri.parse("package:" + context.packageName),
+ )
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
FLog.w(
ReactConstants.TAG,
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DefaultDevLoadingViewImplementation.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DefaultDevLoadingViewImplementation.kt
index cc71f4f78eee..ad783e8bb494 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DefaultDevLoadingViewImplementation.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DefaultDevLoadingViewImplementation.kt
@@ -140,11 +140,12 @@ public class DefaultDevLoadingViewImplementation(
// Allow tapping anywhere on the banner to dismiss
rootView.setOnClickListener { hideInternal() }
- val popup = PopupWindow(
- rootView,
- ViewGroup.LayoutParams.MATCH_PARENT,
- ViewGroup.LayoutParams.WRAP_CONTENT,
- )
+ val popup =
+ PopupWindow(
+ rootView,
+ ViewGroup.LayoutParams.MATCH_PARENT,
+ ViewGroup.LayoutParams.WRAP_CONTENT,
+ )
popup.showAtLocation(currentActivity.window.decorView, Gravity.NO_GRAVITY, 0, topOffset)
devLoadingView = textView // Store the TextView for updateProgress()
devLoadingPopup = popup
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevServerHelper.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevServerHelper.kt
index 81561bc56c68..6f90b41becfc 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevServerHelper.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevServerHelper.kt
@@ -174,11 +174,11 @@ public open class DevServerHelper(
checkNotNull(clientId)
packagerClient =
JSPackagerClient(
- clientId,
- packagerConnectionSettings,
- handlers,
- onPackagerConnectedCallback,
- )
+ clientId,
+ packagerConnectionSettings,
+ handlers,
+ onPackagerConnectedCallback,
+ )
.apply { init() }
return null
@@ -215,10 +215,10 @@ public open class DevServerHelper(
}
inspectorPackagerConnection =
CxxInspectorPackagerConnection(
- this@DevServerHelper.inspectorDeviceUrl,
- deviceName,
- packageName,
- )
+ this@DevServerHelper.inspectorDeviceUrl,
+ deviceName,
+ packageName,
+ )
.apply { connect() }
return null
}
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerBase.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerBase.kt
index 788bb00406e0..099789e37cab 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerBase.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerBase.kt
@@ -107,14 +107,15 @@ public abstract class DevSupportManagerBase(
public final override var currentReactContext: ReactContext? = null
private set
- public final override val devSettings: DeveloperSettings = DevInternalSettings(
- applicationContext,
- object : DevInternalSettings.Listener {
- override fun onInternalSettingsChanged() {
- this@DevSupportManagerBase.reloadSettings()
- }
- },
- )
+ public final override val devSettings: DeveloperSettings =
+ DevInternalSettings(
+ applicationContext,
+ object : DevInternalSettings.Listener {
+ override fun onInternalSettingsChanged() {
+ this@DevSupportManagerBase.reloadSettings()
+ }
+ },
+ )
override val currentActivity: Activity?
get() = reactInstanceDevHelper.currentActivity
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/PerftestDevSupportManager.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/PerftestDevSupportManager.kt
index b9f75d1f1ddf..f0cd50b3cda9 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/PerftestDevSupportManager.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/PerftestDevSupportManager.kt
@@ -18,12 +18,13 @@ internal class PerftestDevSupportManager(
applicationContext: Context,
) : ReleaseDevSupportManager() {
- override val devSettings: DeveloperSettings = DevInternalSettings(
- applicationContext,
- object : DevInternalSettings.Listener {
- override fun onInternalSettingsChanged() = Unit
- },
- )
+ override val devSettings: DeveloperSettings =
+ DevInternalSettings(
+ applicationContext,
+ object : DevInternalSettings.Listener {
+ override fun onInternalSettingsChanged() = Unit
+ },
+ )
private val devServerHelper: DevServerHelper =
DevServerHelper(devSettings, applicationContext, devSettings.packagerConnectionSettings)
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/RedBoxContentView.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/RedBoxContentView.kt
index 47c2c5aece86..4a4891aede20 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/RedBoxContentView.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/RedBoxContentView.kt
@@ -181,14 +181,15 @@ internal class RedBoxContentView(
companion object {
private val JSON: MediaType? = MediaType.parse("application/json; charset=utf-8")
- private fun stackFrameToJson(frame: StackFrame) = JSONObject(
- mapOf(
- "file" to frame.file,
- "methodName" to frame.method,
- "lineNumber" to frame.line,
- "column" to frame.column,
- ),
- )
+ private fun stackFrameToJson(frame: StackFrame) =
+ JSONObject(
+ mapOf(
+ "file" to frame.file,
+ "methodName" to frame.method,
+ "lineNumber" to frame.line,
+ "column" to frame.column,
+ ),
+ )
}
}
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/StackTraceHelper.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/StackTraceHelper.kt
index 59ef0b222bb1..fccfa59e9804 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/StackTraceHelper.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/StackTraceHelper.kt
@@ -248,14 +248,15 @@ public object StackTraceHelper {
) : StackFrame {
/** Convert the stack frame to a JSON representation. */
- override fun toJSON(): JSONObject = JSONObject(
- mapOf(
- FILE_KEY to (file.orEmpty()),
- METHOD_NAME_KEY to method,
- LINE_NUMBER_KEY to line,
- COLUMN_KEY to column,
- COLLAPSE_KEY to isCollapsed,
- ),
- )
+ override fun toJSON(): JSONObject =
+ JSONObject(
+ mapOf(
+ FILE_KEY to (file.orEmpty()),
+ METHOD_NAME_KEY to method,
+ LINE_NUMBER_KEY to line,
+ COLUMN_KEY to column,
+ COLLAPSE_KEY to isCollapsed,
+ ),
+ )
}
}
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/perfmonitor/PerfMonitorOverlayView.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/perfmonitor/PerfMonitorOverlayView.kt
index 63d5fa858d46..0403aa2a9961 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/perfmonitor/PerfMonitorOverlayView.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/perfmonitor/PerfMonitorOverlayView.kt
@@ -142,9 +142,8 @@ internal class PerfMonitorOverlayView(
val dialog =
createAnchoredDialog(dpToPx(12f), dpToPx(12f)).apply { setContentView(containerLayout) }
dialog.window?.apply {
- attributes = attributes?.apply {
- flags = flags or WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
- }
+ attributes =
+ attributes?.apply { flags = flags or WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE }
}
return dialog
@@ -159,13 +158,14 @@ internal class PerfMonitorOverlayView(
setCancelable(false)
}
dialog.window?.apply {
- attributes = attributes?.apply {
- width = WindowManager.LayoutParams.WRAP_CONTENT
- height = WindowManager.LayoutParams.WRAP_CONTENT
- gravity = Gravity.TOP or Gravity.END
- x = offsetX.toInt()
- y = offsetY.toInt()
- }
+ attributes =
+ attributes?.apply {
+ width = WindowManager.LayoutParams.WRAP_CONTENT
+ height = WindowManager.LayoutParams.WRAP_CONTENT
+ gravity = Gravity.TOP or Gravity.END
+ x = offsetX.toInt()
+ y = offsetY.toInt()
+ }
}
dialog.window?.decorView?.let { decorView ->
ViewCompat.setOnApplyWindowInsetsListener(decorView) { view, windowInsets ->
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/ViewTransitionSnapshotManager.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/ViewTransitionSnapshotManager.kt
index edb39de7bdd3..4e62a4318166 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/ViewTransitionSnapshotManager.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/ViewTransitionSnapshotManager.kt
@@ -129,12 +129,13 @@ internal class ViewTransitionSnapshotManager(
// and the partial result gets stretched to fill the pseudo-element.
val windowWidth = window.decorView.width
val windowHeight = window.decorView.height
- val clampedRect = Rect(
- viewRect.left.coerceAtLeast(0),
- viewRect.top.coerceAtLeast(0),
- viewRect.right.coerceAtMost(windowWidth),
- viewRect.bottom.coerceAtMost(windowHeight),
- )
+ val clampedRect =
+ Rect(
+ viewRect.left.coerceAtLeast(0),
+ viewRect.top.coerceAtLeast(0),
+ viewRect.right.coerceAtMost(windowWidth),
+ viewRect.bottom.coerceAtMost(windowHeight),
+ )
if (clampedRect.isEmpty) {
// Entirely off-screen — nothing to capture.
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountItemDispatcher.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountItemDispatcher.kt
index 72257c165077..984ff9e75074 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountItemDispatcher.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountItemDispatcher.kt
@@ -412,10 +412,10 @@ internal class MountItemDispatcher(
}
return buildList {
- do {
- queue.poll()?.let { add(it) }
- } while (queue.isNotEmpty())
- }
+ do {
+ queue.poll()?.let { add(it) }
+ } while (queue.isNotEmpty())
+ }
.takeIf { it.isNotEmpty() }
}
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountingManager.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountingManager.kt
index b788bb54e656..fc1f576da33d 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountingManager.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountingManager.kt
@@ -64,14 +64,15 @@ internal class MountingManager(
reactContext: ThemedReactContext?,
rootView: View?,
): SurfaceMountingManager {
- val surfaceMountingManager = SurfaceMountingManager(
- surfaceId,
- jsResponderHandler,
- viewManagerRegistry,
- rootViewManager,
- mountItemExecutor,
- checkNotNull(reactContext),
- )
+ val surfaceMountingManager =
+ SurfaceMountingManager(
+ surfaceId,
+ jsResponderHandler,
+ viewManagerRegistry,
+ rootViewManager,
+ mountItemExecutor,
+ checkNotNull(reactContext),
+ )
// There could technically be a race condition here if addRootView is called twice from
// different threads, though this is (probably) extremely unlikely, and likely an error.
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.kt
index 25cdb216c138..0c8c7bf05502 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.kt
@@ -977,9 +977,8 @@ internal constructor(
// TODO T62717437 - Use a flag to determine that these event emitters belong to virtual nodes
// only.
- val viewState: ViewState = registryLock.write {
- tagToViewState.getOrPut(reactTag) { ViewState(reactTag) }
- }
+ val viewState: ViewState =
+ registryLock.write { tagToViewState.getOrPut(reactTag) { ViewState(reactTag) } }
val previousEventEmitterWrapper = viewState.eventEmitter
synchronized(viewState) {
@@ -1140,9 +1139,8 @@ internal constructor(
)
}
- private fun getNullableViewState(reactTag: Int): ViewState? = registryLock.read {
- tagToViewState[reactTag]
- }
+ private fun getNullableViewState(reactTag: Int): ViewState? =
+ registryLock.read { tagToViewState[reactTag] }
/** Applies a bitmap as the background of the view with the given tag, if it exists. */
@UiThread
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/FabricNameComponentMapping.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/FabricNameComponentMapping.kt
index 8721e35b753d..31d93c32b695 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/FabricNameComponentMapping.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/FabricNameComponentMapping.kt
@@ -9,27 +9,28 @@ package com.facebook.react.fabric.mounting.mountitems
/** Utility class for Fabric components, this will be removed */
internal object FabricNameComponentMapping {
- private val componentNames: Map = mapOf(
- // TODO T97384889: unify component names between JS - Android - iOS - C++
- "View" to "RCTView",
- "Image" to "RCTImageView",
- "ScrollView" to "RCTScrollView",
- "Slider" to "RCTSlider",
- "ModalHostView" to "RCTModalHostView",
- "Paragraph" to "RCTText",
- "SelectableParagraph" to "RCTSelectableText",
- "Text" to "RCTText",
- "RawText" to "RCTRawText",
- "ActivityIndicatorView" to "AndroidProgressBar",
- "ShimmeringView" to "RKShimmeringView",
- "TemplateView" to "RCTTemplateView",
- "AxialGradientView" to "RCTAxialGradientView",
- "Video" to "RCTVideo",
- "Map" to "RCTMap",
- "WebView" to "RCTWebView",
- "Keyframes" to "RCTKeyframes",
- "ImpressionTrackingView" to "RCTImpressionTrackingView",
- )
+ private val componentNames: Map =
+ mapOf(
+ // TODO T97384889: unify component names between JS - Android - iOS - C++
+ "View" to "RCTView",
+ "Image" to "RCTImageView",
+ "ScrollView" to "RCTScrollView",
+ "Slider" to "RCTSlider",
+ "ModalHostView" to "RCTModalHostView",
+ "Paragraph" to "RCTText",
+ "SelectableParagraph" to "RCTSelectableText",
+ "Text" to "RCTText",
+ "RawText" to "RCTRawText",
+ "ActivityIndicatorView" to "AndroidProgressBar",
+ "ShimmeringView" to "RKShimmeringView",
+ "TemplateView" to "RCTTemplateView",
+ "AxialGradientView" to "RCTAxialGradientView",
+ "Video" to "RCTVideo",
+ "Map" to "RCTMap",
+ "WebView" to "RCTWebView",
+ "Keyframes" to "RCTKeyframes",
+ "ImpressionTrackingView" to "RCTImpressionTrackingView",
+ )
/** @return the name of component in the Fabric environment */
@JvmStatic
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/turbomodule/core/TurboModuleManager.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/turbomodule/core/TurboModuleManager.kt
index 4d7dc27b4d7f..41bc24f51df5 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/turbomodule/core/TurboModuleManager.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/turbomodule/core/TurboModuleManager.kt
@@ -50,11 +50,12 @@ public class TurboModuleManager(
@Suppress("NoHungarianNotation")
@DoNotStrip
- private val mHybridData: HybridData = initHybrid(
- jsCallInvokerHolder as CallInvokerHolderImpl,
- nativeMethodCallInvokerHolder as NativeMethodCallInvokerHolderImpl,
- delegate,
- )
+ private val mHybridData: HybridData =
+ initHybrid(
+ jsCallInvokerHolder as CallInvokerHolderImpl,
+ nativeMethodCallInvokerHolder as NativeMethodCallInvokerHolderImpl,
+ delegate,
+ )
init {
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/jstasks/HeadlessJsTaskContext.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/jstasks/HeadlessJsTaskContext.kt
index 5c023cff353d..3a18fb438010 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/jstasks/HeadlessJsTaskContext.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/jstasks/HeadlessJsTaskContext.kt
@@ -117,13 +117,14 @@ public class HeadlessJsTaskContext private constructor(reactContext: ReactContex
}
removeTimeout(taskId)
- val taskConfig = HeadlessJsTaskConfig(
- sourceTaskConfig.taskKey,
- sourceTaskConfig.data,
- sourceTaskConfig.timeout,
- sourceTaskConfig.isAllowedInForeground,
- retryPolicy.update(),
- )
+ val taskConfig =
+ HeadlessJsTaskConfig(
+ sourceTaskConfig.taskKey,
+ sourceTaskConfig.data,
+ sourceTaskConfig.timeout,
+ sourceTaskConfig.isAllowedInForeground,
+ retryPolicy.update(),
+ )
val retryAttempt = Runnable { startTask(taskConfig, taskId) }
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/blob/BlobModule.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/blob/BlobModule.kt
index abed9481bb7e..6cbe3d3f38e7 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/blob/BlobModule.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/blob/BlobModule.kt
@@ -107,9 +107,10 @@ public class BlobModule(reactContext: ReactApplicationContext) :
}
val blob = checkNotNull(map.getMap("blob"))
- val bytes = checkNotNull(
- resolve(blob.getString("blobId"), blob.getInt("offset"), blob.getInt("size")),
- )
+ val bytes =
+ checkNotNull(
+ resolve(blob.getString("blobId"), blob.getInt("offset"), blob.getInt("size")),
+ )
return RequestBody.create(MediaType.parse(type), bytes)
}
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/core/ReactChoreographer.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/core/ReactChoreographer.kt
index 16c72087426c..85bcbcdd4378 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/core/ReactChoreographer.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/core/ReactChoreographer.kt
@@ -44,27 +44,28 @@ public class ReactChoreographer private constructor(choreographerProvider: Chore
private var totalCallbacks = 0
@GuardedBy("callbackQueues") private var hasPostedCallback = false
- private val frameCallback = Choreographer.FrameCallback { frameTimeNanos ->
- synchronized(callbackQueues) {
- // Callbacks run once and are then automatically removed, the callback will
- // be posted again from postFrameCallback
- hasPostedCallback = false
- for (i in callbackQueues.indices) {
- val callbackQueue = callbackQueues[i]
- val initialLength = callbackQueue.size
- for (callback in 0 until initialLength) {
- val frameCallback = callbackQueue.pollFirst()
- if (frameCallback != null) {
- frameCallback.doFrame(frameTimeNanos)
- totalCallbacks--
- } else {
- FLog.e(ReactConstants.TAG, "Tried to execute non-existent frame callback")
+ private val frameCallback =
+ Choreographer.FrameCallback { frameTimeNanos ->
+ synchronized(callbackQueues) {
+ // Callbacks run once and are then automatically removed, the callback will
+ // be posted again from postFrameCallback
+ hasPostedCallback = false
+ for (i in callbackQueues.indices) {
+ val callbackQueue = callbackQueues[i]
+ val initialLength = callbackQueue.size
+ for (callback in 0 until initialLength) {
+ val frameCallback = callbackQueue.pollFirst()
+ if (frameCallback != null) {
+ frameCallback.doFrame(frameTimeNanos)
+ totalCallbacks--
+ } else {
+ FLog.e(ReactConstants.TAG, "Tried to execute non-existent frame callback")
+ }
+ }
}
+ maybeRemoveFrameCallback()
}
}
- maybeRemoveFrameCallback()
- }
- }
init {
UiThreadUtil.runOnUiThread { choreographer = choreographerProvider.getChoreographer() }
@@ -137,8 +138,6 @@ public class ReactChoreographer private constructor(choreographerProvider: Chore
@VisibleForTesting
internal fun overrideInstanceForTest(instance: ReactChoreographer?): ReactChoreographer? =
- choreographer.also {
- choreographer = instance
- }
+ choreographer.also { choreographer = instance }
}
}
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/debug/SourceCodeModule.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/debug/SourceCodeModule.kt
index afb529825cbd..e7298617e4c1 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/debug/SourceCodeModule.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/debug/SourceCodeModule.kt
@@ -18,13 +18,14 @@ import com.facebook.react.module.annotations.ReactModule
@ReactModule(name = NativeSourceCodeSpec.NAME)
public class SourceCodeModule(reactContext: ReactApplicationContext) :
NativeSourceCodeSpec(reactContext) {
- override fun getTypedExportedConstants(): Map = mapOf(
- "scriptURL" to
- Assertions.assertNotNull(
- reactApplicationContext.getSourceURL(),
- "No source URL loaded, have you initialised the instance?",
- ),
- )
+ override fun getTypedExportedConstants(): Map =
+ mapOf(
+ "scriptURL" to
+ Assertions.assertNotNull(
+ reactApplicationContext.getSourceURL(),
+ "No source URL loaded, have you initialised the instance?",
+ ),
+ )
public companion object {
public const val NAME: String = NativeSourceCodeSpec.NAME
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/dialog/DialogModule.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/dialog/DialogModule.kt
index 4a78c7b33dd9..984bc8aaa702 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/dialog/DialogModule.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/dialog/DialogModule.kt
@@ -191,12 +191,13 @@ public class DialogModule(reactContext: ReactApplicationContext?) :
private const val KEY_ITEMS: String = "items"
private const val KEY_CANCELABLE: String = "cancelable"
- private val CONSTANTS: Map = mapOf(
- ACTION_BUTTON_CLICKED to ACTION_BUTTON_CLICKED,
- ACTION_DISMISSED to ACTION_DISMISSED,
- KEY_BUTTON_POSITIVE to DialogInterface.BUTTON_POSITIVE,
- KEY_BUTTON_NEGATIVE to DialogInterface.BUTTON_NEGATIVE,
- KEY_BUTTON_NEUTRAL to DialogInterface.BUTTON_NEUTRAL,
- )
+ private val CONSTANTS: Map =
+ mapOf(
+ ACTION_BUTTON_CLICKED to ACTION_BUTTON_CLICKED,
+ ACTION_DISMISSED to ACTION_DISMISSED,
+ KEY_BUTTON_POSITIVE to DialogInterface.BUTTON_POSITIVE,
+ KEY_BUTTON_NEGATIVE to DialogInterface.BUTTON_NEGATIVE,
+ KEY_BUTTON_NEUTRAL to DialogInterface.BUTTON_NEUTRAL,
+ )
}
}
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/network/NetworkingModule.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/network/NetworkingModule.kt
index 5cc33ee48ee2..2e9f2a2aa316 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/network/NetworkingModule.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/network/NetworkingModule.kt
@@ -390,32 +390,33 @@ public class NetworkingModule(
clientBuilder.addNetworkInterceptor { chain ->
val originalResponse = chain.proceed(chain.request())
val originalResponseBody = checkNotNull(originalResponse.body())
- val responseBody = ProgressResponseBody(
- originalResponseBody,
- object : ProgressListener {
- var last: Long = System.nanoTime()
-
- override fun onProgress(bytesWritten: Long, contentLength: Long, done: Boolean) {
- val now = System.nanoTime()
- if (!done && !shouldDispatch(now, last)) {
- return
- }
- if (responseType == "text") {
- // For 'text' responses we continuously send response data with progress
- // info to
- // JS below, so no need to do anything here.
- return
- }
- NetworkEventUtil.onDataReceivedProgress(
- reactApplicationContext,
- requestId,
- bytesWritten,
- contentLength,
- )
- last = now
- }
- },
- )
+ val responseBody =
+ ProgressResponseBody(
+ originalResponseBody,
+ object : ProgressListener {
+ var last: Long = System.nanoTime()
+
+ override fun onProgress(bytesWritten: Long, contentLength: Long, done: Boolean) {
+ val now = System.nanoTime()
+ if (!done && !shouldDispatch(now, last)) {
+ return
+ }
+ if (responseType == "text") {
+ // For 'text' responses we continuously send response data with progress
+ // info to
+ // JS below, so no need to do anything here.
+ return
+ }
+ NetworkEventUtil.onDataReceivedProgress(
+ reactApplicationContext,
+ requestId,
+ bytesWritten,
+ contentLength,
+ )
+ last = now
+ }
+ },
+ )
originalResponse.newBuilder().body(responseBody).build()
}
}
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/toast/ToastModule.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/toast/ToastModule.kt
index ce1085fd9baf..2dac29a606e9 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/toast/ToastModule.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/toast/ToastModule.kt
@@ -20,13 +20,14 @@ import com.facebook.react.module.annotations.ReactModule
internal class ToastModule(reactContext: ReactApplicationContext) :
NativeToastAndroidSpec(reactContext) {
- override fun getTypedExportedConstants(): Map = mapOf(
- DURATION_SHORT_KEY to Toast.LENGTH_SHORT,
- DURATION_LONG_KEY to Toast.LENGTH_LONG,
- GRAVITY_TOP_KEY to (Gravity.TOP or Gravity.CENTER_HORIZONTAL),
- GRAVITY_BOTTOM_KEY to (Gravity.BOTTOM or Gravity.CENTER_HORIZONTAL),
- GRAVITY_CENTER to (Gravity.CENTER_HORIZONTAL or Gravity.CENTER_VERTICAL),
- )
+ override fun getTypedExportedConstants(): Map =
+ mapOf(
+ DURATION_SHORT_KEY to Toast.LENGTH_SHORT,
+ DURATION_LONG_KEY to Toast.LENGTH_LONG,
+ GRAVITY_TOP_KEY to (Gravity.TOP or Gravity.CENTER_HORIZONTAL),
+ GRAVITY_BOTTOM_KEY to (Gravity.BOTTOM or Gravity.CENTER_HORIZONTAL),
+ GRAVITY_CENTER to (Gravity.CENTER_HORIZONTAL or Gravity.CENTER_VERTICAL),
+ )
override fun show(message: String?, durationDouble: Double) {
val duration = durationDouble.toInt()
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/CoreReactPackage.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/CoreReactPackage.kt
index b5249b9d183c..de6735cdbfbc 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/CoreReactPackage.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/CoreReactPackage.kt
@@ -89,17 +89,18 @@ internal class CoreReactPackage(
private fun fallbackForMissingClass(): ReactModuleInfoProvider {
// In OSS case, the annotation processor does not run. We fall back on creating this byhand
- val moduleList: Array> = arrayOf>(
- AndroidInfoModule::class.java,
- DeviceInfoModule::class.java,
- SourceCodeModule::class.java,
- DevMenuModule::class.java,
- DevSettingsModule::class.java,
- DeviceEventManagerModule::class.java,
- LogBoxModule::class.java,
- ExceptionsManagerModule::class.java,
- HeadlessJsTaskSupportModule::class.java,
- )
+ val moduleList: Array> =
+ arrayOf>(
+ AndroidInfoModule::class.java,
+ DeviceInfoModule::class.java,
+ SourceCodeModule::class.java,
+ DevMenuModule::class.java,
+ DevSettingsModule::class.java,
+ DeviceEventManagerModule::class.java,
+ LogBoxModule::class.java,
+ ExceptionsManagerModule::class.java,
+ HeadlessJsTaskSupportModule::class.java,
+ )
val reactModuleInfoMap: MutableMap = HashMap()
for (moduleClass in moduleList) {
val reactModule = moduleClass.getAnnotation(ReactModule::class.java)
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactHostImpl.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactHostImpl.kt
index 4db89e7a3143..53143a87d4c2 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactHostImpl.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactHostImpl.kt
@@ -1028,22 +1028,24 @@ public class ReactHostImpl(
jsBundleLoader.onSuccess(
{ task ->
val bundleLoader = checkNotNull(task.getResult())
- val reactContext = bridgelessReactContextRef.getOrCreate {
- stateTracker.enterState(method, "Creating BridgelessReactContext")
- BridgelessReactContext(context, this)
- }
+ val reactContext =
+ bridgelessReactContextRef.getOrCreate {
+ stateTracker.enterState(method, "Creating BridgelessReactContext")
+ BridgelessReactContext(context, this)
+ }
reactContext.jsExceptionHandler = devSupportManager
stateTracker.enterState(method, "Creating ReactInstance")
- val instance = ReactInstance(
- reactContext,
- reactHostDelegate,
- componentFactory,
- devSupportManager,
- { e: Exception -> this.handleHostException(e) },
- useDevSupport,
- getOrCreateReactHostInspectorTarget(),
- )
+ val instance =
+ ReactInstance(
+ reactContext,
+ reactHostDelegate,
+ componentFactory,
+ devSupportManager,
+ { e: Exception -> this.handleHostException(e) },
+ useDevSupport,
+ getOrCreateReactHostInspectorTarget(),
+ )
reactInstance = instance
val memoryPressureListener = createMemoryPressureListener(instance)
@@ -1605,12 +1607,13 @@ public class ReactHostImpl(
TracingState.ENABLED_IN_BACKGROUND_MODE,
TracingState.ENABLED_IN_CDP_MODE -> {
if (InspectorFlags.getFrameRecordingEnabled()) {
- val observer = FrameTimingsObserver(
- _screenshotsEnabled,
- { frameTimingsSequence ->
- inspectorTarget.recordFrameTimings(frameTimingsSequence)
- },
- )
+ val observer =
+ FrameTimingsObserver(
+ _screenshotsEnabled,
+ { frameTimingsSequence ->
+ inspectorTarget.recordFrameTimings(frameTimingsSequence)
+ },
+ )
observer.setCurrentWindow(currentActivity?.window)
observer.start()
frameTimingsObserver = observer
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactInstance.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactInstance.kt
index 82debd9a48b8..cb101e8ee224 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactInstance.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactInstance.kt
@@ -119,10 +119,11 @@ internal class ReactInstance(
* Prepare the ReactInstance by installing JSI bindings, initializing Fabric + TurboModules, and
* loading the JS bundle.
*/
- val spec = ReactQueueConfigurationSpec(
- MessageQueueThreadSpec.newBackgroundThreadSpec("v_native"),
- MessageQueueThreadSpec.newBackgroundThreadSpec("v_js"),
- )
+ val spec =
+ ReactQueueConfigurationSpec(
+ MessageQueueThreadSpec.newBackgroundThreadSpec("v_native"),
+ MessageQueueThreadSpec.newBackgroundThreadSpec("v_js"),
+ )
reactQueueConfiguration = ReactQueueConfigurationImpl.create(spec, exceptionHandler)
FLog.d(TAG, "Calling initializeMessageQueueThreads()")
context.initializeMessageQueueThreads(reactQueueConfiguration)
@@ -291,9 +292,10 @@ internal class ReactInstance(
override fun reportJsException(errorMap: ProcessedError) {
val data = StackTraceHelper.convertProcessedError(errorMap)
try {
- val exceptionsManager = checkNotNull(
- getNativeModule(NativeExceptionsManagerSpec.NAME),
- )
+ val exceptionsManager =
+ checkNotNull(
+ getNativeModule(NativeExceptionsManagerSpec.NAME),
+ )
exceptionsManager.reportException(data)
} catch (e: Exception) {
// Sometimes (e.g: always with the default exception manager) the native module exceptions
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactSurfaceView.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactSurfaceView.kt
index bf3ac2397560..6ff3c2860575 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactSurfaceView.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactSurfaceView.kt
@@ -56,9 +56,10 @@ public class ReactSurfaceView(context: Context?, internal val surface: ReactSurf
// When not in edge-to-edge mode, subtract the top system bar insets so the offset is
// relative to the content area (below the status bar / cutout).
ViewCompat.getRootWindowInsets(this)?.apply {
- val insets = getInsets(
- WindowInsetsCompat.Type.statusBars() or WindowInsetsCompat.Type.displayCutout(),
- )
+ val insets =
+ getInsets(
+ WindowInsetsCompat.Type.statusBars() or WindowInsetsCompat.Type.displayCutout(),
+ )
locationInWindow[0] -= insets.left
locationInWindow[1] -= insets.top
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/internal/bolts/Task.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/internal/bolts/Task.kt
index 5c663cb74dc7..c6b2472ad27d 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/internal/bolts/Task.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/internal/bolts/Task.kt
@@ -100,15 +100,16 @@ public class Task : TaskInterface {
}
/** Turns a Task into a Task, dropping any result */
- public fun makeVoid(): Task = continueWithTask(
- { task ->
- when {
- task.isCancelled() -> cancelled()
- task.isFaulted() -> forError(task.getError())
- else -> TASK_NULL
- }
- },
- )
+ public fun makeVoid(): Task =
+ continueWithTask(
+ { task ->
+ when {
+ task.isCancelled() -> cancelled()
+ task.isFaulted() -> forError(task.getError())
+ else -> TASK_NULL
+ }
+ },
+ )
/**
* Adds a continuation that will be scheduled using the executor, returning a new task that
@@ -168,16 +169,17 @@ public class Task : TaskInterface {
public fun onSuccess(
continuation: Continuation,
executor: Executor = IMMEDIATE_EXECUTOR,
- ): Task = continueWithTask(
- { task ->
- when {
- task.isCancelled() -> cancelled()
- task.isFaulted() -> forError(task.getError())
- else -> task.continueWith(continuation)
- }
- },
- executor,
- )
+ ): Task =
+ continueWithTask(
+ { task ->
+ when {
+ task.isCancelled() -> cancelled()
+ task.isFaulted() -> forError(task.getError())
+ else -> task.continueWith(continuation)
+ }
+ },
+ executor,
+ )
/**
* Runs a continuation when a task completes successfully, forwarding along [java.lang.Exception]s
@@ -186,16 +188,17 @@ public class Task : TaskInterface {
public fun onSuccessTask(
continuation: Continuation>,
executor: Executor = IMMEDIATE_EXECUTOR,
- ): Task = continueWithTask(
- { task ->
- when {
- task.isCancelled() -> cancelled()
- task.isFaulted() -> forError(task.getError())
- else -> task.continueWithTask(continuation)
- }
- },
- executor,
- )
+ ): Task =
+ continueWithTask(
+ { task ->
+ when {
+ task.isCancelled() -> cancelled()
+ task.isFaulted() -> forError(task.getError())
+ else -> task.continueWithTask(continuation)
+ }
+ },
+ executor,
+ )
private fun runContinuations() =
synchronized(lock) {
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/shell/MainReactPackage.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/shell/MainReactPackage.kt
index f7ac78bd6eae..14b053b4196f 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/shell/MainReactPackage.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/shell/MainReactPackage.kt
@@ -139,27 +139,28 @@ constructor(private val config: MainPackageConfig? = null) :
@Suppress("DEPRECATION")
override fun createViewManagers(
reactContext: ReactApplicationContext,
- ): List> = listOf(
- ReactDrawerLayoutManager(),
- ReactHorizontalScrollViewManager(),
- ReactHorizontalScrollContainerViewManager(),
- ReactProgressBarViewManager(),
- if (ReactNativeFeatureFlags.useNestedScrollViewAndroid()) ReactNestedScrollViewManager()
- else ReactScrollViewManager(),
- ReactSwitchManager(),
- ReactSafeAreaViewManager(),
- SwipeRefreshLayoutManager(),
- // Native equivalents
- ReactImageManager(),
- ReactModalHostManager(),
- ReactTextInputManager(),
- if (ReactNativeFeatureFlags.enablePreparedTextLayout()) PreparedLayoutTextViewManager()
- else ReactTextViewManager(),
- SelectableTextViewManager(),
- ReactViewManager(),
- ReactVirtualViewManager(),
- ReactUnimplementedViewManager(),
- )
+ ): List> =
+ listOf(
+ ReactDrawerLayoutManager(),
+ ReactHorizontalScrollViewManager(),
+ ReactHorizontalScrollContainerViewManager(),
+ ReactProgressBarViewManager(),
+ if (ReactNativeFeatureFlags.useNestedScrollViewAndroid()) ReactNestedScrollViewManager()
+ else ReactScrollViewManager(),
+ ReactSwitchManager(),
+ ReactSafeAreaViewManager(),
+ SwipeRefreshLayoutManager(),
+ // Native equivalents
+ ReactImageManager(),
+ ReactModalHostManager(),
+ ReactTextInputManager(),
+ if (ReactNativeFeatureFlags.enablePreparedTextLayout()) PreparedLayoutTextViewManager()
+ else ReactTextViewManager(),
+ SelectableTextViewManager(),
+ ReactViewManager(),
+ ReactVirtualViewManager(),
+ ReactUnimplementedViewManager(),
+ )
/**
* A map of view managers that should be registered with
@@ -167,41 +168,46 @@ constructor(private val config: MainPackageConfig? = null) :
*/
@Suppress("DEPRECATION")
@SuppressLint("VisibleForTests")
- public val viewManagersMap: Map = mapOf(
- ReactDrawerLayoutManager.REACT_CLASS to
- ModuleSpec.viewManagerSpec { ReactDrawerLayoutManager() },
- ReactHorizontalScrollViewManager.REACT_CLASS to
- ModuleSpec.viewManagerSpec { ReactHorizontalScrollViewManager() },
- ReactHorizontalScrollContainerViewManager.REACT_CLASS to
- ModuleSpec.viewManagerSpec { ReactHorizontalScrollContainerViewManager() },
- ReactProgressBarViewManager.REACT_CLASS to
- ModuleSpec.viewManagerSpec { ReactProgressBarViewManager() },
- ReactSafeAreaViewManager.REACT_CLASS to
- ModuleSpec.viewManagerSpec { ReactSafeAreaViewManager() },
- ReactScrollViewManager.REACT_CLASS to
- ModuleSpec.viewManagerSpec {
- if (ReactNativeFeatureFlags.useNestedScrollViewAndroid()) ReactNestedScrollViewManager()
- else ReactScrollViewManager()
- },
- ReactSwitchManager.REACT_CLASS to ModuleSpec.viewManagerSpec { ReactSwitchManager() },
- SwipeRefreshLayoutManager.REACT_CLASS to
- ModuleSpec.viewManagerSpec { SwipeRefreshLayoutManager() },
- ReactImageManager.REACT_CLASS to ModuleSpec.viewManagerSpec { ReactImageManager() },
- ReactModalHostManager.REACT_CLASS to ModuleSpec.viewManagerSpec { ReactModalHostManager() },
- ReactTextInputManager.REACT_CLASS to ModuleSpec.viewManagerSpec { ReactTextInputManager() },
- ReactTextViewManager.REACT_CLASS to
- ModuleSpec.viewManagerSpec {
- if (ReactNativeFeatureFlags.enablePreparedTextLayout()) PreparedLayoutTextViewManager()
- else ReactTextViewManager()
- },
- SelectableTextViewManager.REACT_CLASS to
- ModuleSpec.viewManagerSpec { SelectableTextViewManager() },
- ReactViewManager.REACT_CLASS to ModuleSpec.viewManagerSpec { ReactViewManager() },
- ReactVirtualViewManager.REACT_CLASS to
- ModuleSpec.viewManagerSpec { ReactVirtualViewManager() },
- ReactUnimplementedViewManager.REACT_CLASS to
- ModuleSpec.viewManagerSpec { ReactUnimplementedViewManager() },
- )
+ public val viewManagersMap: Map =
+ mapOf(
+ ReactDrawerLayoutManager.REACT_CLASS to
+ ModuleSpec.viewManagerSpec { ReactDrawerLayoutManager() },
+ ReactHorizontalScrollViewManager.REACT_CLASS to
+ ModuleSpec.viewManagerSpec { ReactHorizontalScrollViewManager() },
+ ReactHorizontalScrollContainerViewManager.REACT_CLASS to
+ ModuleSpec.viewManagerSpec { ReactHorizontalScrollContainerViewManager() },
+ ReactProgressBarViewManager.REACT_CLASS to
+ ModuleSpec.viewManagerSpec { ReactProgressBarViewManager() },
+ ReactSafeAreaViewManager.REACT_CLASS to
+ ModuleSpec.viewManagerSpec { ReactSafeAreaViewManager() },
+ ReactScrollViewManager.REACT_CLASS to
+ ModuleSpec.viewManagerSpec {
+ if (ReactNativeFeatureFlags.useNestedScrollViewAndroid())
+ ReactNestedScrollViewManager()
+ else ReactScrollViewManager()
+ },
+ ReactSwitchManager.REACT_CLASS to ModuleSpec.viewManagerSpec { ReactSwitchManager() },
+ SwipeRefreshLayoutManager.REACT_CLASS to
+ ModuleSpec.viewManagerSpec { SwipeRefreshLayoutManager() },
+ ReactImageManager.REACT_CLASS to ModuleSpec.viewManagerSpec { ReactImageManager() },
+ ReactModalHostManager.REACT_CLASS to
+ ModuleSpec.viewManagerSpec { ReactModalHostManager() },
+ ReactTextInputManager.REACT_CLASS to
+ ModuleSpec.viewManagerSpec { ReactTextInputManager() },
+ ReactTextViewManager.REACT_CLASS to
+ ModuleSpec.viewManagerSpec {
+ if (ReactNativeFeatureFlags.enablePreparedTextLayout())
+ PreparedLayoutTextViewManager()
+ else ReactTextViewManager()
+ },
+ SelectableTextViewManager.REACT_CLASS to
+ ModuleSpec.viewManagerSpec { SelectableTextViewManager() },
+ ReactViewManager.REACT_CLASS to ModuleSpec.viewManagerSpec { ReactViewManager() },
+ ReactVirtualViewManager.REACT_CLASS to
+ ModuleSpec.viewManagerSpec { ReactVirtualViewManager() },
+ ReactUnimplementedViewManager.REACT_CLASS to
+ ModuleSpec.viewManagerSpec { ReactUnimplementedViewManager() },
+ )
public override fun getViewManagers(reactContext: ReactApplicationContext): List =
viewManagersMap.values.toList()
@@ -247,35 +253,36 @@ constructor(private val config: MainPackageConfig? = null) :
private fun fallbackForMissingClass(): ReactModuleInfoProvider {
// In the OSS case, the annotation processor does not run.
// We fall back to creating this by hand
- val moduleList: Array> = arrayOf(
- AccessibilityInfoModule::class.java,
- AppearanceModule::class.java,
- AppStateModule::class.java,
- BlobModule::class.java,
- DevLoadingModule::class.java,
- FileReaderModule::class.java,
- ClipboardModule::class.java,
- DialogModule::class.java,
- FrescoModule::class.java,
- I18nManagerModule::class.java,
- ImageLoaderModule::class.java,
- ImageStoreManager::class.java,
- IntentModule::class.java,
- if (ReactNativeFeatureFlags.cxxNativeAnimatedEnabled()) null
- else NativeAnimatedModule::class.java,
- NetworkingModule::class.java,
- PermissionsModule::class.java,
- ReactDevToolsSettingsManagerModule::class.java,
- ReactDevToolsRuntimeSettingsModule::class.java,
- ShareModule::class.java,
- StatusBarModule::class.java,
- SoundManagerModule::class.java,
- ToastModule::class.java,
- VibrationModule::class.java,
- WebSocketModule::class.java,
- )
- .filterNotNull()
- .toTypedArray()
+ val moduleList: Array> =
+ arrayOf(
+ AccessibilityInfoModule::class.java,
+ AppearanceModule::class.java,
+ AppStateModule::class.java,
+ BlobModule::class.java,
+ DevLoadingModule::class.java,
+ FileReaderModule::class.java,
+ ClipboardModule::class.java,
+ DialogModule::class.java,
+ FrescoModule::class.java,
+ I18nManagerModule::class.java,
+ ImageLoaderModule::class.java,
+ ImageStoreManager::class.java,
+ IntentModule::class.java,
+ if (ReactNativeFeatureFlags.cxxNativeAnimatedEnabled()) null
+ else NativeAnimatedModule::class.java,
+ NetworkingModule::class.java,
+ PermissionsModule::class.java,
+ ReactDevToolsSettingsManagerModule::class.java,
+ ReactDevToolsRuntimeSettingsModule::class.java,
+ ShareModule::class.java,
+ StatusBarModule::class.java,
+ SoundManagerModule::class.java,
+ ToastModule::class.java,
+ VibrationModule::class.java,
+ WebSocketModule::class.java,
+ )
+ .filterNotNull()
+ .toTypedArray()
val moduleMap =
moduleList
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/BackgroundStyleApplicator.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/BackgroundStyleApplicator.kt
index 8e1fd2ef02bf..c7d94a770c39 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/BackgroundStyleApplicator.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/BackgroundStyleApplicator.kt
@@ -535,12 +535,13 @@ public object BackgroundStyleApplicator {
paddingBoxRect.bottom = composite.bounds.bottom - (computedBorderInsets?.bottom?.dpToPx() ?: 0f)
if (composite.borderRadius?.hasRoundedBorders() == true) {
- val paddingBoxPath = createPaddingBoxPath(
- view,
- composite,
- paddingBoxRect,
- computedBorderInsets,
- )
+ val paddingBoxPath =
+ createPaddingBoxPath(
+ view,
+ composite,
+ paddingBoxRect,
+ computedBorderInsets,
+ )
paddingBoxPath.offset(drawingRect.left.toFloat(), drawingRect.top.toFloat())
// On Android 28 and below, use antialiased clipping with Porter-Duff compositing. On newer
@@ -763,38 +764,46 @@ public object BackgroundStyleApplicator {
val paddingBoxPath = Path()
- val innerTopLeftRadiusX = getInnerBorderRadius(
- computedBorderRadius?.topLeft?.horizontal?.dpToPx(),
- computedBorderInsets?.left?.dpToPx(),
- )
- val innerTopLeftRadiusY = getInnerBorderRadius(
- computedBorderRadius?.topLeft?.vertical?.dpToPx(),
- computedBorderInsets?.top?.dpToPx(),
- )
- val innerTopRightRadiusX = getInnerBorderRadius(
- computedBorderRadius?.topRight?.horizontal?.dpToPx(),
- computedBorderInsets?.right?.dpToPx(),
- )
- val innerTopRightRadiusY = getInnerBorderRadius(
- computedBorderRadius?.topRight?.vertical?.dpToPx(),
- computedBorderInsets?.top?.dpToPx(),
- )
- val innerBottomRightRadiusX = getInnerBorderRadius(
- computedBorderRadius?.bottomRight?.horizontal?.dpToPx(),
- computedBorderInsets?.right?.dpToPx(),
- )
- val innerBottomRightRadiusY = getInnerBorderRadius(
- computedBorderRadius?.bottomRight?.vertical?.dpToPx(),
- computedBorderInsets?.bottom?.dpToPx(),
- )
- val innerBottomLeftRadiusX = getInnerBorderRadius(
- computedBorderRadius?.bottomLeft?.horizontal?.dpToPx(),
- computedBorderInsets?.left?.dpToPx(),
- )
- val innerBottomLeftRadiusY = getInnerBorderRadius(
- computedBorderRadius?.bottomLeft?.vertical?.dpToPx(),
- computedBorderInsets?.bottom?.dpToPx(),
- )
+ val innerTopLeftRadiusX =
+ getInnerBorderRadius(
+ computedBorderRadius?.topLeft?.horizontal?.dpToPx(),
+ computedBorderInsets?.left?.dpToPx(),
+ )
+ val innerTopLeftRadiusY =
+ getInnerBorderRadius(
+ computedBorderRadius?.topLeft?.vertical?.dpToPx(),
+ computedBorderInsets?.top?.dpToPx(),
+ )
+ val innerTopRightRadiusX =
+ getInnerBorderRadius(
+ computedBorderRadius?.topRight?.horizontal?.dpToPx(),
+ computedBorderInsets?.right?.dpToPx(),
+ )
+ val innerTopRightRadiusY =
+ getInnerBorderRadius(
+ computedBorderRadius?.topRight?.vertical?.dpToPx(),
+ computedBorderInsets?.top?.dpToPx(),
+ )
+ val innerBottomRightRadiusX =
+ getInnerBorderRadius(
+ computedBorderRadius?.bottomRight?.horizontal?.dpToPx(),
+ computedBorderInsets?.right?.dpToPx(),
+ )
+ val innerBottomRightRadiusY =
+ getInnerBorderRadius(
+ computedBorderRadius?.bottomRight?.vertical?.dpToPx(),
+ computedBorderInsets?.bottom?.dpToPx(),
+ )
+ val innerBottomLeftRadiusX =
+ getInnerBorderRadius(
+ computedBorderRadius?.bottomLeft?.horizontal?.dpToPx(),
+ computedBorderInsets?.left?.dpToPx(),
+ )
+ val innerBottomLeftRadiusY =
+ getInnerBorderRadius(
+ computedBorderRadius?.bottomLeft?.vertical?.dpToPx(),
+ computedBorderInsets?.bottom?.dpToPx(),
+ )
paddingBoxPath.addRoundRect(
paddingBoxRect,
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/JSPointerDispatcher.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/JSPointerDispatcher.kt
index c40e2295bc47..6577976c90ed 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/JSPointerDispatcher.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/JSPointerDispatcher.kt
@@ -334,11 +334,12 @@ public class JSPointerDispatcher(private val rootViewGroup: ViewGroup) {
// https://suragch.medium.com/how-touch-events-are-delivered-in-android-eee3b607b038
val isExitFromRoot = isCapture && action == MotionEvent.ACTION_HOVER_EXIT
- val eventState = createEventState(
- activePointerId,
- motionEvent,
- clearHitPathForActivePointer = isExitFromRoot,
- )
+ val eventState =
+ createEventState(
+ activePointerId,
+ motionEvent,
+ clearHitPathForActivePointer = isExitFromRoot,
+ )
// Calculate the targetTag, with special handling for when we exit the root view. In that case,
// we use the root viewId of the last event
@@ -496,12 +497,13 @@ public class JSPointerDispatcher(private val rootViewGroup: ViewGroup) {
}
// target -> root
- val leaveViewTargets = filterByShouldDispatch(
- lastHitPath.subList(0, lastHitPath.size - firstDivergentIndexFromBack),
- EVENT.LEAVE,
- EVENT.LEAVE_CAPTURE,
- nonDivergentListeningToLeave,
- )
+ val leaveViewTargets =
+ filterByShouldDispatch(
+ lastHitPath.subList(0, lastHitPath.size - firstDivergentIndexFromBack),
+ EVENT.LEAVE,
+ EVENT.LEAVE_CAPTURE,
+ nonDivergentListeningToLeave,
+ )
if (leaveViewTargets.isNotEmpty()) {
// We want to dispatch from target -> root, so no need to reverse
dispatchEventForViewTargets(
@@ -528,12 +530,13 @@ public class JSPointerDispatcher(private val rootViewGroup: ViewGroup) {
}
// target -> root
- val enterViewTargets = filterByShouldDispatch(
- activeHitPath.subList(0, activeHitPath.size - firstDivergentIndexFromBack),
- EVENT.ENTER,
- EVENT.ENTER_CAPTURE,
- nonDivergentListeningToEnter,
- )
+ val enterViewTargets =
+ filterByShouldDispatch(
+ activeHitPath.subList(0, activeHitPath.size - firstDivergentIndexFromBack),
+ EVENT.ENTER,
+ EVENT.ENTER_CAPTURE,
+ nonDivergentListeningToEnter,
+ )
if (enterViewTargets.isNotEmpty()) {
// We want to iterate these from root -> target so we need to reverse
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/LayoutShadowNode.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/LayoutShadowNode.kt
index d072ebfe51ff..05b8b123afa8 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/LayoutShadowNode.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/LayoutShadowNode.kt
@@ -664,14 +664,15 @@ public open class LayoutShadowNode : ReactShadowNodeImpl() {
return
}
- val positionSpacingTypes = intArrayOf(
- Spacing.START,
- Spacing.END,
- Spacing.LEFT,
- Spacing.RIGHT,
- Spacing.TOP,
- Spacing.BOTTOM,
- )
+ val positionSpacingTypes =
+ intArrayOf(
+ Spacing.START,
+ Spacing.END,
+ Spacing.LEFT,
+ Spacing.RIGHT,
+ Spacing.TOP,
+ Spacing.BOTTOM,
+ )
val spacingType = maybeTransformLeftRightToStartEnd(positionSpacingTypes[index])
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/MatrixMathHelper.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/MatrixMathHelper.kt
index 3f5ffd3700b3..11275d996698 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/MatrixMathHelper.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/MatrixMathHelper.kt
@@ -115,12 +115,13 @@ public object MatrixMathHelper {
) {
// rightHandSide is the right hand side of the equation.
// rightHandSide is a vector, or point in 3d space relative to the origin.
- val rightHandSide = doubleArrayOf(
- normalizedMatrix[3],
- normalizedMatrix[7],
- normalizedMatrix[11],
- normalizedMatrix[15],
- )
+ val rightHandSide =
+ doubleArrayOf(
+ normalizedMatrix[3],
+ normalizedMatrix[7],
+ normalizedMatrix[11],
+ normalizedMatrix[15],
+ )
// Solve the equation by inverting perspectiveMatrix and multiplying
// rightHandSide by the inverse.
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactAccessibilityDelegate.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactAccessibilityDelegate.kt
index e33e14dfd3d7..6a227761f256 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactAccessibilityDelegate.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactAccessibilityDelegate.kt
@@ -562,14 +562,15 @@ public open class ReactAccessibilityDelegate( // The View this delegate is attac
public companion object {
public const val TOP_ACCESSIBILITY_ACTION_EVENT: String = "topAccessibilityAction"
- private val actionIdMap = mapOf(
- "activate" to AccessibilityActionCompat.ACTION_CLICK.id,
- "longpress" to AccessibilityActionCompat.ACTION_LONG_CLICK.id,
- "increment" to AccessibilityActionCompat.ACTION_SCROLL_FORWARD.id,
- "decrement" to AccessibilityActionCompat.ACTION_SCROLL_BACKWARD.id,
- "expand" to AccessibilityActionCompat.ACTION_EXPAND.id,
- "collapse" to AccessibilityActionCompat.ACTION_COLLAPSE.id,
- )
+ private val actionIdMap =
+ mapOf(
+ "activate" to AccessibilityActionCompat.ACTION_CLICK.id,
+ "longpress" to AccessibilityActionCompat.ACTION_LONG_CLICK.id,
+ "increment" to AccessibilityActionCompat.ACTION_SCROLL_FORWARD.id,
+ "decrement" to AccessibilityActionCompat.ACTION_SCROLL_BACKWARD.id,
+ "expand" to AccessibilityActionCompat.ACTION_EXPAND.id,
+ "collapse" to AccessibilityActionCompat.ACTION_COLLAPSE.id,
+ )
private const val TAG = "ReactAccessibilityDelegate"
private var customActionCounter = 0x3f000000
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactRootViewTagGenerator.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactRootViewTagGenerator.kt
index c1f0793be594..8227ec15ba73 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactRootViewTagGenerator.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactRootViewTagGenerator.kt
@@ -17,7 +17,6 @@ internal object ReactRootViewTagGenerator {
@JvmStatic
@Synchronized
- fun getNextRootViewTag(): Int = nextRootViewTag.also {
- nextRootViewTag += ROOT_VIEW_TAG_INCREMENT
- }
+ fun getNextRootViewTag(): Int =
+ nextRootViewTag.also { nextRootViewTag += ROOT_VIEW_TAG_INCREMENT }
}
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/RootViewUtil.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/RootViewUtil.kt
index c76e3b6496ab..bee98c26b00a 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/RootViewUtil.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/RootViewUtil.kt
@@ -40,9 +40,10 @@ public object RootViewUtil {
// When not in edge-to-edge mode, subtract the top system bar insets so the offset is
// relative to the content area (below the status bar / cutout).
ViewCompat.getRootWindowInsets(v)?.apply {
- val insets = getInsets(
- WindowInsetsCompat.Type.statusBars() or WindowInsetsCompat.Type.displayCutout(),
- )
+ val insets =
+ getInsets(
+ WindowInsetsCompat.Type.statusBars() or WindowInsetsCompat.Type.displayCutout(),
+ )
locationInWindow[0] -= insets.left
locationInWindow[1] -= insets.top
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/Spacing.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/Spacing.kt
index b3b82ecca055..2439018b76b1 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/Spacing.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/Spacing.kt
@@ -169,20 +169,21 @@ public class Spacing(private val defaultValue: Float, private val spacing: Float
/** Spacing type that represents the block start direction (top). E.g. `marginBlockStart`. */
public const val BLOCK_START: Int = 11
- private val flagsMap = intArrayOf(
- 1, /*LEFT*/
- 2, /*TOP*/
- 4, /*RIGHT*/
- 8, /*BOTTOM*/
- 16, /*START*/
- 32, /*END*/
- 64, /*HORIZONTAL*/
- 128, /*VERTICAL*/
- 256, /*ALL*/
- 512, /*BLOCK*/
- 1024, /*BLOCK_END*/
- 2048,
- )
+ private val flagsMap =
+ intArrayOf(
+ 1, /*LEFT*/
+ 2, /*TOP*/
+ 4, /*RIGHT*/
+ 8, /*BOTTOM*/
+ 16, /*START*/
+ 32, /*END*/
+ 64, /*HORIZONTAL*/
+ 128, /*VERTICAL*/
+ 256, /*ALL*/
+ 512, /*BLOCK*/
+ 1024, /*BLOCK_END*/
+ 2048,
+ )
private fun newFullSpacingArray(): FloatArray {
return floatArrayOf(
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/TouchTargetHelper.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/TouchTargetHelper.kt
index 3debb1cb10a7..b38d417f330e 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/TouchTargetHelper.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/TouchTargetHelper.kt
@@ -355,23 +355,25 @@ public object TouchTargetHelper {
}
PointerEvents.BOX_ONLY -> {
// This view may be the target, its children don't matter
- val targetView = findTouchTargetView(
- eventCoords,
- view,
- EnumSet.of(TouchTargetReturnType.SELF),
- pathAccumulator,
- )
+ val targetView =
+ findTouchTargetView(
+ eventCoords,
+ view,
+ EnumSet.of(TouchTargetReturnType.SELF),
+ pathAccumulator,
+ )
targetView?.let { pathAccumulator?.add(ViewTarget(view.id, view)) }
targetView
}
PointerEvents.BOX_NONE -> {
// This view can't be the target, but its children might.
- val targetView = findTouchTargetView(
- eventCoords,
- view,
- EnumSet.of(TouchTargetReturnType.CHILD),
- pathAccumulator,
- )
+ val targetView =
+ findTouchTargetView(
+ eventCoords,
+ view,
+ EnumSet.of(TouchTargetReturnType.CHILD),
+ pathAccumulator,
+ )
if (targetView != null) {
pathAccumulator?.add(ViewTarget(view.id, view))
@@ -410,12 +412,13 @@ public object TouchTargetHelper {
return view
}
- val result = findTouchTargetView(
- eventCoords,
- view,
- EnumSet.of(TouchTargetReturnType.SELF, TouchTargetReturnType.CHILD),
- pathAccumulator,
- )
+ val result =
+ findTouchTargetView(
+ eventCoords,
+ view,
+ EnumSet.of(TouchTargetReturnType.SELF, TouchTargetReturnType.CHILD),
+ pathAccumulator,
+ )
result?.let { pathAccumulator?.add(ViewTarget(view.id, view)) }
result
}
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/TransformHelper.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/TransformHelper.kt
index eb20cb0ecf0f..8c713b98fbec 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/TransformHelper.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/TransformHelper.kt
@@ -83,11 +83,12 @@ public object TransformHelper {
val helperMatrix = helperMatrix.get()!!
MatrixMathHelper.resetIdentityMatrix(result)
- val offsets = getTranslateForTransformOrigin(
- viewWidth,
- viewHeight,
- transformOrigin,
- )
+ val offsets =
+ getTranslateForTransformOrigin(
+ viewWidth,
+ viewHeight,
+ transformOrigin,
+ )
if (offsets != null) {
MatrixMathHelper.resetIdentityMatrix(helperMatrix)
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModuleConstants.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModuleConstants.kt
index d06cfecf6ab9..2cabb9fa6a01 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModuleConstants.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModuleConstants.kt
@@ -14,38 +14,39 @@ import com.facebook.react.uimanager.events.TouchEventType
/** Constants exposed to JS from [UIManagerModule]. */
internal object UIManagerModuleConstants {
@JvmField
- val bubblingEventTypeConstants: Map = mapOf(
- "topChange" to
- mapOf(
- "phasedRegistrationNames" to
- mapOf("bubbled" to "onChange", "captured" to "onChangeCapture"),
- ),
- "topSelect" to
- mapOf(
- "phasedRegistrationNames" to
- mapOf("bubbled" to "onSelect", "captured" to "onSelectCapture"),
- ),
- TouchEventType.getJSEventName(TouchEventType.START) to
- mapOf(
- "phasedRegistrationNames" to
- mapOf("bubbled" to "onTouchStart", "captured" to "onTouchStartCapture"),
- ),
- TouchEventType.getJSEventName(TouchEventType.MOVE) to
- mapOf(
- "phasedRegistrationNames" to
- mapOf("bubbled" to "onTouchMove", "captured" to "onTouchMoveCapture"),
- ),
- TouchEventType.getJSEventName(TouchEventType.END) to
- mapOf(
- "phasedRegistrationNames" to
- mapOf("bubbled" to "onTouchEnd", "captured" to "onTouchEndCapture"),
- ),
- TouchEventType.getJSEventName(TouchEventType.CANCEL) to
- mapOf(
- "phasedRegistrationNames" to
- mapOf("bubbled" to "onTouchCancel", "captured" to "onTouchCancelCapture"),
- ),
- )
+ val bubblingEventTypeConstants: Map =
+ mapOf(
+ "topChange" to
+ mapOf(
+ "phasedRegistrationNames" to
+ mapOf("bubbled" to "onChange", "captured" to "onChangeCapture"),
+ ),
+ "topSelect" to
+ mapOf(
+ "phasedRegistrationNames" to
+ mapOf("bubbled" to "onSelect", "captured" to "onSelectCapture"),
+ ),
+ TouchEventType.getJSEventName(TouchEventType.START) to
+ mapOf(
+ "phasedRegistrationNames" to
+ mapOf("bubbled" to "onTouchStart", "captured" to "onTouchStartCapture"),
+ ),
+ TouchEventType.getJSEventName(TouchEventType.MOVE) to
+ mapOf(
+ "phasedRegistrationNames" to
+ mapOf("bubbled" to "onTouchMove", "captured" to "onTouchMoveCapture"),
+ ),
+ TouchEventType.getJSEventName(TouchEventType.END) to
+ mapOf(
+ "phasedRegistrationNames" to
+ mapOf("bubbled" to "onTouchEnd", "captured" to "onTouchEndCapture"),
+ ),
+ TouchEventType.getJSEventName(TouchEventType.CANCEL) to
+ mapOf(
+ "phasedRegistrationNames" to
+ mapOf("bubbled" to "onTouchCancel", "captured" to "onTouchCancelCapture"),
+ ),
+ )
@JvmField
val directEventTypeConstants: Map = run {
@@ -70,31 +71,32 @@ internal object UIManagerModuleConstants {
}
@JvmField
- val constants: Map = mapOf(
- "UIView" to
- mapOf(
- "ContentMode" to
- mapOf(
- "ScaleAspectFit" to ImageView.ScaleType.FIT_CENTER.ordinal,
- "ScaleAspectFill" to ImageView.ScaleType.CENTER_CROP.ordinal,
- "ScaleAspectCenter" to ImageView.ScaleType.CENTER_INSIDE.ordinal,
- ),
- ),
- "StyleConstants" to
- mapOf(
- "PointerEventsValues" to
- mapOf(
- "none" to PointerEvents.NONE.ordinal,
- "boxNone" to PointerEvents.BOX_NONE.ordinal,
- "boxOnly" to PointerEvents.BOX_ONLY.ordinal,
- "unspecified" to PointerEvents.AUTO.ordinal,
- ),
- ),
- "AccessibilityEventTypes" to
- mapOf(
- "typeWindowStateChanged" to AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED,
- "typeViewFocused" to AccessibilityEvent.TYPE_VIEW_FOCUSED,
- "typeViewClicked" to AccessibilityEvent.TYPE_VIEW_CLICKED,
- ),
- )
+ val constants: Map =
+ mapOf(
+ "UIView" to
+ mapOf(
+ "ContentMode" to
+ mapOf(
+ "ScaleAspectFit" to ImageView.ScaleType.FIT_CENTER.ordinal,
+ "ScaleAspectFill" to ImageView.ScaleType.CENTER_CROP.ordinal,
+ "ScaleAspectCenter" to ImageView.ScaleType.CENTER_INSIDE.ordinal,
+ ),
+ ),
+ "StyleConstants" to
+ mapOf(
+ "PointerEventsValues" to
+ mapOf(
+ "none" to PointerEvents.NONE.ordinal,
+ "boxNone" to PointerEvents.BOX_NONE.ordinal,
+ "boxOnly" to PointerEvents.BOX_ONLY.ordinal,
+ "unspecified" to PointerEvents.AUTO.ordinal,
+ ),
+ ),
+ "AccessibilityEventTypes" to
+ mapOf(
+ "typeWindowStateChanged" to AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED,
+ "typeViewFocused" to AccessibilityEvent.TYPE_VIEW_FOCUSED,
+ "typeViewClicked" to AccessibilityEvent.TYPE_VIEW_CLICKED,
+ ),
+ )
}
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModuleConstantsHelper.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModuleConstantsHelper.kt
index ebbb58c7482b..f668f5c12893 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModuleConstantsHelper.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModuleConstantsHelper.kt
@@ -41,10 +41,11 @@ internal object UIManagerModuleConstantsHelper {
@JvmStatic
val defaultExportableEventTypes: Map
- get() = mapOf(
- BUBBLING_EVENTS_KEY to UIManagerModuleConstants.bubblingEventTypeConstants,
- DIRECT_EVENTS_KEY to UIManagerModuleConstants.directEventTypeConstants,
- )
+ get() =
+ mapOf(
+ BUBBLING_EVENTS_KEY to UIManagerModuleConstants.bubblingEventTypeConstants,
+ DIRECT_EVENTS_KEY to UIManagerModuleConstants.directEventTypeConstants,
+ )
private fun validateDirectEventNames(
viewManagerName: String,
@@ -110,13 +111,14 @@ internal object UIManagerModuleConstantsHelper {
for (viewManager in viewManagers) {
val viewManagerName = viewManager.getName()
- val viewManagerConstants: MutableMap<*, *> = createConstantsForViewManager(
- viewManager,
- null,
- null,
- allBubblingEventTypes,
- allDirectEventTypes,
- )
+ val viewManagerConstants: MutableMap<*, *> =
+ createConstantsForViewManager(
+ viewManager,
+ null,
+ null,
+ allBubblingEventTypes,
+ allDirectEventTypes,
+ )
if (!viewManagerConstants.isEmpty()) {
constants[viewManagerName] = viewManagerConstants
}
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManagersPropertyCache.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManagersPropertyCache.kt
index 303fbe6da63a..2c4f6c702b83 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManagersPropertyCache.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManagersPropertyCache.kt
@@ -356,9 +356,10 @@ internal object ViewManagersPropertyCache {
// This is to include all the setters from parent classes. Once calculated the result will be
// stored in CLASS_PROPS_CACHE so that we only scan for @ReactProp annotations once per class.
@Suppress("UNCHECKED_CAST")
- val props: MutableMap = HashMap(
- getNativePropSettersForViewManagerClass(cls.superclass as Class>),
- )
+ val props: MutableMap =
+ HashMap(
+ getNativePropSettersForViewManagerClass(cls.superclass as Class>),
+ )
extractPropSettersFromViewManagerClassDefinition(cls, props)
CLASS_PROPS_CACHE[cls] = props
return props
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewProps.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewProps.kt
index 8aeb06848370..281c390a7578 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewProps.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewProps.kt
@@ -194,77 +194,80 @@ public object ViewProps {
internal const val ON_CLICK: String = "onClick"
internal const val ON_CLICK_CAPTURE: String = "onClickCapture"
@JvmField
- public val BORDER_SPACING_TYPES: IntArray = intArrayOf(
- Spacing.ALL,
- Spacing.START,
- Spacing.END,
- Spacing.TOP,
- Spacing.BOTTOM,
- Spacing.LEFT,
- Spacing.RIGHT,
- )
+ public val BORDER_SPACING_TYPES: IntArray =
+ intArrayOf(
+ Spacing.ALL,
+ Spacing.START,
+ Spacing.END,
+ Spacing.TOP,
+ Spacing.BOTTOM,
+ Spacing.LEFT,
+ Spacing.RIGHT,
+ )
@JvmField
- public val PADDING_MARGIN_SPACING_TYPES: IntArray = intArrayOf(
- Spacing.ALL,
- Spacing.VERTICAL,
- Spacing.HORIZONTAL,
- Spacing.START,
- Spacing.END,
- Spacing.TOP,
- Spacing.BOTTOM,
- Spacing.LEFT,
- Spacing.RIGHT,
- )
- private val LAYOUT_ONLY_PROPS: HashSet = HashSet(
- listOf(
- ALIGN_SELF,
- ALIGN_ITEMS,
- COLLAPSABLE,
- FLEX,
- FLEX_BASIS,
- FLEX_DIRECTION,
- FLEX_GROW,
- ROW_GAP,
- COLUMN_GAP,
- GAP,
- FLEX_SHRINK,
- FLEX_WRAP,
- JUSTIFY_CONTENT,
- ALIGN_CONTENT,
- DISPLAY, /* position */
- POSITION,
- RIGHT,
- TOP,
- BOTTOM,
- LEFT,
- START,
- END, /* dimensions */
- WIDTH,
- HEIGHT,
- MIN_WIDTH,
- MAX_WIDTH,
- MIN_HEIGHT,
- MAX_HEIGHT, /* margins */
- MARGIN,
- MARGIN_VERTICAL,
- MARGIN_HORIZONTAL,
- MARGIN_LEFT,
- MARGIN_RIGHT,
- MARGIN_TOP,
- MARGIN_BOTTOM,
- MARGIN_START,
- MARGIN_END, /* paddings */
- PADDING,
- PADDING_VERTICAL,
- PADDING_HORIZONTAL,
- PADDING_LEFT,
- PADDING_RIGHT,
- PADDING_TOP,
- PADDING_BOTTOM,
- PADDING_START,
- PADDING_END,
- ),
- )
+ public val PADDING_MARGIN_SPACING_TYPES: IntArray =
+ intArrayOf(
+ Spacing.ALL,
+ Spacing.VERTICAL,
+ Spacing.HORIZONTAL,
+ Spacing.START,
+ Spacing.END,
+ Spacing.TOP,
+ Spacing.BOTTOM,
+ Spacing.LEFT,
+ Spacing.RIGHT,
+ )
+ private val LAYOUT_ONLY_PROPS: HashSet =
+ HashSet(
+ listOf(
+ ALIGN_SELF,
+ ALIGN_ITEMS,
+ COLLAPSABLE,
+ FLEX,
+ FLEX_BASIS,
+ FLEX_DIRECTION,
+ FLEX_GROW,
+ ROW_GAP,
+ COLUMN_GAP,
+ GAP,
+ FLEX_SHRINK,
+ FLEX_WRAP,
+ JUSTIFY_CONTENT,
+ ALIGN_CONTENT,
+ DISPLAY, /* position */
+ POSITION,
+ RIGHT,
+ TOP,
+ BOTTOM,
+ LEFT,
+ START,
+ END, /* dimensions */
+ WIDTH,
+ HEIGHT,
+ MIN_WIDTH,
+ MAX_WIDTH,
+ MIN_HEIGHT,
+ MAX_HEIGHT, /* margins */
+ MARGIN,
+ MARGIN_VERTICAL,
+ MARGIN_HORIZONTAL,
+ MARGIN_LEFT,
+ MARGIN_RIGHT,
+ MARGIN_TOP,
+ MARGIN_BOTTOM,
+ MARGIN_START,
+ MARGIN_END, /* paddings */
+ PADDING,
+ PADDING_VERTICAL,
+ PADDING_HORIZONTAL,
+ PADDING_LEFT,
+ PADDING_RIGHT,
+ PADDING_TOP,
+ PADDING_BOTTOM,
+ PADDING_START,
+ PADDING_END,
+ ),
+ )
@JvmStatic
public fun isLayoutOnly(map: ReadableMap, prop: String): Boolean {
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/drawable/BorderDrawable.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/drawable/BorderDrawable.kt
index 60b4e1cc9cdb..d1293ee48d9c 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/drawable/BorderDrawable.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/drawable/BorderDrawable.kt
@@ -137,24 +137,26 @@ internal class BorderDrawable(
@Deprecated("Deprecated in Java")
override fun getOpacity(): Int {
- val maxBorderAlpha = maxOf(
- (Color.alpha(multiplyColorAlpha(computedBorderColors.left, borderAlpha))),
- (Color.alpha(multiplyColorAlpha(computedBorderColors.top, borderAlpha))),
- (Color.alpha(multiplyColorAlpha(computedBorderColors.right, borderAlpha))),
- (Color.alpha(multiplyColorAlpha(computedBorderColors.bottom, borderAlpha))),
- )
+ val maxBorderAlpha =
+ maxOf(
+ (Color.alpha(multiplyColorAlpha(computedBorderColors.left, borderAlpha))),
+ (Color.alpha(multiplyColorAlpha(computedBorderColors.top, borderAlpha))),
+ (Color.alpha(multiplyColorAlpha(computedBorderColors.right, borderAlpha))),
+ (Color.alpha(multiplyColorAlpha(computedBorderColors.bottom, borderAlpha))),
+ )
// If the highest alpha value of all border edges is 0, then the drawable is TRANSPARENT.
if (maxBorderAlpha == 0) {
return PixelFormat.TRANSPARENT
}
- val minBorderAlpha = minOf(
- (Color.alpha(multiplyColorAlpha(computedBorderColors.left, borderAlpha))),
- (Color.alpha(multiplyColorAlpha(computedBorderColors.top, borderAlpha))),
- (Color.alpha(multiplyColorAlpha(computedBorderColors.right, borderAlpha))),
- (Color.alpha(multiplyColorAlpha(computedBorderColors.bottom, borderAlpha))),
- )
+ val minBorderAlpha =
+ minOf(
+ (Color.alpha(multiplyColorAlpha(computedBorderColors.left, borderAlpha))),
+ (Color.alpha(multiplyColorAlpha(computedBorderColors.top, borderAlpha))),
+ (Color.alpha(multiplyColorAlpha(computedBorderColors.right, borderAlpha))),
+ (Color.alpha(multiplyColorAlpha(computedBorderColors.bottom, borderAlpha))),
+ )
/*
* If the lowest alpha value of all border edges is 255, then the drawable is OPAQUE.
@@ -241,16 +243,17 @@ internal class BorderDrawable(
val top = bounds.top
// Check for fast path to border drawing.
- val fastBorderColor = fastBorderCompatibleColorOrZero(
- borderLeft,
- borderTop,
- borderRight,
- borderBottom,
- computedBorderColors.left,
- computedBorderColors.top,
- computedBorderColors.right,
- computedBorderColors.bottom,
- )
+ val fastBorderColor =
+ fastBorderCompatibleColorOrZero(
+ borderLeft,
+ borderTop,
+ borderRight,
+ borderBottom,
+ computedBorderColors.left,
+ computedBorderColors.top,
+ computedBorderColors.right,
+ computedBorderColors.bottom,
+ )
if (fastBorderColor != 0) {
if (Color.alpha(fastBorderColor) != 0) {
// Border color is not transparent.
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/drawable/InsetBoxShadowDrawable.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/drawable/InsetBoxShadowDrawable.kt
index f54beecb6107..c59484be0f7f 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/drawable/InsetBoxShadowDrawable.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/drawable/InsetBoxShadowDrawable.kt
@@ -85,24 +85,26 @@ internal class InsetBoxShadowDrawable(
val computedBorderRadii = computeBorderRadii()
val computedBorderInsets = computeBorderInsets()
- val paddingBoxRect = RectF(
- bounds.left + (computedBorderInsets?.left ?: 0f),
- bounds.top + (computedBorderInsets?.top ?: 0f),
- bounds.right - (computedBorderInsets?.right ?: 0f),
- bounds.bottom - (computedBorderInsets?.bottom ?: 0f),
- )
- val paddingBoxRadii = computedBorderRadii?.let {
- floatArrayOf(
- innerRadius(it.topLeft.horizontal, computedBorderInsets?.left),
- innerRadius(it.topLeft.vertical, computedBorderInsets?.top),
- innerRadius(it.topRight.horizontal, computedBorderInsets?.right),
- innerRadius(it.topRight.vertical, computedBorderInsets?.top),
- innerRadius(it.bottomRight.horizontal, computedBorderInsets?.right),
- innerRadius(it.bottomRight.vertical, computedBorderInsets?.bottom),
- innerRadius(it.bottomLeft.horizontal, computedBorderInsets?.left),
- innerRadius(it.bottomLeft.vertical, computedBorderInsets?.bottom),
- )
- }
+ val paddingBoxRect =
+ RectF(
+ bounds.left + (computedBorderInsets?.left ?: 0f),
+ bounds.top + (computedBorderInsets?.top ?: 0f),
+ bounds.right - (computedBorderInsets?.right ?: 0f),
+ bounds.bottom - (computedBorderInsets?.bottom ?: 0f),
+ )
+ val paddingBoxRadii =
+ computedBorderRadii?.let {
+ floatArrayOf(
+ innerRadius(it.topLeft.horizontal, computedBorderInsets?.left),
+ innerRadius(it.topLeft.vertical, computedBorderInsets?.top),
+ innerRadius(it.topRight.horizontal, computedBorderInsets?.right),
+ innerRadius(it.topRight.vertical, computedBorderInsets?.top),
+ innerRadius(it.bottomRight.horizontal, computedBorderInsets?.right),
+ innerRadius(it.bottomRight.vertical, computedBorderInsets?.bottom),
+ innerRadius(it.bottomLeft.horizontal, computedBorderInsets?.left),
+ innerRadius(it.bottomLeft.vertical, computedBorderInsets?.bottom),
+ )
+ }
val x = offsetX.dpToPx()
val y = offsetY.dpToPx()
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/TouchesHelper.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/TouchesHelper.kt
index e26e0390226a..435ac67afbf6 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/TouchesHelper.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/TouchesHelper.kt
@@ -132,14 +132,15 @@ internal object TouchesHelper {
}
for (touchData in changedTouches) {
- val eventData = touchData?.let { td ->
- val ed = td.copy()
- val changedTouchesArray = getWritableArray(/* copyObjects */ true, changedTouches)
- val touchesArray = getWritableArray(/* copyObjects */ true, touches)
- ed.putArray(CHANGED_TOUCHES_KEY, changedTouchesArray)
- ed.putArray(TOUCHES_KEY, touchesArray)
- ed
- }
+ val eventData =
+ touchData?.let { td ->
+ val ed = td.copy()
+ val changedTouchesArray = getWritableArray(/* copyObjects */ true, changedTouches)
+ val touchesArray = getWritableArray(/* copyObjects */ true, touches)
+ ed.putArray(CHANGED_TOUCHES_KEY, changedTouchesArray)
+ ed.putArray(TOUCHES_KEY, touchesArray)
+ ed
+ }
eventEmitter.receiveEvent(
event.surfaceId,
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/style/RadialGradient.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/style/RadialGradient.kt
index b56ff428516e..8aef78ebc92d 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/style/RadialGradient.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/style/RadialGradient.kt
@@ -327,18 +327,20 @@ internal class RadialGradient(
height: Float,
sizeKeyword: GradientSize.KeywordType,
): Pair {
- val corners = arrayOf(
- Pair(0f, 0f), // top-left
- Pair(width, 0f), // top-right
- Pair(width, height), // bottom-right
- Pair(0f, height), // bottom-left
- )
+ val corners =
+ arrayOf(
+ Pair(0f, 0f), // top-left
+ Pair(width, 0f), // top-right
+ Pair(width, height), // bottom-right
+ Pair(0f, height), // bottom-left
+ )
var cornerIndex = 0
- var distance = sqrt(
- (centerX - corners[cornerIndex].first).pow(2) +
- (centerY - corners[cornerIndex].second).pow(2),
- )
+ var distance =
+ sqrt(
+ (centerX - corners[cornerIndex].first).pow(2) +
+ (centerY - corners[cornerIndex].second).pow(2),
+ )
val isClosestCorner = sizeKeyword == GradientSize.KeywordType.CLOSEST_CORNER
for (i in 1 until corners.size) {
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/drawer/ReactDrawerLayoutManager.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/drawer/ReactDrawerLayoutManager.kt
index 40370cc11712..87c679d3b544 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/drawer/ReactDrawerLayoutManager.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/drawer/ReactDrawerLayoutManager.kt
@@ -150,10 +150,11 @@ public class ReactDrawerLayoutManager :
return true
}
- public override fun getCommandsMap(): Map = mapOf(
- COMMAND_OPEN_DRAWER to OPEN_DRAWER,
- COMMAND_CLOSE_DRAWER to CLOSE_DRAWER,
- )
+ public override fun getCommandsMap(): Map =
+ mapOf(
+ COMMAND_OPEN_DRAWER to OPEN_DRAWER,
+ COMMAND_CLOSE_DRAWER to CLOSE_DRAWER,
+ )
@Deprecated(
message =
@@ -171,13 +172,14 @@ public class ReactDrawerLayoutManager :
}
}
- public override fun getExportedViewConstants(): Map = mapOf(
- DRAWER_POSITION to
- mapOf(
- DRAWER_POSITION_LEFT to Gravity.START,
- DRAWER_POSITION_RIGHT to Gravity.END,
- ),
- )
+ public override fun getExportedViewConstants(): Map =
+ mapOf(
+ DRAWER_POSITION to
+ mapOf(
+ DRAWER_POSITION_LEFT to Gravity.START,
+ DRAWER_POSITION_RIGHT to Gravity.END,
+ ),
+ )
public override fun getExportedCustomDirectEventTypeConstants(): Map {
val eventTypeConstants = super.getExportedCustomDirectEventTypeConstants() ?: mutableMapOf()
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/image/ReactImageView.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/image/ReactImageView.kt
index 252681d7b8d0..0b3e78db9b3e 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/image/ReactImageView.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/image/ReactImageView.kt
@@ -290,13 +290,14 @@ public class ReactImageView(
for (idx in 0 until sources.size()) {
val source = sources.getMap(idx) ?: continue
val cacheControl = computeCacheControl(source.getString("cache"))
- var imageSource = ImageSource(
- context,
- source.getString("uri"),
- source.getDouble("width"),
- source.getDouble("height"),
- cacheControl,
- )
+ var imageSource =
+ ImageSource(
+ context,
+ source.getString("uri"),
+ source.getDouble("width"),
+ source.getDouble("height"),
+ cacheControl,
+ )
if (Uri.EMPTY == imageSource.uri) {
warnImageSource(source.getString("uri"))
imageSource = getTransparentBitmapImageSource(context)
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/MaintainVisibleScrollPositionHelper.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/MaintainVisibleScrollPositionHelper.kt
index cca66c7a7334..0b9082233f61 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/MaintainVisibleScrollPositionHelper.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/MaintainVisibleScrollPositionHelper.kt
@@ -47,12 +47,13 @@ internal class MaintainVisibleScrollPositionHelper(
get() = scrollView?.getChildAt(0) as ReactViewGroup?
private val uIManager: UIManager
- get() = checkNotNull(
- UIManagerHelper.getUIManager(
- checkNotNull(scrollView?.context as ReactContext?),
- UIManagerType.FABRIC,
- ),
- )
+ get() =
+ checkNotNull(
+ UIManagerHelper.getUIManager(
+ checkNotNull(scrollView?.context as ReactContext?),
+ UIManagerType.FABRIC,
+ ),
+ )
class Config
internal constructor(val minIndexForVisible: Int, val autoScrollToTopThreshold: Int?) {
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollViewCommandHelper.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollViewCommandHelper.kt
index bdecd478cf78..411ae5418384 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollViewCommandHelper.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollViewCommandHelper.kt
@@ -18,11 +18,12 @@ public class ReactScrollViewCommandHelper {
public const val COMMAND_FLASH_SCROLL_INDICATORS: Int = 3
@JvmStatic
- public fun getCommandsMap(): Map = hashMapOf(
- "scrollTo" to COMMAND_SCROLL_TO,
- "scrollToEnd" to COMMAND_SCROLL_TO_END,
- "flashScrollIndicators" to COMMAND_FLASH_SCROLL_INDICATORS,
- )
+ public fun getCommandsMap(): Map =
+ hashMapOf(
+ "scrollTo" to COMMAND_SCROLL_TO,
+ "scrollToEnd" to COMMAND_SCROLL_TO_END,
+ "flashScrollIndicators" to COMMAND_FLASH_SCROLL_INDICATORS,
+ )
@JvmStatic
public fun receiveCommand(
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollViewManager.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollViewManager.kt
index 2f8df4150b3a..99cce0dbe809 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollViewManager.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollViewManager.kt
@@ -442,15 +442,17 @@ constructor(private val fpsListener: FpsListener? = null) :
public companion object {
public const val REACT_CLASS: String = "RCTScrollView"
- public fun createExportedCustomDirectEventTypeConstants(): Map = mapOf(
- getJSEventName(ScrollEventType.SCROLL) to mapOf("registrationName" to "onScroll"),
- getJSEventName(ScrollEventType.BEGIN_DRAG) to
- mapOf("registrationName" to "onScrollBeginDrag"),
- getJSEventName(ScrollEventType.END_DRAG) to mapOf("registrationName" to "onScrollEndDrag"),
- getJSEventName(ScrollEventType.MOMENTUM_BEGIN) to
- mapOf("registrationName" to "onMomentumScrollBegin"),
- getJSEventName(ScrollEventType.MOMENTUM_END) to
- mapOf("registrationName" to "onMomentumScrollEnd"),
- )
+ public fun createExportedCustomDirectEventTypeConstants(): Map =
+ mapOf(
+ getJSEventName(ScrollEventType.SCROLL) to mapOf("registrationName" to "onScroll"),
+ getJSEventName(ScrollEventType.BEGIN_DRAG) to
+ mapOf("registrationName" to "onScrollBeginDrag"),
+ getJSEventName(ScrollEventType.END_DRAG) to
+ mapOf("registrationName" to "onScrollEndDrag"),
+ getJSEventName(ScrollEventType.MOMENTUM_BEGIN) to
+ mapOf("registrationName" to "onMomentumScrollBegin"),
+ getJSEventName(ScrollEventType.MOMENTUM_END) to
+ mapOf("registrationName" to "onMomentumScrollEnd"),
+ )
}
}
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ScrollEvent.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ScrollEvent.kt
index 04992c5605c1..62f7ecfa9b34 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ScrollEvent.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ScrollEvent.kt
@@ -170,18 +170,19 @@ public class ScrollEvent private constructor() : Event() {
contentHeight: Int,
scrollViewWidth: Int,
scrollViewHeight: Int,
- ): ScrollEvent = obtain(
- ViewUtil.NO_SURFACE_ID,
- viewTag,
- scrollEventType,
- scrollX,
- scrollY,
- xVelocity,
- yVelocity,
- contentWidth,
- contentHeight,
- scrollViewWidth,
- scrollViewHeight,
- )
+ ): ScrollEvent =
+ obtain(
+ ViewUtil.NO_SURFACE_ID,
+ viewTag,
+ scrollEventType,
+ scrollX,
+ scrollY,
+ xVelocity,
+ yVelocity,
+ contentWidth,
+ contentHeight,
+ scrollViewWidth,
+ scrollViewHeight,
+ )
}
}
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/VirtualViewContainerStateExperimental.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/VirtualViewContainerStateExperimental.kt
index c1f009f3b9a6..0504a310bb59 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/VirtualViewContainerStateExperimental.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/VirtualViewContainerStateExperimental.kt
@@ -325,11 +325,12 @@ internal class IntervalTree(private val horizontal: Boolean) : MutableCollection
node.left == null -> node.right
node.right == null -> node.left
else -> {
- val successor = findMin(
- requireNotNull(node.right) {
- "[IntervalTree] node.right must not be null when finding node's successor"
- },
- )
+ val successor =
+ findMin(
+ requireNotNull(node.right) {
+ "[IntervalTree] node.right must not be null when finding node's successor"
+ },
+ )
node.virtualView = successor.virtualView
node.interval = successor.interval
node.right = delete(node.right, successor)
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/swiperefresh/SwipeRefreshLayoutManager.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/swiperefresh/SwipeRefreshLayoutManager.kt
index a1b21029758d..e719dd0502f4 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/swiperefresh/SwipeRefreshLayoutManager.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/swiperefresh/SwipeRefreshLayoutManager.kt
@@ -117,13 +117,14 @@ internal open class SwipeRefreshLayoutManager :
}
}
- override fun getExportedViewConstants(): MutableMap = mutableMapOf(
- "SIZE" to
- mutableMapOf(
- "DEFAULT" to SwipeRefreshLayout.DEFAULT,
- "LARGE" to SwipeRefreshLayout.LARGE,
- ),
- )
+ override fun getExportedViewConstants(): MutableMap =
+ mutableMapOf(
+ "SIZE" to
+ mutableMapOf(
+ "DEFAULT" to SwipeRefreshLayout.DEFAULT,
+ "LARGE" to SwipeRefreshLayout.LARGE,
+ ),
+ )
override fun getExportedCustomDirectEventTypeConstants(): MutableMap {
val baseEventTypeConstants = super.getExportedCustomDirectEventTypeConstants()
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextUpdate.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextUpdate.kt
index 183243681981..111febfc53ef 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextUpdate.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextUpdate.kt
@@ -25,12 +25,13 @@ internal class ReactTextUpdate(
textAlign: Int,
textBreakStrategy: Int,
justificationMode: Int,
- ): ReactTextUpdate = ReactTextUpdate(
- text,
- jsEventCounter,
- textAlign,
- textBreakStrategy,
- justificationMode,
- )
+ ): ReactTextUpdate =
+ ReactTextUpdate(
+ text,
+ jsEventCounter,
+ textAlign,
+ textBreakStrategy,
+ justificationMode,
+ )
}
}
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.kt
index 5ea878dcef05..14822ab1c0a7 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.kt
@@ -681,13 +681,14 @@ internal object TextLayoutManager {
fontWeightAdjustment: Int,
attributedString: MapBuffer,
reactTextViewManagerCallback: ReactTextViewManagerCallback?,
- ): Spannable = getOrCreateSpannableForText(
- assets,
- fontWeightAdjustment,
- attributedString,
- reactTextViewManagerCallback,
- null,
- )
+ ): Spannable =
+ getOrCreateSpannableForText(
+ assets,
+ fontWeightAdjustment,
+ attributedString,
+ reactTextViewManagerCallback,
+ null,
+ )
@OptIn(UnstableReactNativeAPI::class)
internal fun getOrCreateSpannableForText(
@@ -695,13 +696,14 @@ internal object TextLayoutManager {
attributedString: MapBuffer,
reactTextViewManagerCallback: ReactTextViewManagerCallback?,
textEffectRegistry: TextEffectRegistry?,
- ): Spannable = getOrCreateSpannableForText(
- assets,
- 0,
- attributedString,
- reactTextViewManagerCallback,
- textEffectRegistry,
- )
+ ): Spannable =
+ getOrCreateSpannableForText(
+ assets,
+ 0,
+ attributedString,
+ reactTextViewManagerCallback,
+ textEffectRegistry,
+ )
@OptIn(UnstableReactNativeAPI::class)
internal fun getOrCreateSpannableForText(
@@ -740,13 +742,14 @@ internal object TextLayoutManager {
textEffectRegistry: TextEffectRegistry? = null,
): Spannable {
if (ReactNativeFeatureFlags.enableAndroidTextMeasurementOptimizations()) {
- val spannable = buildSpannableFromFragmentsOptimized(
- assets,
- fontWeightAdjustment,
- fragments,
- outputReactTags,
- textEffectRegistry,
- )
+ val spannable =
+ buildSpannableFromFragmentsOptimized(
+ assets,
+ fontWeightAdjustment,
+ fragments,
+ outputReactTags,
+ textEffectRegistry,
+ )
reactTextViewManagerCallback?.onPostProcessSpannable(spannable)
return spannable
@@ -971,13 +974,14 @@ internal object TextLayoutManager {
reactTextViewManagerCallback: ReactTextViewManagerCallback?,
textEffectRegistry: TextEffectRegistry? = null,
): Layout {
- val text = getOrCreateSpannableForText(
- assets,
- fontWeightAdjustment,
- attributedString,
- reactTextViewManagerCallback,
- textEffectRegistry,
- )
+ val text =
+ getOrCreateSpannableForText(
+ assets,
+ fontWeightAdjustment,
+ attributedString,
+ reactTextViewManagerCallback,
+ textEffectRegistry,
+ )
val paint: TextPaint
if (attributedString.contains(AS_KEY_CACHE_ID)) {
@@ -989,15 +993,15 @@ internal object TextLayoutManager {
}
return createLayout(
- text,
- paint,
- attributedString,
- paragraphAttributes,
- width,
- widthYogaMeasureMode,
- height,
- heightYogaMeasureMode,
- )
+ text,
+ paint,
+ attributedString,
+ paragraphAttributes,
+ width,
+ widthYogaMeasureMode,
+ height,
+ heightYogaMeasureMode,
+ )
.layout
}
@@ -1068,33 +1072,12 @@ internal object TextLayoutManager {
)
}
- var layout = createLayout(
- text,
- boring,
- width,
- widthYogaMeasureMode,
- includeFontPadding,
- textBreakStrategy,
- hyphenationFrequency,
- alignment,
- justificationMode,
- ellipsizeMode,
- maximumNumberOfLines,
- paint,
- )
-
- if (
- widthYogaMeasureMode == YogaMeasureMode.AT_MOST &&
- paragraphAttributes.contains(PA_KEY_TEXT_WIDTH_MODE) &&
- paragraphAttributes.getString(PA_KEY_TEXT_WIDTH_MODE) == TEXT_WIDTH_MODE_LONGEST_LINE
- ) {
- val lineCount = calculateLineCount(layout, maximumNumberOfLines)
- val longestLineWidth = longestLineWidth(layout, lineCount)
- val tightenedWidth = max(1, ceil(longestLineWidth).toInt())
- if (tightenedWidth < layout.width) {
- val tightenedLayout = buildLayout(
+ var layout =
+ createLayout(
text,
- tightenedWidth,
+ boring,
+ width,
+ widthYogaMeasureMode,
includeFontPadding,
textBreakStrategy,
hyphenationFrequency,
@@ -1104,6 +1087,29 @@ internal object TextLayoutManager {
maximumNumberOfLines,
paint,
)
+
+ if (
+ widthYogaMeasureMode == YogaMeasureMode.AT_MOST &&
+ paragraphAttributes.contains(PA_KEY_TEXT_WIDTH_MODE) &&
+ paragraphAttributes.getString(PA_KEY_TEXT_WIDTH_MODE) == TEXT_WIDTH_MODE_LONGEST_LINE
+ ) {
+ val lineCount = calculateLineCount(layout, maximumNumberOfLines)
+ val longestLineWidth = longestLineWidth(layout, lineCount)
+ val tightenedWidth = max(1, ceil(longestLineWidth).toInt())
+ if (tightenedWidth < layout.width) {
+ val tightenedLayout =
+ buildLayout(
+ text,
+ tightenedWidth,
+ includeFontPadding,
+ textBreakStrategy,
+ hyphenationFrequency,
+ alignment,
+ justificationMode,
+ ellipsizeMode,
+ maximumNumberOfLines,
+ paint,
+ )
if (calculateLineCount(tightenedLayout, maximumNumberOfLines) == lineCount) {
layout = tightenedLayout
}
@@ -1129,18 +1135,19 @@ internal object TextLayoutManager {
heightYogaMeasureMode: YogaMeasureMode,
reactTextViewManagerCallback: ReactTextViewManagerCallback?,
textEffectRegistry: TextEffectRegistry? = null,
- ): PreparedLayout = createPreparedLayout(
- assets,
- 0,
- attributedString,
- paragraphAttributes,
- width,
- widthYogaMeasureMode,
- height,
- heightYogaMeasureMode,
- reactTextViewManagerCallback,
- textEffectRegistry,
- )
+ ): PreparedLayout =
+ createPreparedLayout(
+ assets,
+ 0,
+ attributedString,
+ paragraphAttributes,
+ width,
+ widthYogaMeasureMode,
+ height,
+ heightYogaMeasureMode,
+ reactTextViewManagerCallback,
+ textEffectRegistry,
+ )
@JvmStatic
@OptIn(UnstableReactNativeAPI::class)
@@ -1158,39 +1165,42 @@ internal object TextLayoutManager {
): PreparedLayout {
val fragments = attributedString.getMapBuffer(AS_KEY_FRAGMENTS)
val reactTags = IntArray(fragments.count)
- val text = createSpannableFromAttributedString(
- assets,
- fontWeightAdjustment,
- fragments,
- reactTextViewManagerCallback,
- reactTags,
- textEffectRegistry,
- )
+ val text =
+ createSpannableFromAttributedString(
+ assets,
+ fontWeightAdjustment,
+ fragments,
+ reactTextViewManagerCallback,
+ reactTags,
+ textEffectRegistry,
+ )
val baseTextAttributes =
TextAttributeProps.fromMapBuffer(attributedString.getMapBuffer(AS_KEY_BASE_ATTRIBUTES))
- val result = createLayout(
- text,
- newPaintWithAttributes(baseTextAttributes, assets, fontWeightAdjustment),
- attributedString,
- paragraphAttributes,
- width,
- widthYogaMeasureMode,
- height,
- heightYogaMeasureMode,
- )
+ val result =
+ createLayout(
+ text,
+ newPaintWithAttributes(baseTextAttributes, assets, fontWeightAdjustment),
+ attributedString,
+ paragraphAttributes,
+ width,
+ widthYogaMeasureMode,
+ height,
+ heightYogaMeasureMode,
+ )
val maximumNumberOfLines =
if (paragraphAttributes.contains(PA_KEY_MAX_NUMBER_OF_LINES))
paragraphAttributes.getInt(PA_KEY_MAX_NUMBER_OF_LINES)
else ReactConstants.UNSET
- val verticalOffset = getVerticalOffset(
- result.layout,
- paragraphAttributes,
- height,
- heightYogaMeasureMode,
- maximumNumberOfLines,
- )
+ val verticalOffset =
+ getVerticalOffset(
+ result.layout,
+ paragraphAttributes,
+ height,
+ heightYogaMeasureMode,
+ maximumNumberOfLines,
+ )
return PreparedLayout(
result.layout,
@@ -1320,19 +1330,20 @@ internal object TextLayoutManager {
reactTextViewManagerCallback: ReactTextViewManagerCallback?,
attachmentsPositions: FloatArray?,
textEffectRegistry: TextEffectRegistry? = null,
- ): Long = measureText(
- assets,
- 0,
- attributedString,
- paragraphAttributes,
- width,
- widthYogaMeasureMode,
- height,
- heightYogaMeasureMode,
- reactTextViewManagerCallback,
- attachmentsPositions,
- textEffectRegistry,
- )
+ ): Long =
+ measureText(
+ assets,
+ 0,
+ attributedString,
+ paragraphAttributes,
+ width,
+ widthYogaMeasureMode,
+ height,
+ heightYogaMeasureMode,
+ reactTextViewManagerCallback,
+ attachmentsPositions,
+ textEffectRegistry,
+ )
@JvmStatic
@OptIn(UnstableReactNativeAPI::class)
@@ -1350,18 +1361,19 @@ internal object TextLayoutManager {
textEffectRegistry: TextEffectRegistry? = null,
): Long {
// TODO(5578671): Handle text direction (see View#getTextDirectionHeuristic)
- val layout = createLayoutForMeasurement(
- assets,
- fontWeightAdjustment,
- attributedString,
- paragraphAttributes,
- width,
- widthYogaMeasureMode,
- height,
- heightYogaMeasureMode,
- reactTextViewManagerCallback,
- textEffectRegistry,
- )
+ val layout =
+ createLayoutForMeasurement(
+ assets,
+ fontWeightAdjustment,
+ attributedString,
+ paragraphAttributes,
+ width,
+ widthYogaMeasureMode,
+ height,
+ heightYogaMeasureMode,
+ reactTextViewManagerCallback,
+ textEffectRegistry,
+ )
val maximumNumberOfLines =
if (paragraphAttributes.contains(PA_KEY_MAX_NUMBER_OF_LINES))
@@ -1630,16 +1642,17 @@ internal object TextLayoutManager {
height: Float,
reactTextViewManagerCallback: ReactTextViewManagerCallback?,
textEffectRegistry: TextEffectRegistry? = null,
- ): WritableArray = measureLines(
- assetManager,
- 0,
- attributedString,
- paragraphAttributes,
- width,
- height,
- reactTextViewManagerCallback,
- textEffectRegistry,
- )
+ ): WritableArray =
+ measureLines(
+ assetManager,
+ 0,
+ attributedString,
+ paragraphAttributes,
+ width,
+ height,
+ reactTextViewManagerCallback,
+ textEffectRegistry,
+ )
@JvmStatic
@OptIn(UnstableReactNativeAPI::class)
@@ -1653,18 +1666,19 @@ internal object TextLayoutManager {
reactTextViewManagerCallback: ReactTextViewManagerCallback?,
textEffectRegistry: TextEffectRegistry? = null,
): WritableArray {
- val layout = createLayoutForMeasurement(
- assetManager,
- fontWeightAdjustment,
- attributedString,
- paragraphAttributes,
- width,
- YogaMeasureMode.EXACTLY,
- height,
- YogaMeasureMode.EXACTLY,
- reactTextViewManagerCallback,
- textEffectRegistry,
- )
+ val layout =
+ createLayoutForMeasurement(
+ assetManager,
+ fontWeightAdjustment,
+ attributedString,
+ paragraphAttributes,
+ width,
+ YogaMeasureMode.EXACTLY,
+ height,
+ YogaMeasureMode.EXACTLY,
+ reactTextViewManagerCallback,
+ textEffectRegistry,
+ )
return FontMetricsUtil.getFontMetrics(
layout.text,
layout,
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.kt
index 665bd4adcf22..3d9a05b63f84 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.kt
@@ -974,15 +974,16 @@ public open class ReactTextInputManager public constructor() :
}
}
- override fun getExportedViewConstants(): Map = mapOf(
- "AutoCapitalizationType" to
- mapOf(
- "none" to 0,
- "characters" to InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS,
- "words" to InputType.TYPE_TEXT_FLAG_CAP_WORDS,
- "sentences" to InputType.TYPE_TEXT_FLAG_CAP_SENTENCES,
- ),
- )
+ override fun getExportedViewConstants(): Map =
+ mapOf(
+ "AutoCapitalizationType" to
+ mapOf(
+ "none" to 0,
+ "characters" to InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS,
+ "words" to InputType.TYPE_TEXT_FLAG_CAP_WORDS,
+ "sentences" to InputType.TYPE_TEXT_FLAG_CAP_SENTENCES,
+ ),
+ )
override fun setPadding(view: ReactEditText, left: Int, top: Int, right: Int, bottom: Int) {
view.setPadding(left, top, right, bottom)
@@ -1072,58 +1073,60 @@ public open class ReactTextInputManager public constructor() :
// private const val TX_STATE_KEY_HASH: Short = 2
private const val TX_STATE_KEY_MOST_RECENT_EVENT_COUNT: Short = 3
- private val REACT_PROPS_AUTOFILL_HINTS_MAP: Map = mapOf(
- "2fa-app-otp" to HintConstants.AUTOFILL_HINT_2FA_APP_OTP,
- "birthdate-day" to HintConstants.AUTOFILL_HINT_BIRTH_DATE_DAY,
- "birthdate-full" to HintConstants.AUTOFILL_HINT_BIRTH_DATE_FULL,
- "birthdate-month" to HintConstants.AUTOFILL_HINT_BIRTH_DATE_MONTH,
- "birthdate-year" to HintConstants.AUTOFILL_HINT_BIRTH_DATE_YEAR,
- "cc-csc" to HintConstants.AUTOFILL_HINT_CREDIT_CARD_SECURITY_CODE,
- "cc-exp" to HintConstants.AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DATE,
- "cc-exp-day" to HintConstants.AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DAY,
- "cc-exp-month" to HintConstants.AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_MONTH,
- "cc-exp-year" to HintConstants.AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_YEAR,
- "cc-number" to HintConstants.AUTOFILL_HINT_CREDIT_CARD_NUMBER,
- "email" to HintConstants.AUTOFILL_HINT_EMAIL_ADDRESS,
- "email-otp" to HintConstants.AUTOFILL_HINT_EMAIL_OTP,
- "flight-confirmation-code" to HintConstants.AUTOFILL_HINT_FLIGHT_CONFIRMATION_CODE,
- "flight-number" to HintConstants.AUTOFILL_HINT_FLIGHT_NUMBER,
- "gender" to HintConstants.AUTOFILL_HINT_GENDER,
- "gift-card-number" to HintConstants.AUTOFILL_HINT_GIFT_CARD_NUMBER,
- "gift-card-pin" to HintConstants.AUTOFILL_HINT_GIFT_CARD_PIN,
- "loyalty-account-number" to HintConstants.AUTOFILL_HINT_LOYALTY_ACCOUNT_NUMBER,
- "name" to HintConstants.AUTOFILL_HINT_PERSON_NAME,
- "name-family" to HintConstants.AUTOFILL_HINT_PERSON_NAME_FAMILY,
- "name-given" to HintConstants.AUTOFILL_HINT_PERSON_NAME_GIVEN,
- "name-middle" to HintConstants.AUTOFILL_HINT_PERSON_NAME_MIDDLE,
- "name-middle-initial" to HintConstants.AUTOFILL_HINT_PERSON_NAME_MIDDLE_INITIAL,
- "name-prefix" to HintConstants.AUTOFILL_HINT_PERSON_NAME_PREFIX,
- "name-suffix" to HintConstants.AUTOFILL_HINT_PERSON_NAME_SUFFIX,
- "password" to HintConstants.AUTOFILL_HINT_PASSWORD,
- "password-new" to HintConstants.AUTOFILL_HINT_NEW_PASSWORD,
- "postal-address" to HintConstants.AUTOFILL_HINT_POSTAL_ADDRESS,
- "postal-address-country" to HintConstants.AUTOFILL_HINT_POSTAL_ADDRESS_COUNTRY,
- "postal-address-dependent-locality" to
- HintConstants.AUTOFILL_HINT_POSTAL_ADDRESS_DEPENDENT_LOCALITY,
- "postal-address-extended" to HintConstants.AUTOFILL_HINT_POSTAL_ADDRESS_EXTENDED_ADDRESS,
- "postal-address-extended-postal-code" to
- HintConstants.AUTOFILL_HINT_POSTAL_ADDRESS_EXTENDED_POSTAL_CODE,
- "postal-address-locality" to HintConstants.AUTOFILL_HINT_POSTAL_ADDRESS_LOCALITY,
- "postal-address-region" to HintConstants.AUTOFILL_HINT_POSTAL_ADDRESS_REGION,
- "postal-address-unit" to HintConstants.AUTOFILL_HINT_POSTAL_ADDRESS_APT_NUMBER,
- "postal-code" to HintConstants.AUTOFILL_HINT_POSTAL_CODE,
- "promo-code" to HintConstants.AUTOFILL_HINT_PROMO_CODE,
- "street-address" to HintConstants.AUTOFILL_HINT_POSTAL_ADDRESS_STREET_ADDRESS,
- "sms-otp" to HintConstants.AUTOFILL_HINT_SMS_OTP,
- "tel" to HintConstants.AUTOFILL_HINT_PHONE_NUMBER,
- "tel-country-code" to HintConstants.AUTOFILL_HINT_PHONE_COUNTRY_CODE,
- "tel-national" to HintConstants.AUTOFILL_HINT_PHONE_NATIONAL,
- "tel-device" to HintConstants.AUTOFILL_HINT_PHONE_NUMBER_DEVICE,
- "upi-vpa" to HintConstants.AUTOFILL_HINT_UPI_VPA,
- "wifi-password" to HintConstants.AUTOFILL_HINT_WIFI_PASSWORD,
- "username" to HintConstants.AUTOFILL_HINT_USERNAME,
- "username-new" to HintConstants.AUTOFILL_HINT_NEW_USERNAME,
- )
+ private val REACT_PROPS_AUTOFILL_HINTS_MAP: Map =
+ mapOf(
+ "2fa-app-otp" to HintConstants.AUTOFILL_HINT_2FA_APP_OTP,
+ "birthdate-day" to HintConstants.AUTOFILL_HINT_BIRTH_DATE_DAY,
+ "birthdate-full" to HintConstants.AUTOFILL_HINT_BIRTH_DATE_FULL,
+ "birthdate-month" to HintConstants.AUTOFILL_HINT_BIRTH_DATE_MONTH,
+ "birthdate-year" to HintConstants.AUTOFILL_HINT_BIRTH_DATE_YEAR,
+ "cc-csc" to HintConstants.AUTOFILL_HINT_CREDIT_CARD_SECURITY_CODE,
+ "cc-exp" to HintConstants.AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DATE,
+ "cc-exp-day" to HintConstants.AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DAY,
+ "cc-exp-month" to HintConstants.AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_MONTH,
+ "cc-exp-year" to HintConstants.AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_YEAR,
+ "cc-number" to HintConstants.AUTOFILL_HINT_CREDIT_CARD_NUMBER,
+ "email" to HintConstants.AUTOFILL_HINT_EMAIL_ADDRESS,
+ "email-otp" to HintConstants.AUTOFILL_HINT_EMAIL_OTP,
+ "flight-confirmation-code" to HintConstants.AUTOFILL_HINT_FLIGHT_CONFIRMATION_CODE,
+ "flight-number" to HintConstants.AUTOFILL_HINT_FLIGHT_NUMBER,
+ "gender" to HintConstants.AUTOFILL_HINT_GENDER,
+ "gift-card-number" to HintConstants.AUTOFILL_HINT_GIFT_CARD_NUMBER,
+ "gift-card-pin" to HintConstants.AUTOFILL_HINT_GIFT_CARD_PIN,
+ "loyalty-account-number" to HintConstants.AUTOFILL_HINT_LOYALTY_ACCOUNT_NUMBER,
+ "name" to HintConstants.AUTOFILL_HINT_PERSON_NAME,
+ "name-family" to HintConstants.AUTOFILL_HINT_PERSON_NAME_FAMILY,
+ "name-given" to HintConstants.AUTOFILL_HINT_PERSON_NAME_GIVEN,
+ "name-middle" to HintConstants.AUTOFILL_HINT_PERSON_NAME_MIDDLE,
+ "name-middle-initial" to HintConstants.AUTOFILL_HINT_PERSON_NAME_MIDDLE_INITIAL,
+ "name-prefix" to HintConstants.AUTOFILL_HINT_PERSON_NAME_PREFIX,
+ "name-suffix" to HintConstants.AUTOFILL_HINT_PERSON_NAME_SUFFIX,
+ "password" to HintConstants.AUTOFILL_HINT_PASSWORD,
+ "password-new" to HintConstants.AUTOFILL_HINT_NEW_PASSWORD,
+ "postal-address" to HintConstants.AUTOFILL_HINT_POSTAL_ADDRESS,
+ "postal-address-country" to HintConstants.AUTOFILL_HINT_POSTAL_ADDRESS_COUNTRY,
+ "postal-address-dependent-locality" to
+ HintConstants.AUTOFILL_HINT_POSTAL_ADDRESS_DEPENDENT_LOCALITY,
+ "postal-address-extended" to
+ HintConstants.AUTOFILL_HINT_POSTAL_ADDRESS_EXTENDED_ADDRESS,
+ "postal-address-extended-postal-code" to
+ HintConstants.AUTOFILL_HINT_POSTAL_ADDRESS_EXTENDED_POSTAL_CODE,
+ "postal-address-locality" to HintConstants.AUTOFILL_HINT_POSTAL_ADDRESS_LOCALITY,
+ "postal-address-region" to HintConstants.AUTOFILL_HINT_POSTAL_ADDRESS_REGION,
+ "postal-address-unit" to HintConstants.AUTOFILL_HINT_POSTAL_ADDRESS_APT_NUMBER,
+ "postal-code" to HintConstants.AUTOFILL_HINT_POSTAL_CODE,
+ "promo-code" to HintConstants.AUTOFILL_HINT_PROMO_CODE,
+ "street-address" to HintConstants.AUTOFILL_HINT_POSTAL_ADDRESS_STREET_ADDRESS,
+ "sms-otp" to HintConstants.AUTOFILL_HINT_SMS_OTP,
+ "tel" to HintConstants.AUTOFILL_HINT_PHONE_NUMBER,
+ "tel-country-code" to HintConstants.AUTOFILL_HINT_PHONE_COUNTRY_CODE,
+ "tel-national" to HintConstants.AUTOFILL_HINT_PHONE_NATIONAL,
+ "tel-device" to HintConstants.AUTOFILL_HINT_PHONE_NUMBER_DEVICE,
+ "upi-vpa" to HintConstants.AUTOFILL_HINT_UPI_VPA,
+ "wifi-password" to HintConstants.AUTOFILL_HINT_WIFI_PASSWORD,
+ "username" to HintConstants.AUTOFILL_HINT_USERNAME,
+ "username-new" to HintConstants.AUTOFILL_HINT_NEW_USERNAME,
+ )
private const val FOCUS_TEXT_INPUT = 1
private const val BLUR_TEXT_INPUT = 2
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextScrollWatcher.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextScrollWatcher.kt
index 51d082e63ec9..7d2dc1690644 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextScrollWatcher.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextScrollWatcher.kt
@@ -26,19 +26,20 @@ internal class ReactTextScrollWatcher(private val editText: ReactEditText) : Scr
override fun onScrollChanged(horiz: Int, vert: Int, oldHoriz: Int, oldVert: Int) {
if (previousHorizontal != horiz || previousVert != vert) {
- val event = obtain(
- surfaceId,
- editText.id,
- ScrollEventType.SCROLL,
- horiz.toFloat(),
- vert.toFloat(),
- 0f, // can't get x velocity
- 0f, // can't get y velocity
- 0, // can't get content width
- 0, // can't get content height
- editText.width,
- editText.height,
- )
+ val event =
+ obtain(
+ surfaceId,
+ editText.id,
+ ScrollEventType.SCROLL,
+ horiz.toFloat(),
+ vert.toFloat(),
+ 0f, // can't get x velocity
+ 0f, // can't get y velocity
+ 0, // can't get content width
+ 0, // can't get content height
+ editText.width,
+ editText.height,
+ )
eventDispatcher?.dispatchEvent(event)
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewManager.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewManager.kt
index fc0629f9cf72..058c584d8679 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewManager.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewManager.kt
@@ -46,18 +46,19 @@ public open class ReactViewManager : ReactClippingViewManager()
public companion object {
public const val REACT_CLASS: String = ViewProps.VIEW_CLASS_NAME
- private val SPACING_TYPES = intArrayOf(
- Spacing.ALL,
- Spacing.LEFT,
- Spacing.RIGHT,
- Spacing.TOP,
- Spacing.BOTTOM,
- Spacing.START,
- Spacing.END,
- Spacing.BLOCK,
- Spacing.BLOCK_END,
- Spacing.BLOCK_START,
- )
+ private val SPACING_TYPES =
+ intArrayOf(
+ Spacing.ALL,
+ Spacing.LEFT,
+ Spacing.RIGHT,
+ Spacing.TOP,
+ Spacing.BOTTOM,
+ Spacing.START,
+ Spacing.END,
+ Spacing.BLOCK,
+ Spacing.BLOCK_END,
+ Spacing.BLOCK_START,
+ )
private const val CMD_HOTSPOT_UPDATE = 1
private const val CMD_SET_PRESSED = 2
private const val HOTSPOT_UPDATE_KEY = "hotspotUpdate"
diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/animated/NativeAnimatedInterpolationTest.kt b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/animated/NativeAnimatedInterpolationTest.kt
index 9052f68142e8..64ca94ec2630 100644
--- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/animated/NativeAnimatedInterpolationTest.kt
+++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/animated/NativeAnimatedInterpolationTest.kt
@@ -70,24 +70,24 @@ class NativeAnimatedInterpolationTest {
val input = doubleArrayOf(10.0, 20.0)
val output = doubleArrayOf(0.0, 1.0)
assertThat(
- InterpolationAnimatedNode.interpolate(
- 30.0,
- input,
- output,
- InterpolationAnimatedNode.EXTRAPOLATE_TYPE_CLAMP,
- InterpolationAnimatedNode.EXTRAPOLATE_TYPE_CLAMP,
- ),
- )
+ InterpolationAnimatedNode.interpolate(
+ 30.0,
+ input,
+ output,
+ InterpolationAnimatedNode.EXTRAPOLATE_TYPE_CLAMP,
+ InterpolationAnimatedNode.EXTRAPOLATE_TYPE_CLAMP,
+ ),
+ )
.isEqualTo(1.0)
assertThat(
- InterpolationAnimatedNode.interpolate(
- 5.0,
- input,
- output,
- InterpolationAnimatedNode.EXTRAPOLATE_TYPE_CLAMP,
- InterpolationAnimatedNode.EXTRAPOLATE_TYPE_CLAMP,
- ),
- )
+ InterpolationAnimatedNode.interpolate(
+ 5.0,
+ input,
+ output,
+ InterpolationAnimatedNode.EXTRAPOLATE_TYPE_CLAMP,
+ InterpolationAnimatedNode.EXTRAPOLATE_TYPE_CLAMP,
+ ),
+ )
.isEqualTo(0.0)
}
@@ -96,24 +96,24 @@ class NativeAnimatedInterpolationTest {
val input = doubleArrayOf(10.0, 20.0)
val output = doubleArrayOf(0.0, 1.0)
assertThat(
- InterpolationAnimatedNode.interpolate(
- 30.0,
- input,
- output,
- InterpolationAnimatedNode.EXTRAPOLATE_TYPE_IDENTITY,
- InterpolationAnimatedNode.EXTRAPOLATE_TYPE_IDENTITY,
- ),
- )
+ InterpolationAnimatedNode.interpolate(
+ 30.0,
+ input,
+ output,
+ InterpolationAnimatedNode.EXTRAPOLATE_TYPE_IDENTITY,
+ InterpolationAnimatedNode.EXTRAPOLATE_TYPE_IDENTITY,
+ ),
+ )
.isEqualTo(30.0)
assertThat(
- InterpolationAnimatedNode.interpolate(
- 5.0,
- input,
- output,
- InterpolationAnimatedNode.EXTRAPOLATE_TYPE_IDENTITY,
- InterpolationAnimatedNode.EXTRAPOLATE_TYPE_IDENTITY,
- ),
- )
+ InterpolationAnimatedNode.interpolate(
+ 5.0,
+ input,
+ output,
+ InterpolationAnimatedNode.EXTRAPOLATE_TYPE_IDENTITY,
+ InterpolationAnimatedNode.EXTRAPOLATE_TYPE_IDENTITY,
+ ),
+ )
.isEqualTo(5.0)
}
@@ -130,32 +130,33 @@ class NativeAnimatedInterpolationTest {
@Test
fun testInterpolateString() {
val input = doubleArrayOf(0.0, 1.0)
- val output = arrayOf(
- doubleArrayOf(20.0, 20.0, 20.0, 80.0, 80.0, 80.0, 80.0, 20.0),
- doubleArrayOf(40.0, 40.0, 33.0, 60.0, 60.0, 60.0, 65.0, 40.0),
- )
+ val output =
+ arrayOf(
+ doubleArrayOf(20.0, 20.0, 20.0, 80.0, 80.0, 80.0, 80.0, 20.0),
+ doubleArrayOf(40.0, 40.0, 33.0, 60.0, 60.0, 60.0, 65.0, 40.0),
+ )
val pattern = "M20,20L20,80L80,80L80,20Z"
assertThat(
- InterpolationAnimatedNode.interpolateString(
- pattern,
- 0.0,
- input,
- output,
- InterpolationAnimatedNode.EXTRAPOLATE_TYPE_IDENTITY,
- InterpolationAnimatedNode.EXTRAPOLATE_TYPE_IDENTITY,
- ),
- )
+ InterpolationAnimatedNode.interpolateString(
+ pattern,
+ 0.0,
+ input,
+ output,
+ InterpolationAnimatedNode.EXTRAPOLATE_TYPE_IDENTITY,
+ InterpolationAnimatedNode.EXTRAPOLATE_TYPE_IDENTITY,
+ ),
+ )
.isEqualTo("M20,20L20,80L80,80L80,20Z")
assertThat(
- InterpolationAnimatedNode.interpolateString(
- pattern,
- 0.5,
- input,
- output,
- InterpolationAnimatedNode.EXTRAPOLATE_TYPE_IDENTITY,
- InterpolationAnimatedNode.EXTRAPOLATE_TYPE_IDENTITY,
- ),
- )
+ InterpolationAnimatedNode.interpolateString(
+ pattern,
+ 0.5,
+ input,
+ output,
+ InterpolationAnimatedNode.EXTRAPOLATE_TYPE_IDENTITY,
+ InterpolationAnimatedNode.EXTRAPOLATE_TYPE_IDENTITY,
+ ),
+ )
.isEqualTo("M30,30L26.5,70L70,70L72.5,30Z")
}
diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/bridge/ArrayBufferTest.kt b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/bridge/ArrayBufferTest.kt
index 8ebbd6f1c5e5..b749eacaaab0 100644
--- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/bridge/ArrayBufferTest.kt
+++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/bridge/ArrayBufferTest.kt
@@ -159,9 +159,7 @@ class ArrayBufferTest {
@Test
fun arrayBufferWithOwnedBytesRejectsNonDirectByteBuffer() {
- assertThatThrownBy {
- ArrayBuffer.arrayBufferWithOwnedBytes(ByteBuffer.wrap(byteArrayOf(1, 2)))
- }
+ assertThatThrownBy { ArrayBuffer.arrayBufferWithOwnedBytes(ByteBuffer.wrap(byteArrayOf(1, 2))) }
.isInstanceOf(IllegalArgumentException::class.java)
.hasMessageContaining("requires a direct ByteBuffer")
}
diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/bridge/ReactTestHelper.kt b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/bridge/ReactTestHelper.kt
index 65d817ae6d87..53c328427a61 100644
--- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/bridge/ReactTestHelper.kt
+++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/bridge/ReactTestHelper.kt
@@ -58,17 +58,18 @@ object ReactTestHelper {
@OptIn(UnstableReactNativeAPI::class)
fun createTestReactApplicationContext(application: Application): ReactApplicationContext {
- val reactHost = spy(
- ReactHostImpl(
- RuntimeEnvironment.getApplication(),
- mock(),
- mock(),
- Task.Companion.IMMEDIATE_EXECUTOR,
- Task.Companion.IMMEDIATE_EXECUTOR,
- false /* allowPackagerServerAccess */,
- false /* useDevSupport */,
- ),
- )
+ val reactHost =
+ spy(
+ ReactHostImpl(
+ RuntimeEnvironment.getApplication(),
+ mock(),
+ mock(),
+ Task.Companion.IMMEDIATE_EXECUTOR,
+ Task.Companion.IMMEDIATE_EXECUTOR,
+ false /* allowPackagerServerAccess */,
+ false /* useDevSupport */,
+ ),
+ )
return BridgelessReactContext(application, reactHost)
}
}
diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/devsupport/MultipartStreamReaderTest.kt b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/devsupport/MultipartStreamReaderTest.kt
index 1ef4499184aa..ea999dc165eb 100644
--- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/devsupport/MultipartStreamReaderTest.kt
+++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/devsupport/MultipartStreamReaderTest.kt
@@ -17,15 +17,16 @@ class MultipartStreamReaderTest {
@Test
fun testSimpleCase() {
- val response: ByteString = encodeUtf8(
- "preamble, should be ignored\r\n" +
- "--sample_boundary\r\n" +
- "Content-Type: application/json; charset=utf-8\r\n" +
- "Content-Length: 2\r\n\r\n" +
- "{}\r\n" +
- "--sample_boundary--\r\n" +
- "epilogue, should be ignored",
- )
+ val response: ByteString =
+ encodeUtf8(
+ "preamble, should be ignored\r\n" +
+ "--sample_boundary\r\n" +
+ "Content-Type: application/json; charset=utf-8\r\n" +
+ "Content-Length: 2\r\n\r\n" +
+ "{}\r\n" +
+ "--sample_boundary--\r\n" +
+ "epilogue, should be ignored",
+ )
val source = Buffer()
source.write(response)
@@ -55,17 +56,18 @@ class MultipartStreamReaderTest {
@Test
fun testMultipleParts() {
- val response: ByteString = encodeUtf8(
- "preamble, should be ignored\r\n" +
- "--sample_boundary\r\n" +
- "1\r\n" +
- "--sample_boundary\r\n" +
- "2\r\n" +
- "--sample_boundary\r\n" +
- "3\r\n" +
- "--sample_boundary--\r\n" +
- "epilogue, should be ignored",
- )
+ val response: ByteString =
+ encodeUtf8(
+ "preamble, should be ignored\r\n" +
+ "--sample_boundary\r\n" +
+ "1\r\n" +
+ "--sample_boundary\r\n" +
+ "2\r\n" +
+ "--sample_boundary\r\n" +
+ "3\r\n" +
+ "--sample_boundary--\r\n" +
+ "epilogue, should be ignored",
+ )
val source = Buffer()
source.write(response)
@@ -109,15 +111,16 @@ class MultipartStreamReaderTest {
@Test
fun testNoCloseDelimiter() {
- val response: ByteString = encodeUtf8(
- "preamble, should be ignored\r\n" +
- "--sample_boundary\r\n" +
- "Content-Type: application/json; charset=utf-8\r\n" +
- "Content-Length: 2\r\n\r\n" +
- "{}\r\n" +
- "--sample_boundary\r\n" +
- "incomplete message...",
- )
+ val response: ByteString =
+ encodeUtf8(
+ "preamble, should be ignored\r\n" +
+ "--sample_boundary\r\n" +
+ "Content-Type: application/json; charset=utf-8\r\n" +
+ "Content-Length: 2\r\n\r\n" +
+ "{}\r\n" +
+ "--sample_boundary\r\n" +
+ "incomplete message...",
+ )
val source = Buffer()
source.write(response)
@@ -134,18 +137,19 @@ class MultipartStreamReaderTest {
@Test
fun testListenerDoesNotNeedToFullyReadBody() {
- val response: ByteString = encodeUtf8(
- "preamble\r\n" +
- "--sample_boundary\r\n" +
- "Content-Type: text/plain\r\n" +
- "Content-Length: 4\r\n\r\n" +
- "ABCD\r\n" +
- "--sample_boundary\r\n" +
- "Content-Type: text/plain\r\n" +
- "Content-Length: 1\r\n\r\n" +
- "Z\r\n" +
- "--sample_boundary--\r\n",
- )
+ val response: ByteString =
+ encodeUtf8(
+ "preamble\r\n" +
+ "--sample_boundary\r\n" +
+ "Content-Type: text/plain\r\n" +
+ "Content-Length: 4\r\n\r\n" +
+ "ABCD\r\n" +
+ "--sample_boundary\r\n" +
+ "Content-Type: text/plain\r\n" +
+ "Content-Length: 1\r\n\r\n" +
+ "Z\r\n" +
+ "--sample_boundary--\r\n",
+ )
val source = Buffer().apply { write(response) }
val reader = MultipartStreamReader(source, "sample_boundary")
@@ -178,14 +182,15 @@ class MultipartStreamReaderTest {
@Test
fun testHeaderNamesAreCaseInsensitive() {
- val response: ByteString = encodeUtf8(
- "preamble\r\n" +
- "--sample_boundary\r\n" +
- "content-type: application/json\r\n" +
- "content-length: 2\r\n\r\n" +
- "{}\r\n" +
- "--sample_boundary--\r\n",
- )
+ val response: ByteString =
+ encodeUtf8(
+ "preamble\r\n" +
+ "--sample_boundary\r\n" +
+ "content-type: application/json\r\n" +
+ "content-length: 2\r\n\r\n" +
+ "{}\r\n" +
+ "--sample_boundary--\r\n",
+ )
val source = Buffer().apply { write(response) }
val reader = MultipartStreamReader(source, "sample_boundary")
diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/fabric/FabricMountingManagerInstrumentationTest.kt b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/fabric/FabricMountingManagerInstrumentationTest.kt
index ea33b5cb289a..d2b2d9cd2b8a 100644
--- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/fabric/FabricMountingManagerInstrumentationTest.kt
+++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/fabric/FabricMountingManagerInstrumentationTest.kt
@@ -86,15 +86,16 @@ class FabricMountingManagerInstrumentationTest {
index: Int,
componentName: String = "RCTView",
): IntBufferBatchMountItem {
- val intBuffer = intArrayOf(
- IntBufferBatchMountItem.INSTRUCTION_CREATE,
- reactTag,
- 1,
- IntBufferBatchMountItem.INSTRUCTION_INSERT,
- reactTag,
- parentTag,
- index,
- )
+ val intBuffer =
+ intArrayOf(
+ IntBufferBatchMountItem.INSTRUCTION_CREATE,
+ reactTag,
+ 1,
+ IntBufferBatchMountItem.INSTRUCTION_INSERT,
+ reactTag,
+ parentTag,
+ index,
+ )
val objBuffer = arrayOf(componentName, JavaOnlyMap.of(), null, null)
return IntBufferBatchMountItem(surfaceId, intBuffer, objBuffer, 1)
}
@@ -192,21 +193,22 @@ class FabricMountingManagerInstrumentationTest {
initialMount.execute(mountingManager)
assertThat(smm.getView(42)).isNotNull()
- val intBuffer = intArrayOf(
- IntBufferBatchMountItem.INSTRUCTION_REMOVE,
- 42,
- surfaceId,
- 0,
- IntBufferBatchMountItem.INSTRUCTION_DELETE,
- 42,
- IntBufferBatchMountItem.INSTRUCTION_CREATE,
- 42,
- 1,
- IntBufferBatchMountItem.INSTRUCTION_INSERT,
- 42,
- surfaceId,
- 0,
- )
+ val intBuffer =
+ intArrayOf(
+ IntBufferBatchMountItem.INSTRUCTION_REMOVE,
+ 42,
+ surfaceId,
+ 0,
+ IntBufferBatchMountItem.INSTRUCTION_DELETE,
+ 42,
+ IntBufferBatchMountItem.INSTRUCTION_CREATE,
+ 42,
+ 1,
+ IntBufferBatchMountItem.INSTRUCTION_INSERT,
+ 42,
+ surfaceId,
+ 0,
+ )
val objBuffer = arrayOf("RCTView", JavaOnlyMap.of(), null, null)
val batchMount = IntBufferBatchMountItem(surfaceId, intBuffer, objBuffer, 2)
batchMount.execute(mountingManager)
diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/fabric/events/TouchEventDispatchTest.kt b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/fabric/events/TouchEventDispatchTest.kt
index 00e45c3d92a6..ebecb3a9ef97 100644
--- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/fabric/events/TouchEventDispatchTest.kt
+++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/fabric/events/TouchEventDispatchTest.kt
@@ -45,450 +45,462 @@ class TouchEventDispatchTest {
private val touchEventCoalescingKeyHelper = TouchEventCoalescingKeyHelper()
/** Events (1 pointer): START -> MOVE -> MOVE -> UP */
- private val startMoveEndSequence = listOf(
- createTouchEvent(
- gestureTime = GESTURE_START_TIME,
- action = MotionEvent.ACTION_DOWN,
- pointerId = 0,
- pointerIds = intArrayOf(0),
- pointerCoords = arrayOf(pointerCoords(1f, 1f)),
- ),
- createTouchEvent(
- gestureTime = GESTURE_START_TIME,
- action = MotionEvent.ACTION_MOVE,
- pointerId = 0,
- pointerIds = intArrayOf(0),
- pointerCoords = arrayOf(pointerCoords(1f, 2f)),
- ),
- createTouchEvent(
- gestureTime = GESTURE_START_TIME,
- action = MotionEvent.ACTION_MOVE,
- pointerId = 0,
- pointerIds = intArrayOf(0),
- pointerCoords = arrayOf(pointerCoords(1f, 3f)),
- ),
- createTouchEvent(
- gestureTime = GESTURE_START_TIME,
- action = MotionEvent.ACTION_UP,
- pointerId = 0,
- pointerIds = intArrayOf(0),
- pointerCoords = arrayOf(pointerCoords(1f, 3f)),
- ),
- )
+ private val startMoveEndSequence =
+ listOf(
+ createTouchEvent(
+ gestureTime = GESTURE_START_TIME,
+ action = MotionEvent.ACTION_DOWN,
+ pointerId = 0,
+ pointerIds = intArrayOf(0),
+ pointerCoords = arrayOf(pointerCoords(1f, 1f)),
+ ),
+ createTouchEvent(
+ gestureTime = GESTURE_START_TIME,
+ action = MotionEvent.ACTION_MOVE,
+ pointerId = 0,
+ pointerIds = intArrayOf(0),
+ pointerCoords = arrayOf(pointerCoords(1f, 2f)),
+ ),
+ createTouchEvent(
+ gestureTime = GESTURE_START_TIME,
+ action = MotionEvent.ACTION_MOVE,
+ pointerId = 0,
+ pointerIds = intArrayOf(0),
+ pointerCoords = arrayOf(pointerCoords(1f, 3f)),
+ ),
+ createTouchEvent(
+ gestureTime = GESTURE_START_TIME,
+ action = MotionEvent.ACTION_UP,
+ pointerId = 0,
+ pointerIds = intArrayOf(0),
+ pointerCoords = arrayOf(pointerCoords(1f, 3f)),
+ ),
+ )
/** Expected values for [startMoveEndSequence] */
- private val startMoveEndExpectedSequence = listOf(
- /*
- * START event for touch 1:
- * {
- * touches: [touch1],
- * changed: [touch1]
- * }
- */
- buildGestureEvent(
- surfaceId = SURFACE_ID,
- viewTag = TARGET_VIEW_ID,
- locationX = 1f,
- locationY = 1f,
- time = GESTURE_START_TIME,
- pointerId = 0,
- touches = listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 1f, GESTURE_START_TIME, 0)),
- changedTouches =
- listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 1f, GESTURE_START_TIME, 0)),
- ),
- /*
- * MOVE event for touch 1:
- * {
- * touches: [touch1],
- * changed: [touch1]
- * }
- */
- buildGestureEvent(
- surfaceId = SURFACE_ID,
- viewTag = TARGET_VIEW_ID,
- locationX = 1f,
- locationY = 2f,
- time = GESTURE_START_TIME,
- pointerId = 0,
- touches = listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 2f, GESTURE_START_TIME, 0)),
- changedTouches =
- listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 2f, GESTURE_START_TIME, 0)),
- ),
- /*
- * MOVE event for touch 1:
- * {
- * touches: [touch1],
- * changed: [touch1]
- * }
- */
- buildGestureEvent(
- surfaceId = SURFACE_ID,
- viewTag = TARGET_VIEW_ID,
- locationX = 1f,
- locationY = 3f,
- time = GESTURE_START_TIME,
- pointerId = 0,
- touches = listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 3f, GESTURE_START_TIME, 0)),
- changedTouches =
- listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 3f, GESTURE_START_TIME, 0)),
- ),
- /*
- * END event for touch 1:
- * {
- * touches: [],
- * changed: [touch1]
- * }
- */
- buildGestureEvent(
- surfaceId = SURFACE_ID,
- viewTag = TARGET_VIEW_ID,
- locationX = 1f,
- locationY = 3f,
- time = GESTURE_START_TIME,
- pointerId = 0,
- touches = emptyList(),
- changedTouches =
- listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 3f, GESTURE_START_TIME, 0)),
- ),
- )
+ private val startMoveEndExpectedSequence =
+ listOf(
+ /*
+ * START event for touch 1:
+ * {
+ * touches: [touch1],
+ * changed: [touch1]
+ * }
+ */
+ buildGestureEvent(
+ surfaceId = SURFACE_ID,
+ viewTag = TARGET_VIEW_ID,
+ locationX = 1f,
+ locationY = 1f,
+ time = GESTURE_START_TIME,
+ pointerId = 0,
+ touches =
+ listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 1f, GESTURE_START_TIME, 0)),
+ changedTouches =
+ listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 1f, GESTURE_START_TIME, 0)),
+ ),
+ /*
+ * MOVE event for touch 1:
+ * {
+ * touches: [touch1],
+ * changed: [touch1]
+ * }
+ */
+ buildGestureEvent(
+ surfaceId = SURFACE_ID,
+ viewTag = TARGET_VIEW_ID,
+ locationX = 1f,
+ locationY = 2f,
+ time = GESTURE_START_TIME,
+ pointerId = 0,
+ touches =
+ listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 2f, GESTURE_START_TIME, 0)),
+ changedTouches =
+ listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 2f, GESTURE_START_TIME, 0)),
+ ),
+ /*
+ * MOVE event for touch 1:
+ * {
+ * touches: [touch1],
+ * changed: [touch1]
+ * }
+ */
+ buildGestureEvent(
+ surfaceId = SURFACE_ID,
+ viewTag = TARGET_VIEW_ID,
+ locationX = 1f,
+ locationY = 3f,
+ time = GESTURE_START_TIME,
+ pointerId = 0,
+ touches =
+ listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 3f, GESTURE_START_TIME, 0)),
+ changedTouches =
+ listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 3f, GESTURE_START_TIME, 0)),
+ ),
+ /*
+ * END event for touch 1:
+ * {
+ * touches: [],
+ * changed: [touch1]
+ * }
+ */
+ buildGestureEvent(
+ surfaceId = SURFACE_ID,
+ viewTag = TARGET_VIEW_ID,
+ locationX = 1f,
+ locationY = 3f,
+ time = GESTURE_START_TIME,
+ pointerId = 0,
+ touches = emptyList(),
+ changedTouches =
+ listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 3f, GESTURE_START_TIME, 0)),
+ ),
+ )
/** Events (2 pointer): START 1st -> START 2nd -> MOVE 1st -> UP 2st -> UP 1st */
- private val startPointerMoveUpSequence = listOf(
- createTouchEvent(
- gestureTime = GESTURE_START_TIME,
- action = MotionEvent.ACTION_DOWN,
- pointerId = 0,
- pointerIds = intArrayOf(0),
- pointerCoords = arrayOf(pointerCoords(1f, 1f)),
- ),
- createTouchEvent(
- gestureTime = GESTURE_START_TIME,
- action = MotionEvent.ACTION_POINTER_DOWN,
- pointerId = 1,
- pointerIds = intArrayOf(0, 1),
- pointerCoords = arrayOf(pointerCoords(1f, 1f), pointerCoords(2f, 1f)),
- ),
- createTouchEvent(
- gestureTime = GESTURE_START_TIME,
- action = MotionEvent.ACTION_MOVE,
- pointerId = 0,
- pointerIds = intArrayOf(0, 1),
- pointerCoords = arrayOf(pointerCoords(1f, 2f), pointerCoords(2f, 1f)),
- ),
- createTouchEvent(
- gestureTime = GESTURE_START_TIME,
- action = MotionEvent.ACTION_POINTER_UP,
- pointerId = 1,
- pointerIds = intArrayOf(0, 1),
- pointerCoords = arrayOf(pointerCoords(1f, 2f), pointerCoords(2f, 1f)),
- ),
- createTouchEvent(
- gestureTime = GESTURE_START_TIME,
- action = MotionEvent.ACTION_POINTER_UP,
- pointerId = 0,
- pointerIds = intArrayOf(0),
- pointerCoords = arrayOf(pointerCoords(1f, 2f)),
- ),
- )
+ private val startPointerMoveUpSequence =
+ listOf(
+ createTouchEvent(
+ gestureTime = GESTURE_START_TIME,
+ action = MotionEvent.ACTION_DOWN,
+ pointerId = 0,
+ pointerIds = intArrayOf(0),
+ pointerCoords = arrayOf(pointerCoords(1f, 1f)),
+ ),
+ createTouchEvent(
+ gestureTime = GESTURE_START_TIME,
+ action = MotionEvent.ACTION_POINTER_DOWN,
+ pointerId = 1,
+ pointerIds = intArrayOf(0, 1),
+ pointerCoords = arrayOf(pointerCoords(1f, 1f), pointerCoords(2f, 1f)),
+ ),
+ createTouchEvent(
+ gestureTime = GESTURE_START_TIME,
+ action = MotionEvent.ACTION_MOVE,
+ pointerId = 0,
+ pointerIds = intArrayOf(0, 1),
+ pointerCoords = arrayOf(pointerCoords(1f, 2f), pointerCoords(2f, 1f)),
+ ),
+ createTouchEvent(
+ gestureTime = GESTURE_START_TIME,
+ action = MotionEvent.ACTION_POINTER_UP,
+ pointerId = 1,
+ pointerIds = intArrayOf(0, 1),
+ pointerCoords = arrayOf(pointerCoords(1f, 2f), pointerCoords(2f, 1f)),
+ ),
+ createTouchEvent(
+ gestureTime = GESTURE_START_TIME,
+ action = MotionEvent.ACTION_POINTER_UP,
+ pointerId = 0,
+ pointerIds = intArrayOf(0),
+ pointerCoords = arrayOf(pointerCoords(1f, 2f)),
+ ),
+ )
/** Expected values for [startPointerMoveUpSequence] */
- private val startPointerMoveUpExpectedSequence = listOf(
- /*
- * START event for touch 1:
- * {
- * touch: 0,
- * touches: [touch1],
- * changed: [touch1]
- * }
- */
- buildGestureEvent(
- surfaceId = SURFACE_ID,
- viewTag = TARGET_VIEW_ID,
- locationX = 1f,
- locationY = 1f,
- time = GESTURE_START_TIME,
- pointerId = 0,
- touches = listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 1f, GESTURE_START_TIME, 0)),
- changedTouches =
- listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 1f, GESTURE_START_TIME, 0)),
- ),
- /*
- * START event for touch 2:
- * {
- * touch: 1,
- * touches: [touch0, touch1],
- * changed: [touch1]
- * }
- */
- buildGestureEvent(
- surfaceId = SURFACE_ID,
- viewTag = TARGET_VIEW_ID,
- locationX = 2f,
- locationY = 1f,
- time = GESTURE_START_TIME,
- pointerId = 1,
- touches =
- listOf(
- buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 1f, GESTURE_START_TIME, 0),
- buildGesture(SURFACE_ID, TARGET_VIEW_ID, 2f, 1f, GESTURE_START_TIME, 1),
- ),
- changedTouches =
- listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 2f, 1f, GESTURE_START_TIME, 1)),
- ),
- /*
- * MOVE event for touch 1:
- * {
- * touch: 0,
- * touches: [touch0, touch1],
- * changed: [touch0, touch1]
- * }
- * {
- * touch: 1,
- * touches: [touch0, touch1],
- * changed: [touch0, touch1]
- * }
- */
- buildGestureEvent(
- surfaceId = SURFACE_ID,
- viewTag = TARGET_VIEW_ID,
- locationX = 1f,
- locationY = 2f,
- time = GESTURE_START_TIME,
- pointerId = 0,
- touches =
- listOf(
- buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 2f, GESTURE_START_TIME, 0),
- buildGesture(SURFACE_ID, TARGET_VIEW_ID, 2f, 1f, GESTURE_START_TIME, 1),
- ),
- changedTouches =
- listOf(
- buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 2f, GESTURE_START_TIME, 0),
- buildGesture(SURFACE_ID, TARGET_VIEW_ID, 2f, 1f, GESTURE_START_TIME, 1),
- ),
- ),
- buildGestureEvent(
- surfaceId = SURFACE_ID,
- viewTag = TARGET_VIEW_ID,
- locationX = 2f,
- locationY = 1f,
- time = GESTURE_START_TIME,
- pointerId = 1,
- touches =
- listOf(
- buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 2f, GESTURE_START_TIME, 0),
- buildGesture(SURFACE_ID, TARGET_VIEW_ID, 2f, 1f, GESTURE_START_TIME, 1),
- ),
- changedTouches =
- listOf(
- buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 2f, GESTURE_START_TIME, 0),
- buildGesture(SURFACE_ID, TARGET_VIEW_ID, 2f, 1f, GESTURE_START_TIME, 1),
- ),
- ),
- /*
- * UP event pointer 1:
- * {
- * touch: 1,
- * touches: [touch0],
- * changed: [touch1]
- * }
- */
- buildGestureEvent(
- surfaceId = SURFACE_ID,
- viewTag = TARGET_VIEW_ID,
- locationX = 2f,
- locationY = 1f,
- time = GESTURE_START_TIME,
- pointerId = 1,
- touches = listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 2f, GESTURE_START_TIME, 0)),
- changedTouches =
- listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 2f, 1f, GESTURE_START_TIME, 1)),
- ),
- /*
- * UP event pointer 0:
- * {
- * touch: 0,
- * touches: [],
- * changed: [touch0]
- * }
- */
- buildGestureEvent(
- surfaceId = SURFACE_ID,
- viewTag = TARGET_VIEW_ID,
- locationX = 1f,
- locationY = 2f,
- time = GESTURE_START_TIME,
- pointerId = 0,
- touches = emptyList(),
- changedTouches =
- listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 2f, GESTURE_START_TIME, 0)),
- ),
- )
+ private val startPointerMoveUpExpectedSequence =
+ listOf(
+ /*
+ * START event for touch 1:
+ * {
+ * touch: 0,
+ * touches: [touch1],
+ * changed: [touch1]
+ * }
+ */
+ buildGestureEvent(
+ surfaceId = SURFACE_ID,
+ viewTag = TARGET_VIEW_ID,
+ locationX = 1f,
+ locationY = 1f,
+ time = GESTURE_START_TIME,
+ pointerId = 0,
+ touches =
+ listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 1f, GESTURE_START_TIME, 0)),
+ changedTouches =
+ listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 1f, GESTURE_START_TIME, 0)),
+ ),
+ /*
+ * START event for touch 2:
+ * {
+ * touch: 1,
+ * touches: [touch0, touch1],
+ * changed: [touch1]
+ * }
+ */
+ buildGestureEvent(
+ surfaceId = SURFACE_ID,
+ viewTag = TARGET_VIEW_ID,
+ locationX = 2f,
+ locationY = 1f,
+ time = GESTURE_START_TIME,
+ pointerId = 1,
+ touches =
+ listOf(
+ buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 1f, GESTURE_START_TIME, 0),
+ buildGesture(SURFACE_ID, TARGET_VIEW_ID, 2f, 1f, GESTURE_START_TIME, 1),
+ ),
+ changedTouches =
+ listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 2f, 1f, GESTURE_START_TIME, 1)),
+ ),
+ /*
+ * MOVE event for touch 1:
+ * {
+ * touch: 0,
+ * touches: [touch0, touch1],
+ * changed: [touch0, touch1]
+ * }
+ * {
+ * touch: 1,
+ * touches: [touch0, touch1],
+ * changed: [touch0, touch1]
+ * }
+ */
+ buildGestureEvent(
+ surfaceId = SURFACE_ID,
+ viewTag = TARGET_VIEW_ID,
+ locationX = 1f,
+ locationY = 2f,
+ time = GESTURE_START_TIME,
+ pointerId = 0,
+ touches =
+ listOf(
+ buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 2f, GESTURE_START_TIME, 0),
+ buildGesture(SURFACE_ID, TARGET_VIEW_ID, 2f, 1f, GESTURE_START_TIME, 1),
+ ),
+ changedTouches =
+ listOf(
+ buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 2f, GESTURE_START_TIME, 0),
+ buildGesture(SURFACE_ID, TARGET_VIEW_ID, 2f, 1f, GESTURE_START_TIME, 1),
+ ),
+ ),
+ buildGestureEvent(
+ surfaceId = SURFACE_ID,
+ viewTag = TARGET_VIEW_ID,
+ locationX = 2f,
+ locationY = 1f,
+ time = GESTURE_START_TIME,
+ pointerId = 1,
+ touches =
+ listOf(
+ buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 2f, GESTURE_START_TIME, 0),
+ buildGesture(SURFACE_ID, TARGET_VIEW_ID, 2f, 1f, GESTURE_START_TIME, 1),
+ ),
+ changedTouches =
+ listOf(
+ buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 2f, GESTURE_START_TIME, 0),
+ buildGesture(SURFACE_ID, TARGET_VIEW_ID, 2f, 1f, GESTURE_START_TIME, 1),
+ ),
+ ),
+ /*
+ * UP event pointer 1:
+ * {
+ * touch: 1,
+ * touches: [touch0],
+ * changed: [touch1]
+ * }
+ */
+ buildGestureEvent(
+ surfaceId = SURFACE_ID,
+ viewTag = TARGET_VIEW_ID,
+ locationX = 2f,
+ locationY = 1f,
+ time = GESTURE_START_TIME,
+ pointerId = 1,
+ touches =
+ listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 2f, GESTURE_START_TIME, 0)),
+ changedTouches =
+ listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 2f, 1f, GESTURE_START_TIME, 1)),
+ ),
+ /*
+ * UP event pointer 0:
+ * {
+ * touch: 0,
+ * touches: [],
+ * changed: [touch0]
+ * }
+ */
+ buildGestureEvent(
+ surfaceId = SURFACE_ID,
+ viewTag = TARGET_VIEW_ID,
+ locationX = 1f,
+ locationY = 2f,
+ time = GESTURE_START_TIME,
+ pointerId = 0,
+ touches = emptyList(),
+ changedTouches =
+ listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 2f, GESTURE_START_TIME, 0)),
+ ),
+ )
/** Events (2 pointer): START 1st -> START 2nd -> MOVE 1st -> CANCEL */
- private val startMoveCancelSequence = listOf(
- createTouchEvent(
- gestureTime = GESTURE_START_TIME,
- action = MotionEvent.ACTION_DOWN,
- pointerId = 0,
- pointerIds = intArrayOf(0),
- pointerCoords = arrayOf(pointerCoords(1f, 1f)),
- ),
- createTouchEvent(
- gestureTime = GESTURE_START_TIME,
- action = MotionEvent.ACTION_POINTER_DOWN,
- pointerId = 1,
- pointerIds = intArrayOf(0, 1),
- pointerCoords = arrayOf(pointerCoords(1f, 1f), pointerCoords(2f, 1f)),
- ),
- createTouchEvent(
- gestureTime = GESTURE_START_TIME,
- action = MotionEvent.ACTION_MOVE,
- pointerId = 0,
- pointerIds = intArrayOf(0, 1),
- pointerCoords = arrayOf(pointerCoords(1f, 2f), pointerCoords(2f, 1f)),
- ),
- createTouchEvent(
- gestureTime = GESTURE_START_TIME,
- action = MotionEvent.ACTION_CANCEL,
- pointerId = 0,
- pointerIds = intArrayOf(0, 1),
- pointerCoords = arrayOf(pointerCoords(1f, 3f), pointerCoords(2f, 1f)),
- ),
- )
+ private val startMoveCancelSequence =
+ listOf(
+ createTouchEvent(
+ gestureTime = GESTURE_START_TIME,
+ action = MotionEvent.ACTION_DOWN,
+ pointerId = 0,
+ pointerIds = intArrayOf(0),
+ pointerCoords = arrayOf(pointerCoords(1f, 1f)),
+ ),
+ createTouchEvent(
+ gestureTime = GESTURE_START_TIME,
+ action = MotionEvent.ACTION_POINTER_DOWN,
+ pointerId = 1,
+ pointerIds = intArrayOf(0, 1),
+ pointerCoords = arrayOf(pointerCoords(1f, 1f), pointerCoords(2f, 1f)),
+ ),
+ createTouchEvent(
+ gestureTime = GESTURE_START_TIME,
+ action = MotionEvent.ACTION_MOVE,
+ pointerId = 0,
+ pointerIds = intArrayOf(0, 1),
+ pointerCoords = arrayOf(pointerCoords(1f, 2f), pointerCoords(2f, 1f)),
+ ),
+ createTouchEvent(
+ gestureTime = GESTURE_START_TIME,
+ action = MotionEvent.ACTION_CANCEL,
+ pointerId = 0,
+ pointerIds = intArrayOf(0, 1),
+ pointerCoords = arrayOf(pointerCoords(1f, 3f), pointerCoords(2f, 1f)),
+ ),
+ )
/** Expected values for [startMoveCancelSequence] */
- private val startMoveCancelExpectedSequence = listOf(
- /*
- * START event for touch 1:
- * {
- * touch: 0,
- * touches: [touch1],
- * changed: [touch1]
- * }
- */
- buildGestureEvent(
- surfaceId = SURFACE_ID,
- viewTag = TARGET_VIEW_ID,
- locationX = 1f,
- locationY = 1f,
- time = GESTURE_START_TIME,
- pointerId = 0,
- touches = listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 1f, GESTURE_START_TIME, 0)),
- changedTouches =
- listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 1f, GESTURE_START_TIME, 0)),
- ),
- /*
- * START event for touch 2:
- * {
- * touch: 1,
- * touches: [touch0, touch1],
- * changed: [touch1]
- * }
- */
- buildGestureEvent(
- surfaceId = SURFACE_ID,
- viewTag = TARGET_VIEW_ID,
- locationX = 2f,
- locationY = 1f,
- time = GESTURE_START_TIME,
- pointerId = 1,
- touches =
- listOf(
- buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 1f, GESTURE_START_TIME, 0),
- buildGesture(SURFACE_ID, TARGET_VIEW_ID, 2f, 1f, GESTURE_START_TIME, 1),
- ),
- changedTouches =
- listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 2f, 1f, GESTURE_START_TIME, 1)),
- ),
- /*
- * MOVE event for touch 1:
- * {
- * touch: 0,
- * touches: [touch0, touch1],
- * changed: [touch0, touch1]
- * }
- * {
- * touch: 1,
- * touches: [touch0, touch1],
- * changed: [touch0, touch1]
- * }
- */
- buildGestureEvent(
- surfaceId = SURFACE_ID,
- viewTag = TARGET_VIEW_ID,
- locationX = 1f,
- locationY = 2f,
- time = GESTURE_START_TIME,
- pointerId = 0,
- touches =
+ private val startMoveCancelExpectedSequence =
+ listOf(
+ /*
+ * START event for touch 1:
+ * {
+ * touch: 0,
+ * touches: [touch1],
+ * changed: [touch1]
+ * }
+ */
+ buildGestureEvent(
+ surfaceId = SURFACE_ID,
+ viewTag = TARGET_VIEW_ID,
+ locationX = 1f,
+ locationY = 1f,
+ time = GESTURE_START_TIME,
+ pointerId = 0,
+ touches =
+ listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 1f, GESTURE_START_TIME, 0)),
+ changedTouches =
+ listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 1f, GESTURE_START_TIME, 0)),
+ ),
+ /*
+ * START event for touch 2:
+ * {
+ * touch: 1,
+ * touches: [touch0, touch1],
+ * changed: [touch1]
+ * }
+ */
+ buildGestureEvent(
+ surfaceId = SURFACE_ID,
+ viewTag = TARGET_VIEW_ID,
+ locationX = 2f,
+ locationY = 1f,
+ time = GESTURE_START_TIME,
+ pointerId = 1,
+ touches =
+ listOf(
+ buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 1f, GESTURE_START_TIME, 0),
+ buildGesture(SURFACE_ID, TARGET_VIEW_ID, 2f, 1f, GESTURE_START_TIME, 1),
+ ),
+ changedTouches =
+ listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 2f, 1f, GESTURE_START_TIME, 1)),
+ ),
+ /*
+ * MOVE event for touch 1:
+ * {
+ * touch: 0,
+ * touches: [touch0, touch1],
+ * changed: [touch0, touch1]
+ * }
+ * {
+ * touch: 1,
+ * touches: [touch0, touch1],
+ * changed: [touch0, touch1]
+ * }
+ */
+ buildGestureEvent(
+ surfaceId = SURFACE_ID,
+ viewTag = TARGET_VIEW_ID,
+ locationX = 1f,
+ locationY = 2f,
+ time = GESTURE_START_TIME,
+ pointerId = 0,
+ touches =
+ listOf(
+ buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 2f, GESTURE_START_TIME, 0),
+ buildGesture(SURFACE_ID, TARGET_VIEW_ID, 2f, 1f, GESTURE_START_TIME, 1),
+ ),
+ changedTouches =
+ listOf(
+ buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 2f, GESTURE_START_TIME, 0),
+ buildGesture(SURFACE_ID, TARGET_VIEW_ID, 2f, 1f, GESTURE_START_TIME, 1),
+ ),
+ ),
+ buildGestureEvent(
+ SURFACE_ID,
+ TARGET_VIEW_ID,
+ 2f,
+ 1f,
+ GESTURE_START_TIME,
+ 1,
listOf(
buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 2f, GESTURE_START_TIME, 0),
buildGesture(SURFACE_ID, TARGET_VIEW_ID, 2f, 1f, GESTURE_START_TIME, 1),
),
- changedTouches =
listOf(
buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 2f, GESTURE_START_TIME, 0),
buildGesture(SURFACE_ID, TARGET_VIEW_ID, 2f, 1f, GESTURE_START_TIME, 1),
),
- ),
- buildGestureEvent(
- SURFACE_ID,
- TARGET_VIEW_ID,
- 2f,
- 1f,
- GESTURE_START_TIME,
- 1,
- listOf(
- buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 2f, GESTURE_START_TIME, 0),
- buildGesture(SURFACE_ID, TARGET_VIEW_ID, 2f, 1f, GESTURE_START_TIME, 1),
),
- listOf(
- buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 2f, GESTURE_START_TIME, 0),
- buildGesture(SURFACE_ID, TARGET_VIEW_ID, 2f, 1f, GESTURE_START_TIME, 1),
+ /*
+ * CANCEL event:
+ * {
+ * touch: 0,
+ * touches: [],
+ * changed: [touch0, touch1]
+ * }
+ * {
+ * touch: 1,
+ * touches: [],
+ * changed: [touch0, touch1]
+ * }
+ */
+ buildGestureEvent(
+ surfaceId = SURFACE_ID,
+ viewTag = TARGET_VIEW_ID,
+ locationX = 1f,
+ locationY = 3f,
+ time = GESTURE_START_TIME,
+ pointerId = 0,
+ touches = emptyList(),
+ changedTouches =
+ listOf(
+ buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 3f, GESTURE_START_TIME, 0),
+ buildGesture(SURFACE_ID, TARGET_VIEW_ID, 2f, 1f, GESTURE_START_TIME, 1),
+ ),
),
- ),
- /*
- * CANCEL event:
- * {
- * touch: 0,
- * touches: [],
- * changed: [touch0, touch1]
- * }
- * {
- * touch: 1,
- * touches: [],
- * changed: [touch0, touch1]
- * }
- */
- buildGestureEvent(
- surfaceId = SURFACE_ID,
- viewTag = TARGET_VIEW_ID,
- locationX = 1f,
- locationY = 3f,
- time = GESTURE_START_TIME,
- pointerId = 0,
- touches = emptyList(),
- changedTouches =
- listOf(
- buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 3f, GESTURE_START_TIME, 0),
- buildGesture(SURFACE_ID, TARGET_VIEW_ID, 2f, 1f, GESTURE_START_TIME, 1),
- ),
- ),
- buildGestureEvent(
- surfaceId = SURFACE_ID,
- viewTag = TARGET_VIEW_ID,
- locationX = 2f,
- locationY = 1f,
- time = GESTURE_START_TIME,
- pointerId = 1,
- touches = emptyList(),
- changedTouches =
- listOf(
- buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 3f, GESTURE_START_TIME, 0),
- buildGesture(SURFACE_ID, TARGET_VIEW_ID, 2f, 1f, GESTURE_START_TIME, 1),
- ),
- ),
- )
+ buildGestureEvent(
+ surfaceId = SURFACE_ID,
+ viewTag = TARGET_VIEW_ID,
+ locationX = 2f,
+ locationY = 1f,
+ time = GESTURE_START_TIME,
+ pointerId = 1,
+ touches = emptyList(),
+ changedTouches =
+ listOf(
+ buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 3f, GESTURE_START_TIME, 0),
+ buildGesture(SURFACE_ID, TARGET_VIEW_ID, 2f, 1f, GESTURE_START_TIME, 1),
+ ),
+ ),
+ )
private lateinit var eventDispatcher: EventDispatcher
private lateinit var eventEmitter: FabricEventEmitter
diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/modules/model/ReactModuleInfoTest.kt b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/modules/model/ReactModuleInfoTest.kt
index 22ffbd76bbb2..85576444a541 100644
--- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/modules/model/ReactModuleInfoTest.kt
+++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/modules/model/ReactModuleInfoTest.kt
@@ -16,14 +16,15 @@ class ReactModuleInfoTest {
@Test
fun testCreateReactModuleInfo() {
- val reactModuleInfo = ReactModuleInfo(
- /* name = */ "name",
- /* className = */ "class",
- /* canOverrideExistingModule = */ false,
- /* needsEagerInit = */ false,
- /* isCxxModule = */ false,
- /* isTurboModule = */ false,
- )
+ val reactModuleInfo =
+ ReactModuleInfo(
+ /* name = */ "name",
+ /* className = */ "class",
+ /* canOverrideExistingModule = */ false,
+ /* needsEagerInit = */ false,
+ /* isCxxModule = */ false,
+ /* isTurboModule = */ false,
+ )
assertThat(reactModuleInfo.name).isEqualTo("name")
assertThat(reactModuleInfo.canOverrideExistingModule).isFalse()
assertThat(reactModuleInfo.needsEagerInit).isFalse()
diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/modules/network/NetworkingModuleTest.kt b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/modules/network/NetworkingModuleTest.kt
index 0f60284d4a80..da1f2e4163d7 100644
--- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/modules/network/NetworkingModuleTest.kt
+++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/modules/network/NetworkingModuleTest.kt
@@ -220,10 +220,11 @@ class NetworkingModuleTest {
@Test
fun testHeaders() {
- val headers = listOf(
- JavaOnlyArray.of("Accept", "text/plain"),
- JavaOnlyArray.of("User-Agent", "React test agent/1.0"),
- )
+ val headers =
+ listOf(
+ JavaOnlyArray.of("Accept", "text/plain"),
+ JavaOnlyArray.of("User-Agent", "React test agent/1.0"),
+ )
networkingModule.sendRequest(
"GET",
@@ -365,11 +366,12 @@ class NetworkingModuleTest {
@Test
fun testMultipartPostRequestHeaders() {
setupRequestBodyUtil()
- val headers = listOf(
- JavaOnlyArray.of("Accept", "text/plain"),
- JavaOnlyArray.of("User-Agent", "React test agent/1.0"),
- JavaOnlyArray.of("content-type", "multipart/form-data"),
- )
+ val headers =
+ listOf(
+ JavaOnlyArray.of("Accept", "text/plain"),
+ JavaOnlyArray.of("User-Agent", "React test agent/1.0"),
+ JavaOnlyArray.of("content-type", "multipart/form-data"),
+ )
val body = JavaOnlyMap()
val formData = JavaOnlyArray()
diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/runtime/ReactHostDelegateTest.kt b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/runtime/ReactHostDelegateTest.kt
index e3081d5b4d90..f3aefed9303f 100644
--- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/runtime/ReactHostDelegateTest.kt
+++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/runtime/ReactHostDelegateTest.kt
@@ -36,12 +36,13 @@ class ReactHostDelegateTest {
Mockito.mock(ReactPackageTurboModuleManagerDelegate.Builder::class.java)
val hermesInstance: JSRuntimeFactory = Mockito.mock(HermesInstance::class.java)
val jsMainModulePathMocked = "mockedJSMainModulePath"
- val delegate = DefaultReactHostDelegate(
- jsMainModulePath = jsMainModulePathMocked,
- jsBundleLoader = jsBundleLoader,
- jsRuntimeFactory = hermesInstance,
- turboModuleManagerDelegateBuilder = turboModuleManagerDelegateBuilderMock,
- )
+ val delegate =
+ DefaultReactHostDelegate(
+ jsMainModulePath = jsMainModulePathMocked,
+ jsBundleLoader = jsBundleLoader,
+ jsRuntimeFactory = hermesInstance,
+ turboModuleManagerDelegateBuilder = turboModuleManagerDelegateBuilderMock,
+ )
assertThat(delegate.jsMainModulePath).isEqualTo(jsMainModulePathMocked)
}
diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/BorderRadiusStyleTest.kt b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/BorderRadiusStyleTest.kt
index 7f15a7fb1c05..4a002f15fb8c 100644
--- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/BorderRadiusStyleTest.kt
+++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/BorderRadiusStyleTest.kt
@@ -28,36 +28,37 @@ class BorderRadiusStyleTest {
@Test
fun testCorrectPriorityLTR() {
- val propertyOrderMap = mapOf(
- ComputedBorderRadiusProp.COMPUTED_BORDER_TOP_LEFT_RADIUS to
- arrayOf(
- BorderRadiusProp.BORDER_RADIUS,
- BorderRadiusProp.BORDER_TOP_LEFT_RADIUS,
- BorderRadiusProp.BORDER_TOP_START_RADIUS,
- BorderRadiusProp.BORDER_START_START_RADIUS,
- ),
- ComputedBorderRadiusProp.COMPUTED_BORDER_TOP_RIGHT_RADIUS to
- arrayOf(
- BorderRadiusProp.BORDER_RADIUS,
- BorderRadiusProp.BORDER_TOP_RIGHT_RADIUS,
- BorderRadiusProp.BORDER_TOP_END_RADIUS,
- BorderRadiusProp.BORDER_START_END_RADIUS,
- ),
- ComputedBorderRadiusProp.COMPUTED_BORDER_BOTTOM_LEFT_RADIUS to
- arrayOf(
- BorderRadiusProp.BORDER_RADIUS,
- BorderRadiusProp.BORDER_BOTTOM_LEFT_RADIUS,
- BorderRadiusProp.BORDER_BOTTOM_START_RADIUS,
- BorderRadiusProp.BORDER_END_START_RADIUS,
- ),
- ComputedBorderRadiusProp.COMPUTED_BORDER_BOTTOM_RIGHT_RADIUS to
- arrayOf(
- BorderRadiusProp.BORDER_RADIUS,
- BorderRadiusProp.BORDER_BOTTOM_RIGHT_RADIUS,
- BorderRadiusProp.BORDER_BOTTOM_END_RADIUS,
- BorderRadiusProp.BORDER_END_END_RADIUS,
- ),
- )
+ val propertyOrderMap =
+ mapOf(
+ ComputedBorderRadiusProp.COMPUTED_BORDER_TOP_LEFT_RADIUS to
+ arrayOf(
+ BorderRadiusProp.BORDER_RADIUS,
+ BorderRadiusProp.BORDER_TOP_LEFT_RADIUS,
+ BorderRadiusProp.BORDER_TOP_START_RADIUS,
+ BorderRadiusProp.BORDER_START_START_RADIUS,
+ ),
+ ComputedBorderRadiusProp.COMPUTED_BORDER_TOP_RIGHT_RADIUS to
+ arrayOf(
+ BorderRadiusProp.BORDER_RADIUS,
+ BorderRadiusProp.BORDER_TOP_RIGHT_RADIUS,
+ BorderRadiusProp.BORDER_TOP_END_RADIUS,
+ BorderRadiusProp.BORDER_START_END_RADIUS,
+ ),
+ ComputedBorderRadiusProp.COMPUTED_BORDER_BOTTOM_LEFT_RADIUS to
+ arrayOf(
+ BorderRadiusProp.BORDER_RADIUS,
+ BorderRadiusProp.BORDER_BOTTOM_LEFT_RADIUS,
+ BorderRadiusProp.BORDER_BOTTOM_START_RADIUS,
+ BorderRadiusProp.BORDER_END_START_RADIUS,
+ ),
+ ComputedBorderRadiusProp.COMPUTED_BORDER_BOTTOM_RIGHT_RADIUS to
+ arrayOf(
+ BorderRadiusProp.BORDER_RADIUS,
+ BorderRadiusProp.BORDER_BOTTOM_RIGHT_RADIUS,
+ BorderRadiusProp.BORDER_BOTTOM_END_RADIUS,
+ BorderRadiusProp.BORDER_END_END_RADIUS,
+ ),
+ )
propertyOrderMap.forEach { order ->
val borderRadiusStyle = BorderRadiusStyle()
@@ -80,36 +81,37 @@ class BorderRadiusStyleTest {
@Test
fun testCorrectPriorityRTL() {
setContextLeftAndRightSwap(ctx, true)
- val propertyOrderMap = mapOf(
- ComputedBorderRadiusProp.COMPUTED_BORDER_TOP_LEFT_RADIUS to
- arrayOf(
- BorderRadiusProp.BORDER_RADIUS,
- BorderRadiusProp.BORDER_TOP_RIGHT_RADIUS,
- BorderRadiusProp.BORDER_TOP_END_RADIUS,
- BorderRadiusProp.BORDER_START_END_RADIUS,
- ),
- ComputedBorderRadiusProp.COMPUTED_BORDER_TOP_RIGHT_RADIUS to
- arrayOf(
- BorderRadiusProp.BORDER_RADIUS,
- BorderRadiusProp.BORDER_TOP_LEFT_RADIUS,
- BorderRadiusProp.BORDER_TOP_START_RADIUS,
- BorderRadiusProp.BORDER_START_START_RADIUS,
- ),
- ComputedBorderRadiusProp.COMPUTED_BORDER_BOTTOM_LEFT_RADIUS to
- arrayOf(
- BorderRadiusProp.BORDER_RADIUS,
- BorderRadiusProp.BORDER_BOTTOM_RIGHT_RADIUS,
- BorderRadiusProp.BORDER_BOTTOM_END_RADIUS,
- BorderRadiusProp.BORDER_END_END_RADIUS,
- ),
- ComputedBorderRadiusProp.COMPUTED_BORDER_BOTTOM_RIGHT_RADIUS to
- arrayOf(
- BorderRadiusProp.BORDER_RADIUS,
- BorderRadiusProp.BORDER_BOTTOM_LEFT_RADIUS,
- BorderRadiusProp.BORDER_BOTTOM_START_RADIUS,
- BorderRadiusProp.BORDER_END_START_RADIUS,
- ),
- )
+ val propertyOrderMap =
+ mapOf(
+ ComputedBorderRadiusProp.COMPUTED_BORDER_TOP_LEFT_RADIUS to
+ arrayOf(
+ BorderRadiusProp.BORDER_RADIUS,
+ BorderRadiusProp.BORDER_TOP_RIGHT_RADIUS,
+ BorderRadiusProp.BORDER_TOP_END_RADIUS,
+ BorderRadiusProp.BORDER_START_END_RADIUS,
+ ),
+ ComputedBorderRadiusProp.COMPUTED_BORDER_TOP_RIGHT_RADIUS to
+ arrayOf(
+ BorderRadiusProp.BORDER_RADIUS,
+ BorderRadiusProp.BORDER_TOP_LEFT_RADIUS,
+ BorderRadiusProp.BORDER_TOP_START_RADIUS,
+ BorderRadiusProp.BORDER_START_START_RADIUS,
+ ),
+ ComputedBorderRadiusProp.COMPUTED_BORDER_BOTTOM_LEFT_RADIUS to
+ arrayOf(
+ BorderRadiusProp.BORDER_RADIUS,
+ BorderRadiusProp.BORDER_BOTTOM_RIGHT_RADIUS,
+ BorderRadiusProp.BORDER_BOTTOM_END_RADIUS,
+ BorderRadiusProp.BORDER_END_END_RADIUS,
+ ),
+ ComputedBorderRadiusProp.COMPUTED_BORDER_BOTTOM_RIGHT_RADIUS to
+ arrayOf(
+ BorderRadiusProp.BORDER_RADIUS,
+ BorderRadiusProp.BORDER_BOTTOM_LEFT_RADIUS,
+ BorderRadiusProp.BORDER_BOTTOM_START_RADIUS,
+ BorderRadiusProp.BORDER_END_START_RADIUS,
+ ),
+ )
propertyOrderMap.forEach { order ->
val borderRadiusStyle = BorderRadiusStyle()
@@ -127,36 +129,37 @@ class BorderRadiusStyleTest {
@Test
fun testCorrectPriorityRTLNoSwap() {
setContextLeftAndRightSwap(ctx, false)
- val propertyOrderMap = mapOf(
- ComputedBorderRadiusProp.COMPUTED_BORDER_TOP_LEFT_RADIUS to
- arrayOf(
- BorderRadiusProp.BORDER_RADIUS,
- BorderRadiusProp.BORDER_TOP_LEFT_RADIUS,
- BorderRadiusProp.BORDER_TOP_END_RADIUS,
- BorderRadiusProp.BORDER_START_END_RADIUS,
- ),
- ComputedBorderRadiusProp.COMPUTED_BORDER_TOP_RIGHT_RADIUS to
- arrayOf(
- BorderRadiusProp.BORDER_RADIUS,
- BorderRadiusProp.BORDER_TOP_RIGHT_RADIUS,
- BorderRadiusProp.BORDER_TOP_START_RADIUS,
- BorderRadiusProp.BORDER_START_START_RADIUS,
- ),
- ComputedBorderRadiusProp.COMPUTED_BORDER_BOTTOM_LEFT_RADIUS to
- arrayOf(
- BorderRadiusProp.BORDER_RADIUS,
- BorderRadiusProp.BORDER_BOTTOM_LEFT_RADIUS,
- BorderRadiusProp.BORDER_BOTTOM_START_RADIUS,
- BorderRadiusProp.BORDER_END_END_RADIUS,
- ),
- ComputedBorderRadiusProp.COMPUTED_BORDER_BOTTOM_RIGHT_RADIUS to
- arrayOf(
- BorderRadiusProp.BORDER_RADIUS,
- BorderRadiusProp.BORDER_BOTTOM_RIGHT_RADIUS,
- BorderRadiusProp.BORDER_BOTTOM_END_RADIUS,
- BorderRadiusProp.BORDER_END_START_RADIUS,
- ),
- )
+ val propertyOrderMap =
+ mapOf(
+ ComputedBorderRadiusProp.COMPUTED_BORDER_TOP_LEFT_RADIUS to
+ arrayOf(
+ BorderRadiusProp.BORDER_RADIUS,
+ BorderRadiusProp.BORDER_TOP_LEFT_RADIUS,
+ BorderRadiusProp.BORDER_TOP_END_RADIUS,
+ BorderRadiusProp.BORDER_START_END_RADIUS,
+ ),
+ ComputedBorderRadiusProp.COMPUTED_BORDER_TOP_RIGHT_RADIUS to
+ arrayOf(
+ BorderRadiusProp.BORDER_RADIUS,
+ BorderRadiusProp.BORDER_TOP_RIGHT_RADIUS,
+ BorderRadiusProp.BORDER_TOP_START_RADIUS,
+ BorderRadiusProp.BORDER_START_START_RADIUS,
+ ),
+ ComputedBorderRadiusProp.COMPUTED_BORDER_BOTTOM_LEFT_RADIUS to
+ arrayOf(
+ BorderRadiusProp.BORDER_RADIUS,
+ BorderRadiusProp.BORDER_BOTTOM_LEFT_RADIUS,
+ BorderRadiusProp.BORDER_BOTTOM_START_RADIUS,
+ BorderRadiusProp.BORDER_END_END_RADIUS,
+ ),
+ ComputedBorderRadiusProp.COMPUTED_BORDER_BOTTOM_RIGHT_RADIUS to
+ arrayOf(
+ BorderRadiusProp.BORDER_RADIUS,
+ BorderRadiusProp.BORDER_BOTTOM_RIGHT_RADIUS,
+ BorderRadiusProp.BORDER_BOTTOM_END_RADIUS,
+ BorderRadiusProp.BORDER_END_START_RADIUS,
+ ),
+ )
propertyOrderMap.forEach { order ->
val borderRadiusStyle = BorderRadiusStyle()
@@ -173,12 +176,13 @@ class BorderRadiusStyleTest {
@Test
fun testBorderRadiusPercentages() {
- val borderRadiusStyle = BorderRadiusStyle(
- topLeft = LengthPercentage(0f, LengthPercentageType.PERCENT),
- topRight = LengthPercentage(10f, LengthPercentageType.PERCENT),
- bottomLeft = LengthPercentage(20f, LengthPercentageType.PERCENT),
- bottomRight = LengthPercentage(30f, LengthPercentageType.PERCENT),
- )
+ val borderRadiusStyle =
+ BorderRadiusStyle(
+ topLeft = LengthPercentage(0f, LengthPercentageType.PERCENT),
+ topRight = LengthPercentage(10f, LengthPercentageType.PERCENT),
+ bottomLeft = LengthPercentage(20f, LengthPercentageType.PERCENT),
+ bottomRight = LengthPercentage(30f, LengthPercentageType.PERCENT),
+ )
val resolved = borderRadiusStyle.resolve(0, context = ctx, width = 1000f, height = 1000f)
assertThat(resolved.topLeft).isEqualTo(CornerRadii(0f, 0f))
diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/JSPointerDispatcherTest.kt b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/JSPointerDispatcherTest.kt
index 21041d1c773f..63279df820b1 100644
--- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/JSPointerDispatcherTest.kt
+++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/JSPointerDispatcherTest.kt
@@ -74,11 +74,12 @@ class JSPointerDispatcherTest {
@Test
fun testPointerEnter() {
val childRect = getChildViewRectInRootCoordinates(0)
- val ev = createMotionEvent(
- MotionEvent.ACTION_DOWN,
- childRect.centerX().toFloat(),
- childRect.centerY().toFloat(),
- )
+ val ev =
+ createMotionEvent(
+ MotionEvent.ACTION_DOWN,
+ childRect.centerX().toFloat(),
+ childRect.centerY().toFloat(),
+ )
val mockDispatcher: EventDispatcher = mock()
pointerDispatcher.handleMotionEvent(ev, mockDispatcher, false)
verify(mockDispatcher).dispatchEvent(argThat(EventWithName(PointerEventHelper.POINTER_DOWN)))
diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/MatrixMathHelperTest.kt b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/MatrixMathHelperTest.kt
index 1e4e5852cc44..19274bcd9214 100644
--- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/MatrixMathHelperTest.kt
+++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/MatrixMathHelperTest.kt
@@ -159,64 +159,67 @@ class MatrixMathHelperTest {
@Test
fun testMultiplyInto() {
- val matrixA = doubleArrayOf(
- 1.0,
- 2.0,
- 3.0,
- 4.0,
- 5.0,
- 6.0,
- 7.0,
- 8.0,
- 9.0,
- 10.0,
- 11.0,
- 12.0,
- 13.0,
- 14.0,
- 15.0,
- 16.0,
- )
- val matrixB = doubleArrayOf(
- 2.0,
- 0.0,
- 0.0,
- 0.0,
- 0.0,
- 2.0,
- 0.0,
- 0.0,
- 0.0,
- 0.0,
- 2.0,
- 0.0,
- 0.0,
- 0.0,
- 0.0,
- 2.0,
- )
+ val matrixA =
+ doubleArrayOf(
+ 1.0,
+ 2.0,
+ 3.0,
+ 4.0,
+ 5.0,
+ 6.0,
+ 7.0,
+ 8.0,
+ 9.0,
+ 10.0,
+ 11.0,
+ 12.0,
+ 13.0,
+ 14.0,
+ 15.0,
+ 16.0,
+ )
+ val matrixB =
+ doubleArrayOf(
+ 2.0,
+ 0.0,
+ 0.0,
+ 0.0,
+ 0.0,
+ 2.0,
+ 0.0,
+ 0.0,
+ 0.0,
+ 0.0,
+ 2.0,
+ 0.0,
+ 0.0,
+ 0.0,
+ 0.0,
+ 2.0,
+ )
val result = DoubleArray(16)
MatrixMathHelper.multiplyInto(result, matrixA, matrixB)
- val expected = doubleArrayOf(
- 2.0,
- 4.0,
- 6.0,
- 8.0,
- 10.0,
- 12.0,
- 14.0,
- 16.0,
- 18.0,
- 20.0,
- 22.0,
- 24.0,
- 26.0,
- 28.0,
- 30.0,
- 32.0,
- )
+ val expected =
+ doubleArrayOf(
+ 2.0,
+ 4.0,
+ 6.0,
+ 8.0,
+ 10.0,
+ 12.0,
+ 14.0,
+ 16.0,
+ 18.0,
+ 20.0,
+ 22.0,
+ 24.0,
+ 26.0,
+ 28.0,
+ 30.0,
+ 32.0,
+ )
assertThat(result).containsExactly(*expected)
}
@@ -225,69 +228,72 @@ class MatrixMathHelperTest {
fun testCreateIdentityMatrix() {
val identity = MatrixMathHelper.createIdentityMatrix()
- val expected = doubleArrayOf(
- 1.0,
- 0.0,
- 0.0,
- 0.0,
- 0.0,
- 1.0,
- 0.0,
- 0.0,
- 0.0,
- 0.0,
- 1.0,
- 0.0,
- 0.0,
- 0.0,
- 0.0,
- 1.0,
- )
+ val expected =
+ doubleArrayOf(
+ 1.0,
+ 0.0,
+ 0.0,
+ 0.0,
+ 0.0,
+ 1.0,
+ 0.0,
+ 0.0,
+ 0.0,
+ 0.0,
+ 1.0,
+ 0.0,
+ 0.0,
+ 0.0,
+ 0.0,
+ 1.0,
+ )
assertThat(identity).containsExactly(*expected)
}
@Test
fun testResetIdentityMatrix() {
- val matrix = doubleArrayOf(
- 5.0,
- 2.0,
- 3.0,
- 4.0,
- 1.0,
- 6.0,
- 7.0,
- 8.0,
- 9.0,
- 10.0,
- 11.0,
- 12.0,
- 13.0,
- 14.0,
- 15.0,
- 16.0,
- )
+ val matrix =
+ doubleArrayOf(
+ 5.0,
+ 2.0,
+ 3.0,
+ 4.0,
+ 1.0,
+ 6.0,
+ 7.0,
+ 8.0,
+ 9.0,
+ 10.0,
+ 11.0,
+ 12.0,
+ 13.0,
+ 14.0,
+ 15.0,
+ 16.0,
+ )
MatrixMathHelper.resetIdentityMatrix(matrix)
- val expected = doubleArrayOf(
- 1.0,
- 0.0,
- 0.0,
- 0.0,
- 0.0,
- 1.0,
- 0.0,
- 0.0,
- 0.0,
- 0.0,
- 1.0,
- 0.0,
- 0.0,
- 0.0,
- 0.0,
- 1.0,
- )
+ val expected =
+ doubleArrayOf(
+ 1.0,
+ 0.0,
+ 0.0,
+ 0.0,
+ 0.0,
+ 1.0,
+ 0.0,
+ 0.0,
+ 0.0,
+ 0.0,
+ 1.0,
+ 0.0,
+ 0.0,
+ 0.0,
+ 0.0,
+ 1.0,
+ )
assertThat(matrix).containsExactly(*expected)
}
@@ -297,113 +303,118 @@ class MatrixMathHelperTest {
val identityMatrix = MatrixMathHelper.createIdentityMatrix()
assertThat(MatrixMathHelper.determinant(identityMatrix)).isEqualTo(1.0)
- val matrix = doubleArrayOf(
- 2.0,
- 0.0,
- 0.0,
- 0.0,
- 0.0,
- 2.0,
- 0.0,
- 0.0,
- 0.0,
- 0.0,
- 2.0,
- 0.0,
- 0.0,
- 0.0,
- 0.0,
- 2.0,
- )
+ val matrix =
+ doubleArrayOf(
+ 2.0,
+ 0.0,
+ 0.0,
+ 0.0,
+ 0.0,
+ 2.0,
+ 0.0,
+ 0.0,
+ 0.0,
+ 0.0,
+ 2.0,
+ 0.0,
+ 0.0,
+ 0.0,
+ 0.0,
+ 2.0,
+ )
assertThat(MatrixMathHelper.determinant(matrix)).isEqualTo(16.0)
}
@Test
fun testInverse() {
- val matrix = doubleArrayOf(
- 2.0,
- 0.0,
- 0.0,
- 0.0,
- 0.0,
- 2.0,
- 0.0,
- 0.0,
- 0.0,
- 0.0,
- 2.0,
- 0.0,
- 0.0,
- 0.0,
- 0.0,
- 2.0,
- )
+ val matrix =
+ doubleArrayOf(
+ 2.0,
+ 0.0,
+ 0.0,
+ 0.0,
+ 0.0,
+ 2.0,
+ 0.0,
+ 0.0,
+ 0.0,
+ 0.0,
+ 2.0,
+ 0.0,
+ 0.0,
+ 0.0,
+ 0.0,
+ 2.0,
+ )
val inverse = MatrixMathHelper.inverse(matrix)
- val expected = doubleArrayOf(
- 0.5,
- 0.0,
- 0.0,
- 0.0,
- 0.0,
- 0.5,
- 0.0,
- 0.0,
- 0.0,
- 0.0,
- 0.5,
- 0.0,
- 0.0,
- 0.0,
- 0.0,
- 0.5,
- )
+ val expected =
+ doubleArrayOf(
+ 0.5,
+ 0.0,
+ 0.0,
+ 0.0,
+ 0.0,
+ 0.5,
+ 0.0,
+ 0.0,
+ 0.0,
+ 0.0,
+ 0.5,
+ 0.0,
+ 0.0,
+ 0.0,
+ 0.0,
+ 0.5,
+ )
assertThat(inverse).containsExactly(*expected)
}
@Test
fun testTranspose() {
- val matrix = doubleArrayOf(
- 1.0,
- 2.0,
- 3.0,
- 4.0,
- 5.0,
- 6.0,
- 7.0,
- 8.0,
- 9.0,
- 10.0,
- 11.0,
- 12.0,
- 13.0,
- 14.0,
- 15.0,
- 16.0,
- )
+ val matrix =
+ doubleArrayOf(
+ 1.0,
+ 2.0,
+ 3.0,
+ 4.0,
+ 5.0,
+ 6.0,
+ 7.0,
+ 8.0,
+ 9.0,
+ 10.0,
+ 11.0,
+ 12.0,
+ 13.0,
+ 14.0,
+ 15.0,
+ 16.0,
+ )
val transposed = MatrixMathHelper.transpose(matrix)
- val expected = doubleArrayOf(
- 1.0,
- 5.0,
- 9.0,
- 13.0,
- 2.0,
- 6.0,
- 10.0,
- 14.0,
- 3.0,
- 7.0,
- 11.0,
- 15.0,
- 4.0,
- 8.0,
- 12.0,
- 16.0,
- )
+ val expected =
+ doubleArrayOf(
+ 1.0,
+ 5.0,
+ 9.0,
+ 13.0,
+ 2.0,
+ 6.0,
+ 10.0,
+ 14.0,
+ 3.0,
+ 7.0,
+ 11.0,
+ 15.0,
+ 4.0,
+ 8.0,
+ 12.0,
+ 16.0,
+ )
assertThat(transposed).containsExactly(*expected)
}
@@ -411,24 +422,25 @@ class MatrixMathHelperTest {
@Test
fun testMultiplyVectorByMatrix() {
val vector = doubleArrayOf(1.0, 2.0, 3.0, 1.0)
- val matrix = doubleArrayOf(
- 2.0,
- 0.0,
- 0.0,
- 0.0,
- 0.0,
- 2.0,
- 0.0,
- 0.0,
- 0.0,
- 0.0,
- 2.0,
- 0.0,
- 0.0,
- 0.0,
- 0.0,
- 1.0,
- )
+ val matrix =
+ doubleArrayOf(
+ 2.0,
+ 0.0,
+ 0.0,
+ 0.0,
+ 0.0,
+ 2.0,
+ 0.0,
+ 0.0,
+ 0.0,
+ 0.0,
+ 2.0,
+ 0.0,
+ 0.0,
+ 0.0,
+ 0.0,
+ 1.0,
+ )
val result = DoubleArray(4)
MatrixMathHelper.multiplyVectorByMatrix(vector, matrix, result)
diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/ReactPropForShadowNodeSpecTest.kt b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/ReactPropForShadowNodeSpecTest.kt
index 6499b9aeabfe..94fb5c28c7e1 100644
--- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/ReactPropForShadowNodeSpecTest.kt
+++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/ReactPropForShadowNodeSpecTest.kt
@@ -59,76 +59,76 @@ class ReactPropForShadowNodeSpecTest {
@Test(expected = RuntimeException::class)
fun testMethodWithWrongNumberOfParams() {
BaseViewManager(
- object : ReactShadowNodeImpl() {
- @Suppress("UNUSED_PARAMETER")
- @ReactProp(name = "prop")
- fun setterWithIncorrectNumberOfArgs(value: Boolean, anotherValue: Int) = Unit
- }
- .javaClass,
- )
+ object : ReactShadowNodeImpl() {
+ @Suppress("UNUSED_PARAMETER")
+ @ReactProp(name = "prop")
+ fun setterWithIncorrectNumberOfArgs(value: Boolean, anotherValue: Int) = Unit
+ }
+ .javaClass,
+ )
.nativeProps
}
@Test(expected = RuntimeException::class)
fun testMethodWithTooFewParams() {
BaseViewManager(
- object : ReactShadowNodeImpl() {
- @ReactProp(name = "prop") fun setterWithNoArgs() = Unit
- }
- .javaClass,
- )
+ object : ReactShadowNodeImpl() {
+ @ReactProp(name = "prop") fun setterWithNoArgs() = Unit
+ }
+ .javaClass,
+ )
.nativeProps
}
@Test(expected = RuntimeException::class)
fun testUnsupportedValueType() {
BaseViewManager(
- object : ReactShadowNodeImpl() {
- @Suppress("UNUSED_PARAMETER")
- @ReactProp(name = "prop")
- fun setterWithMap(value: Map<*, *>) = Unit
- }
- .javaClass,
- )
+ object : ReactShadowNodeImpl() {
+ @Suppress("UNUSED_PARAMETER")
+ @ReactProp(name = "prop")
+ fun setterWithMap(value: Map<*, *>) = Unit
+ }
+ .javaClass,
+ )
.nativeProps
}
@Test(expected = RuntimeException::class)
fun testGroupInvalidNumberOfParams() {
BaseViewManager(
- object : ReactShadowNodeImpl() {
- @Suppress("UNUSED_PARAMETER")
- @ReactPropGroup(names = ["prop1", "prop2"])
- fun setterWithTooManyParams(index: Int, value: Float, boolean: Boolean) = Unit
- }
- .javaClass,
- )
+ object : ReactShadowNodeImpl() {
+ @Suppress("UNUSED_PARAMETER")
+ @ReactPropGroup(names = ["prop1", "prop2"])
+ fun setterWithTooManyParams(index: Int, value: Float, boolean: Boolean) = Unit
+ }
+ .javaClass,
+ )
.nativeProps
}
@Test(expected = RuntimeException::class)
fun testGroupTooFewParams() {
BaseViewManager(
- object : ReactShadowNodeImpl() {
- @Suppress("UNUSED_PARAMETER")
- @ReactPropGroup(names = ["props1", "prop2"])
- fun setterWithTooFewParams(index: Int) = Unit
- }
- .javaClass,
- )
+ object : ReactShadowNodeImpl() {
+ @Suppress("UNUSED_PARAMETER")
+ @ReactPropGroup(names = ["props1", "prop2"])
+ fun setterWithTooFewParams(index: Int) = Unit
+ }
+ .javaClass,
+ )
.nativeProps
}
@Test(expected = RuntimeException::class)
fun testGroupNoIndexParam() {
BaseViewManager(
- object : ReactShadowNodeImpl() {
- @Suppress("UNUSED_PARAMETER")
- @ReactPropGroup(names = ["prop1", "prop2"])
- fun setterWithNoIndexParam(value: Float, boolean: Boolean) = Unit
- }
- .javaClass,
- )
+ object : ReactShadowNodeImpl() {
+ @Suppress("UNUSED_PARAMETER")
+ @ReactPropGroup(names = ["prop1", "prop2"])
+ fun setterWithNoIndexParam(value: Float, boolean: Boolean) = Unit
+ }
+ .javaClass,
+ )
.nativeProps
}
diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/UIManagerModuleConstantsHelperTest.kt b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/UIManagerModuleConstantsHelperTest.kt
index e42f05e32524..8c313263cf55 100644
--- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/UIManagerModuleConstantsHelperTest.kt
+++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/UIManagerModuleConstantsHelperTest.kt
@@ -43,22 +43,24 @@ class UIManagerModuleConstantsHelperTest {
@Suppress("UNCHECKED_CAST")
@Test
fun normalizeEventTypes_withNestedObjects_doesNotLoseThem() {
- val nestedObjects = mutableMapOf(
- "onColorChanged" to
- mutableMapOf(
- "phasedRegistrationNames" to
- mutableMapOf(
- "bubbled" to "onColorChanged",
- "captured" to "onColorChangedCapture",
- ),
- ),
- )
- val result = checkNotNull(
- UIManagerModuleConstantsHelper.normalizeEventTypes(nestedObjects)
- as Map>>,
- ) {
- "returned map was null"
- }
+ val nestedObjects =
+ mutableMapOf(
+ "onColorChanged" to
+ mutableMapOf(
+ "phasedRegistrationNames" to
+ mutableMapOf(
+ "bubbled" to "onColorChanged",
+ "captured" to "onColorChangedCapture",
+ ),
+ ),
+ )
+ val result =
+ checkNotNull(
+ UIManagerModuleConstantsHelper.normalizeEventTypes(nestedObjects)
+ as Map>>,
+ ) {
+ "returned map was null"
+ }
verifyNestedObjects(result, "topColorChanged")
verifyNestedObjects(result, "onColorChanged")
}
diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/UIManagerModuleConstantsTest.kt b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/UIManagerModuleConstantsTest.kt
index 4765577a8075..640708e3a921 100644
--- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/UIManagerModuleConstantsTest.kt
+++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/UIManagerModuleConstantsTest.kt
@@ -42,13 +42,14 @@ class UIManagerModuleConstantsTest {
override fun getExportedCustomBubblingEventTypeConstants(): MutableMap =
mutableMapOf("onTwirl" to TWIRL_BUBBLING_EVENT_MAP)
- override fun getExportedViewConstants(): MutableMap = mutableMapOf(
- "PhotoSizeType" to
- mutableMapOf(
- "Small" to 1,
- "Large" to 2,
- ),
- )
+ override fun getExportedViewConstants(): MutableMap =
+ mutableMapOf(
+ "PhotoSizeType" to
+ mutableMapOf(
+ "Small" to 1,
+ "Large" to 2,
+ ),
+ )
override fun getNativeProps(): MutableMap = mutableMapOf("fooProp" to "number")
}
@@ -201,13 +202,14 @@ class UIManagerModuleConstantsTest {
companion object {
- private val TWIRL_BUBBLING_EVENT_MAP: Map<*, *> = mapOf(
- "phasedRegistrationNames" to
- mapOf(
- "bubbled" to "onTwirl",
- "captured" to "onTwirlCaptured",
- ),
- )
+ private val TWIRL_BUBBLING_EVENT_MAP: Map<*, *> =
+ mapOf(
+ "phasedRegistrationNames" to
+ mapOf(
+ "bubbled" to "onTwirl",
+ "captured" to "onTwirlCaptured",
+ ),
+ )
private val TWIRL_DIRECT_EVENT_MAP: Map = mapOf("registrationName" to "onTwirl")
diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/style/ColorStopTest.kt b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/style/ColorStopTest.kt
index 005b0bf6d4c6..209133c2a048 100644
--- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/style/ColorStopTest.kt
+++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/style/ColorStopTest.kt
@@ -30,10 +30,11 @@ class ColorStopTest {
@Test
fun testBasicColorStops() {
- val colorStops = listOf(
- ColorStop(Color.RED, LengthPercentage(0f, LengthPercentageType.PERCENT)),
- ColorStop(Color.GREEN, LengthPercentage(42f, LengthPercentageType.PERCENT)),
- )
+ val colorStops =
+ listOf(
+ ColorStop(Color.RED, LengthPercentage(0f, LengthPercentageType.PERCENT)),
+ ColorStop(Color.GREEN, LengthPercentage(42f, LengthPercentageType.PERCENT)),
+ )
val processed = ColorStopUtils.getFixedColorStops(colorStops, 60f)
assertThat(processed).hasSize(2)
@@ -45,11 +46,12 @@ class ColorStopTest {
@Test
fun testColorStopsWithFirstAndLastPositionsMissing() {
- val colorStops = listOf(
- ColorStop(Color.RED),
- ColorStop(Color.GREEN, LengthPercentage(30f, LengthPercentageType.PERCENT)),
- ColorStop(Color.BLUE),
- )
+ val colorStops =
+ listOf(
+ ColorStop(Color.RED),
+ ColorStop(Color.GREEN, LengthPercentage(30f, LengthPercentageType.PERCENT)),
+ ColorStop(Color.BLUE),
+ )
val processed = ColorStopUtils.getFixedColorStops(colorStops, 80f)
assertThat(processed).hasSize(3)
@@ -63,13 +65,14 @@ class ColorStopTest {
@Test
fun testColorStopsWithLessPositionValueThanPreviousPosition() {
- val colorStops = listOf(
- ColorStop(Color.RED),
- ColorStop(Color.GREEN, LengthPercentage(30f, LengthPercentageType.PERCENT)),
- ColorStop(Color.BLUE, LengthPercentage(20f, LengthPercentageType.PERCENT)),
- ColorStop(Color.GRAY, LengthPercentage(60f, LengthPercentageType.PERCENT)),
- ColorStop(Color.CYAN, LengthPercentage(50f, LengthPercentageType.PERCENT)),
- )
+ val colorStops =
+ listOf(
+ ColorStop(Color.RED),
+ ColorStop(Color.GREEN, LengthPercentage(30f, LengthPercentageType.PERCENT)),
+ ColorStop(Color.BLUE, LengthPercentage(20f, LengthPercentageType.PERCENT)),
+ ColorStop(Color.GRAY, LengthPercentage(60f, LengthPercentageType.PERCENT)),
+ ColorStop(Color.CYAN, LengthPercentage(50f, LengthPercentageType.PERCENT)),
+ )
val processed = ColorStopUtils.getFixedColorStops(colorStops, 80f)
assertThat(processed).hasSize(5)
@@ -87,12 +90,13 @@ class ColorStopTest {
@Test
fun testColorStopsWithMissingMiddlePositions() {
- val colorStops = listOf(
- ColorStop(Color.RED, LengthPercentage(0f, LengthPercentageType.PERCENT)),
- ColorStop(Color.GREEN),
- ColorStop(Color.BLUE),
- ColorStop(Color.TRANSPARENT, LengthPercentage(100f, LengthPercentageType.PERCENT)),
- )
+ val colorStops =
+ listOf(
+ ColorStop(Color.RED, LengthPercentage(0f, LengthPercentageType.PERCENT)),
+ ColorStop(Color.GREEN),
+ ColorStop(Color.BLUE),
+ ColorStop(Color.TRANSPARENT, LengthPercentage(100f, LengthPercentageType.PERCENT)),
+ )
val processed = ColorStopUtils.getFixedColorStops(colorStops, 100f)
assertThat(processed).hasSize(4)
@@ -108,10 +112,11 @@ class ColorStopTest {
@Test
fun testColorStopsWithMixedUnits() {
- val colorStops = listOf(
- ColorStop(Color.YELLOW, LengthPercentage(100f, LengthPercentageType.POINT)),
- ColorStop(Color.BLUE, LengthPercentage(50f, LengthPercentageType.PERCENT)),
- )
+ val colorStops =
+ listOf(
+ ColorStop(Color.YELLOW, LengthPercentage(100f, LengthPercentageType.POINT)),
+ ColorStop(Color.BLUE, LengthPercentage(50f, LengthPercentageType.PERCENT)),
+ )
val processed200px = ColorStopUtils.getFixedColorStops(colorStops, 200f)
assertThat(processed200px).hasSize(2)
@@ -132,13 +137,14 @@ class ColorStopTest {
@Test
fun testColorStopsWithMultipleTransitionHints() {
- val colorStops = listOf(
- ColorStop(Color.RED, LengthPercentage(0f, LengthPercentageType.PERCENT)),
- ColorStop(null, LengthPercentage(10f, LengthPercentageType.PERCENT)),
- ColorStop(Color.GREEN, LengthPercentage(50f, LengthPercentageType.PERCENT)),
- ColorStop(null, LengthPercentage(85f, LengthPercentageType.PERCENT)),
- ColorStop(Color.BLUE, LengthPercentage(100f, LengthPercentageType.PERCENT)),
- )
+ val colorStops =
+ listOf(
+ ColorStop(Color.RED, LengthPercentage(0f, LengthPercentageType.PERCENT)),
+ ColorStop(null, LengthPercentage(10f, LengthPercentageType.PERCENT)),
+ ColorStop(Color.GREEN, LengthPercentage(50f, LengthPercentageType.PERCENT)),
+ ColorStop(null, LengthPercentage(85f, LengthPercentageType.PERCENT)),
+ ColorStop(Color.BLUE, LengthPercentage(100f, LengthPercentageType.PERCENT)),
+ )
val processed = ColorStopUtils.getFixedColorStops(colorStops, 100f)
assertThat(processed.size).isEqualTo(21)
assertThat(processed.first().color).isEqualTo(Color.RED)
@@ -155,13 +161,14 @@ class ColorStopTest {
@Test
fun testColorStopsWithPositionedStopAdjacentToUnpositionedStop() {
- val colorStops = listOf(
- ColorStop(Color.RED, LengthPercentage(0f, LengthPercentageType.PERCENT)),
- ColorStop(Color.GREEN, LengthPercentage(20f, LengthPercentageType.PERCENT)),
- ColorStop(Color.BLUE),
- ColorStop(Color.YELLOW, LengthPercentage(80f, LengthPercentageType.PERCENT)),
- ColorStop(Color.MAGENTA, LengthPercentage(100f, LengthPercentageType.PERCENT)),
- )
+ val colorStops =
+ listOf(
+ ColorStop(Color.RED, LengthPercentage(0f, LengthPercentageType.PERCENT)),
+ ColorStop(Color.GREEN, LengthPercentage(20f, LengthPercentageType.PERCENT)),
+ ColorStop(Color.BLUE),
+ ColorStop(Color.YELLOW, LengthPercentage(80f, LengthPercentageType.PERCENT)),
+ ColorStop(Color.MAGENTA, LengthPercentage(100f, LengthPercentageType.PERCENT)),
+ )
val processed = ColorStopUtils.getFixedColorStops(colorStops, 100f)
assertThat(processed).hasSize(5)
diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/views/image/ReactImagePropertyTest.kt b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/views/image/ReactImagePropertyTest.kt
index 3674e630de43..c3b78c3f3834 100644
--- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/views/image/ReactImagePropertyTest.kt
+++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/views/image/ReactImagePropertyTest.kt
@@ -162,8 +162,11 @@ class ReactImagePropertyTest {
viewManager.updateProperties(view, buildStyles("borderTopLeftRadius", "25%"))
assertThat(
- BackgroundStyleApplicator.getBorderRadius(view, BorderRadiusProp.BORDER_TOP_LEFT_RADIUS),
- )
+ BackgroundStyleApplicator.getBorderRadius(
+ view,
+ BorderRadiusProp.BORDER_TOP_LEFT_RADIUS,
+ ),
+ )
.isEqualTo(LengthPercentage(25f, LengthPercentageType.PERCENT))
viewManager.updateProperties(view, buildStyles("borderRadius", null))
diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/views/text/ReactTextViewTest.kt b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/views/text/ReactTextViewTest.kt
index 8f07d2159077..a6178e923d67 100644
--- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/views/text/ReactTextViewTest.kt
+++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/views/text/ReactTextViewTest.kt
@@ -157,9 +157,7 @@ class ReactTextViewTest {
)
view.layout(0, 0, width, viewHeight)
- return createBitmap(width, bitmapHeight).also {
- view.drawTextForTest(Canvas(it))
- }
+ return createBitmap(width, bitmapHeight).also { view.drawTextForTest(Canvas(it)) }
}
private fun hasVisiblePixelBelowViewBounds(bitmap: Bitmap): Boolean {
diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/views/text/TextLayoutManagerFontWeightAdjustmentTest.kt b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/views/text/TextLayoutManagerFontWeightAdjustmentTest.kt
index b2df8cfd4c0e..7fadd9b556da 100644
--- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/views/text/TextLayoutManagerFontWeightAdjustmentTest.kt
+++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/views/text/TextLayoutManagerFontWeightAdjustmentTest.kt
@@ -97,14 +97,15 @@ class TextLayoutManagerFontWeightAdjustmentTest {
@Test
fun `custom style applies font variation settings after high level font properties`() {
val paint = mock()
- val span = CustomStyleSpan(
- Typeface.NORMAL,
- 700,
- null,
- "'wght' 450",
- "sans-serif",
- RuntimeEnvironment.getApplication().assets,
- )
+ val span =
+ CustomStyleSpan(
+ Typeface.NORMAL,
+ 700,
+ null,
+ "'wght' 450",
+ "sans-serif",
+ RuntimeEnvironment.getApplication().assets,
+ )
span.updateMeasureState(paint)
diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/views/textinput/ReactTextInputPropertyTest.kt b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/views/textinput/ReactTextInputPropertyTest.kt
index 4a6f6cc7560d..53a023f3c3de 100644
--- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/views/textinput/ReactTextInputPropertyTest.kt
+++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/views/textinput/ReactTextInputPropertyTest.kt
@@ -244,21 +244,22 @@ class ReactTextInputPropertyTest {
return
}
- val expectedHints = listOf(
- "2fa-app-otp" to HintConstants.AUTOFILL_HINT_2FA_APP_OTP,
- "email-otp" to HintConstants.AUTOFILL_HINT_EMAIL_OTP,
- "flight-confirmation-code" to HintConstants.AUTOFILL_HINT_FLIGHT_CONFIRMATION_CODE,
- "flight-number" to HintConstants.AUTOFILL_HINT_FLIGHT_NUMBER,
- "gift-card-number" to HintConstants.AUTOFILL_HINT_GIFT_CARD_NUMBER,
- "gift-card-pin" to HintConstants.AUTOFILL_HINT_GIFT_CARD_PIN,
- "loyalty-account-number" to HintConstants.AUTOFILL_HINT_LOYALTY_ACCOUNT_NUMBER,
- "postal-address-dependent-locality" to
- HintConstants.AUTOFILL_HINT_POSTAL_ADDRESS_DEPENDENT_LOCALITY,
- "postal-address-unit" to HintConstants.AUTOFILL_HINT_POSTAL_ADDRESS_APT_NUMBER,
- "promo-code" to HintConstants.AUTOFILL_HINT_PROMO_CODE,
- "upi-vpa" to HintConstants.AUTOFILL_HINT_UPI_VPA,
- "wifi-password" to HintConstants.AUTOFILL_HINT_WIFI_PASSWORD,
- )
+ val expectedHints =
+ listOf(
+ "2fa-app-otp" to HintConstants.AUTOFILL_HINT_2FA_APP_OTP,
+ "email-otp" to HintConstants.AUTOFILL_HINT_EMAIL_OTP,
+ "flight-confirmation-code" to HintConstants.AUTOFILL_HINT_FLIGHT_CONFIRMATION_CODE,
+ "flight-number" to HintConstants.AUTOFILL_HINT_FLIGHT_NUMBER,
+ "gift-card-number" to HintConstants.AUTOFILL_HINT_GIFT_CARD_NUMBER,
+ "gift-card-pin" to HintConstants.AUTOFILL_HINT_GIFT_CARD_PIN,
+ "loyalty-account-number" to HintConstants.AUTOFILL_HINT_LOYALTY_ACCOUNT_NUMBER,
+ "postal-address-dependent-locality" to
+ HintConstants.AUTOFILL_HINT_POSTAL_ADDRESS_DEPENDENT_LOCALITY,
+ "postal-address-unit" to HintConstants.AUTOFILL_HINT_POSTAL_ADDRESS_APT_NUMBER,
+ "promo-code" to HintConstants.AUTOFILL_HINT_PROMO_CODE,
+ "upi-vpa" to HintConstants.AUTOFILL_HINT_UPI_VPA,
+ "wifi-password" to HintConstants.AUTOFILL_HINT_WIFI_PASSWORD,
+ )
expectedHints.forEach { (autoComplete, expectedHint) ->
manager.updateProperties(view, buildStyles("autoComplete", autoComplete))
@@ -458,16 +459,16 @@ class ReactTextInputPropertyTest {
manager.updateProperties(view, buildStyles("textAlign", "start"))
assertThat(
- view.gravity and
- (Gravity.HORIZONTAL_GRAVITY_MASK or Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK),
- )
+ view.gravity and
+ (Gravity.HORIZONTAL_GRAVITY_MASK or Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK),
+ )
.isEqualTo(Gravity.START)
manager.updateProperties(view, buildStyles("textAlign", "end"))
assertThat(
- view.gravity and
- (Gravity.HORIZONTAL_GRAVITY_MASK or Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK),
- )
+ view.gravity and
+ (Gravity.HORIZONTAL_GRAVITY_MASK or Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK),
+ )
.isEqualTo(Gravity.END)
manager.updateProperties(view, buildStyles("textAlign", null))
@@ -571,22 +572,24 @@ class ReactTextInputPropertyTest {
"'wght' 550",
),
)
- val matchingSpan = CustomStyleSpan(
- 0,
- 400,
- view.fontFeatureSettings,
- "'wght' 550",
- "sans-serif",
- themedContext.assets,
- )
- val differingSpan = CustomStyleSpan(
- 0,
- 400,
- view.fontFeatureSettings,
- "'wght' 700",
- "sans-serif",
- themedContext.assets,
- )
+ val matchingSpan =
+ CustomStyleSpan(
+ 0,
+ 400,
+ view.fontFeatureSettings,
+ "'wght' 550",
+ "sans-serif",
+ themedContext.assets,
+ )
+ val differingSpan =
+ CustomStyleSpan(
+ 0,
+ 400,
+ view.fontFeatureSettings,
+ "'wght' 700",
+ "sans-serif",
+ themedContext.assets,
+ )
val textUpdate =
SpannableString("matching different").apply {
setSpan(matchingSpan, 0, 8, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
diff --git a/packages/react-native/gradle/libs.versions.toml b/packages/react-native/gradle/libs.versions.toml
index 0bba9087d8dc..0c84940db453 100644
--- a/packages/react-native/gradle/libs.versions.toml
+++ b/packages/react-native/gradle/libs.versions.toml
@@ -31,7 +31,6 @@ jsc-android = "2026004.0.1"
jsr305 = "3.0.2"
junit = "4.13.2"
kotlin = "2.2.0"
-ktfmt = "0.22.0"
mockito = "3.12.4"
mockito-kotlin = "3.2.0"
nexus-publish = "2.0.0"
@@ -97,7 +96,6 @@ thoughtworks = {module = "com.thoughtworks.xstream:xstream", version.ref = "xstr
android-application = { id = "com.android.application", version.ref = "agp" }
android-library = { id = "com.android.library", version.ref = "agp" }
download = { id = "de.undercouch.download", version.ref = "download" }
-ktfmt = { id = "com.ncorti.ktfmt.gradle", version.ref = "ktfmt" }
nexus-publish = { id = "io.github.gradle-nexus.publish-plugin", version.ref = "nexus-publish" }
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
binary-compatibility-validator = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version.ref = "binary-compatibility-validator" }
diff --git a/packages/rn-tester/android/app/benchmark/build.gradle.kts b/packages/rn-tester/android/app/benchmark/build.gradle.kts
index cb04bececdc7..4dd893d668b8 100644
--- a/packages/rn-tester/android/app/benchmark/build.gradle.kts
+++ b/packages/rn-tester/android/app/benchmark/build.gradle.kts
@@ -5,9 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/
-plugins {
- alias(libs.plugins.android.test)
-}
+plugins { alias(libs.plugins.android.test) }
android {
namespace = "com.example.benchmark"
diff --git a/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterActivity.kt b/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterActivity.kt
index 776d86a6d869..0ae099a8f379 100644
--- a/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterActivity.kt
+++ b/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterActivity.kt
@@ -67,11 +67,12 @@ internal class RNTesterActivity : ReactActivity() {
maybeUpdateBackgroundColor()
reactDelegate?.reactHost?.let { reactHost ->
- val devMenuConfiguration = DevMenuConfiguration(
- devMenuEnabled = true,
- shakeGestureEnabled = true,
- keyboardShortcutsEnabled = true,
- )
+ val devMenuConfiguration =
+ DevMenuConfiguration(
+ devMenuEnabled = true,
+ shakeGestureEnabled = true,
+ keyboardShortcutsEnabled = true,
+ )
reactHost.setDevMenuConfiguration(devMenuConfiguration)
}
diff --git a/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.kt b/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.kt
index d7d574c21527..7e8c9f7798c6 100644
--- a/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.kt
+++ b/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.kt
@@ -81,19 +81,21 @@ internal class RNTesterApplication : Application(), ReactApplication {
object : ReactPackage, ViewManagerOnDemandReactPackage {
override fun getViewManagerNames(
reactContext: ReactApplicationContext,
- ) = listOf(
- "RNTMyNativeView",
- "RNTMyLegacyNativeView",
- "RNTReportFullyDrawnView",
- )
+ ) =
+ listOf(
+ "RNTMyNativeView",
+ "RNTMyLegacyNativeView",
+ "RNTReportFullyDrawnView",
+ )
override fun createViewManagers(
reactContext: ReactApplicationContext,
- ): List> = listOf(
- MyNativeViewManager(),
- MyLegacyViewManager(reactContext),
- ReportFullyDrawnViewManager(),
- )
+ ): List> =
+ listOf(
+ MyNativeViewManager(),
+ MyLegacyViewManager(reactContext),
+ ReportFullyDrawnViewManager(),
+ )
override fun createViewManager(
reactContext: ReactApplicationContext,
diff --git a/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/component/MyLegacyViewManager.kt b/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/component/MyLegacyViewManager.kt
index 95297c4555ae..f65f7a45b35e 100644
--- a/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/component/MyLegacyViewManager.kt
+++ b/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/component/MyLegacyViewManager.kt
@@ -85,11 +85,12 @@ internal class MyLegacyViewManager(reactContext: ReactApplicationContext) :
}
}
- override fun getCommandsMap(): Map = mapOf(
- "changeBackgroundColor" to COMMAND_CHANGE_BACKGROUND_COLOR,
- "addOverlays" to COMMAND_ADD_OVERLAYS,
- "removeOverlays" to COMMAND_REMOVE_OVERLAYS,
- )
+ override fun getCommandsMap(): Map =
+ mapOf(
+ "changeBackgroundColor" to COMMAND_CHANGE_BACKGROUND_COLOR,
+ "addOverlays" to COMMAND_ADD_OVERLAYS,
+ "removeOverlays" to COMMAND_REMOVE_OVERLAYS,
+ )
companion object {
const val REACT_CLASS = "RNTMyLegacyNativeView"
diff --git a/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/component/MyNativeViewManager.kt b/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/component/MyNativeViewManager.kt
index e730282e5c4c..731c0b03854a 100644
--- a/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/component/MyNativeViewManager.kt
+++ b/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/component/MyNativeViewManager.kt
@@ -69,14 +69,15 @@ internal class MyNativeViewManager :
view.setBackgroundColor(backgroundColor)
}
- override fun getExportedCustomBubblingEventTypeConstants(): Map = mapOf(
- "topIntArrayChanged" to
- mapOf(
- "phasedRegistrationNames" to
- mapOf(
- "bubbled" to "onIntArrayChanged",
- "captured" to "onIntArrayChangedCapture",
- ),
- ),
- )
+ override fun getExportedCustomBubblingEventTypeConstants(): Map =
+ mapOf(
+ "topIntArrayChanged" to
+ mapOf(
+ "phasedRegistrationNames" to
+ mapOf(
+ "bubbled" to "onIntArrayChanged",
+ "captured" to "onIntArrayChangedCapture",
+ ),
+ ),
+ )
}
diff --git a/private/react-native-fantom/build.gradle.kts b/private/react-native-fantom/build.gradle.kts
index 69c1a037fdae..d253b8f14f99 100644
--- a/private/react-native-fantom/build.gradle.kts
+++ b/private/react-native-fantom/build.gradle.kts
@@ -63,11 +63,12 @@ val testerBuildOutputFileTree =
fileTree(testerBuildDir.toString())
.include("**/*.cmake", "**/*.marks", "**/compiler_depends.ts", "**/Makefile", "**/link.txt")
-val createNativeDepsDirectories by tasks.registering {
- downloadsDir.mkdirs()
- thirdParty.mkdirs()
- reportsDir.mkdirs()
-}
+val createNativeDepsDirectories by
+ tasks.registering {
+ downloadsDir.mkdirs()
+ thirdParty.mkdirs()
+ reportsDir.mkdirs()
+ }
val downloadFollyDest = File(reactAndroidDownloadsDir, "folly-${FOLLY_VERSION}.tar.gz")
@@ -143,36 +144,40 @@ val prepareRNCodegen by
into(codegenOutDir)
}
-val enableHermesBuild by tasks.registering {
- project(":packages:react-native:ReactAndroid:hermes-engine") {
- tasks.configureEach { enabled = true }
- }
-}
+val enableHermesBuild by
+ tasks.registering {
+ project(":packages:react-native:ReactAndroid:hermes-engine") {
+ tasks.configureEach { enabled = true }
+ }
+ }
-val prepareHermesDependencies by tasks.registering {
- dependsOn(
- enableHermesBuild,
- ":packages:react-native:ReactAndroid:hermes-engine:buildHermesLibWithDebugger",
- ":packages:react-native:ReactAndroid:hermes-engine:prepareHeadersForPrefabWithDebugger",
- )
-}
+val prepareHermesDependencies by
+ tasks.registering {
+ dependsOn(
+ enableHermesBuild,
+ ":packages:react-native:ReactAndroid:hermes-engine:buildHermesLibWithDebugger",
+ ":packages:react-native:ReactAndroid:hermes-engine:prepareHeadersForPrefabWithDebugger",
+ )
+ }
-val prepareNative3pDependencies by tasks.registering {
- dependsOn(
- prepareGflags,
- prepareNlohmannJson,
- prepareFolly,
- ":packages:react-native:ReactAndroid:prepareBoost",
- ":packages:react-native:ReactAndroid:prepareDoubleConversion",
- ":packages:react-native:ReactAndroid:prepareFastFloat",
- ":packages:react-native:ReactAndroid:prepareFmt",
- ":packages:react-native:ReactAndroid:prepareGlog",
- )
-}
+val prepareNative3pDependencies by
+ tasks.registering {
+ dependsOn(
+ prepareGflags,
+ prepareNlohmannJson,
+ prepareFolly,
+ ":packages:react-native:ReactAndroid:prepareBoost",
+ ":packages:react-native:ReactAndroid:prepareDoubleConversion",
+ ":packages:react-native:ReactAndroid:prepareFastFloat",
+ ":packages:react-native:ReactAndroid:prepareFmt",
+ ":packages:react-native:ReactAndroid:prepareGlog",
+ )
+ }
-val prepareAllDependencies by tasks.registering {
- dependsOn(prepareRNCodegen, prepareHermesDependencies, prepareNative3pDependencies)
-}
+val prepareAllDependencies by
+ tasks.registering {
+ dependsOn(prepareRNCodegen, prepareHermesDependencies, prepareNative3pDependencies)
+ }
val configureFantomTester by
tasks.registering(CustomExecTask::class) {
@@ -180,23 +185,24 @@ val configureFantomTester by
workingDir(testerDir)
inputs.dir(testerDir)
outputs.files(testerBuildOutputFileTree)
- val cmdArgs = mutableListOf(
- cmakeBinaryPath,
- // Suppress all warnings as this is the Hermes build and we can't fix them.
- "--log-level=ERROR",
- "-S",
- ".",
- "-B",
- testerBuildDir.toString(),
- "-DCMAKE_BUILD_TYPE=Debug",
- "-DFANTOM_CODEGEN_DIR=$buildDir/codegen",
- "-DFANTOM_THIRD_PARTY_DIR=$buildDir/third-party",
- "-DREACT_ANDROID_DIR=$reactAndroidDir",
- "-DREACT_COMMON_DIR=$reactNativeDir/ReactCommon",
- "-DREACT_CXX_PLATFORM_DIR=$reactNativeDir/ReactCxxPlatform",
- "-DREACT_THIRD_PARTY_NDK_DIR=$reactAndroidBuildDir/third-party-ndk",
- "-DRN_ENABLE_DEBUG_STRING_CONVERTIBLE=ON",
- )
+ val cmdArgs =
+ mutableListOf(
+ cmakeBinaryPath,
+ // Suppress all warnings as this is the Hermes build and we can't fix them.
+ "--log-level=ERROR",
+ "-S",
+ ".",
+ "-B",
+ testerBuildDir.toString(),
+ "-DCMAKE_BUILD_TYPE=Debug",
+ "-DFANTOM_CODEGEN_DIR=$buildDir/codegen",
+ "-DFANTOM_THIRD_PARTY_DIR=$buildDir/third-party",
+ "-DREACT_ANDROID_DIR=$reactAndroidDir",
+ "-DREACT_COMMON_DIR=$reactNativeDir/ReactCommon",
+ "-DREACT_CXX_PLATFORM_DIR=$reactNativeDir/ReactCxxPlatform",
+ "-DREACT_THIRD_PARTY_NDK_DIR=$reactAndroidBuildDir/third-party-ndk",
+ "-DRN_ENABLE_DEBUG_STRING_CONVERTIBLE=ON",
+ )
cmdArgs.add("-DHERMES_V1_ENABLED=1")
diff --git a/scripts/clang-format.js b/scripts/clang-format.js
index abdf8c81df45..9b7181374b19 100644
--- a/scripts/clang-format.js
+++ b/scripts/clang-format.js
@@ -10,18 +10,49 @@
'use strict';
-const dotslash = require('fb-dotslash');
const {spawnSync} = require('node:child_process');
const fs = require('node:fs');
const path = require('node:path');
const {globSync} = require('tinyglobby');
const REPO_ROOT = path.resolve(__dirname, '..');
-const CLANG_FORMAT = path.join(__dirname, 'clang-format');
+const OSS_CLANG_FORMAT_DOTSLASH = path.join(__dirname, 'clang-format');
const GENERATED_MARKER = Buffer.from('@' + 'generated');
+const IGNORE_FILE = path.join(REPO_ROOT, '.clang-format-ignore');
const MAX_HEADER_BYTES = 4096;
const MAX_FILES_PER_PROCESS = 30;
+const SOURCE_GLOB = '**/*.{c,cc,cpp,cu,cuh,cxx,h,hh,hpp,hxx,m,mm,proto,tcc}';
+
+function findClangFormat() {
+ if (process.env.CLANG_FORMAT != null && process.env.CLANG_FORMAT !== '') {
+ return {command: process.env.CLANG_FORMAT, prefixArguments: []};
+ }
+
+ try {
+ const metaClangFormat = require('./clang-format.fb').findMetaClangFormat();
+ if (metaClangFormat != null) {
+ return metaClangFormat;
+ }
+ } catch (error) {
+ if (
+ error == null ||
+ error.code !== 'MODULE_NOT_FOUND' ||
+ !String(error.message).includes("'./clang-format.fb'")
+ ) {
+ throw error;
+ }
+ }
+
+ return {
+ command:
+ process.env.DOTSLASH != null && process.env.DOTSLASH !== ''
+ ? process.env.DOTSLASH
+ : require('fb-dotslash'),
+ prefixArguments: [OSS_CLANG_FORMAT_DOTSLASH],
+ };
+}
+
/** @param {string} file */
function isGenerated(file) {
let fd;
@@ -41,16 +72,33 @@ function isGenerated(file) {
}
function main() {
+ const arguments_ = process.argv.slice(2);
+ const check = arguments_.includes('--check');
+ const clangFormat = findClangFormat();
+ const positionalArguments = arguments_.filter(
+ argument => argument !== '--check',
+ );
+ const ignore = fs
+ .readFileSync(IGNORE_FILE, 'utf8')
+ .split('\n')
+ .map(line => line.trim())
+ .filter(line => line !== '' && !line.startsWith('#'));
+ const discoveredFiles = globSync(SOURCE_GLOB, {cwd: REPO_ROOT, ignore});
const files =
- process.argv.length > 2
- ? process.argv.slice(2)
- : globSync('*/**/*.{h,cpp,m,mm}', {cwd: REPO_ROOT});
+ positionalArguments.length > 0
+ ? positionalArguments.filter(file => discoveredFiles.includes(file))
+ : discoveredFiles;
const sourceFiles = files.filter(file => !isGenerated(file));
+ let exitStatus = 0;
for (let i = 0; i < sourceFiles.length; i += MAX_FILES_PER_PROCESS) {
+ const formatterArguments = [
+ ...(check ? ['--dry-run', '--Werror'] : ['-i']),
+ ...sourceFiles.slice(i, i + MAX_FILES_PER_PROCESS),
+ ];
const result = spawnSync(
- dotslash,
- [CLANG_FORMAT, '-i', ...sourceFiles.slice(i, i + MAX_FILES_PER_PROCESS)],
+ clangFormat.command,
+ [...clangFormat.prefixArguments, ...formatterArguments],
{
cwd: REPO_ROOT,
stdio: 'inherit',
@@ -61,13 +109,13 @@ function main() {
throw result.error;
}
if (result.signal != null) {
- process.kill(process.pid, result.signal);
- return;
+ throw new Error(`clang-format was terminated by ${result.signal}`);
}
if (result.status !== 0) {
- process.exit(result.status ?? 1);
+ exitStatus = result.status ?? 1;
}
}
+ process.exitCode = exitStatus;
}
main();
diff --git a/scripts/format-java.js b/scripts/format-java.js
new file mode 100644
index 000000000000..d991b6b38922
--- /dev/null
+++ b/scripts/format-java.js
@@ -0,0 +1,106 @@
+/**
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ *
+ * @noflow
+ * @format
+ */
+
+'use strict';
+
+const {findJava, warnMissingJava} = require('./format-utils');
+const {spawnSync} = require('node:child_process');
+const fs = require('node:fs');
+const path = require('node:path');
+const {globSync} = require('tinyglobby');
+
+const REPO_ROOT = path.resolve(__dirname, '..');
+const GENERATED_MARKER = Buffer.from('@' + 'generated');
+const MINIMUM_JAVA_VERSION = 17;
+const MAX_FILES_PER_PROCESS = 30;
+const MAX_HEADER_BYTES = 4096;
+const IGNORE = [
+ '**/Pods/**',
+ '**/build/**',
+ '**/com/facebook/yoga/**',
+ '**/node_modules/**',
+];
+
+function isGenerated(file) {
+ let fd;
+ try {
+ fd = fs.openSync(path.resolve(REPO_ROOT, file), 'r');
+ const header = Buffer.alloc(MAX_HEADER_BYTES);
+ const bytesRead = fs.readSync(fd, header, 0, header.length, 0);
+ return header.subarray(0, bytesRead).includes(GENERATED_MARKER);
+ } catch (error) {
+ const message = error instanceof Error ? error.message : String(error);
+ throw new Error(`Unable to inspect ${file}: ${message}`, {cause: error});
+ } finally {
+ if (fd != null) {
+ fs.closeSync(fd);
+ }
+ }
+}
+
+function findGoogleJavaFormatJar() {
+ const packageRoot = path.dirname(
+ require.resolve('google-java-format/package.json'),
+ );
+ const jars = fs
+ .readdirSync(path.join(packageRoot, 'lib'))
+ .filter(file => file.endsWith('-all-deps.jar'));
+ if (jars.length !== 1) {
+ throw new Error(
+ `Expected one google-java-format jar, found ${jars.length}.`,
+ );
+ }
+ return path.join(packageRoot, 'lib', jars[0]);
+}
+
+function main() {
+ const check = process.argv[2] === '--check';
+ const java = findJava(MINIMUM_JAVA_VERSION);
+ if (java == null) {
+ warnMissingJava('Java');
+ return;
+ }
+ const googleJavaFormatJar = findGoogleJavaFormatJar();
+ const files = globSync('**/*.java', {cwd: REPO_ROOT, ignore: IGNORE}).filter(
+ file => !isGenerated(file),
+ );
+
+ let exitStatus = 0;
+ for (let i = 0; i < files.length; i += MAX_FILES_PER_PROCESS) {
+ const result = spawnSync(
+ java,
+ [
+ '--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED',
+ '--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED',
+ '--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED',
+ '--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED',
+ '--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED',
+ '--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED',
+ '-jar',
+ googleJavaFormatJar,
+ ...(check ? ['--dry-run', '--set-exit-if-changed'] : ['--replace']),
+ ...files.slice(i, i + MAX_FILES_PER_PROCESS),
+ ],
+ {cwd: REPO_ROOT, stdio: 'inherit'},
+ );
+ if (result.error != null) {
+ throw result.error;
+ }
+ if (result.signal != null) {
+ throw new Error(`google-java-format was terminated by ${result.signal}`);
+ }
+ if (result.status !== 0) {
+ exitStatus = result.status ?? 1;
+ }
+ }
+ process.exitCode = exitStatus;
+}
+
+main();
diff --git a/scripts/format-kotlin.js b/scripts/format-kotlin.js
new file mode 100644
index 000000000000..9879f9bcbf97
--- /dev/null
+++ b/scripts/format-kotlin.js
@@ -0,0 +1,81 @@
+/**
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ *
+ * @noflow
+ * @format
+ */
+
+'use strict';
+
+const {findJava, warnMissingJava} = require('./format-utils');
+const {spawnSync} = require('node:child_process');
+const fs = require('node:fs');
+const path = require('node:path');
+const {globSync} = require('tinyglobby');
+
+const REPO_ROOT = path.resolve(__dirname, '..');
+const KTFMT_JAR = require.resolve('ktfmt/lib/ktfmt.jar');
+const GENERATED_MARKER = Buffer.from('@' + 'generated');
+const MINIMUM_JAVA_VERSION = 17;
+const MAX_FILES_PER_PROCESS = 100;
+const MAX_HEADER_BYTES = 4096;
+const IGNORE = [
+ '**/build/**',
+ '**/com/facebook/yoga/**',
+ '**/hermes-engine/**',
+ '**/internal/featureflags/**',
+ '**/node_modules/**',
+ '**/systeminfo/ReactNativeVersion.kt',
+];
+
+function isGenerated(file) {
+ const fd = fs.openSync(path.resolve(REPO_ROOT, file), 'r');
+ try {
+ const header = Buffer.alloc(MAX_HEADER_BYTES);
+ const bytesRead = fs.readSync(fd, header, 0, header.length, 0);
+ return header.subarray(0, bytesRead).includes(GENERATED_MARKER);
+ } finally {
+ fs.closeSync(fd);
+ }
+}
+
+function main() {
+ const check = process.argv[2] === '--check';
+ const java = findJava(MINIMUM_JAVA_VERSION);
+ if (java == null) {
+ warnMissingJava('Kotlin');
+ return;
+ }
+ const files = globSync('**/*.{kt,kts}', {
+ cwd: REPO_ROOT,
+ ignore: IGNORE,
+ }).filter(file => !isGenerated(file));
+ for (let i = 0; i < files.length; i += MAX_FILES_PER_PROCESS) {
+ const result = spawnSync(
+ java,
+ [
+ '-jar',
+ KTFMT_JAR,
+ '--do-not-remove-unused-imports',
+ ...(check ? ['--dry-run', '--set-exit-if-changed'] : []),
+ ...files.slice(i, i + MAX_FILES_PER_PROCESS),
+ ],
+ {cwd: REPO_ROOT, stdio: 'inherit'},
+ );
+ if (result.error != null) {
+ throw result.error;
+ }
+ if (result.signal != null) {
+ process.kill(process.pid, result.signal);
+ return;
+ }
+ if (result.status !== 0) {
+ process.exit(result.status ?? 1);
+ }
+ }
+}
+
+main();
diff --git a/scripts/format-python.js b/scripts/format-python.js
new file mode 100644
index 000000000000..ba7dcb745ca9
--- /dev/null
+++ b/scripts/format-python.js
@@ -0,0 +1,205 @@
+/**
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ *
+ * @noflow
+ * @format
+ */
+
+'use strict';
+
+const {IS_META_CHECKOUT, findMetaTool} = require('./format-utils');
+const {spawnSync} = require('node:child_process');
+const fs = require('node:fs');
+const path = require('node:path');
+
+const REPO_ROOT = path.resolve(__dirname, '..');
+const RUFF_VERSION = '0.14.0';
+const RUFF_ROOT = path.join(
+ REPO_ROOT,
+ 'node_modules',
+ '.cache',
+ 'react-native-format',
+ `ruff-${RUFF_VERSION}`,
+);
+
+function run(command, args, options = {}) {
+ const environment = options.env ?? process.env;
+ const result = spawnSync(command, args, {
+ cwd: REPO_ROOT,
+ stdio: options.quiet === true ? 'ignore' : 'inherit',
+ ...options,
+ env: {...environment, PWD: REPO_ROOT},
+ });
+ if (result.error != null) {
+ if (options.quiet !== true) {
+ console.error(result.error.message);
+ }
+ return {status: 1};
+ }
+ if (result.signal != null) {
+ process.kill(process.pid, result.signal);
+ return {status: 1};
+ }
+ return {status: result.status ?? 1};
+}
+
+function findPython() {
+ const candidates =
+ process.platform === 'win32'
+ ? [
+ ['py', ['-3']],
+ ['python', []],
+ ]
+ : [
+ ['python3', []],
+ ['python', []],
+ ];
+
+ for (const [command, prefixArguments] of candidates) {
+ if (
+ run(
+ command,
+ [
+ ...prefixArguments,
+ '-c',
+ 'import sys; raise SystemExit(sys.version_info.major != 3)',
+ ],
+ {quiet: true},
+ ).status === 0
+ ) {
+ return {command, prefixArguments};
+ }
+ }
+ return null;
+}
+
+function warnMissingPython() {
+ console.warn(
+ 'warning: Skipping Python formatting because Python 3 with pip was not found.\n' +
+ 'Please install Python 3 with pip and make sure `python3` (`py -3` on Windows) and pip are available in your PATH.',
+ );
+}
+
+function warnMissingMetaRuff() {
+ console.warn(
+ 'warning: Skipping Python formatting because the Meta-managed Ruff tool could not run.\n' +
+ 'From the fbsource root, run `tools/third-party/ruff/ruff --version`. ' +
+ 'If that fails, repair your Meta DotSlash setup.',
+ );
+}
+
+function runRuff(command, prefixArguments, check) {
+ if (
+ run(command, [...prefixArguments, '--version'], {quiet: true}).status !== 0
+ ) {
+ return false;
+ }
+ const format = run(command, [
+ ...prefixArguments,
+ 'format',
+ ...(check ? ['--check'] : []),
+ '.',
+ ]);
+ process.exit(format.status);
+}
+
+function main() {
+ const check = process.argv[2] === '--check';
+ if (process.env.RUFF != null) {
+ if (!runRuff(process.env.RUFF, [], check)) {
+ if (IS_META_CHECKOUT) {
+ warnMissingMetaRuff();
+ } else {
+ console.warn(
+ 'warning: Skipping Python formatting because the configured Ruff command could not run.\n' +
+ 'Please install Ruff and set RUFF=/path/to/ruff, or unset RUFF to use automatic installation.',
+ );
+ }
+ return;
+ }
+ }
+
+ const metaRuff = findMetaTool('tools', 'third-party', 'ruff', 'ruff');
+ if (metaRuff != null) {
+ if (!runRuff(metaRuff.command, metaRuff.prefixArguments, check)) {
+ warnMissingMetaRuff();
+ }
+ return;
+ }
+ if (IS_META_CHECKOUT) {
+ warnMissingMetaRuff();
+ return;
+ }
+
+ const python = findPython();
+ if (python == null) {
+ warnMissingPython();
+ return;
+ }
+ const pythonPath = [RUFF_ROOT, process.env.PYTHONPATH]
+ .filter(Boolean)
+ .join(path.delimiter);
+ const environment = {...process.env, PYTHONPATH: pythonPath};
+
+ if (
+ run(python.command, [...python.prefixArguments, '-c', 'import ruff'], {
+ env: environment,
+ quiet: true,
+ }).status !== 0
+ ) {
+ if (
+ run(
+ python.command,
+ [...python.prefixArguments, '-m', 'pip', '--version'],
+ {quiet: true},
+ ).status !== 0
+ ) {
+ warnMissingPython();
+ return;
+ }
+ try {
+ fs.mkdirSync(RUFF_ROOT, {recursive: true});
+ } catch (error) {
+ console.warn(
+ `warning: Skipping Python formatting because the Ruff cache could not be created: ${String(error)}`,
+ );
+ return;
+ }
+ const install = run(python.command, [
+ ...python.prefixArguments,
+ '-m',
+ 'pip',
+ 'install',
+ '--disable-pip-version-check',
+ '--only-binary=:all:',
+ `--target=${RUFF_ROOT}`,
+ `ruff==${RUFF_VERSION}`,
+ ]);
+ if (install.status !== 0) {
+ console.warn(
+ `warning: Skipping Python formatting because Ruff ${RUFF_VERSION} could not be installed.\n` +
+ 'Please check your network connection, or install Ruff and set RUFF=/path/to/ruff.',
+ );
+ return;
+ }
+ }
+
+ const format = run(
+ python.command,
+ [
+ ...python.prefixArguments,
+ '-m',
+ 'ruff',
+ 'format',
+ ...(check ? ['--check'] : []),
+ '.',
+ ],
+ {env: environment},
+ );
+ process.exit(format.status);
+}
+
+main();
diff --git a/scripts/format-swift.js b/scripts/format-swift.js
new file mode 100644
index 000000000000..74885bd7d79d
--- /dev/null
+++ b/scripts/format-swift.js
@@ -0,0 +1,146 @@
+/**
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ *
+ * @noflow
+ * @format
+ */
+
+'use strict';
+
+const {
+ IS_META_CHECKOUT,
+ commandVersion,
+ findMetaTool,
+} = require('./format-utils');
+const {spawnSync} = require('node:child_process');
+const fs = require('node:fs');
+const path = require('node:path');
+const {globSync} = require('tinyglobby');
+
+const REPO_ROOT = path.resolve(__dirname, '..');
+const CONFIG = path.join(REPO_ROOT, '.swift-format');
+const GENERATED_MARKER = Buffer.from('@' + 'generated');
+const MINIMUM_SWIFT_FORMAT_MAJOR = 6;
+const MINIMUM_SWIFT_FORMAT_MINOR = 3;
+const MAX_FILES_PER_PROCESS = 100;
+const MAX_HEADER_BYTES = 4096;
+const IGNORE = ['**/Pods/**', '**/build/**', '**/node_modules/**'];
+
+function isGenerated(file) {
+ let fd;
+ try {
+ fd = fs.openSync(path.resolve(REPO_ROOT, file), 'r');
+ const header = Buffer.alloc(MAX_HEADER_BYTES);
+ const bytesRead = fs.readSync(fd, header, 0, header.length, 0);
+ return header.subarray(0, bytesRead).includes(GENERATED_MARKER);
+ } catch (error) {
+ const message = error instanceof Error ? error.message : String(error);
+ throw new Error(`Unable to inspect ${file}: ${message}`, {cause: error});
+ } finally {
+ if (fd != null) {
+ fs.closeSync(fd);
+ }
+ }
+}
+
+function parseSwiftFormatVersion(output) {
+ const version =
+ /swift-format(?: version)?[:\s]+(\d+)\.(\d+)/i.exec(output) ??
+ /Swift version\s+(\d+)\.(\d+)/i.exec(output) ??
+ /^\s*(\d+)\.(\d+)/.exec(output);
+ if (version == null) {
+ return null;
+ }
+ const reportedMajor = Number(version[1]);
+ return reportedMajor >= 100
+ ? [Math.floor(reportedMajor / 100), reportedMajor % 100]
+ : [reportedMajor, Number(version[2])];
+}
+
+function findSwiftFormat() {
+ const candidates = [];
+ if (process.env.SWIFT_FORMAT != null && process.env.SWIFT_FORMAT !== '') {
+ candidates.push([process.env.SWIFT_FORMAT, []]);
+ } else {
+ const metaSwiftFormat = findMetaTool(
+ 'tools',
+ 'lint',
+ 'swift-format',
+ 'swift-format',
+ );
+ if (metaSwiftFormat != null) {
+ candidates.push([
+ metaSwiftFormat.command,
+ metaSwiftFormat.prefixArguments,
+ ]);
+ }
+ candidates.push(['swift-format', []], ['swift', ['format']]);
+ }
+ for (const [command, prefixArguments] of candidates) {
+ const result = commandVersion(command, prefixArguments);
+ const version = parseSwiftFormatVersion(result.output);
+ if (
+ result.status === 0 &&
+ version != null &&
+ (version[0] > MINIMUM_SWIFT_FORMAT_MAJOR ||
+ (version[0] === MINIMUM_SWIFT_FORMAT_MAJOR &&
+ version[1] >= MINIMUM_SWIFT_FORMAT_MINOR))
+ ) {
+ return {command, prefixArguments};
+ }
+ }
+ const instructions = IS_META_CHECKOUT
+ ? 'Meta: unset SWIFT_FORMAT and run `tools/lint/swift-format/swift-format --version` from the fbsource root. If that fails, repair your Meta DotSlash setup.'
+ : 'Please install Swift 6.3 or newer and make sure `swift-format` or `swift` is in your PATH, or set SWIFT_FORMAT=/path/to/swift-format.';
+ console.warn(
+ 'warning: Skipping Swift formatting because swift-format 6.3 or newer was not found.\n' +
+ instructions,
+ );
+ return null;
+}
+
+function main() {
+ const check = process.argv[2] === '--check';
+ const swiftFormat = findSwiftFormat();
+ if (swiftFormat == null) {
+ return;
+ }
+ const files = globSync('**/*.swift', {cwd: REPO_ROOT, ignore: IGNORE}).filter(
+ file => !isGenerated(file),
+ );
+
+ let exitStatus = 0;
+ for (let i = 0; i < files.length; i += MAX_FILES_PER_PROCESS) {
+ const result = spawnSync(
+ swiftFormat.command,
+ [
+ ...swiftFormat.prefixArguments,
+ check ? 'lint' : 'format',
+ '--configuration',
+ CONFIG,
+ ...(check ? ['--strict'] : ['--in-place']),
+ ...files.slice(i, i + MAX_FILES_PER_PROCESS),
+ ],
+ {
+ cwd: REPO_ROOT,
+ env: {...process.env, PWD: REPO_ROOT},
+ stdio: 'inherit',
+ },
+ );
+ if (result.error != null) {
+ throw result.error;
+ }
+ if (result.signal != null) {
+ throw new Error(`swift-format was terminated by ${result.signal}`);
+ }
+ if (result.status !== 0) {
+ exitStatus = result.status ?? 1;
+ }
+ }
+ process.exitCode = exitStatus;
+}
+
+main();
diff --git a/scripts/format-utils.js b/scripts/format-utils.js
new file mode 100644
index 000000000000..7b4dac220cb3
--- /dev/null
+++ b/scripts/format-utils.js
@@ -0,0 +1,88 @@
+/**
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ *
+ * @noflow
+ * @format
+ */
+
+'use strict';
+
+const {spawnSync} = require('node:child_process');
+const path = require('node:path');
+
+const REPO_ROOT = path.resolve(__dirname, '..');
+
+let metaUtils = null;
+try {
+ metaUtils = require('./format-utils.fb');
+} catch (error) {
+ if (
+ error == null ||
+ typeof error !== 'object' ||
+ error.code !== 'MODULE_NOT_FOUND' ||
+ !String(error.message).includes("'./format-utils.fb'")
+ ) {
+ throw error;
+ }
+}
+
+const IS_META_CHECKOUT = metaUtils != null;
+
+function commandVersion(command, prefixArguments = []) {
+ const result = spawnSync(command, [...prefixArguments, '--version'], {
+ encoding: 'utf8',
+ env: {...process.env, PWD: REPO_ROOT},
+ });
+ return {
+ output: `${result.stdout ?? ''}\n${result.stderr ?? ''}`,
+ status: result.status,
+ };
+}
+
+function findMetaTool(...relativePath) {
+ return metaUtils?.findMetaTool(...relativePath) ?? null;
+}
+
+function javaMajorVersion(command) {
+ const result = spawnSync(command, ['-version'], {encoding: 'utf8'});
+ const output = `${result.stdout ?? ''}\n${result.stderr ?? ''}`;
+ const version = /version "(?:1\.)?(\d+)/.exec(output);
+ return result.status === 0 && version != null ? Number(version[1]) : null;
+}
+
+function findJava(minimumVersion) {
+ if (process.env.JAVA != null && process.env.JAVA !== '') {
+ return javaMajorVersion(process.env.JAVA) >= minimumVersion
+ ? process.env.JAVA
+ : null;
+ }
+
+ const candidates = [];
+ candidates.push(...(metaUtils?.findJavaCandidates() ?? []));
+ candidates.push('java');
+
+ return (
+ candidates.find(command => javaMajorVersion(command) >= minimumVersion) ??
+ null
+ );
+}
+
+function warnMissingJava(language) {
+ const instructions =
+ metaUtils?.missingJavaInstructions() ??
+ 'Please install a JDK of your choice with Java 17 or newer and make sure the `java` command is in your PATH, or set JAVA=/path/to/java.';
+ console.warn(
+ `warning: Skipping ${language} formatting because Java 17 or newer was not found.\n${instructions}`,
+ );
+}
+
+module.exports = {
+ commandVersion,
+ findJava,
+ findMetaTool,
+ IS_META_CHECKOUT,
+ warnMissingJava,
+};
diff --git a/yarn.lock b/yarn.lock
index 5126518dbbe1..ff0546f73995 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2912,6 +2912,11 @@ async-limiter@~1.0.0:
resolved "https://registry.yarnpkg.com/async-limiter/-/async-limiter-1.0.1.tgz#dd379e94f0db8310b08291f9d64c3209766617fd"
integrity sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ==
+async@^3.2.4:
+ version "3.2.6"
+ resolved "https://registry.yarnpkg.com/async/-/async-3.2.6.tgz#1b0728e14929d51b85b449b7f06e27c1145e38ce"
+ integrity sha512-htCUDlxyyCLMgaM3xXg0C0LW2xqfuQ6p05pCEIsXuyQ+a1koYKTuBMzRNwmybfLgvJDMd0r1LTn4+E0Ti6C2AA==
+
author-regex@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/author-regex/-/author-regex-1.0.0.tgz#d08885be6b9bbf9439fe087c76287245f0a81450"
@@ -3146,6 +3151,13 @@ brace-expansion@^1.1.7:
balanced-match "^1.0.0"
concat-map "0.0.1"
+brace-expansion@^2.0.1:
+ version "2.1.4"
+ resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-2.1.4.tgz#589dab11c0018d0366be64cd8bf12c8dbecc8326"
+ integrity sha512-hGfVzPxthbf3+2yjg/RBs60cB0FhqBS/zvdV/4wn4/BmN0bNMMHPc4V/BbFieqf1TKAGGAHnY4eSjajCl0f2Xg==
+ dependencies:
+ balanced-match "^1.0.0"
+
brace-expansion@^2.0.2:
version "2.0.2"
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-2.0.2.tgz#54fc53237a613d854c7bd37463aad17df87214e7"
@@ -5041,6 +5053,17 @@ glob@^7.0.0, glob@^7.1.3, glob@^7.1.4:
once "^1.3.0"
path-is-absolute "^1.0.0"
+glob@^8.1.0:
+ version "8.1.0"
+ resolved "https://registry.yarnpkg.com/glob/-/glob-8.1.0.tgz#d388f656593ef708ee3e34640fdfb99a9fd1c33e"
+ integrity sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==
+ dependencies:
+ fs.realpath "^1.0.0"
+ inflight "^1.0.4"
+ inherits "2"
+ minimatch "^5.0.1"
+ once "^1.3.0"
+
globals@^11.1.0:
version "11.12.0"
resolved "https://registry.yarnpkg.com/globals/-/globals-11.12.0.tgz#ab8795338868a0babd8525758018c2a7eb95c42e"
@@ -5085,6 +5108,15 @@ globby@^11.1.0:
merge2 "^1.4.1"
slash "^3.0.0"
+google-java-format@1.4.0:
+ version "1.4.0"
+ resolved "https://registry.yarnpkg.com/google-java-format/-/google-java-format-1.4.0.tgz#d944b7a20f0a3729318b5c120931178843ed9a82"
+ integrity sha512-TlO1nUogUW6PonVL4xZCciVoJcjB2Nxo/dEY5M8GC5TJnQi6A4XeqJoiOot/To20350wPup9aQfP3Ia6GR+vEg==
+ dependencies:
+ async "^3.2.4"
+ glob "^8.1.0"
+ resolve "^1.22.8"
+
gopd@^1.0.1, gopd@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/gopd/-/gopd-1.2.0.tgz#89f56b8217bdbc8802bd299df6d7f1081d7e51a1"
@@ -6373,6 +6405,11 @@ kleur@^3.0.3:
resolved "https://registry.yarnpkg.com/kleur/-/kleur-3.0.3.tgz#a79c9ecc86ee1ce3fa6206d1216c501f147fc07e"
integrity sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==
+ktfmt@0.59.0:
+ version "0.59.0"
+ resolved "https://registry.yarnpkg.com/ktfmt/-/ktfmt-0.59.0.tgz#99f98b81dbdc7f1487dfbc9850eb17b3780cf6d5"
+ integrity sha512-lOEn/7y2Ez2/nxDTn5EwJv6BSugB8BtzY2Gn6GvyLIAjdUf3xgKzirIxD57t/vu5I6eybivmVtONI3WGXyZ3lw==
+
language-subtag-registry@^0.3.20:
version "0.3.23"
resolved "https://registry.yarnpkg.com/language-subtag-registry/-/language-subtag-registry-0.3.23.tgz#23529e04d9e3b74679d70142df3fd2eb6ec572e7"
@@ -7215,6 +7252,13 @@ minimatch@^10.0.1, minimatch@^10.2.2:
dependencies:
brace-expansion "^5.0.5"
+minimatch@^5.0.1:
+ version "5.1.9"
+ resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-5.1.9.tgz#1293ef15db0098b394540e8f9f744f9fda8dee4b"
+ integrity sha512-7o1wEA2RyMP7Iu7GNba9vc0RWWGACJOCZBJX2GJWip0ikV+wcOsgVuY9uE8CPiyQhkGFSlhuSkZPavN7u1c2Fw==
+ dependencies:
+ brace-expansion "^2.0.1"
+
minimatch@^9.0.4:
version "9.0.9"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-9.0.9.tgz#9b0cb9fcb78087f6fd7eababe2511c4d3d60574e"
@@ -8075,6 +8119,16 @@ resolve@^1.1.6, resolve@^1.14.2, resolve@^1.20.0, resolve@~1.22.1, resolve@~1.22
path-parse "^1.0.7"
supports-preserve-symlinks-flag "^1.0.0"
+resolve@^1.22.8:
+ version "1.22.12"
+ resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.22.12.tgz#f5b2a680897c69c238a13cd16b15671f8b73549f"
+ integrity sha512-TyeJ1zif53BPfHootBGwPRYT1RUt6oGWsaQr8UyZW/eAm9bKoijtvruSDEmZHm92CwS9nj7/fWttqPCgzep8CA==
+ dependencies:
+ es-errors "^1.3.0"
+ is-core-module "^2.16.1"
+ path-parse "^1.0.7"
+ supports-preserve-symlinks-flag "^1.0.0"
+
resolve@^2.0.0-next.5:
version "2.0.0-next.5"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-2.0.0-next.5.tgz#6b0ec3107e671e52b68cd068ef327173b90dc03c"