WordPress/wp-includes/js/dist/preferences-persistence.min.js
youknowriad 1de40f71be Editor: Update the WordPress packages to the Gutenberg 16.7 RC2 version.
This patch, somewhat small brings a lot to WordPress. 
This includes features like:

 - DataViews.
 - Customization tools like box shadow, background size and repeat.
 - UI improvements in the site editor. 
 - Preferences sharing between the post and site editors.
 - Unified panels and editors between post and site editors.
 - Improved template mode in the post editor.
 - Iterations to multiple interactive blocks.
 - Preparing the blocks and UI for pattern overrides.
 - and a lot more.

Props luisherranz, gziolo, isabel_brison, costdev, jonsurrell, peterwilsoncc, get_dave, antonvlasenko, desrosj.
See #60315.
Built from https://develop.svn.wordpress.org/trunk@57377


git-svn-id: http://core.svn.wordpress.org/trunk@56883 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-01-29 21:07:12 +00:00

2 lines
5.5 KiB
JavaScript

/*! This file is auto-generated */
!function(){"use strict";var e={n:function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(r,{a:r}),r},d:function(t,r){for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r:function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{__unstableCreatePersistenceLayer:function(){return m},create:function(){return s}});var r=window.wp.apiFetch,n=e.n(r);const o={},c=window.localStorage;function s({preloadedData:e,localStorageRestoreKey:t="WP_PREFERENCES_RESTORE_DATA",requestDebounceMS:r=2500}={}){let s=e;const i=function(e,t){let r,n;return async function(...o){return n||r?(n&&await n,r&&(clearTimeout(r),r=null),new Promise(((c,s)=>{r=setTimeout((()=>{n=e(...o).then(((...e)=>{c(...e)})).catch((e=>{s(e)})).finally((()=>{n=null,r=null}))}),t)}))):new Promise(((t,r)=>{n=e(...o).then(((...e)=>{t(...e)})).catch((e=>{r(e)})).finally((()=>{n=null}))}))}}(n(),r);return{get:async function(){if(s)return s;const e=await n()({path:"/wp/v2/users/me?context=edit"}),r=e?.meta?.persisted_preferences,i=JSON.parse(c.getItem(t)),a=Date.parse(r?._modified)||0,d=Date.parse(i?._modified)||0;return s=r&&a>=d?r:i||o,s},set:function(e){const r={...e,_modified:(new Date).toISOString()};s=r,c.setItem(t,JSON.stringify(r)),i({path:"/wp/v2/users/me",method:"PUT",keepalive:!0,data:{meta:{persisted_preferences:r}}}).catch((()=>{}))}}}function i(e,t){const r="core/preferences",n="core/interface",o=e?.[n]?.preferences?.features?.[t],c=e?.[t]?.preferences?.features,s=o||c;if(!s)return e;const i=e?.[r]?.preferences;if(i?.[t])return e;let a,d;if(o){const r=e?.[n],o=e?.[n]?.preferences?.features;a={[n]:{...r,preferences:{features:{...o,[t]:void 0}}}}}if(c){const r=e?.[t],n=e?.[t]?.preferences;d={[t]:{...r,preferences:{...n,features:void 0}}}}return{...e,[r]:{preferences:{...i,[t]:s}},...a,...d}}const a=e=>e;function d(e,{from:t,to:r},n,o=a){const c="core/preferences",s=e?.[t]?.preferences?.[n];if(void 0===s)return e;const i=e?.[c]?.preferences?.[r]?.[n];if(i)return e;const d=e?.[c]?.preferences,f=e?.[c]?.preferences?.[r],u=e?.[t],l=e?.[t]?.preferences,p=o({[n]:s});return{...e,[c]:{preferences:{...d,[r]:{...f,...p}}},[t]:{...u,preferences:{...l,[n]:void 0}}}}function f(e){var t;const r=null!==(t=e?.panels)&&void 0!==t?t:{};return Object.keys(r).reduce(((e,t)=>{const n=r[t];return!1===n?.enabled&&e.inactivePanels.push(t),!0===n?.opened&&e.openPanels.push(t),e}),{inactivePanels:[],openPanels:[]})}function u(e){if(e)return e=i(e,"core/edit-widgets"),e=i(e,"core/customize-widgets"),e=i(e,"core/edit-post"),e=d(e=function(e){var t,r,n;const o="core/interface",c="core/preferences",s=e?.[o]?.enableItems;if(!s)return e;const i=null!==(t=e?.[c]?.preferences)&&void 0!==t?t:{},a=null!==(r=s?.singleEnableItems?.complementaryArea)&&void 0!==r?r:{},d=Object.keys(a).reduce(((e,t)=>{const r=a[t];return e?.[t]?.complementaryArea?e:{...e,[t]:{...e[t],complementaryArea:r}}}),i),f=null!==(n=s?.multipleEnableItems?.pinnedItems)&&void 0!==n?n:{},u=Object.keys(f).reduce(((e,t)=>{const r=f[t];return e?.[t]?.pinnedItems?e:{...e,[t]:{...e[t],pinnedItems:r}}}),d),l=e[o];return{...e,[c]:{preferences:u},[o]:{...l,enableItems:void 0}}}(e=function(e){const t="core/interface",r="core/preferences",n=e?.[t]?.preferences?.features,o=n?Object.keys(n):[];return o?.length?o.reduce((function(e,o){if(o.startsWith("core"))return e;const c=n?.[o];if(!c)return e;const s=e?.[r]?.preferences?.[o];if(s)return e;const i=e?.[r]?.preferences,a=e?.[t],d=e?.[t]?.preferences?.features;return{...e,[r]:{preferences:{...i,[o]:c}},[t]:{...a,preferences:{features:{...d,[o]:void 0}}}}}),e):e}(e=i(e,"core/edit-site"))),{from:"core/edit-post",to:"core/edit-post"},"hiddenBlockTypes"),e=d(e,{from:"core/edit-post",to:"core/edit-post"},"editorMode"),e=d(e,{from:"core/edit-post",to:"core/edit-post"},"preferredStyleVariations"),e=d(e,{from:"core/edit-post",to:"core/edit-post"},"panels",f),e=d(e,{from:"core/editor",to:"core/edit-post"},"isPublishSidebarEnabled"),e=d(e,{from:"core/edit-site",to:"core/edit-site"},"editorMode"),e?.["core/preferences"]?.preferences}function l(e){const t=function(e){const t=`WP_DATA_USER_${e}`,r=window.localStorage.getItem(t);return JSON.parse(r)}(e);return u(t)}function p(e){let t=(r=e,Object.keys(r).reduce(((e,t)=>{const n=r[t];if(n?.complementaryArea){const r={...n};return delete r.complementaryArea,r.isComplementaryAreaVisible=!0,e[t]=r,e}return e}),r));var r;return t=function(e){var t,r;let n=e;return["allowRightClickOverrides","distractionFree","editorMode","fixedToolbar","focusMode","hiddenBlockTypes","inactivePanels","keepCaretInsideBlock","mostUsedBlocks","openPanels","showBlockBreadcrumbs","showIconLabels","showListViewByDefault"].forEach((t=>{void 0!==e?.["core/edit-post"]?.[t]&&(n={...n,core:{...n?.core,[t]:e["core/edit-post"][t]}},delete n["core/edit-post"][t]),void 0!==e?.["core/edit-site"]?.[t]&&delete n["core/edit-site"][t]})),0===Object.keys(null!==(t=n?.["core/edit-post"])&&void 0!==t?t:{})?.length&&delete n["core/edit-post"],0===Object.keys(null!==(r=n?.["core/edit-site"])&&void 0!==r?r:{})?.length&&delete n["core/edit-site"],n}(t),t}function m(e,t){const r=`WP_PREFERENCES_USER_${t}`,n=JSON.parse(window.localStorage.getItem(r)),o=Date.parse(e&&e._modified)||0,c=Date.parse(n&&n._modified)||0;let i;return i=e&&o>=c?p(e):n?p(n):l(t),s({preloadedData:i,localStorageRestoreKey:r})}(window.wp=window.wp||{}).preferencesPersistence=t}();