Skip to content

Commit

Permalink
update package, got all the strings now
Browse files Browse the repository at this point in the history
  • Loading branch information
connorjclark committed Feb 4, 2025
1 parent 46e62aa commit ae78390
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 35 deletions.
6 changes: 3 additions & 3 deletions core/audits/insights/dom-size-insight.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ class DOMSizeInsight extends Audit {

/** @type {LH.Audit.Details.Table['headings']} */
const headings = [
{key: 'statistic', valueType: 'text', label: 'Statistic'}, // TODO !
{key: 'node', valueType: 'node', label: str_(i18n.UIStrings.columnElement)},
{key: 'value', valueType: 'numeric', label: 'Value'}, // TODO !
{key: 'statistic', valueType: 'text', label: str_(UIStrings.statistic)},
{key: 'node', valueType: 'node', label: str_(UIStrings.element)},
{key: 'value', valueType: 'numeric', label: str_(UIStrings.value)},
];
/** @type {LH.Audit.Details.Table['items']} */
const items = [
Expand Down
1 change: 1 addition & 0 deletions core/audits/insights/viewport-insight.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class ViewportInsight extends Audit {
static async audit(artifacts, context) {
return adaptInsightToAuditProduct(artifacts, context, 'Viewport', (insight) => {
const nodeId = insight.viewportEvent?.args.data.node_id;
// TODO: we want to show this snippet in the report.
const htmlSnippet = insight.viewportEvent ?
`<meta name=viewport content="${insight.viewportEvent.args.data.content}">` :
null;
Expand Down
6 changes: 5 additions & 1 deletion core/computed/metrics/lantern-metric.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ async function getComputationDataParamsFromTrace(data, context) {
const graph = await PageDependencyGraph.request({...data, fromTrace: true}, context);
const traceEngineResult = await TraceEngineResult.request(data, context);
const frameId = traceEngineResult.data.Meta.mainFrameId;
const navigationId = traceEngineResult.data.Meta.mainFrameNavigations[0].args.data.navigationId;
const navigationId = traceEngineResult.data.Meta.mainFrameNavigations[0].args.data?.navigationId;
if (!navigationId) {
throw new Error(`Lantern metrics could not be calculated due to missing navigation id`);
}

const processedNavigation = Lantern.TraceEngineComputationData.createProcessedNavigation(
traceEngineResult.data, frameId, navigationId);
const simulator = data.simulator || (await LoadSimulator.request(data, context));
Expand Down
26 changes: 0 additions & 26 deletions core/computed/trace-engine-result.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* SPDX-License-Identifier: Apache-2.0
*/

import * as i18n from '../lib/i18n/i18n.js';
import * as TraceEngine from '../lib/trace-engine.js';
import {makeComputedArtifact} from './computed-artifact.js';
import {CumulativeLayoutShift} from './metrics/cumulative-layout-shift.js';
Expand All @@ -28,34 +27,9 @@ class TraceEngineResult {
), {});
if (!processor.parsedTrace) throw new Error('No data');
if (!processor.insights) throw new Error('No insights');
this.localizeInsights(processor.insights);
return {data: processor.parsedTrace, insights: processor.insights};
}

/**
* @param {import('@paulirish/trace_engine/models/trace/insights/types.js').TraceInsightSets} insightSets
*/
static localizeInsights(insightSets) {
for (const insightSet of insightSets.values()) {
for (const [name, model] of Object.entries(insightSet.model)) {
if (model instanceof Error) {
continue;
}

const key = `node_modules/@paulirish/trace_engine/models/trace/insights/${name}.js`;
const str_ = i18n.createIcuMessageFn(key, {
title: model.title,
description: model.description,
});

// @ts-expect-error coerce to string, should be fine
model.title = str_(model.title);
// @ts-expect-error coerce to string, should be fine
model.description = str_(model.description);
}
}
}

/**
* @param {{trace: LH.Trace}} data
* @param {LH.Artifacts.ComputedContext} context
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@
"webtreemap-cdt": "^3.2.1"
},
"dependencies": {
"@paulirish/trace_engine": "0.0.41",
"@paulirish/trace_engine": "0.0.42",
"@sentry/node": "^7.0.0",
"axe-core": "^4.10.2",
"chrome-launcher": "^1.1.2",
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1080,10 +1080,10 @@
"@nodelib/fs.scandir" "2.1.3"
fastq "^1.6.0"

"@paulirish/[email protected].41":
version "0.0.41"
resolved "https://registry.yarnpkg.com/@paulirish/trace_engine/-/trace_engine-0.0.41.tgz#7d631cc7a143e430ae9c2c4a1b95fb87fc95a9d3"
integrity sha512-pvr2UFt9XSIioc0pLy9AfzYixkr62cOjBL7+pFC3uLWEwbnQWweC5IWPsD1/I7wStoJLwBEhazcSaFeHnzzfYA==
"@paulirish/[email protected].42":
version "0.0.42"
resolved "https://registry.yarnpkg.com/@paulirish/trace_engine/-/trace_engine-0.0.42.tgz#94f72903f0ff26414e8e09fba5af410a0bc22942"
integrity sha512-gZx3UqNjoyISsxd+fLSm6d6umSgRoJ9RzgU79YAg9wPIIe795G8GbC89BML5vsxOOxxsakAv5bgCVK2WCyIwbw==
dependencies:
third-party-web latest

Expand Down

0 comments on commit ae78390

Please sign in to comment.