@rindo/core 3.0.1 → 3.1.0

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.
Files changed (111) hide show
  1. package/cli/config-flags.d.ts +122 -122
  2. package/cli/index.cjs +2301 -2432
  3. package/cli/index.d.ts +19 -19
  4. package/cli/index.js +2302 -2433
  5. package/cli/package.json +1 -1
  6. package/compiler/package.json +1 -1
  7. package/compiler/rindo.d.ts +73 -73
  8. package/compiler/rindo.js +66137 -62907
  9. package/compiler/rindo.min.js +2 -2
  10. package/compiler/sys/in-memory-fs.d.ts +218 -218
  11. package/compiler/transpile.d.ts +32 -32
  12. package/dev-server/client/app-error.d.ts +18 -18
  13. package/dev-server/client/events.d.ts +6 -6
  14. package/dev-server/client/hmr-components.d.ts +1 -1
  15. package/dev-server/client/hmr-external-styles.d.ts +1 -1
  16. package/dev-server/client/hmr-images.d.ts +1 -1
  17. package/dev-server/client/hmr-inline-styles.d.ts +1 -1
  18. package/dev-server/client/hmr-util.d.ts +9 -9
  19. package/dev-server/client/hmr-window.d.ts +10 -10
  20. package/dev-server/client/index.d.ts +6 -6
  21. package/dev-server/client/index.js +781 -781
  22. package/dev-server/client/logger.d.ts +5 -5
  23. package/dev-server/client/package.json +1 -1
  24. package/dev-server/client/progress.d.ts +3 -3
  25. package/dev-server/client/status.d.ts +4 -4
  26. package/dev-server/connector.html +2 -2
  27. package/dev-server/index.d.ts +3 -3
  28. package/dev-server/index.js +228 -228
  29. package/dev-server/open-in-editor-api.js +1 -1
  30. package/dev-server/package.json +1 -1
  31. package/dev-server/server-process.js +1300 -1281
  32. package/dev-server/ws.js +1 -1
  33. package/dev-server/xdg-open +0 -0
  34. package/internal/app-data/index.cjs +88 -88
  35. package/internal/app-data/index.d.ts +4 -4
  36. package/internal/app-data/index.js +88 -88
  37. package/internal/app-data/package.json +1 -1
  38. package/internal/client/css-shim.js +1 -1
  39. package/internal/client/dom.js +1 -1
  40. package/internal/client/index.js +3380 -3380
  41. package/internal/client/package.json +1 -1
  42. package/internal/client/patch-browser.js +155 -155
  43. package/internal/client/patch-esm.js +25 -25
  44. package/internal/client/shadow-css.js +382 -382
  45. package/internal/hydrate/package.json +1 -1
  46. package/internal/index.d.ts +2 -2
  47. package/internal/index.js +1 -1
  48. package/internal/package.json +1 -1
  49. package/internal/rindo-private.d.ts +2272 -2268
  50. package/internal/rindo-public-compiler.d.ts +2377 -2356
  51. package/internal/rindo-public-docs.d.ts +139 -139
  52. package/internal/rindo-public-runtime.d.ts +1636 -1636
  53. package/internal/testing/package.json +1 -1
  54. package/mock-doc/index.cjs +4766 -4766
  55. package/mock-doc/index.d.ts +1006 -1006
  56. package/mock-doc/index.js +4766 -4766
  57. package/mock-doc/package.json +1 -1
  58. package/package.json +9 -9
  59. package/screenshot/connector-base.d.ts +42 -42
  60. package/screenshot/connector-local.d.ts +7 -7
  61. package/screenshot/index.d.ts +3 -3
  62. package/screenshot/index.js +615 -615
  63. package/screenshot/package.json +1 -1
  64. package/screenshot/pixel-match.d.ts +1 -1
  65. package/screenshot/pixel-match.js +14 -14
  66. package/screenshot/screenshot-compare.d.ts +3 -3
  67. package/screenshot/screenshot-fs.d.ts +15 -15
  68. package/sys/node/autoprefixer.js +2 -2
  69. package/sys/node/glob.js +1 -1
  70. package/sys/node/graceful-fs.js +1 -1
  71. package/sys/node/index.d.ts +22 -22
  72. package/sys/node/index.js +6 -3
  73. package/sys/node/node-fetch.js +1 -1
  74. package/sys/node/package.json +1 -1
  75. package/sys/node/prompts.js +1 -1
  76. package/sys/node/worker.js +1 -1
  77. package/testing/index.d.ts +12 -12
  78. package/testing/index.js +7 -3
  79. package/testing/jest/jest-config.d.ts +16 -16
  80. package/testing/jest/jest-environment.d.ts +15 -15
  81. package/testing/jest/jest-preprocessor.d.ts +59 -59
  82. package/testing/jest/jest-runner.d.ts +10 -10
  83. package/testing/jest/jest-screenshot.d.ts +2 -2
  84. package/testing/jest/jest-serializer.d.ts +4 -4
  85. package/testing/jest/jest-setup-test-framework.d.ts +1 -1
  86. package/testing/matchers/attributes.d.ts +14 -14
  87. package/testing/matchers/class-list.d.ts +12 -12
  88. package/testing/matchers/events.d.ts +21 -21
  89. package/testing/matchers/html.d.ts +12 -12
  90. package/testing/matchers/index.d.ts +23 -23
  91. package/testing/matchers/screenshot.d.ts +5 -5
  92. package/testing/matchers/text.d.ts +4 -4
  93. package/testing/mock-fetch.d.ts +11 -11
  94. package/testing/mocks.d.ts +56 -56
  95. package/testing/package.json +1 -1
  96. package/testing/puppeteer/index.d.ts +2 -2
  97. package/testing/puppeteer/puppeteer-browser.d.ts +6 -6
  98. package/testing/puppeteer/puppeteer-declarations.d.ts +403 -403
  99. package/testing/puppeteer/puppeteer-element.d.ts +67 -67
  100. package/testing/puppeteer/puppeteer-emulate.d.ts +2 -2
  101. package/testing/puppeteer/puppeteer-events.d.ts +21 -21
  102. package/testing/puppeteer/puppeteer-page.d.ts +2 -2
  103. package/testing/puppeteer/puppeteer-screenshot.d.ts +4 -4
  104. package/testing/reset-build-conditionals.d.ts +2 -2
  105. package/testing/spec-page.d.ts +2 -2
  106. package/testing/test-transpile.d.ts +2 -2
  107. package/testing/testing-logger.d.ts +25 -25
  108. package/testing/testing-sys.d.ts +6 -6
  109. package/testing/testing-utils.d.ts +79 -79
  110. package/testing/testing.d.ts +2 -2
  111. package/dependencies.json +0 -120
