Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions flow-typed/npm/babel-traverse_v7.x.x.js
Original file line number Diff line number Diff line change
Expand Up @@ -558,24 +558,24 @@ declare module '@babel/traverse' {
* Check whether we have the input `key`. If the `key` references an array then we check
* if the array has any items, otherwise we just check if it's falsy.
*/
has(key: $Keys<TNode>): boolean;
has(key: keyof TNode): boolean;

isStatic(): boolean;

/**
* Alias of `has`.
*/
is(key: $Keys<TNode>): boolean;
is(key: keyof TNode): boolean;

/**
* Opposite of `has`.
*/
isnt(key: $Keys<TNode>): boolean;
isnt(key: keyof TNode): boolean;

/**
* Check whether the path node `key` strict equals `value`.
*/
equals(key: $Keys<TNode>, value: any): boolean;
equals(key: keyof TNode, value: any): boolean;

/**
* Check the type against our stored internal type of the node. This is handy when a node has
Expand Down Expand Up @@ -726,7 +726,7 @@ declare module '@babel/traverse' {

getAllPrevSiblings(): Array<NodePath<>>;

get<TKey: $Keys<TNode>>(
get<TKey: keyof TNode>(
key: TKey,
context?: boolean | TraversalContext,
): TNode[TKey] extends BabelNode ? NodePath<> : Array<NodePath<>>;
Expand Down
4 changes: 2 additions & 2 deletions flow-typed/npm/rxjs_v6.x.x.js
Original file line number Diff line number Diff line change
Expand Up @@ -2186,10 +2186,10 @@ declare module 'rxjs/operators' {
): rxjs$MonoTypeOperatorFunction<T>;

declare export function distinctUntilKeyChanged<T>(
key: $Keys<T>,
key: keyof T,
): rxjs$MonoTypeOperatorFunction<T>;

declare export function distinctUntilKeyChanged<T, K: $Keys<T>>(
declare export function distinctUntilKeyChanged<T, K: keyof T>(
key: K,
compare: (x: mixed, y: mixed) => boolean,
): rxjs$MonoTypeOperatorFunction<T>;
Expand Down
48 changes: 24 additions & 24 deletions packages/dev-middleware/src/inspector-proxy/Device.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,18 @@ const debug = require('debug')('Metro:InspectorProxy');
const PAGES_POLLING_INTERVAL = 1000;

const WS_CLOSURE_CODE = {
NORMAL: 1000,
INTERNAL_ERROR: 1011,
NORMAL: 1000,
};

// should be aligned with
// https://github.com/facebook/react-native-devtools-frontend/blob/3d17e0fd462dc698db34586697cce2371b25e0d3/front_end/ui/legacy/components/utils/TargetDetachedDialog.ts#L50-L64
export const WS_CLOSE_REASON = {
PAGE_NOT_FOUND: '[PAGE_NOT_FOUND] Debugger page not found',
CONNECTION_LOST: '[CONNECTION_LOST] Connection lost to corresponding device',
RECREATING_DEVICE: '[RECREATING_DEVICE] Recreating device connection',
NEW_DEBUGGER_OPENED:
'[NEW_DEBUGGER_OPENED] New debugger opened for the same app instance',
PAGE_NOT_FOUND: '[PAGE_NOT_FOUND] Debugger page not found',
RECREATING_DEVICE: '[RECREATING_DEVICE] Recreating device connection',
};

// Prefix for script URLs that are alphanumeric IDs. See comment in #processMessageFromDeviceLegacy method for
Expand Down Expand Up @@ -160,9 +160,9 @@ export default class Device {
this.#deviceRelativeBaseUrl = deviceRelativeBaseUrl;
this.#deviceEventReporter = eventReporter
? new DeviceEventReporter(eventReporter, {
appId: app,
deviceId: id,
deviceName: name,
appId: app,
})
: null;
this.#createCustomMessageHandler = createMessageMiddleware;
Expand Down Expand Up @@ -334,17 +334,17 @@ export default class Device {
);

this.#deviceEventReporter?.logConnection('debugger', {
pageId,
frontendUserAgent: userAgent,
pageId,
});

const debuggerInfo: ?DebuggerConnection & DebuggerConnection = {
socket,
prependedFilePrefix: false,
pageId,
userAgent: userAgent,
customHandler: null,
debuggerRelativeBaseUrl,
pageId,
prependedFilePrefix: false,
socket,
userAgent,
};

this.#debuggerConnection = debuggerInfo;
Expand All @@ -357,16 +357,15 @@ export default class Device {
if (this.#debuggerConnection && this.#createCustomMessageHandler) {
this.#debuggerConnection.customHandler = this.#createCustomMessageHandler(
{
page,
debugger: {
userAgent: debuggerInfo.userAgent,
sendMessage: message => {
try {
const payload = JSON.stringify(message);
this.#cdpDebugLogging.log('ProxyToDebugger', payload);
socket.send(payload);
} catch {}
},
userAgent: debuggerInfo.userAgent,
},
device: {
appId: this.#app,
Expand All @@ -386,6 +385,7 @@ export default class Device {
} catch {}
},
},
page,
},
);

Expand All @@ -405,8 +405,8 @@ export default class Device {
this.#cdpDebugLogging.log('DebuggerToProxy', message);
const debuggerRequest = JSON.parse(message);
this.#deviceEventReporter?.logRequest(debuggerRequest, 'debugger', {
pageId: this.#debuggerConnection?.pageId ?? null,
frontendUserAgent: userAgent,
pageId: this.#debuggerConnection?.pageId ?? null,
prefersFuseboxFrontend: this.#isPageFuseboxFrontend(
this.#debuggerConnection?.pageId,
),
Expand Down Expand Up @@ -482,7 +482,7 @@ export default class Device {
/**
* Returns `true` if a page supports the given target capability flag.
*/
#pageHasCapability(page: Page, flag: $Keys<TargetCapabilityFlags>): boolean {
#pageHasCapability(page: Page, flag: keyof TargetCapabilityFlags): boolean {
return page.capabilities[flag] === true;
}

