lighthouse 10.4.0-dev.20230717 → 10.4.0-dev.20230718

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.
@@ -11,6 +11,15 @@ export class ExecutionContext {
11
11
  * @return {string}
12
12
  */
13
13
  static serializeArguments(args: unknown[]): string;
14
+ /**
15
+ * Serializes an array of functions or strings.
16
+ *
17
+ * Also makes sure that an esbuild-bundled version of Lighthouse will
18
+ * continue to create working code to be executed within the browser.
19
+ * @param {Array<Function|string>=} deps
20
+ * @return {string}
21
+ */
22
+ static serializeDeps(deps?: Array<Function | string> | undefined): string;
14
23
  /** @param {LH.Gatherer.ProtocolSession} session */
15
24
  constructor(session: LH.Gatherer.ProtocolSession);
16
25
  _session: LH.Gatherer.ProtocolSession;
@@ -47,15 +56,6 @@ export class ExecutionContext {
47
56
  * @return {Promise<*>}
48
57
  */
49
58
  _evaluateInContext(expression: string, contextId: number | undefined): Promise<any>;
50
- /**
51
- * Serializes an array of functions or strings.
52
- *
53
- * Also makes sure that an esbuild-bundled version of Lighthouse will
54
- * continue to create working code to be executed within the browser.
55
- * @param {Array<Function|string>=} deps
56
- * @return {string}
57
- */
58
- _serializeDeps(deps?: Array<Function | string> | undefined): string;
59
59
  /**
60
60
  * Note: Prefer `evaluate` instead.
61
61
  * Evaluate an expression in the context of the current page. If useIsolation is true, the expression
@@ -155,28 +155,6 @@ class ExecutionContext {
155
155
  }
156
156
  }
157
157
 
158
- /**
159
- * Serializes an array of functions or strings.
160
- *
161
- * Also makes sure that an esbuild-bundled version of Lighthouse will
162
- * continue to create working code to be executed within the browser.
163
- * @param {Array<Function|string>=} deps
164
- * @return {string}
165
- */
166
- _serializeDeps(deps) {
167
- deps = [pageFunctions.esbuildFunctionNameStubString, ...deps || []];
168
- return deps.map(dep => {
169
- if (typeof dep === 'function') {
170
- // esbuild will change the actual function name (ie. function actualName() {})
171
- // always, despite minification settings, but preserve the real name in `actualName.name`
172
- // (see esbuildFunctionNameStubString).
173
- return `const ${dep.name} = ${dep}`;
174
- } else {
175
- return dep;
176
- }
177
- }).join('\n');
178
- }
179
-
180
158
  /**
181
159
  * Note: Prefer `evaluate` instead.
182
160
  * Evaluate an expression in the context of the current page. If useIsolation is true, the expression
@@ -219,7 +197,7 @@ class ExecutionContext {
219
197
  */
220
198
  evaluate(mainFn, options) {
221
199
  const argsSerialized = ExecutionContext.serializeArguments(options.args);
222
- const depsSerialized = this._serializeDeps(options.deps);
200
+ const depsSerialized = ExecutionContext.serializeDeps(options.deps);
223
201
 
224
202
  const expression = `(() => {
225
203
  ${depsSerialized}
@@ -239,7 +217,7 @@ class ExecutionContext {
239
217
  */
240
218
  async evaluateOnNewDocument(mainFn, options) {
241
219
  const argsSerialized = ExecutionContext.serializeArguments(options.args);
242
- const depsSerialized = this._serializeDeps(options.deps);
220
+ const depsSerialized = ExecutionContext.serializeDeps(options.deps);
243
221
 
244
222
  const expression = `(() => {
245
223
  ${ExecutionContext._cachedNativesPreamble};
@@ -289,6 +267,28 @@ class ExecutionContext {
289
267
  static serializeArguments(args) {
290
268
  return args.map(arg => arg === undefined ? 'undefined' : JSON.stringify(arg)).join(',');
291
269
  }
270
+
271
+ /**
272
+ * Serializes an array of functions or strings.
273
+ *
274
+ * Also makes sure that an esbuild-bundled version of Lighthouse will
275
+ * continue to create working code to be executed within the browser.
276
+ * @param {Array<Function|string>=} deps
277
+ * @return {string}
278
+ */
279
+ static serializeDeps(deps) {
280
+ deps = [pageFunctions.esbuildFunctionNameStubString, ...deps || []];
281
+ return deps.map(dep => {
282
+ if (typeof dep === 'function') {
283
+ // esbuild will change the actual function name (ie. function actualName() {})
284
+ // always, despite minification settings, but preserve the real name in `actualName.name`
285
+ // (see esbuildFunctionNameStubString).
286
+ return `const ${dep.name} = ${dep}`;
287
+ } else {
288
+ return dep;
289
+ }
290
+ }).join('\n');
291
+ }
292
292
  }
293
293
 
294
294
  export {ExecutionContext};
@@ -514,12 +514,11 @@ function truncate(string, characterLimit) {
514
514
  }
515
515
 
516
516
  // This is to support bundled lighthouse.
517
- // esbuild calls every function with a builtin `__name`, whose purpose is to store the
518
- // real name of the function so that esbuild can rename it to avoid collisions. There is no way to
519
- // disable this renaming, even if esbuild minification (and thus function name mangling) is disabled.
520
- // Anywhere we inject dynamically generated code at runtime for the browser to process,
521
- // we must manually include this function (because esbuild only does so once at the top scope
522
- // of the bundle, which is irrelevant for code executed in the browser).
517
+ // esbuild calls every function with a builtin `__name` (since we set keepNames: true),
518
+ // whose purpose is to store the real name of the function so that esbuild can rename it to avoid
519
+ // collisions. Anywhere we inject dynamically generated code at runtime for the browser to process,
520
+ // we must manually include this function (because esbuild only does so once at the top scope of
521
+ // the bundle, which is irrelevant for code executed in the browser).
523
522
  const esbuildFunctionNameStubString = 'var __name=(fn)=>fn;';
524
523
 
525
524
  /** @type {string} */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "lighthouse",
3
3
  "type": "module",
4
- "version": "10.4.0-dev.20230717",
4
+ "version": "10.4.0-dev.20230718",
5
5
  "description": "Automated auditing, performance metrics, and best practices for the web.",
6
6
  "main": "./core/index.js",
7
7
  "bin": {
package/tsconfig.json CHANGED
@@ -30,6 +30,7 @@
30
30
  "shared/localization/locales/en-US.json",
31
31
  ],
32
32
  "exclude": [
33
+ "build/test/*test-case*.js",
33
34
  "core/test/audits/**/*.js",
34
35
  "core/test/fixtures/**/*.js",
35
36
  "core/test/computed/**/*.js",