Skip to content
Closed
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
16 changes: 10 additions & 6 deletions packages/polyfills/console.js
Original file line number Diff line number Diff line change
Expand Up @@ -569,10 +569,7 @@ function consoleAssertPolyfill(expression, label) {
}
}

// https://developer.mozilla.org/en-US/docs/Web/API/console/timeStamp_static.
// Non-standard API for recording markers on a timeline of the Performance instrumentation.
// The actual logging is not provided by definition.
function consoleTimeStampPolyfill() {}
function stub() {}

if (global.nativeLoggingHook) {
const originalConsole = global.console;
Expand All @@ -585,7 +582,11 @@ if (global.nativeLoggingHook) {
}

global.console = {
timeStamp: consoleTimeStampPolyfill,
time: stub,
timeEnd: stub,
timeStamp: stub,
count: stub,
countReset: stub,
...(originalConsole ?? {}),
error: getNativeLogFunction(LOG_LEVELS.error),
info: getNativeLogFunction(LOG_LEVELS.info),
Expand Down Expand Up @@ -676,7 +677,6 @@ if (global.nativeLoggingHook) {
});
}
} else if (!global.console) {
function stub() {}
const log = global.print || stub;

global.console = {
Expand All @@ -692,6 +692,8 @@ if (global.nativeLoggingHook) {
}
},
clear: stub,
count: stub,
countReset: stub,
dir: stub,
dirxml: stub,
group: stub,
Expand All @@ -700,6 +702,8 @@ if (global.nativeLoggingHook) {
profile: stub,
profileEnd: stub,
table: stub,
time: stub,
timeEnd: stub,
timeStamp: stub,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,19 @@
// flowlint unsafe-getters-setters:off

import type {DOMHighResTimeStamp} from './PerformanceEntry';
import type {
ExtensionMarkerPayload,
ExtensionTrackEntryPayload,
} from './UserTimingExtensibility';

import {getCurrentTimeStamp} from './internals/Utilities';
import {PerformanceEntry} from './PerformanceEntry';

export type DetailType = mixed;
export type DetailType =
| mixed
// This will effectively ignored by Flow (mixed | anything = mixed)
// but we'll use it as documentation for how to use the extensibility API.
| {devtools?: ExtensionMarkerPayload | ExtensionTrackEntryPayload, ...};

export type PerformanceMarkOptions = $ReadOnly<{
detail?: DetailType,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* 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.
*
* @flow strict
* @format
*/

export type DevToolsColor =
| 'primary'
| 'primary-light'
| 'primary-dark'
| 'secondary'
| 'secondary-light'
| 'secondary-dark'
| 'tertiary'
| 'tertiary-light'
| 'tertiary-dark'
| 'warning'
| 'error';

export interface ExtensionTrackEntryPayload {
dataType?: 'track-entry'; // Defaults to "track-entry"
color?: DevToolsColor; // Defaults to "primary"
track: string; // Required: Name of the custom track
trackGroup?: string; // Optional: Group for organizing tracks
properties?: Array<[string, string]>; // Key-value pairs for detailed view
tooltipText?: string; // Short description for tooltip
}

export interface ExtensionMarkerPayload {
dataType: 'marker'; // Required: Identifies as a marker
color?: DevToolsColor; // Defaults to "primary"
properties?: Array<[string, string]>; // Key-value pairs for detailed view
tooltipText?: string; // Short description for tooltip
}
Loading