Expand All @@ -491,11 +491,11 @@ export default class Device {
*/
#createSyntheticPage(): Page {
return {
app: this.#app,
capabilities: {},
id: REACT_NATIVE_RELOADABLE_PAGE_ID,
title: 'React Native Experimental (Improved Chrome Reloads)',
vm: "don't use",
app: this.#app,
capabilities: {},
};
}

Expand Down Expand Up @@ -596,8 +596,8 @@ export default class Device {
const pageId = this.#debuggerConnection?.pageId ?? null;
if ('id' in parsedPayload) {
this.#deviceEventReporter?.logResponse(parsedPayload, 'device', {
pageId,
frontendUserAgent: this.#debuggerConnection?.userAgent ?? null,
pageId,
prefersFuseboxFrontend: this.#isPageFuseboxFrontend(pageId),
});
}
Expand Down Expand Up @@ -665,15 +665,15 @@ export default class Device {
this.#sendConnectEventToDevice(page.id);

const toSend = [
{method: 'Runtime.enable', id: 1e9},
{method: 'Debugger.enable', id: 1e9},
{id: 1e9, method: 'Runtime.enable'},
{id: 1e9, method: 'Debugger.enable'},
];

for (const message of toSend) {
const pageId = this.#debuggerConnection?.pageId ?? null;
this.#deviceEventReporter?.logRequest(message, 'proxy', {
pageId,
frontendUserAgent: this.#debuggerConnection?.userAgent ?? null,
pageId,
prefersFuseboxFrontend: this.#isPageFuseboxFrontend(pageId),
});
this.#sendMessageToDevice({
Expand Down Expand Up @@ -820,10 +820,10 @@ export default class Device {
//
// This is not an issue in VSCode/Nuclide where the IDE knows to resume
// at its convenience.
const resumeMessage = {method: 'Debugger.resume', id: 0};
const resumeMessage = {id: 0, method: 'Debugger.resume'};
this.#deviceEventReporter?.logRequest(resumeMessage, 'proxy', {
pageId: this.#debuggerConnection?.pageId ?? null,
frontendUserAgent: this.#debuggerConnection?.userAgent ?? null,
pageId: this.#debuggerConnection?.pageId ?? null,
prefersFuseboxFrontend: this.#isPageFuseboxFrontend(
this.#debuggerConnection?.pageId,
),
Expand Down Expand Up @@ -894,8 +894,8 @@ export default class Device {
socket.send(JSON.stringify(response));
const pageId = this.#debuggerConnection?.pageId ?? null;
this.#deviceEventReporter?.logResponse(response, 'proxy', {
pageId,
frontendUserAgent: this.#debuggerConnection?.userAgent ?? null,
pageId,
prefersFuseboxFrontend: this.#isPageFuseboxFrontend(pageId),
});
return null;
Expand Down Expand Up @@ -973,8 +973,8 @@ export default class Device {
socket.send(JSON.stringify(response));
const pageId = this.#debuggerConnection?.pageId ?? null;
this.#deviceEventReporter?.logResponse(response, 'proxy', {
pageId,
frontendUserAgent: this.#debuggerConnection?.userAgent ?? null,
pageId,
prefersFuseboxFrontend: this.#isPageFuseboxFrontend(pageId),
});
};
Expand All @@ -988,8 +988,8 @@ export default class Device {
this.#sendErrorToDebugger(error);
const pageId = this.#debuggerConnection?.pageId ?? null;
this.#deviceEventReporter?.logResponse(response, 'proxy', {
pageId,
frontendUserAgent: this.#debuggerConnection?.userAgent ?? null,
pageId,
prefersFuseboxFrontend: this.#isPageFuseboxFrontend(pageId),
});
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ import type {JSONSerializable} from '../types';
import type {Commands, Events} from './protocol';

// Note: A CDP event is a JSON-RPC notification with no `id` member.
export type CDPEvent<TEvent: $Keys<Events> = 'unknown'> = {
export type CDPEvent<TEvent: keyof Events = 'unknown'> = {
method: TEvent,
params: Events[TEvent],
};

export type CDPRequest<TCommand: $Keys<Commands> = 'unknown'> = {
export type CDPRequest<TCommand: keyof Commands = 'unknown'> = {
method: TCommand,
params: Commands[TCommand]['paramsType'],
id: number,
};

export type CDPResponse<TCommand: $Keys<Commands> = 'unknown'> =
export type CDPResponse<TCommand: keyof Commands = 'unknown'> =
| {
result: Commands[TCommand]['resultType'],
id: number,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ type PassThroughProps = $ReadOnly<{
passthroughAnimatedPropExplicitValues?: ViewProps | null,
}>;

type LooseOmit<O: interface {}, K: $Keys<$FlowFixMe>> = Pick<
type LooseOmit<O: interface {}, K: keyof $FlowFixMe> = Pick<
O,
Exclude<$Keys<O>, K>,
Exclude<keyof O, K>,
>;

export type AnimatedProps<Props: {...}> = LooseOmit<
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native/Libraries/AppState/AppState.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type AppStateEventDefinitions = {
focus: [],
};

export type AppStateEvent = $Keys<AppStateEventDefinitions>;
export type AppStateEvent = keyof AppStateEventDefinitions;

type NativeAppStateEventDefinitions = {
appStateDidChange: [{app_state: AppStateStatus}],
Expand Down
Loading
Loading