WordPress/wp-admin/js/updates.min.js
desrosj 968d57a6b3 Build/Test Tools: Support NodeJS 14.x in the 4.5 branch.
This updates the 4.5 branch to support the latest LTS version of NodeJS (currently 14.x), allowing the same version to be used across all WordPress branches that receive security updates as a courtesy.

Because older branches use (really) old versions of NodeJS, the local Docker environment cannot be backported since the needed dependencies will not run on these older versions (see #48301). This also blocks the ability to move automated testing over to GitHub Actions (see #50401).

This also replaces the `npm-shrinkwrap.json` with a `package-lock.json` file. Lock files were not supported in earlier versions of NPM, but can now be used.

In addition to backporting the package updates that happened after branching 4.5, dependencies that were removed in future releases have also been updated to their latest versions.

Props desrosj, dd32, netweb, jorbin.
Merges [37185,37212,37612,38111,38688,39110,39113-39119,39478,42460-42461,42463,42887,43320,43323,43977,44219,44233,44728,45321,45765,46404,46408-46409,47404,47867-47869,47872-47873,48705,49636,49933,49937,49939,50017,50126,50176,50185,50192] to the 4.5 branch.
See #52341.
Built from https://develop.svn.wordpress.org/branches/4.5@50208


git-svn-id: http://core.svn.wordpress.org/branches/4.5@49880 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-02-05 04:20:44 +00:00

1 line
9.0 KiB
JavaScript

window.wp=window.wp||{},function(d,n,p){n.updates={},n.updates.ajaxNonce=window._wpUpdatesSettings.ajax_nonce,n.updates.l10n=window._wpUpdatesSettings.l10n,n.updates.shouldRequestFilesystemCredentials=null,n.updates.filesystemCredentials={ftp:{host:null,username:null,password:null,connectionType:null},ssh:{publicKey:"",privateKey:""},fsNonce:""},n.updates.updateLock=!1,n.updates.updateDoneSuccessfully=!1,n.updates.updateQueue=[],n.updates.$elToReturnFocusToFromCredentialsModal=null,n.updates.decrementCount=function(e){var a,t=d("#wp-admin-bar-updates .ab-label"),s=d('a[href="update-core.php"] .update-plugins'),u=d("#menu-plugins"),n=t.text();(n=parseInt(n,10)-1)<0||isNaN(n)||(d("#wp-admin-bar-updates .ab-item").removeAttr("title"),t.text(n),s.each(function(e,t){t.className=t.className.replace(/count-\d+/,"count-"+n)}),s.removeAttr("title"),s.find(".update-count").text(n),"plugin"===e&&(a=u.find(".plugin-count").eq(0).text(),(a=parseInt(a,10)-1)<0||isNaN(a)||(u.find(".plugin-count").text(a),u.find(".update-plugins").each(function(e,t){t.className=t.className.replace(/count-\d+/,"count-"+a)}),0<a?d(".subsubsub .upgrade .count").text("("+a+")"):d(".subsubsub .upgrade").remove())))},n.updates.updatePlugin=function(e,t){var a,s,u=d(".plugin-card-"+t);"plugins"===p||"plugins-network"===p?a=d('[data-plugin="'+e+'"]').next().find(".update-message"):"plugin-install"===p&&(s=(a=u.find(".update-now")).data("name"),a.attr("aria-label",n.updates.l10n.updatingLabel.replace("%s",s)),u.removeClass("plugin-card-update-failed").find(".notice.notice-error").remove()),a.addClass("updating-message"),a.html()!==n.updates.l10n.updating&&a.data("originaltext",a.html()),a.text(n.updates.l10n.updating),n.a11y.speak(n.updates.l10n.updatingMsg),n.updates.updateLock?n.updates.updateQueue.push({type:"update-plugin",data:{plugin:e,slug:t}}):(n.updates.updateLock=!0,t={_ajax_nonce:n.updates.ajaxNonce,plugin:e,slug:t,_fs_nonce:n.updates.filesystemCredentials.fsNonce,username:n.updates.filesystemCredentials.ftp.username,password:n.updates.filesystemCredentials.ftp.password,hostname:n.updates.filesystemCredentials.ftp.hostname,connection_type:n.updates.filesystemCredentials.ftp.connectionType,public_key:n.updates.filesystemCredentials.ssh.publicKey,private_key:n.updates.filesystemCredentials.ssh.privateKey},n.ajax.post("update-plugin",t).done(n.updates.updateSuccess).fail(n.updates.updateError))},n.updates.updateSuccess=function(e){var t,a,s;"plugins"===p||"plugins-network"===p?(t=(a=d('[data-plugin="'+e.plugin+'"]').first()).next().find(".update-message"),a.addClass("updated").removeClass("update"),s=a.find(".plugin-version-author-uri").html().replace(e.oldVersion,e.newVersion),a.find(".plugin-version-author-uri").html(s),a.next().addClass("updated")):"plugin-install"===p&&((t=d(".plugin-card-"+e.slug).find(".update-now")).addClass("button-disabled"),a=t.data("name"),t.attr("aria-label",n.updates.l10n.updatedLabel.replace("%s",a))),t.removeClass("updating-message").addClass("updated-message"),t.text(n.updates.l10n.updated),n.a11y.speak(n.updates.l10n.updatedMsg),n.updates.decrementCount("plugin"),n.updates.updateDoneSuccessfully=!0,n.updates.updateLock=!1,d(document).trigger("wp-plugin-update-success",e),n.updates.queueChecker()},n.updates.updateError=function(e){var t,a,s,u=d(".plugin-card-"+e.slug);n.updates.updateDoneSuccessfully=!1,e.errorCode&&"unable_to_connect_to_filesystem"==e.errorCode&&n.updates.shouldRequestFilesystemCredentials?n.updates.credentialError(e,"update-plugin"):(s=n.updates.l10n.updateFailed.replace("%s",e.error),"plugins"===p||"plugins-network"===p?d('[data-plugin="'+e.plugin+'"]').next().find(".update-message").html(s).removeClass("updating-message"):"plugin-install"===p&&(a=(t=u.find(".update-now")).data("name"),u.addClass("plugin-card-update-failed").append('<div class="notice notice-error is-dismissible"><p>'+s+"</p></div>"),t.attr("aria-label",n.updates.l10n.updateFailedLabel.replace("%s",a)).html(n.updates.l10n.updateFailedShort).removeClass("updating-message"),u.on("click",".notice.is-dismissible .notice-dismiss",function(){setTimeout(function(){u.removeClass("plugin-card-update-failed").find(".column-name a").focus()},200)})),n.a11y.speak(s,"assertive"),n.updates.updateLock=!1,d(document).trigger("wp-plugin-update-error",e),n.updates.queueChecker())},n.updates.showErrorInCredentialsForm=function(e){var t=d(".notification-dialog");t.find(".error").remove(),t.find("h3").after('<div class="error">'+e+"</div>")},n.updates.credentialError=function(e,t){n.updates.updateQueue.push({type:t,data:{plugin:e.plugin,slug:e.slug}}),n.updates.showErrorInCredentialsForm(e.error),n.updates.requestFilesystemCredentials()},n.updates.queueChecker=function(){var e;n.updates.updateLock||n.updates.updateQueue.length<=0||(e=n.updates.updateQueue.shift(),n.updates.updatePlugin(e.data.plugin,e.data.slug))},n.updates.requestFilesystemCredentials=function(e){!1===n.updates.updateDoneSuccessfully&&("plugin-install"===p&&e&&(n.updates.$elToReturnFocusToFromCredentialsModal=d(e.target)),n.updates.updateLock=!0,n.updates.requestForCredentialsModalOpen())},n.updates.keydown=function(e){27===e.keyCode?n.updates.requestForCredentialsModalCancel():9===e.keyCode&&("upgrade"!==e.target.id||e.shiftKey?"hostname"===e.target.id&&e.shiftKey&&(d("#upgrade").focus(),e.preventDefault()):(d("#hostname").focus(),e.preventDefault()))},n.updates.requestForCredentialsModalOpen=function(){var e=d("#request-filesystem-credentials-dialog");d("body").addClass("modal-open"),e.show(),e.find("input:enabled:first").focus(),e.keydown(n.updates.keydown)},n.updates.requestForCredentialsModalClose=function(){d("#request-filesystem-credentials-dialog").hide(),d("body").removeClass("modal-open"),n.updates.$elToReturnFocusToFromCredentialsModal.focus()},n.updates.requestForCredentialsModalCancel=function(){var e,t;!1===n.updates.updateLock&&0===n.updates.updateQueue.length||(e=n.updates.updateQueue[0].data,n.updates.updateLock=!1,n.updates.updateQueue=[],n.updates.requestForCredentialsModalClose(),"plugins"===p||"plugins-network"===p?t=d('[data-plugin="'+e.plugin+'"]').next().find(".update-message"):"plugin-install"===p&&(t=d(".plugin-card-"+e.slug).find(".update-now")),t.removeClass("updating-message"),t.html(t.data("originaltext")),n.a11y.speak(n.updates.l10n.updateCancel))},n.updates.beforeunload=function(){if(n.updates.updateLock)return n.updates.l10n.beforeunload},d(document).ready(function(){n.updates.shouldRequestFilesystemCredentials=!(d("#request-filesystem-credentials-dialog").length<=0),d("#request-filesystem-credentials-dialog form").on("submit",function(){return n.updates.filesystemCredentials.fsNonce=d("#_fs_nonce").val(),n.updates.filesystemCredentials.ftp.hostname=d("#hostname").val(),n.updates.filesystemCredentials.ftp.username=d("#username").val(),n.updates.filesystemCredentials.ftp.password=d("#password").val(),n.updates.filesystemCredentials.ftp.connectionType=d('input[name="connection_type"]:checked').val(),n.updates.filesystemCredentials.ssh.publicKey=d("#public_key").val(),n.updates.filesystemCredentials.ssh.privateKey=d("#private_key").val(),n.updates.requestForCredentialsModalClose(),n.updates.updateLock=!1,n.updates.queueChecker(),!1}),d('#request-filesystem-credentials-dialog [data-js-action="close"], .notification-dialog-background').on("click",function(){n.updates.requestForCredentialsModalCancel()}),d('#request-filesystem-credentials-dialog input[name="connection_type"]').on("change",function(){d(this).parents("form").find("#private_key, #public_key").parents("label").toggle("ssh"==d(this).val())}).change(),d(".plugin-update-tr").on("click",".update-link",function(e){e.preventDefault(),n.updates.shouldRequestFilesystemCredentials&&!n.updates.updateLock&&n.updates.requestFilesystemCredentials(e);e=d(e.target).parents(".plugin-update-tr");n.updates.$elToReturnFocusToFromCredentialsModal=e.prev().find(".check-column input"),n.updates.updatePlugin(e.data("plugin"),e.data("slug"))}),d(".plugin-card").on("click",".update-now",function(e){e.preventDefault();var t=d(e.target);t.hasClass("updating-message")||t.hasClass("button-disabled")||(n.updates.shouldRequestFilesystemCredentials&&!n.updates.updateLock&&n.updates.requestFilesystemCredentials(e),n.updates.updatePlugin(t.data("plugin"),t.data("slug")))}),d("#plugin_update_from_iframe").on("click",function(e){var t=window.parent==window?null:window.parent;d.support.postMessage=!!window.postMessage,!1!==d.support.postMessage&&null!==t&&-1===window.parent.location.pathname.indexOf("update-core.php")&&(e.preventDefault(),e={action:"updatePlugin",type:"update-plugin",data:{plugin:d(this).data("plugin"),slug:d(this).data("slug")}},t.postMessage(JSON.stringify(e),window.location.origin))})}),d(window).on("message",function(e){var t,a=e.originalEvent,e=document.location,e=e.protocol+"//"+e.hostname;if(a.origin===e&&void 0!==(t=d.parseJSON(a.data)).action)switch(t.action){case"decrementUpdateCount":n.updates.decrementCount(t.upgradeType);break;case"updatePlugin":tb_remove(),n.updates.updateQueue.push(t),n.updates.queueChecker()}}),d(window).on("beforeunload",n.updates.beforeunload)}(jQuery,window.wp,window.pagenow,window.ajaxurl);