@elementor/editor-audits 4.4.0-1129 → 4.4.0-1130

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/dist/index.js CHANGED
@@ -246,16 +246,16 @@ async function requestPageContext(documentId, imageSizeRequests, allowNonceRetry
246
246
 
247
247
  // src/registry.ts
248
248
  var registry = /* @__PURE__ */ new Map();
249
- function registerAudit(audit26) {
250
- registry.set(audit26.id, audit26);
249
+ function registerAudit(audit25) {
250
+ registry.set(audit25.id, audit25);
251
251
  }
252
252
  function getRegisteredAudits() {
253
253
  return Array.from(registry.values());
254
254
  }
255
255
 
256
256
  // src/utils/is-scored-audit.ts
257
- function isScoredAudit(audit26) {
258
- return audit26.weight > 0;
257
+ function isScoredAudit(audit25) {
258
+ return audit25.weight > 0;
259
259
  }
260
260
 
261
261
  // src/utils/sort-failed-audits.ts
@@ -316,16 +316,16 @@ function computeReport(documentId, results) {
316
316
  const accumulators = Object.fromEntries(
317
317
  ALL_CATEGORIES.map((c) => [c, { totalWeight: 0, passedWeight: 0, total: 0, failed: 0 }])
318
318
  );
319
- for (const { audit: audit26, result } of results) {
319
+ for (const { audit: audit25, result } of results) {
320
320
  if (result.status === "skipped") {
321
321
  continue;
322
322
  }
323
- for (const category of audit26.categories) {
323
+ for (const category of audit25.categories) {
324
324
  const acc = accumulators[category];
325
325
  acc.total++;
326
- acc.totalWeight += audit26.weight;
326
+ acc.totalWeight += audit25.weight;
327
327
  if (result.status === "pass") {
328
- acc.passedWeight += audit26.weight;
328
+ acc.passedWeight += audit25.weight;
329
329
  } else {
330
330
  acc.failed++;
331
331
  }
@@ -641,10 +641,10 @@ async function runPageAudit(documentId) {
641
641
  const ctx = { documentId, elements, pageContext, kit, renderedHtml };
642
642
  const registered = getRegisteredAudits();
643
643
  const auditResults = await Promise.all(
644
- registered.map(async (audit26) => {
645
- const { evaluate: _evaluate, ...meta } = audit26;
644
+ registered.map(async (audit25) => {
645
+ const { evaluate: _evaluate, ...meta } = audit25;
646
646
  try {
647
- const result = await audit26.evaluate(ctx);
647
+ const result = await audit25.evaluate(ctx);
648
648
  return { audit: meta, result };
649
649
  } catch (error) {
650
650
  const reason = error instanceof Error ? error.message : "unknown-error";
@@ -1125,9 +1125,9 @@ function ViolationIcon({ violation, widgetIcon }) {
1125
1125
  function SkipReasonTooltip({ reason }) {
1126
1126
  return /* @__PURE__ */ React12.createElement(import_ui11.Tooltip, { title: reason, placement: "top" }, /* @__PURE__ */ React12.createElement(import_ui11.Box, { "aria-label": reason, component: "span", sx: { display: "inline-flex", alignItems: "center" } }, /* @__PURE__ */ React12.createElement(import_icons10.HelpIcon, { fontSize: "small", color: "action" })));
1127
1127
  }
1128
- function StatusIndicator({ audit: audit26, violations }) {
1128
+ function StatusIndicator({ audit: audit25, violations }) {
1129
1129
  if (violations) {
1130
- return /* @__PURE__ */ React12.createElement(React12.Fragment, null, /* @__PURE__ */ React12.createElement(SeverityIcon, { severity: audit26.severity }), isScoredAudit(audit26) && /* @__PURE__ */ React12.createElement(import_ui11.Typography, { variant: "caption", color: "text.secondary", fontWeight: "bold" }, violations.length));
1130
+ return /* @__PURE__ */ React12.createElement(React12.Fragment, null, /* @__PURE__ */ React12.createElement(SeverityIcon, { severity: audit25.severity }), isScoredAudit(audit25) && /* @__PURE__ */ React12.createElement(import_ui11.Typography, { variant: "caption", color: "text.secondary", fontWeight: "bold" }, violations.length));
1131
1131
  }
1132
1132
  return /* @__PURE__ */ React12.createElement(import_icons10.CheckIcon, { fontSize: "small", color: "success" });
1133
1133
  }
@@ -1169,7 +1169,7 @@ function getSharedAngiePrompt(violations) {
1169
1169
  );
1170
1170
  return allShareTheSameFix ? first.angiePrompt : void 0;
1171
1171
  }
1172
- function ViolationRow({ audit: audit26, expanded, onToggleExpand, skipReason, violations }) {
1172
+ function ViolationRow({ audit: audit25, expanded, onToggleExpand, skipReason, violations }) {
1173
1173
  const primaryViolation = violations?.[0];
1174
1174
  const isGuidanceFocusable = !!primaryViolation;
1175
1175
  const panelZIndex = (0, import_editor_floating_panels2.useFloatingPanelZIndex)(AUDIT_PANEL_ID);
@@ -1192,8 +1192,8 @@ function ViolationRow({ audit: audit26, expanded, onToggleExpand, skipReason, vi
1192
1192
  },
1193
1193
  onClick: onToggleExpand
1194
1194
  },
1195
- /* @__PURE__ */ React12.createElement(import_ui11.Typography, { variant: "subtitle2", color: "text.secondary", sx: { flex: 1 } }, audit26.title),
1196
- !skipReason && /* @__PURE__ */ React12.createElement(StatusIndicator, { audit: audit26, violations })
1195
+ /* @__PURE__ */ React12.createElement(import_ui11.Typography, { variant: "subtitle2", color: "text.secondary", sx: { flex: 1 } }, audit25.title),
1196
+ !skipReason && /* @__PURE__ */ React12.createElement(StatusIndicator, { audit: audit25, violations })
1197
1197
  ), skipReason && /* @__PURE__ */ React12.createElement(SkipReasonTooltip, { reason: skipReason }), /* @__PURE__ */ React12.createElement(
1198
1198
  import_ui11.IconButton,
1199
1199
  {
@@ -1211,7 +1211,7 @@ function ViolationRow({ audit: audit26, expanded, onToggleExpand, skipReason, vi
1211
1211
  }
1212
1212
  }
1213
1213
  )
1214
- )), /* @__PURE__ */ React12.createElement(import_ui11.Collapse, { in: expanded }, /* @__PURE__ */ React12.createElement(import_ui11.Box, { paddingBlock: 1 }, /* @__PURE__ */ React12.createElement(import_ui11.Tooltip, { title: audit26.fixHint, placement: "top" }, /* @__PURE__ */ React12.createElement(
1214
+ )), /* @__PURE__ */ React12.createElement(import_ui11.Collapse, { in: expanded }, /* @__PURE__ */ React12.createElement(import_ui11.Box, { paddingBlock: 1 }, /* @__PURE__ */ React12.createElement(import_ui11.Tooltip, { title: audit25.fixHint, placement: "top" }, /* @__PURE__ */ React12.createElement(
1215
1215
  import_ui11.Alert,
1216
1216
  {
1217
1217
  severity: "secondary",
@@ -1222,7 +1222,7 @@ function ViolationRow({ audit: audit26, expanded, onToggleExpand, skipReason, vi
1222
1222
  onClick: isGuidanceFocusable ? handleGuidanceClick : void 0,
1223
1223
  onKeyDown: isGuidanceFocusable ? onKeyboardClick(handleGuidanceClick) : void 0
1224
1224
  },
1225
- /* @__PURE__ */ React12.createElement(import_ui11.Typography, { variant: "caption", component: "p", color: "text.secondary" }, audit26.description),
1225
+ /* @__PURE__ */ React12.createElement(import_ui11.Typography, { variant: "caption", component: "p", color: "text.secondary" }, audit25.description),
1226
1226
  primaryViolation && /* @__PURE__ */ React12.createElement(
1227
1227
  GuidanceAction,
1228
1228
  {
@@ -1340,17 +1340,17 @@ var import_i18n12 = require("@wordpress/i18n");
1340
1340
  var ALL_SEVERITIES = ["error", "warning", "info"];
1341
1341
  function countSeverities(report, category) {
1342
1342
  const counts = { error: 0, warning: 0, info: 0 };
1343
- for (const { audit: audit26, result } of report.auditResults) {
1343
+ for (const { audit: audit25, result } of report.auditResults) {
1344
1344
  if (result.status !== "fail") {
1345
1345
  continue;
1346
1346
  }
1347
- if (category && !audit26.categories.includes(category)) {
1347
+ if (category && !audit25.categories.includes(category)) {
1348
1348
  continue;
1349
1349
  }
1350
- if (!isScoredAudit(audit26)) {
1350
+ if (!isScoredAudit(audit25)) {
1351
1351
  continue;
1352
1352
  }
1353
- counts[audit26.severity] += result.violations.length;
1353
+ counts[audit25.severity] += result.violations.length;
1354
1354
  }
1355
1355
  return counts;
1356
1356
  }
@@ -1556,7 +1556,7 @@ function SeverityCard({ severity, count }) {
1556
1556
  flex: 1,
1557
1557
  flexDirection: "column",
1558
1558
  gap: 1,
1559
- bgcolor: "grey.50",
1559
+ bgcolor: "action.hover",
1560
1560
  borderRadius: 1.5,
1561
1561
  px: 1.5,
1562
1562
  py: 1
@@ -2982,50 +2982,6 @@ var audit24 = {
2982
2982
  }
2983
2983
  };
2984
2984
 
2985
- // src/audits/too-many-widgets.ts
2986
- var import_editor_elements9 = require("@elementor/editor-elements");
2987
- var import_i18n43 = require("@wordpress/i18n");
2988
- var WIDGET_COUNT_THRESHOLD = 100;
2989
- function isCountableWidget(node, widgetsCache) {
2990
- if (node.elType === "widget") {
2991
- return true;
2992
- }
2993
- return !!widgetsCache?.[node.elType]?.meta?.is_compound;
2994
- }
2995
- var audit25 = {
2996
- id: "audits/too-many-widgets",
2997
- title: (0, import_i18n43.__)("Too many widgets", "elementor"),
2998
- description: (0, import_i18n43.__)("Excessive DOM size caused by too many widgets degrades rendering performance.", "elementor"),
2999
- fixHint: (0, import_i18n43.__)("Reduce the number of widgets on the page by removing or combining elements.", "elementor"),
3000
- categories: ["best-practices", "performance"],
3001
- severity: "warning",
3002
- weight: 5,
3003
- evaluate: (ctx) => {
3004
- if (ctx.elements.tree.length === 0) {
3005
- return { status: "skipped", reason: (0, import_i18n43.__)("No elements", "elementor") };
3006
- }
3007
- const widgetsCache = (0, import_editor_elements9.getWidgetsCache)();
3008
- let widgetCount = 0;
3009
- walkElements(ctx.elements.tree, (node) => {
3010
- if (isCountableWidget(node, widgetsCache)) {
3011
- widgetCount++;
3012
- }
3013
- });
3014
- if (widgetCount <= WIDGET_COUNT_THRESHOLD) {
3015
- return { status: "pass" };
3016
- }
3017
- return {
3018
- status: "fail",
3019
- violations: [
3020
- {
3021
- auditId: audit25.id,
3022
- label: (0, import_i18n43.__)("Page has too many widgets.", "elementor")
3023
- }
3024
- ]
3025
- };
3026
- }
3027
- };
3028
-
3029
2985
  // src/register-audits.ts
3030
2986
  var AUDITS = [
3031
2987
  audit17,
@@ -3033,7 +2989,6 @@ var AUDITS = [
3033
2989
  audit16,
3034
2990
  audit10,
3035
2991
  audit7,
3036
- audit25,
3037
2992
  audit23,
3038
2993
  audit5,
3039
2994
  audit14,
@@ -3055,8 +3010,8 @@ var AUDITS = [
3055
3010
  audit8
3056
3011
  ];
3057
3012
  function registerAllAudits() {
3058
- for (const audit26 of AUDITS) {
3059
- registerAudit(audit26);
3013
+ for (const audit25 of AUDITS) {
3014
+ registerAudit(audit25);
3060
3015
  }
3061
3016
  }
3062
3017