Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 1d6352c

Browse files
author
Brian Vaughn
committedJan 20, 2022
Renamed Store variables based on PR feedback
1 parent 5c1adb2 commit 1d6352c

File tree

6 files changed

+43
-39
lines changed

6 files changed

+43
-39
lines changed
 

‎packages/react-devtools-shared/src/__tests__/store-test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -915,17 +915,17 @@ describe('Store', () => {
915915
const containerA = document.createElement('div');
916916
const containerB = document.createElement('div');
917917

918-
expect(store.rootSupportsProfiling).toBe(false);
918+
expect(store.rootSupportsBasicProfiling).toBe(false);
919919

920920
act(() => legacyRender(<Component />, containerA));
921-
expect(store.rootSupportsProfiling).toBe(true);
921+
expect(store.rootSupportsBasicProfiling).toBe(true);
922922

923923
act(() => legacyRender(<Component />, containerB));
924924
act(() => ReactDOM.unmountComponentAtNode(containerA));
925-
expect(store.rootSupportsProfiling).toBe(true);
925+
expect(store.rootSupportsBasicProfiling).toBe(true);
926926

927927
act(() => ReactDOM.unmountComponentAtNode(containerB));
928-
expect(store.rootSupportsProfiling).toBe(false);
928+
expect(store.rootSupportsBasicProfiling).toBe(false);
929929
});
930930

