@elementor/editor-audits 4.3.3 → 4.3.4
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.d.mts +9 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +560 -294
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +549 -273
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -13
- package/src/api/page-context-client.ts +8 -5
- package/src/audits/accessibility-statement.ts +39 -0
- package/src/audits/accessibility-widget.ts +41 -0
- package/src/audits/google-consent-mode.ts +4 -7
- package/src/audits/images-inefficient-format.ts +67 -0
- package/src/audits/images-too-large.ts +23 -9
- package/src/components/violation-cta-button.tsx +3 -2
- package/src/components/violation-row.tsx +13 -4
- package/src/register-audits.ts +6 -0
- package/src/register-promotions.ts +23 -0
- package/src/runner.ts +9 -5
- package/src/types.ts +9 -1
- package/src/utils/atomic-background-image-sources.ts +56 -0
- package/src/utils/atomic-image-sources.ts +62 -0
- package/src/utils/background-image-sources.ts +32 -0
- package/src/utils/image-alt.ts +3 -1
- package/src/utils/image-like-sources.ts +5 -2
- package/src/utils/image-size-key.ts +8 -0
- package/src/utils/page-attachments.ts +16 -7
- package/src/utils/scan-accessibility-widgets.ts +7 -0
|
@@ -7,6 +7,7 @@ export type ImageLikeMedia = {
|
|
|
7
7
|
id?: number;
|
|
8
8
|
url?: string;
|
|
9
9
|
alt?: string;
|
|
10
|
+
size?: string;
|
|
10
11
|
};
|
|
11
12
|
|
|
12
13
|
export type ImageLikeSourceVisit = {
|
|
@@ -51,7 +52,7 @@ function collectMediaFromNode( node: ElementSnapshotNode ): ImageLikeMedia[] {
|
|
|
51
52
|
const image = node.settings.image as ImageLikeMedia | undefined;
|
|
52
53
|
|
|
53
54
|
if ( image?.id || image?.url ) {
|
|
54
|
-
sources.push( image );
|
|
55
|
+
sources.push( { ...image, size: node.settings.image_size as string | undefined } );
|
|
55
56
|
}
|
|
56
57
|
|
|
57
58
|
const gallery = ( node.settings.carousel ?? node.settings.gallery ?? node.settings.wp_gallery ) as
|
|
@@ -59,9 +60,11 @@ function collectMediaFromNode( node: ElementSnapshotNode ): ImageLikeMedia[] {
|
|
|
59
60
|
| undefined;
|
|
60
61
|
|
|
61
62
|
if ( Array.isArray( gallery ) ) {
|
|
63
|
+
const gallerySize = node.settings.thumbnail_size as string | undefined;
|
|
64
|
+
|
|
62
65
|
for ( const item of gallery ) {
|
|
63
66
|
if ( item?.id || item?.url ) {
|
|
64
|
-
sources.push( item );
|
|
67
|
+
sources.push( { ...item, size: gallerySize } );
|
|
65
68
|
}
|
|
66
69
|
}
|
|
67
70
|
}
|
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
import { type ElementSnapshotNode } from '../types';
|
|
2
|
-
import {
|
|
2
|
+
import { walkAtomicBackgroundImageSources } from './atomic-background-image-sources';
|
|
3
|
+
import { walkAtomicImageSources } from './atomic-image-sources';
|
|
4
|
+
import { walkBackgroundImageSources } from './background-image-sources';
|
|
5
|
+
import { type ImageLikeMedia, walkImageLikeSources } from './image-like-sources';
|
|
6
|
+
import { buildImageSizeKey } from './image-size-key';
|
|
3
7
|
|
|
4
|
-
export function
|
|
5
|
-
const
|
|
8
|
+
export function extractImageSizeRequests( tree: ElementSnapshotNode[] ): string[] {
|
|
9
|
+
const keys = new Set< string >();
|
|
6
10
|
|
|
7
|
-
|
|
11
|
+
const collect = ( media: ImageLikeMedia ) => {
|
|
8
12
|
if ( media.id ) {
|
|
9
|
-
|
|
13
|
+
keys.add( buildImageSizeKey( { id: media.id, size: media.size } ) );
|
|
10
14
|
}
|
|
11
|
-
}
|
|
15
|
+
};
|
|
12
16
|
|
|
13
|
-
|
|
17
|
+
walkImageLikeSources( tree, ( { media } ) => collect( media ) );
|
|
18
|
+
walkBackgroundImageSources( tree, ( { media } ) => collect( media ) );
|
|
19
|
+
walkAtomicImageSources( tree, ( { media } ) => collect( media ) );
|
|
20
|
+
walkAtomicBackgroundImageSources( tree, ( { media } ) => collect( media ) );
|
|
21
|
+
|
|
22
|
+
return Array.from( keys ).sort();
|
|
14
23
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Script sources of known accessibility widgets. Ally is listed first; append third-party
|
|
2
|
+
// widget script sources here (UserWay, AccessiBe, EqualWeb, etc.) once confirmed.
|
|
3
|
+
const ACCESSIBILITY_WIDGET_SCRIPT_SOURCES = [ 'cdn.elementor.com/a11y/widget.js' ];
|
|
4
|
+
|
|
5
|
+
export function hasAccessibilityWidgetScript( html: string ): boolean {
|
|
6
|
+
return ACCESSIBILITY_WIDGET_SCRIPT_SOURCES.some( ( src ) => html.includes( src ) );
|
|
7
|
+
}
|