@tstdl/base 0.84.3 → 0.84.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.eslintrc.json CHANGED
@@ -24,10 +24,6 @@
24
24
  },
25
25
  "plugins": ["@typescript-eslint"],
26
26
  "rules": {
27
- /** angular */
28
- "@angular-eslint/template/eqeqeq": "off",
29
- "@angular-eslint/no-host-metadata-property": ["error", { "allowStatic": true }],
30
-
31
27
  /** typescript */
32
28
  "@typescript-eslint/brace-style": ["error", "stroustrup", { "allowSingleLine": true }],
33
29
  "@typescript-eslint/consistent-type-definitions": "off",
@@ -0,0 +1,26 @@
1
+ import type { ElementHandle, Frame, Page } from 'playwright';
2
+ import type { Delay } from './element-controller.js';
3
+ import type { FrameController, FrameControllerOptions } from './frame-controller.js';
4
+ import { LocatorController } from './locator-controller.js';
5
+ import type { PageControllerOptions } from './page-controller.js';
6
+ export type DocumentControllerOptions = {
7
+ defaultActionDelay?: Delay;
8
+ defaultTypeDelay?: Delay;
9
+ };
10
+ export type DocumentControllerForwardOptions = {
11
+ pageControllerOptions: PageControllerOptions;
12
+ frameControllerOptions: FrameControllerOptions;
13
+ };
14
+ export declare class DocumentController extends LocatorController {
15
+ protected readonly forwardOptions: DocumentControllerForwardOptions;
16
+ /** @deprecated should be avoided */
17
+ readonly document: Page | Frame;
18
+ constructor(document: Page | Frame, options: DocumentControllerOptions, forwardOptions: DocumentControllerForwardOptions);
19
+ setContent(...args: Parameters<Page['setContent']>): Promise<void>;
20
+ navigate(...args: Parameters<Page['goto']>): Promise<void>;
21
+ waitForLoadState(...args: Parameters<Page['waitForLoadState']>): Promise<void>;
22
+ waitForUrl(...args: Parameters<Page['waitForURL']>): Promise<void>;
23
+ waitForElement(selector: string, options?: Parameters<Page['waitForSelector']>[1]): Promise<ElementHandle>;
24
+ getInFrame(frameSelector: string): LocatorController;
25
+ waitForFrame(selector: string, options?: Parameters<Page['waitForSelector']>[1]): Promise<FrameController>;
26
+ }
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var document_controller_exports = {};
30
+ __export(document_controller_exports, {
31
+ DocumentController: () => DocumentController
32
+ });
33
+ module.exports = __toCommonJS(document_controller_exports);
34
+ var import_type_guards = require("../utils/type-guards.js");
35
+ var import_locator_controller = require("./locator-controller.js");
36
+ class DocumentController extends import_locator_controller.LocatorController {
37
+ forwardOptions;
38
+ /** @deprecated should be avoided */
39
+ document;
40
+ constructor(document, options, forwardOptions) {
41
+ super(document, { actionDelay: options.defaultActionDelay, typeDelay: options.defaultTypeDelay });
42
+ this.document = document;
43
+ this.forwardOptions = forwardOptions;
44
+ }
45
+ async setContent(...args) {
46
+ await this.document.setContent(...args);
47
+ }
48
+ async navigate(...args) {
49
+ await this.document.goto(...args);
50
+ }
51
+ async waitForLoadState(...args) {
52
+ await this.document.waitForLoadState(...args);
53
+ }
54
+ async waitForUrl(...args) {
55
+ await this.document.waitForURL(...args);
56
+ }
57
+ async waitForElement(selector, options) {
58
+ const element = await this.document.waitForSelector(selector, options);
59
+ if ((0, import_type_guards.isNull)(element)) {
60
+ throw new Error("Element not found.");
61
+ }
62
+ return element;
63
+ }
64
+ getInFrame(frameSelector) {
65
+ const locator = this.document.frameLocator(frameSelector);
66
+ return new import_locator_controller.LocatorController(locator, this.elementControllerOptions);
67
+ }
68
+ async waitForFrame(selector, options) {
69
+ const element = await this.waitForElement(selector, options);
70
+ const frame = await element.contentFrame();
71
+ if ((0, import_type_guards.isNull)(frame)) {
72
+ throw new Error("Element is not a frame.");
73
+ }
74
+ return newFrameController(frame, this.forwardOptions.frameControllerOptions, { pageControllerOptions: this.forwardOptions.pageControllerOptions });
75
+ }
76
+ }
77
+ let frameControllerConstructor;
78
+ async function newFrameController(...args) {
79
+ if ((0, import_type_guards.isUndefined)(frameControllerConstructor)) {
80
+ frameControllerConstructor = importFrameController();
81
+ void frameControllerConstructor.then((constructor) => frameControllerConstructor = constructor);
82
+ }
83
+ return new (await frameControllerConstructor)(...args);
84
+ }
85
+ async function importFrameController() {
86
+ const module2 = await import("./frame-controller.js");
87
+ return module2.FrameController;
88
+ }
@@ -1,7 +1,6 @@
1
+ import type { ElementHandle, Locator } from 'playwright';
1
2
  import type { Merge, NonUndefinable, TypedOmit } from '../types.js';
2
3
  import type { ValueOrProvider } from '../utils/value-or-provider.js';
3
- import type { ElementHandle, Locator } from 'playwright';
4
- import { PageController } from './page-controller.js';
5
4
  export type Delay = ValueOrProvider<number>;
6
5
  export type ActionDelayOptions = {
7
6
  actionDelay?: Delay;
@@ -19,19 +18,14 @@ export type ElementControllerOptions = {
19
18
  type LocatorOptions<K extends keyof Locator, I extends keyof Parameters<Locator[K]>> = NonUndefinable<Parameters<Locator[K]>[I]>;
20
19
  export declare class ElementController {
21
20
  readonly locatorOrHandle: Locator | ElementHandle;
22
- readonly pageController: PageController;
23
21
  readonly options: ElementControllerOptions;
24
- constructor(locatorOrHandle: Locator | ElementHandle, pageController: PageController, options?: ElementControllerOptions);
22
+ constructor(locatorOrHandle: Locator | ElementHandle, options?: ElementControllerOptions);
25
23
  waitFor(options?: Parameters<Locator['waitFor']>[0]): Promise<void>;
26
24
  fill(text: string, options?: Merge<LocatorOptions<'fill', 1>, ActionDelayOptions>): Promise<void>;
27
25
  type(text: string, options?: Merge<TypedOmit<LocatorOptions<'type', 1>, 'delay'>, ActionDelayOptions & TypeDelayOptions>): Promise<void>;
28
26
  selectOption(value: string | string[], options?: Merge<LocatorOptions<'selectOption', 1>, ActionDelayOptions>): Promise<void>;
29
27
  click(options?: Merge<TypedOmit<LocatorOptions<'click', 0>, 'delay'>, ActionDelayOptions & ClickDelayOptions>): Promise<void>;
30
28
  getValue(options?: LocatorOptions<'inputValue', 0>): Promise<string>;
31
- /**
32
- * Get PageController for element. Element must be a frame.
33
- */
34
- getPage(options?: LocatorOptions<'elementHandle', 0>): Promise<PageController>;
35
29
  private prepareAction;
36
30
  }
37
31
  export {};
@@ -24,15 +24,11 @@ module.exports = __toCommonJS(element_controller_exports);
24
24
  var import_timing = require("../utils/timing.js");
25
25
  var import_type_guards = require("../utils/type-guards.js");
26
26
  var import_value_or_provider = require("../utils/value-or-provider.js");
27
- var import_page_controller = require("./page-controller.js");
28
- var import_utils = require("./utils.js");
29
27
  class ElementController {
30
28
  locatorOrHandle;
31
- pageController;
32
29
  options;
33
- constructor(locatorOrHandle, pageController, options = {}) {
30
+ constructor(locatorOrHandle, options = {}) {
34
31
  this.locatorOrHandle = locatorOrHandle;
35
- this.pageController = pageController;
36
32
  this.options = options;
37
33
  }
38
34
  async waitFor(options) {
@@ -67,18 +63,6 @@ class ElementController {
67
63
  async getValue(options) {
68
64
  return this.locatorOrHandle.inputValue(options);
69
65
  }
70
- /**
71
- * Get PageController for element. Element must be a frame.
72
- */
73
- async getPage(options) {
74
- const handle = (0, import_utils.isLocator)(this.locatorOrHandle) ? await this.locatorOrHandle.elementHandle(options) : this.locatorOrHandle;
75
- if ((0, import_type_guards.isNull)(handle)) {
76
- throw new Error("Could not get element handle.");
77
- }
78
- const frame = await this.locatorOrHandle.contentFrame();
79
- (0, import_type_guards.assertNotNull)(frame, "Could not get content frame for element handle.");
80
- return new import_page_controller.PageController(frame.page(), this.pageController.options);
81
- }
82
66
  async prepareAction(options) {
83
67
  await delay(options?.actionDelay ?? this.options.actionDelay);
84
68
  }
@@ -0,0 +1,23 @@
1
+ import type { Frame, Page } from 'playwright';
2
+ import type { DocumentControllerOptions } from './document-controller.js';
3
+ import { DocumentController } from './document-controller.js';
4
+ import type { PageControllerOptions } from './page-controller.js';
5
+ import { PageController } from './page-controller.js';
6
+ export type FrameControllerOptions = DocumentControllerOptions;
7
+ export type FrameControllerForwardOptions = {
8
+ pageControllerOptions: PageControllerOptions;
9
+ };
10
+ export declare class FrameController extends DocumentController {
11
+ private readonly frameControllerForwardOptions;
12
+ /** @deprecated should be avoided */
13
+ readonly frame: Frame;
14
+ readonly options: FrameControllerOptions;
15
+ constructor(frame: Frame, options: FrameControllerOptions, forwardOptions: FrameControllerForwardOptions);
16
+ /** Get the page containing this frame */
17
+ getPage(): PageController;
18
+ /**
19
+ * @param frameSelector frame name, url or url predicate
20
+ * @returns
21
+ */
22
+ getFrame(frameSelector: Parameters<Page['frame']>[0]): FrameController;
23
+ }
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var frame_controller_exports = {};
20
+ __export(frame_controller_exports, {
21
+ FrameController: () => FrameController
22
+ });
23
+ module.exports = __toCommonJS(frame_controller_exports);
24
+ var import_type_guards = require("../utils/type-guards.js");
25
+ var import_document_controller = require("./document-controller.js");
26
+ var import_page_controller = require("./page-controller.js");
27
+ class FrameController extends import_document_controller.DocumentController {
28
+ frameControllerForwardOptions;
29
+ /** @deprecated should be avoided */
30
+ frame;
31
+ options;
32
+ constructor(frame, options, forwardOptions) {
33
+ super(frame, options, { frameControllerOptions: options, pageControllerOptions: forwardOptions.pageControllerOptions });
34
+ this.options = options;
35
+ this.frameControllerForwardOptions = forwardOptions;
36
+ }
37
+ /** Get the page containing this frame */
38
+ getPage() {
39
+ return new import_page_controller.PageController(this.frame.page(), this.frameControllerForwardOptions.pageControllerOptions);
40
+ }
41
+ /**
42
+ * @param frameSelector frame name, url or url predicate
43
+ * @returns
44
+ */
45
+ getFrame(frameSelector) {
46
+ const frame = this.frame.page().frame(frameSelector);
47
+ if ((0, import_type_guards.isNull)(frame)) {
48
+ throw new Error("Frame not found.");
49
+ }
50
+ return new FrameController(frame, this.options, this.frameControllerForwardOptions);
51
+ }
52
+ }
@@ -1,6 +1,9 @@
1
1
  export * from './browser-context-controller.js';
2
2
  export * from './browser-controller.js';
3
3
  export * from './browser.service.js';
4
+ export * from './document-controller.js';
4
5
  export * from './element-controller.js';
6
+ export * from './frame-controller.js';
7
+ export * from './locator-controller.js';
5
8
  export * from './page-controller.js';
6
9
  export * from './types.js';
package/browser/index.js CHANGED
@@ -18,6 +18,9 @@ module.exports = __toCommonJS(browser_exports);
18
18
  __reExport(browser_exports, require("./browser-context-controller.js"), module.exports);
19
19
  __reExport(browser_exports, require("./browser-controller.js"), module.exports);
20
20
  __reExport(browser_exports, require("./browser.service.js"), module.exports);
21
+ __reExport(browser_exports, require("./document-controller.js"), module.exports);
21
22
  __reExport(browser_exports, require("./element-controller.js"), module.exports);
23
+ __reExport(browser_exports, require("./frame-controller.js"), module.exports);
24
+ __reExport(browser_exports, require("./locator-controller.js"), module.exports);
22
25
  __reExport(browser_exports, require("./page-controller.js"), module.exports);
23
26
  __reExport(browser_exports, require("./types.js"), module.exports);
@@ -0,0 +1,16 @@
1
+ import type { Frame, FrameLocator, Locator, Page } from 'playwright';
2
+ import type { NonUndefinable, SimplifyObject } from '../types.js';
3
+ import type { ElementControllerOptions } from './element-controller.js';
4
+ import { ElementController } from './element-controller.js';
5
+ export declare class LocatorController {
6
+ protected readonly elementControllerOptions: ElementControllerOptions;
7
+ readonly locatable: Page | Frame | Locator | FrameLocator;
8
+ constructor(locatable: Page | Frame | Locator | FrameLocator, elementControllerOptions: ElementControllerOptions);
9
+ getBySelector(selector: string, options?: SimplifyObject<Pick<NonUndefinable<Parameters<Page['locator']>[1]>, 'hasText' | 'hasNotText'>>): ElementController;
10
+ getByRole(role: Parameters<Page['getByRole']>[0], options?: Parameters<Page['getByRole']>[1]): ElementController;
11
+ getByLabel(text: Parameters<Page['getByLabel']>[0], options?: Parameters<Page['getByLabel']>[1]): ElementController;
12
+ getByAltText(text: Parameters<Page['getByAltText']>[0], options?: Parameters<Page['getByAltText']>[1]): ElementController;
13
+ getByPlaceholder(text: Parameters<Page['getByPlaceholder']>[0], options?: Parameters<Page['getByPlaceholder']>[1]): ElementController;
14
+ getByText(text: Parameters<Page['getByText']>[0], options?: Parameters<Page['getByText']>[1]): ElementController;
15
+ getByTitle(text: Parameters<Page['getByTitle']>[0], options?: Parameters<Page['getByTitle']>[1]): ElementController;
16
+ }
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var locator_controller_exports = {};
20
+ __export(locator_controller_exports, {
21
+ LocatorController: () => LocatorController
22
+ });
23
+ module.exports = __toCommonJS(locator_controller_exports);
24
+ var import_element_controller = require("./element-controller.js");
25
+ class LocatorController {
26
+ elementControllerOptions;
27
+ locatable;
28
+ constructor(locatable, elementControllerOptions) {
29
+ this.locatable = locatable;
30
+ this.elementControllerOptions = elementControllerOptions;
31
+ }
32
+ getBySelector(selector, options) {
33
+ const locator = this.locatable.locator(selector, options);
34
+ return new import_element_controller.ElementController(locator, this.elementControllerOptions);
35
+ }
36
+ getByRole(role, options) {
37
+ const locator = this.locatable.getByRole(role, options);
38
+ return new import_element_controller.ElementController(locator, this.elementControllerOptions);
39
+ }
40
+ getByLabel(text, options) {
41
+ const locator = this.locatable.getByLabel(text, options);
42
+ return new import_element_controller.ElementController(locator, this.elementControllerOptions);
43
+ }
44
+ getByAltText(text, options) {
45
+ const locator = this.locatable.getByAltText(text, options);
46
+ return new import_element_controller.ElementController(locator, this.elementControllerOptions);
47
+ }
48
+ getByPlaceholder(text, options) {
49
+ const locator = this.locatable.getByPlaceholder(text, options);
50
+ return new import_element_controller.ElementController(locator, this.elementControllerOptions);
51
+ }
52
+ getByText(text, options) {
53
+ const locator = this.locatable.getByText(text, options);
54
+ return new import_element_controller.ElementController(locator, this.elementControllerOptions);
55
+ }
56
+ getByTitle(text, options) {
57
+ const locator = this.locatable.getByTitle(text, options);
58
+ return new import_element_controller.ElementController(locator, this.elementControllerOptions);
59
+ }
60
+ }
@@ -1,39 +1,29 @@
1
- import type { ElementHandle, Page } from 'playwright';
1
+ import type { Page } from 'playwright';
2
2
  import type { AsyncDisposable } from '../disposable/disposable.js';
3
3
  import { disposeAsync } from '../disposable/disposable.js';
4
- import type { NonUndefinable, SimplifyObject } from '../types.js';
5
- import type { Delay } from './element-controller.js';
6
- import { ElementController } from './element-controller.js';
4
+ import type { DocumentControllerOptions } from './document-controller.js';
5
+ import { DocumentController } from './document-controller.js';
6
+ import type { FrameControllerOptions } from './frame-controller.js';
7
+ import { FrameController } from './frame-controller.js';
7
8
  import type { PdfRenderOptions } from './pdf-options.js';
8
9
  import type { Abortable } from './types.js';
9
- export type PageControllerOptions = {
10
- defaultActionDelay?: Delay;
11
- defaultTypeDelay?: Delay;
10
+ export type PageControllerOptions = DocumentControllerOptions & {
11
+ defaultFrameControllerOptions?: FrameControllerOptions;
12
12
  };
13
- export declare class PageController implements AsyncDisposable {
14
- private readonly elementControllerOptions;
13
+ export declare class PageController extends DocumentController implements AsyncDisposable {
15
14
  /** @deprecated should be avoided */
16
15
  readonly page: Page;
17
16
  readonly options: PageControllerOptions;
18
17
  constructor(page: Page, options?: PageControllerOptions);
19
18
  [disposeAsync](): Promise<void>;
20
19
  close(): Promise<void>;
21
- setContent(...args: Parameters<Page['setContent']>): Promise<void>;
22
20
  setExtraHttpHeaders(headers: Record<string, string>): Promise<void>;
23
- navigate(...args: Parameters<Page['goto']>): Promise<void>;
24
21
  waitForClose(): Promise<void>;
25
- waitForLoadState(...args: Parameters<Page['waitForLoadState']>): Promise<void>;
26
- waitForUrl(...args: Parameters<Page['waitForURL']>): Promise<void>;
27
- waitForElement(selector: string, options: Parameters<Page['waitForSelector']>[1]): Promise<ElementHandle>;
28
- waitForFrame(selector: string, options: Parameters<Page['waitForSelector']>[1]): Promise<PageController>;
29
- getFrame(selector: Parameters<Page['frame']>[0]): PageController;
30
- getBySelector(selector: string, options?: SimplifyObject<Pick<NonUndefinable<Parameters<Page['locator']>[1]>, 'hasText' | 'hasNotText'>>): ElementController;
31
- getByRole(role: Parameters<Page['getByRole']>[0], options?: Parameters<Page['getByRole']>[1]): ElementController;
32
- getByLabel(text: Parameters<Page['getByLabel']>[0], options?: Parameters<Page['getByLabel']>[1]): ElementController;
33
- getByAltText(text: Parameters<Page['getByAltText']>[0], options?: Parameters<Page['getByAltText']>[1]): ElementController;
34
- getByPlaceholder(text: Parameters<Page['getByPlaceholder']>[0], options?: Parameters<Page['getByPlaceholder']>[1]): ElementController;
35
- getByText(text: Parameters<Page['getByText']>[0], options?: Parameters<Page['getByText']>[1]): ElementController;
36
- getByTitle(text: Parameters<Page['getByTitle']>[0], options?: Parameters<Page['getByTitle']>[1]): ElementController;
22
+ /**
23
+ * @param frameSelector frame name, url or url predicate
24
+ * @returns
25
+ */
26
+ getFrame(frameSelector: Parameters<Page['frame']>[0]): FrameController;
37
27
  renderPdf(options?: PdfRenderOptions & Abortable): Promise<Uint8Array>;
38
28
  renderPdfStream(options?: PdfRenderOptions & Abortable): ReadableStream<Uint8Array>;
39
29
  }
@@ -26,16 +26,16 @@ var import_readable_stream_from_promise = require("../utils/stream/readable-stre
26
26
  var import_timing = require("../utils/timing.js");
27
27
  var import_type_guards = require("../utils/type-guards.js");
28
28
  var import_units = require("../utils/units.js");
29
- var import_element_controller = require("./element-controller.js");
30
- class PageController {
31
- elementControllerOptions;
29
+ var import_document_controller = require("./document-controller.js");
30
+ var import_frame_controller = require("./frame-controller.js");
31
+ class PageController extends import_document_controller.DocumentController {
32
32
  /** @deprecated should be avoided */
33
33
  page;
34
34
  options;
35
35
  constructor(page, options = {}) {
36
+ super(page, options, { pageControllerOptions: options, frameControllerOptions: options.defaultFrameControllerOptions ?? options });
36
37
  this.page = page;
37
38
  this.options = options;
38
- this.elementControllerOptions = { actionDelay: this.options.defaultActionDelay, typeDelay: this.options.defaultTypeDelay };
39
39
  }
40
40
  async [import_disposable.disposeAsync]() {
41
41
  await this.close();
@@ -43,15 +43,9 @@ class PageController {
43
43
  async close() {
44
44
  await this.page.close();
45
45
  }
46
- async setContent(...args) {
47
- await this.page.setContent(...args);
48
- }
49
46
  async setExtraHttpHeaders(headers) {
50
47
  await this.page.setExtraHTTPHeaders(headers);
51
48
  }
52
- async navigate(...args) {
53
- await this.page.goto(...args);
54
- }
55
49
  async waitForClose() {
56
50
  return new Promise((resolve) => {
57
51
  if (this.page.isClosed()) {
@@ -61,61 +55,16 @@ class PageController {
61
55
  this.page.once("close", () => resolve());
62
56
  });
63
57
  }
64
- async waitForLoadState(...args) {
65
- await this.page.waitForLoadState(...args);
66
- }
67
- async waitForUrl(...args) {
68
- await this.page.waitForURL(...args);
69
- }
70
- async waitForElement(selector, options) {
71
- const element = await this.page.waitForSelector(selector, options);
72
- if ((0, import_type_guards.isNull)(element)) {
73
- throw new Error("Element not found.");
74
- }
75
- return element;
76
- }
77
- async waitForFrame(selector, options) {
78
- const element = await this.waitForElement(selector, options);
79
- const frame = await element.contentFrame();
80
- if ((0, import_type_guards.isNull)(frame)) {
81
- throw new Error("Element is not a frame.");
82
- }
83
- return new PageController(frame.page(), this.options);
84
- }
85
- getFrame(selector) {
86
- const frame = this.page.frame(selector);
58
+ /**
59
+ * @param frameSelector frame name, url or url predicate
60
+ * @returns
61
+ */
62
+ getFrame(frameSelector) {
63
+ const frame = this.page.frame(frameSelector);
87
64
  if ((0, import_type_guards.isNull)(frame)) {
88
65
  throw new Error("Frame not found.");
89
66
  }
90
- return new PageController(frame.page(), this.options);
91
- }
92
- getBySelector(selector, options) {
93
- const locator = this.page.locator(selector, options);
94
- return new import_element_controller.ElementController(locator, this, this.elementControllerOptions);
95
- }
96
- getByRole(role, options) {
97
- const locator = this.page.getByRole(role, options);
98
- return new import_element_controller.ElementController(locator, this, this.elementControllerOptions);
99
- }
100
- getByLabel(text, options) {
101
- const locator = this.page.getByLabel(text, options);
102
- return new import_element_controller.ElementController(locator, this, this.elementControllerOptions);
103
- }
104
- getByAltText(text, options) {
105
- const locator = this.page.getByAltText(text, options);
106
- return new import_element_controller.ElementController(locator, this, this.elementControllerOptions);
107
- }
108
- getByPlaceholder(text, options) {
109
- const locator = this.page.getByPlaceholder(text, options);
110
- return new import_element_controller.ElementController(locator, this, this.elementControllerOptions);
111
- }
112
- getByText(text, options) {
113
- const locator = this.page.getByText(text, options);
114
- return new import_element_controller.ElementController(locator, this, this.elementControllerOptions);
115
- }
116
- getByTitle(text, options) {
117
- const locator = this.page.getByTitle(text, options);
118
- return new import_element_controller.ElementController(locator, this, this.elementControllerOptions);
67
+ return new import_frame_controller.FrameController(frame, this.options, this.forwardOptions);
119
68
  }
120
69
  async renderPdf(options = {}) {
121
70
  const createPdfOptions = convertPdfOptions(options);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tstdl/base",
3
- "version": "0.84.3",
3
+ "version": "0.84.4",
4
4
  "author": "Patrick Hein",
5
5
  "publishConfig": {
6
6
  "access": "public"