mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-12 13:44:21 +01:00
eae23abd88
Further improves webpack configuration for editor files to use hashed module IDs in the compressed (`*.min.js`) production files. Follow up to [50940]. Props @gziolo. Merges [51035] to the 5.7 branch. Fixes #53192. Built from https://develop.svn.wordpress.org/branches/5.7@51036 git-svn-id: http://core.svn.wordpress.org/branches/5.7@50645 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2 lines
16 KiB
JavaScript
2 lines
16 KiB
JavaScript
/*! This file is auto-generated */
|
|
this.wp=this.wp||{},this.wp.mediaUtils=function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s="Lb+8")}({"1OyB":function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}r.d(t,"a",(function(){return n}))},"25BE":function(e,t,r){"use strict";function n(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}r.d(t,"a",(function(){return n}))},BsWD:function(e,t,r){"use strict";r.d(t,"a",(function(){return i}));var n=r("a3WO");function i(e,t){if(e){if("string"==typeof e)return Object(n.a)(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Object(n.a)(e,t):void 0}}},DSFK:function(e,t,r){"use strict";function n(e){if(Array.isArray(e))return e}r.d(t,"a",(function(){return n}))},GRId:function(e,t){e.exports=window.wp.element},"HaE+":function(e,t,r){"use strict";function n(e,t,r,n,i,o,a){try{var l=e[o](a),c=l.value}catch(e){return void r(e)}l.done?t(c):Promise.resolve(c).then(n,i)}function i(e){return function(){var t=this,r=arguments;return new Promise((function(i,o){var a=e.apply(t,r);function l(e){n(a,i,o,l,c,"next",e)}function c(e){n(a,i,o,l,c,"throw",e)}l(void 0)}))}}r.d(t,"a",(function(){return i}))},JX7q:function(e,t,r){"use strict";function n(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}r.d(t,"a",(function(){return n}))},Ji7U:function(e,t,r){"use strict";r.d(t,"a",(function(){return i}));var n=r("s4An");function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Object(n.a)(e,t)}},KQm4:function(e,t,r){"use strict";r.d(t,"a",(function(){return a}));var n=r("a3WO");var i=r("25BE"),o=r("BsWD");function a(e){return function(e){if(Array.isArray(e))return Object(n.a)(e)}(e)||Object(i.a)(e)||Object(o.a)(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}},"Lb+8":function(e,t,r){"use strict";r.r(t),r.d(t,"MediaUpload",(function(){return h})),r.d(t,"uploadMedia",(function(){return M}));var n=r("1OyB"),i=r("vuIU"),o=r("JX7q"),a=r("Ji7U"),l=r("md7G"),c=r("foSv"),u=r("YLtl"),s=r("GRId"),f=r("l3Sj");function d(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=Object(c.a)(e);if(t){var i=Object(c.a)(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return Object(l.a)(this,r)}}var p=window.wp,m=[],y=function(e){return Object(u.pick)(e,["sizes","mime","type","subtype","id","url","alt","link","caption"])},b=function(e){return p.media.query({order:"ASC",orderby:"post__in",post__in:e,posts_per_page:-1,query:!0,type:"image"})},h=function(e){Object(a.a)(r,e);var t=d(r);function r(e){var i,a=e.allowedTypes,l=e.gallery,c=void 0!==l&&l,u=e.unstableFeaturedImageFlow,s=void 0!==u&&u,d=e.modalClass,m=e.multiple,y=void 0!==m&&m,b=e.title,h=void 0===b?Object(f.__)("Select or Upload Media"):b;if(Object(n.a)(this,r),(i=t.apply(this,arguments)).openModal=i.openModal.bind(Object(o.a)(i)),i.onOpen=i.onOpen.bind(Object(o.a)(i)),i.onSelect=i.onSelect.bind(Object(o.a)(i)),i.onUpdate=i.onUpdate.bind(Object(o.a)(i)),i.onClose=i.onClose.bind(Object(o.a)(i)),c)i.buildAndSetGalleryFrame();else{var v={title:h,multiple:y};a&&(v.library={type:a}),i.frame=p.media(v)}return d&&i.frame.$el.addClass(d),s&&i.buildAndSetFeatureImageFrame(),i.initializeListeners(),i}return Object(i.a)(r,[{key:"initializeListeners",value:function(){this.frame.on("select",this.onSelect),this.frame.on("update",this.onUpdate),this.frame.on("open",this.onOpen),this.frame.on("close",this.onClose)}},{key:"buildAndSetGalleryFrame",value:function(){var e=this.props,t=e.addToGallery,r=void 0!==t&&t,n=e.allowedTypes,i=e.multiple,o=void 0!==i&&i,a=e.value,l=void 0===a?m:a;if(l!==this.lastGalleryValue){var c;this.lastGalleryValue=l,this.frame&&this.frame.remove(),c=r?"gallery-library":l&&l.length?"gallery-edit":"gallery",this.GalleryDetailsMediaFrame||(this.GalleryDetailsMediaFrame=p.media.view.MediaFrame.Post.extend({galleryToolbar:function(){var e=this.state().get("editing");this.toolbar.set(new p.media.view.Toolbar({controller:this,items:{insert:{style:"primary",text:e?p.media.view.l10n.updateGallery:p.media.view.l10n.insertGallery,priority:80,requires:{library:!0},click:function(){var e=this.controller,t=e.state();e.close(),t.trigger("update",t.get("library")),e.setState(e.options.state),e.reset()}}}}))},editState:function(){var e=this.state("gallery").get("selection"),t=new p.media.view.EditImage({model:e.single(),controller:this}).render();this.content.set(t),t.loadEditor()},createStates:function(){this.on("toolbar:create:main-gallery",this.galleryToolbar,this),this.on("content:render:edit-image",this.editState,this),this.states.add([new p.media.controller.Library({id:"gallery",title:p.media.view.l10n.createGalleryTitle,priority:40,toolbar:"main-gallery",filterable:"uploaded",multiple:"add",editable:!1,library:p.media.query(Object(u.defaults)({type:"image"},this.options.library))}),new p.media.controller.EditImage({model:this.options.editImage}),new p.media.controller.GalleryEdit({library:this.options.selection,editing:this.options.editing,menu:"gallery",displaySettings:!1,multiple:!0}),new p.media.controller.GalleryAdd])}}));var s=b(l),f=new p.media.model.Selection(s.models,{props:s.props.toJSON(),multiple:o});this.frame=new this.GalleryDetailsMediaFrame({mimeType:n,state:c,multiple:o,selection:f,editing:!(!l||!l.length)}),p.media.frame=this.frame,this.initializeListeners()}}},{key:"buildAndSetFeatureImageFrame",value:function(){var e=p.media.view.MediaFrame.Select.extend({featuredImageToolbar:function(e){this.createSelectToolbar(e,{text:p.media.view.l10n.setFeaturedImage,state:this.options.state})},editState:function(){var e=this.state("featured-image").get("selection"),t=new p.media.view.EditImage({model:e.single(),controller:this}).render();this.content.set(t),t.loadEditor()},createStates:function(){this.on("toolbar:create:featured-image",this.featuredImageToolbar,this),this.on("content:render:edit-image",this.editState,this),this.states.add([new p.media.controller.FeaturedImage,new p.media.controller.EditImage({model:this.options.editImage})])}}),t=b(this.props.value),r=new p.media.model.Selection(t.models,{props:t.props.toJSON()});this.frame=new e({mimeType:this.props.allowedTypes,state:"featured-image",multiple:this.props.multiple,selection:r,editing:!!this.props.value}),p.media.frame=this.frame}},{key:"componentWillUnmount",value:function(){this.frame.remove()}},{key:"onUpdate",value:function(e){var t=this.props,r=t.onSelect,n=t.multiple,i=void 0!==n&&n,o=this.frame.state(),a=e||o.get("selection");a&&a.models.length&&r(i?a.models.map((function(e){return y(e.toJSON())})):y(a.models[0].toJSON()))}},{key:"onSelect",value:function(){var e=this.props,t=e.onSelect,r=e.multiple,n=void 0!==r&&r,i=this.frame.state().get("selection").toJSON();t(n?i:i[0])}},{key:"onOpen",value:function(){if(this.updateCollection(),this.props.value){if(!this.props.gallery){var e=this.frame.state().get("selection");Object(u.castArray)(this.props.value).forEach((function(t){e.add(p.media.attachment(t))}))}b(Object(u.castArray)(this.props.value)).more()}}},{key:"onClose",value:function(){var e=this.props.onClose;e&&e()}},{key:"updateCollection",value:function(){var e=this.frame.content.get();if(e&&e.collection){var t=e.collection;t.toArray().forEach((function(e){return e.trigger("destroy",e)})),t.mirroring._hasMore=!0,t.more()}}},{key:"openModal",value:function(){this.props.gallery&&this.buildAndSetGalleryFrame(),this.frame.open()}},{key:"render",value:function(){return this.props.render({open:this.openModal})}}]),r}(s.Component),v=r("dvlR"),O=r.n(v),g=r("rePB"),w=r("HaE+"),j=r("KQm4"),S=r("ODXe"),_=r("ywyh"),x=r.n(_),E=r("xTGt");function T(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function P(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?T(Object(r),!0).forEach((function(t){Object(g.a)(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):T(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function A(e,t){var r;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(r=function(e,t){if(!e)return;if("string"==typeof e)return I(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return I(e,t)}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,l=!1;return{s:function(){r=e[Symbol.iterator]()},n:function(){var e=r.next();return a=e.done,e},e:function(e){l=!0,o=e},f:function(){try{a||null==r.return||r.return()}finally{if(l)throw o}}}}function I(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function k(e){return e?Object(u.flatMap)(e,(function(e,t){var r=e.split("/"),n=Object(S.a)(r,1)[0],i=t.split("|");return[e].concat(Object(j.a)(Object(u.map)(i,(function(e){return"".concat(n,"/").concat(e)}))))})):e}function M(e){return F.apply(this,arguments)}function F(){return(F=Object(w.a)(O.a.mark((function e(t){var r,n,i,o,a,l,c,d,p,m,y,b,h,v,g,w,S,_,x,T,I,M,F,G,D,R;return O.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=t.allowedTypes,n=t.additionalData,i=void 0===n?{}:n,o=t.filesList,a=t.maxUploadFileSize,l=t.onError,c=void 0===l?u.noop:l,d=t.onFileChange,p=t.wpAllowedMimeTypes,m=void 0===p?null:p,y=Object(j.a)(o),b=[],h=function(e,t){Object(E.revokeBlobURL)(Object(u.get)(b,[e,"url"])),b[e]=t,d(Object(u.compact)(b))},v=function(e){return!r||Object(u.some)(r,(function(t){return Object(u.includes)(t,"/")?t===e:Object(u.startsWith)(e,"".concat(t,"/"))}))},g=k(m),w=function(e){return Object(u.includes)(g,e)},S=function(e){e.message=[Object(s.createElement)("strong",{key:"filename"},e.file.name),": ",e.message],c(e)},_=[],x=A(y),e.prev=10,x.s();case 12:if((T=x.n()).done){e.next=31;break}if(I=T.value,!g||!I.type||w(I.type)){e.next=17;break}return S({code:"MIME_TYPE_NOT_ALLOWED_FOR_USER",message:Object(f.__)("Sorry, this file type is not permitted for security reasons."),file:I}),e.abrupt("continue",29);case 17:if(!I.type||v(I.type)){e.next=20;break}return S({code:"MIME_TYPE_NOT_SUPPORTED",message:Object(f.__)("Sorry, this file type is not supported here."),file:I}),e.abrupt("continue",29);case 20:if(!(a&&I.size>a)){e.next=23;break}return S({code:"SIZE_ABOVE_LIMIT",message:Object(f.__)("This file exceeds the maximum upload size for this site."),file:I}),e.abrupt("continue",29);case 23:if(!(I.size<=0)){e.next=26;break}return S({code:"EMPTY_FILE",message:Object(f.__)("This file is empty."),file:I}),e.abrupt("continue",29);case 26:_.push(I),b.push({url:Object(E.createBlobURL)(I)}),d(b);case 29:e.next=12;break;case 31:e.next=36;break;case 33:e.prev=33,e.t0=e.catch(10),x.e(e.t0);case 36:return e.prev=36,x.f(),e.finish(36);case 39:M=0;case 40:if(!(M<_.length)){e.next=59;break}return F=_[M],e.prev=42,e.next=45,U(F,i);case 45:G=e.sent,D=P(P({},Object(u.omit)(G,["alt_text","source_url"])),{},{alt:G.alt_text,caption:Object(u.get)(G,["caption","raw"],""),title:G.title.raw,url:G.source_url}),h(M,D),e.next=56;break;case 50:e.prev=50,e.t1=e.catch(42),h(M,null),R=void 0,R=Object(u.has)(e.t1,["message"])?Object(u.get)(e.t1,["message"]):Object(f.sprintf)(Object(f.__)("Error while uploading file %s to the media library."),F.name),c({code:"GENERAL",message:R,file:F});case 56:++M,e.next=40;break;case 59:case"end":return e.stop()}}),e,null,[[10,33,36,39],[42,50]])})))).apply(this,arguments)}function U(e,t){var r=new window.FormData;return r.append("file",e,e.name||e.type.replace("/",".")),Object(u.forEach)(t,(function(e,t){return r.append(t,e)})),x()({path:"/wp/v2/media",body:r,method:"POST"})}},ODXe:function(e,t,r){"use strict";r.d(t,"a",(function(){return a}));var n=r("DSFK");var i=r("BsWD"),o=r("PYwp");function a(e,t){return Object(n.a)(e)||function(e,t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e)){var r=[],n=!0,i=!1,o=void 0;try{for(var a,l=e[Symbol.iterator]();!(n=(a=l.next()).done)&&(r.push(a.value),!t||r.length!==t);n=!0);}catch(e){i=!0,o=e}finally{try{n||null==l.return||l.return()}finally{if(i)throw o}}return r}}(e,t)||Object(i.a)(e,t)||Object(o.a)()}},PYwp:function(e,t,r){"use strict";function n(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}r.d(t,"a",(function(){return n}))},U8pU:function(e,t,r){"use strict";function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}r.d(t,"a",(function(){return n}))},YLtl:function(e,t){e.exports=window.lodash},a3WO:function(e,t,r){"use strict";function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}r.d(t,"a",(function(){return n}))},dvlR:function(e,t){e.exports=window.regeneratorRuntime},foSv:function(e,t,r){"use strict";function n(e){return(n=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}r.d(t,"a",(function(){return n}))},l3Sj:function(e,t){e.exports=window.wp.i18n},md7G:function(e,t,r){"use strict";r.d(t,"a",(function(){return o}));var n=r("U8pU"),i=r("JX7q");function o(e,t){return!t||"object"!==Object(n.a)(t)&&"function"!=typeof t?Object(i.a)(e):t}},rePB:function(e,t,r){"use strict";function n(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}r.d(t,"a",(function(){return n}))},s4An:function(e,t,r){"use strict";function n(e,t){return(n=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}r.d(t,"a",(function(){return n}))},vuIU:function(e,t,r){"use strict";function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function i(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}r.d(t,"a",(function(){return i}))},xTGt:function(e,t){e.exports=window.wp.blob},ywyh:function(e,t){e.exports=window.wp.apiFetch}}); |