Initial Sample.
This commit is contained in:
171
graphql-subscription/node_modules/@apollo/client/testing/internal/profile/Render.d.ts
generated
vendored
Normal file
171
graphql-subscription/node_modules/@apollo/client/testing/internal/profile/Render.d.ts
generated
vendored
Normal file
@@ -0,0 +1,171 @@
|
||||
/// <reference types="react" />
|
||||
import { screen } from "@testing-library/dom";
|
||||
/** @internal */
|
||||
export interface BaseRender {
|
||||
id: string;
|
||||
phase: "mount" | "update" | "nested-update";
|
||||
actualDuration: number;
|
||||
baseDuration: number;
|
||||
startTime: number;
|
||||
commitTime: number;
|
||||
/**
|
||||
* The number of renders that have happened so far (including this render).
|
||||
*/
|
||||
count: number;
|
||||
}
|
||||
type Screen = typeof screen;
|
||||
/** @internal */
|
||||
export type SyncScreen = {
|
||||
[K in keyof Screen]: K extends `find${string}` ? {
|
||||
/** @deprecated A snapshot is static, so avoid async queries! */
|
||||
(...args: Parameters<Screen[K]>): ReturnType<Screen[K]>;
|
||||
} : Screen[K];
|
||||
};
|
||||
/** @internal */
|
||||
export interface Render<Snapshot> extends BaseRender {
|
||||
/**
|
||||
* The snapshot, as returned by the `takeSnapshot` option of `profile`.
|
||||
* (If using `profileHook`, this is the return value of the hook.)
|
||||
*/
|
||||
snapshot: Snapshot;
|
||||
/**
|
||||
* A DOM snapshot of the rendered component, if the `snapshotDOM`
|
||||
* option of `profile` was enabled.
|
||||
*/
|
||||
readonly domSnapshot: HTMLElement;
|
||||
/**
|
||||
* Returns a callback to receive a `screen` instance that is scoped to the
|
||||
* DOM snapshot of this `Render` instance.
|
||||
* Note: this is used as a callback to prevent linter errors.
|
||||
* @example
|
||||
* ```diff
|
||||
* const { withinDOM } = RenderedComponent.takeRender();
|
||||
* -expect(screen.getByText("foo")).toBeInTheDocument();
|
||||
* +expect(withinDOM().getByText("foo")).toBeInTheDocument();
|
||||
* ```
|
||||
*/
|
||||
withinDOM: () => SyncScreen;
|
||||
renderedComponents: Array<string | React.ComponentType>;
|
||||
}
|
||||
/** @internal */
|
||||
export declare class RenderInstance<Snapshot> implements Render<Snapshot> {
|
||||
snapshot: Snapshot;
|
||||
private stringifiedDOM;
|
||||
renderedComponents: Array<string | React.ComponentType>;
|
||||
id: string;
|
||||
phase: "mount" | "update" | "nested-update";
|
||||
actualDuration: number;
|
||||
baseDuration: number;
|
||||
startTime: number;
|
||||
commitTime: number;
|
||||
count: number;
|
||||
constructor(baseRender: BaseRender, snapshot: Snapshot, stringifiedDOM: string | undefined, renderedComponents: Array<string | React.ComponentType>);
|
||||
private _domSnapshot;
|
||||
get domSnapshot(): HTMLElement;
|
||||
get withinDOM(): () => {
|
||||
getByLabelText<T extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").SelectorMatcherOptions | undefined): T;
|
||||
getAllByLabelText<T_1 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").SelectorMatcherOptions | undefined): T_1[];
|
||||
queryByLabelText<T_2 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").SelectorMatcherOptions | undefined): T_2 | null;
|
||||
queryAllByLabelText<T_3 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").SelectorMatcherOptions | undefined): T_3[];
|
||||
findByLabelText<T_4 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").SelectorMatcherOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined): Promise<T_4>;
|
||||
findAllByLabelText<T_5 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").SelectorMatcherOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined): Promise<T_5[]>;
|
||||
getByPlaceholderText<T_6 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined): T_6;
|
||||
getAllByPlaceholderText<T_7 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined): T_7[];
|
||||
queryByPlaceholderText<T_8 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined): T_8 | null;
|
||||
queryAllByPlaceholderText<T_9 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined): T_9[];
|
||||
findByPlaceholderText<T_10 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined): Promise<T_10>;
|
||||
findAllByPlaceholderText<T_11 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined): Promise<T_11[]>;
|
||||
getByText<T_12 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").SelectorMatcherOptions | undefined): T_12;
|
||||
getAllByText<T_13 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").SelectorMatcherOptions | undefined): T_13[];
|
||||
queryByText<T_14 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").SelectorMatcherOptions | undefined): T_14 | null;
|
||||
queryAllByText<T_15 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").SelectorMatcherOptions | undefined): T_15[];
|
||||
findByText<T_16 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").SelectorMatcherOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined): Promise<T_16>;
|
||||
findAllByText<T_17 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").SelectorMatcherOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined): Promise<T_17[]>;
|
||||
getByAltText<T_18 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined): T_18;
|
||||
getAllByAltText<T_19 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined): T_19[];
|
||||
queryByAltText<T_20 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined): T_20 | null;
|
||||
queryAllByAltText<T_21 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined): T_21[];
|
||||
findByAltText<T_22 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined): Promise<T_22>;
|
||||
findAllByAltText<T_23 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined): Promise<T_23[]>;
|
||||
getByTitle<T_24 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined): T_24;
|
||||
getAllByTitle<T_25 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined): T_25[];
|
||||
queryByTitle<T_26 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined): T_26 | null;
|
||||
queryAllByTitle<T_27 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined): T_27[];
|
||||
findByTitle<T_28 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined): Promise<T_28>;
|
||||
findAllByTitle<T_29 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined): Promise<T_29[]>;
|
||||
getByDisplayValue<T_30 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined): T_30;
|
||||
getAllByDisplayValue<T_31 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined): T_31[];
|
||||
queryByDisplayValue<T_32 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined): T_32 | null;
|
||||
queryAllByDisplayValue<T_33 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined): T_33[];
|
||||
findByDisplayValue<T_34 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined): Promise<T_34>;
|
||||
findAllByDisplayValue<T_35 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined): Promise<T_35[]>;
|
||||
getByRole<T_36 extends HTMLElement = HTMLElement>(role: import("@testing-library/dom").ByRoleMatcher, options?: import("@testing-library/dom").ByRoleOptions | undefined): T_36;
|
||||
getAllByRole<T_37 extends HTMLElement = HTMLElement>(role: import("@testing-library/dom").ByRoleMatcher, options?: import("@testing-library/dom").ByRoleOptions | undefined): T_37[];
|
||||
queryByRole<T_38 extends HTMLElement = HTMLElement>(role: import("@testing-library/dom").ByRoleMatcher, options?: import("@testing-library/dom").ByRoleOptions | undefined): T_38 | null;
|
||||
queryAllByRole<T_39 extends HTMLElement = HTMLElement>(role: import("@testing-library/dom").ByRoleMatcher, options?: import("@testing-library/dom").ByRoleOptions | undefined): T_39[];
|
||||
findByRole<T_40 extends HTMLElement = HTMLElement>(role: import("@testing-library/dom").ByRoleMatcher, options?: import("@testing-library/dom").ByRoleOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined): Promise<T_40>;
|
||||
findAllByRole<T_41 extends HTMLElement = HTMLElement>(role: import("@testing-library/dom").ByRoleMatcher, options?: import("@testing-library/dom").ByRoleOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined): Promise<T_41[]>;
|
||||
getByTestId<T_42 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined): T_42;
|
||||
getAllByTestId<T_43 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined): T_43[];
|
||||
queryByTestId<T_44 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined): T_44 | null;
|
||||
queryAllByTestId<T_45 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined): T_45[];
|
||||
findByTestId<T_46 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined): Promise<T_46>;
|
||||
findAllByTestId<T_47 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined): Promise<T_47[]>;
|
||||
} & {
|
||||
getByLabelText: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").SelectorMatcherOptions | undefined) => HTMLElement;
|
||||
getAllByLabelText: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").SelectorMatcherOptions | undefined) => HTMLElement[];
|
||||
queryByLabelText: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").SelectorMatcherOptions | undefined) => HTMLElement | null;
|
||||
queryAllByLabelText: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").SelectorMatcherOptions | undefined) => HTMLElement[];
|
||||
findByLabelText: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").SelectorMatcherOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined) => Promise<HTMLElement>;
|
||||
findAllByLabelText: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").SelectorMatcherOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined) => Promise<HTMLElement[]>;
|
||||
getByPlaceholderText: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined) => HTMLElement;
|
||||
getAllByPlaceholderText: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined) => HTMLElement[];
|
||||
queryByPlaceholderText: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined) => HTMLElement | null;
|
||||
queryAllByPlaceholderText: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined) => HTMLElement[];
|
||||
findByPlaceholderText: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined) => Promise<HTMLElement>;
|
||||
findAllByPlaceholderText: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined) => Promise<HTMLElement[]>;
|
||||
getByText: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").SelectorMatcherOptions | undefined) => HTMLElement;
|
||||
getAllByText: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").SelectorMatcherOptions | undefined) => HTMLElement[];
|
||||
queryByText: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").SelectorMatcherOptions | undefined) => HTMLElement | null;
|
||||
queryAllByText: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").SelectorMatcherOptions | undefined) => HTMLElement[];
|
||||
findByText: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").SelectorMatcherOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined) => Promise<HTMLElement>;
|
||||
findAllByText: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").SelectorMatcherOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined) => Promise<HTMLElement[]>;
|
||||
getByAltText: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined) => HTMLElement;
|
||||
getAllByAltText: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined) => HTMLElement[];
|
||||
queryByAltText: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined) => HTMLElement | null;
|
||||
queryAllByAltText: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined) => HTMLElement[];
|
||||
findByAltText: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined) => Promise<HTMLElement>;
|
||||
findAllByAltText: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined) => Promise<HTMLElement[]>;
|
||||
getByTitle: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined) => HTMLElement;
|
||||
getAllByTitle: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined) => HTMLElement[];
|
||||
queryByTitle: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined) => HTMLElement | null;
|
||||
queryAllByTitle: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined) => HTMLElement[];
|
||||
findByTitle: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined) => Promise<HTMLElement>;
|
||||
findAllByTitle: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined) => Promise<HTMLElement[]>;
|
||||
getByDisplayValue: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined) => HTMLElement;
|
||||
getAllByDisplayValue: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined) => HTMLElement[];
|
||||
queryByDisplayValue: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined) => HTMLElement | null;
|
||||
queryAllByDisplayValue: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined) => HTMLElement[];
|
||||
findByDisplayValue: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined) => Promise<HTMLElement>;
|
||||
findAllByDisplayValue: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined) => Promise<HTMLElement[]>;
|
||||
getByRole: (role: import("@testing-library/dom").ByRoleMatcher, options?: import("@testing-library/dom").ByRoleOptions | undefined) => HTMLElement;
|
||||
getAllByRole: (role: import("@testing-library/dom").ByRoleMatcher, options?: import("@testing-library/dom").ByRoleOptions | undefined) => HTMLElement[];
|
||||
queryByRole: (role: import("@testing-library/dom").ByRoleMatcher, options?: import("@testing-library/dom").ByRoleOptions | undefined) => HTMLElement | null;
|
||||
queryAllByRole: (role: import("@testing-library/dom").ByRoleMatcher, options?: import("@testing-library/dom").ByRoleOptions | undefined) => HTMLElement[];
|
||||
findByRole: (role: import("@testing-library/dom").ByRoleMatcher, options?: import("@testing-library/dom").ByRoleOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined) => Promise<HTMLElement>;
|
||||
findAllByRole: (role: import("@testing-library/dom").ByRoleMatcher, options?: import("@testing-library/dom").ByRoleOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined) => Promise<HTMLElement[]>;
|
||||
getByTestId: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined) => HTMLElement;
|
||||
getAllByTestId: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined) => HTMLElement[];
|
||||
queryByTestId: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined) => HTMLElement | null;
|
||||
queryAllByTestId: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined) => HTMLElement[];
|
||||
findByTestId: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined) => Promise<HTMLElement>;
|
||||
findAllByTestId: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined) => Promise<HTMLElement[]>;
|
||||
} & {
|
||||
debug: (element?: Element | HTMLDocument | (Element | HTMLDocument)[] | undefined, maxLength?: number | undefined, options?: import("pretty-format").PrettyFormatOptions | undefined) => void;
|
||||
logTestingPlaygroundURL: (element?: Element | HTMLDocument | undefined) => void;
|
||||
};
|
||||
}
|
||||
/** @internal */
|
||||
export declare function errorOnDomInteraction(): void;
|
||||
export {};
|
||||
//# sourceMappingURL=Render.d.ts.map
|
||||
144
graphql-subscription/node_modules/@apollo/client/testing/internal/profile/Render.js
generated
vendored
Normal file
144
graphql-subscription/node_modules/@apollo/client/testing/internal/profile/Render.js
generated
vendored
Normal file
@@ -0,0 +1,144 @@
|
||||
/* istanbul ignore file */
|
||||
import { __spreadArray } from "tslib";
|
||||
/*
|
||||
Something in this file does not compile correctly while measuring code coverage
|
||||
and will lead to a
|
||||
Uncaught [ReferenceError: cov_1zb8w312au is not defined]
|
||||
if we do not ignore this file in code coverage.
|
||||
|
||||
As we only use this file in our internal tests, we can safely ignore it.
|
||||
*/
|
||||
import { within, screen } from "@testing-library/dom";
|
||||
import { JSDOM, VirtualConsole } from "jsdom";
|
||||
import { applyStackTrace, captureStackTrace } from "./traces.js";
|
||||
/** @internal */
|
||||
var RenderInstance = /** @class */ (function () {
|
||||
function RenderInstance(baseRender, snapshot, stringifiedDOM, renderedComponents) {
|
||||
this.snapshot = snapshot;
|
||||
this.stringifiedDOM = stringifiedDOM;
|
||||
this.renderedComponents = renderedComponents;
|
||||
this.id = baseRender.id;
|
||||
this.phase = baseRender.phase;
|
||||
this.actualDuration = baseRender.actualDuration;
|
||||
this.baseDuration = baseRender.baseDuration;
|
||||
this.startTime = baseRender.startTime;
|
||||
this.commitTime = baseRender.commitTime;
|
||||
this.count = baseRender.count;
|
||||
}
|
||||
Object.defineProperty(RenderInstance.prototype, "domSnapshot", {
|
||||
get: function () {
|
||||
if (this._domSnapshot)
|
||||
return this._domSnapshot;
|
||||
if (!this.stringifiedDOM) {
|
||||
throw new Error("DOM snapshot is not available - please set the `snapshotDOM` option");
|
||||
}
|
||||
var virtualConsole = new VirtualConsole();
|
||||
var stackTrace = captureStackTrace("RenderInstance.get");
|
||||
virtualConsole.on("jsdomError", function (error) {
|
||||
throw applyStackTrace(error, stackTrace);
|
||||
});
|
||||
var snapDOM = new JSDOM(this.stringifiedDOM, {
|
||||
runScripts: "dangerously",
|
||||
virtualConsole: virtualConsole,
|
||||
});
|
||||
var document = snapDOM.window.document;
|
||||
var body = document.body;
|
||||
var script = document.createElement("script");
|
||||
script.type = "text/javascript";
|
||||
script.text = "\n ".concat(errorOnDomInteraction.toString(), ";\n ").concat(errorOnDomInteraction.name, "();\n ");
|
||||
body.appendChild(script);
|
||||
body.removeChild(script);
|
||||
return (this._domSnapshot = body);
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(RenderInstance.prototype, "withinDOM", {
|
||||
get: function () {
|
||||
var _this = this;
|
||||
var snapScreen = Object.assign(within(this.domSnapshot), {
|
||||
debug: function () {
|
||||
var _a = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
_a[_i] = arguments[_i];
|
||||
}
|
||||
var _b = _a[0], dom = _b === void 0 ? _this.domSnapshot : _b, rest = _a.slice(1);
|
||||
screen.debug.apply(screen, __spreadArray([dom], rest, false));
|
||||
},
|
||||
logTestingPlaygroundURL: function () {
|
||||
var _a = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
_a[_i] = arguments[_i];
|
||||
}
|
||||
var _b = _a[0], dom = _b === void 0 ? _this.domSnapshot : _b, rest = _a.slice(1);
|
||||
screen.logTestingPlaygroundURL.apply(screen, __spreadArray([dom], rest, false));
|
||||
},
|
||||
});
|
||||
return function () { return snapScreen; };
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
return RenderInstance;
|
||||
}());
|
||||
export { RenderInstance };
|
||||
/** @internal */
|
||||
export function errorOnDomInteraction() {
|
||||
var events = [
|
||||
"auxclick",
|
||||
"blur",
|
||||
"change",
|
||||
"click",
|
||||
"copy",
|
||||
"cut",
|
||||
"dblclick",
|
||||
"drag",
|
||||
"dragend",
|
||||
"dragenter",
|
||||
"dragleave",
|
||||
"dragover",
|
||||
"dragstart",
|
||||
"drop",
|
||||
"focus",
|
||||
"focusin",
|
||||
"focusout",
|
||||
"input",
|
||||
"keydown",
|
||||
"keypress",
|
||||
"keyup",
|
||||
"mousedown",
|
||||
"mouseenter",
|
||||
"mouseleave",
|
||||
"mousemove",
|
||||
"mouseout",
|
||||
"mouseover",
|
||||
"mouseup",
|
||||
"paste",
|
||||
"pointercancel",
|
||||
"pointerdown",
|
||||
"pointerenter",
|
||||
"pointerleave",
|
||||
"pointermove",
|
||||
"pointerout",
|
||||
"pointerover",
|
||||
"pointerup",
|
||||
"scroll",
|
||||
"select",
|
||||
"selectionchange",
|
||||
"selectstart",
|
||||
"submit",
|
||||
"toggle",
|
||||
"touchcancel",
|
||||
"touchend",
|
||||
"touchmove",
|
||||
"touchstart",
|
||||
"wheel",
|
||||
];
|
||||
function warnOnDomInteraction() {
|
||||
throw new Error("\n DOM interaction with a snapshot detected in test.\n Please don't interact with the DOM you get from `withinDOM`,\n but still use `screen' to get elements for simulating user interaction.\n ");
|
||||
}
|
||||
events.forEach(function (event) {
|
||||
document.addEventListener(event, warnOnDomInteraction);
|
||||
});
|
||||
}
|
||||
//# sourceMappingURL=Render.js.map
|
||||
1
graphql-subscription/node_modules/@apollo/client/testing/internal/profile/Render.js.map
generated
vendored
Normal file
1
graphql-subscription/node_modules/@apollo/client/testing/internal/profile/Render.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
10
graphql-subscription/node_modules/@apollo/client/testing/internal/profile/context.d.ts
generated
vendored
Normal file
10
graphql-subscription/node_modules/@apollo/client/testing/internal/profile/context.d.ts
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import * as React from "react";
|
||||
export interface ProfilerContextValue {
|
||||
renderedComponents: Array<React.ComponentType | string>;
|
||||
}
|
||||
export declare function ProfilerContextProvider({ children, value, }: {
|
||||
children: React.ReactNode;
|
||||
value: ProfilerContextValue;
|
||||
}): React.JSX.Element;
|
||||
export declare function useProfilerContext(): ProfilerContextValue | undefined;
|
||||
//# sourceMappingURL=context.d.ts.map
|
||||
14
graphql-subscription/node_modules/@apollo/client/testing/internal/profile/context.js
generated
vendored
Normal file
14
graphql-subscription/node_modules/@apollo/client/testing/internal/profile/context.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
import * as React from "react";
|
||||
var ProfilerContext = React.createContext(undefined);
|
||||
export function ProfilerContextProvider(_a) {
|
||||
var children = _a.children, value = _a.value;
|
||||
var parentContext = useProfilerContext();
|
||||
if (parentContext) {
|
||||
throw new Error("Profilers should not be nested in the same tree");
|
||||
}
|
||||
return (React.createElement(ProfilerContext.Provider, { value: value }, children));
|
||||
}
|
||||
export function useProfilerContext() {
|
||||
return React.useContext(ProfilerContext);
|
||||
}
|
||||
//# sourceMappingURL=context.js.map
|
||||
1
graphql-subscription/node_modules/@apollo/client/testing/internal/profile/context.js.map
generated
vendored
Normal file
1
graphql-subscription/node_modules/@apollo/client/testing/internal/profile/context.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../../src/testing/internal/profile/context.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAM/B,IAAM,eAAe,GAAG,KAAK,CAAC,aAAa,CACzC,SAAS,CACV,CAAC;AAEF,MAAM,UAAU,uBAAuB,CAAC,EAMvC;QALC,QAAQ,cAAA,EACR,KAAK,WAAA;IAKL,IAAM,aAAa,GAAG,kBAAkB,EAAE,CAAC;IAE3C,IAAI,aAAa,EAAE,CAAC;QAClB,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;IACrE,CAAC;IAED,OAAO,CACL,oBAAC,eAAe,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,IACnC,QAAQ,CACgB,CAC5B,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,kBAAkB;IAChC,OAAO,KAAK,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC;AAC3C,CAAC","sourcesContent":["import * as React from \"react\";\n\nexport interface ProfilerContextValue {\n renderedComponents: Array<React.ComponentType | string>;\n}\n\nconst ProfilerContext = React.createContext<ProfilerContextValue | undefined>(\n undefined\n);\n\nexport function ProfilerContextProvider({\n children,\n value,\n}: {\n children: React.ReactNode;\n value: ProfilerContextValue;\n}) {\n const parentContext = useProfilerContext();\n\n if (parentContext) {\n throw new Error(\"Profilers should not be nested in the same tree\");\n }\n\n return (\n <ProfilerContext.Provider value={value}>\n {children}\n </ProfilerContext.Provider>\n );\n}\n\nexport function useProfilerContext() {\n return React.useContext(ProfilerContext);\n}\n"]}
|
||||
4
graphql-subscription/node_modules/@apollo/client/testing/internal/profile/index.d.ts
generated
vendored
Normal file
4
graphql-subscription/node_modules/@apollo/client/testing/internal/profile/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
export type { NextRenderOptions, Profiler, ProfiledComponent, ProfiledHook, } from "./profile.js";
|
||||
export { createProfiler, profile, profileHook, useTrackRenders, WaitForRenderTimeoutError, } from "./profile.js";
|
||||
export type { SyncScreen } from "./Render.js";
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
2
graphql-subscription/node_modules/@apollo/client/testing/internal/profile/index.js
generated
vendored
Normal file
2
graphql-subscription/node_modules/@apollo/client/testing/internal/profile/index.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export { createProfiler, profile, profileHook, useTrackRenders, WaitForRenderTimeoutError, } from "./profile.js";
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
graphql-subscription/node_modules/@apollo/client/testing/internal/profile/index.js.map
generated
vendored
Normal file
1
graphql-subscription/node_modules/@apollo/client/testing/internal/profile/index.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/testing/internal/profile/index.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,cAAc,EACd,OAAO,EACP,WAAW,EACX,eAAe,EACf,yBAAyB,GAC1B,MAAM,cAAc,CAAC","sourcesContent":["export type {\n NextRenderOptions,\n Profiler,\n ProfiledComponent,\n ProfiledHook,\n} from \"./profile.js\";\nexport {\n createProfiler,\n profile,\n profileHook,\n useTrackRenders,\n WaitForRenderTimeoutError,\n} from \"./profile.js\";\n\nexport type { SyncScreen } from \"./Render.js\";\n"]}
|
||||
109
graphql-subscription/node_modules/@apollo/client/testing/internal/profile/profile.d.ts
generated
vendored
Normal file
109
graphql-subscription/node_modules/@apollo/client/testing/internal/profile/profile.d.ts
generated
vendored
Normal file
@@ -0,0 +1,109 @@
|
||||
import * as React from "react";
|
||||
import type { Render, BaseRender } from "./Render.js";
|
||||
type ValidSnapshot = void | (object & {
|
||||
call?: never;
|
||||
});
|
||||
/** only used for passing around data internally */
|
||||
declare const _stackTrace: unique symbol;
|
||||
/** @internal */
|
||||
export interface NextRenderOptions {
|
||||
timeout?: number;
|
||||
[_stackTrace]?: string;
|
||||
}
|
||||
/** @internal */
|
||||
interface ProfilerProps {
|
||||
children: React.ReactNode;
|
||||
}
|
||||
/** @internal */
|
||||
export interface Profiler<Snapshot> extends React.FC<ProfilerProps>, ProfiledComponentFields<Snapshot>, ProfiledComponentOnlyFields<Snapshot> {
|
||||
}
|
||||
interface ReplaceSnapshot<Snapshot> {
|
||||
(newSnapshot: Snapshot): void;
|
||||
(updateSnapshot: (lastSnapshot: Readonly<Snapshot>) => Snapshot): void;
|
||||
}
|
||||
interface MergeSnapshot<Snapshot> {
|
||||
(partialSnapshot: Partial<Snapshot>): void;
|
||||
(updatePartialSnapshot: (lastSnapshot: Readonly<Snapshot>) => Partial<Snapshot>): void;
|
||||
}
|
||||
interface ProfiledComponentOnlyFields<Snapshot> {
|
||||
mergeSnapshot: MergeSnapshot<Snapshot>;
|
||||
replaceSnapshot: ReplaceSnapshot<Snapshot>;
|
||||
}
|
||||
interface ProfiledComponentFields<Snapshot> {
|
||||
/**
|
||||
* An array of all renders that have happened so far.
|
||||
* Errors thrown during component render will be captured here, too.
|
||||
*/
|
||||
renders: Array<Render<Snapshot> | {
|
||||
phase: "snapshotError";
|
||||
count: number;
|
||||
error: unknown;
|
||||
}>;
|
||||
/**
|
||||
* Peeks the next render from the current iterator position, without advancing the iterator.
|
||||
* If no render has happened yet, it will wait for the next render to happen.
|
||||
* @throws {WaitForRenderTimeoutError} if no render happens within the timeout
|
||||
*/
|
||||
peekRender(options?: NextRenderOptions): Promise<Render<Snapshot>>;
|
||||
/**
|
||||
* Iterates to the next render and returns it.
|
||||
* If no render has happened yet, it will wait for the next render to happen.
|
||||
* @throws {WaitForRenderTimeoutError} if no render happens within the timeout
|
||||
*/
|
||||
takeRender(options?: NextRenderOptions): Promise<Render<Snapshot>>;
|
||||
/**
|
||||
* Returns the total number of renders.
|
||||
*/
|
||||
totalRenderCount(): number;
|
||||
/**
|
||||
* Returns the current render.
|
||||
* @throws {Error} if no render has happened yet
|
||||
*/
|
||||
getCurrentRender(): Render<Snapshot>;
|
||||
/**
|
||||
* Waits for the next render to happen.
|
||||
* Does not advance the render iterator.
|
||||
*/
|
||||
waitForNextRender(options?: NextRenderOptions): Promise<Render<Snapshot>>;
|
||||
}
|
||||
export interface ProfiledComponent<Snapshot extends ValidSnapshot, Props = {}> extends React.FC<Props>, ProfiledComponentFields<Snapshot>, ProfiledComponentOnlyFields<Snapshot> {
|
||||
}
|
||||
/** @internal */
|
||||
export declare function profile<Snapshot extends ValidSnapshot = void, Props = {}>({ Component, ...options }: Parameters<typeof createProfiler<Snapshot>>[0] & {
|
||||
Component: React.ComponentType<Props>;
|
||||
}): ProfiledComponent<Snapshot, Props>;
|
||||
/** @internal */
|
||||
export declare function createProfiler<Snapshot extends ValidSnapshot = void>({ onRender, snapshotDOM, initialSnapshot, skipNonTrackingRenders, }?: {
|
||||
onRender?: (info: BaseRender & {
|
||||
snapshot: Snapshot;
|
||||
replaceSnapshot: ReplaceSnapshot<Snapshot>;
|
||||
mergeSnapshot: MergeSnapshot<Snapshot>;
|
||||
}) => void;
|
||||
snapshotDOM?: boolean;
|
||||
initialSnapshot?: Snapshot;
|
||||
/**
|
||||
* This will skip renders during which no renders tracked by
|
||||
* `useTrackRenders` occured.
|
||||
*/
|
||||
skipNonTrackingRenders?: boolean;
|
||||
}): Profiler<Snapshot>;
|
||||
/** @internal */
|
||||
export declare class WaitForRenderTimeoutError extends Error {
|
||||
constructor();
|
||||
}
|
||||
type StringReplaceRenderWithSnapshot<T extends string> = T extends `${infer Pre}Render${infer Post}` ? `${Pre}Snapshot${Post}` : T;
|
||||
type ResultReplaceRenderWithSnapshot<T> = T extends (...args: infer Args) => Render<infer Snapshot> ? (...args: Args) => Snapshot : T extends (...args: infer Args) => Promise<Render<infer Snapshot>> ? (...args: Args) => Promise<Snapshot> : T;
|
||||
type ProfiledHookFields<ReturnValue> = ProfiledComponentFields<ReturnValue> extends infer PC ? {
|
||||
[K in keyof PC as StringReplaceRenderWithSnapshot<K & string>]: ResultReplaceRenderWithSnapshot<PC[K]>;
|
||||
} : never;
|
||||
/** @internal */
|
||||
export interface ProfiledHook<Props, ReturnValue> extends React.FC<Props>, ProfiledHookFields<ReturnValue> {
|
||||
Profiler: Profiler<ReturnValue>;
|
||||
}
|
||||
/** @internal */
|
||||
export declare function profileHook<ReturnValue extends ValidSnapshot, Props>(renderCallback: (props: Props) => ReturnValue): ProfiledHook<Props, ReturnValue>;
|
||||
export declare function useTrackRenders({ name }?: {
|
||||
name?: string;
|
||||
}): void;
|
||||
export {};
|
||||
//# sourceMappingURL=profile.d.ts.map
|
||||
296
graphql-subscription/node_modules/@apollo/client/testing/internal/profile/profile.js
generated
vendored
Normal file
296
graphql-subscription/node_modules/@apollo/client/testing/internal/profile/profile.js
generated
vendored
Normal file
@@ -0,0 +1,296 @@
|
||||
var _a, _b;
|
||||
import { __addDisposableResource, __assign, __awaiter, __disposeResources, __extends, __generator, __rest } from "tslib";
|
||||
import * as React from "react";
|
||||
import { TextEncoder, TextDecoder } from "util";
|
||||
(_a = global.TextEncoder) !== null && _a !== void 0 ? _a : (global.TextEncoder = TextEncoder);
|
||||
// @ts-ignore
|
||||
(_b = global.TextDecoder) !== null && _b !== void 0 ? _b : (global.TextDecoder = TextDecoder);
|
||||
import { RenderInstance } from "./Render.js";
|
||||
import { applyStackTrace, captureStackTrace } from "./traces.js";
|
||||
import { ProfilerContextProvider, useProfilerContext } from "./context.js";
|
||||
import { disableActWarnings } from "../disposables/index.js";
|
||||
/** only used for passing around data internally */
|
||||
var _stackTrace = Symbol();
|
||||
/** @internal */
|
||||
export function profile(_a) {
|
||||
var Component = _a.Component, options = __rest(_a, ["Component"]);
|
||||
var Profiler = createProfiler(options);
|
||||
return Object.assign(function ProfiledComponent(props) {
|
||||
return (React.createElement(Profiler, null,
|
||||
React.createElement(Component, __assign({}, props))));
|
||||
}, {
|
||||
mergeSnapshot: Profiler.mergeSnapshot,
|
||||
replaceSnapshot: Profiler.replaceSnapshot,
|
||||
getCurrentRender: Profiler.getCurrentRender,
|
||||
peekRender: Profiler.peekRender,
|
||||
takeRender: Profiler.takeRender,
|
||||
totalRenderCount: Profiler.totalRenderCount,
|
||||
waitForNextRender: Profiler.waitForNextRender,
|
||||
get renders() {
|
||||
return Profiler.renders;
|
||||
},
|
||||
});
|
||||
}
|
||||
/** @internal */
|
||||
export function createProfiler(_a) {
|
||||
var _b = _a === void 0 ? {} : _a, onRender = _b.onRender, _c = _b.snapshotDOM, snapshotDOM = _c === void 0 ? false : _c, initialSnapshot = _b.initialSnapshot, skipNonTrackingRenders = _b.skipNonTrackingRenders;
|
||||
var nextRender;
|
||||
var resolveNextRender;
|
||||
var rejectNextRender;
|
||||
var snapshotRef = { current: initialSnapshot };
|
||||
var replaceSnapshot = function (snap) {
|
||||
if (typeof snap === "function") {
|
||||
if (!initialSnapshot) {
|
||||
throw new Error("Cannot use a function to update the snapshot if no initial snapshot was provided.");
|
||||
}
|
||||
snapshotRef.current = snap(typeof snapshotRef.current === "object" ? __assign({}, snapshotRef.current) : snapshotRef.current);
|
||||
}
|
||||
else {
|
||||
snapshotRef.current = snap;
|
||||
}
|
||||
};
|
||||
var mergeSnapshot = function (partialSnapshot) {
|
||||
replaceSnapshot(function (snapshot) { return (__assign(__assign({}, snapshot), (typeof partialSnapshot === "function" ?
|
||||
partialSnapshot(snapshot)
|
||||
: partialSnapshot))); });
|
||||
};
|
||||
var profilerContext = {
|
||||
renderedComponents: [],
|
||||
};
|
||||
var profilerOnRender = function (id, phase, actualDuration, baseDuration, startTime, commitTime) {
|
||||
if (skipNonTrackingRenders &&
|
||||
profilerContext.renderedComponents.length === 0) {
|
||||
return;
|
||||
}
|
||||
var baseRender = {
|
||||
id: id,
|
||||
phase: phase,
|
||||
actualDuration: actualDuration,
|
||||
baseDuration: baseDuration,
|
||||
startTime: startTime,
|
||||
commitTime: commitTime,
|
||||
count: Profiler.renders.length + 1,
|
||||
};
|
||||
try {
|
||||
/*
|
||||
* The `onRender` function could contain `expect` calls that throw
|
||||
* `JestAssertionError`s - but we are still inside of React, where errors
|
||||
* might be swallowed.
|
||||
* So we record them and re-throw them in `takeRender`
|
||||
* Additionally, we reject the `waitForNextRender` promise.
|
||||
*/
|
||||
onRender === null || onRender === void 0 ? void 0 : onRender(__assign(__assign({}, baseRender), { replaceSnapshot: replaceSnapshot, mergeSnapshot: mergeSnapshot, snapshot: snapshotRef.current }));
|
||||
var snapshot = snapshotRef.current;
|
||||
var domSnapshot = snapshotDOM ? window.document.body.innerHTML : undefined;
|
||||
var render = new RenderInstance(baseRender, snapshot, domSnapshot, profilerContext.renderedComponents);
|
||||
profilerContext.renderedComponents = [];
|
||||
Profiler.renders.push(render);
|
||||
resolveNextRender === null || resolveNextRender === void 0 ? void 0 : resolveNextRender(render);
|
||||
}
|
||||
catch (error) {
|
||||
Profiler.renders.push({
|
||||
phase: "snapshotError",
|
||||
count: Profiler.renders.length,
|
||||
error: error,
|
||||
});
|
||||
rejectNextRender === null || rejectNextRender === void 0 ? void 0 : rejectNextRender(error);
|
||||
}
|
||||
finally {
|
||||
nextRender = resolveNextRender = rejectNextRender = undefined;
|
||||
}
|
||||
};
|
||||
var iteratorPosition = 0;
|
||||
var Profiler = Object.assign(function (_a) {
|
||||
var children = _a.children;
|
||||
return (React.createElement(ProfilerContextProvider, { value: profilerContext },
|
||||
React.createElement(React.Profiler, { id: "test", onRender: profilerOnRender }, children)));
|
||||
}, {
|
||||
replaceSnapshot: replaceSnapshot,
|
||||
mergeSnapshot: mergeSnapshot,
|
||||
}, {
|
||||
renders: new Array(),
|
||||
totalRenderCount: function () {
|
||||
return Profiler.renders.length;
|
||||
},
|
||||
peekRender: function (options) {
|
||||
if (options === void 0) { options = {}; }
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var render;
|
||||
var _a;
|
||||
return __generator(this, function (_b) {
|
||||
if (iteratorPosition < Profiler.renders.length) {
|
||||
render = Profiler.renders[iteratorPosition];
|
||||
if (render.phase === "snapshotError") {
|
||||
throw render.error;
|
||||
}
|
||||
return [2 /*return*/, render];
|
||||
}
|
||||
return [2 /*return*/, Profiler.waitForNextRender(__assign((_a = {}, _a[_stackTrace] = captureStackTrace(Profiler.peekRender), _a), options))];
|
||||
});
|
||||
});
|
||||
},
|
||||
takeRender: function (options) {
|
||||
if (options === void 0) { options = {}; }
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var env_1, _disabledActWarnings, error, e_1, e_2;
|
||||
var _a;
|
||||
return __generator(this, function (_b) {
|
||||
switch (_b.label) {
|
||||
case 0:
|
||||
env_1 = { stack: [], error: void 0, hasError: false };
|
||||
_b.label = 1;
|
||||
case 1:
|
||||
_b.trys.push([1, 7, 8, 9]);
|
||||
_disabledActWarnings = __addDisposableResource(env_1, disableActWarnings(), false);
|
||||
error = undefined;
|
||||
_b.label = 2;
|
||||
case 2:
|
||||
_b.trys.push([2, 4, 5, 6]);
|
||||
return [4 /*yield*/, Profiler.peekRender(__assign((_a = {}, _a[_stackTrace] = captureStackTrace(Profiler.takeRender), _a), options))];
|
||||
case 3: return [2 /*return*/, _b.sent()];
|
||||
case 4:
|
||||
e_1 = _b.sent();
|
||||
error = e_1;
|
||||
throw e_1;
|
||||
case 5:
|
||||
if (!(error && error instanceof WaitForRenderTimeoutError)) {
|
||||
iteratorPosition++;
|
||||
}
|
||||
return [7 /*endfinally*/];
|
||||
case 6: return [3 /*break*/, 9];
|
||||
case 7:
|
||||
e_2 = _b.sent();
|
||||
env_1.error = e_2;
|
||||
env_1.hasError = true;
|
||||
return [3 /*break*/, 9];
|
||||
case 8:
|
||||
__disposeResources(env_1);
|
||||
return [7 /*endfinally*/];
|
||||
case 9: return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
getCurrentRender: function () {
|
||||
// The "current" render should point at the same render that the most
|
||||
// recent `takeRender` call returned, so we need to get the "previous"
|
||||
// iterator position, otherwise `takeRender` advances the iterator
|
||||
// to the next render. This means we need to call `takeRender` at least
|
||||
// once before we can get a current render.
|
||||
var currentPosition = iteratorPosition - 1;
|
||||
if (currentPosition < 0) {
|
||||
throw new Error("No current render available. You need to call `takeRender` before you can get the current render.");
|
||||
}
|
||||
var render = Profiler.renders[currentPosition];
|
||||
if (render.phase === "snapshotError") {
|
||||
throw render.error;
|
||||
}
|
||||
return render;
|
||||
},
|
||||
waitForNextRender: function (_a) {
|
||||
var _b = _a === void 0 ? {} : _a, _c = _b.timeout, timeout = _c === void 0 ? 1000 : _c,
|
||||
// capture the stack trace here so its stack trace is as close to the calling code as possible
|
||||
_d = _stackTrace,
|
||||
// capture the stack trace here so its stack trace is as close to the calling code as possible
|
||||
_e = _b[_d],
|
||||
// capture the stack trace here so its stack trace is as close to the calling code as possible
|
||||
stackTrace = _e === void 0 ? captureStackTrace(Profiler.waitForNextRender) : _e;
|
||||
if (!nextRender) {
|
||||
nextRender = Promise.race([
|
||||
new Promise(function (resolve, reject) {
|
||||
resolveNextRender = resolve;
|
||||
rejectNextRender = reject;
|
||||
}),
|
||||
new Promise(function (_, reject) {
|
||||
return setTimeout(function () {
|
||||
return reject(applyStackTrace(new WaitForRenderTimeoutError(), stackTrace));
|
||||
}, timeout);
|
||||
}),
|
||||
]);
|
||||
}
|
||||
return nextRender;
|
||||
},
|
||||
});
|
||||
return Profiler;
|
||||
}
|
||||
/** @internal */
|
||||
var WaitForRenderTimeoutError = /** @class */ (function (_super) {
|
||||
__extends(WaitForRenderTimeoutError, _super);
|
||||
function WaitForRenderTimeoutError() {
|
||||
var _newTarget = this.constructor;
|
||||
var _this = _super.call(this, "Exceeded timeout waiting for next render.") || this;
|
||||
Object.setPrototypeOf(_this, _newTarget.prototype);
|
||||
return _this;
|
||||
}
|
||||
return WaitForRenderTimeoutError;
|
||||
}(Error));
|
||||
export { WaitForRenderTimeoutError };
|
||||
/** @internal */
|
||||
export function profileHook(renderCallback) {
|
||||
var Profiler = createProfiler();
|
||||
var ProfiledHook = function (props) {
|
||||
Profiler.replaceSnapshot(renderCallback(props));
|
||||
return null;
|
||||
};
|
||||
return Object.assign(function App(props) {
|
||||
return (React.createElement(Profiler, null,
|
||||
React.createElement(ProfiledHook, __assign({}, props))));
|
||||
}, {
|
||||
Profiler: Profiler,
|
||||
}, {
|
||||
renders: Profiler.renders,
|
||||
totalSnapshotCount: Profiler.totalRenderCount,
|
||||
peekSnapshot: function (options) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0: return [4 /*yield*/, Profiler.peekRender(options)];
|
||||
case 1: return [2 /*return*/, (_a.sent()).snapshot];
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
takeSnapshot: function (options) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0: return [4 /*yield*/, Profiler.takeRender(options)];
|
||||
case 1: return [2 /*return*/, (_a.sent()).snapshot];
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
getCurrentSnapshot: function () {
|
||||
return Profiler.getCurrentRender().snapshot;
|
||||
},
|
||||
waitForNextSnapshot: function (options) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0: return [4 /*yield*/, Profiler.waitForNextRender(options)];
|
||||
case 1: return [2 /*return*/, (_a.sent()).snapshot];
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
function resolveHookOwner() {
|
||||
var _a, _b, _c;
|
||||
return (_c = (_b = (_a = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED) === null || _a === void 0 ? void 0 : _a.ReactCurrentOwner) === null || _b === void 0 ? void 0 : _b.current) === null || _c === void 0 ? void 0 : _c.elementType;
|
||||
}
|
||||
export function useTrackRenders(_a) {
|
||||
var _b = _a === void 0 ? {} : _a, name = _b.name;
|
||||
var component = name || resolveHookOwner();
|
||||
if (!component) {
|
||||
throw new Error("useTrackRender: Unable to determine component. Please ensure the hook is called inside a rendered component or provide a `name` option.");
|
||||
}
|
||||
var ctx = useProfilerContext();
|
||||
if (!ctx) {
|
||||
throw new Error("useTrackComponentRender: A Profiler must be created and rendered to track component renders");
|
||||
}
|
||||
React.useLayoutEffect(function () {
|
||||
ctx.renderedComponents.unshift(component);
|
||||
});
|
||||
}
|
||||
//# sourceMappingURL=profile.js.map
|
||||
1
graphql-subscription/node_modules/@apollo/client/testing/internal/profile/profile.js.map
generated
vendored
Normal file
1
graphql-subscription/node_modules/@apollo/client/testing/internal/profile/profile.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
7
graphql-subscription/node_modules/@apollo/client/testing/internal/profile/traces.d.ts
generated
vendored
Normal file
7
graphql-subscription/node_modules/@apollo/client/testing/internal/profile/traces.d.ts
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
/**
|
||||
* Captures a StackTrace and (if passed) cuts off
|
||||
* the first lines including the calling function.
|
||||
*/
|
||||
export declare function captureStackTrace(callingFunction?: string | (() => {})): string;
|
||||
export declare function applyStackTrace(error: Error, stackTrace: string): Error;
|
||||
//# sourceMappingURL=traces.d.ts.map
|
||||
30
graphql-subscription/node_modules/@apollo/client/testing/internal/profile/traces.js
generated
vendored
Normal file
30
graphql-subscription/node_modules/@apollo/client/testing/internal/profile/traces.js
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* Captures a StackTrace and (if passed) cuts off
|
||||
* the first lines including the calling function.
|
||||
*/
|
||||
export function captureStackTrace(callingFunction) {
|
||||
var stack = "";
|
||||
try {
|
||||
throw new Error("");
|
||||
}
|
||||
catch (e) {
|
||||
(stack = e.stack);
|
||||
}
|
||||
var callerName = typeof callingFunction === "string" ? callingFunction
|
||||
: callingFunction ? callingFunction.name
|
||||
: undefined;
|
||||
if (callerName && stack.includes(callerName)) {
|
||||
var lines = stack.split("\n");
|
||||
stack = lines
|
||||
.slice(
|
||||
// @ts-expect-error this is too old of a TS target, but node has it
|
||||
lines.findLastIndex(function (line) { return line.includes(callerName); }) + 1)
|
||||
.join("\n");
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
export function applyStackTrace(error, stackTrace) {
|
||||
error.stack = error.message + "\n" + stackTrace;
|
||||
return error;
|
||||
}
|
||||
//# sourceMappingURL=traces.js.map
|
||||
1
graphql-subscription/node_modules/@apollo/client/testing/internal/profile/traces.js.map
generated
vendored
Normal file
1
graphql-subscription/node_modules/@apollo/client/testing/internal/profile/traces.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"traces.js","sourceRoot":"","sources":["../../../../src/testing/internal/profile/traces.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,eAAqC;IACrE,IAAI,KAAK,GAAG,EAAE,CAAC;IACf,IAAI,CAAC;QACH,MAAM,IAAI,KAAK,CAAC,EAAE,CAAC,CAAC;IACtB,CAAC;IAAC,OAAO,CAAM,EAAE,CAAC;QAChB,CAAG,KAAK,GAAK,CAAC,MAAN,CAAO,CAAC;IAClB,CAAC;IAED,IAAM,UAAU,GACd,OAAO,eAAe,KAAK,QAAQ,CAAC,CAAC,CAAC,eAAe;QACrD,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,eAAe,CAAC,IAAI;YACxC,CAAC,CAAC,SAAS,CAAC;IAEd,IAAI,UAAU,IAAI,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;QAC7C,IAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAEhC,KAAK,GAAG,KAAK;aACV,KAAK;QACJ,mEAAmE;QACnE,KAAK,CAAC,aAAa,CAAC,UAAC,IAAY,IAAK,OAAA,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAzB,CAAyB,CAAC,GAAG,CAAC,CACrE;aACA,IAAI,CAAC,IAAI,CAAC,CAAC;IAChB,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,KAAY,EAAE,UAAkB;IAC9D,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,OAAO,GAAG,IAAI,GAAG,UAAU,CAAC;IAChD,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["/**\n * Captures a StackTrace and (if passed) cuts off\n * the first lines including the calling function.\n */\nexport function captureStackTrace(callingFunction?: string | (() => {})) {\n let stack = \"\";\n try {\n throw new Error(\"\");\n } catch (e: any) {\n ({ stack } = e);\n }\n\n const callerName =\n typeof callingFunction === \"string\" ? callingFunction\n : callingFunction ? callingFunction.name\n : undefined;\n\n if (callerName && stack.includes(callerName)) {\n const lines = stack.split(\"\\n\");\n\n stack = lines\n .slice(\n // @ts-expect-error this is too old of a TS target, but node has it\n lines.findLastIndex((line: string) => line.includes(callerName)) + 1\n )\n .join(\"\\n\");\n }\n\n return stack;\n}\n\nexport function applyStackTrace(error: Error, stackTrace: string) {\n error.stack = error.message + \"\\n\" + stackTrace;\n return error;\n}\n"]}
|
||||
Reference in New Issue
Block a user