Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
};
case "UpdateElements":
return {
type: "UpdateElements",
token: "",
viewports: field("viewports", decodeViewports),
};
default:
throw fieldError("type", `Unknown FrameMessage type: ${repr(type)}`);
}
}
);
const decodeViewports: Decoder> = array(
autoRecord({
// A viewport of a frame can be partially off-screen.
x: number,
y: number,
width: decodeUnsignedFloat,
height: decodeUnsignedFloat,
})
);
// $ExpectType { readonly [key: string]: unknown; }
mixedDict(undefined);
// $ExpectType true
constant(true)(undefined);
// $ExpectType false
constant(false)(undefined);
// $ExpectType 0
constant(0)(undefined);
// $ExpectType "const"
constant("const")(undefined);
// $ExpectType undefined
constant(undefined)(undefined);
// $ExpectType null
constant(null)(undefined);
// $ExpectType string[]
array(string)(undefined);
// $ExpectType { [key: string]: string; }
dict(string)(undefined);
// $ExpectType string
record(() => "")(undefined);
// $ExpectType { a: string; }
record(field => ({ a: field("a", string) }))(undefined);
// $ExpectType string
tuple(() => "")(undefined);
// $ExpectType string[]
tuple(item => [item(0, string)])(undefined);
// $ExpectType [string]
tuple<[string]>(item => [item(0, string)])(undefined);
// $ExpectType [string, boolean]
pair(string, boolean)(undefined);
// $ExpectType [string, boolean, boolean]
triple(string, boolean, boolean)(undefined);
arr => new Set(array(decoder)(normalizeStringArray(arr)))
);
throw new TypeError(`Invalid ElementType: ${repr(type)}`);
}
}
export function decodeElementTypesConstants(type: string): ElementTypes {
switch (type) {
case "selectable":
return type;
default:
throw new TypeError(`Invalid ElementTypes constant: ${repr(type)}`);
}
}
export const decodeElementTypes: Decoder = either(
map(string, decodeElementTypesConstants),
array(map(string, decodeElementType))
);
export type Point = {
x: number,
y: number,
align: "left" | "right",
debug: string,
};
export type HintMeasurements = {
...Point,
maxX: number,
weight: number,
};
export type VisibleElement = {
});
export type Perf = Array<{
timeToFirstPaint: number,
timeToLastPaint: number,
topDurations: Durations,
collectStats: Array,
renderDurations: Durations,
}>;
export const decodePerf: Decoder = array(
autoRecord({
timeToFirstPaint: number,
timeToLastPaint: number,
topDurations: decodeDurations,
collectStats: array(decodeStats),
renderDurations: decodeDurations,
})
);
export type TabsPerf = { [tabId: string]: Perf, ... };
export const decodeTabsPerf: Decoder = dict(decodePerf);
export class TimeTracker {
_durations: Durations = [];
_current: ?{ label: string, timestamp: number } = undefined;
start(label: string) {
this.stop();
this._current = {
numTrackedElements: number,
numVisibleElements: number,
numVisibleFrames: number,
bailed: number,
durations: decodeDurations,
});
export type Perf = Array<{
timeToFirstPaint: number,
timeToLastPaint: number,
topDurations: Durations,
collectStats: Array,
renderDurations: Durations,
}>;
export const decodePerf: Decoder = array(
autoRecord({
timeToFirstPaint: number,
timeToLastPaint: number,
topDurations: decodeDurations,
collectStats: array(decodeStats),
renderDurations: decodeDurations,
})
);
export type TabsPerf = { [tabId: string]: Perf, ... };
export const decodeTabsPerf: Decoder = dict(decodePerf);
export class TimeTracker {
_durations: Durations = [];
_current: ?{ label: string, timestamp: number } = undefined;
default: defaults.logLevel,
}),
useKeyTranslations: field("useKeyTranslations", boolean, {
default: defaults.useKeyTranslations,
}),
keyTranslations: field("keyTranslations", dict(decodeKeyPair, "skip"), {
default: defaults.keyTranslations,
}),
normalKeyboardShortcuts: field(
"normalKeyboardShortcuts",
array(decodeKeyboardMappingWithModifiers, "skip"),
{ default: defaults.normalKeyboardShortcuts }
),
hintsKeyboardShortcuts: field(
"hintsKeyboardShortcuts",
array(decodeKeyboardMapping, "skip"),
{ default: defaults.hintsKeyboardShortcuts }
),
}));
}