diff options
author | Yury German <blueknight@gentoo.org> | 2022-01-23 18:37:36 -0500 |
---|---|---|
committer | Yury German <blueknight@gentoo.org> | 2022-01-23 18:37:36 -0500 |
commit | f18b23a3a9378fb0a98856d436aa9ebf94e47429 (patch) | |
tree | e418433e22854ebd2d77eaa869d5d0470a973317 /plugins/jetpack/jetpack_vendor/automattic/jetpack-lazy-images | |
parent | Add classic-editor 1.5 (diff) | |
download | blogs-gentoo-f18b23a3a9378fb0a98856d436aa9ebf94e47429.tar.gz blogs-gentoo-f18b23a3a9378fb0a98856d436aa9ebf94e47429.tar.bz2 blogs-gentoo-f18b23a3a9378fb0a98856d436aa9ebf94e47429.zip |
Updating Classic Editor, Google Authenticatior, Jetpack, Public Post Preview, Table of Contents, Wordpress Importer
Signed-off-by: Yury German <blueknight@gentoo.org>
Diffstat (limited to 'plugins/jetpack/jetpack_vendor/automattic/jetpack-lazy-images')
12 files changed, 1367 insertions, 0 deletions
diff --git a/plugins/jetpack/jetpack_vendor/automattic/jetpack-lazy-images/CHANGELOG.md b/plugins/jetpack/jetpack_vendor/automattic/jetpack-lazy-images/CHANGELOG.md new file mode 100644 index 00000000..fbeb8c83 --- /dev/null +++ b/plugins/jetpack/jetpack_vendor/automattic/jetpack-lazy-images/CHANGELOG.md @@ -0,0 +1,189 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [2.1.0] - 2022-01-04 +### Changed +- Switch to pcov for code coverage. +- Updated package dependencies. +- Updated package textdomain from `jetpack` to `jetpack-lazy-images`. + +## [2.0.10] - 2021-12-14 + +## [2.0.9] - 2021-11-30 +### Changed +- Remove `.min` from built JS. +- Updated package dependencies. + +## [2.0.8] - 2021-11-22 +### Changed +- Updated package dependencies + +## [2.0.7] - 2021-11-17 +### Changed +- Updated package dependencies. + +## [2.0.6] - 2021-11-16 +### Added +- Use monorepo `validate-es` script to validate Webpack builds. + +### Changed +- Updated package dependencies. + +## [2.0.5] - 2021-11-09 +### Changed +- Update webpack build config. + +## [2.0.4] - 2021-11-02 +### Changed +- Set `convertDeprecationsToExceptions` true in PHPUnit config. +- Update PHPUnit configs to include just what needs coverage rather than include everything then try to exclude stuff that doesn't. + +## [2.0.3] - 2021-10-19 +### Changed +- Updated package dependencies. + +### Deprecated +- General: remove numerous long-deprecated functions. + +## [2.0.2] - 2021-10-12 +### Changed +- Updated package dependencies + +## [2.0.1] - 2021-09-28 +### Changed +- Allow Node ^14.17.6 to be used in this project. This shouldn't change the behavior of the code itself. +- Updated package dependencies. + +## [2.0.0] - 2021-08-31 +### Changed +- Run composer update on test-php command instead of phpunit. +- Tests: update PHPUnit polyfills dependency (yoast/phpunit-polyfills). +- Update annotations versions. +- Update to latest webpack, webpack-cli and calypso-build. +- Use Node 16.7.0 in tooling. This shouldn't change the behavior of the code itself. + +### Removed +- Removed IE11 support. + +## [1.5.1] - 2021-08-10 +### Changed +- Updated package dependencies + +## [1.5.0] - 2021-06-29 +### Changed +- Build using calypso-build, and use the intersection-observer npm module instead of bundling a copy. +- Update docs to replace yarn with pnpm. +- Update node version requirement to 14.16.1 + +## [1.4.4] - 2021-05-25 +### Changed +- Updated package dependencies. + +## [1.4.3] - 2021-04-27 +### Changed +- Updated package dependencies + +## [1.4.2] - 2021-03-30 +### Added +- Composer alias for dev-master, to improve dependencies + +### Changed +- Update package dependencies. + +### Fixed +- Update icon file used for tests, WP 5.7 no longer silences exif errors. +- Use `composer update` rather than `install` in scripts, as composer.lock isn't checked in. + +## [1.4.1] - 2021-02-23 + +- Update dependency webpack to v4.46.0 +- Update dependency webpack-cli to v4.5.0 +- CI: Make tests more generic +- CLI: Add install command + +## [1.4.0] - 2021-01-26 + +- Mirroring: Move build command into composer +- Mirroring: Fix vendor copy of lazy-images in jetpack-production +- Add mirror-repo information to all current composer packages +- Lazy Images: do not include js linting config in production +- Monorepo: Reorganize all projects +- Various PHPCS and Cleanup + +## [1.3.0] - 2021-01-05 + +- Lazy-Images: Downgrade to ES5 +- Pin dependencies +- Packages: Update for PHP 8 testing +- Reorganize composer scripts +- General: update minimum required version to WordPress 5.5 +- Codecoverage: fix reports +- Updated PHPCS: Packages and Debugger + +## [1.2.2] - 2020-12-09 + +- Update dependencies to latest stable +- Updated dependencies to latest stable + +## [1.2.1] - 2020-11-24 + +- General: update minimum required version to WordPress 5.5 +- Codecoverage: fix reports +- Updated PHPCS: Packages and Debugger + +## [1.2.0] - 2020-10-27 + +- Lazy Images: Use a better name for wp_localize_script's l10n object +- Lazy Images: Start linting lazy-images.js + +## [1.1.3] - 2020-12-09 + +- Update dependencies to latest stable + +## [1.1.2] - 2020-11-24 + +- Version packages for release + +## [1.1.1] - 2020-11-10 + +- Update dependencies to latest stable + +## [1.1.0] - 2020-09-29 + +- Consolidate the Lazy Images package to rely on the Assets package + +## 1.0.0 - 2020-08-25 + +- Lazy Images: Move into a package + +[2.1.0]: https://github.com/Automattic/jetpack-lazy-images/compare/v2.0.10...v2.1.0 +[2.0.10]: https://github.com/Automattic/jetpack-lazy-images/compare/v2.0.9...v2.0.10 +[2.0.9]: https://github.com/Automattic/jetpack-lazy-images/compare/v2.0.8...v2.0.9 +[2.0.8]: https://github.com/Automattic/jetpack-lazy-images/compare/v2.0.7...v2.0.8 +[2.0.7]: https://github.com/Automattic/jetpack-lazy-images/compare/v2.0.6...v2.0.7 +[2.0.6]: https://github.com/Automattic/jetpack-lazy-images/compare/v2.0.5...v2.0.6 +[2.0.5]: https://github.com/Automattic/jetpack-lazy-images/compare/v2.0.4...v2.0.5 +[2.0.4]: https://github.com/Automattic/jetpack-lazy-images/compare/v2.0.3...v2.0.4 +[2.0.3]: https://github.com/Automattic/jetpack-lazy-images/compare/v2.0.2...v2.0.3 +[2.0.2]: https://github.com/Automattic/jetpack-lazy-images/compare/v2.0.1...v2.0.2 +[2.0.1]: https://github.com/Automattic/jetpack-lazy-images/compare/v2.0.0...v2.0.1 +[2.0.0]: https://github.com/Automattic/jetpack-lazy-images/compare/v1.5.1...v2.0.0 +[1.5.1]: https://github.com/Automattic/jetpack-lazy-images/compare/v1.5.0...v1.5.1 +[1.5.0]: https://github.com/Automattic/jetpack-lazy-images/compare/v1.4.4...v1.5.0 +[1.4.4]: https://github.com/Automattic/jetpack-lazy-images/compare/v1.4.3...v1.4.4 +[1.4.3]: https://github.com/Automattic/jetpack-lazy-images/compare/v1.4.2...v1.4.3 +[1.4.2]: https://github.com/Automattic/jetpack-lazy-images/compare/v1.4.1...v1.4.2 +[1.4.1]: https://github.com/Automattic/jetpack-lazy-images/compare/v1.4.0...v1.4.1 +[1.4.0]: https://github.com/Automattic/jetpack-lazy-images/compare/v1.3.0...v1.4.0 +[1.3.0]: https://github.com/Automattic/jetpack-lazy-images/compare/v1.2.2...v1.3.0 +[1.2.2]: https://github.com/Automattic/jetpack-lazy-images/compare/v1.2.1...v1.2.2 +[1.2.1]: https://github.com/Automattic/jetpack-lazy-images/compare/v1.2.0...v1.2.1 +[1.2.0]: https://github.com/Automattic/jetpack-lazy-images/compare/v1.1.3...v1.2.0 +[1.1.3]: https://github.com/Automattic/jetpack-lazy-images/compare/v1.1.2...v1.1.3 +[1.1.2]: https://github.com/Automattic/jetpack-lazy-images/compare/v1.1.1...v1.1.2 +[1.1.1]: https://github.com/Automattic/jetpack-lazy-images/compare/v1.1.0...v1.1.1 +[1.1.0]: https://github.com/Automattic/jetpack-lazy-images/compare/v1.0.0...v1.1.0 diff --git a/plugins/jetpack/jetpack_vendor/automattic/jetpack-lazy-images/LICENSE.txt b/plugins/jetpack/jetpack_vendor/automattic/jetpack-lazy-images/LICENSE.txt new file mode 100644 index 00000000..e82774c1 --- /dev/null +++ b/plugins/jetpack/jetpack_vendor/automattic/jetpack-lazy-images/LICENSE.txt @@ -0,0 +1,357 @@ +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + +=================================== + + +GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + +Copyright (C) 1989, 1991 Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +Everyone is permitted to copy and distribute verbatim copies +of this license document, but changing it is not allowed. + + Preamble + +The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + +When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + +To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + +For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + +We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + +Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + +Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + +The precise terms and conditions for copying, distribution and +modification follow. + +GNU GENERAL PUBLIC LICENSE +TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + +0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + +1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + +2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + +a) You must cause the modified files to carry prominent notices +stating that you changed the files and the date of any change. + +b) You must cause any work that you distribute or publish, that in +whole or in part contains or is derived from the Program or any +part thereof, to be licensed as a whole at no charge to all third +parties under the terms of this License. + +c) If the modified program normally reads commands interactively +when run, you must cause it, when started running for such +interactive use in the most ordinary way, to print or display an +announcement including an appropriate copyright notice and a +notice that there is no warranty (or else, saying that you provide +a warranty) and that users may redistribute the program under +these conditions, and telling the user how to view a copy of this +License. (Exception: if the Program itself is interactive but +does not normally print such an announcement, your work based on +the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + +3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + +a) Accompany it with the complete corresponding machine-readable +source code, which must be distributed under the terms of Sections +1 and 2 above on a medium customarily used for software interchange; or, + +b) Accompany it with a written offer, valid for at least three +years, to give any third party, for a charge no more than your +cost of physically performing source distribution, a complete +machine-readable copy of the corresponding source code, to be +distributed under the terms of Sections 1 and 2 above on a medium +customarily used for software interchange; or, + +c) Accompany it with the information you received as to the offer +to distribute corresponding source code. (This alternative is +allowed only for noncommercial distribution and only if you +received the program in object code or executable form with such +an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + +4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + +5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + +6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + +7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + +8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + +9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + +10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + +11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + +12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + +How to Apply These Terms to Your New Programs + +If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + +To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + +<one line to give the program's name and a brief idea of what it does.> +Copyright (C) <year> <name of author> + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + +Gnomovision version 69, Copyright (C) year name of author +Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. +This is free software, and you are welcome to redistribute it +under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + +Yoyodyne, Inc., hereby disclaims all copyright interest in the program +`Gnomovision' (which makes passes at compilers) written by James Hacker. + +<signature of Ty Coon>, 1 April 1989 +Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/plugins/jetpack/jetpack_vendor/automattic/jetpack-lazy-images/SECURITY.md b/plugins/jetpack/jetpack_vendor/automattic/jetpack-lazy-images/SECURITY.md new file mode 100644 index 00000000..b4b46c0e --- /dev/null +++ b/plugins/jetpack/jetpack_vendor/automattic/jetpack-lazy-images/SECURITY.md @@ -0,0 +1,38 @@ +# Security Policy + +Full details of the Automattic Security Policy can be found on [automattic.com](https://automattic.com/security/). + +## Supported Versions + +Generally, only the latest version of Jetpack has continued support. If a critical vulnerability is found in the current version of Jetpack, we may opt to backport any patches to previous versions. + +## Reporting a Vulnerability + +[Jetpack](https://jetpack.com/) is an open-source plugin for WordPress. Our HackerOne program covers the plugin software, as well as a variety of related projects and infrastructure. + +**For responsible disclosure of security issues and to be eligible for our bug bounty program, please submit your report via the [HackerOne](https://hackerone.com/automattic) portal.** + +Our most critical targets are: + +* Jetpack and the Jetpack composer packages (all within this repo) +* Jetpack.com -- the primary marketing site. +* cloud.jetpack.com -- a management site. +* wordpress.com -- the shared management site for both Jetpack and WordPress.com sites. + +For more targets, see the `In Scope` section on [HackerOne](https://hackerone.com/automattic). + +_Please note that the **WordPress software is a separate entity** from Automattic. Please report vulnerabilities for WordPress through [the WordPress Foundation's HackerOne page](https://hackerone.com/wordpress)._ + +## Guidelines + +We're committed to working with security researchers to resolve the vulnerabilities they discover. You can help us by following these guidelines: + +* Follow [HackerOne's disclosure guidelines](https://www.hackerone.com/disclosure-guidelines). +* Pen-testing Production: + * Please **setup a local environment** instead whenever possible. Most of our code is open source (see above). + * If that's not possible, **limit any data access/modification** to the bare minimum necessary to reproduce a PoC. + * **_Don't_ automate form submissions!** That's very annoying for us, because it adds extra work for the volunteers who manage those systems, and reduces the signal/noise ratio in our communication channels. + * To be eligible for a bounty, all of these guidelines must be followed. +* Be Patient - Give us a reasonable time to correct the issue before you disclose the vulnerability. + +We also expect you to comply with all applicable laws. You're responsible to pay any taxes associated with your bounties. diff --git a/plugins/jetpack/jetpack_vendor/automattic/jetpack-lazy-images/dist/intersection-observer.asset.php b/plugins/jetpack/jetpack_vendor/automattic/jetpack-lazy-images/dist/intersection-observer.asset.php new file mode 100644 index 00000000..d56f1d1f --- /dev/null +++ b/plugins/jetpack/jetpack_vendor/automattic/jetpack-lazy-images/dist/intersection-observer.asset.php @@ -0,0 +1 @@ +<?php return array('dependencies' => array(), 'version' => '6ae6d91d4b64fe31e32c2797e7c3dd42');
\ No newline at end of file diff --git a/plugins/jetpack/jetpack_vendor/automattic/jetpack-lazy-images/dist/intersection-observer.js b/plugins/jetpack/jetpack_vendor/automattic/jetpack-lazy-images/dist/intersection-observer.js new file mode 100644 index 00000000..5fa4e6e7 --- /dev/null +++ b/plugins/jetpack/jetpack_vendor/automattic/jetpack-lazy-images/dist/intersection-observer.js @@ -0,0 +1 @@ +!function(){"use strict";if("object"==typeof window)if("IntersectionObserver"in window&&"IntersectionObserverEntry"in window&&"intersectionRatio"in window.IntersectionObserverEntry.prototype)"isIntersecting"in window.IntersectionObserverEntry.prototype||Object.defineProperty(window.IntersectionObserverEntry.prototype,"isIntersecting",{get:function(){return this.intersectionRatio>0}});else{var t=function(t){for(var e=window.document,o=i(e);o;)o=i(e=o.ownerDocument);return e}(),e=[],o=null,n=null;s.prototype.THROTTLE_TIMEOUT=100,s.prototype.POLL_INTERVAL=null,s.prototype.USE_MUTATION_OBSERVER=!0,s._setupCrossOriginUpdater=function(){return o||(o=function(t,o){n=t&&o?l(t,o):{top:0,bottom:0,left:0,right:0,width:0,height:0},e.forEach((function(t){t._checkForIntersections()}))}),o},s._resetCrossOriginUpdater=function(){o=null,n=null},s.prototype.observe=function(t){if(!this._observationTargets.some((function(e){return e.element==t}))){if(!t||1!=t.nodeType)throw new Error("target must be an Element");this._registerInstance(),this._observationTargets.push({element:t,entry:null}),this._monitorIntersections(t.ownerDocument),this._checkForIntersections()}},s.prototype.unobserve=function(t){this._observationTargets=this._observationTargets.filter((function(e){return e.element!=t})),this._unmonitorIntersections(t.ownerDocument),0==this._observationTargets.length&&this._unregisterInstance()},s.prototype.disconnect=function(){this._observationTargets=[],this._unmonitorAllIntersections(),this._unregisterInstance()},s.prototype.takeRecords=function(){var t=this._queuedEntries.slice();return this._queuedEntries=[],t},s.prototype._initThresholds=function(t){var e=t||[0];return Array.isArray(e)||(e=[e]),e.sort().filter((function(t,e,o){if("number"!=typeof t||isNaN(t)||t<0||t>1)throw new Error("threshold must be a number between 0 and 1 inclusively");return t!==o[e-1]}))},s.prototype._parseRootMargin=function(t){var e=(t||"0px").split(/\s+/).map((function(t){var e=/^(-?\d*\.?\d+)(px|%)$/.exec(t);if(!e)throw new Error("rootMargin must be specified in pixels or percent");return{value:parseFloat(e[1]),unit:e[2]}}));return e[1]=e[1]||e[0],e[2]=e[2]||e[0],e[3]=e[3]||e[1],e},s.prototype._monitorIntersections=function(e){var o=e.defaultView;if(o&&-1==this._monitoringDocuments.indexOf(e)){var n=this._checkForIntersections,r=null,s=null;this.POLL_INTERVAL?r=o.setInterval(n,this.POLL_INTERVAL):(h(o,"resize",n,!0),h(e,"scroll",n,!0),this.USE_MUTATION_OBSERVER&&"MutationObserver"in o&&(s=new o.MutationObserver(n)).observe(e,{attributes:!0,childList:!0,characterData:!0,subtree:!0})),this._monitoringDocuments.push(e),this._monitoringUnsubscribes.push((function(){var t=e.defaultView;t&&(r&&t.clearInterval(r),c(t,"resize",n,!0)),c(e,"scroll",n,!0),s&&s.disconnect()}));var u=this.root&&(this.root.ownerDocument||this.root)||t;if(e!=u){var a=i(e);a&&this._monitorIntersections(a.ownerDocument)}}},s.prototype._unmonitorIntersections=function(e){var o=this._monitoringDocuments.indexOf(e);if(-1!=o){var n=this.root&&(this.root.ownerDocument||this.root)||t,r=this._observationTargets.some((function(t){var o=t.element.ownerDocument;if(o==e)return!0;for(;o&&o!=n;){var r=i(o);if((o=r&&r.ownerDocument)==e)return!0}return!1}));if(!r){var s=this._monitoringUnsubscribes[o];if(this._monitoringDocuments.splice(o,1),this._monitoringUnsubscribes.splice(o,1),s(),e!=n){var h=i(e);h&&this._unmonitorIntersections(h.ownerDocument)}}}},s.prototype._unmonitorAllIntersections=function(){var t=this._monitoringUnsubscribes.slice(0);this._monitoringDocuments.length=0,this._monitoringUnsubscribes.length=0;for(var e=0;e<t.length;e++)t[e]()},s.prototype._checkForIntersections=function(){if(this.root||!o||n){var t=this._rootIsInDom(),e=t?this._getRootRect():{top:0,bottom:0,left:0,right:0,width:0,height:0};this._observationTargets.forEach((function(n){var i=n.element,s=u(i),h=this._rootContainsTarget(i),c=n.entry,a=t&&h&&this._computeTargetAndRootIntersection(i,s,e),l=null;this._rootContainsTarget(i)?o&&!this.root||(l=e):l={top:0,bottom:0,left:0,right:0,width:0,height:0};var f=n.entry=new r({time:window.performance&&performance.now&&performance.now(),target:i,boundingClientRect:s,rootBounds:l,intersectionRect:a});c?t&&h?this._hasCrossedThreshold(c,f)&&this._queuedEntries.push(f):c&&c.isIntersecting&&this._queuedEntries.push(f):this._queuedEntries.push(f)}),this),this._queuedEntries.length&&this._callback(this.takeRecords(),this)}},s.prototype._computeTargetAndRootIntersection=function(e,i,r){if("none"!=window.getComputedStyle(e).display){for(var s,h,c,a,f,d,g,m,v=i,_=p(e),b=!1;!b&&_;){var w=null,y=1==_.nodeType?window.getComputedStyle(_):{};if("none"==y.display)return null;if(_==this.root||9==_.nodeType)if(b=!0,_==this.root||_==t)o&&!this.root?!n||0==n.width&&0==n.height?(_=null,w=null,v=null):w=n:w=r;else{var I=p(_),E=I&&u(I),T=I&&this._computeTargetAndRootIntersection(I,E,r);E&&T?(_=I,w=l(E,T)):(_=null,v=null)}else{var R=_.ownerDocument;_!=R.body&&_!=R.documentElement&&"visible"!=y.overflow&&(w=u(_))}if(w&&(s=w,h=v,c=void 0,a=void 0,f=void 0,d=void 0,g=void 0,m=void 0,c=Math.max(s.top,h.top),a=Math.min(s.bottom,h.bottom),f=Math.max(s.left,h.left),d=Math.min(s.right,h.right),m=a-c,v=(g=d-f)>=0&&m>=0&&{top:c,bottom:a,left:f,right:d,width:g,height:m}||null),!v)break;_=_&&p(_)}return v}},s.prototype._getRootRect=function(){var e;if(this.root&&!d(this.root))e=u(this.root);else{var o=d(this.root)?this.root:t,n=o.documentElement,i=o.body;e={top:0,left:0,right:n.clientWidth||i.clientWidth,width:n.clientWidth||i.clientWidth,bottom:n.clientHeight||i.clientHeight,height:n.clientHeight||i.clientHeight}}return this._expandRectByRootMargin(e)},s.prototype._expandRectByRootMargin=function(t){var e=this._rootMarginValues.map((function(e,o){return"px"==e.unit?e.value:e.value*(o%2?t.width:t.height)/100})),o={top:t.top-e[0],right:t.right+e[1],bottom:t.bottom+e[2],left:t.left-e[3]};return o.width=o.right-o.left,o.height=o.bottom-o.top,o},s.prototype._hasCrossedThreshold=function(t,e){var o=t&&t.isIntersecting?t.intersectionRatio||0:-1,n=e.isIntersecting?e.intersectionRatio||0:-1;if(o!==n)for(var i=0;i<this.thresholds.length;i++){var r=this.thresholds[i];if(r==o||r==n||r<o!=r<n)return!0}},s.prototype._rootIsInDom=function(){return!this.root||f(t,this.root)},s.prototype._rootContainsTarget=function(e){var o=this.root&&(this.root.ownerDocument||this.root)||t;return f(o,e)&&(!this.root||o==e.ownerDocument)},s.prototype._registerInstance=function(){e.indexOf(this)<0&&e.push(this)},s.prototype._unregisterInstance=function(){var t=e.indexOf(this);-1!=t&&e.splice(t,1)},window.IntersectionObserver=s,window.IntersectionObserverEntry=r}function i(t){try{return t.defaultView&&t.defaultView.frameElement||null}catch(t){return null}}function r(t){this.time=t.time,this.target=t.target,this.rootBounds=a(t.rootBounds),this.boundingClientRect=a(t.boundingClientRect),this.intersectionRect=a(t.intersectionRect||{top:0,bottom:0,left:0,right:0,width:0,height:0}),this.isIntersecting=!!t.intersectionRect;var e=this.boundingClientRect,o=e.width*e.height,n=this.intersectionRect,i=n.width*n.height;this.intersectionRatio=o?Number((i/o).toFixed(4)):this.isIntersecting?1:0}function s(t,e){var o,n,i,r=e||{};if("function"!=typeof t)throw new Error("callback must be a function");if(r.root&&1!=r.root.nodeType&&9!=r.root.nodeType)throw new Error("root must be a Document or Element");this._checkForIntersections=(o=this._checkForIntersections.bind(this),n=this.THROTTLE_TIMEOUT,i=null,function(){i||(i=setTimeout((function(){o(),i=null}),n))}),this._callback=t,this._observationTargets=[],this._queuedEntries=[],this._rootMarginValues=this._parseRootMargin(r.rootMargin),this.thresholds=this._initThresholds(r.threshold),this.root=r.root||null,this.rootMargin=this._rootMarginValues.map((function(t){return t.value+t.unit})).join(" "),this._monitoringDocuments=[],this._monitoringUnsubscribes=[]}function h(t,e,o,n){"function"==typeof t.addEventListener?t.addEventListener(e,o,n||!1):"function"==typeof t.attachEvent&&t.attachEvent("on"+e,o)}function c(t,e,o,n){"function"==typeof t.removeEventListener?t.removeEventListener(e,o,n||!1):"function"==typeof t.detatchEvent&&t.detatchEvent("on"+e,o)}function u(t){var e;try{e=t.getBoundingClientRect()}catch(t){}return e?(e.width&&e.height||(e={top:e.top,right:e.right,bottom:e.bottom,left:e.left,width:e.right-e.left,height:e.bottom-e.top}),e):{top:0,bottom:0,left:0,right:0,width:0,height:0}}function a(t){return!t||"x"in t?t:{top:t.top,y:t.top,bottom:t.bottom,left:t.left,x:t.left,right:t.right,width:t.width,height:t.height}}function l(t,e){var o=e.top-t.top,n=e.left-t.left;return{top:o,left:n,height:e.height,width:e.width,bottom:o+e.height,right:n+e.width}}function f(t,e){for(var o=e;o;){if(o==t)return!0;o=p(o)}return!1}function p(e){var o=e.parentNode;return 9==e.nodeType&&e!=t?i(e):(o&&o.assignedSlot&&(o=o.assignedSlot.parentNode),o&&11==o.nodeType&&o.host?o.host:o)}function d(t){return t&&9===t.nodeType}}();
\ No newline at end of file diff --git a/plugins/jetpack/jetpack_vendor/automattic/jetpack-lazy-images/dist/intersection-observer.src.js b/plugins/jetpack/jetpack_vendor/automattic/jetpack-lazy-images/dist/intersection-observer.src.js new file mode 100644 index 00000000..5fa4e6e7 --- /dev/null +++ b/plugins/jetpack/jetpack_vendor/automattic/jetpack-lazy-images/dist/intersection-observer.src.js @@ -0,0 +1 @@ +!function(){"use strict";if("object"==typeof window)if("IntersectionObserver"in window&&"IntersectionObserverEntry"in window&&"intersectionRatio"in window.IntersectionObserverEntry.prototype)"isIntersecting"in window.IntersectionObserverEntry.prototype||Object.defineProperty(window.IntersectionObserverEntry.prototype,"isIntersecting",{get:function(){return this.intersectionRatio>0}});else{var t=function(t){for(var e=window.document,o=i(e);o;)o=i(e=o.ownerDocument);return e}(),e=[],o=null,n=null;s.prototype.THROTTLE_TIMEOUT=100,s.prototype.POLL_INTERVAL=null,s.prototype.USE_MUTATION_OBSERVER=!0,s._setupCrossOriginUpdater=function(){return o||(o=function(t,o){n=t&&o?l(t,o):{top:0,bottom:0,left:0,right:0,width:0,height:0},e.forEach((function(t){t._checkForIntersections()}))}),o},s._resetCrossOriginUpdater=function(){o=null,n=null},s.prototype.observe=function(t){if(!this._observationTargets.some((function(e){return e.element==t}))){if(!t||1!=t.nodeType)throw new Error("target must be an Element");this._registerInstance(),this._observationTargets.push({element:t,entry:null}),this._monitorIntersections(t.ownerDocument),this._checkForIntersections()}},s.prototype.unobserve=function(t){this._observationTargets=this._observationTargets.filter((function(e){return e.element!=t})),this._unmonitorIntersections(t.ownerDocument),0==this._observationTargets.length&&this._unregisterInstance()},s.prototype.disconnect=function(){this._observationTargets=[],this._unmonitorAllIntersections(),this._unregisterInstance()},s.prototype.takeRecords=function(){var t=this._queuedEntries.slice();return this._queuedEntries=[],t},s.prototype._initThresholds=function(t){var e=t||[0];return Array.isArray(e)||(e=[e]),e.sort().filter((function(t,e,o){if("number"!=typeof t||isNaN(t)||t<0||t>1)throw new Error("threshold must be a number between 0 and 1 inclusively");return t!==o[e-1]}))},s.prototype._parseRootMargin=function(t){var e=(t||"0px").split(/\s+/).map((function(t){var e=/^(-?\d*\.?\d+)(px|%)$/.exec(t);if(!e)throw new Error("rootMargin must be specified in pixels or percent");return{value:parseFloat(e[1]),unit:e[2]}}));return e[1]=e[1]||e[0],e[2]=e[2]||e[0],e[3]=e[3]||e[1],e},s.prototype._monitorIntersections=function(e){var o=e.defaultView;if(o&&-1==this._monitoringDocuments.indexOf(e)){var n=this._checkForIntersections,r=null,s=null;this.POLL_INTERVAL?r=o.setInterval(n,this.POLL_INTERVAL):(h(o,"resize",n,!0),h(e,"scroll",n,!0),this.USE_MUTATION_OBSERVER&&"MutationObserver"in o&&(s=new o.MutationObserver(n)).observe(e,{attributes:!0,childList:!0,characterData:!0,subtree:!0})),this._monitoringDocuments.push(e),this._monitoringUnsubscribes.push((function(){var t=e.defaultView;t&&(r&&t.clearInterval(r),c(t,"resize",n,!0)),c(e,"scroll",n,!0),s&&s.disconnect()}));var u=this.root&&(this.root.ownerDocument||this.root)||t;if(e!=u){var a=i(e);a&&this._monitorIntersections(a.ownerDocument)}}},s.prototype._unmonitorIntersections=function(e){var o=this._monitoringDocuments.indexOf(e);if(-1!=o){var n=this.root&&(this.root.ownerDocument||this.root)||t,r=this._observationTargets.some((function(t){var o=t.element.ownerDocument;if(o==e)return!0;for(;o&&o!=n;){var r=i(o);if((o=r&&r.ownerDocument)==e)return!0}return!1}));if(!r){var s=this._monitoringUnsubscribes[o];if(this._monitoringDocuments.splice(o,1),this._monitoringUnsubscribes.splice(o,1),s(),e!=n){var h=i(e);h&&this._unmonitorIntersections(h.ownerDocument)}}}},s.prototype._unmonitorAllIntersections=function(){var t=this._monitoringUnsubscribes.slice(0);this._monitoringDocuments.length=0,this._monitoringUnsubscribes.length=0;for(var e=0;e<t.length;e++)t[e]()},s.prototype._checkForIntersections=function(){if(this.root||!o||n){var t=this._rootIsInDom(),e=t?this._getRootRect():{top:0,bottom:0,left:0,right:0,width:0,height:0};this._observationTargets.forEach((function(n){var i=n.element,s=u(i),h=this._rootContainsTarget(i),c=n.entry,a=t&&h&&this._computeTargetAndRootIntersection(i,s,e),l=null;this._rootContainsTarget(i)?o&&!this.root||(l=e):l={top:0,bottom:0,left:0,right:0,width:0,height:0};var f=n.entry=new r({time:window.performance&&performance.now&&performance.now(),target:i,boundingClientRect:s,rootBounds:l,intersectionRect:a});c?t&&h?this._hasCrossedThreshold(c,f)&&this._queuedEntries.push(f):c&&c.isIntersecting&&this._queuedEntries.push(f):this._queuedEntries.push(f)}),this),this._queuedEntries.length&&this._callback(this.takeRecords(),this)}},s.prototype._computeTargetAndRootIntersection=function(e,i,r){if("none"!=window.getComputedStyle(e).display){for(var s,h,c,a,f,d,g,m,v=i,_=p(e),b=!1;!b&&_;){var w=null,y=1==_.nodeType?window.getComputedStyle(_):{};if("none"==y.display)return null;if(_==this.root||9==_.nodeType)if(b=!0,_==this.root||_==t)o&&!this.root?!n||0==n.width&&0==n.height?(_=null,w=null,v=null):w=n:w=r;else{var I=p(_),E=I&&u(I),T=I&&this._computeTargetAndRootIntersection(I,E,r);E&&T?(_=I,w=l(E,T)):(_=null,v=null)}else{var R=_.ownerDocument;_!=R.body&&_!=R.documentElement&&"visible"!=y.overflow&&(w=u(_))}if(w&&(s=w,h=v,c=void 0,a=void 0,f=void 0,d=void 0,g=void 0,m=void 0,c=Math.max(s.top,h.top),a=Math.min(s.bottom,h.bottom),f=Math.max(s.left,h.left),d=Math.min(s.right,h.right),m=a-c,v=(g=d-f)>=0&&m>=0&&{top:c,bottom:a,left:f,right:d,width:g,height:m}||null),!v)break;_=_&&p(_)}return v}},s.prototype._getRootRect=function(){var e;if(this.root&&!d(this.root))e=u(this.root);else{var o=d(this.root)?this.root:t,n=o.documentElement,i=o.body;e={top:0,left:0,right:n.clientWidth||i.clientWidth,width:n.clientWidth||i.clientWidth,bottom:n.clientHeight||i.clientHeight,height:n.clientHeight||i.clientHeight}}return this._expandRectByRootMargin(e)},s.prototype._expandRectByRootMargin=function(t){var e=this._rootMarginValues.map((function(e,o){return"px"==e.unit?e.value:e.value*(o%2?t.width:t.height)/100})),o={top:t.top-e[0],right:t.right+e[1],bottom:t.bottom+e[2],left:t.left-e[3]};return o.width=o.right-o.left,o.height=o.bottom-o.top,o},s.prototype._hasCrossedThreshold=function(t,e){var o=t&&t.isIntersecting?t.intersectionRatio||0:-1,n=e.isIntersecting?e.intersectionRatio||0:-1;if(o!==n)for(var i=0;i<this.thresholds.length;i++){var r=this.thresholds[i];if(r==o||r==n||r<o!=r<n)return!0}},s.prototype._rootIsInDom=function(){return!this.root||f(t,this.root)},s.prototype._rootContainsTarget=function(e){var o=this.root&&(this.root.ownerDocument||this.root)||t;return f(o,e)&&(!this.root||o==e.ownerDocument)},s.prototype._registerInstance=function(){e.indexOf(this)<0&&e.push(this)},s.prototype._unregisterInstance=function(){var t=e.indexOf(this);-1!=t&&e.splice(t,1)},window.IntersectionObserver=s,window.IntersectionObserverEntry=r}function i(t){try{return t.defaultView&&t.defaultView.frameElement||null}catch(t){return null}}function r(t){this.time=t.time,this.target=t.target,this.rootBounds=a(t.rootBounds),this.boundingClientRect=a(t.boundingClientRect),this.intersectionRect=a(t.intersectionRect||{top:0,bottom:0,left:0,right:0,width:0,height:0}),this.isIntersecting=!!t.intersectionRect;var e=this.boundingClientRect,o=e.width*e.height,n=this.intersectionRect,i=n.width*n.height;this.intersectionRatio=o?Number((i/o).toFixed(4)):this.isIntersecting?1:0}function s(t,e){var o,n,i,r=e||{};if("function"!=typeof t)throw new Error("callback must be a function");if(r.root&&1!=r.root.nodeType&&9!=r.root.nodeType)throw new Error("root must be a Document or Element");this._checkForIntersections=(o=this._checkForIntersections.bind(this),n=this.THROTTLE_TIMEOUT,i=null,function(){i||(i=setTimeout((function(){o(),i=null}),n))}),this._callback=t,this._observationTargets=[],this._queuedEntries=[],this._rootMarginValues=this._parseRootMargin(r.rootMargin),this.thresholds=this._initThresholds(r.threshold),this.root=r.root||null,this.rootMargin=this._rootMarginValues.map((function(t){return t.value+t.unit})).join(" "),this._monitoringDocuments=[],this._monitoringUnsubscribes=[]}function h(t,e,o,n){"function"==typeof t.addEventListener?t.addEventListener(e,o,n||!1):"function"==typeof t.attachEvent&&t.attachEvent("on"+e,o)}function c(t,e,o,n){"function"==typeof t.removeEventListener?t.removeEventListener(e,o,n||!1):"function"==typeof t.detatchEvent&&t.detatchEvent("on"+e,o)}function u(t){var e;try{e=t.getBoundingClientRect()}catch(t){}return e?(e.width&&e.height||(e={top:e.top,right:e.right,bottom:e.bottom,left:e.left,width:e.right-e.left,height:e.bottom-e.top}),e):{top:0,bottom:0,left:0,right:0,width:0,height:0}}function a(t){return!t||"x"in t?t:{top:t.top,y:t.top,bottom:t.bottom,left:t.left,x:t.left,right:t.right,width:t.width,height:t.height}}function l(t,e){var o=e.top-t.top,n=e.left-t.left;return{top:o,left:n,height:e.height,width:e.width,bottom:o+e.height,right:n+e.width}}function f(t,e){for(var o=e;o;){if(o==t)return!0;o=p(o)}return!1}function p(e){var o=e.parentNode;return 9==e.nodeType&&e!=t?i(e):(o&&o.assignedSlot&&(o=o.assignedSlot.parentNode),o&&11==o.nodeType&&o.host?o.host:o)}function d(t){return t&&9===t.nodeType}}();
\ No newline at end of file diff --git a/plugins/jetpack/jetpack_vendor/automattic/jetpack-lazy-images/dist/lazy-images.asset.php b/plugins/jetpack/jetpack_vendor/automattic/jetpack-lazy-images/dist/lazy-images.asset.php new file mode 100644 index 00000000..13eb125f --- /dev/null +++ b/plugins/jetpack/jetpack_vendor/automattic/jetpack-lazy-images/dist/lazy-images.asset.php @@ -0,0 +1 @@ +<?php return array('dependencies' => array(), 'version' => '22d8bb42bcd6edc9c8ef53eb9b087d17');
\ No newline at end of file diff --git a/plugins/jetpack/jetpack_vendor/automattic/jetpack-lazy-images/dist/lazy-images.js b/plugins/jetpack/jetpack_vendor/automattic/jetpack-lazy-images/dist/lazy-images.js new file mode 100644 index 00000000..d606a494 --- /dev/null +++ b/plugins/jetpack/jetpack_vendor/automattic/jetpack-lazy-images/dist/lazy-images.js @@ -0,0 +1 @@ +!function(){var e=function(){var e,t,n,a={rootMargin:"200px 0px",threshold:.01},i=[];d();var r=document.querySelector("body");function d(){e=[].slice.call(document.querySelectorAll("img.jetpack-lazy-image:not(.jetpack-lazy-image--handled)")),n&&n.disconnect(),"IntersectionObserver"in window?(n=new IntersectionObserver(l,a),e.forEach((function(e){e.getAttribute("data-lazy-loaded")||n.observe(e)})),window.addEventListener("beforeprint",c),window.matchMedia&&window.matchMedia("print").addListener((function(e){e.matches&&c()}))):o()}function o(){for(n&&n.disconnect();e.length>0;)s(e[0])}function l(t){for(var a=0;a<t.length;a++){var i=t[a];i.intersectionRatio>0&&(n.unobserve(i.target),s(i.target))}0===e.length&&n.disconnect()}function c(){if(!t&&(e.length>0||i.length>0)){(t=document.createElement("div")).id="loadingWarning",t.style.fontWeight="bold",t.innerText=jetpackLazyImagesL10n.loading_warning;var n=document.createElement("style");n.innerHTML="#loadingWarning { display: none; }\n@media print {\n#loadingWarning { display: block; }\nbody > #loadingWarning ~ * { display: none !important; }\n}",t.appendChild(n),r.insertBefore(t,r.firstChild)}e.length>0&&o(),t&&alert(jetpackLazyImagesL10n.loading_warning)}function s(t){var n;if(t instanceof HTMLImageElement){var a=t.getAttribute("data-lazy-srcset"),r=t.getAttribute("data-lazy-sizes");t.removeAttribute("data-lazy-srcset"),t.removeAttribute("data-lazy-sizes"),t.removeAttribute("data-lazy-src"),t.classList.add("jetpack-lazy-image--handled"),t.setAttribute("data-lazy-loaded",1),r&&t.setAttribute("sizes",r),a?t.setAttribute("srcset",a):t.removeAttribute("srcset"),t.setAttribute("loading","eager"),i.push(t);var d=e.indexOf(t);d>=0&&e.splice(d,1),t.complete?g.call(t,null):(t.addEventListener("load",g,{once:!0}),t.addEventListener("error",g,{once:!0}));try{n=new Event("jetpack-lazy-loaded-image",{bubbles:!0,cancelable:!0})}catch(e){(n=document.createEvent("Event")).initEvent("jetpack-lazy-loaded-image",!0,!0)}t.dispatchEvent(n)}}function g(){var n=i.indexOf(this);n>=0&&i.splice(n,1),t&&0===e.length&&0===i.length&&(t.parentNode.removeChild(t),t=null)}r&&(r.addEventListener("is.post-load",d),r.addEventListener("jetpack-lazy-images-load",d))};"interactive"===document.readyState||"complete"===document.readyState?e():document.addEventListener("DOMContentLoaded",e)}();
\ No newline at end of file diff --git a/plugins/jetpack/jetpack_vendor/automattic/jetpack-lazy-images/src/images/1x1.trans.gif b/plugins/jetpack/jetpack_vendor/automattic/jetpack-lazy-images/src/images/1x1.trans.gif Binary files differnew file mode 100644 index 00000000..f191b280 --- /dev/null +++ b/plugins/jetpack/jetpack_vendor/automattic/jetpack-lazy-images/src/images/1x1.trans.gif diff --git a/plugins/jetpack/jetpack_vendor/automattic/jetpack-lazy-images/src/js/lazy-images.js b/plugins/jetpack/jetpack_vendor/automattic/jetpack-lazy-images/src/js/lazy-images.js new file mode 100644 index 00000000..92b4f217 --- /dev/null +++ b/plugins/jetpack/jetpack_vendor/automattic/jetpack-lazy-images/src/js/lazy-images.js @@ -0,0 +1,219 @@ +/* global jetpackLazyImagesL10n */ + +var jetpackLazyImagesModule = function () { + var config = { + // If the image gets within 200px in the Y axis, start the download. + rootMargin: '200px 0px', + threshold: 0.01, + }; + var loadingImages = []; + var lazyImages, loadingWarning, observer; + + lazy_load_init(); + + var bodyEl = document.querySelector( 'body' ); + if ( bodyEl ) { + // Lazy load images that are brought in from Infinite Scroll + bodyEl.addEventListener( 'is.post-load', lazy_load_init ); + + // Add event to provide optional compatibility for other code. + bodyEl.addEventListener( 'jetpack-lazy-images-load', lazy_load_init ); + } + + /** + * Initialize the module. + */ + function lazy_load_init() { + // @todo: Use Array.from once es6 is allowed. + lazyImages = [].slice.call( + document.querySelectorAll( 'img.jetpack-lazy-image:not(.jetpack-lazy-image--handled)' ) + ); + + // If initialized, then disconnect the observer + if ( observer ) { + observer.disconnect(); + } + + // If we don't have support for intersection observer, loads the images immediately + if ( ! ( 'IntersectionObserver' in window ) ) { + loadAllImages(); + } else { + // It is supported, load the images + observer = new IntersectionObserver( onIntersection, config ); + + lazyImages.forEach( function ( image ) { + if ( ! image.getAttribute( 'data-lazy-loaded' ) ) { + observer.observe( image ); + } + } ); + + // Watch for attempts to print, and load all images. Most browsers + // support beforeprint, Safari needs a media listener. Doesn't hurt + // to double-fire if a browser supports both. + window.addEventListener( 'beforeprint', onPrint ); + if ( window.matchMedia ) { + window.matchMedia( 'print' ).addListener( function ( mql ) { + if ( mql.matches ) { + onPrint(); + } + } ); + } + } + } + + /** + * Load all of the images immediately + */ + function loadAllImages() { + if ( observer ) { + observer.disconnect(); + } + + while ( lazyImages.length > 0 ) { + applyImage( lazyImages[ 0 ] ); + } + } + + /** + * On intersection + * + * @param {Array} entries - List of elements being observed. + */ + function onIntersection( entries ) { + // Loop through the entries + for ( var i = 0; i < entries.length; i++ ) { + var entry = entries[ i ]; + + // Are we in viewport? + if ( entry.intersectionRatio > 0 ) { + // Stop watching and load the image + observer.unobserve( entry.target ); + applyImage( entry.target ); + } + } + + // Disconnect if we've already loaded all of the images + if ( lazyImages.length === 0 ) { + observer.disconnect(); + } + } + + /** + * On print + */ + function onPrint() { + if ( ! loadingWarning && ( lazyImages.length > 0 || loadingImages.length > 0 ) ) { + // Replace the printed page with a notice that images are still loading. + // Hopefully the user won't actually print this, but if they do at least it'll not + // waste too much ink. + loadingWarning = document.createElement( 'div' ); + loadingWarning.id = 'loadingWarning'; + loadingWarning.style.fontWeight = 'bold'; + loadingWarning.innerText = jetpackLazyImagesL10n.loading_warning; + + var s = document.createElement( 'style' ); + s.innerHTML = + '#loadingWarning { display: none; }\n@media print {\n#loadingWarning { display: block; }\nbody > #loadingWarning ~ * { display: none !important; }\n}'; + loadingWarning.appendChild( s ); + + bodyEl.insertBefore( loadingWarning, bodyEl.firstChild ); + } + + if ( lazyImages.length > 0 ) { + loadAllImages(); + } + + // May as well try an alert() too. The browser may block it, but if not + // it could save them some trouble. + if ( loadingWarning ) { + alert( jetpackLazyImagesL10n.loading_warning ); + } + } + + /** + * Apply the image + * + * @param {Element} image - The image object. + */ + function applyImage( image ) { + var lazyLoadedImageEvent; + + if ( ! ( image instanceof HTMLImageElement ) ) { + return; + } + + var srcset = image.getAttribute( 'data-lazy-srcset' ); + var sizes = image.getAttribute( 'data-lazy-sizes' ); + + // Remove lazy attributes. + image.removeAttribute( 'data-lazy-srcset' ); + image.removeAttribute( 'data-lazy-sizes' ); + image.removeAttribute( 'data-lazy-src' ); + + // Add the attributes we want. + image.classList.add( 'jetpack-lazy-image--handled' ); + image.setAttribute( 'data-lazy-loaded', 1 ); + + if ( sizes ) { + image.setAttribute( 'sizes', sizes ); + } + + if ( ! srcset ) { + image.removeAttribute( 'srcset' ); + } else { + image.setAttribute( 'srcset', srcset ); + } + + // Force eager loading, otherwise the browser-native loading=lazy support will still + // prevent the loading. + image.setAttribute( 'loading', 'eager' ); + + loadingImages.push( image ); + var idx = lazyImages.indexOf( image ); + if ( idx >= 0 ) { + lazyImages.splice( idx, 1 ); + } + + if ( image.complete ) { + loadedImage.call( image, null ); + } else { + image.addEventListener( 'load', loadedImage, { once: true } ); + image.addEventListener( 'error', loadedImage, { once: true } ); + } + + // Fire an event so that third-party code can perform actions after an image is loaded. + try { + lazyLoadedImageEvent = new Event( 'jetpack-lazy-loaded-image', { + bubbles: true, + cancelable: true, + } ); + } catch ( e ) { + lazyLoadedImageEvent = document.createEvent( 'Event' ); + lazyLoadedImageEvent.initEvent( 'jetpack-lazy-loaded-image', true, true ); + } + + image.dispatchEvent( lazyLoadedImageEvent ); + } + + /** + * An image from applyImage() finished loading. + */ + function loadedImage() { + var idx = loadingImages.indexOf( this ); + if ( idx >= 0 ) { + loadingImages.splice( idx, 1 ); + } + + if ( loadingWarning && lazyImages.length === 0 && loadingImages.length === 0 ) { + loadingWarning.parentNode.removeChild( loadingWarning ); + loadingWarning = null; + } + } +}; + +// Let's kick things off now +if ( document.readyState === 'interactive' || document.readyState === 'complete' ) { + jetpackLazyImagesModule(); +} else { + document.addEventListener( 'DOMContentLoaded', jetpackLazyImagesModule ); +} diff --git a/plugins/jetpack/jetpack_vendor/automattic/jetpack-lazy-images/src/lazy-images.php b/plugins/jetpack/jetpack_vendor/automattic/jetpack-lazy-images/src/lazy-images.php new file mode 100644 index 00000000..8be08ed5 --- /dev/null +++ b/plugins/jetpack/jetpack_vendor/automattic/jetpack-lazy-images/src/lazy-images.php @@ -0,0 +1,516 @@ +<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName + +/** + * The Lazy Images package. + * + * @since 1.0.0 + * @since-jetpack 8.8.0 + * + * This package has been lifted from the Jetpack modules folder and adapted to be + * an standalone package reusable outside Jetpack. + * + * @package automattic/jetpack-lazy-images + */ + +/** + * This package relies heavily upon the Lazy Load plugin which was worked on by + * Mohammad Jangda (batmoo), the WordPress.com VIP team, the TechCrunch 2011 + * redesign team, and Jake Goldman of 10up LLC. + * + * The JavaScript has been updated to rely on InterSection observer instead of + * jQuery Sonar. Many thanks to Dean Hume (deanhume) and his example: + * https://github.com/deanhume/lazy-observer-load + */ + +namespace Automattic\Jetpack; + +/** + * Class Automattic\Jetpack\Jetpack_Lazy_Images + * + * @since 1.0.0 + * @since-jetpack 8.8.0 + */ +class Jetpack_Lazy_Images { + + /** + * Class instance. + * + * @since 1.0.0 + * @since-jetpack 5.6.0 + * + * @var null + */ + private static $instance = null; + + /** + * Singleton implementation. + * + * @since 1.0.0 + * @since-jetpack 5.6.0 + * + * @return object The class instance. + */ + public static function instance() { + if ( is_null( self::$instance ) ) { + self::$instance = new Jetpack_Lazy_Images(); + } + + return self::$instance; + } + + /** + * Check if the request is a AMP request. + * + * @since 1.0.0 + * @since-jetpack 8.8.0 + * + * @return bool + */ + public static function is_amp_request() { + $is_amp_request = ( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ); + + /** + * Returns true if the current request should return valid AMP content. + * + * @since 1.0.0 + * @since-jetpack 8.8.0 + * + * @param boolean $is_amp_request Is this request supposed to return valid AMP content? + */ + return apply_filters( 'jetpack_lazy_images_is_amp_request', $is_amp_request ); + } + + /** + * Registers actions. + * + * @since 1.0.0 + * @since-jetpack 8.8.0 + * + * @return void + */ + private function __construct() { + if ( is_admin() ) { + return; + } + + /** + * Whether the lazy-images module should load. + * + * This filter is not prefixed with jetpack_ to provide a smoother migration + * process from the WordPress Lazy Load plugin. + * + * @package automattic/jetpack-lazy-images + * + * @since 1.0.0 + * @since-jetpack 5.6.0 + * + * @param bool true Whether lazy image loading should occur. + */ + if ( ! apply_filters( 'lazyload_is_enabled', true ) ) { + return; + } + + if ( self::is_amp_request() ) { + return; + } + + add_action( 'wp_head', array( $this, 'setup_filters' ), 9999 ); // We don't really want to modify anything in <head> since it's mostly all metadata. + add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_assets' ) ); + + // Do not lazy load avatar in admin bar. + add_action( 'admin_bar_menu', array( $this, 'remove_filters' ), 0 ); + + add_filter( 'wp_kses_allowed_html', array( $this, 'allow_lazy_attributes' ) ); + add_action( 'wp_head', array( $this, 'add_nojs_fallback' ) ); + } + + /** + * Setup filters. + * + * @since 1.0.0 + * @since-jetpack 5.6.0 + * + * @return void + */ + public function setup_filters() { + add_filter( 'the_content', array( $this, 'add_image_placeholders' ), PHP_INT_MAX ); // Run this later, so other content filters have run, including image_add_wh on WP.com. + add_filter( 'post_thumbnail_html', array( $this, 'add_image_placeholders' ), PHP_INT_MAX ); + add_filter( 'get_avatar', array( $this, 'add_image_placeholders' ), PHP_INT_MAX ); + add_filter( 'widget_text', array( $this, 'add_image_placeholders' ), PHP_INT_MAX ); + add_filter( 'get_image_tag', array( $this, 'add_image_placeholders' ), PHP_INT_MAX ); + add_filter( 'wp_get_attachment_image_attributes', array( __CLASS__, 'process_image_attributes' ), PHP_INT_MAX ); + } + + /** + * Remove filters. + * + * @since 1.0.0 + * @since-jetpack 5.6.0 + * + * @return void + */ + public function remove_filters() { + remove_filter( 'the_content', array( $this, 'add_image_placeholders' ), PHP_INT_MAX ); + remove_filter( 'post_thumbnail_html', array( $this, 'add_image_placeholders' ), PHP_INT_MAX ); + remove_filter( 'get_avatar', array( $this, 'add_image_placeholders' ), PHP_INT_MAX ); + remove_filter( 'widget_text', array( $this, 'add_image_placeholders' ), PHP_INT_MAX ); + remove_filter( 'get_image_tag', array( $this, 'add_image_placeholders' ), PHP_INT_MAX ); + remove_filter( 'wp_get_attachment_image_attributes', array( __CLASS__, 'process_image_attributes' ), PHP_INT_MAX ); + } + + /** + * Ensure that our lazy image attributes are not filtered out of image tags. + * + * @since 1.0.0 + * @since-jetpack 5.6.0 + * + * @param array $allowed_tags The allowed tags and their attributes. + * @return array + */ + public function allow_lazy_attributes( $allowed_tags ) { + if ( ! isset( $allowed_tags['img'] ) ) { + return $allowed_tags; + } + + // But, if images are allowed, ensure that our attributes are allowed! + $img_attributes = array_merge( + $allowed_tags['img'], + array( + 'data-lazy-src' => 1, + 'data-lazy-srcset' => 1, + 'data-lazy-sizes' => 1, + ) + ); + + $allowed_tags['img'] = $img_attributes; + + return $allowed_tags; + } + + /** + * Add image placeholders. + * + * @since 1.0.0 + * @since-jetpack 5.6.0 + * + * @param string $content Content. + * @return string + */ + public function add_image_placeholders( $content ) { + // Don't lazy load for feeds, previews. + if ( is_feed() || is_preview() ) { + return $content; + } + + // Don't lazy-load if the content has already been run through previously. + if ( false !== strpos( $content, 'data-lazy-src' ) ) { + return $content; + } + + // This is a pretty simple regex, but it works. + $content = preg_replace_callback( '#<(img)([^>]+?)(>(.*?)</\\1>|[\/]?>)#si', array( __CLASS__, 'process_image' ), $content ); + + return $content; + } + + /** + * Returns true when a given string of classes contains a class signifying lazy images. + * should not process the image. + * + * @since 1.0.0 + * @since-jetpack 5.9.0 + * + * @param string $classes A string of space-separated classes. + * @return bool + */ + public static function should_skip_image_with_blocked_class( $classes ) { + $blocked_classes = array( + 'skip-lazy', + 'gazette-featured-content-thumbnail', + ); + + /** + * Allow plugins and themes to tell lazy images to skip an image with a given class. + * + * @package automattic/jetpack-lazy-images + * + * @since 1.0.0 + * @since-jetpack 8.7.0 + * + * @param array An array of strings where each string is a class. + */ + $blocked_classes = apply_filters( 'jetpack_lazy_images_blocked_classes', $blocked_classes ); + + if ( ! is_array( $blocked_classes ) || empty( $blocked_classes ) ) { + return false; + } + + foreach ( $blocked_classes as $class ) { + if ( false !== strpos( $classes, $class ) ) { + return true; + } + } + + return false; + } + + /** + * Processes images in content by acting as the preg_replace_callback. + * + * @since 1.0.0 + * @since-jetpack 5.6.0 + * + * @param array $matches Matches. + * + * @return string The image with updated lazy attributes. + */ + public static function process_image( $matches ) { + $old_attributes_str = $matches[2]; + $old_attributes_kses_hair = wp_kses_hair( $old_attributes_str, wp_allowed_protocols() ); + + if ( empty( $old_attributes_kses_hair['src'] ) ) { + return $matches[0]; + } + + $old_attributes = self::flatten_kses_hair_data( $old_attributes_kses_hair ); + + // If we didn't add lazy attributes, just return the original image source. + if ( ! empty( $old_attributes['class'] ) && false !== strpos( $old_attributes['class'], 'jetpack-lazy-image' ) ) { + return $matches[0]; + } + + $new_attributes = self::process_image_attributes( $old_attributes ); + $new_attributes_str = self::build_attributes_string( $new_attributes ); + + return sprintf( '<img %1$s><noscript>%2$s</noscript>', $new_attributes_str, $matches[0] ); + } + + /** + * Given an array of image attributes, updates the `src`, `srcset`, and `sizes` attributes so + * that they load lazily. + * + * @since 1.0.0 + * @since-jetpack 5.7.0 + * + * @param array $attributes Attributes. + * + * @return array The updated image attributes array with lazy load attributes. + */ + public static function process_image_attributes( $attributes ) { + if ( empty( $attributes['src'] ) ) { + return $attributes; + } + + if ( ! empty( $attributes['class'] ) && self::should_skip_image_with_blocked_class( $attributes['class'] ) ) { + return $attributes; + } + + if ( isset( $attributes['data-skip-lazy'] ) ) { + return $attributes; + } + + /** + * Allow plugins and themes to conditionally skip processing an image via its attributes. + * + * @package automattic/jetpack-lazy-images + * + * @since 1.0.0 + * @since-jetpack 5.9.0 + * @deprecated-jetpack 6.5.0 Use jetpack_lazy_images_skip_image_with_attributes instead. + * + * @param bool Default to not skip processing the current image. + * @param array An array of attributes via wp_kses_hair() for the current image. + */ + if ( apply_filters( 'jetpack_lazy_images_skip_image_with_atttributes', false, $attributes ) ) { + return $attributes; + } + + /** + * Allow plugins and themes to conditionally skip processing an image via its attributes. + * + * @package automattic/jetpack-lazy-images + * + * @since 1.0.0 + * @since-jetpack 5.9.0 + * @since-jetpack 6.5.0 Filter name was updated from jetpack_lazy_images_skip_image_with_atttributes to correct typo. + * + * @param bool Default to not skip processing the current image. + * @param array An array of attributes via wp_kses_hair() for the current image. + */ + if ( apply_filters( 'jetpack_lazy_images_skip_image_with_attributes', false, $attributes ) ) { + return $attributes; + } + + $old_attributes = $attributes; + + // Stash srcset and sizes in data attributes. + foreach ( array( 'srcset', 'sizes' ) as $attribute ) { + if ( isset( $old_attributes[ $attribute ] ) ) { + $attributes[ "data-lazy-$attribute" ] = $old_attributes[ $attribute ]; + unset( $attributes[ $attribute ] ); + } + } + + // We set this, adding the query arg so that it doesn't exactly equal the src attribute, so that photon JavaScript + // will hold off on processing this image. + $attributes['data-lazy-src'] = esc_url_raw( add_query_arg( 'is-pending-load', true, $attributes['src'] ) ); + + $attributes['srcset'] = self::get_placeholder_image(); + $attributes['class'] = sprintf( + '%s jetpack-lazy-image', + empty( $old_attributes['class'] ) + ? '' + : $old_attributes['class'] + ); + + /** + * Allow plugins and themes to override the attributes on the image before the content is updated. + * + * One potential use of this filter is for themes that set `height:auto` on the `img` tag. + * With this filter, the theme could get the width and height attributes from the + * $attributes array and then add a style tag that sets those values as well, which could + * minimize reflow as images load. + * + * @package automattic/jetpack-lazy-images + * + * @since 1.0.0 + * @since-jetpack 5.6.0 + * + * @param array An array containing the attributes for the image, where the key is the attribute name + * and the value is the attribute value. + */ + return apply_filters( 'jetpack_lazy_images_new_attributes', $attributes ); + } + + /** + * Adds JavaScript to check if the current browser supports JavaScript as well as some styles to hide lazy + * images when the browser does not support JavaScript. + * + * @since 1.0.0 + * @since-jetpack 5.6.0 + * + * @return void + */ + public function add_nojs_fallback() { + ?> + <style type="text/css"> + /* If html does not have either class, do not show lazy loaded images. */ + html:not( .jetpack-lazy-images-js-enabled ):not( .js ) .jetpack-lazy-image { + display: none; + } + </style> + <script> + document.documentElement.classList.add( + 'jetpack-lazy-images-js-enabled' + ); + </script> + <?php + } + + /** + * Retrieves the placeholder image after running it through the lazyload_images_placeholder_image filter. + * + * @since 1.0.0 + * @since-jetpack 5.6.0 + * + * @return string The placeholder image source. + */ + private static function get_placeholder_image() { + /** + * Allows plugins and themes to modify the placeholder image. + * + * This filter is not prefixed with jetpack_ to provide a smoother migration + * process from the WordPress Lazy Load plugin. + * + * @module lazy-images + * + * @since 1.0.0 + * @since-jetpack 5.6.0 + * @since-jetpack 6.5.0 Default image is now a base64 encoded transparent gif. + * + * @param string The URL to the placeholder image. + */ + return apply_filters( + 'lazyload_images_placeholder_image', + 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7' + ); + } + + /** + * Flatter KSES hair data. + * + * @since 1.0.0 + * @since-jetpack 5.6.0 + * + * @param array $attributes Attributes. + * + * @return array + */ + private static function flatten_kses_hair_data( $attributes ) { + $flattened_attributes = array(); + foreach ( $attributes as $name => $attribute ) { + $flattened_attributes[ $name ] = $attribute['value']; + } + return $flattened_attributes; + } + + /** + * Build attributes string. + * + * @since 1.0.0 + * @since-jetpack 5.6.0 + * + * @param array $attributes Attributes. + * + * @return string + */ + private static function build_attributes_string( $attributes ) { + $string = array(); + foreach ( $attributes as $name => $value ) { + if ( '' === $value ) { + $string[] = sprintf( '%s', $name ); + } else { + $string[] = sprintf( '%s="%s"', $name, esc_attr( $value ) ); + } + } + return implode( ' ', $string ); + } + + /** + * Enqueue assets. + * + * @since 1.0.0 + * @since-jetpack 5.6.0 + * + * @return void + */ + public function enqueue_assets() { + Assets::register_script( + 'jetpack-lazy-images-polyfill-intersectionobserver', + '../dist/intersection-observer.js', + __FILE__, + array( + 'nonmin_path' => '../dist/intersection-observer.src.js', + 'in_footer' => true, + ) + ); + Assets::register_script( + 'jetpack-lazy-images', + '../dist/lazy-images.js', + __FILE__, + array( + 'nonmin_path' => 'js/lazy-images.js', + 'dependencies' => array( 'jetpack-lazy-images-polyfill-intersectionobserver' ), + 'in_footer' => true, + ) + ); + Assets::enqueue_script( 'jetpack-lazy-images' ); + wp_localize_script( + 'jetpack-lazy-images', + 'jetpackLazyImagesL10n', + array( + 'loading_warning' => __( 'Images are still loading. Please cancel your print and try again.', 'jetpack-lazy-images' ), + ) + ); + } +} diff --git a/plugins/jetpack/jetpack_vendor/automattic/jetpack-lazy-images/webpack.config.js b/plugins/jetpack/jetpack_vendor/automattic/jetpack-lazy-images/webpack.config.js new file mode 100644 index 00000000..4d5d2bdb --- /dev/null +++ b/plugins/jetpack/jetpack_vendor/automattic/jetpack-lazy-images/webpack.config.js @@ -0,0 +1,43 @@ +const jetpackWebpackConfig = require( '@automattic/jetpack-webpack-config/webpack' ); +const path = require( 'path' ); +const CopyWebpackPlugin = require( 'copy-webpack-plugin' ); + +module.exports = [ + { + entry: { + 'lazy-images': './src/js/lazy-images.js', + 'intersection-observer': require.resolve( 'intersection-observer/intersection-observer.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(), + new CopyWebpackPlugin( { + patterns: [ + { + from: require.resolve( 'intersection-observer/intersection-observer.js' ), + to: 'intersection-observer.src.js', + }, + ], + } ), + ], + module: { + strictExportPresence: true, + rules: [ + // Transpile JavaScript, including node_modules. + jetpackWebpackConfig.TranspileRule(), + ], + }, + }, +]; |