@remotion/renderer 4.0.0-fastlambda.8 → 4.0.0-lambda.3

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 (191) hide show
  1. package/dist/assets/cleanup-assets.d.ts +2 -0
  2. package/dist/assets/cleanup-assets.js +2 -0
  3. package/dist/assets/download-and-map-assets-to-file.d.ts +6 -0
  4. package/dist/assets/download-and-map-assets-to-file.js +46 -19
  5. package/dist/assets/ffmpeg-volume-expression.d.ts +2 -1
  6. package/dist/assets/ffmpeg-volume-expression.js +15 -12
  7. package/dist/assets/get-audio-channels.d.ts +5 -2
  8. package/dist/assets/get-audio-channels.js +15 -4
  9. package/dist/browser/Accessibility.d.ts +175 -0
  10. package/dist/browser/Accessibility.js +423 -0
  11. package/dist/browser/AriaQueryHandler.d.ts +20 -0
  12. package/dist/browser/AriaQueryHandler.js +108 -0
  13. package/dist/browser/Browser.d.ts +209 -0
  14. package/dist/browser/Browser.js +402 -0
  15. package/dist/browser/BrowserConnector.d.ts +26 -0
  16. package/dist/browser/BrowserConnector.js +49 -0
  17. package/dist/browser/BrowserFetcher.d.ts +89 -0
  18. package/dist/browser/BrowserFetcher.js +512 -0
  19. package/dist/browser/BrowserRunner.d.ts +39 -0
  20. package/dist/browser/BrowserRunner.js +308 -0
  21. package/dist/browser/Connection.d.ts +49 -0
  22. package/dist/browser/Connection.js +262 -0
  23. package/dist/browser/ConnectionTransport.d.ts +21 -0
  24. package/dist/browser/ConnectionTransport.js +17 -0
  25. package/dist/browser/ConsoleMessage.d.ts +55 -0
  26. package/dist/browser/ConsoleMessage.js +75 -0
  27. package/dist/browser/Coverage.d.ts +180 -0
  28. package/dist/browser/Coverage.js +371 -0
  29. package/dist/browser/DOMWorld.d.ts +50 -0
  30. package/dist/browser/DOMWorld.js +280 -0
  31. package/dist/browser/Debug.d.ts +19 -0
  32. package/dist/browser/Debug.js +42 -0
  33. package/dist/browser/DeviceDescriptors.d.ts +40 -0
  34. package/dist/browser/DeviceDescriptors.js +1407 -0
  35. package/dist/browser/EmulationManager.d.ts +7 -0
  36. package/dist/browser/EmulationManager.js +40 -0
  37. package/dist/browser/Errors.d.ts +25 -0
  38. package/dist/browser/Errors.js +35 -0
  39. package/dist/browser/EvalTypes.d.ts +27 -0
  40. package/dist/browser/EvalTypes.js +17 -0
  41. package/dist/browser/EventEmitter.d.ts +70 -0
  42. package/dist/browser/EventEmitter.js +102 -0
  43. package/dist/browser/ExecutionContext.d.ts +35 -0
  44. package/dist/browser/ExecutionContext.js +190 -0
  45. package/dist/browser/FileChooser.d.ts +56 -0
  46. package/dist/browser/FileChooser.js +86 -0
  47. package/dist/browser/FrameManager.d.ts +96 -0
  48. package/dist/browser/FrameManager.js +512 -0
  49. package/dist/browser/HTTPRequest.d.ts +42 -0
  50. package/dist/browser/HTTPRequest.js +82 -0
  51. package/dist/browser/HTTPResponse.d.ts +100 -0
  52. package/dist/browser/HTTPResponse.js +196 -0
  53. package/dist/browser/Input.d.ts +355 -0
  54. package/dist/browser/Input.js +592 -0
  55. package/dist/browser/JSHandle.d.ts +36 -0
  56. package/dist/browser/JSHandle.js +93 -0
  57. package/dist/browser/LaunchOptions.d.ts +117 -0
  58. package/dist/browser/LaunchOptions.js +17 -0
  59. package/dist/browser/Launcher.d.ts +9 -0
  60. package/dist/browser/Launcher.js +602 -0
  61. package/dist/browser/LifecycleWatcher.d.ts +29 -0
  62. package/dist/browser/LifecycleWatcher.js +193 -0
  63. package/dist/browser/NetworkConditions.d.ts +26 -0
  64. package/dist/browser/NetworkConditions.js +33 -0
  65. package/dist/browser/NetworkEventManager.d.ts +35 -0
  66. package/dist/browser/NetworkEventManager.js +128 -0
  67. package/dist/browser/NetworkManager.d.ts +36 -0
  68. package/dist/browser/NetworkManager.js +284 -0
  69. package/dist/browser/NodeWebSocketTransport.d.ts +11 -0
  70. package/dist/browser/NodeWebSocketTransport.js +90 -0
  71. package/dist/browser/PDFOptions.d.ts +165 -0
  72. package/dist/browser/PDFOptions.js +34 -0
  73. package/dist/browser/PipeTransport.d.ts +10 -0
  74. package/dist/browser/PipeTransport.js +86 -0
  75. package/dist/browser/Product.d.ts +16 -0
  76. package/dist/browser/Product.js +17 -0
  77. package/dist/browser/Puppeteer.d.ts +35 -0
  78. package/dist/browser/Puppeteer.js +17 -0
  79. package/dist/browser/PuppeteerNode.d.ts +92 -0
  80. package/dist/browser/PuppeteerNode.js +143 -0
  81. package/dist/browser/PuppeteerViewport.d.ts +5 -0
  82. package/dist/browser/PuppeteerViewport.js +2 -0
  83. package/dist/browser/QueryHandler.d.ts +64 -0
  84. package/dist/browser/QueryHandler.js +183 -0
  85. package/dist/browser/ScreenshotOptions.d.ts +14 -0
  86. package/dist/browser/ScreenshotOptions.js +2 -0
  87. package/dist/browser/SecurityDetails.d.ts +55 -0
  88. package/dist/browser/SecurityDetails.js +95 -0
  89. package/dist/browser/Target.d.ts +61 -0
  90. package/dist/browser/Target.js +146 -0
  91. package/dist/browser/TaskQueue.d.ts +20 -0
  92. package/dist/browser/TaskQueue.js +47 -0
  93. package/dist/browser/TimeoutSettings.d.ts +23 -0
  94. package/dist/browser/TimeoutSettings.js +62 -0
  95. package/dist/browser/Tracing.d.ts +45 -0
  96. package/dist/browser/Tracing.js +136 -0
  97. package/dist/browser/USKeyboardLayout.d.ts +39 -0
  98. package/dist/browser/USKeyboardLayout.js +406 -0
  99. package/dist/browser/WebWorker.d.ts +96 -0
  100. package/dist/browser/WebWorker.js +122 -0
  101. package/dist/browser/assert.d.ts +21 -0
  102. package/dist/browser/assert.js +29 -0
  103. package/dist/browser/compat.d.ts +2 -0
  104. package/dist/browser/compat.js +17 -0
  105. package/dist/browser/create-browser-fetcher.d.ts +17 -0
  106. package/dist/browser/create-browser-fetcher.js +140 -0
  107. package/dist/browser/dialog.d.ts +70 -0
  108. package/dist/browser/dialog.js +114 -0
  109. package/dist/browser/environment.d.ts +16 -0
  110. package/dist/browser/environment.js +19 -0
  111. package/dist/browser/fetch.d.ts +16 -0
  112. package/dist/browser/fetch.js +46 -0
  113. package/dist/browser/find-up.d.ts +4 -0
  114. package/dist/browser/find-up.js +85 -0
  115. package/dist/browser/get-download-destination.d.ts +1 -0
  116. package/dist/browser/get-download-destination.js +38 -0
  117. package/dist/browser/mitt/index.d.ts +22 -0
  118. package/dist/browser/mitt/index.js +49 -0
  119. package/dist/browser/node.d.ts +2 -0
  120. package/dist/browser/node.js +9 -0
  121. package/dist/browser/page.d.ts +78 -0
  122. package/dist/browser/page.js +277 -0
  123. package/dist/browser/pkg-dir.d.ts +3 -0
  124. package/dist/browser/pkg-dir.js +13 -0
  125. package/dist/browser/revisions.d.ts +21 -0
  126. package/dist/browser/revisions.js +22 -0
  127. package/dist/browser/util.d.ts +46 -0
  128. package/dist/browser/util.js +161 -0
  129. package/dist/calculate-ffmpeg-filters.js +2 -2
  130. package/dist/combine-videos.d.ts +2 -1
  131. package/dist/combine-videos.js +8 -1
  132. package/dist/cycle-browser-tabs.d.ts +2 -1
  133. package/dist/cycle-browser-tabs.js +9 -2
  134. package/dist/ensure-presentation-timestamp.d.ts +1 -0
  135. package/dist/ensure-presentation-timestamp.js +57 -0
  136. package/dist/extract-frame-from-video.d.ts +11 -0
  137. package/dist/extract-frame-from-video.js +197 -0
  138. package/dist/frame-to-ffmpeg-timestamp.d.ts +1 -0
  139. package/dist/frame-to-ffmpeg-timestamp.js +8 -0
  140. package/dist/get-compositions.d.ts +5 -2
  141. package/dist/get-compositions.js +23 -5
  142. package/dist/get-duration-of-asset.d.ts +7 -0
  143. package/dist/get-duration-of-asset.js +36 -0
  144. package/dist/get-port.js +26 -24
  145. package/dist/index.d.ts +33 -9
  146. package/dist/index.js +14 -5
  147. package/dist/is-beyond-last-frame.d.ts +2 -0
  148. package/dist/is-beyond-last-frame.js +12 -0
  149. package/dist/last-frame-from-video-cache.d.ts +10 -0
  150. package/dist/last-frame-from-video-cache.js +50 -0
  151. package/dist/make-assets-download-dir.js +6 -1
  152. package/dist/make-cancel-signal.d.ts +7 -0
  153. package/dist/make-cancel-signal.js +25 -0
  154. package/dist/merge-audio-track.js +2 -2
  155. package/dist/offthread-video-server.d.ts +14 -0
  156. package/dist/offthread-video-server.js +67 -0
  157. package/dist/open-browser.d.ts +6 -6
  158. package/dist/open-browser.js +24 -20
  159. package/dist/prepare-server.d.ts +13 -2
  160. package/dist/prepare-server.js +35 -5
  161. package/dist/preprocess-audio-track.d.ts +1 -0
  162. package/dist/preprocess-audio-track.js +2 -2
  163. package/dist/prespawn-ffmpeg.d.ts +2 -0
  164. package/dist/prespawn-ffmpeg.js +10 -9
  165. package/dist/provide-screenshot.js +1 -1
  166. package/dist/puppeteer-screenshot.js +5 -1
  167. package/dist/render-frames.d.ts +6 -1
  168. package/dist/render-frames.js +96 -37
  169. package/dist/render-media.d.ts +12 -2
  170. package/dist/render-media.js +127 -54
  171. package/dist/render-still.d.ts +14 -4
  172. package/dist/render-still.js +58 -19
  173. package/dist/serve-handler/glob-slash.d.ts +1 -0
  174. package/dist/serve-handler/glob-slash.js +12 -0
  175. package/dist/serve-handler/index.d.ts +4 -0
  176. package/dist/serve-handler/index.js +205 -0
  177. package/dist/serve-handler/is-path-inside.d.ts +1 -0
  178. package/dist/serve-handler/is-path-inside.js +27 -0
  179. package/dist/serve-handler/range-parser.d.ts +13 -0
  180. package/dist/serve-handler/range-parser.js +57 -0
  181. package/dist/serve-static.d.ts +10 -3
  182. package/dist/serve-static.js +22 -4
  183. package/dist/set-props-and-env.d.ts +3 -1
  184. package/dist/set-props-and-env.js +28 -6
  185. package/dist/stitch-frames-to-video.d.ts +4 -1
  186. package/dist/stitch-frames-to-video.js +36 -15
  187. package/dist/stringify-ffmpeg-filter.js +3 -0
  188. package/dist/tmp-dir.js +5 -1
  189. package/dist/validate-fps-for-gif.d.ts +2 -0
  190. package/dist/validate-fps-for-gif.js +9 -0
  191. package/package.json +6 -7
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Copyright 2019 Google Inc. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { EvaluateFn, EvaluateFnReturnType, EvaluateHandleFn, SerializableOrJSHandle, UnwrapPromiseLike } from './EvalTypes';
17
+ import { ExecutionContext } from './ExecutionContext';
18
+ import { Frame } from './FrameManager';
19
+ import { ElementHandle, JSHandle } from './JSHandle';
20
+ import { TimeoutSettings } from './TimeoutSettings';
21
+ export declare class DOMWorld {
22
+ #private;
23
+ get _waitTasks(): Set<WaitTask>;
24
+ constructor(frame: Frame, timeoutSettings: TimeoutSettings);
25
+ frame(): Frame;
26
+ _setContext(context: ExecutionContext | null): void;
27
+ _hasContext(): boolean;
28
+ _detach(): void;
29
+ executionContext(): Promise<ExecutionContext>;
30
+ evaluateHandle<HandlerType extends JSHandle = JSHandle>(pageFunction: EvaluateHandleFn, ...args: SerializableOrJSHandle[]): Promise<HandlerType>;
31
+ evaluate<T extends EvaluateFn>(pageFunction: T, ...args: SerializableOrJSHandle[]): Promise<UnwrapPromiseLike<EvaluateFnReturnType<T>>>;
32
+ _document(): Promise<ElementHandle>;
33
+ waitForFunction(pageFunction: Function | string, ...args: SerializableOrJSHandle[]): Promise<JSHandle>;
34
+ title(): Promise<string>;
35
+ }
36
+ interface WaitTaskOptions {
37
+ domWorld: DOMWorld;
38
+ predicateBody: Function | string;
39
+ title: string;
40
+ timeout: number;
41
+ args: SerializableOrJSHandle[];
42
+ }
43
+ declare class WaitTask {
44
+ #private;
45
+ promise: Promise<JSHandle>;
46
+ constructor(options: WaitTaskOptions);
47
+ terminate(error: Error): void;
48
+ rerun(): Promise<void>;
49
+ }
50
+ export {};
@@ -0,0 +1,280 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright 2019 Google Inc. All rights reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
18
+ if (kind === "m") throw new TypeError("Private method is not writable");
19
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
20
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
21
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
22
+ };
23
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
24
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
25
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
26
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
27
+ };
28
+ var _DOMWorld_frame, _DOMWorld_timeoutSettings, _DOMWorld_documentPromise, _DOMWorld_contextPromise, _DOMWorld_contextResolveCallback, _DOMWorld_detached, _DOMWorld_waitTasks, _WaitTask_instances, _WaitTask_domWorld, _WaitTask_timeout, _WaitTask_predicateBody, _WaitTask_args, _WaitTask_runCount, _WaitTask_resolve, _WaitTask_reject, _WaitTask_timeoutTimer, _WaitTask_terminated, _WaitTask_cleanup;
29
+ Object.defineProperty(exports, "__esModule", { value: true });
30
+ exports.DOMWorld = void 0;
31
+ const assert_1 = require("./assert");
32
+ const Errors_1 = require("./Errors");
33
+ const util_1 = require("./util");
34
+ class DOMWorld {
35
+ constructor(frame, timeoutSettings) {
36
+ _DOMWorld_frame.set(this, void 0);
37
+ _DOMWorld_timeoutSettings.set(this, void 0);
38
+ _DOMWorld_documentPromise.set(this, null);
39
+ _DOMWorld_contextPromise.set(this, null);
40
+ _DOMWorld_contextResolveCallback.set(this, null);
41
+ _DOMWorld_detached.set(this, false);
42
+ _DOMWorld_waitTasks.set(this, new Set());
43
+ // Keep own reference to client because it might differ from the FrameManager's
44
+ // client for OOP iframes.
45
+ __classPrivateFieldSet(this, _DOMWorld_frame, frame, "f");
46
+ __classPrivateFieldSet(this, _DOMWorld_timeoutSettings, timeoutSettings, "f");
47
+ this._setContext(null);
48
+ }
49
+ get _waitTasks() {
50
+ return __classPrivateFieldGet(this, _DOMWorld_waitTasks, "f");
51
+ }
52
+ frame() {
53
+ return __classPrivateFieldGet(this, _DOMWorld_frame, "f");
54
+ }
55
+ _setContext(context) {
56
+ var _a;
57
+ if (context) {
58
+ (0, assert_1.assert)(__classPrivateFieldGet(this, _DOMWorld_contextResolveCallback, "f"), 'Execution Context has already been set.');
59
+ (_a = __classPrivateFieldGet(this, _DOMWorld_contextResolveCallback, "f")) === null || _a === void 0 ? void 0 : _a.call(null, context);
60
+ __classPrivateFieldSet(this, _DOMWorld_contextResolveCallback, null, "f");
61
+ for (const waitTask of this._waitTasks) {
62
+ waitTask.rerun();
63
+ }
64
+ }
65
+ else {
66
+ __classPrivateFieldSet(this, _DOMWorld_documentPromise, null, "f");
67
+ __classPrivateFieldSet(this, _DOMWorld_contextPromise, new Promise((fulfill) => {
68
+ __classPrivateFieldSet(this, _DOMWorld_contextResolveCallback, fulfill, "f");
69
+ }), "f");
70
+ }
71
+ }
72
+ _hasContext() {
73
+ return !__classPrivateFieldGet(this, _DOMWorld_contextResolveCallback, "f");
74
+ }
75
+ _detach() {
76
+ __classPrivateFieldSet(this, _DOMWorld_detached, true, "f");
77
+ for (const waitTask of this._waitTasks) {
78
+ waitTask.terminate(new Error('waitForFunction failed: frame got detached.'));
79
+ }
80
+ }
81
+ executionContext() {
82
+ if (__classPrivateFieldGet(this, _DOMWorld_detached, "f")) {
83
+ throw new Error(`Execution context is not available in detached frame "${__classPrivateFieldGet(this, _DOMWorld_frame, "f").url()}" (are you trying to evaluate?)`);
84
+ }
85
+ if (__classPrivateFieldGet(this, _DOMWorld_contextPromise, "f") === null) {
86
+ throw new Error(`Execution content promise is missing`);
87
+ }
88
+ return __classPrivateFieldGet(this, _DOMWorld_contextPromise, "f");
89
+ }
90
+ async evaluateHandle(pageFunction, ...args) {
91
+ const context = await this.executionContext();
92
+ return context.evaluateHandle(pageFunction, ...args);
93
+ }
94
+ async evaluate(pageFunction, ...args) {
95
+ const context = await this.executionContext();
96
+ return context.evaluate(pageFunction, ...args);
97
+ }
98
+ _document() {
99
+ if (__classPrivateFieldGet(this, _DOMWorld_documentPromise, "f")) {
100
+ return __classPrivateFieldGet(this, _DOMWorld_documentPromise, "f");
101
+ }
102
+ __classPrivateFieldSet(this, _DOMWorld_documentPromise, this.executionContext().then(async (context) => {
103
+ const document = await context.evaluateHandle('document');
104
+ const element = document.asElement();
105
+ if (element === null) {
106
+ throw new Error('Document is null');
107
+ }
108
+ return element;
109
+ }), "f");
110
+ return __classPrivateFieldGet(this, _DOMWorld_documentPromise, "f");
111
+ }
112
+ waitForFunction(pageFunction, ...args) {
113
+ const timeout = __classPrivateFieldGet(this, _DOMWorld_timeoutSettings, "f").timeout();
114
+ const waitTaskOptions = {
115
+ domWorld: this,
116
+ predicateBody: pageFunction,
117
+ title: 'function',
118
+ timeout,
119
+ args,
120
+ };
121
+ const waitTask = new WaitTask(waitTaskOptions);
122
+ return waitTask.promise;
123
+ }
124
+ title() {
125
+ return this.evaluate(() => {
126
+ return document.title;
127
+ });
128
+ }
129
+ }
130
+ exports.DOMWorld = DOMWorld;
131
+ _DOMWorld_frame = new WeakMap(), _DOMWorld_timeoutSettings = new WeakMap(), _DOMWorld_documentPromise = new WeakMap(), _DOMWorld_contextPromise = new WeakMap(), _DOMWorld_contextResolveCallback = new WeakMap(), _DOMWorld_detached = new WeakMap(), _DOMWorld_waitTasks = new WeakMap();
132
+ const noop = () => undefined;
133
+ class WaitTask {
134
+ constructor(options) {
135
+ _WaitTask_instances.add(this);
136
+ _WaitTask_domWorld.set(this, void 0);
137
+ _WaitTask_timeout.set(this, void 0);
138
+ _WaitTask_predicateBody.set(this, void 0);
139
+ _WaitTask_args.set(this, void 0);
140
+ _WaitTask_runCount.set(this, 0);
141
+ _WaitTask_resolve.set(this, noop);
142
+ _WaitTask_reject.set(this, noop);
143
+ _WaitTask_timeoutTimer.set(this, void 0);
144
+ _WaitTask_terminated.set(this, false);
145
+ function getPredicateBody(predicateBody) {
146
+ if ((0, util_1.isString)(predicateBody)) {
147
+ return `return (${predicateBody});`;
148
+ }
149
+ return `return (${predicateBody})(...args);`;
150
+ }
151
+ __classPrivateFieldSet(this, _WaitTask_domWorld, options.domWorld, "f");
152
+ __classPrivateFieldSet(this, _WaitTask_timeout, options.timeout, "f");
153
+ __classPrivateFieldSet(this, _WaitTask_predicateBody, getPredicateBody(options.predicateBody), "f");
154
+ __classPrivateFieldSet(this, _WaitTask_args, options.args, "f");
155
+ __classPrivateFieldSet(this, _WaitTask_runCount, 0, "f");
156
+ __classPrivateFieldGet(this, _WaitTask_domWorld, "f")._waitTasks.add(this);
157
+ this.promise = new Promise((resolve, reject) => {
158
+ __classPrivateFieldSet(this, _WaitTask_resolve, resolve, "f");
159
+ __classPrivateFieldSet(this, _WaitTask_reject, reject, "f");
160
+ });
161
+ // Since page navigation requires us to re-install the pageScript, we should track
162
+ // timeout on our end.
163
+ if (options.timeout) {
164
+ const timeoutError = new Errors_1.TimeoutError(`waiting for ${options.title} failed: timeout ${options.timeout}ms exceeded`);
165
+ __classPrivateFieldSet(this, _WaitTask_timeoutTimer, setTimeout(() => {
166
+ return this.terminate(timeoutError);
167
+ }, options.timeout), "f");
168
+ }
169
+ this.rerun();
170
+ }
171
+ terminate(error) {
172
+ __classPrivateFieldSet(this, _WaitTask_terminated, true, "f");
173
+ __classPrivateFieldGet(this, _WaitTask_reject, "f").call(this, error);
174
+ __classPrivateFieldGet(this, _WaitTask_instances, "m", _WaitTask_cleanup).call(this);
175
+ }
176
+ async rerun() {
177
+ var _a;
178
+ const runCount = __classPrivateFieldSet(this, _WaitTask_runCount, (_a = __classPrivateFieldGet(this, _WaitTask_runCount, "f"), ++_a), "f");
179
+ let success = null;
180
+ let error = null;
181
+ const context = await __classPrivateFieldGet(this, _WaitTask_domWorld, "f").executionContext();
182
+ if (__classPrivateFieldGet(this, _WaitTask_terminated, "f") || runCount !== __classPrivateFieldGet(this, _WaitTask_runCount, "f")) {
183
+ return;
184
+ }
185
+ if (__classPrivateFieldGet(this, _WaitTask_terminated, "f") || runCount !== __classPrivateFieldGet(this, _WaitTask_runCount, "f")) {
186
+ return;
187
+ }
188
+ try {
189
+ success = await context.evaluateHandle(waitForPredicatePageFunction, __classPrivateFieldGet(this, _WaitTask_predicateBody, "f"), __classPrivateFieldGet(this, _WaitTask_timeout, "f"), ...__classPrivateFieldGet(this, _WaitTask_args, "f"));
190
+ }
191
+ catch (error_) {
192
+ error = error_;
193
+ }
194
+ if (__classPrivateFieldGet(this, _WaitTask_terminated, "f") || runCount !== __classPrivateFieldGet(this, _WaitTask_runCount, "f")) {
195
+ if (success) {
196
+ await success.dispose();
197
+ }
198
+ return;
199
+ }
200
+ // Ignore timeouts in pageScript - we track timeouts ourselves.
201
+ // If the frame's execution context has already changed, `frame.evaluate` will
202
+ // throw an error - ignore this predicate run altogether.
203
+ if (!error &&
204
+ (await __classPrivateFieldGet(this, _WaitTask_domWorld, "f")
205
+ .evaluate((s) => {
206
+ return !s;
207
+ }, success)
208
+ .catch(() => {
209
+ return true;
210
+ }))) {
211
+ if (!success) {
212
+ throw new Error('Assertion: result handle is not available');
213
+ }
214
+ await success.dispose();
215
+ return;
216
+ }
217
+ if (error) {
218
+ if (error.message.includes('TypeError: binding is not a function')) {
219
+ return this.rerun();
220
+ }
221
+ // When frame is detached the task should have been terminated by the DOMWorld.
222
+ // This can fail if we were adding this task while the frame was detached,
223
+ // so we terminate here instead.
224
+ if (error.message.includes('Execution context is not available in detached frame')) {
225
+ this.terminate(new Error('waitForFunction failed: frame got detached.'));
226
+ return;
227
+ }
228
+ // When the page is navigated, the promise is rejected.
229
+ // We will try again in the new execution context.
230
+ if (error.message.includes('Execution context was destroyed')) {
231
+ return;
232
+ }
233
+ // We could have tried to evaluate in a context which was already
234
+ // destroyed.
235
+ if (error.message.includes('Cannot find context with specified id')) {
236
+ return;
237
+ }
238
+ __classPrivateFieldGet(this, _WaitTask_reject, "f").call(this, error);
239
+ }
240
+ else {
241
+ if (!success) {
242
+ throw new Error('Assertion: result handle is not available');
243
+ }
244
+ __classPrivateFieldGet(this, _WaitTask_resolve, "f").call(this, success);
245
+ }
246
+ __classPrivateFieldGet(this, _WaitTask_instances, "m", _WaitTask_cleanup).call(this);
247
+ }
248
+ }
249
+ _WaitTask_domWorld = new WeakMap(), _WaitTask_timeout = new WeakMap(), _WaitTask_predicateBody = new WeakMap(), _WaitTask_args = new WeakMap(), _WaitTask_runCount = new WeakMap(), _WaitTask_resolve = new WeakMap(), _WaitTask_reject = new WeakMap(), _WaitTask_timeoutTimer = new WeakMap(), _WaitTask_terminated = new WeakMap(), _WaitTask_instances = new WeakSet(), _WaitTask_cleanup = function _WaitTask_cleanup() {
250
+ if (__classPrivateFieldGet(this, _WaitTask_timeoutTimer, "f") !== undefined) {
251
+ clearTimeout(__classPrivateFieldGet(this, _WaitTask_timeoutTimer, "f"));
252
+ }
253
+ __classPrivateFieldGet(this, _WaitTask_domWorld, "f")._waitTasks.delete(this);
254
+ };
255
+ function waitForPredicatePageFunction(predicateBody, timeout, ...args) {
256
+ // eslint-disable-next-line no-new-func
257
+ const predicate = new Function('...args', predicateBody);
258
+ let timedOut = false;
259
+ if (timeout) {
260
+ setTimeout(() => {
261
+ timedOut = true;
262
+ }, timeout);
263
+ }
264
+ return new Promise((resolve) => {
265
+ async function onRaf() {
266
+ if (timedOut) {
267
+ resolve(undefined);
268
+ return;
269
+ }
270
+ const success = await predicate(...args);
271
+ if (success) {
272
+ resolve(success);
273
+ }
274
+ else {
275
+ requestAnimationFrame(onRaf);
276
+ }
277
+ }
278
+ onRaf();
279
+ });
280
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Copyright 2020 Google Inc. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ declare global {
17
+ var __PUPPETEER_DEBUG: string;
18
+ }
19
+ export declare const debug: (prefix: string) => (...args: unknown[]) => void;
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright 2020 Google Inc. All rights reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.debug = void 0;
19
+ const debug = (prefix) => {
20
+ return (...logArgs) => {
21
+ const debugLevel = globalThis.__PUPPETEER_DEBUG;
22
+ if (!debugLevel) {
23
+ return;
24
+ }
25
+ const everythingShouldBeLogged = debugLevel === '*';
26
+ const prefixMatchesDebugLevel = everythingShouldBeLogged ||
27
+ /**
28
+ * If the debug level is `foo*`, that means we match any prefix that
29
+ * starts with `foo`. If the level is `foo`, we match only the prefix
30
+ * `foo`.
31
+ */
32
+ (debugLevel.endsWith('*')
33
+ ? prefix.startsWith(debugLevel)
34
+ : prefix === debugLevel);
35
+ if (!prefixMatchesDebugLevel) {
36
+ return;
37
+ }
38
+ // eslint-disable-next-line no-console
39
+ console.log(`${prefix}:`, ...logArgs);
40
+ };
41
+ };
42
+ exports.debug = debug;
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Copyright 2017 Google Inc. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ /**
17
+ * @public
18
+ */
19
+ export interface Device {
20
+ name: string;
21
+ userAgent: string;
22
+ viewport: {
23
+ width: number;
24
+ height: number;
25
+ deviceScaleFactor: number;
26
+ isMobile: boolean;
27
+ hasTouch: boolean;
28
+ isLandscape: boolean;
29
+ };
30
+ }
31
+ /**
32
+ * @public
33
+ */
34
+ export declare type DevicesMap = {
35
+ [name: string]: Device;
36
+ };
37
+ /**
38
+ * @internal
39
+ */
40
+ export declare const _devicesMap: DevicesMap;