@@ -1,403 +1,403 @@
1
- /// <reference types="node" />
2
- import type { EventInitDict, EventSpy, ScreenshotDiff, ScreenshotOptions } from '@rindo/core/internal';
3
- import type { ClickOptions, HTTPResponse, Page, ScreenshotOptions as PuppeteerScreenshotOptions, WaitForOptions } from 'puppeteer';
4
- /**
5
- * This type was once exported by Puppeteer, but has since moved to an object literal in (Puppeteer’s) native types.
6
- * Re-create it here as a named type to use across multiple Rindo-related testing files.
7
- */
8
- export type PageCloseOptions = {
9
- runBeforeUnload?: boolean;
10
- };
11
- export interface NewE2EPageOptions extends WaitForOptions {
12
- url?: string;
13
- html?: string;
14
- failOnConsoleError?: boolean;
15
- failOnNetworkError?: boolean;
16
- }
17
- type Omit<T, K> = Pick<T, Exclude<keyof T, K>>;
18
- type PuppeteerPage = Omit<Page, 'bringToFront' | 'browser' | 'screenshot' | 'emulate' | 'emulateMedia' | 'frames' | 'goBack' | 'goForward' | 'isClosed' | 'mainFrame' | 'pdf' | 'reload' | 'target' | 'title' | 'viewport' | 'waitForNavigation' | 'screenshot' | 'workers' | 'addListener' | 'prependListener' | 'prependOnceListener' | 'removeAllListeners' | 'setMaxListeners' | 'getMaxListeners' | 'listeners' | 'rawListeners' | 'emit' | 'eventNames' | 'listenerCount' | '$x' | 'waitForXPath'>;
19
- export interface PageDiagnostic {
20
- type: 'error' | 'pageerror' | 'requestfailed';
21
- message?: string;
22
- location?: string;
23
- }
24
- /**
25
- * The E2EPage is a wrapper utility to Puppeteer in order to
26
- * to create easier to write and read end-to-end tests.
27
- */
28
- export interface E2EPage extends PuppeteerPage {
29
- /**
30
- * `Experimental`
31
- * Takes a screenshot of the page, then compares the current screenshot
32
- * against the master screenshot. The returned screenshot compare
33
- * results can then be used to test pixel mismatches, such as
34
- * `expect(results).toMatchScreenshot()`.
35
- */
36
- compareScreenshot(): Promise<ScreenshotDiff>;
37
- /**
38
- * `Experimental`
39
- * Takes a screenshot of the page, then compares the current screenshot
40
- * against the master screenshot. The provided `description` will be
41
- * added onto its current description, which comes from the test description.
42
- */
43
- compareScreenshot(description: string): Promise<ScreenshotDiff>;
44
- /**
45
- * `Experimental`
46
- * Takes a screenshot of the page, then compares the current screenshot
47
- * against the master screenshot. The `opts` argument can be used to
48
- * customize screenshot options.
49
- */
50
- compareScreenshot(opts: ScreenshotOptions): Promise<ScreenshotDiff>;
51
- /**
52
- * `Experimental`
53
- * Takes a screenshot of the page, then compares the current screenshot
54
- * against the master screenshot. The `description` argument will be
55
- * added onto its current description, which comes from the test description.
56
- * The `opts` argument can be used to customize screenshot options.
57
- */
58
- compareScreenshot(description: string, opts: ScreenshotOptions): Promise<ScreenshotDiff>;
59
- /**
60
- * Sets a debugger;
61
- */
62
- debugger(): Promise<void>;
63
- /**
64
- * Find an element that matches the selector, which is the same as
65
- * `document.querySelector(selector)`. Use `>>>` within the
66
- * selector to find an element within the host element's shadow root.
67
- * For example, to select the first `div` inside of the component
68
- * `my-cmp`, the call would be `page.find('my-cmp >>> div')`.
69
- * Returns `null` if an element was not found.
70
- */
71
- find(selector: FindSelector): Promise<E2EElement>;
72
- /**
73
- * Find all elements that match the selector, which is the same as
74
- * `document.querySelectorAll(selector)`. Use `>>>` within the
75
- * selector to find elements within the host element's shadow root.
76
- * For example, to select all of the `li` elements inside of the component
77
- * `my-cmp`, the call would be `page.findAll('my-cmp >>> li')`.
78
- * Returns an empty array if no elements were found.
79
- */
80
- findAll(selector: string): Promise<E2EElement[]>;
81
- /**
82
- * During an end-to-end test, a dev-server is started so `page.goto(url)` can be used
83
- * on the app being tested. Urls are always relative since the dev server provides
84
- * a localhost address. A shortcut to `page.goto(url)` is to set the `url` option
85
- * when creating a new page, such as `const page = await newE2EPage({ url })`.
86
- */
87
- goTo(url: string, options?: WaitForOptions): Promise<HTTPResponse | null>;
88
- /**
89
- * Instead of testing a url directly, html content can be mocked using
90
- * `page.setContent(html)`. A shortcut to `page.setContent(html)` is to set
91
- * the `html` option when creating a new page, such as
92
- * `const page = await newE2EPage({ html })`.
93
- */
94
- setContent(html: string, options?: WaitForOptions): Promise<void>;
95
- /**
96
- * Used to test if an event was, or was not dispatched. This method
97
- * returns a promise, that resolves with an EventSpy. The EventSpy
98
- * can be used along with `expect(spy).toHaveReceivedEvent()`,
99
- * `expect(spy).toHaveReceivedEventTimes(x)` and
100
- * `expect(spy).toHaveReceivedEventDetail({...})`.
101
- */
102
- spyOnEvent(eventName: string, selector?: 'window' | 'document'): Promise<EventSpy>;
103
- /**
104
- * Both Rindo and Puppeteer have an asynchronous architecture, which is a good thing
105
- * for performance. Since all calls are async, it's required that
106
- * `await page.waitForChanges()` is called when changes are made to components.
107
- * An error will be thrown if changes were made to a component but `waitForChanges()`
108
- * was not called.
109
- */
110
- waitForChanges(): Promise<void>;
111
- /**
112
- * Waits for the event to be received on `window`. The optional second argument
113
- * allows the listener to be set to `document` if needed.
114
- */
115
- waitForEvent(eventName: string): Promise<any>;
116
- getDiagnostics(): PageDiagnostic[];
117
- }
118
- export interface E2EPageInternal extends E2EPage {
119
- isClosed(): boolean;
120
- _e2eElements: E2EElementInternal[];
121
- _e2eEvents: Map<number, WaitForEvent>;
122
- _e2eEventIds: number;
123
- _e2eGoto(url: string, options?: Partial<WaitForOptions>): Promise<HTTPResponse | null>;
124
- _e2eClose(options?: PageCloseOptions): Promise<void>;
125
- screenshot(options?: PuppeteerScreenshotOptions): Promise<Buffer>;
126
- }
127
- export interface E2EElement {
128
- /**
129
- * Used to call a method on a component. For example, if a component
130
- * has the method `cmp.myMethod(arg1, arg2)`, calling this method
131
- * from a e2e test could be `cmp.callMethod('myMethod', arg1, arg2)`.
132
- */
133
- callMethod(methodName: string, ...methodArgs: any[]): Promise<any>;
134
- /**
135
- * Gets and sets the value of the class attribute of the e2e element.
136
- * Note that `await page.waitForChanges()` must be called before reading
137
- * the value if content has changed.
138
- */
139
- className: string;
140
- /**
141
- * Using classList is a convenient alternative to accessing an element's list
142
- * of classes as a space-delimited string via `element.className`.
143
- */
144
- classList: {
145
- /**
146
- * Add specified class values. If these classes already exist in
147
- * attribute of the element, then they are ignored.
148
- */
149
- add: (...tokens: string[]) => void;
150
- /**
151
- * Remove specified class values. Note: Removing a class that does
152
- * not exist does NOT throw an error.
153
- */
154
- remove: (...tokens: string[]) => void;
155
- /**
156
- * If class exists then remove it, if not, then add it.
157
- */
158
- toggle: (token: string) => void;
159
- /**
160
- * Checks if specified class value exists in class attribute of the element.
161
- */
162
- contains: (className: string) => boolean;
163
- };
164
- /**
165
- * Calling `click()` on an element scrolls it into view if needed, and
166
- * then uses `page.mouse` to click in the center of the element.
167
- * Please see the puppeteer docs for more information.
168
- */
169
- click(options?: ClickOptions): Promise<void>;
170
- /**
171
- * Find a child element that matches the selector, which is the same as
172
- * `element.querySelector(selector)`. Use `>>>` within the
173
- * selector to find an element within a host element's shadow root.
174
- * For example, to select the first `div` inside of the component
175
- * `my-cmp`, which is a child of this element, the call would be
176
- * `element.find('my-cmp >>> div')`. Returns `null` if no
177
- * elements were found.
178
- */
179
- find(selector: FindSelector): Promise<E2EElement>;
180
- /**
181
- * Find all child elements that match the selector, which is the same as
182
- * `element.querySelectorAll(selector)`. Use `>>>` within the
183
- * selector to find elements within a host element's shadow root.
184
- * For example, to select all `li` elements inside of the component
185
- * `my-cmp`, which is a child of this element, the call would be
186
- * `element.findAll('my-cmp >>> li')`. Returns an empty array if
187
- * no elements were found.
188
- */
189
- findAll(selector: FindSelector): Promise<E2EElement[]>;
190
- /**
191
- * Sets focus on the element.
192
- */
193
- focus(): Promise<void>;
194
- /**
195
- * Returns the value of a specified attribute on the element. If the
196
- * given attribute does not exist, the value returned will be null.
197
- */
198
- getAttribute(name: string): string;
199
- /**
200
- * Used to get a property set on a component. For example, if a
201
- * component has the property `elm.myProp`, then calling
202
- * `elm.getProperty('myProp')` would return the `myProp` property value.
203
- */
204
- getProperty(propertyName: string): Promise<any>;
205
- /**
206
- * Returns an object that reports the values of all CSS properties of this
207
- * element after applying active stylesheets and resolving any basic computation
208
- * those values may contain. Individual CSS property values are accessed by
209
- * simply indexing with CSS property names. The method is shortcut and an async
210
- * version of using `window.getComputedStyle(element)` directly.
211
- */
212
- getComputedStyle(pseudoElt?: string | null): Promise<CSSStyleDeclaration>;
213
- /**
214
- * Sets hover on the element.
215
- */
216
- hover(): Promise<void>;
217
- /**
218
- * Gets and sets `id` property of the element.
219
- * Note that `await page.waitForChanges()` must be called before reading
220
- * the value if content has changed.
221
- */
222
- id: string;
223
- /**
224
- * Gets and sets `innerHTML` property of the element.
225
- * Note that `await page.waitForChanges()` must be called before reading
226
- * the value if content has changed.
227
- */
228
- innerHTML: string;
229
- /**
230
- * Gets and sets `innerText` property of the element.
231
- * Note that `await page.waitForChanges()` must be called before reading
232
- * the value if content has changed.
233
- */
234
- innerText: string;
235
- /**
236
- * Resolves to true if the element is visible in the current viewport.
237
- */
238
- isIntersectingViewport(): Promise<boolean>;
239
- /**
240
- * Resolves `true` when the element's style is `display !== 'none'`,
241
- * `visibility !== 'hidden'` and `opacity !== '0'`.
242
- */
243
- isVisible(): Promise<boolean>;
244
- /**
245
- * Node name of the node, which in an element's case is the tag name.
246
- * Note, this will always be upper-cased.
247
- */
248
- nodeName: string;
249
- /**
250
- * The type of a node represented by a number.
251
- * Element = 1, TextNode = 3, Comment = 8,
252
- * Document Fragment (also what a shadow root is) = 11.
253
- */
254
- nodeType: number;
255
- /**
256
- * Gets the element's `outerHTML. This is a read-only property and will
257
- * throw an error if set.
258
- */
259
- outerHTML: string;
260
- /**
261
- * Focuses the element, and then uses `keyboard.down` and `keyboard.up`.
262
- * If key is a single character and no modifier keys besides Shift are
263
- * being held down, a keypress/input event will also be generated. The
264
- * text option can be specified to force an input event to be generated.
265
- * Note: Modifier keys DO effect `elementHandle.press`. Holding down Shift
266
- * will type the text in upper case.
267
- * Key names: https://github.com/puppeteer/puppeteer/blob/main/src/common/USKeyboardLayout.ts
268
- */
269
- press(key: string, options?: {
270
- text?: string;
271
- delay?: number;
272
- }): Promise<void>;
273
- /**
274
- * Removes the attribute on the specified element. Note that
275
- * `await page.waitForChanges()` must be called before reading
276
- * the value if content has changed.
277
- */
278
- removeAttribute(name: string): void;
279
- /**
280
- * Sets the value of an attribute on the specified element. If the
281
- * attribute already exists, the value is updated; otherwise a new
282
- * attribute is added with the specified name and value. The value
283
- * will always be converted to a string. Note that
284
- * `await page.waitForChanges()` must be called before reading
285
- * the value if content has changed.
286
- */
287
- setAttribute(name: string, value: any): void;
288
- /**
289
- * Used to set a property set on a component. For example, if a
290
- * component has the property `elm.myProp`, then calling
291
- * `elm.setProperty('myProp', 88)` would set the value `88` to
292
- * the `myProp` property on the component.
293
- */
294
- setProperty(propertyName: string, value: any): void;
295
- /**
296
- * The ShadowRoot interface of the Shadow DOM API is the root node of a
297
- * DOM subtree that is rendered separately from a document's main DOM tree.
298
- * This value will be `null` if the element does not have a `shadowRoot`.
299
- */
300
- shadowRoot: ShadowRoot;
301
- /**
302
- * Used to test if an event was, or was not dispatched. This method
303
- * returns a promise, that resolves with an EventSpy. The EventSpy
304
- * can be used along with `expect(spy).toHaveReceivedEvent()`,
305
- * `expect(spy).toHaveReceivedEventTimes(x)` and
306
- * `expect(spy).toHaveReceivedEventDetail({...})`.
307
- */
308
- spyOnEvent(eventName: string): Promise<EventSpy>;
309
- /**
310
- * Represents the tab order of the current element. Setting the
311
- * `tabIndex` property will also set the `tabindex` attribute.
312
- */
313
- tabIndex: number;
314
- /**
315
- * Tag name of the element. Note, this will always be upper-cased.
316
- */
317
- tagName: string;
318
- /**
319
- * This method scrolls the element it into view if needed,
320
- * and then uses `page.touchscreen` to tap in the center of the element.
321
- */
322
- tap(): Promise<void>;
323
- /**
324
- * The `textContent` property represents the text content of a node
325
- * and its descendants. Note that `await page.waitForChanges()` must
326
- * be called before reading the value if content has changed.
327
- */
328
- textContent: string;
329
- /**
330
- * Represents the `title` of the element, the text usually displayed in a
331
- * 'tool tip' popup when the mouse is over the displayed node.
332
- */
333
- title: string;
334
- /**
335
- * Toggles a `boolean` attribute (removing it if it is present and adding
336
- * it if it is not present) on the given element. Note that
337
- * `await page.waitForChanges()` must be called before reading
338
- * the value if content has changed. The optional `force` argument is a
339
- * `boolean` value to determine whether the attribute should be added or
340
- * removed, no matter whether the attribute is present or not at the moment.
341
- */
342
- toggleAttribute(name: string, force?: boolean): void;
343
- /**
344
- * This is a convenience method to easily create a `CustomEvent`,
345
- * and dispatch it from the element, to include any custom event
346
- * `detail` data as the second argument.
347
- */
348
- triggerEvent(eventName: string, eventInitDict?: EventInitDict): void;
349
- /**
350
- * Sends a keydown, keypress/input, and keyup event for each character in the text.
351
- * To press a special key, like Control or ArrowDown, use `keyboard.press`.
352
- */
353
- type(text: string, options?: {
354
- delay: number;
355
- }): Promise<void>;
356
- /**
357
- * Waits until the element's style is `display !== 'none'`,
358
- * `visibility !== 'hidden'`, `opacity !== '0'` and the element
359
- * is connected to the document.
360
- */
361
- waitForVisible(): Promise<void>;
362
- /**
363
- * Waits until the element's style is `display === 'none'`, or
364
- * `visibility === 'hidden'`, or `opacity === '0'`, or the element
365
- * is no longer connected to the document.
366
- */
367
- waitForNotVisible(): Promise<void>;
368
- /**
369
- * Waits until the given event is listened in the element.
370
- */
371
- waitForEvent(eventName: string): Promise<any>;
372
- }
373
- export interface E2EElementInternal extends E2EElement {
374
- e2eDispose(): Promise<void>;
375
- e2eRunActions(): Promise<unknown>;
376
- e2eSync(): Promise<void>;
377
- }
378
- export type FindSelector = string | FindSelectorOptions;
379
- export interface FindSelectorOptions {
380
- /**
381
- * Finds an element with text content matching this
382
- * exact value after the whitespace has been trimmed.
383
- */
384
- text?: string;
385
- /**
386
- * Finds an element with text content containing this value.
387
- */
388
- contains?: string;
389
- }
390
- export interface WaitForEventOptions {
391
- timeout?: number;
392
- }
393
- export interface WaitForEvent {
394
- eventName: string;
395
- callback: (ev: any) => void;
396
- }
397
- export interface BrowserWindow extends Window {
398
- rindoOnEvent(id: number, event: any): void;
399
- rindoSerializeEvent(ev: CustomEvent): any;
400
- rindoSerializeEventTarget(target: any): any;
401
- rindoAppLoaded: boolean;
402
- }
403
- export {};
1
+ /// <reference types="node" />
2
+ import type { EventInitDict, EventSpy, ScreenshotDiff, ScreenshotOptions } from '@rindo/core/internal';
3
+ import type { ClickOptions, HTTPResponse, Page, ScreenshotOptions as PuppeteerScreenshotOptions, WaitForOptions } from 'puppeteer';
4
+ /**
5
+ * This type was once exported by Puppeteer, but has since moved to an object literal in (Puppeteer’s) native types.
6
+ * Re-create it here as a named type to use across multiple Rindo-related testing files.
7
+ */
8
+ export type PageCloseOptions = {
9
+ runBeforeUnload?: boolean;
10
+ };
11
+ export interface NewE2EPageOptions extends WaitForOptions {
12
+ url?: string;
13
+ html?: string;
14
+ failOnConsoleError?: boolean;
15
+ failOnNetworkError?: boolean;
16
+ }
17
+ type Omit<T, K> = Pick<T, Exclude<keyof T, K>>;
18
+ type PuppeteerPage = Omit<Page, 'bringToFront' | 'browser' | 'screenshot' | 'emulate' | 'emulateMedia' | 'frames' | 'goBack' | 'goForward' | 'isClosed' | 'mainFrame' | 'pdf' | 'reload' | 'target' | 'title' | 'viewport' | 'waitForNavigation' | 'screenshot' | 'workers' | 'addListener' | 'prependListener' | 'prependOnceListener' | 'removeAllListeners' | 'setMaxListeners' | 'getMaxListeners' | 'listeners' | 'rawListeners' | 'emit' | 'eventNames' | 'listenerCount' | '$x' | 'waitForXPath'>;
19
+ export interface PageDiagnostic {
20
+ type: 'error' | 'pageerror' | 'requestfailed';
21
+ message?: string;
22
+ location?: string;
23
+ }
24
+ /**
25
+ * The E2EPage is a wrapper utility to Puppeteer in order to
26
+ * to create easier to write and read end-to-end tests.
27
+ */
28
+ export interface E2EPage extends PuppeteerPage {
29
+ /**
30
+ * `Experimental`
31
+ * Takes a screenshot of the page, then compares the current screenshot
32
+ * against the master screenshot. The returned screenshot compare
33
+ * results can then be used to test pixel mismatches, such as
34
+ * `expect(results).toMatchScreenshot()`.
35
+ */
36
+ compareScreenshot(): Promise<ScreenshotDiff>;
37
+ /**
38
+ * `Experimental`
39
+ * Takes a screenshot of the page, then compares the current screenshot
40
+ * against the master screenshot. The provided `description` will be
41
+ * added onto its current description, which comes from the test description.
42
+ */
43
+ compareScreenshot(description: string): Promise<ScreenshotDiff>;
44
+ /**
45
+ * `Experimental`
46
+ * Takes a screenshot of the page, then compares the current screenshot
47
+ * against the master screenshot. The `opts` argument can be used to
48
+ * customize screenshot options.
49
+ */
50
+ compareScreenshot(opts: ScreenshotOptions): Promise<ScreenshotDiff>;
51
+ /**
52
+ * `Experimental`
53
+ * Takes a screenshot of the page, then compares the current screenshot
54
+ * against the master screenshot. The `description` argument will be
55
+ * added onto its current description, which comes from the test description.
56
+ * The `opts` argument can be used to customize screenshot options.
57
+ */
58
+ compareScreenshot(description: string, opts: ScreenshotOptions): Promise<ScreenshotDiff>;
59
+ /**
60
+ * Sets a debugger;
61
+ */
62
+ debugger(): Promise<void>;
63
+ /**
64
+ * Find an element that matches the selector, which is the same as
65
+ * `document.querySelector(selector)`. Use `>>>` within the
66
+ * selector to find an element within the host element's shadow root.
67
+ * For example, to select the first `div` inside of the component
68
+ * `my-cmp`, the call would be `page.find('my-cmp >>> div')`.
69
+ * Returns `null` if an element was not found.
70
+ */
71
+ find(selector: FindSelector): Promise<E2EElement>;
72
+ /**
73
+ * Find all elements that match the selector, which is the same as
74
+ * `document.querySelectorAll(selector)`. Use `>>>` within the
75
+ * selector to find elements within the host element's shadow root.
76
+ * For example, to select all of the `li` elements inside of the component
77
+ * `my-cmp`, the call would be `page.findAll('my-cmp >>> li')`.
78
+ * Returns an empty array if no elements were found.
79
+ */
80
+ findAll(selector: string): Promise<E2EElement[]>;
81
+ /**
82
+ * During an end-to-end test, a dev-server is started so `page.goto(url)` can be used
83
+ * on the app being tested. Urls are always relative since the dev server provides
84
+ * a localhost address. A shortcut to `page.goto(url)` is to set the `url` option
85
+ * when creating a new page, such as `const page = await newE2EPage({ url })`.
86
+ */
87
+ goTo(url: string, options?: WaitForOptions): Promise<HTTPResponse | null>;
88
+ /**
89
+ * Instead of testing a url directly, html content can be mocked using
90
+ * `page.setContent(html)`. A shortcut to `page.setContent(html)` is to set
91
+ * the `html` option when creating a new page, such as
92
+ * `const page = await newE2EPage({ html })`.
93
+ */
94
+ setContent(html: string, options?: WaitForOptions): Promise<void>;
95
+ /**
96
+ * Used to test if an event was, or was not dispatched. This method
97
+ * returns a promise, that resolves with an EventSpy. The EventSpy
98
+ * can be used along with `expect(spy).toHaveReceivedEvent()`,
99
+ * `expect(spy).toHaveReceivedEventTimes(x)` and
100
+ * `expect(spy).toHaveReceivedEventDetail({...})`.
101
+ */
102
+ spyOnEvent(eventName: string, selector?: 'window' | 'document'): Promise<EventSpy>;
103
+ /**
104
+ * Both Rindo and Puppeteer have an asynchronous architecture, which is a good thing
105
+ * for performance. Since all calls are async, it's required that
106
+ * `await page.waitForChanges()` is called when changes are made to components.
107
+ * An error will be thrown if changes were made to a component but `waitForChanges()`
108
+ * was not called.
109
+ */
110
+ waitForChanges(): Promise<void>;
111
+ /**
112
+ * Waits for the event to be received on `window`. The optional second argument
113
+ * allows the listener to be set to `document` if needed.
114
+ */
115
+ waitForEvent(eventName: string): Promise<any>;
116
+ getDiagnostics(): PageDiagnostic[];
117
+ }
118
+ export interface E2EPageInternal extends E2EPage {
119
+ isClosed(): boolean;
120
+ _e2eElements: E2EElementInternal[];
121
+ _e2eEvents: Map<number, WaitForEvent>;
122
+ _e2eEventIds: number;
123
+ _e2eGoto(url: string, options?: Partial<WaitForOptions>): Promise<HTTPResponse | null>;
124
+ _e2eClose(options?: PageCloseOptions): Promise<void>;
125
+ screenshot(options?: PuppeteerScreenshotOptions): Promise<Buffer>;
126
+ }
127
+ export interface E2EElement {
128
+ /**
129
+ * Used to call a method on a component. For example, if a component
130
+ * has the method `cmp.myMethod(arg1, arg2)`, calling this method
131
+ * from a e2e test could be `cmp.callMethod('myMethod', arg1, arg2)`.
132
+ */
133
+ callMethod(methodName: string, ...methodArgs: any[]): Promise<any>;
134
+ /**
135
+ * Gets and sets the value of the class attribute of the e2e element.
136
+ * Note that `await page.waitForChanges()` must be called before reading
137
+ * the value if content has changed.
138
+ */
139
+ className: string;
140
+ /**
141
+ * Using classList is a convenient alternative to accessing an element's list
142
+ * of classes as a space-delimited string via `element.className`.
143
+ */
144
+ classList: {
145
+ /**
146
+ * Add specified class values. If these classes already exist in
147
+ * attribute of the element, then they are ignored.
148
+ */
149
+ add: (...tokens: string[]) => void;
150
+ /**
151
+ * Remove specified class values. Note: Removing a class that does
152
+ * not exist does NOT throw an error.
153
+ */
154
+ remove: (...tokens: string[]) => void;
155
+ /**
156
+ * If class exists then remove it, if not, then add it.
157
+ */
158
+ toggle: (token: string) => void;
159
+ /**
160
+ * Checks if specified class value exists in class attribute of the element.
161
+ */
162
+ contains: (className: string) => boolean;
163
+ };
164
+ /**
165
+ * Calling `click()` on an element scrolls it into view if needed, and
166
+ * then uses `page.mouse` to click in the center of the element.
167
+ * Please see the puppeteer docs for more information.
168
+ */
169
+ click(options?: ClickOptions): Promise<void>;
170
+ /**
171
+ * Find a child element that matches the selector, which is the same as
172
+ * `element.querySelector(selector)`. Use `>>>` within the
173
+ * selector to find an element within a host element's shadow root.
174
+ * For example, to select the first `div` inside of the component
175
+ * `my-cmp`, which is a child of this element, the call would be
176
+ * `element.find('my-cmp >>> div')`. Returns `null` if no
177
+ * elements were found.
178
+ */
179
+ find(selector: FindSelector): Promise<E2EElement>;
180
+ /**
181
+ * Find all child elements that match the selector, which is the same as
182
+ * `element.querySelectorAll(selector)`. Use `>>>` within the
183
+ * selector to find elements within a host element's shadow root.
184
+ * For example, to select all `li` elements inside of the component
185
+ * `my-cmp`, which is a child of this element, the call would be
186
+ * `element.findAll('my-cmp >>> li')`. Returns an empty array if
187
+ * no elements were found.
188
+ */
189
+ findAll(selector: FindSelector): Promise<E2EElement[]>;
190
+ /**
191
+ * Sets focus on the element.
192
+ */
193
+ focus(): Promise<void>;
194
+ /**
195
+ * Returns the value of a specified attribute on the element. If the
196
+ * given attribute does not exist, the value returned will be null.
197
+ */
198
+ getAttribute(name: string): string;
199
+ /**
200
+ * Used to get a property set on a component. For example, if a
201
+ * component has the property `elm.myProp`, then calling
202
+ * `elm.getProperty('myProp')` would return the `myProp` property value.
203
+ */
204
+ getProperty(propertyName: string): Promise<any>;
205
+ /**
206
+ * Returns an object that reports the values of all CSS properties of this
207
+ * element after applying active stylesheets and resolving any basic computation
208
+ * those values may contain. Individual CSS property values are accessed by
209
+ * simply indexing with CSS property names. The method is shortcut and an async
210
+ * version of using `window.getComputedStyle(element)` directly.
211
+ */
212
+ getComputedStyle(pseudoElt?: string | null): Promise<CSSStyleDeclaration>;
213
+ /**
214
+ * Sets hover on the element.
215
+ */
216
+ hover(): Promise<void>;
217
+ /**
218
+ * Gets and sets `id` property of the element.
219
+ * Note that `await page.waitForChanges()` must be called before reading
220
+ * the value if content has changed.
221
+ */
222
+ id: string;
223
+ /**
224
+ * Gets and sets `innerHTML` property of the element.
225
+ * Note that `await page.waitForChanges()` must be called before reading
226
+ * the value if content has changed.
227
+ */
228
+ innerHTML: string;
229
+ /**
230
+ * Gets and sets `innerText` property of the element.
231
+ * Note that `await page.waitForChanges()` must be called before reading
232
+ * the value if content has changed.
233
+ */
234
+ innerText: string;
235
+ /**
236
+ * Resolves to true if the element is visible in the current viewport.
237
+ */
238
+ isIntersectingViewport(): Promise<boolean>;
239
+ /**
240
+ * Resolves `true` when the element's style is `display !== 'none'`,
241
+ * `visibility !== 'hidden'` and `opacity !== '0'`.
242
+ */
243
+ isVisible(): Promise<boolean>;
244
+ /**
245
+ * Node name of the node, which in an element's case is the tag name.
246
+ * Note, this will always be upper-cased.
247
+ */
248
+ nodeName: string;
249
+ /**
250
+ * The type of a node represented by a number.
251
+ * Element = 1, TextNode = 3, Comment = 8,
252
+ * Document Fragment (also what a shadow root is) = 11.
253
+ */
254
+ nodeType: number;
255
+ /**
256
+ * Gets the element's `outerHTML. This is a read-only property and will
257
+ * throw an error if set.
258
+ */
259
+ outerHTML: string;
260
+ /**
261
+ * Focuses the element, and then uses `keyboard.down` and `keyboard.up`.
262
+ * If key is a single character and no modifier keys besides Shift are
263
+ * being held down, a keypress/input event will also be generated. The
264
+ * text option can be specified to force an input event to be generated.
265
+ * Note: Modifier keys DO effect `elementHandle.press`. Holding down Shift
266
+ * will type the text in upper case.
267
+ * Key names: https://github.com/puppeteer/puppeteer/blob/main/src/common/USKeyboardLayout.ts
268
+ */
269
+ press(key: string, options?: {
270
+ text?: string;
271
+ delay?: number;
272
+ }): Promise<void>;
273
+ /**
274
+ * Removes the attribute on the specified element. Note that
275
+ * `await page.waitForChanges()` must be called before reading
276
+ * the value if content has changed.
277
+ */
278
+ removeAttribute(name: string): void;
279
+ /**
280
+ * Sets the value of an attribute on the specified element. If the
281
+ * attribute already exists, the value is updated; otherwise a new
282
+ * attribute is added with the specified name and value. The value
283
+ * will always be converted to a string. Note that
284
+ * `await page.waitForChanges()` must be called before reading
285
+ * the value if content has changed.
286
+ */
287
+ setAttribute(name: string, value: any): void;
288
+ /**
289
+ * Used to set a property set on a component. For example, if a
290
+ * component has the property `elm.myProp`, then calling
291
+ * `elm.setProperty('myProp', 88)` would set the value `88` to
292
+ * the `myProp` property on the component.
293
+ */
294
+ setProperty(propertyName: string, value: any): void;
295
+ /**
296
+ * The ShadowRoot interface of the Shadow DOM API is the root node of a
297
+ * DOM subtree that is rendered separately from a document's main DOM tree.
298
+ * This value will be `null` if the element does not have a `shadowRoot`.
299
+ */
300
+ shadowRoot: ShadowRoot;
301
+ /**
302
+ * Used to test if an event was, or was not dispatched. This method
303
+ * returns a promise, that resolves with an EventSpy. The EventSpy
304
+ * can be used along with `expect(spy).toHaveReceivedEvent()`,
305
+ * `expect(spy).toHaveReceivedEventTimes(x)` and
306
+ * `expect(spy).toHaveReceivedEventDetail({...})`.
307
+ */
308
+ spyOnEvent(eventName: string): Promise<EventSpy>;
309
+ /**
310
+ * Represents the tab order of the current element. Setting the
311
+ * `tabIndex` property will also set the `tabindex` attribute.
312
+ */
313
+ tabIndex: number;
314
+ /**
315
+ * Tag name of the element. Note, this will always be upper-cased.
316
+ */
317
+ tagName: string;
318
+ /**
319
+ * This method scrolls the element it into view if needed,
320
+ * and then uses `page.touchscreen` to tap in the center of the element.
321
+ */
322
+ tap(): Promise<void>;
323
+ /**
324
+ * The `textContent` property represents the text content of a node
325
+ * and its descendants. Note that `await page.waitForChanges()` must
326
+ * be called before reading the value if content has changed.
327
+ */
328
+ textContent: string;
329
+ /**
330
+ * Represents the `title` of the element, the text usually displayed in a
331
+ * 'tool tip' popup when the mouse is over the displayed node.
332
+ */
333
+ title: string;
334
+ /**
335
+ * Toggles a `boolean` attribute (removing it if it is present and adding
336
+ * it if it is not present) on the given element. Note that
337
+ * `await page.waitForChanges()` must be called before reading
338
+ * the value if content has changed. The optional `force` argument is a
339
+ * `boolean` value to determine whether the attribute should be added or
340
+ * removed, no matter whether the attribute is present or not at the moment.
341
+ */
342
+ toggleAttribute(name: string, force?: boolean): void;
343
+ /**
344
+ * This is a convenience method to easily create a `CustomEvent`,
345
+ * and dispatch it from the element, to include any custom event
346
+ * `detail` data as the second argument.
347
+ */
348
+ triggerEvent(eventName: string, eventInitDict?: EventInitDict): void;
349
+ /**
350
+ * Sends a keydown, keypress/input, and keyup event for each character in the text.
351
+ * To press a special key, like Control or ArrowDown, use `keyboard.press`.
352
+ */
353
+ type(text: string, options?: {
354
+ delay: number;
355
+ }): Promise<void>;
356
+ /**
357
+ * Waits until the element's style is `display !== 'none'`,
358
+ * `visibility !== 'hidden'`, `opacity !== '0'` and the element
359
+ * is connected to the document.
360
+ */
361
+ waitForVisible(): Promise<void>;
362
+ /**
363
+ * Waits until the element's style is `display === 'none'`, or
364
+ * `visibility === 'hidden'`, or `opacity === '0'`, or the element
365
+ * is no longer connected to the document.
366
+ */
367
+ waitForNotVisible(): Promise<void>;
368
+ /**
369
+ * Waits until the given event is listened in the element.
370
+ */
371
+ waitForEvent(eventName: string): Promise<any>;
372
+ }
373
+ export interface E2EElementInternal extends E2EElement {
374
+ e2eDispose(): Promise<void>;
375
+ e2eRunActions(): Promise<unknown>;
376
+ e2eSync(): Promise<void>;
377
+ }
378
+ export type FindSelector = string | FindSelectorOptions;
379
+ export interface FindSelectorOptions {
380
+ /**
381
+ * Finds an element with text content matching this
382
+ * exact value after the whitespace has been trimmed.
383
+ */
384
+ text?: string;
385
+ /**
386
+ * Finds an element with text content containing this value.
387
+ */
388
+ contains?: string;
389
+ }
390
+ export interface WaitForEventOptions {
391
+ timeout?: number;
392
+ }
393
+ export interface WaitForEvent {
394
+ eventName: string;
395
+ callback: (ev: any) => void;
396
+ }
397
+ export interface BrowserWindow extends Window {
398
+ rindoOnEvent(id: number, event: any): void;
399
+ rindoSerializeEvent(ev: CustomEvent): any;
400
+ rindoSerializeEventTarget(target: any): any;
401
+ rindoAppLoaded: boolean;
402
+ }
403
+ export {};