931931
it('should properly serialize non-string key values', () => {

‎packages/react-devtools-shared/src/backend/renderer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ import {
4747
} from './utils';
4848
import {
4949
__DEBUG__,
50-
PROFILING_FLAG_LEGACY_SUPPORT,
50+
PROFILING_FLAG_BASIC_SUPPORT,
5151
PROFILING_FLAG_TIMELINE_SUPPORT,
5252
SESSION_STORAGE_RELOAD_AND_PROFILE_KEY,
5353
SESSION_STORAGE_RECORD_CHANGE_DESCRIPTIONS_KEY,
@@ -1915,7 +1915,7 @@ export function attach(
19151915
// Instead let's re-purpose a pre-existing field to carry more information.
19161916
let profilingFlags = 0;
19171917
if (isProfilingSupported) {
1918-
profilingFlags = PROFILING_FLAG_LEGACY_SUPPORT;
1918+
profilingFlags = PROFILING_FLAG_BASIC_SUPPORT;
19191919
if (typeof injectProfilingHooks === 'function') {
19201920
profilingFlags |= PROFILING_FLAG_TIMELINE_SUPPORT;
19211921
}

‎packages/react-devtools-shared/src/constants.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export const TREE_OPERATION_UPDATE_ERRORS_OR_WARNINGS = 5;
2525
export const TREE_OPERATION_REMOVE_ROOT = 6;
2626
export const TREE_OPERATION_SET_SUBTREE_MODE = 7;
2727

28-
export const PROFILING_FLAG_LEGACY_SUPPORT = 0b01;
28+
export const PROFILING_FLAG_BASIC_SUPPORT = 0b01;
2929
export const PROFILING_FLAG_TIMELINE_SUPPORT = 0b10;
3030

3131
export const LOCAL_STORAGE_DEFAULT_TAB_KEY = 'React::DevTools::defaultTab';

‎packages/react-devtools-shared/src/devtools/store.js

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import EventEmitter from '../events';
1111
import {inspect} from 'util';
1212
import {
13-
PROFILING_FLAG_LEGACY_SUPPORT,
13+
PROFILING_FLAG_BASIC_SUPPORT,
1414
PROFILING_FLAG_TIMELINE_SUPPORT,
1515
TREE_OPERATION_ADD,
1616
TREE_OPERATION_REMOVE,
@@ -74,8 +74,8 @@ type Config = {|
7474
|};
7575

7676
export type Capabilities = {|
77+
supportsBasicProfiling: boolean,
7778
hasOwnerMetadata: boolean,
78-
supportsProfiling: boolean,
7979
supportsStrictMode: boolean,
8080
supportsTimeline: boolean,
8181
|};
@@ -91,8 +91,8 @@ export default class Store extends EventEmitter<{|
9191
mutated: [[Array<number>, Map<number, number>]],
9292
recordChangeDescriptions: [],
9393
roots: [],
94-
rootSupportsProfiling: [],
95-
rootSupportsTimeline: [],
94+
rootSupportsBasicProfiling: [],
95+
rootSupportsTimelineProfiling: [],
9696
supportsNativeStyleEditor: [],
9797
supportsReloadAndProfile: [],
9898
unsupportedBridgeProtocolDetected: [],
@@ -172,8 +172,8 @@ export default class Store extends EventEmitter<{|
172172
_supportsTraceUpdates: boolean = false;
173173

174174
// These options default to false but may be updated as roots are added and removed.
175-
_rootSupportsProfiling: boolean = false;
176-
_rootSupportsTimeline: boolean = false;
175+
_rootSupportsBasicProfiling: boolean = false;
176+
_rootSupportsTimelineProfiling: boolean = false;
177177

178178
_unsupportedBridgeProtocol: BridgeProtocol | null = null;
179179
_unsupportedRendererVersionDetected: boolean = false;
@@ -410,13 +410,13 @@ export default class Store extends EventEmitter<{|
410410
}
411411

412412
// At least one of the currently mounted roots support the Legacy profiler.
413-
get rootSupportsProfiling(): boolean {
414-
return this._rootSupportsProfiling;
413+
get rootSupportsBasicProfiling(): boolean {
414+
return this._rootSupportsBasicProfiling;
415415
}
416416

417417
// At least one of the currently mounted roots support the Timeline profiler.
418-
get rootSupportsTimeline(): boolean {
419-
return this._rootSupportsTimeline;
418+
get rootSupportsTimelineProfiling(): boolean {
419+
return this._rootSupportsTimelineProfiling;
420420
}
421421

422422
get supportsNativeInspection(): boolean {
@@ -924,8 +924,8 @@ export default class Store extends EventEmitter<{|
924924
const isStrictModeCompliant = operations[i] > 0;
925925
i++;
926926

927-
const supportsProfiling =
928-
(operations[i] & PROFILING_FLAG_LEGACY_SUPPORT) !== 0;
927+
const supportsBasicProfiling =
928+
(operations[i] & PROFILING_FLAG_BASIC_SUPPORT) !== 0;
929929
const supportsTimeline =
930930
(operations[i] & PROFILING_FLAG_TIMELINE_SUPPORT) !== 0;
931931
i++;
@@ -939,8 +939,8 @@ export default class Store extends EventEmitter<{|
939939
this._roots = this._roots.concat(id);
940940
this._rootIDToRendererID.set(id, rendererID);
941941
this._rootIDToCapabilities.set(id, {
942+
supportsBasicProfiling,
942943
hasOwnerMetadata,
943-
supportsProfiling,
944944
supportsStrictMode,
945945
supportsTimeline,
946946
});
@@ -1249,34 +1249,38 @@ export default class Store extends EventEmitter<{|
12491249
}
12501250

12511251
if (haveRootsChanged) {
1252-
const prevRootSupportsProfiling = this._rootSupportsProfiling;
1253-
const prevRootSupportsTimeline = this._rootSupportsTimeline;
1252+
const prevRootSupportsProfiling = this._rootSupportsBasicProfiling;
1253+
const prevRootSupportsTimelineProfiling = this
1254+
._rootSupportsTimelineProfiling;
12541255

12551256
this._hasOwnerMetadata = false;
1256-
this._rootSupportsProfiling = false;
1257-
this._rootSupportsTimeline = false;
1257+
this._rootSupportsBasicProfiling = false;
1258+
this._rootSupportsTimelineProfiling = false;
12581259
this._rootIDToCapabilities.forEach(
1259-
({hasOwnerMetadata, supportsProfiling, supportsTimeline}) => {
1260+
({supportsBasicProfiling, hasOwnerMetadata, supportsTimeline}) => {
1261+
if (supportsBasicProfiling) {
1262+
this._rootSupportsBasicProfiling = true;
1263+
}
12601264
if (hasOwnerMetadata) {
12611265
this._hasOwnerMetadata = true;
12621266
}
1263-
if (supportsProfiling) {
1264-
this._rootSupportsProfiling = true;
1265-
}
12661267
if (supportsTimeline) {
1267-
this._rootSupportsTimeline = true;
1268+
this._rootSupportsTimelineProfiling = true;
12681269
}
12691270
},
12701271
);
12711272

12721273
this.emit('roots');
12731274

1274-
if (this._rootSupportsProfiling !== prevRootSupportsProfiling) {
1275-
this.emit('rootSupportsProfiling');
1275+
if (this._rootSupportsBasicProfiling !== prevRootSupportsProfiling) {
1276+
this.emit('rootSupportsBasicProfiling');
12761277
}
12771278

1278-
if (this._rootSupportsTimeline !== prevRootSupportsTimeline) {
1279-
this.emit('rootSupportsTimeline');
1279+
if (
1280+
this._rootSupportsTimelineProfiling !==
1281+
prevRootSupportsTimelineProfiling
1282+
) {
1283+
this.emit('rootSupportsTimelineProfiling');
12801284
}
12811285
}
12821286

‎packages/react-devtools-shared/src/devtools/views/Profiler/ProfilerContext.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,18 +96,18 @@ function ProfilerContextController({children}: Props) {
9696
isProcessingData: profilerStore.isProcessingData,
9797
isProfiling: profilerStore.isProfiling,
9898
profilingData: profilerStore.profilingData,
99-
supportsProfiling: store.rootSupportsProfiling,
99+
supportsProfiling: store.rootSupportsBasicProfiling,
100100
}),
101101
subscribe: (callback: Function) => {
102102
profilerStore.addListener('profilingData', callback);
103103
profilerStore.addListener('isProcessingData', callback);
104104
profilerStore.addListener('isProfiling', callback);
105-
store.addListener('rootSupportsProfiling', callback);
105+
store.addListener('rootSupportsBasicProfiling', callback);
106106
return () => {
107107
profilerStore.removeListener('profilingData', callback);
108108
profilerStore.removeListener('isProcessingData', callback);
109109
profilerStore.removeListener('isProfiling', callback);
110-
store.removeListener('rootSupportsProfiling', callback);
110+
store.removeListener('rootSupportsBasicProfiling', callback);
111111
};
112112
},
113113
}),

‎packages/react-devtools-timeline/src/TimelineContext.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ function TimelineContextController({children}: Props) {
4848

4949
const isTimelineSupported = useSyncExternalStore<boolean>(
5050
function subscribe(callback) {
51-
store.addListener('rootSupportsTimeline', callback);
51+
store.addListener('rootSupportsTimelineProfiling', callback);
5252
return function unsubscribe() {
53-
store.removeListener('rootSupportsTimeline', callback);
53+
store.removeListener('rootSupportsTimelineProfiling', callback);
5454
};
5555
},
5656
function getState() {
57-
return store.rootSupportsTimeline;
57+
return store.rootSupportsTimelineProfiling;
5858
},
5959
);
6060

0 commit comments

Comments
 (0)
Please sign in to comment.