diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 516aec549b80d..22ab759c7f155 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1949,18 +1949,6 @@ importers: specifier: 4.9.1 version: 4.9.1(webpack@5.76.0) - projects/packages/image-cdn: - devDependencies: - '@automattic/jetpack-webpack-config': - specifier: workspace:* - version: link:../../js-packages/webpack-config - webpack: - specifier: 5.76.0 - version: 5.76.0(webpack-cli@4.9.1) - webpack-cli: - specifier: 4.9.1 - version: 4.9.1(webpack@5.76.0) - projects/packages/import: {} projects/packages/jetpack-mu-wpcom: diff --git a/projects/packages/image-cdn/changelog/remove-lazy-support-image-cdn b/projects/packages/image-cdn/changelog/remove-lazy-support-image-cdn new file mode 100644 index 0000000000000..55efc69bae2c9 --- /dev/null +++ b/projects/packages/image-cdn/changelog/remove-lazy-support-image-cdn @@ -0,0 +1,4 @@ +Significance: minor +Type: removed + +Lazy Loading: Removed compatibility script for Jetpack Lazy Loading module. diff --git a/projects/packages/image-cdn/composer.json b/projects/packages/image-cdn/composer.json index ab442913ff599..03daecc74b696 100644 --- a/projects/packages/image-cdn/composer.json +++ b/projects/packages/image-cdn/composer.json @@ -29,9 +29,7 @@ "@composer phpunit" ], "post-install-cmd": "WorDBless\\Composer\\InstallDropin::copy", - "post-update-cmd": "WorDBless\\Composer\\InstallDropin::copy", - "build-production": "pnpm run build-production", - "build-development": "pnpm run build" + "post-update-cmd": "WorDBless\\Composer\\InstallDropin::copy" }, "repositories": [ { @@ -51,7 +49,7 @@ }, "autotagger": true, "branch-alias": { - "dev-trunk": "0.3.x-dev" + "dev-trunk": "0.4.x-dev" }, "textdomain": "jetpack-image-cdn", "version-constants": { diff --git a/projects/packages/image-cdn/package.json b/projects/packages/image-cdn/package.json deleted file mode 100644 index 8548562808605..0000000000000 --- a/projects/packages/image-cdn/package.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "private": true, - "name": "@automattic/jetpack-image-cdn", - "version": "0.3.7-alpha", - "description": "Serve images through Jetpack's powerful CDN", - "homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/packages/image-cdn/#readme", - "bugs": { - "url": "https://github.com/Automattic/jetpack/labels/[Package] Image Cdn" - }, - "repository": { - "type": "git", - "url": "https://github.com/Automattic/jetpack.git", - "directory": "projects/packages/image-cdn" - }, - "license": "GPL-2.0-or-later", - "author": "Automattic", - "scripts": { - "build": "pnpm run clean && pnpm run build-js", - "build-js": "webpack", - "build-production": "pnpm run clean && pnpm run build-production-js", - "build-production-js": "NODE_ENV=production BABEL_ENV=production pnpm run build-js", - "clean": "rm -rf dist" - }, - "devDependencies": { - "@automattic/jetpack-webpack-config": "workspace:*", - "webpack": "5.76.0", - "webpack-cli": "4.9.1" - } -} diff --git a/projects/packages/image-cdn/src/class-image-cdn.php b/projects/packages/image-cdn/src/class-image-cdn.php index 3efae89543fb0..6714a875f9147 100644 --- a/projects/packages/image-cdn/src/class-image-cdn.php +++ b/projects/packages/image-cdn/src/class-image-cdn.php @@ -7,14 +7,12 @@ namespace Automattic\Jetpack\Image_CDN; -use Automattic\Jetpack\Assets; - /** * Class Image_CDN */ final class Image_CDN { - const PACKAGE_VERSION = '0.3.7-alpha'; + const PACKAGE_VERSION = '0.4.0-alpha'; /** * Singleton. @@ -114,9 +112,6 @@ private function setup() { add_filter( 'wp_calculate_image_srcset', array( $this, 'filter_srcset_array' ), 10, 5 ); add_filter( 'wp_calculate_image_sizes', array( $this, 'filter_sizes' ), 1, 2 ); // Early so themes can still easily filter. - // Helpers for maniuplated images. - add_action( 'wp_enqueue_scripts', array( $this, 'action_wp_enqueue_scripts' ), 9 ); - /** * Allow Photon to disable uploaded images resizing and use its own resize capabilities instead. * @@ -1228,30 +1223,6 @@ protected static function image_sizes() { return is_array( self::$image_sizes ) ? self::$image_sizes : array(); } - /** - * Enqueue Photon helper script - * - * @uses wp_enqueue_script, plugins_url - * @action wp_enqueue_script - * @return null - */ - public function action_wp_enqueue_scripts() { - if ( self::is_amp_endpoint() ) { - return; - } - - Assets::register_script( - 'jetpack-photon', - '../dist/image-cdn.js', - __FILE__, - array( - 'enqueue' => true, - 'nonminpath' => 'js/image-cdn.js', - 'in_footer' => true, - ) - ); - } - /** * Determine if image_downsize should utilize Photon via REST API. * diff --git a/projects/packages/image-cdn/src/js/image-cdn.js b/projects/packages/image-cdn/src/js/image-cdn.js deleted file mode 100644 index 269e957267243..0000000000000 --- a/projects/packages/image-cdn/src/js/image-cdn.js +++ /dev/null @@ -1,63 +0,0 @@ -/* eslint-disable */ -( function () { - /** - * - */ - function recalculate() { - if ( this.complete ) { - // Support for lazy loading: if there is a lazy-src attribute and it's value - // is not the same as the current src we should wait until the image load event - const lazySrc = this.getAttribute( 'data-lazy-src' ); - if ( lazySrc && this.src !== lazySrc ) { - this.addEventListener( 'onload', recalculate ); - return; - } - - // Copying CSS width/height into element attributes. - const width = this.width; - const height = this.height; - if ( width && width > 0 && height && height > 0 ) { - this.setAttribute( 'width', width ); - this.setAttribute( 'height', height ); - - reset_for_retina( this ); - } - } else { - this.addEventListener( 'onload', recalculate ); - return; - } - } - - /** - * For images lacking explicit dimensions and needing them, try to add them. - */ - var restore_dims = function () { - const elements = document.querySelectorAll( 'img[data-recalc-dims]' ); - for ( let i = 0; i < elements.length; i++ ) { - recalculate.call( elements[ i ] ); - } - }, - /** - * Modify given image's markup so that devicepx-jetpack.js will act on the image and it won't be reprocessed by this script. - * - * @param img - */ - reset_for_retina = function ( img ) { - img.removeAttribute( 'data-recalc-dims' ); - img.removeAttribute( 'scale' ); - }; - - /** - * Check both when page loads, and when IS is triggered. - */ - if ( typeof window !== 'undefined' && typeof document !== 'undefined' ) { - // `DOMContentLoaded` may fire before the script has a chance to run - if ( document.readyState === 'loading' ) { - document.addEventListener( 'DOMContentLoaded', restore_dims ); - } else { - restore_dims(); - } - } - - document.body.addEventListener( 'is.post-load', restore_dims ); -} )(); diff --git a/projects/packages/image-cdn/webpack.config.js b/projects/packages/image-cdn/webpack.config.js deleted file mode 100644 index ca781997473f0..0000000000000 --- a/projects/packages/image-cdn/webpack.config.js +++ /dev/null @@ -1,31 +0,0 @@ -const path = require( 'path' ); -const jetpackWebpackConfig = require( '@automattic/jetpack-webpack-config/webpack' ); - -module.exports = [ - { - entry: { - 'image-cdn': './src/js/image-cdn.js', - }, - mode: jetpackWebpackConfig.mode, - devtool: jetpackWebpackConfig.devtool, - output: { - ...jetpackWebpackConfig.output, - path: path.resolve( './dist' ), - }, - optimization: { - ...jetpackWebpackConfig.optimization, - }, - resolve: { - ...jetpackWebpackConfig.resolve, - }, - node: false, - plugins: [ ...jetpackWebpackConfig.StandardPlugins() ], - module: { - strictExportPresence: true, - rules: [ - // Transpile JavaScript, including node_modules. - jetpackWebpackConfig.TranspileRule(), - ], - }, - }, -]; diff --git a/projects/plugins/boost/changelog/remove-lazy-support-image-cdn b/projects/plugins/boost/changelog/remove-lazy-support-image-cdn new file mode 100644 index 0000000000000..9aa70e3ec1f75 --- /dev/null +++ b/projects/plugins/boost/changelog/remove-lazy-support-image-cdn @@ -0,0 +1,5 @@ +Significance: patch +Type: changed +Comment: Updated composer.lock. + + diff --git a/projects/plugins/boost/composer.lock b/projects/plugins/boost/composer.lock index ee475fdbd91d5..cd34e4608f320 100644 --- a/projects/plugins/boost/composer.lock +++ b/projects/plugins/boost/composer.lock @@ -744,7 +744,7 @@ "dist": { "type": "path", "url": "../../packages/image-cdn", - "reference": "38d37494ab8ed0e2ae35658ba6f4c8e097a7476d" + "reference": "fdd9e3c288c7ada8ddcc70fb46ff4ae1426b3309" }, "require": { "automattic/jetpack-assets": "@dev", @@ -767,7 +767,7 @@ }, "autotagger": true, "branch-alias": { - "dev-trunk": "0.3.x-dev" + "dev-trunk": "0.4.x-dev" }, "textdomain": "jetpack-image-cdn", "version-constants": { @@ -791,12 +791,6 @@ ], "post-update-cmd": [ "WorDBless\\Composer\\InstallDropin::copy" - ], - "build-production": [ - "pnpm run build-production" - ], - "build-development": [ - "pnpm run build" ] }, "license": [ diff --git a/projects/plugins/jetpack/changelog/remove-lazy-support-image-cdn b/projects/plugins/jetpack/changelog/remove-lazy-support-image-cdn new file mode 100644 index 0000000000000..a1c1831fa1ef7 --- /dev/null +++ b/projects/plugins/jetpack/changelog/remove-lazy-support-image-cdn @@ -0,0 +1,5 @@ +Significance: patch +Type: other +Comment: Updated composer.lock. + + diff --git a/projects/plugins/jetpack/composer.lock b/projects/plugins/jetpack/composer.lock index c087d4286a7f6..b991b4d6e6f65 100644 --- a/projects/plugins/jetpack/composer.lock +++ b/projects/plugins/jetpack/composer.lock @@ -1302,7 +1302,7 @@ "dist": { "type": "path", "url": "../../packages/image-cdn", - "reference": "38d37494ab8ed0e2ae35658ba6f4c8e097a7476d" + "reference": "fdd9e3c288c7ada8ddcc70fb46ff4ae1426b3309" }, "require": { "automattic/jetpack-assets": "@dev", @@ -1325,7 +1325,7 @@ }, "autotagger": true, "branch-alias": { - "dev-trunk": "0.3.x-dev" + "dev-trunk": "0.4.x-dev" }, "textdomain": "jetpack-image-cdn", "version-constants": { @@ -1349,12 +1349,6 @@ ], "post-update-cmd": [ "WorDBless\\Composer\\InstallDropin::copy" - ], - "build-production": [ - "pnpm run build-production" - ], - "build-development": [ - "pnpm run build" ] }, "license": [