refactor: renderer config to provide async stack tagging api implementation

This commit is contained in:
Ruslan Lesiutin
2025-10-22 17:29:31 +01:00
parent 71b3a03cc9
commit 04bc6864ed
10 changed files with 38 additions and 5 deletions
+1
View File
@@ -462,6 +462,7 @@ module.exports = {
globals: {
nativeFabricUIManager: 'readonly',
RN$enableMicrotasksInReact: 'readonly',
RN$unstable_createTask: 'readonly',
},
},
{
+5
View File
@@ -402,6 +402,11 @@ export function resolveEventTimeStamp(): number {
return -1.1;
}
// Async Stack Tagging API.
// Chromium-only: https://developer.chrome.com/docs/devtools/console/api#createtask
// eslint-disable-next-line react-internal/no-production-logging
export const createTask = console.createTask;
export function shouldAttemptEagerTransition() {
return false;
}
@@ -741,6 +741,11 @@ export function resolveEventTimeStamp(): number {
return event && event !== schedulerEvent ? event.timeStamp : -1.1;
}
// Async Stack Tagging API.
// Chromium-only: https://developer.chrome.com/docs/devtools/console/api#createtask
// eslint-disable-next-line react-internal/no-production-logging
export const createTask: typeof console.createTask | void = console.createTask;
export const isPrimaryRenderer = true;
export const warnsIfNotActing = true;
// This initialization code may run even on server environments
@@ -424,6 +424,13 @@ export function resolveEventTimeStamp(): number {
return -1.1;
}
// This matches Chrome's console.createTask in terms of signature.
// This doesn't match Chrome's console.createTask in terms of behavior and implementation.
export const createTask: typeof console.createTask | void =
typeof RN$unstable_createTask === 'function'
? RN$unstable_createTask
: undefined;
export function shouldAttemptEagerTransition(): boolean {
return false;
}
@@ -366,6 +366,8 @@ export function resolveEventTimeStamp(): number {
return -1.1;
}
export const createTask: typeof console.createTask | void = undefined;
export function shouldAttemptEagerTransition(): boolean {
return false;
}
+7 -5
View File
@@ -24,7 +24,11 @@ import {
NoLanes,
} from './ReactFiberLane';
import {resolveEventType, resolveEventTimeStamp} from './ReactFiberConfig';
import {
resolveEventType,
resolveEventTimeStamp,
createTask as createTaskFromFiberConfig,
} from './ReactFiberConfig';
import {
enableProfilerCommitHooks,
@@ -43,10 +47,8 @@ import * as Scheduler from 'scheduler';
const {unstable_now: now} = Scheduler;
const createTask =
// eslint-disable-next-line react-internal/no-production-logging
__DEV__ && console.createTask
? // eslint-disable-next-line react-internal/no-production-logging
console.createTask
__DEV__ && createTaskFromFiberConfig
? createTaskFromFiberConfig
: (name: string) => null;
export const REGULAR_UPDATE: UpdateType = 0;
@@ -85,6 +85,7 @@ export const resolveUpdatePriority = $$$config.resolveUpdatePriority;
export const trackSchedulerEvent = $$$config.trackSchedulerEvent;
export const resolveEventType = $$$config.resolveEventType;
export const resolveEventTimeStamp = $$$config.resolveEventTimeStamp;
export const createTask = $$$config.createTask;
export const shouldAttemptEagerTransition =
$$$config.shouldAttemptEagerTransition;
export const detachDeletedInstance = $$$config.detachDeletedInstance;
@@ -259,6 +259,11 @@ export function resolveEventType(): null | string {
export function resolveEventTimeStamp(): number {
return -1.1;
}
// Async Stack Tagging API.
// Chromium-only: https://developer.chrome.com/docs/devtools/console/api#createtask
// eslint-disable-next-line react-internal/no-production-logging
export const createTask = console.createTask;
export function shouldAttemptEagerTransition(): boolean {
return false;
}
+3
View File
@@ -303,3 +303,6 @@ declare const nativeFabricUIManager: {
unstable_getCurrentEventPriority: () => number,
...
};
// eslint-disable-next-line no-unused-vars
declare const RN$unstable_createTask: typeof console.createTask;
+2
View File
@@ -48,6 +48,8 @@ module.exports = {
nativeFabricUIManager: 'readonly',
// RN flag to enable microtasks
RN$enableMicrotasksInReact: 'readonly',
// RN's temporary Async Stack Tagging API.
RN$unstable_createTask: 'readonly',
// Trusted Types
trustedTypes: 'readonly',
// RN supports this