@wordpress/preferences-persistence 1.46.0 → 1.48.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/build/create/debounce-async.js.map +1 -1
  3. package/build/create/index.js.map +1 -1
  4. package/build/index.js.map +1 -1
  5. package/build/migrations/legacy-local-storage-data/convert-edit-post-panels.js.map +1 -1
  6. package/build/migrations/legacy-local-storage-data/index.js +5 -1
  7. package/build/migrations/legacy-local-storage-data/index.js.map +1 -1
  8. package/build/migrations/legacy-local-storage-data/move-feature-preferences.js.map +1 -1
  9. package/build/migrations/legacy-local-storage-data/move-individual-preference.js.map +1 -1
  10. package/build/migrations/legacy-local-storage-data/move-interface-enable-items.js.map +1 -1
  11. package/build/migrations/legacy-local-storage-data/move-third-party-feature-preferences.js.map +1 -1
  12. package/build/migrations/preferences-package-data/convert-complementary-areas.js.map +1 -1
  13. package/build/migrations/preferences-package-data/convert-editor-settings.js +1 -1
  14. package/build/migrations/preferences-package-data/convert-editor-settings.js.map +1 -1
  15. package/build/migrations/preferences-package-data/index.js.map +1 -1
  16. package/build-module/create/debounce-async.js.map +1 -1
  17. package/build-module/create/index.js.map +1 -1
  18. package/build-module/index.js.map +1 -1
  19. package/build-module/migrations/legacy-local-storage-data/convert-edit-post-panels.js.map +1 -1
  20. package/build-module/migrations/legacy-local-storage-data/index.js +5 -1
  21. package/build-module/migrations/legacy-local-storage-data/index.js.map +1 -1
  22. package/build-module/migrations/legacy-local-storage-data/move-feature-preferences.js.map +1 -1
  23. package/build-module/migrations/legacy-local-storage-data/move-individual-preference.js.map +1 -1
  24. package/build-module/migrations/legacy-local-storage-data/move-interface-enable-items.js.map +1 -1
  25. package/build-module/migrations/legacy-local-storage-data/move-third-party-feature-preferences.js.map +1 -1
  26. package/build-module/migrations/preferences-package-data/convert-complementary-areas.js.map +1 -1
  27. package/build-module/migrations/preferences-package-data/convert-editor-settings.js +1 -1
  28. package/build-module/migrations/preferences-package-data/convert-editor-settings.js.map +1 -1
  29. package/build-module/migrations/preferences-package-data/index.js.map +1 -1
  30. package/package.json +3 -3
  31. package/src/migrations/legacy-local-storage-data/index.js +6 -1
  32. package/src/migrations/preferences-package-data/convert-editor-settings.js +3 -0
  33. package/src/migrations/preferences-package-data/test/convert-complementary-areas.js +1 -1
  34. package/src/migrations/preferences-package-data/test/index.js +3 -4
package/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 1.48.0 (2024-04-19)
6
+
7
+ ## 1.47.0 (2024-04-03)
8
+
5
9
  ## 1.46.0 (2024-03-21)
6
10
 
7
11
  ## 1.45.0 (2024-03-06)
@@ -1 +1 @@
1
- {"version":3,"names":["debounceAsync","func","delayMS","timeoutId","activePromise","debounced","args","Promise","resolve","reject","then","thenArgs","catch","error","finally","clearTimeout","setTimeout"],"sources":["@wordpress/preferences-persistence/src/create/debounce-async.js"],"sourcesContent":["/**\n * Performs a leading edge debounce of async functions.\n *\n * If three functions are throttled at the same time:\n * - The first happens immediately.\n * - The second is never called.\n * - The third happens `delayMS` milliseconds after the first has resolved.\n *\n * This is distinct from `{ debounce } from @wordpress/compose` in that it\n * waits for promise resolution.\n *\n * @param {Function} func A function that returns a promise.\n * @param {number} delayMS A delay in milliseconds.\n *\n * @return {Function} A function that debounce whatever function is passed\n * to it.\n */\nexport default function debounceAsync( func, delayMS ) {\n\tlet timeoutId;\n\tlet activePromise;\n\n\treturn async function debounced( ...args ) {\n\t\t// This is a leading edge debounce. If there's no promise or timeout\n\t\t// in progress, call the debounced function immediately.\n\t\tif ( ! activePromise && ! timeoutId ) {\n\t\t\treturn new Promise( ( resolve, reject ) => {\n\t\t\t\t// Keep a reference to the promise.\n\t\t\t\tactivePromise = func( ...args )\n\t\t\t\t\t.then( ( ...thenArgs ) => {\n\t\t\t\t\t\tresolve( ...thenArgs );\n\t\t\t\t\t} )\n\t\t\t\t\t.catch( ( error ) => {\n\t\t\t\t\t\treject( error );\n\t\t\t\t\t} )\n\t\t\t\t\t.finally( () => {\n\t\t\t\t\t\t// As soon this promise is complete, clear the way for the\n\t\t\t\t\t\t// next one to happen immediately.\n\t\t\t\t\t\tactivePromise = null;\n\t\t\t\t\t} );\n\t\t\t} );\n\t\t}\n\n\t\tif ( activePromise ) {\n\t\t\t// Let any active promises finish before queuing the next request.\n\t\t\tawait activePromise;\n\t\t}\n\n\t\t// Clear any active timeouts, abandoning any requests that have\n\t\t// been queued but not been made.\n\t\tif ( timeoutId ) {\n\t\t\tclearTimeout( timeoutId );\n\t\t\ttimeoutId = null;\n\t\t}\n\n\t\t// Trigger any trailing edge calls to the function.\n\t\treturn new Promise( ( resolve, reject ) => {\n\t\t\t// Schedule the next request but with a delay.\n\t\t\ttimeoutId = setTimeout( () => {\n\t\t\t\tactivePromise = func( ...args )\n\t\t\t\t\t.then( ( ...thenArgs ) => {\n\t\t\t\t\t\tresolve( ...thenArgs );\n\t\t\t\t\t} )\n\t\t\t\t\t.catch( ( error ) => {\n\t\t\t\t\t\treject( error );\n\t\t\t\t\t} )\n\t\t\t\t\t.finally( () => {\n\t\t\t\t\t\t// As soon this promise is complete, clear the way for the\n\t\t\t\t\t\t// next one to happen immediately.\n\t\t\t\t\t\tactivePromise = null;\n\t\t\t\t\t\ttimeoutId = null;\n\t\t\t\t\t} );\n\t\t\t}, delayMS );\n\t\t} );\n\t};\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,aAAaA,CAAEC,IAAI,EAAEC,OAAO,EAAG;EACtD,IAAIC,SAAS;EACb,IAAIC,aAAa;EAEjB,OAAO,eAAeC,SAASA,CAAE,GAAGC,IAAI,EAAG;IAC1C;IACA;IACA,IAAK,CAAEF,aAAa,IAAI,CAAED,SAAS,EAAG;MACrC,OAAO,IAAII,OAAO,CAAE,CAAEC,OAAO,EAAEC,MAAM,KAAM;QAC1C;QACAL,aAAa,GAAGH,IAAI,CAAE,GAAGK,IAAK,CAAC,CAC7BI,IAAI,CAAE,CAAE,GAAGC,QAAQ,KAAM;UACzBH,OAAO,CAAE,GAAGG,QAAS,CAAC;QACvB,CAAE,CAAC,CACFC,KAAK,CAAIC,KAAK,IAAM;UACpBJ,MAAM,CAAEI,KAAM,CAAC;QAChB,CAAE,CAAC,CACFC,OAAO,CAAE,MAAM;UACf;UACA;UACAV,aAAa,GAAG,IAAI;QACrB,CAAE,CAAC;MACL,CAAE,CAAC;IACJ;IAEA,IAAKA,aAAa,EAAG;MACpB;MACA,MAAMA,aAAa;IACpB;;IAEA;IACA;IACA,IAAKD,SAAS,EAAG;MAChBY,YAAY,CAAEZ,SAAU,CAAC;MACzBA,SAAS,GAAG,IAAI;IACjB;;IAEA;IACA,OAAO,IAAII,OAAO,CAAE,CAAEC,OAAO,EAAEC,MAAM,KAAM;MAC1C;MACAN,SAAS,GAAGa,UAAU,CAAE,MAAM;QAC7BZ,aAAa,GAAGH,IAAI,CAAE,GAAGK,IAAK,CAAC,CAC7BI,IAAI,CAAE,CAAE,GAAGC,QAAQ,KAAM;UACzBH,OAAO,CAAE,GAAGG,QAAS,CAAC;QACvB,CAAE,CAAC,CACFC,KAAK,CAAIC,KAAK,IAAM;UACpBJ,MAAM,CAAEI,KAAM,CAAC;QAChB,CAAE,CAAC,CACFC,OAAO,CAAE,MAAM;UACf;UACA;UACAV,aAAa,GAAG,IAAI;UACpBD,SAAS,GAAG,IAAI;QACjB,CAAE,CAAC;MACL,CAAC,EAAED,OAAQ,CAAC;IACb,CAAE,CAAC;EACJ,CAAC;AACF"}
1
+ {"version":3,"names":["debounceAsync","func","delayMS","timeoutId","activePromise","debounced","args","Promise","resolve","reject","then","thenArgs","catch","error","finally","clearTimeout","setTimeout"],"sources":["@wordpress/preferences-persistence/src/create/debounce-async.js"],"sourcesContent":["/**\n * Performs a leading edge debounce of async functions.\n *\n * If three functions are throttled at the same time:\n * - The first happens immediately.\n * - The second is never called.\n * - The third happens `delayMS` milliseconds after the first has resolved.\n *\n * This is distinct from `{ debounce } from @wordpress/compose` in that it\n * waits for promise resolution.\n *\n * @param {Function} func A function that returns a promise.\n * @param {number} delayMS A delay in milliseconds.\n *\n * @return {Function} A function that debounce whatever function is passed\n * to it.\n */\nexport default function debounceAsync( func, delayMS ) {\n\tlet timeoutId;\n\tlet activePromise;\n\n\treturn async function debounced( ...args ) {\n\t\t// This is a leading edge debounce. If there's no promise or timeout\n\t\t// in progress, call the debounced function immediately.\n\t\tif ( ! activePromise && ! timeoutId ) {\n\t\t\treturn new Promise( ( resolve, reject ) => {\n\t\t\t\t// Keep a reference to the promise.\n\t\t\t\tactivePromise = func( ...args )\n\t\t\t\t\t.then( ( ...thenArgs ) => {\n\t\t\t\t\t\tresolve( ...thenArgs );\n\t\t\t\t\t} )\n\t\t\t\t\t.catch( ( error ) => {\n\t\t\t\t\t\treject( error );\n\t\t\t\t\t} )\n\t\t\t\t\t.finally( () => {\n\t\t\t\t\t\t// As soon this promise is complete, clear the way for the\n\t\t\t\t\t\t// next one to happen immediately.\n\t\t\t\t\t\tactivePromise = null;\n\t\t\t\t\t} );\n\t\t\t} );\n\t\t}\n\n\t\tif ( activePromise ) {\n\t\t\t// Let any active promises finish before queuing the next request.\n\t\t\tawait activePromise;\n\t\t}\n\n\t\t// Clear any active timeouts, abandoning any requests that have\n\t\t// been queued but not been made.\n\t\tif ( timeoutId ) {\n\t\t\tclearTimeout( timeoutId );\n\t\t\ttimeoutId = null;\n\t\t}\n\n\t\t// Trigger any trailing edge calls to the function.\n\t\treturn new Promise( ( resolve, reject ) => {\n\t\t\t// Schedule the next request but with a delay.\n\t\t\ttimeoutId = setTimeout( () => {\n\t\t\t\tactivePromise = func( ...args )\n\t\t\t\t\t.then( ( ...thenArgs ) => {\n\t\t\t\t\t\tresolve( ...thenArgs );\n\t\t\t\t\t} )\n\t\t\t\t\t.catch( ( error ) => {\n\t\t\t\t\t\treject( error );\n\t\t\t\t\t} )\n\t\t\t\t\t.finally( () => {\n\t\t\t\t\t\t// As soon this promise is complete, clear the way for the\n\t\t\t\t\t\t// next one to happen immediately.\n\t\t\t\t\t\tactivePromise = null;\n\t\t\t\t\t\ttimeoutId = null;\n\t\t\t\t\t} );\n\t\t\t}, delayMS );\n\t\t} );\n\t};\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,aAAaA,CAAEC,IAAI,EAAEC,OAAO,EAAG;EACtD,IAAIC,SAAS;EACb,IAAIC,aAAa;EAEjB,OAAO,eAAeC,SAASA,CAAE,GAAGC,IAAI,EAAG;IAC1C;IACA;IACA,IAAK,CAAEF,aAAa,IAAI,CAAED,SAAS,EAAG;MACrC,OAAO,IAAII,OAAO,CAAE,CAAEC,OAAO,EAAEC,MAAM,KAAM;QAC1C;QACAL,aAAa,GAAGH,IAAI,CAAE,GAAGK,IAAK,CAAC,CAC7BI,IAAI,CAAE,CAAE,GAAGC,QAAQ,KAAM;UACzBH,OAAO,CAAE,GAAGG,QAAS,CAAC;QACvB,CAAE,CAAC,CACFC,KAAK,CAAIC,KAAK,IAAM;UACpBJ,MAAM,CAAEI,KAAM,CAAC;QAChB,CAAE,CAAC,CACFC,OAAO,CAAE,MAAM;UACf;UACA;UACAV,aAAa,GAAG,IAAI;QACrB,CAAE,CAAC;MACL,CAAE,CAAC;IACJ;IAEA,IAAKA,aAAa,EAAG;MACpB;MACA,MAAMA,aAAa;IACpB;;IAEA;IACA;IACA,IAAKD,SAAS,EAAG;MAChBY,YAAY,CAAEZ,SAAU,CAAC;MACzBA,SAAS,GAAG,IAAI;IACjB;;IAEA;IACA,OAAO,IAAII,OAAO,CAAE,CAAEC,OAAO,EAAEC,MAAM,KAAM;MAC1C;MACAN,SAAS,GAAGa,UAAU,CAAE,MAAM;QAC7BZ,aAAa,GAAGH,IAAI,CAAE,GAAGK,IAAK,CAAC,CAC7BI,IAAI,CAAE,CAAE,GAAGC,QAAQ,KAAM;UACzBH,OAAO,CAAE,GAAGG,QAAS,CAAC;QACvB,CAAE,CAAC,CACFC,KAAK,CAAIC,KAAK,IAAM;UACpBJ,MAAM,CAAEI,KAAM,CAAC;QAChB,CAAE,CAAC,CACFC,OAAO,CAAE,MAAM;UACf;UACA;UACAV,aAAa,GAAG,IAAI;UACpBD,SAAS,GAAG,IAAI;QACjB,CAAE,CAAC;MACL,CAAC,EAAED,OAAQ,CAAC;IACb,CAAE,CAAC;EACJ,CAAC;AACF","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["_apiFetch","_interopRequireDefault","require","_debounceAsync","EMPTY_OBJECT","localStorage","window","create","preloadedData","localStorageRestoreKey","requestDebounceMS","cache","debouncedApiFetch","debounceAsync","apiFetch","get","user","path","serverData","meta","persisted_preferences","localData","JSON","parse","getItem","serverTimestamp","Date","_modified","localTimestamp","set","newData","dataWithTimestamp","toISOString","setItem","stringify","method","keepalive","data","catch"],"sources":["@wordpress/preferences-persistence/src/create/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\n\n/**\n * Internal dependencies\n */\nimport debounceAsync from './debounce-async';\n\nconst EMPTY_OBJECT = {};\nconst localStorage = window.localStorage;\n\n/**\n * Creates a persistence layer that stores data in WordPress user meta via the\n * REST API.\n *\n * @param {Object} options\n * @param {?Object} options.preloadedData Any persisted preferences data that should be preloaded.\n * When set, the persistence layer will avoid fetching data\n * from the REST API.\n * @param {?string} options.localStorageRestoreKey The key to use for restoring the localStorage backup, used\n * when the persistence layer calls `localStorage.getItem` or\n * `localStorage.setItem`.\n * @param {?number} options.requestDebounceMS Debounce requests to the API so that they only occur at\n * minimum every `requestDebounceMS` milliseconds, and don't\n * swamp the server. Defaults to 2500ms.\n *\n * @return {Object} A persistence layer for WordPress user meta.\n */\nexport default function create( {\n\tpreloadedData,\n\tlocalStorageRestoreKey = 'WP_PREFERENCES_RESTORE_DATA',\n\trequestDebounceMS = 2500,\n} = {} ) {\n\tlet cache = preloadedData;\n\tconst debouncedApiFetch = debounceAsync( apiFetch, requestDebounceMS );\n\n\tasync function get() {\n\t\tif ( cache ) {\n\t\t\treturn cache;\n\t\t}\n\n\t\tconst user = await apiFetch( {\n\t\t\tpath: '/wp/v2/users/me?context=edit',\n\t\t} );\n\n\t\tconst serverData = user?.meta?.persisted_preferences;\n\t\tconst localData = JSON.parse(\n\t\t\tlocalStorage.getItem( localStorageRestoreKey )\n\t\t);\n\n\t\t// Date parse returns NaN for invalid input. Coerce anything invalid\n\t\t// into a conveniently comparable zero.\n\t\tconst serverTimestamp = Date.parse( serverData?._modified ) || 0;\n\t\tconst localTimestamp = Date.parse( localData?._modified ) || 0;\n\n\t\t// Prefer server data if it exists and is more recent.\n\t\t// Otherwise fallback to localStorage data.\n\t\tif ( serverData && serverTimestamp >= localTimestamp ) {\n\t\t\tcache = serverData;\n\t\t} else if ( localData ) {\n\t\t\tcache = localData;\n\t\t} else {\n\t\t\tcache = EMPTY_OBJECT;\n\t\t}\n\n\t\treturn cache;\n\t}\n\n\tfunction set( newData ) {\n\t\tconst dataWithTimestamp = {\n\t\t\t...newData,\n\t\t\t_modified: new Date().toISOString(),\n\t\t};\n\t\tcache = dataWithTimestamp;\n\n\t\t// Store data in local storage as a fallback. If for some reason the\n\t\t// api request does not complete or becomes unavailable, this data\n\t\t// can be used to restore preferences.\n\t\tlocalStorage.setItem(\n\t\t\tlocalStorageRestoreKey,\n\t\t\tJSON.stringify( dataWithTimestamp )\n\t\t);\n\n\t\t// The user meta endpoint seems susceptible to errors when consecutive\n\t\t// requests are made in quick succession. Ensure there's a gap between\n\t\t// any consecutive requests.\n\t\t//\n\t\t// Catch and do nothing with errors from the REST API.\n\t\tdebouncedApiFetch( {\n\t\t\tpath: '/wp/v2/users/me',\n\t\t\tmethod: 'PUT',\n\t\t\t// `keepalive` will still send the request in the background,\n\t\t\t// even when a browser unload event might interrupt it.\n\t\t\t// This should hopefully make things more resilient.\n\t\t\t// This does have a size limit of 64kb, but the data is usually\n\t\t\t// much less.\n\t\t\tkeepalive: true,\n\t\t\tdata: {\n\t\t\t\tmeta: {\n\t\t\t\t\tpersisted_preferences: dataWithTimestamp,\n\t\t\t\t},\n\t\t\t},\n\t\t} ).catch( () => {} );\n\t}\n\n\treturn {\n\t\tget,\n\t\tset,\n\t};\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,SAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,cAAA,GAAAF,sBAAA,CAAAC,OAAA;AARA;AACA;AACA;;AAGA;AACA;AACA;;AAGA,MAAME,YAAY,GAAG,CAAC,CAAC;AACvB,MAAMC,YAAY,GAAGC,MAAM,CAACD,YAAY;;AAExC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASE,MAAMA,CAAE;EAC/BC,aAAa;EACbC,sBAAsB,GAAG,6BAA6B;EACtDC,iBAAiB,GAAG;AACrB,CAAC,GAAG,CAAC,CAAC,EAAG;EACR,IAAIC,KAAK,GAAGH,aAAa;EACzB,MAAMI,iBAAiB,GAAG,IAAAC,sBAAa,EAAEC,iBAAQ,EAAEJ,iBAAkB,CAAC;EAEtE,eAAeK,GAAGA,CAAA,EAAG;IACpB,IAAKJ,KAAK,EAAG;MACZ,OAAOA,KAAK;IACb;IAEA,MAAMK,IAAI,GAAG,MAAM,IAAAF,iBAAQ,EAAE;MAC5BG,IAAI,EAAE;IACP,CAAE,CAAC;IAEH,MAAMC,UAAU,GAAGF,IAAI,EAAEG,IAAI,EAAEC,qBAAqB;IACpD,MAAMC,SAAS,GAAGC,IAAI,CAACC,KAAK,CAC3BlB,YAAY,CAACmB,OAAO,CAAEf,sBAAuB,CAC9C,CAAC;;IAED;IACA;IACA,MAAMgB,eAAe,GAAGC,IAAI,CAACH,KAAK,CAAEL,UAAU,EAAES,SAAU,CAAC,IAAI,CAAC;IAChE,MAAMC,cAAc,GAAGF,IAAI,CAACH,KAAK,CAAEF,SAAS,EAAEM,SAAU,CAAC,IAAI,CAAC;;IAE9D;IACA;IACA,IAAKT,UAAU,IAAIO,eAAe,IAAIG,cAAc,EAAG;MACtDjB,KAAK,GAAGO,UAAU;IACnB,CAAC,MAAM,IAAKG,SAAS,EAAG;MACvBV,KAAK,GAAGU,SAAS;IAClB,CAAC,MAAM;MACNV,KAAK,GAAGP,YAAY;IACrB;IAEA,OAAOO,KAAK;EACb;EAEA,SAASkB,GAAGA,CAAEC,OAAO,EAAG;IACvB,MAAMC,iBAAiB,GAAG;MACzB,GAAGD,OAAO;MACVH,SAAS,EAAE,IAAID,IAAI,CAAC,CAAC,CAACM,WAAW,CAAC;IACnC,CAAC;IACDrB,KAAK,GAAGoB,iBAAiB;;IAEzB;IACA;IACA;IACA1B,YAAY,CAAC4B,OAAO,CACnBxB,sBAAsB,EACtBa,IAAI,CAACY,SAAS,CAAEH,iBAAkB,CACnC,CAAC;;IAED;IACA;IACA;IACA;IACA;IACAnB,iBAAiB,CAAE;MAClBK,IAAI,EAAE,iBAAiB;MACvBkB,MAAM,EAAE,KAAK;MACb;MACA;MACA;MACA;MACA;MACAC,SAAS,EAAE,IAAI;MACfC,IAAI,EAAE;QACLlB,IAAI,EAAE;UACLC,qBAAqB,EAAEW;QACxB;MACD;IACD,CAAE,CAAC,CAACO,KAAK,CAAE,MAAM,CAAC,CAAE,CAAC;EACtB;EAEA,OAAO;IACNvB,GAAG;IACHc;EACD,CAAC;AACF"}
1
+ {"version":3,"names":["_apiFetch","_interopRequireDefault","require","_debounceAsync","EMPTY_OBJECT","localStorage","window","create","preloadedData","localStorageRestoreKey","requestDebounceMS","cache","debouncedApiFetch","debounceAsync","apiFetch","get","user","path","serverData","meta","persisted_preferences","localData","JSON","parse","getItem","serverTimestamp","Date","_modified","localTimestamp","set","newData","dataWithTimestamp","toISOString","setItem","stringify","method","keepalive","data","catch"],"sources":["@wordpress/preferences-persistence/src/create/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\n\n/**\n * Internal dependencies\n */\nimport debounceAsync from './debounce-async';\n\nconst EMPTY_OBJECT = {};\nconst localStorage = window.localStorage;\n\n/**\n * Creates a persistence layer that stores data in WordPress user meta via the\n * REST API.\n *\n * @param {Object} options\n * @param {?Object} options.preloadedData Any persisted preferences data that should be preloaded.\n * When set, the persistence layer will avoid fetching data\n * from the REST API.\n * @param {?string} options.localStorageRestoreKey The key to use for restoring the localStorage backup, used\n * when the persistence layer calls `localStorage.getItem` or\n * `localStorage.setItem`.\n * @param {?number} options.requestDebounceMS Debounce requests to the API so that they only occur at\n * minimum every `requestDebounceMS` milliseconds, and don't\n * swamp the server. Defaults to 2500ms.\n *\n * @return {Object} A persistence layer for WordPress user meta.\n */\nexport default function create( {\n\tpreloadedData,\n\tlocalStorageRestoreKey = 'WP_PREFERENCES_RESTORE_DATA',\n\trequestDebounceMS = 2500,\n} = {} ) {\n\tlet cache = preloadedData;\n\tconst debouncedApiFetch = debounceAsync( apiFetch, requestDebounceMS );\n\n\tasync function get() {\n\t\tif ( cache ) {\n\t\t\treturn cache;\n\t\t}\n\n\t\tconst user = await apiFetch( {\n\t\t\tpath: '/wp/v2/users/me?context=edit',\n\t\t} );\n\n\t\tconst serverData = user?.meta?.persisted_preferences;\n\t\tconst localData = JSON.parse(\n\t\t\tlocalStorage.getItem( localStorageRestoreKey )\n\t\t);\n\n\t\t// Date parse returns NaN for invalid input. Coerce anything invalid\n\t\t// into a conveniently comparable zero.\n\t\tconst serverTimestamp = Date.parse( serverData?._modified ) || 0;\n\t\tconst localTimestamp = Date.parse( localData?._modified ) || 0;\n\n\t\t// Prefer server data if it exists and is more recent.\n\t\t// Otherwise fallback to localStorage data.\n\t\tif ( serverData && serverTimestamp >= localTimestamp ) {\n\t\t\tcache = serverData;\n\t\t} else if ( localData ) {\n\t\t\tcache = localData;\n\t\t} else {\n\t\t\tcache = EMPTY_OBJECT;\n\t\t}\n\n\t\treturn cache;\n\t}\n\n\tfunction set( newData ) {\n\t\tconst dataWithTimestamp = {\n\t\t\t...newData,\n\t\t\t_modified: new Date().toISOString(),\n\t\t};\n\t\tcache = dataWithTimestamp;\n\n\t\t// Store data in local storage as a fallback. If for some reason the\n\t\t// api request does not complete or becomes unavailable, this data\n\t\t// can be used to restore preferences.\n\t\tlocalStorage.setItem(\n\t\t\tlocalStorageRestoreKey,\n\t\t\tJSON.stringify( dataWithTimestamp )\n\t\t);\n\n\t\t// The user meta endpoint seems susceptible to errors when consecutive\n\t\t// requests are made in quick succession. Ensure there's a gap between\n\t\t// any consecutive requests.\n\t\t//\n\t\t// Catch and do nothing with errors from the REST API.\n\t\tdebouncedApiFetch( {\n\t\t\tpath: '/wp/v2/users/me',\n\t\t\tmethod: 'PUT',\n\t\t\t// `keepalive` will still send the request in the background,\n\t\t\t// even when a browser unload event might interrupt it.\n\t\t\t// This should hopefully make things more resilient.\n\t\t\t// This does have a size limit of 64kb, but the data is usually\n\t\t\t// much less.\n\t\t\tkeepalive: true,\n\t\t\tdata: {\n\t\t\t\tmeta: {\n\t\t\t\t\tpersisted_preferences: dataWithTimestamp,\n\t\t\t\t},\n\t\t\t},\n\t\t} ).catch( () => {} );\n\t}\n\n\treturn {\n\t\tget,\n\t\tset,\n\t};\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,SAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,cAAA,GAAAF,sBAAA,CAAAC,OAAA;AARA;AACA;AACA;;AAGA;AACA;AACA;;AAGA,MAAME,YAAY,GAAG,CAAC,CAAC;AACvB,MAAMC,YAAY,GAAGC,MAAM,CAACD,YAAY;;AAExC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASE,MAAMA,CAAE;EAC/BC,aAAa;EACbC,sBAAs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,CACnC,CAAC;;IAED;IACA;IACA;IACA;IACA;IACAnB,iBAAiB,CAAE;MAClBK,IAAI,EAAE,iBAAiB;MACvBkB,MAAM,EAAE,KAAK;MACb;MACA;MACA;MACA;MACA;MACAC,SAAS,EAAE,IAAI;MACfC,IAAI,EAAE;QACLlB,IAAI,EAAE;UACLC,qBAAqB,EAAEW;QACxB;MACD;IACD,CAAE,CAAC,CAACO,KAAK,CAAE,MAAM,CAAC,CAAE,CAAC;EACtB;EAEA,OAAO;IACNvB,GAAG;IACHc;EACD,CAAC;AACF","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["_create","_interopRequireDefault","require","_legacyLocalStorageData","_preferencesPackageData","__unstableCreatePersistenceLayer","serverData","userId","localStorageRestoreKey","localData","JSON","parse","window","localStorage","getItem","serverModified","Date","_modified","localModified","preloadedData","convertPreferencesPackageData","convertLegacyLocalStorageData","create"],"sources":["@wordpress/preferences-persistence/src/index.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport create from './create';\nimport convertLegacyLocalStorageData from './migrations/legacy-local-storage-data';\nimport convertPreferencesPackageData from './migrations/preferences-package-data';\n\nexport { create };\n\n/**\n * Creates the persistence layer with preloaded data.\n *\n * It prioritizes any data from the server, but falls back first to localStorage\n * restore data, and then to any legacy data.\n *\n * This function is used internally by WordPress in an inline script, so\n * prefixed with `__unstable`.\n *\n * @param {Object} serverData Preferences data preloaded from the server.\n * @param {string} userId The user id.\n *\n * @return {Object} The persistence layer initialized with the preloaded data.\n */\nexport function __unstableCreatePersistenceLayer( serverData, userId ) {\n\tconst localStorageRestoreKey = `WP_PREFERENCES_USER_${ userId }`;\n\tconst localData = JSON.parse(\n\t\twindow.localStorage.getItem( localStorageRestoreKey )\n\t);\n\n\t// Date parse returns NaN for invalid input. Coerce anything invalid\n\t// into a conveniently comparable zero.\n\tconst serverModified =\n\t\tDate.parse( serverData && serverData._modified ) || 0;\n\tconst localModified = Date.parse( localData && localData._modified ) || 0;\n\n\tlet preloadedData;\n\tif ( serverData && serverModified >= localModified ) {\n\t\tpreloadedData = convertPreferencesPackageData( serverData );\n\t} else if ( localData ) {\n\t\tpreloadedData = convertPreferencesPackageData( localData );\n\t} else {\n\t\t// Check if there is data in the legacy format from the old persistence system.\n\t\tpreloadedData = convertLegacyLocalStorageData( userId );\n\t}\n\n\treturn create( {\n\t\tpreloadedData,\n\t\tlocalStorageRestoreKey,\n\t} );\n}\n"],"mappings":";;;;;;;;;;;;;AAGA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,uBAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,uBAAA,GAAAH,sBAAA,CAAAC,OAAA;AALA;AACA;AACA;;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASG,gCAAgCA,CAAEC,UAAU,EAAEC,MAAM,EAAG;EACtE,MAAMC,sBAAsB,GAAI,uBAAuBD,MAAQ,EAAC;EAChE,MAAME,SAAS,GAAGC,IAAI,CAACC,KAAK,CAC3BC,MAAM,CAACC,YAAY,CAACC,OAAO,CAAEN,sBAAuB,CACrD,CAAC;;EAED;EACA;EACA,MAAMO,cAAc,GACnBC,IAAI,CAACL,KAAK,CAAEL,UAAU,IAAIA,UAAU,CAACW,SAAU,CAAC,IAAI,CAAC;EACtD,MAAMC,aAAa,GAAGF,IAAI,CAACL,KAAK,CAAEF,SAAS,IAAIA,SAAS,CAACQ,SAAU,CAAC,IAAI,CAAC;EAEzE,IAAIE,aAAa;EACjB,IAAKb,UAAU,IAAIS,cAAc,IAAIG,aAAa,EAAG;IACpDC,aAAa,GAAG,IAAAC,+BAA6B,EAAEd,UAAW,CAAC;EAC5D,CAAC,MAAM,IAAKG,SAAS,EAAG;IACvBU,aAAa,GAAG,IAAAC,+BAA6B,EAAEX,SAAU,CAAC;EAC3D,CAAC,MAAM;IACN;IACAU,aAAa,GAAG,IAAAE,+BAA6B,EAAEd,MAAO,CAAC;EACxD;EAEA,OAAO,IAAAe,eAAM,EAAE;IACdH,aAAa;IACbX;EACD,CAAE,CAAC;AACJ"}
1
+ {"version":3,"names":["_create","_interopRequireDefault","require","_legacyLocalStorageData","_preferencesPackageData","__unstableCreatePersistenceLayer","serverData","userId","localStorageRestoreKey","localData","JSON","parse","window","localStorage","getItem","serverModified","Date","_modified","localModified","preloadedData","convertPreferencesPackageData","convertLegacyLocalStorageData","create"],"sources":["@wordpress/preferences-persistence/src/index.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport create from './create';\nimport convertLegacyLocalStorageData from './migrations/legacy-local-storage-data';\nimport convertPreferencesPackageData from './migrations/preferences-package-data';\n\nexport { create };\n\n/**\n * Creates the persistence layer with preloaded data.\n *\n * It prioritizes any data from the server, but falls back first to localStorage\n * restore data, and then to any legacy data.\n *\n * This function is used internally by WordPress in an inline script, so\n * prefixed with `__unstable`.\n *\n * @param {Object} serverData Preferences data preloaded from the server.\n * @param {string} userId The user id.\n *\n * @return {Object} The persistence layer initialized with the preloaded data.\n */\nexport function __unstableCreatePersistenceLayer( serverData, userId ) {\n\tconst localStorageRestoreKey = `WP_PREFERENCES_USER_${ userId }`;\n\tconst localData = JSON.parse(\n\t\twindow.localStorage.getItem( localStorageRestoreKey )\n\t);\n\n\t// Date parse returns NaN for invalid input. Coerce anything invalid\n\t// into a conveniently comparable zero.\n\tconst serverModified =\n\t\tDate.parse( serverData && serverData._modified ) || 0;\n\tconst localModified = Date.parse( localData && localData._modified ) || 0;\n\n\tlet preloadedData;\n\tif ( serverData && serverModified >= localModified ) {\n\t\tpreloadedData = convertPreferencesPackageData( serverData );\n\t} else if ( localData ) {\n\t\tpreloadedData = convertPreferencesPackageData( localData );\n\t} else {\n\t\t// Check if there is data in the legacy format from the old persistence system.\n\t\tpreloadedData = convertLegacyLocalStorageData( userId );\n\t}\n\n\treturn create( {\n\t\tpreloadedData,\n\t\tlocalStorageRestoreKey,\n\t} );\n}\n"],"mappings":";;;;;;;;;;;;;AAGA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,uBAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,uBAAA,GAAAH,sBAAA,CAAAC,OAAA;AALA;AACA;AACA;;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASG,gCAAgCA,CAAEC,UAAU,EAAEC,MAAM,EAAG;EACtE,MAAMC,sBAAsB,GAAI,uBAAuBD,MAAQ,EAAC;EAChE,MAAME,SAAS,GAAGC,IAAI,CAACC,KAAK,CAC3BC,MAAM,CAACC,YAAY,CAACC,OAAO,CAAEN,sBAAuB,CACrD,CAAC;;EAED;EACA;EACA,MAAMO,cAAc,GACnBC,IAAI,CAACL,KAAK,CAAEL,UAAU,IAAIA,UAAU,CAACW,SAAU,CAAC,IAAI,CAAC;EACtD,MAAMC,aAAa,GAAGF,IAAI,CAACL,KAAK,CAAEF,SAAS,IAAIA,SAAS,CAACQ,SAAU,CAAC,IAAI,CAAC;EAEzE,IAAIE,aAAa;EACjB,IAAKb,UAAU,IAAIS,cAAc,IAAIG,aAAa,EAAG;IACpDC,aAAa,GAAG,IAAAC,+BAA6B,EAAEd,UAAW,CAAC;EAC5D,CAAC,MAAM,IAAKG,SAAS,EAAG;IACvBU,aAAa,GAAG,IAAAC,+BAA6B,EAAEX,SAAU,CAAC;EAC3D,CAAC,MAAM;IACN;IACAU,aAAa,GAAG,IAAAE,+BAA6B,EAAEd,MAAO,CAAC;EACxD;EAEA,OAAO,IAAAe,eAAM,EAAE;IACdH,aAAa;IACbX;EACD,CAAE,CAAC;AACJ","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["convertEditPostPanels","preferences","_preferences$panels","panels","Object","keys","reduce","convertedData","panelName","panel","enabled","inactivePanels","push","opened","openPanels"],"sources":["@wordpress/preferences-persistence/src/migrations/legacy-local-storage-data/convert-edit-post-panels.js"],"sourcesContent":["/**\n * Convert the post editor's panels state from:\n * ```\n * {\n * panels: {\n * tags: {\n * enabled: true,\n * opened: true,\n * },\n * permalinks: {\n * enabled: false,\n * opened: false,\n * },\n * },\n * }\n * ```\n *\n * to a new, more concise data structure:\n * {\n * inactivePanels: [\n * 'permalinks',\n * ],\n * openPanels: [\n * 'tags',\n * ],\n * }\n *\n * @param {Object} preferences A preferences object.\n *\n * @return {Object} The converted data.\n */\nexport default function convertEditPostPanels( preferences ) {\n\tconst panels = preferences?.panels ?? {};\n\treturn Object.keys( panels ).reduce(\n\t\t( convertedData, panelName ) => {\n\t\t\tconst panel = panels[ panelName ];\n\n\t\t\tif ( panel?.enabled === false ) {\n\t\t\t\tconvertedData.inactivePanels.push( panelName );\n\t\t\t}\n\n\t\t\tif ( panel?.opened === true ) {\n\t\t\t\tconvertedData.openPanels.push( panelName );\n\t\t\t}\n\n\t\t\treturn convertedData;\n\t\t},\n\t\t{ inactivePanels: [], openPanels: [] }\n\t);\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,qBAAqBA,CAAEC,WAAW,EAAG;EAAA,IAAAC,mBAAA;EAC5D,MAAMC,MAAM,IAAAD,mBAAA,GAAGD,WAAW,EAAEE,MAAM,cAAAD,mBAAA,cAAAA,mBAAA,GAAI,CAAC,CAAC;EACxC,OAAOE,MAAM,CAACC,IAAI,CAAEF,MAAO,CAAC,CAACG,MAAM,CAClC,CAAEC,aAAa,EAAEC,SAAS,KAAM;IAC/B,MAAMC,KAAK,GAAGN,MAAM,CAAEK,SAAS,CAAE;IAEjC,IAAKC,KAAK,EAAEC,OAAO,KAAK,KAAK,EAAG;MAC/BH,aAAa,CAACI,cAAc,CAACC,IAAI,CAAEJ,SAAU,CAAC;IAC/C;IAEA,IAAKC,KAAK,EAAEI,MAAM,KAAK,IAAI,EAAG;MAC7BN,aAAa,CAACO,UAAU,CAACF,IAAI,CAAEJ,SAAU,CAAC;IAC3C;IAEA,OAAOD,aAAa;EACrB,CAAC,EACD;IAAEI,cAAc,EAAE,EAAE;IAAEG,UAAU,EAAE;EAAG,CACtC,CAAC;AACF"}
1
+ {"version":3,"names":["convertEditPostPanels","preferences","_preferences$panels","panels","Object","keys","reduce","convertedData","panelName","panel","enabled","inactivePanels","push","opened","openPanels"],"sources":["@wordpress/preferences-persistence/src/migrations/legacy-local-storage-data/convert-edit-post-panels.js"],"sourcesContent":["/**\n * Convert the post editor's panels state from:\n * ```\n * {\n * panels: {\n * tags: {\n * enabled: true,\n * opened: true,\n * },\n * permalinks: {\n * enabled: false,\n * opened: false,\n * },\n * },\n * }\n * ```\n *\n * to a new, more concise data structure:\n * {\n * inactivePanels: [\n * 'permalinks',\n * ],\n * openPanels: [\n * 'tags',\n * ],\n * }\n *\n * @param {Object} preferences A preferences object.\n *\n * @return {Object} The converted data.\n */\nexport default function convertEditPostPanels( preferences ) {\n\tconst panels = preferences?.panels ?? {};\n\treturn Object.keys( panels ).reduce(\n\t\t( convertedData, panelName ) => {\n\t\t\tconst panel = panels[ panelName ];\n\n\t\t\tif ( panel?.enabled === false ) {\n\t\t\t\tconvertedData.inactivePanels.push( panelName );\n\t\t\t}\n\n\t\t\tif ( panel?.opened === true ) {\n\t\t\t\tconvertedData.openPanels.push( panelName );\n\t\t\t}\n\n\t\t\treturn convertedData;\n\t\t},\n\t\t{ inactivePanels: [], openPanels: [] }\n\t);\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,qBAAqBA,CAAEC,WAAW,EAAG;EAAA,IAAAC,mBAAA;EAC5D,MAAMC,MAAM,IAAAD,mBAAA,GAAGD,WAAW,EAAEE,MAAM,cAAAD,mBAAA,cAAAA,mBAAA,GAAI,CAAC,CAAC;EACxC,OAAOE,MAAM,CAACC,IAAI,CAAEF,MAAO,CAAC,CAACG,MAAM,CAClC,CAAEC,aAAa,EAAEC,SAAS,KAAM;IAC/B,MAAMC,KAAK,GAAGN,MAAM,CAAEK,SAAS,CAAE;IAEjC,IAAKC,KAAK,EAAEC,OAAO,KAAK,KAAK,EAAG;MAC/BH,aAAa,CAACI,cAAc,CAACC,IAAI,CAAEJ,SAAU,CAAC;IAC/C;IAEA,IAAKC,KAAK,EAAEI,MAAM,KAAK,IAAI,EAAG;MAC7BN,aAAa,CAACO,UAAU,CAACF,IAAI,CAAEJ,SAAU,CAAC;IAC3C;IAEA,OAAOD,aAAa;EACrB,CAAC,EACD;IAAEI,cAAc,EAAE,EAAE;IAAEG,UAAU,EAAE;EAAG,CACtC,CAAC;AACF","ignoreList":[]}
@@ -72,7 +72,11 @@ function convertLegacyData(data) {
72
72
  }, 'panels', _convertEditPostPanels.default);
73
73
  data = (0, _moveIndividualPreference.default)(data, {
74
74
  from: 'core/editor',
75
- to: 'core/edit-post'
75
+ to: 'core'
76
+ }, 'isPublishSidebarEnabled');
77
+ data = (0, _moveIndividualPreference.default)(data, {
78
+ from: 'core/edit-post',
79
+ to: 'core'
76
80
  }, 'isPublishSidebarEnabled');
77
81
  data = (0, _moveIndividualPreference.default)(data, {
78
82
  from: 'core/edit-site',
@@ -1 +1 @@
1
- {"version":3,"names":["_moveFeaturePreferences","_interopRequireDefault","require","_moveThirdPartyFeaturePreferences","_moveIndividualPreference","_moveInterfaceEnableItems","_convertEditPostPanels","getLegacyData","userId","key","unparsedData","window","localStorage","getItem","JSON","parse","convertLegacyData","data","moveFeaturePreferences","moveThirdPartyFeaturePreferences","moveInterfaceEnableItems","moveIndividualPreference","from","to","convertEditPostPanels","preferences","convertLegacyLocalStorageData"],"sources":["@wordpress/preferences-persistence/src/migrations/legacy-local-storage-data/index.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport moveFeaturePreferences from './move-feature-preferences';\nimport moveThirdPartyFeaturePreferences from './move-third-party-feature-preferences';\nimport moveIndividualPreference from './move-individual-preference';\nimport moveInterfaceEnableItems from './move-interface-enable-items';\nimport convertEditPostPanels from './convert-edit-post-panels';\n\n/**\n * Gets the legacy local storage data for a given user.\n *\n * @param {string | number} userId The user id.\n *\n * @return {Object | null} The local storage data.\n */\nfunction getLegacyData( userId ) {\n\tconst key = `WP_DATA_USER_${ userId }`;\n\tconst unparsedData = window.localStorage.getItem( key );\n\treturn JSON.parse( unparsedData );\n}\n\n/**\n * Converts data from the old `@wordpress/data` package format.\n *\n * @param {Object | null | undefined} data The legacy data in its original format.\n *\n * @return {Object | undefined} The converted data or `undefined` if there was\n * nothing to convert.\n */\nexport function convertLegacyData( data ) {\n\tif ( ! data ) {\n\t\treturn;\n\t}\n\n\t// Move boolean feature preferences from each editor into the\n\t// preferences store data structure.\n\tdata = moveFeaturePreferences( data, 'core/edit-widgets' );\n\tdata = moveFeaturePreferences( data, 'core/customize-widgets' );\n\tdata = moveFeaturePreferences( data, 'core/edit-post' );\n\tdata = moveFeaturePreferences( data, 'core/edit-site' );\n\n\t// Move third party boolean feature preferences from the interface package\n\t// to the preferences store data structure.\n\tdata = moveThirdPartyFeaturePreferences( data );\n\n\t// Move and convert the interface store's `enableItems` data into the\n\t// preferences data structure.\n\tdata = moveInterfaceEnableItems( data );\n\n\t// Move individual ad-hoc preferences from various packages into the\n\t// preferences store data structure.\n\tdata = moveIndividualPreference(\n\t\tdata,\n\t\t{ from: 'core/edit-post', to: 'core/edit-post' },\n\t\t'hiddenBlockTypes'\n\t);\n\tdata = moveIndividualPreference(\n\t\tdata,\n\t\t{ from: 'core/edit-post', to: 'core/edit-post' },\n\t\t'editorMode'\n\t);\n\tdata = moveIndividualPreference(\n\t\tdata,\n\t\t{ from: 'core/edit-post', to: 'core/edit-post' },\n\t\t'panels',\n\t\tconvertEditPostPanels\n\t);\n\tdata = moveIndividualPreference(\n\t\tdata,\n\t\t{ from: 'core/editor', to: 'core/edit-post' },\n\t\t'isPublishSidebarEnabled'\n\t);\n\tdata = moveIndividualPreference(\n\t\tdata,\n\t\t{ from: 'core/edit-site', to: 'core/edit-site' },\n\t\t'editorMode'\n\t);\n\n\t// The new system is only concerned with persisting\n\t// 'core/preferences' preferences reducer, so only return that.\n\treturn data?.[ 'core/preferences' ]?.preferences;\n}\n\n/**\n * Gets the legacy local storage data for the given user and returns the\n * data converted to the new format.\n *\n * @param {string | number} userId The user id.\n *\n * @return {Object | undefined} The converted data or undefined if no local\n * storage data could be found.\n */\nexport default function convertLegacyLocalStorageData( userId ) {\n\tconst data = getLegacyData( userId );\n\treturn convertLegacyData( data );\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,uBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,iCAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,yBAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,yBAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,sBAAA,GAAAL,sBAAA,CAAAC,OAAA;AAPA;AACA;AACA;;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASK,aAAaA,CAAEC,MAAM,EAAG;EAChC,MAAMC,GAAG,GAAI,gBAAgBD,MAAQ,EAAC;EACtC,MAAME,YAAY,GAAGC,MAAM,CAACC,YAAY,CAACC,OAAO,CAAEJ,GAAI,CAAC;EACvD,OAAOK,IAAI,CAACC,KAAK,CAAEL,YAAa,CAAC;AAClC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASM,iBAAiBA,CAAEC,IAAI,EAAG;EACzC,IAAK,CAAEA,IAAI,EAAG;IACb;EACD;;EAEA;EACA;EACAA,IAAI,GAAG,IAAAC,+BAAsB,EAAED,IAAI,EAAE,mBAAoB,CAAC;EAC1DA,IAAI,GAAG,IAAAC,+BAA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IAAK,CAAC;AACjC"}
1
+ {"version":3,"names":["_moveFeaturePreferences","_interopRequireDefault","require","_moveThirdPartyFeaturePreferences","_moveIndividualPreference","_moveInterfaceEnableItems","_convertEditPostPanels","getLegacyData","userId","key","unparsedData","window","localStorage","getItem","JSON","parse","convertLegacyData","data","moveFeaturePreferences","moveThirdPartyFeaturePreferences","moveInterfaceEnableItems","moveIndividualPreference","from","to","convertEditPostPanels","preferences","convertLegacyLocalStorageData"],"sources":["@wordpress/preferences-persistence/src/migrations/legacy-local-storage-data/index.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport moveFeaturePreferences from './move-feature-preferences';\nimport moveThirdPartyFeaturePreferences from './move-third-party-feature-preferences';\nimport moveIndividualPreference from './move-individual-preference';\nimport moveInterfaceEnableItems from './move-interface-enable-items';\nimport convertEditPostPanels from './convert-edit-post-panels';\n\n/**\n * Gets the legacy local storage data for a given user.\n *\n * @param {string | number} userId The user id.\n *\n * @return {Object | null} The local storage data.\n */\nfunction getLegacyData( userId ) {\n\tconst key = `WP_DATA_USER_${ userId }`;\n\tconst unparsedData = window.localStorage.getItem( key );\n\treturn JSON.parse( unparsedData );\n}\n\n/**\n * Converts data from the old `@wordpress/data` package format.\n *\n * @param {Object | null | undefined} data The legacy data in its original format.\n *\n * @return {Object | undefined} The converted data or `undefined` if there was\n * nothing to convert.\n */\nexport function convertLegacyData( data ) {\n\tif ( ! data ) {\n\t\treturn;\n\t}\n\n\t// Move boolean feature preferences from each editor into the\n\t// preferences store data structure.\n\tdata = moveFeaturePreferences( data, 'core/edit-widgets' );\n\tdata = moveFeaturePreferences( data, 'core/customize-widgets' );\n\tdata = moveFeaturePreferences( data, 'core/edit-post' );\n\tdata = moveFeaturePreferences( data, 'core/edit-site' );\n\n\t// Move third party boolean feature preferences from the interface package\n\t// to the preferences store data structure.\n\tdata = moveThirdPartyFeaturePreferences( data );\n\n\t// Move and convert the interface store's `enableItems` data into the\n\t// preferences data structure.\n\tdata = moveInterfaceEnableItems( data );\n\n\t// Move individual ad-hoc preferences from various packages into the\n\t// preferences store data structure.\n\tdata = moveIndividualPreference(\n\t\tdata,\n\t\t{ from: 'core/edit-post', to: 'core/edit-post' },\n\t\t'hiddenBlockTypes'\n\t);\n\tdata = moveIndividualPreference(\n\t\tdata,\n\t\t{ from: 'core/edit-post', to: 'core/edit-post' },\n\t\t'editorMode'\n\t);\n\tdata = moveIndividualPreference(\n\t\tdata,\n\t\t{ from: 'core/edit-post', to: 'core/edit-post' },\n\t\t'panels',\n\t\tconvertEditPostPanels\n\t);\n\tdata = moveIndividualPreference(\n\t\tdata,\n\t\t{ from: 'core/editor', to: 'core' },\n\t\t'isPublishSidebarEnabled'\n\t);\n\tdata = moveIndividualPreference(\n\t\tdata,\n\t\t{ from: 'core/edit-post', to: 'core' },\n\t\t'isPublishSidebarEnabled'\n\t);\n\tdata = moveIndividualPreference(\n\t\tdata,\n\t\t{ from: 'core/edit-site', to: 'core/edit-site' },\n\t\t'editorMode'\n\t);\n\n\t// The new system is only concerned with persisting\n\t// 'core/preferences' preferences reducer, so only return that.\n\treturn data?.[ 'core/preferences' ]?.preferences;\n}\n\n/**\n * Gets the legacy local storage data for the given user and returns the\n * data converted to the new format.\n *\n * @param {string | number} userId The user id.\n *\n * @return {Object | undefined} The converted data or undefined if no local\n * storage data could be found.\n */\nexport default function convertLegacyLocalStorageData( userId ) {\n\tconst data = getLegacyData( userId );\n\treturn convertLegacyData( data );\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,uBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,iCAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,yBAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,yBAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,sBAAA,GAAAL,sBAAA,CAAAC,OAAA;AAPA;AACA;AACA;;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASK,aAAaA,CAAEC,MAA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IAAEC,EAAE,EAAE;EAAO,CAAC,EACnC,yBACD,CAAC;EACDN,IAAI,GAAG,IAAAI,iCAAwB,EAC9BJ,IAAI,EACJ;IAAEK,IAAI,EAAE,gBAAgB;IAAEC,EAAE,EAAE;EAAO,CAAC,EACtC,yBACD,CAAC;EACDN,IAAI,GAAG,IAAAI,iCAAwB,EAC9BJ,IAAI,EACJ;IAAEK,IAAI,EAAE,gBAAgB;IAAEC,EAAE,EAAE;EAAiB,CAAC,EAChD,YACD,CAAC;;EAED;EACA;EACA,OAAON,IAAI,GAAI,kBAAkB,CAAE,EAAEQ,WAAW;AACjD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASC,6BAA6BA,CAAElB,MAAM,EAAG;EAC/D,MAAMS,IAAI,GAAGV,aAAa,CAAEC,MAAO,CAAC;EACpC,OAAOQ,iBAAiB,CAAEC,IAAK,CAAC;AACjC","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["moveFeaturePreferences","state","sourceStoreName","preferencesStoreName","interfaceStoreName","interfaceFeatures","preferences","features","sourceFeatures","featuresToMigrate","existingPreferences","updatedInterfaceState","otherInterfaceState","otherInterfaceScopes","undefined","updatedSourceState","otherSourceState","sourcePreferences"],"sources":["@wordpress/preferences-persistence/src/migrations/legacy-local-storage-data/move-feature-preferences.js"],"sourcesContent":["/**\n * Move the 'features' object in local storage from the sourceStoreName to the\n * preferences store data structure.\n *\n * Previously, editors used a data structure like this for feature preferences:\n * ```js\n * {\n * 'core/edit-post': {\n * preferences: {\n * features; {\n * topToolbar: true,\n * // ... other boolean 'feature' preferences\n * },\n * },\n * },\n * }\n * ```\n *\n * And for a while these feature preferences lived in the interface package:\n * ```js\n * {\n * 'core/interface': {\n * preferences: {\n * features: {\n * 'core/edit-post': {\n * topToolbar: true\n * }\n * }\n * }\n * }\n * }\n * ```\n *\n * In the preferences store, 'features' aren't considered special, they're\n * merged to the root level of the scope along with other preferences:\n * ```js\n * {\n * 'core/preferences': {\n * preferences: {\n * 'core/edit-post': {\n * topToolbar: true,\n * // ... any other preferences.\n * }\n * }\n * }\n * }\n * ```\n *\n * This function handles moving from either the source store or the interface\n * store to the preferences data structure.\n *\n * @param {Object} state The state before migration.\n * @param {string} sourceStoreName The name of the store that has persisted\n * preferences to migrate to the preferences\n * package.\n * @return {Object} The migrated state\n */\nexport default function moveFeaturePreferences( state, sourceStoreName ) {\n\tconst preferencesStoreName = 'core/preferences';\n\tconst interfaceStoreName = 'core/interface';\n\n\t// Features most recently (and briefly) lived in the interface package.\n\t// If data exists there, prioritize using that for the migration. If not\n\t// also check the original package as the user may have updated from an\n\t// older block editor version.\n\tconst interfaceFeatures =\n\t\tstate?.[ interfaceStoreName ]?.preferences?.features?.[\n\t\t\tsourceStoreName\n\t\t];\n\tconst sourceFeatures = state?.[ sourceStoreName ]?.preferences?.features;\n\tconst featuresToMigrate = interfaceFeatures\n\t\t? interfaceFeatures\n\t\t: sourceFeatures;\n\n\tif ( ! featuresToMigrate ) {\n\t\treturn state;\n\t}\n\n\tconst existingPreferences = state?.[ preferencesStoreName ]?.preferences;\n\n\t// Avoid migrating features again if they've previously been migrated.\n\tif ( existingPreferences?.[ sourceStoreName ] ) {\n\t\treturn state;\n\t}\n\n\tlet updatedInterfaceState;\n\tif ( interfaceFeatures ) {\n\t\tconst otherInterfaceState = state?.[ interfaceStoreName ];\n\t\tconst otherInterfaceScopes =\n\t\t\tstate?.[ interfaceStoreName ]?.preferences?.features;\n\n\t\tupdatedInterfaceState = {\n\t\t\t[ interfaceStoreName ]: {\n\t\t\t\t...otherInterfaceState,\n\t\t\t\tpreferences: {\n\t\t\t\t\tfeatures: {\n\t\t\t\t\t\t...otherInterfaceScopes,\n\t\t\t\t\t\t[ sourceStoreName ]: undefined,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\t}\n\n\tlet updatedSourceState;\n\tif ( sourceFeatures ) {\n\t\tconst otherSourceState = state?.[ sourceStoreName ];\n\t\tconst sourcePreferences = state?.[ sourceStoreName ]?.preferences;\n\n\t\tupdatedSourceState = {\n\t\t\t[ sourceStoreName ]: {\n\t\t\t\t...otherSourceState,\n\t\t\t\tpreferences: {\n\t\t\t\t\t...sourcePreferences,\n\t\t\t\t\tfeatures: undefined,\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\t}\n\n\t// Set the feature values in the interface store, the features\n\t// object is keyed by 'scope', which matches the store name for\n\t// the source.\n\treturn {\n\t\t...state,\n\t\t[ preferencesStoreName ]: {\n\t\t\tpreferences: {\n\t\t\t\t...existingPreferences,\n\t\t\t\t[ sourceStoreName ]: featuresToMigrate,\n\t\t\t},\n\t\t},\n\t\t...updatedInterfaceState,\n\t\t...updatedSourceState,\n\t};\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,sBAAsBA,CAAEC,KAAK,EAAEC,eAAe,EAAG;EACxE,MAAMC,oBAAoB,GAAG,kBAAkB;EAC/C,MAAMC,kBAAkB,GAAG,gBAAgB;;EAE3C;EACA;EACA;EACA;EACA,MAAMC,iBAAiB,GACtBJ,KAAK,GAAIG,kBAAkB,CAAE,EAAEE,WAAW,EAAEC,QAAQ,GACnDL,eAAe,CACf;EACF,MAAMM,cAAc,GAAGP,KAAK,GAAIC,eAAe,CAAE,EAAEI,WAAW,EAAEC,QAAQ;EACxE,MAAME,iBAAiB,GAAGJ,iBAAiB,GACxCA,iBAAiB,GACjBG,cAAc;EAEjB,IAAK,CAAEC,iBAAiB,EAAG;IAC1B,OAAOR,KAAK;EACb;EAEA,MAAMS,mBAAmB,GAAGT,KAAK,GAAIE,oBAAoB,CAAE,EAAEG,WAAW;;EAExE;EACA,IAAKI,mBAAmB,GAAIR,eAAe,CAAE,EAAG;IAC/C,OAAOD,KAAK;EACb;EAEA,IAAIU,qBAAqB;EACzB,IAAKN,iBAAiB,EAAG;IACxB,MAAMO,mBAAmB,GAAGX,KAAK,GAAIG,kBAAkB,CAAE;IACzD,MAAMS,oBAAoB,GACzBZ,KAAK,GAAIG,kBAAkB,CAAE,EAAEE,WAAW,EAAEC,QAAQ;IAErDI,qBAAqB,GAAG;MACvB,CAAEP,kBAAkB,GAAI;QACvB,GAAGQ,mBAAmB;QACtBN,WAAW,EAAE;UACZC,QAAQ,EAAE;YACT,GAAGM,oBAAoB;YACvB,CAAEX,eAAe,GAAIY;UACtB;QACD;MACD;IACD,CAAC;EACF;EAEA,IAAIC,kBAAkB;EACtB,IAAKP,cAAc,EAAG;IACrB,MAAMQ,gBAAgB,GAAGf,KAAK,GAAIC,eAAe,CAAE;IACnD,MAAMe,iBAAiB,GAAGhB,KAAK,GAAIC,eAAe,CAAE,EAAEI,WAAW;IAEjES,kBAAkB,GAAG;MACpB,CAAEb,eAAe,GAAI;QACpB,GAAGc,gBAAgB;QACnBV,WAAW,EAAE;UACZ,GAAGW,iBAAiB;UACpBV,QAAQ,EAAEO;QACX;MACD;IACD,CAAC;EACF;;EAEA;EACA;EACA;EACA,OAAO;IACN,GAAGb,KAAK;IACR,CAAEE,oBAAoB,GAAI;MACzBG,WAAW,EAAE;QACZ,GAAGI,mBAAmB;QACtB,CAAER,eAAe,GAAIO;MACtB;IACD,CAAC;IACD,GAAGE,qBAAqB;IACxB,GAAGI;EACJ,CAAC;AACF"}
1
+ {"version":3,"names":["moveFeaturePreferences","state","sourceStoreName","preferencesStoreName","interfaceStoreName","interfaceFeatures","preferences","features","sourceFeatures","featuresToMigrate","existingPreferences","updatedInterfaceState","otherInterfaceState","otherInterfaceScopes","undefined","updatedSourceState","otherSourceState","sourcePreferences"],"sources":["@wordpress/preferences-persistence/src/migrations/legacy-local-storage-data/move-feature-preferences.js"],"sourcesContent":["/**\n * Move the 'features' object in local storage from the sourceStoreName to the\n * preferences store data structure.\n *\n * Previously, editors used a data structure like this for feature preferences:\n * ```js\n * {\n * 'core/edit-post': {\n * preferences: {\n * features; {\n * topToolbar: true,\n * // ... other boolean 'feature' preferences\n * },\n * },\n * },\n * }\n * ```\n *\n * And for a while these feature preferences lived in the interface package:\n * ```js\n * {\n * 'core/interface': {\n * preferences: {\n * features: {\n * 'core/edit-post': {\n * topToolbar: true\n * }\n * }\n * }\n * }\n * }\n * ```\n *\n * In the preferences store, 'features' aren't considered special, they're\n * merged to the root level of the scope along with other preferences:\n * ```js\n * {\n * 'core/preferences': {\n * preferences: {\n * 'core/edit-post': {\n * topToolbar: true,\n * // ... any other preferences.\n * }\n * }\n * }\n * }\n * ```\n *\n * This function handles moving from either the source store or the interface\n * store to the preferences data structure.\n *\n * @param {Object} state The state before migration.\n * @param {string} sourceStoreName The name of the store that has persisted\n * preferences to migrate to the preferences\n * package.\n * @return {Object} The migrated state\n */\nexport default function moveFeaturePreferences( state, sourceStoreName ) {\n\tconst preferencesStoreName = 'core/preferences';\n\tconst interfaceStoreName = 'core/interface';\n\n\t// Features most recently (and briefly) lived in the interface package.\n\t// If data exists there, prioritize using that for the migration. If not\n\t// also check the original package as the user may have updated from an\n\t// older block editor version.\n\tconst interfaceFeatures =\n\t\tstate?.[ interfaceStoreName ]?.preferences?.features?.[\n\t\t\tsourceStoreName\n\t\t];\n\tconst sourceFeatures = state?.[ sourceStoreName ]?.preferences?.features;\n\tconst featuresToMigrate = interfaceFeatures\n\t\t? interfaceFeatures\n\t\t: sourceFeatures;\n\n\tif ( ! featuresToMigrate ) {\n\t\treturn state;\n\t}\n\n\tconst existingPreferences = state?.[ preferencesStoreName ]?.preferences;\n\n\t// Avoid migrating features again if they've previously been migrated.\n\tif ( existingPreferences?.[ sourceStoreName ] ) {\n\t\treturn state;\n\t}\n\n\tlet updatedInterfaceState;\n\tif ( interfaceFeatures ) {\n\t\tconst otherInterfaceState = state?.[ interfaceStoreName ];\n\t\tconst otherInterfaceScopes =\n\t\t\tstate?.[ interfaceStoreName ]?.preferences?.features;\n\n\t\tupdatedInterfaceState = {\n\t\t\t[ interfaceStoreName ]: {\n\t\t\t\t...otherInterfaceState,\n\t\t\t\tpreferences: {\n\t\t\t\t\tfeatures: {\n\t\t\t\t\t\t...otherInterfaceScopes,\n\t\t\t\t\t\t[ sourceStoreName ]: undefined,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\t}\n\n\tlet updatedSourceState;\n\tif ( sourceFeatures ) {\n\t\tconst otherSourceState = state?.[ sourceStoreName ];\n\t\tconst sourcePreferences = state?.[ sourceStoreName ]?.preferences;\n\n\t\tupdatedSourceState = {\n\t\t\t[ sourceStoreName ]: {\n\t\t\t\t...otherSourceState,\n\t\t\t\tpreferences: {\n\t\t\t\t\t...sourcePreferences,\n\t\t\t\t\tfeatures: undefined,\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\t}\n\n\t// Set the feature values in the interface store, the features\n\t// object is keyed by 'scope', which matches the store name for\n\t// the source.\n\treturn {\n\t\t...state,\n\t\t[ preferencesStoreName ]: {\n\t\t\tpreferences: {\n\t\t\t\t...existingPreferences,\n\t\t\t\t[ sourceStoreName ]: featuresToMigrate,\n\t\t\t},\n\t\t},\n\t\t...updatedInterfaceState,\n\t\t...updatedSourceState,\n\t};\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,sBAAsBA,CA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,iBAAiB;UACpBV,QAAQ,EAAEO;QACX;MACD;IACD,CAAC;EACF;;EAEA;EACA;EACA;EACA,OAAO;IACN,GAAGb,KAAK;IACR,CAAEE,oBAAoB,GAAI;MACzBG,WAAW,EAAE;QACZ,GAAGI,mBAAmB;QACtB,CAAER,eAAe,GAAIO;MACtB;IACD,CAAC;IACD,GAAGE,qBAAqB;IACxB,GAAGI;EACJ,CAAC;AACF","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["identity","arg","moveIndividualPreferenceToPreferences","state","from","sourceStoreName","to","scope","key","convert","preferencesStoreName","sourcePreference","preferences","undefined","targetPreference","otherScopes","otherPreferences","otherSourceState","allSourcePreferences","convertedPreferences"],"sources":["@wordpress/preferences-persistence/src/migrations/legacy-local-storage-data/move-individual-preference.js"],"sourcesContent":["const identity = ( arg ) => arg;\n\n/**\n * Migrates an individual item inside the `preferences` object for a package's store.\n *\n * Previously, some packages had individual 'preferences' of any data type, and many used\n * complex nested data structures. For example:\n * ```js\n * {\n * 'core/edit-post': {\n * preferences: {\n * panels: {\n * publish: {\n * opened: true,\n * enabled: true,\n * }\n * },\n * // ...other preferences.\n * },\n * },\n * }\n *\n * This function supports moving an individual preference like 'panels' above into the\n * preferences package data structure.\n *\n * It supports moving a preference to a particular scope in the preferences store and\n * optionally converting the data using a `convert` function.\n *\n * ```\n *\n * @param {Object} state The original state.\n * @param {Object} migrate An options object that contains details of the migration.\n * @param {string} migrate.from The name of the store to migrate from.\n * @param {string} migrate.to The scope in the preferences store to migrate to.\n * @param {string} key The key in the preferences object to migrate.\n * @param {?Function} convert A function that converts preferences from one format to another.\n */\nexport default function moveIndividualPreferenceToPreferences(\n\tstate,\n\t{ from: sourceStoreName, to: scope },\n\tkey,\n\tconvert = identity\n) {\n\tconst preferencesStoreName = 'core/preferences';\n\tconst sourcePreference = state?.[ sourceStoreName ]?.preferences?.[ key ];\n\n\t// There's nothing to migrate, exit early.\n\tif ( sourcePreference === undefined ) {\n\t\treturn state;\n\t}\n\n\tconst targetPreference =\n\t\tstate?.[ preferencesStoreName ]?.preferences?.[ scope ]?.[ key ];\n\n\t// There's existing data at the target, so don't overwrite it, exit early.\n\tif ( targetPreference ) {\n\t\treturn state;\n\t}\n\n\tconst otherScopes = state?.[ preferencesStoreName ]?.preferences;\n\tconst otherPreferences =\n\t\tstate?.[ preferencesStoreName ]?.preferences?.[ scope ];\n\n\tconst otherSourceState = state?.[ sourceStoreName ];\n\tconst allSourcePreferences = state?.[ sourceStoreName ]?.preferences;\n\n\t// Pass an object with the key and value as this allows the convert\n\t// function to convert to a data structure that has different keys.\n\tconst convertedPreferences = convert( { [ key ]: sourcePreference } );\n\n\treturn {\n\t\t...state,\n\t\t[ preferencesStoreName ]: {\n\t\t\tpreferences: {\n\t\t\t\t...otherScopes,\n\t\t\t\t[ scope ]: {\n\t\t\t\t\t...otherPreferences,\n\t\t\t\t\t...convertedPreferences,\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t[ sourceStoreName ]: {\n\t\t\t...otherSourceState,\n\t\t\tpreferences: {\n\t\t\t\t...allSourcePreferences,\n\t\t\t\t[ key ]: undefined,\n\t\t\t},\n\t\t},\n\t};\n}\n"],"mappings":";;;;;;AAAA,MAAMA,QAAQ,GAAKC,GAAG,IAAMA,GAAG;;AAE/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASC,qCAAqCA,CAC5DC,KAAK,EACL;EAAEC,IAAI,EAAEC,eAAe;EAAEC,EAAE,EAAEC;AAAM,CAAC,EACpCC,GAAG,EACHC,OAAO,GAAGT,QAAQ,EACjB;EACD,MAAMU,oBAAoB,GAAG,kBAAkB;EAC/C,MAAMC,gBAAgB,GAAGR,KAAK,GAAIE,eAAe,CAAE,EAAEO,WAAW,GAAIJ,GAAG,CAAE;;EAEzE;EACA,IAAKG,gBAAgB,KAAKE,SAAS,EAAG;IACrC,OAAOV,KAAK;EACb;EAEA,MAAMW,gBAAgB,GACrBX,KAAK,GAAIO,oBAAoB,CAAE,EAAEE,WAAW,GAAIL,KAAK,CAAE,GAAIC,GAAG,CAAE;;EAEjE;EACA,IAAKM,gBAAgB,EAAG;IACvB,OAAOX,KAAK;EACb;EAEA,MAAMY,WAAW,GAAGZ,KAAK,GAAIO,oBAAoB,CAAE,EAAEE,WAAW;EAChE,MAAMI,gBAAgB,GACrBb,KAAK,GAAIO,oBAAoB,CAAE,EAAEE,WAAW,GAAIL,KAAK,CAAE;EAExD,MAAMU,gBAAgB,GAAGd,KAAK,GAAIE,eAAe,CAAE;EACnD,MAAMa,oBAAoB,GAAGf,KAAK,GAAIE,eAAe,CAAE,EAAEO,WAAW;;EAEpE;EACA;EACA,MAAMO,oBAAoB,GAAGV,OAAO,CAAE;IAAE,CAAED,GAAG,GAAIG;EAAiB,CAAE,CAAC;EAErE,OAAO;IACN,GAAGR,KAAK;IACR,CAAEO,oBAAoB,GAAI;MACzBE,WAAW,EAAE;QACZ,GAAGG,WAAW;QACd,CAAER,KAAK,GAAI;UACV,GAAGS,gBAAgB;UACnB,GAAGG;QACJ;MACD;IACD,CAAC;IACD,CAAEd,eAAe,GAAI;MACpB,GAAGY,gBAAgB;MACnBL,WAAW,EAAE;QACZ,GAAGM,oBAAoB;QACvB,CAAEV,GAAG,GAAIK;MACV;IACD;EACD,CAAC;AACF"}
1
+ {"version":3,"names":["identity","arg","moveIndividualPreferenceToPreferences","state","from","sourceStoreName","to","scope","key","convert","preferencesStoreName","sourcePreference","preferences","undefined","targetPreference","otherScopes","otherPreferences","otherSourceState","allSourcePreferences","convertedPreferences"],"sources":["@wordpress/preferences-persistence/src/migrations/legacy-local-storage-data/move-individual-preference.js"],"sourcesContent":["const identity = ( arg ) => arg;\n\n/**\n * Migrates an individual item inside the `preferences` object for a package's store.\n *\n * Previously, some packages had individual 'preferences' of any data type, and many used\n * complex nested data structures. For example:\n * ```js\n * {\n * 'core/edit-post': {\n * preferences: {\n * panels: {\n * publish: {\n * opened: true,\n * enabled: true,\n * }\n * },\n * // ...other preferences.\n * },\n * },\n * }\n *\n * This function supports moving an individual preference like 'panels' above into the\n * preferences package data structure.\n *\n * It supports moving a preference to a particular scope in the preferences store and\n * optionally converting the data using a `convert` function.\n *\n * ```\n *\n * @param {Object} state The original state.\n * @param {Object} migrate An options object that contains details of the migration.\n * @param {string} migrate.from The name of the store to migrate from.\n * @param {string} migrate.to The scope in the preferences store to migrate to.\n * @param {string} key The key in the preferences object to migrate.\n * @param {?Function} convert A function that converts preferences from one format to another.\n */\nexport default function moveIndividualPreferenceToPreferences(\n\tstate,\n\t{ from: sourceStoreName, to: scope },\n\tkey,\n\tconvert = identity\n) {\n\tconst preferencesStoreName = 'core/preferences';\n\tconst sourcePreference = state?.[ sourceStoreName ]?.preferences?.[ key ];\n\n\t// There's nothing to migrate, exit early.\n\tif ( sourcePreference === undefined ) {\n\t\treturn state;\n\t}\n\n\tconst targetPreference =\n\t\tstate?.[ preferencesStoreName ]?.preferences?.[ scope ]?.[ key ];\n\n\t// There's existing data at the target, so don't overwrite it, exit early.\n\tif ( targetPreference ) {\n\t\treturn state;\n\t}\n\n\tconst otherScopes = state?.[ preferencesStoreName ]?.preferences;\n\tconst otherPreferences =\n\t\tstate?.[ preferencesStoreName ]?.preferences?.[ scope ];\n\n\tconst otherSourceState = state?.[ sourceStoreName ];\n\tconst allSourcePreferences = state?.[ sourceStoreName ]?.preferences;\n\n\t// Pass an object with the key and value as this allows the convert\n\t// function to convert to a data structure that has different keys.\n\tconst convertedPreferences = convert( { [ key ]: sourcePreference } );\n\n\treturn {\n\t\t...state,\n\t\t[ preferencesStoreName ]: {\n\t\t\tpreferences: {\n\t\t\t\t...otherScopes,\n\t\t\t\t[ scope ]: {\n\t\t\t\t\t...otherPreferences,\n\t\t\t\t\t...convertedPreferences,\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t[ sourceStoreName ]: {\n\t\t\t...otherSourceState,\n\t\t\tpreferences: {\n\t\t\t\t...allSourcePreferences,\n\t\t\t\t[ key ]: undefined,\n\t\t\t},\n\t\t},\n\t};\n}\n"],"mappings":";;;;;;AAAA,MAAMA,QAAQ,GAAKC,GAAG,IAAMA,GAAG;;AAE/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASC,qCAAqCA,CAC5DC,KAAK,EACL;EAAEC,IAAI,EAAEC,eAAe;EAAEC,EAAE,EAAEC;AAAM,CAAC,EACpCC,GAAG,EACHC,OAAO,GAAGT,QAAQ,EACjB;EACD,MAAMU,oBAAoB,GAAG,kBAAkB;EAC/C,MAAMC,gBAAgB,GAAGR,KAAK,GAAIE,eAAe,CAAE,EAAEO,WAAW,GAAIJ,GAAG,CAAE;;EAEzE;EACA,IAAKG,gBAAgB,KAAKE,SAAS,EAAG;IACrC,OAAOV,KAAK;EACb;EAEA,MAAMW,gBAAgB,GACrBX,KAAK,GAAIO,oBAAoB,CAAE,EAAEE,WAAW,GAAIL,KAAK,CAAE,GAAIC,GAAG,CAAE;;EAEjE;EACA,IAAKM,gBAAgB,EAAG;IACvB,OAAOX,KAAK;EACb;EAEA,MAAMY,WAAW,GAAGZ,KAAK,GAAIO,oBAAoB,CAAE,EAAEE,WAAW;EAChE,MAAMI,gBAAgB,GACrBb,KAAK,GAAIO,oBAAoB,CAAE,EAAEE,WAAW,GAAIL,KAAK,CAAE;EAExD,MAAMU,gBAAgB,GAAGd,KAAK,GAAIE,eAAe,CAAE;EACnD,MAAMa,oBAAoB,GAAGf,KAAK,GAAIE,eAAe,CAAE,EAAEO,WAAW;;EAEpE;EACA;EACA,MAAMO,oBAAoB,GAAGV,OAAO,CAAE;IAAE,CAAED,GAAG,GAAIG;EAAiB,CAAE,CAAC;EAErE,OAAO;IACN,GAAGR,KAAK;IACR,CAAEO,oBAAoB,GAAI;MACzBE,WAAW,EAAE;QACZ,GAAGG,WAAW;QACd,CAAER,KAAK,GAAI;UACV,GAAGS,gBAAgB;UACnB,GAAGG;QACJ;MACD;IACD,CAAC;IACD,CAAEd,eAAe,GAAI;MACpB,GAAGY,gBAAgB;MACnBL,WAAW,EAAE;QACZ,GAAGM,oBAAoB;QACvB,CAAEV,GAAG,GAAIK;MACV;IACD;EACD,CAAC;AACF","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["moveInterfaceEnableItems","state","_state$preferencesSto","_sourceEnableItems$si","_sourceEnableItems$mu","interfaceStoreName","preferencesStoreName","sourceEnableItems","enableItems","allPreferences","preferences","sourceComplementaryAreas","singleEnableItems","complementaryArea","preferencesWithConvertedComplementaryAreas","Object","keys","reduce","accumulator","scope","data","sourcePinnedItems","multipleEnableItems","pinnedItems","allConvertedData","otherInterfaceItems","undefined"],"sources":["@wordpress/preferences-persistence/src/migrations/legacy-local-storage-data/move-interface-enable-items.js"],"sourcesContent":["/**\n * Migrates interface 'enableItems' data to the preferences store.\n *\n * The interface package stores this data in this format:\n * ```js\n * {\n * enableItems: {\n * singleEnableItems: {\n * \t complementaryArea: {\n * 'core/edit-post': 'edit-post/document',\n * 'core/edit-site': 'edit-site/global-styles',\n * }\n * },\n * multipleEnableItems: {\n * pinnedItems: {\n * 'core/edit-post': {\n * 'plugin-1': true,\n * },\n * 'core/edit-site': {\n * 'plugin-2': true,\n * },\n * },\n * }\n * }\n * }\n * ```\n *\n * and it should be converted it to:\n * ```js\n * {\n * 'core/edit-post': {\n * complementaryArea: 'edit-post/document',\n * pinnedItems: {\n * 'plugin-1': true,\n * },\n * },\n * 'core/edit-site': {\n * complementaryArea: 'edit-site/global-styles',\n * pinnedItems: {\n * 'plugin-2': true,\n * },\n * },\n * }\n * ```\n *\n * @param {Object} state The local storage state.\n */\nexport default function moveInterfaceEnableItems( state ) {\n\tconst interfaceStoreName = 'core/interface';\n\tconst preferencesStoreName = 'core/preferences';\n\tconst sourceEnableItems = state?.[ interfaceStoreName ]?.enableItems;\n\n\t// There's nothing to migrate, exit early.\n\tif ( ! sourceEnableItems ) {\n\t\treturn state;\n\t}\n\n\tconst allPreferences = state?.[ preferencesStoreName ]?.preferences ?? {};\n\n\t// First convert complementaryAreas into the right format.\n\t// Use the existing preferences as the accumulator so that the data is\n\t// merged.\n\tconst sourceComplementaryAreas =\n\t\tsourceEnableItems?.singleEnableItems?.complementaryArea ?? {};\n\n\tconst preferencesWithConvertedComplementaryAreas = Object.keys(\n\t\tsourceComplementaryAreas\n\t).reduce( ( accumulator, scope ) => {\n\t\tconst data = sourceComplementaryAreas[ scope ];\n\n\t\t// Don't overwrite any existing data in the preferences store.\n\t\tif ( accumulator?.[ scope ]?.complementaryArea ) {\n\t\t\treturn accumulator;\n\t\t}\n\n\t\treturn {\n\t\t\t...accumulator,\n\t\t\t[ scope ]: {\n\t\t\t\t...accumulator[ scope ],\n\t\t\t\tcomplementaryArea: data,\n\t\t\t},\n\t\t};\n\t}, allPreferences );\n\n\t// Next feed the converted complementary areas back into a reducer that\n\t// converts the pinned items, resulting in the fully migrated data.\n\tconst sourcePinnedItems =\n\t\tsourceEnableItems?.multipleEnableItems?.pinnedItems ?? {};\n\tconst allConvertedData = Object.keys( sourcePinnedItems ).reduce(\n\t\t( accumulator, scope ) => {\n\t\t\tconst data = sourcePinnedItems[ scope ];\n\t\t\t// Don't overwrite any existing data in the preferences store.\n\t\t\tif ( accumulator?.[ scope ]?.pinnedItems ) {\n\t\t\t\treturn accumulator;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\t...accumulator,\n\t\t\t\t[ scope ]: {\n\t\t\t\t\t...accumulator[ scope ],\n\t\t\t\t\tpinnedItems: data,\n\t\t\t\t},\n\t\t\t};\n\t\t},\n\t\tpreferencesWithConvertedComplementaryAreas\n\t);\n\n\tconst otherInterfaceItems = state[ interfaceStoreName ];\n\n\treturn {\n\t\t...state,\n\t\t[ preferencesStoreName ]: {\n\t\t\tpreferences: allConvertedData,\n\t\t},\n\t\t[ interfaceStoreName ]: {\n\t\t\t...otherInterfaceItems,\n\t\t\tenableItems: undefined,\n\t\t},\n\t};\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,wBAAwBA,CAAEC,KAAK,EAAG;EAAA,IAAAC,qBAAA,EAAAC,qBAAA,EAAAC,qBAAA;EACzD,MAAMC,kBAAkB,GAAG,gBAAgB;EAC3C,MAAMC,oBAAoB,GAAG,kBAAkB;EAC/C,MAAMC,iBAAiB,GAAGN,KAAK,GAAII,kBAAkB,CAAE,EAAEG,WAAW;;EAEpE;EACA,IAAK,CAAED,iBAAiB,EAAG;IAC1B,OAAON,KAAK;EACb;EAEA,MAAMQ,cAAc,IAAAP,qBAAA,GAAGD,KAAK,GAAIK,oBAAoB,CAAE,EAAEI,WAAW,cAAAR,qBAAA,cAAAA,qBAAA,GAAI,CAAC,CAAC;;EAEzE;EACA;EACA;EACA,MAAMS,wBAAwB,IAAAR,qBAAA,GAC7BI,iBAAiB,EAAEK,iBAAiB,EAAEC,iBAAiB,cAAAV,qBAAA,cAAAA,qBAAA,GAAI,CAAC,CAAC;EAE9D,MAAMW,0CAA0C,GAAGC,MAAM,CAACC,IAAI,CAC7DL,wBACD,CAAC,CAACM,MAAM,CAAE,CAAEC,WAAW,EAAEC,KAAK,KAAM;IACnC,MAAMC,IAAI,GAAGT,wBAAwB,CAAEQ,KAAK,CAAE;;IAE9C;IACA,IAAKD,WAAW,GAAIC,KAAK,CAAE,EAAEN,iBAAiB,EAAG;MAChD,OAAOK,WAAW;IACnB;IAEA,OAAO;MACN,GAAGA,WAAW;MACd,CAAEC,KAAK,GAAI;QACV,GAAGD,WAAW,CAAEC,KAAK,CAAE;QACvBN,iBAAiB,EAAEO;MACpB;IACD,CAAC;EACF,CAAC,EAAEX,cAAe,CAAC;;EAEnB;EACA;EACA,MAAMY,iBAAiB,IAAAjB,qBAAA,GACtBG,iBAAiB,EAAEe,mBAAmB,EAAEC,WAAW,cAAAnB,qBAAA,cAAAA,qBAAA,GAAI,CAAC,CAAC;EAC1D,MAAMoB,gBAAgB,GAAGT,MAAM,CAACC,IAAI,CAAEK,iBAAkB,CAAC,CAACJ,MAAM,CAC/D,CAAEC,WAAW,EAAEC,KAAK,KAAM;IACzB,MAAMC,IAAI,GAAGC,iBAAiB,CAAEF,KAAK,CAAE;IACvC;IACA,IAAKD,WAAW,GAAIC,KAAK,CAAE,EAAEI,WAAW,EAAG;MAC1C,OAAOL,WAAW;IACnB;IAEA,OAAO;MACN,GAAGA,WAAW;MACd,CAAEC,KAAK,GAAI;QACV,GAAGD,WAAW,CAAEC,KAAK,CAAE;QACvBI,WAAW,EAAEH;MACd;IACD,CAAC;EACF,CAAC,EACDN,0CACD,CAAC;EAED,MAAMW,mBAAmB,GAAGxB,KAAK,CAAEI,kBAAkB,CAAE;EAEvD,OAAO;IACN,GAAGJ,KAAK;IACR,CAAEK,oBAAoB,GAAI;MACzBI,WAAW,EAAEc;IACd,CAAC;IACD,CAAEnB,kBAAkB,GAAI;MACvB,GAAGoB,mBAAmB;MACtBjB,WAAW,EAAEkB;IACd;EACD,CAAC;AACF"}
1
+ {"version":3,"names":["moveInterfaceEnableItems","state","_state$preferencesSto","_sourceEnableItems$si","_sourceEnableItems$mu","interfaceStoreName","preferencesStoreName","sourceEnableItems","enableItems","allPreferences","preferences","sourceComplementaryAreas","singleEnableItems","complementaryArea","preferencesWithConvertedComplementaryAreas","Object","keys","reduce","accumulator","scope","data","sourcePinnedItems","multipleEnableItems","pinnedItems","allConvertedData","otherInterfaceItems","undefined"],"sources":["@wordpress/preferences-persistence/src/migrations/legacy-local-storage-data/move-interface-enable-items.js"],"sourcesContent":["/**\n * Migrates interface 'enableItems' data to the preferences store.\n *\n * The interface package stores this data in this format:\n * ```js\n * {\n * enableItems: {\n * singleEnableItems: {\n * \t complementaryArea: {\n * 'core/edit-post': 'edit-post/document',\n * 'core/edit-site': 'edit-site/global-styles',\n * }\n * },\n * multipleEnableItems: {\n * pinnedItems: {\n * 'core/edit-post': {\n * 'plugin-1': true,\n * },\n * 'core/edit-site': {\n * 'plugin-2': true,\n * },\n * },\n * }\n * }\n * }\n * ```\n *\n * and it should be converted it to:\n * ```js\n * {\n * 'core/edit-post': {\n * complementaryArea: 'edit-post/document',\n * pinnedItems: {\n * 'plugin-1': true,\n * },\n * },\n * 'core/edit-site': {\n * complementaryArea: 'edit-site/global-styles',\n * pinnedItems: {\n * 'plugin-2': true,\n * },\n * },\n * }\n * ```\n *\n * @param {Object} state The local storage state.\n */\nexport default function moveInterfaceEnableItems( state ) {\n\tconst interfaceStoreName = 'core/interface';\n\tconst preferencesStoreName = 'core/preferences';\n\tconst sourceEnableItems = state?.[ interfaceStoreName ]?.enableItems;\n\n\t// There's nothing to migrate, exit early.\n\tif ( ! sourceEnableItems ) {\n\t\treturn state;\n\t}\n\n\tconst allPreferences = state?.[ preferencesStoreName ]?.preferences ?? {};\n\n\t// First convert complementaryAreas into the right format.\n\t// Use the existing preferences as the accumulator so that the data is\n\t// merged.\n\tconst sourceComplementaryAreas =\n\t\tsourceEnableItems?.singleEnableItems?.complementaryArea ?? {};\n\n\tconst preferencesWithConvertedComplementaryAreas = Object.keys(\n\t\tsourceComplementaryAreas\n\t).reduce( ( accumulator, scope ) => {\n\t\tconst data = sourceComplementaryAreas[ scope ];\n\n\t\t// Don't overwrite any existing data in the preferences store.\n\t\tif ( accumulator?.[ scope ]?.complementaryArea ) {\n\t\t\treturn accumulator;\n\t\t}\n\n\t\treturn {\n\t\t\t...accumulator,\n\t\t\t[ scope ]: {\n\t\t\t\t...accumulator[ scope ],\n\t\t\t\tcomplementaryArea: data,\n\t\t\t},\n\t\t};\n\t}, allPreferences );\n\n\t// Next feed the converted complementary areas back into a reducer that\n\t// converts the pinned items, resulting in the fully migrated data.\n\tconst sourcePinnedItems =\n\t\tsourceEnableItems?.multipleEnableItems?.pinnedItems ?? {};\n\tconst allConvertedData = Object.keys( sourcePinnedItems ).reduce(\n\t\t( accumulator, scope ) => {\n\t\t\tconst data = sourcePinnedItems[ scope ];\n\t\t\t// Don't overwrite any existing data in the preferences store.\n\t\t\tif ( accumulator?.[ scope ]?.pinnedItems ) {\n\t\t\t\treturn accumulator;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\t...accumulator,\n\t\t\t\t[ scope ]: {\n\t\t\t\t\t...accumulator[ scope ],\n\t\t\t\t\tpinnedItems: data,\n\t\t\t\t},\n\t\t\t};\n\t\t},\n\t\tpreferencesWithConvertedComplementaryAreas\n\t);\n\n\tconst otherInterfaceItems = state[ interfaceStoreName ];\n\n\treturn {\n\t\t...state,\n\t\t[ preferencesStoreName ]: {\n\t\t\tpreferences: allConvertedData,\n\t\t},\n\t\t[ interfaceStoreName ]: {\n\t\t\t...otherInterfaceItems,\n\t\t\tenableItems: undefined,\n\t\t},\n\t};\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,wBAAwBA,CAAEC,KAAK,EAAG;EAAA,IAAAC,qBAAA,EAAAC,qBAAA,EAAAC,qBAAA;EACzD,MAAMC,kBAAkB,GAAG,gBAAgB;EAC3C,MAAMC,oBAAoB,GA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G;MAC1C,OAAOL,WAAW;IACnB;IAEA,OAAO;MACN,GAAGA,WAAW;MACd,CAAEC,KAAK,GAAI;QACV,GAAGD,WAAW,CAAEC,KAAK,CAAE;QACvBI,WAAW,EAAEH;MACd;IACD,CAAC;EACF,CAAC,EACDN,0CACD,CAAC;EAED,MAAMW,mBAAmB,GAAGxB,KAAK,CAAEI,kBAAkB,CAAE;EAEvD,OAAO;IACN,GAAGJ,KAAK;IACR,CAAEK,oBAAoB,GAAI;MACzBI,WAAW,EAAEc;IACd,CAAC;IACD,CAAEnB,kBAAkB,GAAI;MACvB,GAAGoB,mBAAmB;MACtBjB,WAAW,EAAEkB;IACd;EACD,CAAC;AACF","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["moveThirdPartyFeaturePreferencesToPreferences","state","interfaceStoreName","preferencesStoreName","interfaceScopes","preferences","features","interfaceScopeKeys","Object","keys","length","reduce","convertedState","scope","startsWith","featuresToMigrate","existingMigratedData","otherPreferencesScopes","otherInterfaceState","otherInterfaceScopes","undefined"],"sources":["@wordpress/preferences-persistence/src/migrations/legacy-local-storage-data/move-third-party-feature-preferences.js"],"sourcesContent":["/**\n * The interface package previously had a public API that could be used by\n * plugins to set persisted boolean 'feature' preferences.\n *\n * While usage was likely non-existent or very small, this function ensures\n * those are migrated to the preferences data structure. The interface\n * package's APIs have now been deprecated and use the preferences store.\n *\n * This will convert data that looks like this:\n * ```js\n * {\n * 'core/interface': {\n * preferences: {\n * features: {\n * 'my-plugin': {\n * myPluginFeature: true\n * }\n * }\n * }\n * }\n * }\n * ```\n *\n * To this:\n * ```js\n * * {\n * 'core/preferences': {\n * preferences: {\n * 'my-plugin': {\n * myPluginFeature: true\n * }\n * }\n * }\n * }\n * ```\n *\n * @param {Object} state The local storage state\n *\n * @return {Object} The state with third party preferences moved to the\n * preferences data structure.\n */\nexport default function moveThirdPartyFeaturePreferencesToPreferences( state ) {\n\tconst interfaceStoreName = 'core/interface';\n\tconst preferencesStoreName = 'core/preferences';\n\n\tconst interfaceScopes =\n\t\tstate?.[ interfaceStoreName ]?.preferences?.features;\n\tconst interfaceScopeKeys = interfaceScopes\n\t\t? Object.keys( interfaceScopes )\n\t\t: [];\n\n\tif ( ! interfaceScopeKeys?.length ) {\n\t\treturn state;\n\t}\n\n\treturn interfaceScopeKeys.reduce( function ( convertedState, scope ) {\n\t\tif ( scope.startsWith( 'core' ) ) {\n\t\t\treturn convertedState;\n\t\t}\n\n\t\tconst featuresToMigrate = interfaceScopes?.[ scope ];\n\t\tif ( ! featuresToMigrate ) {\n\t\t\treturn convertedState;\n\t\t}\n\n\t\tconst existingMigratedData =\n\t\t\tconvertedState?.[ preferencesStoreName ]?.preferences?.[ scope ];\n\n\t\tif ( existingMigratedData ) {\n\t\t\treturn convertedState;\n\t\t}\n\n\t\tconst otherPreferencesScopes =\n\t\t\tconvertedState?.[ preferencesStoreName ]?.preferences;\n\t\tconst otherInterfaceState = convertedState?.[ interfaceStoreName ];\n\t\tconst otherInterfaceScopes =\n\t\t\tconvertedState?.[ interfaceStoreName ]?.preferences?.features;\n\n\t\treturn {\n\t\t\t...convertedState,\n\t\t\t[ preferencesStoreName ]: {\n\t\t\t\tpreferences: {\n\t\t\t\t\t...otherPreferencesScopes,\n\t\t\t\t\t[ scope ]: featuresToMigrate,\n\t\t\t\t},\n\t\t\t},\n\t\t\t[ interfaceStoreName ]: {\n\t\t\t\t...otherInterfaceState,\n\t\t\t\tpreferences: {\n\t\t\t\t\tfeatures: {\n\t\t\t\t\t\t...otherInterfaceScopes,\n\t\t\t\t\t\t[ scope ]: undefined,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\t}, state );\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA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,QAAQ,EAAE;YACT,GAAGa,oBAAoB;YACvB,CAAEN,KAAK,GAAIO;UACZ;QACD;MACD;IACD,CAAC;EACF,CAAC,EAAEnB,KAAM,CAAC;AACX"}
1
+ {"version":3,"names":["moveThirdPartyFeaturePreferencesToPreferences","state","interfaceStoreName","preferencesStoreName","interfaceScopes","preferences","features","interfaceScopeKeys","Object","keys","length","reduce","convertedState","scope","startsWith","featuresToMigrate","existingMigratedData","otherPreferencesScopes","otherInterfaceState","otherInterfaceScopes","undefined"],"sources":["@wordpress/preferences-persistence/src/migrations/legacy-local-storage-data/move-third-party-feature-preferences.js"],"sourcesContent":["/**\n * The interface package previously had a public API that could be used by\n * plugins to set persisted boolean 'feature' preferences.\n *\n * While usage was likely non-existent or very small, this function ensures\n * those are migrated to the preferences data structure. The interface\n * package's APIs have now been deprecated and use the preferences store.\n *\n * This will convert data that looks like this:\n * ```js\n * {\n * 'core/interface': {\n * preferences: {\n * features: {\n * 'my-plugin': {\n * myPluginFeature: true\n * }\n * }\n * }\n * }\n * }\n * ```\n *\n * To this:\n * ```js\n * * {\n * 'core/preferences': {\n * preferences: {\n * 'my-plugin': {\n * myPluginFeature: true\n * }\n * }\n * }\n * }\n * ```\n *\n * @param {Object} state The local storage state\n *\n * @return {Object} The state with third party preferences moved to the\n * preferences data structure.\n */\nexport default function moveThirdPartyFeaturePreferencesToPreferences( state ) {\n\tconst interfaceStoreName = 'core/interface';\n\tconst preferencesStoreName = 'core/preferences';\n\n\tconst interfaceScopes =\n\t\tstate?.[ interfaceStoreName ]?.preferences?.features;\n\tconst interfaceScopeKeys = interfaceScopes\n\t\t? Object.keys( interfaceScopes )\n\t\t: [];\n\n\tif ( ! interfaceScopeKeys?.length ) {\n\t\treturn state;\n\t}\n\n\treturn interfaceScopeKeys.reduce( function ( convertedState, scope ) {\n\t\tif ( scope.startsWith( 'core' ) ) {\n\t\t\treturn convertedState;\n\t\t}\n\n\t\tconst featuresToMigrate = interfaceScopes?.[ scope ];\n\t\tif ( ! featuresToMigrate ) {\n\t\t\treturn convertedState;\n\t\t}\n\n\t\tconst existingMigratedData =\n\t\t\tconvertedState?.[ preferencesStoreName ]?.preferences?.[ scope ];\n\n\t\tif ( existingMigratedData ) {\n\t\t\treturn convertedState;\n\t\t}\n\n\t\tconst otherPreferencesScopes =\n\t\t\tconvertedState?.[ preferencesStoreName ]?.preferences;\n\t\tconst otherInterfaceState = convertedState?.[ interfaceStoreName ];\n\t\tconst otherInterfaceScopes =\n\t\t\tconvertedState?.[ interfaceStoreName ]?.preferences?.features;\n\n\t\treturn {\n\t\t\t...convertedState,\n\t\t\t[ preferencesStoreName ]: {\n\t\t\t\tpreferences: {\n\t\t\t\t\t...otherPreferencesScopes,\n\t\t\t\t\t[ scope ]: featuresToMigrate,\n\t\t\t\t},\n\t\t\t},\n\t\t\t[ interfaceStoreName ]: {\n\t\t\t\t...otherInterfaceState,\n\t\t\t\tpreferences: {\n\t\t\t\t\tfeatures: {\n\t\t\t\t\t\t...otherInterfaceScopes,\n\t\t\t\t\t\t[ scope ]: undefined,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\t}, state );\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,6CAA6CA,CAAEC,KAAK,EAAG;EAC9E,MAAMC,kBAAkB,GAAG,gBAAgB;EAC3C,MAAMC,oBAAoB,GAAG,kBAAkB;EAE/C,MAAMC,eAAe,GACpBH,KAAK,GAAIC,kBAAkB,CAAE,EAAEG,WAAW,EAAEC,QAAQ;EACrD,MAAMC,kBAAkB,GAAGH,eAAe,GACvCI,MAAM,CAACC,IAAI,CAAEL,eAAgB,CAAC,GAC9B,EAAE;EAEL,IAAK,CAAEG,kBAAkB,EAAEG,MAAM,EAAG;IACnC,OAAOT,KAAK;EACb;EAEA,OAAOM,kBAAkB,CAACI,MAAM,CAAE,UAAWC,cAAc,EAAEC,KAAK,EAAG;IACpE,IAAKA,KAAK,CAACC,UAAU,CAAE,MAAO,CAAC,EAAG;MACjC,OAAOF,cAAc;IACtB;IAEA,MAAMG,iBAAiB,GAAGX,eAAe,GAAIS,KAAK,CAAE;IACpD,IAAK,CAAEE,iBAAiB,EAAG;MAC1B,OAAOH,cAAc;IACtB;IAEA,MAAMI,oBAAoB,GACzBJ,cAAc,GAAIT,oBAAoB,CAAE,EAAEE,WAAW,GAAIQ,KAAK,CAAE;IAEjE,IAAKG,oBAAoB,EAAG;MAC3B,OAAOJ,cAAc;IACtB;IAEA,MAAMK,sBAAsB,GAC3BL,cAAc,GAAIT,oBAAoB,CAAE,EAAEE,WAAW;IACtD,MAAMa,mBAAmB,GAAGN,cAAc,GAAIV,kBAAkB,CAAE;IAClE,MAAMiB,oBAAoB,GACzBP,cAAc,GAAIV,kBAAkB,CAAE,EAAEG,WAAW,EAAEC,QAAQ;IAE9D,OAAO;MACN,GAAGM,cAAc;MACjB,CAAET,oBAAoB,GAAI;QACzBE,WAAW,EAAE;UACZ,GAAGY,sBAAsB;UACzB,CAAEJ,KAAK,GAAIE;QACZ;MACD,CAAC;MACD,CAAEb,kBAAkB,GAAI;QACvB,GAAGgB,mBAAmB;QACtBb,WAAW,EAAE;UACZC,QAAQ,EAAE;YACT,GAAGa,oBAAoB;YACvB,CAAEN,KAAK,GAAIO;UACZ;QACD;MACD;IACD,CAAC;EACF,CAAC,EAAEnB,KAAM,CAAC;AACX","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["convertComplementaryAreas","state","Object","keys","reduce","stateAccumulator","scope","scopeData","complementaryArea","updatedScopeData","isComplementaryAreaVisible"],"sources":["@wordpress/preferences-persistence/src/migrations/preferences-package-data/convert-complementary-areas.js"],"sourcesContent":["export default function convertComplementaryAreas( state ) {\n\treturn Object.keys( state ).reduce( ( stateAccumulator, scope ) => {\n\t\tconst scopeData = state[ scope ];\n\n\t\t// If a complementary area is truthy, convert it to the `isComplementaryAreaVisible` boolean.\n\t\tif ( scopeData?.complementaryArea ) {\n\t\t\tconst updatedScopeData = { ...scopeData };\n\t\t\tdelete updatedScopeData.complementaryArea;\n\t\t\tupdatedScopeData.isComplementaryAreaVisible = true;\n\t\t\tstateAccumulator[ scope ] = updatedScopeData;\n\t\t\treturn stateAccumulator;\n\t\t}\n\n\t\treturn stateAccumulator;\n\t}, state );\n}\n"],"mappings":";;;;;;AAAe,SAASA,yBAAyBA,CAAEC,KAAK,EAAG;EAC1D,OAAOC,MAAM,CAACC,IAAI,CAAEF,KAAM,CAAC,CAACG,MAAM,CAAE,CAAEC,gBAAgB,EAAEC,KAAK,KAAM;IAClE,MAAMC,SAAS,GAAGN,KAAK,CAAEK,KAAK,CAAE;;IAEhC;IACA,IAAKC,SAAS,EAAEC,iBAAiB,EAAG;MACnC,MAAMC,gBAAgB,GAAG;QAAE,GAAGF;MAAU,CAAC;MACzC,OAAOE,gBAAgB,CAACD,iBAAiB;MACzCC,gBAAgB,CAACC,0BAA0B,GAAG,IAAI;MAClDL,gBAAgB,CAAEC,KAAK,CAAE,GAAGG,gBAAgB;MAC5C,OAAOJ,gBAAgB;IACxB;IAEA,OAAOA,gBAAgB;EACxB,CAAC,EAAEJ,KAAM,CAAC;AACX"}
1
+ {"version":3,"names":["convertComplementaryAreas","state","Object","keys","reduce","stateAccumulator","scope","scopeData","complementaryArea","updatedScopeData","isComplementaryAreaVisible"],"sources":["@wordpress/preferences-persistence/src/migrations/preferences-package-data/convert-complementary-areas.js"],"sourcesContent":["export default function convertComplementaryAreas( state ) {\n\treturn Object.keys( state ).reduce( ( stateAccumulator, scope ) => {\n\t\tconst scopeData = state[ scope ];\n\n\t\t// If a complementary area is truthy, convert it to the `isComplementaryAreaVisible` boolean.\n\t\tif ( scopeData?.complementaryArea ) {\n\t\t\tconst updatedScopeData = { ...scopeData };\n\t\t\tdelete updatedScopeData.complementaryArea;\n\t\t\tupdatedScopeData.isComplementaryAreaVisible = true;\n\t\t\tstateAccumulator[ scope ] = updatedScopeData;\n\t\t\treturn stateAccumulator;\n\t\t}\n\n\t\treturn stateAccumulator;\n\t}, state );\n}\n"],"mappings":";;;;;;AAAe,SAASA,yBAAyBA,CAAEC,KAAK,EAAG;EAC1D,OAAOC,MAAM,CAACC,IAAI,CAAEF,KAAM,CAAC,CAACG,MAAM,CAAE,CAAEC,gBAAgB,EAAEC,KAAK,KAAM;IAClE,MAAMC,SAAS,GAAGN,KAAK,CAAEK,KAAK,CAAE;;IAEhC;IACA,IAAKC,SAAS,EAAEC,iBAAiB,EAAG;MACnC,MAAMC,gBAAgB,GAAG;QAAE,GAAGF;MAAU,CAAC;MACzC,OAAOE,gBAAgB,CAACD,iBAAiB;MACzCC,gBAAgB,CAACC,0BAA0B,GAAG,IAAI;MAClDL,gBAAgB,CAAEC,KAAK,CAAE,GAAGG,gBAAgB;MAC5C,OAAOJ,gBAAgB;IACxB;IAEA,OAAOA,gBAAgB;EACxB,CAAC,EAAEJ,KAAM,CAAC;AACX","ignoreList":[]}
@@ -11,7 +11,7 @@ exports.default = convertEditorSettings;
11
11
  function convertEditorSettings(data) {
12
12
  var _newData$coreEditPo, _newData$coreEditSi;
13
13
  let newData = data;
14
- const settingsToMoveToCore = ['allowRightClickOverrides', 'distractionFree', 'editorMode', 'fixedToolbar', 'focusMode', 'hiddenBlockTypes', 'inactivePanels', 'keepCaretInsideBlock', 'mostUsedBlocks', 'openPanels', 'showBlockBreadcrumbs', 'showIconLabels', 'showListViewByDefault'];
14
+ const settingsToMoveToCore = ['allowRightClickOverrides', 'distractionFree', 'editorMode', 'fixedToolbar', 'focusMode', 'hiddenBlockTypes', 'inactivePanels', 'keepCaretInsideBlock', 'mostUsedBlocks', 'openPanels', 'showBlockBreadcrumbs', 'showIconLabels', 'showListViewByDefault', 'isPublishSidebarEnabled', 'isComplementaryAreaVisible', 'pinnedItems'];
15
15
  settingsToMoveToCore.forEach(setting => {
16
16
  if (data?.['core/edit-post']?.[setting] !== undefined) {
17
17
  newData = {
@@ -1 +1 @@
1
- {"version":3,"names":["convertEditorSettings","data","_newData$coreEditPo","_newData$coreEditSi","newData","settingsToMoveToCore","forEach","setting","undefined","core","Object","keys","length"],"sources":["@wordpress/preferences-persistence/src/migrations/preferences-package-data/convert-editor-settings.js"],"sourcesContent":["/**\n * Internal dependencies\n */\n\nexport default function convertEditorSettings( data ) {\n\tlet newData = data;\n\tconst settingsToMoveToCore = [\n\t\t'allowRightClickOverrides',\n\t\t'distractionFree',\n\t\t'editorMode',\n\t\t'fixedToolbar',\n\t\t'focusMode',\n\t\t'hiddenBlockTypes',\n\t\t'inactivePanels',\n\t\t'keepCaretInsideBlock',\n\t\t'mostUsedBlocks',\n\t\t'openPanels',\n\t\t'showBlockBreadcrumbs',\n\t\t'showIconLabels',\n\t\t'showListViewByDefault',\n\t];\n\n\tsettingsToMoveToCore.forEach( ( setting ) => {\n\t\tif ( data?.[ 'core/edit-post' ]?.[ setting ] !== undefined ) {\n\t\t\tnewData = {\n\t\t\t\t...newData,\n\t\t\t\tcore: {\n\t\t\t\t\t...newData?.core,\n\t\t\t\t\t[ setting ]: data[ 'core/edit-post' ][ setting ],\n\t\t\t\t},\n\t\t\t};\n\t\t\tdelete newData[ 'core/edit-post' ][ setting ];\n\t\t}\n\n\t\tif ( data?.[ 'core/edit-site' ]?.[ setting ] !== undefined ) {\n\t\t\tdelete newData[ 'core/edit-site' ][ setting ];\n\t\t}\n\t} );\n\n\tif ( Object.keys( newData?.[ 'core/edit-post' ] ?? {} )?.length === 0 ) {\n\t\tdelete newData[ 'core/edit-post' ];\n\t}\n\n\tif ( Object.keys( newData?.[ 'core/edit-site' ] ?? {} )?.length === 0 ) {\n\t\tdelete newData[ 'core/edit-site' ];\n\t}\n\n\treturn newData;\n}\n"],"mappings":";;;;;;AAAA;AACA;AAC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AOR,OAAO,CAAE,gBAAgB,CAAE;EACnC;EAEA,OAAOA,OAAO;AACf"}
1
+ {"version":3,"names":["convertEditorSettings","data","_newData$coreEditPo","_newData$coreEditSi","newData","settingsToMoveToCore","forEach","setting","undefined","core","Object","keys","length"],"sources":["@wordpress/preferences-persistence/src/migrations/preferences-package-data/convert-editor-settings.js"],"sourcesContent":["/**\n * Internal dependencies\n */\n\nexport default function convertEditorSettings( data ) {\n\tlet newData = data;\n\tconst settingsToMoveToCore = [\n\t\t'allowRightClickOverrides',\n\t\t'distractionFree',\n\t\t'editorMode',\n\t\t'fixedToolbar',\n\t\t'focusMode',\n\t\t'hiddenBlockTypes',\n\t\t'inactivePanels',\n\t\t'keepCaretInsideBlock',\n\t\t'mostUsedBlocks',\n\t\t'openPanels',\n\t\t'showBlockBreadcrumbs',\n\t\t'showIconLabels',\n\t\t'showListViewByDefault',\n\t\t'isPublishSidebarEnabled',\n\t\t'isComplementaryAreaVisible',\n\t\t'pinnedItems',\n\t];\n\n\tsettingsToMoveToCore.forEach( ( setting ) => {\n\t\tif ( data?.[ 'core/edit-post' ]?.[ setting ] !== undefined ) {\n\t\t\tnewData = {\n\t\t\t\t...newData,\n\t\t\t\tcore: {\n\t\t\t\t\t...newData?.core,\n\t\t\t\t\t[ setting ]: data[ 'core/edit-post' ][ setting ],\n\t\t\t\t},\n\t\t\t};\n\t\t\tdelete newData[ 'core/edit-post' ][ setting ];\n\t\t}\n\n\t\tif ( data?.[ 'core/edit-site' ]?.[ setting ] !== undefined ) {\n\t\t\tdelete newData[ 'core/edit-site' ][ setting ];\n\t\t}\n\t} );\n\n\tif ( Object.keys( newData?.[ 'core/edit-post' ] ?? {} )?.length === 0 ) {\n\t\tdelete newData[ 'core/edit-post' ];\n\t}\n\n\tif ( Object.keys( newData?.[ 'core/edit-site' ] ?? {} )?.length === 0 ) {\n\t\tdelete newData[ 'core/edit-site' ];\n\t}\n\n\treturn newData;\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;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EAAES,MAAM,KAAK,CAAC,EAAG;IACvE,OAAOR,OAAO,CAAE,gBAAgB,CAAE;EACnC;EAEA,OAAOA,OAAO;AACf","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["_convertComplementaryAreas","_interopRequireDefault","require","_convertEditorSettings","convertPreferencesPackageData","data","newData","convertComplementaryAreas","convertEditorSettings"],"sources":["@wordpress/preferences-persistence/src/migrations/preferences-package-data/index.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport convertComplementaryAreas from './convert-complementary-areas';\nimport convertEditorSettings from './convert-editor-settings';\n\nexport default function convertPreferencesPackageData( data ) {\n\tlet newData = convertComplementaryAreas( data );\n\tnewData = convertEditorSettings( newData );\n\treturn newData;\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,0BAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,sBAAA,GAAAF,sBAAA,CAAAC,OAAA;AAJA;AACA;AACA;;AAIe,SAASE,6BAA6BA,CAAEC,IAAI,EAAG;EAC7D,IAAIC,OAAO,GAAG,IAAAC,kCAAyB,EAAEF,IAAK,CAAC;EAC/CC,OAAO,GAAG,IAAAE,8BAAqB,EAAEF,OAAQ,CAAC;EAC1C,OAAOA,OAAO;AACf"}
1
+ {"version":3,"names":["_convertComplementaryAreas","_interopRequireDefault","require","_convertEditorSettings","convertPreferencesPackageData","data","newData","convertComplementaryAreas","convertEditorSettings"],"sources":["@wordpress/preferences-persistence/src/migrations/preferences-package-data/index.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport convertComplementaryAreas from './convert-complementary-areas';\nimport convertEditorSettings from './convert-editor-settings';\n\nexport default function convertPreferencesPackageData( data ) {\n\tlet newData = convertComplementaryAreas( data );\n\tnewData = convertEditorSettings( newData );\n\treturn newData;\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,0BAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,sBAAA,GAAAF,sBAAA,CAAAC,OAAA;AAJA;AACA;AACA;;AAIe,SAASE,6BAA6BA,CAAEC,IAAI,EAAG;EAC7D,IAAIC,OAAO,GAAG,IAAAC,kCAAyB,EAAEF,IAAK,CAAC;EAC/CC,OAAO,GAAG,IAAAE,8BAAqB,EAAEF,OAAQ,CAAC;EAC1C,OAAOA,OAAO;AACf","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["debounceAsync","func","delayMS","timeoutId","activePromise","debounced","args","Promise","resolve","reject","then","thenArgs","catch","error","finally","clearTimeout","setTimeout"],"sources":["@wordpress/preferences-persistence/src/create/debounce-async.js"],"sourcesContent":["/**\n * Performs a leading edge debounce of async functions.\n *\n * If three functions are throttled at the same time:\n * - The first happens immediately.\n * - The second is never called.\n * - The third happens `delayMS` milliseconds after the first has resolved.\n *\n * This is distinct from `{ debounce } from @wordpress/compose` in that it\n * waits for promise resolution.\n *\n * @param {Function} func A function that returns a promise.\n * @param {number} delayMS A delay in milliseconds.\n *\n * @return {Function} A function that debounce whatever function is passed\n * to it.\n */\nexport default function debounceAsync( func, delayMS ) {\n\tlet timeoutId;\n\tlet activePromise;\n\n\treturn async function debounced( ...args ) {\n\t\t// This is a leading edge debounce. If there's no promise or timeout\n\t\t// in progress, call the debounced function immediately.\n\t\tif ( ! activePromise && ! timeoutId ) {\n\t\t\treturn new Promise( ( resolve, reject ) => {\n\t\t\t\t// Keep a reference to the promise.\n\t\t\t\tactivePromise = func( ...args )\n\t\t\t\t\t.then( ( ...thenArgs ) => {\n\t\t\t\t\t\tresolve( ...thenArgs );\n\t\t\t\t\t} )\n\t\t\t\t\t.catch( ( error ) => {\n\t\t\t\t\t\treject( error );\n\t\t\t\t\t} )\n\t\t\t\t\t.finally( () => {\n\t\t\t\t\t\t// As soon this promise is complete, clear the way for the\n\t\t\t\t\t\t// next one to happen immediately.\n\t\t\t\t\t\tactivePromise = null;\n\t\t\t\t\t} );\n\t\t\t} );\n\t\t}\n\n\t\tif ( activePromise ) {\n\t\t\t// Let any active promises finish before queuing the next request.\n\t\t\tawait activePromise;\n\t\t}\n\n\t\t// Clear any active timeouts, abandoning any requests that have\n\t\t// been queued but not been made.\n\t\tif ( timeoutId ) {\n\t\t\tclearTimeout( timeoutId );\n\t\t\ttimeoutId = null;\n\t\t}\n\n\t\t// Trigger any trailing edge calls to the function.\n\t\treturn new Promise( ( resolve, reject ) => {\n\t\t\t// Schedule the next request but with a delay.\n\t\t\ttimeoutId = setTimeout( () => {\n\t\t\t\tactivePromise = func( ...args )\n\t\t\t\t\t.then( ( ...thenArgs ) => {\n\t\t\t\t\t\tresolve( ...thenArgs );\n\t\t\t\t\t} )\n\t\t\t\t\t.catch( ( error ) => {\n\t\t\t\t\t\treject( error );\n\t\t\t\t\t} )\n\t\t\t\t\t.finally( () => {\n\t\t\t\t\t\t// As soon this promise is complete, clear the way for the\n\t\t\t\t\t\t// next one to happen immediately.\n\t\t\t\t\t\tactivePromise = null;\n\t\t\t\t\t\ttimeoutId = null;\n\t\t\t\t\t} );\n\t\t\t}, delayMS );\n\t\t} );\n\t};\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASA,aAAaA,CAAEC,IAAI,EAAEC,OAAO,EAAG;EACtD,IAAIC,SAAS;EACb,IAAIC,aAAa;EAEjB,OAAO,eAAeC,SAASA,CAAE,GAAGC,IAAI,EAAG;IAC1C;IACA;IACA,IAAK,CAAEF,aAAa,IAAI,CAAED,SAAS,EAAG;MACrC,OAAO,IAAII,OAAO,CAAE,CAAEC,OAAO,EAAEC,MAAM,KAAM;QAC1C;QACAL,aAAa,GAAGH,IAAI,CAAE,GAAGK,IAAK,CAAC,CAC7BI,IAAI,CAAE,CAAE,GAAGC,QAAQ,KAAM;UACzBH,OAAO,CAAE,GAAGG,QAAS,CAAC;QACvB,CAAE,CAAC,CACFC,KAAK,CAAIC,KAAK,IAAM;UACpBJ,MAAM,CAAEI,KAAM,CAAC;QAChB,CAAE,CAAC,CACFC,OAAO,CAAE,MAAM;UACf;UACA;UACAV,aAAa,GAAG,IAAI;QACrB,CAAE,CAAC;MACL,CAAE,CAAC;IACJ;IAEA,IAAKA,aAAa,EAAG;MACpB;MACA,MAAMA,aAAa;IACpB;;IAEA;IACA;IACA,IAAKD,SAAS,EAAG;MAChBY,YAAY,CAAEZ,SAAU,CAAC;MACzBA,SAAS,GAAG,IAAI;IACjB;;IAEA;IACA,OAAO,IAAII,OAAO,CAAE,CAAEC,OAAO,EAAEC,MAAM,KAAM;MAC1C;MACAN,SAAS,GAAGa,UAAU,CAAE,MAAM;QAC7BZ,aAAa,GAAGH,IAAI,CAAE,GAAGK,IAAK,CAAC,CAC7BI,IAAI,CAAE,CAAE,GAAGC,QAAQ,KAAM;UACzBH,OAAO,CAAE,GAAGG,QAAS,CAAC;QACvB,CAAE,CAAC,CACFC,KAAK,CAAIC,KAAK,IAAM;UACpBJ,MAAM,CAAEI,KAAM,CAAC;QAChB,CAAE,CAAC,CACFC,OAAO,CAAE,MAAM;UACf;UACA;UACAV,aAAa,GAAG,IAAI;UACpBD,SAAS,GAAG,IAAI;QACjB,CAAE,CAAC;MACL,CAAC,EAAED,OAAQ,CAAC;IACb,CAAE,CAAC;EACJ,CAAC;AACF"}
1
+ {"version":3,"names":["debounceAsync","func","delayMS","timeoutId","activePromise","debounced","args","Promise","resolve","reject","then","thenArgs","catch","error","finally","clearTimeout","setTimeout"],"sources":["@wordpress/preferences-persistence/src/create/debounce-async.js"],"sourcesContent":["/**\n * Performs a leading edge debounce of async functions.\n *\n * If three functions are throttled at the same time:\n * - The first happens immediately.\n * - The second is never called.\n * - The third happens `delayMS` milliseconds after the first has resolved.\n *\n * This is distinct from `{ debounce } from @wordpress/compose` in that it\n * waits for promise resolution.\n *\n * @param {Function} func A function that returns a promise.\n * @param {number} delayMS A delay in milliseconds.\n *\n * @return {Function} A function that debounce whatever function is passed\n * to it.\n */\nexport default function debounceAsync( func, delayMS ) {\n\tlet timeoutId;\n\tlet activePromise;\n\n\treturn async function debounced( ...args ) {\n\t\t// This is a leading edge debounce. If there's no promise or timeout\n\t\t// in progress, call the debounced function immediately.\n\t\tif ( ! activePromise && ! timeoutId ) {\n\t\t\treturn new Promise( ( resolve, reject ) => {\n\t\t\t\t// Keep a reference to the promise.\n\t\t\t\tactivePromise = func( ...args )\n\t\t\t\t\t.then( ( ...thenArgs ) => {\n\t\t\t\t\t\tresolve( ...thenArgs );\n\t\t\t\t\t} )\n\t\t\t\t\t.catch( ( error ) => {\n\t\t\t\t\t\treject( error );\n\t\t\t\t\t} )\n\t\t\t\t\t.finally( () => {\n\t\t\t\t\t\t// As soon this promise is complete, clear the way for the\n\t\t\t\t\t\t// next one to happen immediately.\n\t\t\t\t\t\tactivePromise = null;\n\t\t\t\t\t} );\n\t\t\t} );\n\t\t}\n\n\t\tif ( activePromise ) {\n\t\t\t// Let any active promises finish before queuing the next request.\n\t\t\tawait activePromise;\n\t\t}\n\n\t\t// Clear any active timeouts, abandoning any requests that have\n\t\t// been queued but not been made.\n\t\tif ( timeoutId ) {\n\t\t\tclearTimeout( timeoutId );\n\t\t\ttimeoutId = null;\n\t\t}\n\n\t\t// Trigger any trailing edge calls to the function.\n\t\treturn new Promise( ( resolve, reject ) => {\n\t\t\t// Schedule the next request but with a delay.\n\t\t\ttimeoutId = setTimeout( () => {\n\t\t\t\tactivePromise = func( ...args )\n\t\t\t\t\t.then( ( ...thenArgs ) => {\n\t\t\t\t\t\tresolve( ...thenArgs );\n\t\t\t\t\t} )\n\t\t\t\t\t.catch( ( error ) => {\n\t\t\t\t\t\treject( error );\n\t\t\t\t\t} )\n\t\t\t\t\t.finally( () => {\n\t\t\t\t\t\t// As soon this promise is complete, clear the way for the\n\t\t\t\t\t\t// next one to happen immediately.\n\t\t\t\t\t\tactivePromise = null;\n\t\t\t\t\t\ttimeoutId = null;\n\t\t\t\t\t} );\n\t\t\t}, delayMS );\n\t\t} );\n\t};\n}\n"],"mappings":"AAAA;AACA;AAC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AAa,GAAG,IAAI;UACpBD,SAAS,GAAG,IAAI;QACjB,CAAE,CAAC;MACL,CAAC,EAAED,OAAQ,CAAC;IACb,CAAE,CAAC;EACJ,CAAC;AACF","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["apiFetch","debounceAsync","EMPTY_OBJECT","localStorage","window","create","preloadedData","localStorageRestoreKey","requestDebounceMS","cache","debouncedApiFetch","get","user","path","serverData","meta","persisted_preferences","localData","JSON","parse","getItem","serverTimestamp","Date","_modified","localTimestamp","set","newData","dataWithTimestamp","toISOString","setItem","stringify","method","keepalive","data","catch"],"sources":["@wordpress/preferences-persistence/src/create/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\n\n/**\n * Internal dependencies\n */\nimport debounceAsync from './debounce-async';\n\nconst EMPTY_OBJECT = {};\nconst localStorage = window.localStorage;\n\n/**\n * Creates a persistence layer that stores data in WordPress user meta via the\n * REST API.\n *\n * @param {Object} options\n * @param {?Object} options.preloadedData Any persisted preferences data that should be preloaded.\n * When set, the persistence layer will avoid fetching data\n * from the REST API.\n * @param {?string} options.localStorageRestoreKey The key to use for restoring the localStorage backup, used\n * when the persistence layer calls `localStorage.getItem` or\n * `localStorage.setItem`.\n * @param {?number} options.requestDebounceMS Debounce requests to the API so that they only occur at\n * minimum every `requestDebounceMS` milliseconds, and don't\n * swamp the server. Defaults to 2500ms.\n *\n * @return {Object} A persistence layer for WordPress user meta.\n */\nexport default function create( {\n\tpreloadedData,\n\tlocalStorageRestoreKey = 'WP_PREFERENCES_RESTORE_DATA',\n\trequestDebounceMS = 2500,\n} = {} ) {\n\tlet cache = preloadedData;\n\tconst debouncedApiFetch = debounceAsync( apiFetch, requestDebounceMS );\n\n\tasync function get() {\n\t\tif ( cache ) {\n\t\t\treturn cache;\n\t\t}\n\n\t\tconst user = await apiFetch( {\n\t\t\tpath: '/wp/v2/users/me?context=edit',\n\t\t} );\n\n\t\tconst serverData = user?.meta?.persisted_preferences;\n\t\tconst localData = JSON.parse(\n\t\t\tlocalStorage.getItem( localStorageRestoreKey )\n\t\t);\n\n\t\t// Date parse returns NaN for invalid input. Coerce anything invalid\n\t\t// into a conveniently comparable zero.\n\t\tconst serverTimestamp = Date.parse( serverData?._modified ) || 0;\n\t\tconst localTimestamp = Date.parse( localData?._modified ) || 0;\n\n\t\t// Prefer server data if it exists and is more recent.\n\t\t// Otherwise fallback to localStorage data.\n\t\tif ( serverData && serverTimestamp >= localTimestamp ) {\n\t\t\tcache = serverData;\n\t\t} else if ( localData ) {\n\t\t\tcache = localData;\n\t\t} else {\n\t\t\tcache = EMPTY_OBJECT;\n\t\t}\n\n\t\treturn cache;\n\t}\n\n\tfunction set( newData ) {\n\t\tconst dataWithTimestamp = {\n\t\t\t...newData,\n\t\t\t_modified: new Date().toISOString(),\n\t\t};\n\t\tcache = dataWithTimestamp;\n\n\t\t// Store data in local storage as a fallback. If for some reason the\n\t\t// api request does not complete or becomes unavailable, this data\n\t\t// can be used to restore preferences.\n\t\tlocalStorage.setItem(\n\t\t\tlocalStorageRestoreKey,\n\t\t\tJSON.stringify( dataWithTimestamp )\n\t\t);\n\n\t\t// The user meta endpoint seems susceptible to errors when consecutive\n\t\t// requests are made in quick succession. Ensure there's a gap between\n\t\t// any consecutive requests.\n\t\t//\n\t\t// Catch and do nothing with errors from the REST API.\n\t\tdebouncedApiFetch( {\n\t\t\tpath: '/wp/v2/users/me',\n\t\t\tmethod: 'PUT',\n\t\t\t// `keepalive` will still send the request in the background,\n\t\t\t// even when a browser unload event might interrupt it.\n\t\t\t// This should hopefully make things more resilient.\n\t\t\t// This does have a size limit of 64kb, but the data is usually\n\t\t\t// much less.\n\t\t\tkeepalive: true,\n\t\t\tdata: {\n\t\t\t\tmeta: {\n\t\t\t\t\tpersisted_preferences: dataWithTimestamp,\n\t\t\t\t},\n\t\t\t},\n\t\t} ).catch( () => {} );\n\t}\n\n\treturn {\n\t\tget,\n\t\tset,\n\t};\n}\n"],"mapp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,OAAOO,KAAK;EACb;EAEA,SAASgB,GAAGA,CAAEC,OAAO,EAAG;IACvB,MAAMC,iBAAiB,GAAG;MACzB,GAAGD,OAAO;MACVH,SAAS,EAAE,IAAID,IAAI,CAAC,CAAC,CAACM,WAAW,CAAC;IACnC,CAAC;IACDnB,KAAK,GAAGkB,iBAAiB;;IAEzB;IACA;IACA;IACAxB,YAAY,CAAC0B,OAAO,CACnBtB,sBAAsB,EACtBW,IAAI,CAACY,SAAS,CAAEH,iBAAkB,CACnC,CAAC;;IAED;IACA;IACA;IACA;IACA;IACAjB,iBAAiB,CAAE;MAClBG,IAAI,EAAE,iBAAiB;MACvBkB,MAAM,EAAE,KAAK;MACb;MACA;MACA;MACA;MACA;MACAC,SAAS,EAAE,IAAI;MACfC,IAAI,EAAE;QACLlB,IAAI,EAAE;UACLC,qBAAqB,EAAEW;QACxB;MACD;IACD,CAAE,CAAC,CAACO,KAAK,CAAE,MAAM,CAAC,CAAE,CAAC;EACtB;EAEA,OAAO;IACNvB,GAAG;IACHc;EACD,CAAC;AACF"}
1
+ {"version":3,"names":["apiFetch","debounceAsync","EMPTY_OBJECT","localStorage","window","create","preloadedData","localStorageRestoreKey","requestDebounceMS","cache","debouncedApiFetch","get","user","path","serverData","meta","persisted_preferences","localData","JSON","parse","getItem","serverTimestamp","Date","_modified","localTimestamp","set","newData","dataWithTimestamp","toISOString","setItem","stringify","method","keepalive","data","catch"],"sources":["@wordpress/preferences-persistence/src/create/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\n\n/**\n * Internal dependencies\n */\nimport debounceAsync from './debounce-async';\n\nconst EMPTY_OBJECT = {};\nconst localStorage = window.localStorage;\n\n/**\n * Creates a persistence layer that stores data in WordPress user meta via the\n * REST API.\n *\n * @param {Object} options\n * @param {?Object} options.preloadedData Any persisted preferences data that should be preloaded.\n * When set, the persistence layer will avoid fetching data\n * from the REST API.\n * @param {?string} options.localStorageRestoreKey The key to use for restoring the localStorage backup, used\n * when the persistence layer calls `localStorage.getItem` or\n * `localStorage.setItem`.\n * @param {?number} options.requestDebounceMS Debounce requests to the API so that they only occur at\n * minimum every `requestDebounceMS` milliseconds, and don't\n * swamp the server. Defaults to 2500ms.\n *\n * @return {Object} A persistence layer for WordPress user meta.\n */\nexport default function create( {\n\tpreloadedData,\n\tlocalStorageRestoreKey = 'WP_PREFERENCES_RESTORE_DATA',\n\trequestDebounceMS = 2500,\n} = {} ) {\n\tlet cache = preloadedData;\n\tconst debouncedApiFetch = debounceAsync( apiFetch, requestDebounceMS );\n\n\tasync function get() {\n\t\tif ( cache ) {\n\t\t\treturn cache;\n\t\t}\n\n\t\tconst user = await apiFetch( {\n\t\t\tpath: '/wp/v2/users/me?context=edit',\n\t\t} );\n\n\t\tconst serverData = user?.meta?.persisted_preferences;\n\t\tconst localData = JSON.parse(\n\t\t\tlocalStorage.getItem( localStorageRestoreKey )\n\t\t);\n\n\t\t// Date parse returns NaN for invalid input. Coerce anything invalid\n\t\t// into a conveniently comparable zero.\n\t\tconst serverTimestamp = Date.parse( serverData?._modified ) || 0;\n\t\tconst localTimestamp = Date.parse( localData?._modified ) || 0;\n\n\t\t// Prefer server data if it exists and is more recent.\n\t\t// Otherwise fallback to localStorage data.\n\t\tif ( serverData && serverTimestamp >= localTimestamp ) {\n\t\t\tcache = serverData;\n\t\t} else if ( localData ) {\n\t\t\tcache = localData;\n\t\t} else {\n\t\t\tcache = EMPTY_OBJECT;\n\t\t}\n\n\t\treturn cache;\n\t}\n\n\tfunction set( newData ) {\n\t\tconst dataWithTimestamp = {\n\t\t\t...newData,\n\t\t\t_modified: new Date().toISOString(),\n\t\t};\n\t\tcache = dataWithTimestamp;\n\n\t\t// Store data in local storage as a fallback. If for some reason the\n\t\t// api request does not complete or becomes unavailable, this data\n\t\t// can be used to restore preferences.\n\t\tlocalStorage.setItem(\n\t\t\tlocalStorageRestoreKey,\n\t\t\tJSON.stringify( dataWithTimestamp )\n\t\t);\n\n\t\t// The user meta endpoint seems susceptible to errors when consecutive\n\t\t// requests are made in quick succession. Ensure there's a gap between\n\t\t// any consecutive requests.\n\t\t//\n\t\t// Catch and do nothing with errors from the REST API.\n\t\tdebouncedApiFetch( {\n\t\t\tpath: '/wp/v2/users/me',\n\t\t\tmethod: 'PUT',\n\t\t\t// `keepalive` will still send the request in the background,\n\t\t\t// even when a browser unload event might interrupt it.\n\t\t\t// This should hopefully make things more resilient.\n\t\t\t// This does have a size limit of 64kb, but the data is usually\n\t\t\t// much less.\n\t\t\tkeepalive: true,\n\t\t\tdata: {\n\t\t\t\tmeta: {\n\t\t\t\t\tpersisted_preferences: dataWithTimestamp,\n\t\t\t\t},\n\t\t\t},\n\t\t} ).catch( () => {} );\n\t}\n\n\treturn {\n\t\tget,\n\t\tset,\n\t};\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,QAAQ,MAAM,sBAAsB;;AAE3C;AACA;AACA;AACA,OAAOC,aAAa,MAAM,kBAAkB;AAE5C,MAAMC,YAAY,GAAG,CAAC,CAAC;AACvB,MAAMC,YAAY,GAAGC,MAAM,CAACD,YAAY;;AAExC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASE,MAAMA,CAAE;EAC/BC,aAAa;EACbC,sBAAsB,GAAG,6BAA6B;EACtDC,iBAAiB,GAAG;AACrB,CAAC,GAAG,CAAC,CAAC,EAAG;EACR,IAAIC,KAAK,GAAGH,aAAa;EACzB,MAAMI,iBAAiB,GAAGT,aAAa,CAAED,QAAQ,EAAEQ,iBAAkB,CAAC;EAEtE,eAAeG,GAAGA,CAAA,EAAG;IACpB,IAAKF,KAAK,EAAG;MACZ,OAAOA,KAAK;IACb;IAEA,MAAMG,IAAI,GAAG,MAAMZ,QAAQ,CAAE;MAC5Ba,IAAI,EAAE;IACP,CAAE,CAAC;IAEH,MAAMC,UAAU,GAAGF,IAAI,EAAEG,IAAI,EAAEC,qBAAqB;IACpD,MAAMC,SAAS,GAAGC,IAAI,CAACC,KAAK,CAC3BhB,YAAY,CAACiB,OAAO,CAAEb,sBAAuB,CAC9C,CAAC;;IAED;IACA;IACA,MAAMc,eAAe,GAAGC,IAAI,CAACH,KAAK,CAAEL,UAAU,EAAES,SAAU,CAAC,IAAI,CAAC;IAChE,MAAMC,cAAc,GAAGF,IAAI,CAACH,KAAK,CAAEF,SAAS,EAAEM,SAAU,CAAC,IAAI,CAAC;;IAE9D;IACA;IACA,IAAKT,UAAU,IAAIO,eAAe,IAAIG,cAAc,EAAG;MACtDf,KAAK,GAAGK,UAAU;IACnB,CAAC,MAAM,IAAKG,SAAS,EAAG;MACvBR,KAAK,GAAGQ,SAAS;IAClB,CAAC,MAAM;MACNR,KAAK,GAAGP,YAAY;IACrB;IAEA,OAAOO,KAAK;EACb;EAEA,SAASgB,GAAGA,CAAEC,OAAO,EAAG;IACvB,MAAMC,iBAAiB,GAAG;MACzB,GAAGD,OAAO;MACVH,SAAS,EAAE,IAAID,IAAI,CAAC,CAAC,CAACM,WAAW,CAAC;IACnC,CAAC;IACDnB,KAAK,GAAGkB,iBAAiB;;IAEzB;IACA;IACA;IACAxB,YAAY,CAAC0B,OAAO,CACnBtB,sBAAsB,EACtBW,IAAI,CAACY,SAAS,CAAEH,iBAAkB,CACnC,CAAC;;IAED;IACA;IACA;IACA;IACA;IACAjB,iBAAiB,CAAE;MAClBG,IAAI,EAAE,iBAAiB;MACvBkB,MAAM,EAAE,KAAK;MACb;MACA;MACA;MACA;MACA;MACAC,SAAS,EAAE,IAAI;MACfC,IAAI,EAAE;QACLlB,IAAI,EAAE;UACLC,qBAAqB,EAAEW;QACxB;MACD;IACD,CAAE,CAAC,CAACO,KAAK,CAAE,MAAM,CAAC,CAAE,CAAC;EACtB;EAEA,OAAO;IACNvB,GAAG;IACHc;EACD,CAAC;AACF","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["create","convertLegacyLocalStorageData","convertPreferencesPackageData","__unstableCreatePersistenceLayer","serverData","userId","localStorageRestoreKey","localData","JSON","parse","window","localStorage","getItem","serverModified","Date","_modified","localModified","preloadedData"],"sources":["@wordpress/preferences-persistence/src/index.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport create from './create';\nimport convertLegacyLocalStorageData from './migrations/legacy-local-storage-data';\nimport convertPreferencesPackageData from './migrations/preferences-package-data';\n\nexport { create };\n\n/**\n * Creates the persistence layer with preloaded data.\n *\n * It prioritizes any data from the server, but falls back first to localStorage\n * restore data, and then to any legacy data.\n *\n * This function is used internally by WordPress in an inline script, so\n * prefixed with `__unstable`.\n *\n * @param {Object} serverData Preferences data preloaded from the server.\n * @param {string} userId The user id.\n *\n * @return {Object} The persistence layer initialized with the preloaded data.\n */\nexport function __unstableCreatePersistenceLayer( serverData, userId ) {\n\tconst localStorageRestoreKey = `WP_PREFERENCES_USER_${ userId }`;\n\tconst localData = JSON.parse(\n\t\twindow.localStorage.getItem( localStorageRestoreKey )\n\t);\n\n\t// Date parse returns NaN for invalid input. Coerce anything invalid\n\t// into a conveniently comparable zero.\n\tconst serverModified =\n\t\tDate.parse( serverData && serverData._modified ) || 0;\n\tconst localModified = Date.parse( localData && localData._modified ) || 0;\n\n\tlet preloadedData;\n\tif ( serverData && serverModified >= localModified ) {\n\t\tpreloadedData = convertPreferencesPackageData( serverData );\n\t} else if ( localData ) {\n\t\tpreloadedData = convertPreferencesPackageData( localData );\n\t} else {\n\t\t// Check if there is data in the legacy format from the old persistence system.\n\t\tpreloadedData = convertLegacyLocalStorageData( userId );\n\t}\n\n\treturn create( {\n\t\tpreloadedData,\n\t\tlocalStorageRestoreKey,\n\t} );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,MAAM,MAAM,UAAU;AAC7B,OAAOC,6BAA6B,MAAM,wCAAwC;AAClF,OAAOC,6BAA6B,MAAM,uCAAuC;AAEjF,SAASF,MAAM;;AAEf;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASG,gCAAgCA,CAAEC,UAAU,EAAEC,MAAM,EAAG;EACtE,MAAMC,sBAAsB,GAAI,uBAAuBD,MAAQ,EAAC;EAChE,MAAME,SAAS,GAAGC,IAAI,CAACC,KAAK,CAC3BC,MAAM,CAACC,YAAY,CAACC,OAAO,CAAEN,sBAAuB,CACrD,CAAC;;EAED;EACA;EACA,MAAMO,cAAc,GACnBC,IAAI,CAACL,KAAK,CAAEL,UAAU,IAAIA,UAAU,CAACW,SAAU,CAAC,IAAI,CAAC;EACtD,MAAMC,aAAa,GAAGF,IAAI,CAACL,KAAK,CAAEF,SAAS,IAAIA,SAAS,CAACQ,SAAU,CAAC,IAAI,CAAC;EAEzE,IAAIE,aAAa;EACjB,IAAKb,UAAU,IAAIS,cAAc,IAAIG,aAAa,EAAG;IACpDC,aAAa,GAAGf,6BAA6B,CAAEE,UAAW,CAAC;EAC5D,CAAC,MAAM,IAAKG,SAAS,EAAG;IACvBU,aAAa,GAAGf,6BAA6B,CAAEK,SAAU,CAAC;EAC3D,CAAC,MAAM;IACN;IACAU,aAAa,GAAGhB,6BAA6B,CAAEI,MAAO,CAAC;EACxD;EAEA,OAAOL,MAAM,CAAE;IACdiB,aAAa;IACbX;EACD,CAAE,CAAC;AACJ"}
1
+ {"version":3,"names":["create","convertLegacyLocalStorageData","convertPreferencesPackageData","__unstableCreatePersistenceLayer","serverData","userId","localStorageRestoreKey","localData","JSON","parse","window","localStorage","getItem","serverModified","Date","_modified","localModified","preloadedData"],"sources":["@wordpress/preferences-persistence/src/index.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport create from './create';\nimport convertLegacyLocalStorageData from './migrations/legacy-local-storage-data';\nimport convertPreferencesPackageData from './migrations/preferences-package-data';\n\nexport { create };\n\n/**\n * Creates the persistence layer with preloaded data.\n *\n * It prioritizes any data from the server, but falls back first to localStorage\n * restore data, and then to any legacy data.\n *\n * This function is used internally by WordPress in an inline script, so\n * prefixed with `__unstable`.\n *\n * @param {Object} serverData Preferences data preloaded from the server.\n * @param {string} userId The user id.\n *\n * @return {Object} The persistence layer initialized with the preloaded data.\n */\nexport function __unstableCreatePersistenceLayer( serverData, userId ) {\n\tconst localStorageRestoreKey = `WP_PREFERENCES_USER_${ userId }`;\n\tconst localData = JSON.parse(\n\t\twindow.localStorage.getItem( localStorageRestoreKey )\n\t);\n\n\t// Date parse returns NaN for invalid input. Coerce anything invalid\n\t// into a conveniently comparable zero.\n\tconst serverModified =\n\t\tDate.parse( serverData && serverData._modified ) || 0;\n\tconst localModified = Date.parse( localData && localData._modified ) || 0;\n\n\tlet preloadedData;\n\tif ( serverData && serverModified >= localModified ) {\n\t\tpreloadedData = convertPreferencesPackageData( serverData );\n\t} else if ( localData ) {\n\t\tpreloadedData = convertPreferencesPackageData( localData );\n\t} else {\n\t\t// Check if there is data in the legacy format from the old persistence system.\n\t\tpreloadedData = convertLegacyLocalStorageData( userId );\n\t}\n\n\treturn create( {\n\t\tpreloadedData,\n\t\tlocalStorageRestoreKey,\n\t} );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,MAAM,MAAM,UAAU;AAC7B,OAAOC,6BAA6B,MAAM,wCAAwC;AAClF,OAAOC,6BAA6B,MAAM,uCAAuC;AAEjF,SAASF,MAAM;;AAEf;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASG,gCAAgCA,CAAEC,UAAU,EAAEC,MAAM,EAAG;EACtE,MAAMC,sBAAsB,GAAI,uBAAuBD,MAAQ,EAAC;EAChE,MAAME,SAAS,GAAGC,IAAI,CAACC,KAAK,CAC3BC,MAAM,CAACC,YAAY,CAACC,OAAO,CAAEN,sBAAuB,CACrD,CAAC;;EAED;EACA;EACA,MAAMO,cAAc,GACnBC,IAAI,CAACL,KAAK,CAAEL,UAAU,IAAIA,UAAU,CAACW,SAAU,CAAC,IAAI,CAAC;EACtD,MAAMC,aAAa,GAAGF,IAAI,CAACL,KAAK,CAAEF,SAAS,IAAIA,SAAS,CAACQ,SAAU,CAAC,IAAI,CAAC;EAEzE,IAAIE,aAAa;EACjB,IAAKb,UAAU,IAAIS,cAAc,IAAIG,aAAa,EAAG;IACpDC,aAAa,GAAGf,6BAA6B,CAAEE,UAAW,CAAC;EAC5D,CAAC,MAAM,IAAKG,SAAS,EAAG;IACvBU,aAAa,GAAGf,6BAA6B,CAAEK,SAAU,CAAC;EAC3D,CAAC,MAAM;IACN;IACAU,aAAa,GAAGhB,6BAA6B,CAAEI,MAAO,CAAC;EACxD;EAEA,OAAOL,MAAM,CAAE;IACdiB,aAAa;IACbX;EACD,CAAE,CAAC;AACJ","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["convertEditPostPanels","preferences","_preferences$panels","panels","Object","keys","reduce","convertedData","panelName","panel","enabled","inactivePanels","push","opened","openPanels"],"sources":["@wordpress/preferences-persistence/src/migrations/legacy-local-storage-data/convert-edit-post-panels.js"],"sourcesContent":["/**\n * Convert the post editor's panels state from:\n * ```\n * {\n * panels: {\n * tags: {\n * enabled: true,\n * opened: true,\n * },\n * permalinks: {\n * enabled: false,\n * opened: false,\n * },\n * },\n * }\n * ```\n *\n * to a new, more concise data structure:\n * {\n * inactivePanels: [\n * 'permalinks',\n * ],\n * openPanels: [\n * 'tags',\n * ],\n * }\n *\n * @param {Object} preferences A preferences object.\n *\n * @return {Object} The converted data.\n */\nexport default function convertEditPostPanels( preferences ) {\n\tconst panels = preferences?.panels ?? {};\n\treturn Object.keys( panels ).reduce(\n\t\t( convertedData, panelName ) => {\n\t\t\tconst panel = panels[ panelName ];\n\n\t\t\tif ( panel?.enabled === false ) {\n\t\t\t\tconvertedData.inactivePanels.push( panelName );\n\t\t\t}\n\n\t\t\tif ( panel?.opened === true ) {\n\t\t\t\tconvertedData.openPanels.push( panelName );\n\t\t\t}\n\n\t\t\treturn convertedData;\n\t\t},\n\t\t{ inactivePanels: [], openPanels: [] }\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASA,qBAAqBA,CAAEC,WAAW,EAAG;EAAA,IAAAC,mBAAA;EAC5D,MAAMC,MAAM,IAAAD,mBAAA,GAAGD,WAAW,EAAEE,MAAM,cAAAD,mBAAA,cAAAA,mBAAA,GAAI,CAAC,CAAC;EACxC,OAAOE,MAAM,CAACC,IAAI,CAAEF,MAAO,CAAC,CAACG,MAAM,CAClC,CAAEC,aAAa,EAAEC,SAAS,KAAM;IAC/B,MAAMC,KAAK,GAAGN,MAAM,CAAEK,SAAS,CAAE;IAEjC,IAAKC,KAAK,EAAEC,OAAO,KAAK,KAAK,EAAG;MAC/BH,aAAa,CAACI,cAAc,CAACC,IAAI,CAAEJ,SAAU,CAAC;IAC/C;IAEA,IAAKC,KAAK,EAAEI,MAAM,KAAK,IAAI,EAAG;MAC7BN,aAAa,CAACO,UAAU,CAACF,IAAI,CAAEJ,SAAU,CAAC;IAC3C;IAEA,OAAOD,aAAa;EACrB,CAAC,EACD;IAAEI,cAAc,EAAE,EAAE;IAAEG,UAAU,EAAE;EAAG,CACtC,CAAC;AACF"}
1
+ {"version":3,"names":["convertEditPostPanels","preferences","_preferences$panels","panels","Object","keys","reduce","convertedData","panelName","panel","enabled","inactivePanels","push","opened","openPanels"],"sources":["@wordpress/preferences-persistence/src/migrations/legacy-local-storage-data/convert-edit-post-panels.js"],"sourcesContent":["/**\n * Convert the post editor's panels state from:\n * ```\n * {\n * panels: {\n * tags: {\n * enabled: true,\n * opened: true,\n * },\n * permalinks: {\n * enabled: false,\n * opened: false,\n * },\n * },\n * }\n * ```\n *\n * to a new, more concise data structure:\n * {\n * inactivePanels: [\n * 'permalinks',\n * ],\n * openPanels: [\n * 'tags',\n * ],\n * }\n *\n * @param {Object} preferences A preferences object.\n *\n * @return {Object} The converted data.\n */\nexport default function convertEditPostPanels( preferences ) {\n\tconst panels = preferences?.panels ?? {};\n\treturn Object.keys( panels ).reduce(\n\t\t( convertedData, panelName ) => {\n\t\t\tconst panel = panels[ panelName ];\n\n\t\t\tif ( panel?.enabled === false ) {\n\t\t\t\tconvertedData.inactivePanels.push( panelName );\n\t\t\t}\n\n\t\t\tif ( panel?.opened === true ) {\n\t\t\t\tconvertedData.openPanels.push( panelName );\n\t\t\t}\n\n\t\t\treturn convertedData;\n\t\t},\n\t\t{ inactivePanels: [], openPanels: [] }\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASA,qBAAqBA,CAAEC,WAAW,EAAG;EAAA,IAAAC,mBAAA;EAC5D,MAAMC,MAAM,IAAAD,mBAAA,GAAGD,WAAW,EAAEE,MAAM,cAAAD,mBAAA,cAAAA,mBAAA,GAAI,CAAC,CAAC;EACxC,OAAOE,MAAM,CAACC,IAAI,CAAEF,MAAO,CAAC,CAACG,MAAM,CAClC,CAAEC,aAAa,EAAEC,SAAS,KAAM;IAC/B,MAAMC,KAAK,GAAGN,MAAM,CAAEK,SAAS,CAAE;IAEjC,IAAKC,KAAK,EAAEC,OAAO,KAAK,KAAK,EAAG;MAC/BH,aAAa,CAACI,cAAc,CAACC,IAAI,CAAEJ,SAAU,CAAC;IAC/C;IAEA,IAAKC,KAAK,EAAEI,MAAM,KAAK,IAAI,EAAG;MAC7BN,aAAa,CAACO,UAAU,CAACF,IAAI,CAAEJ,SAAU,CAAC;IAC3C;IAEA,OAAOD,aAAa;EACrB,CAAC,EACD;IAAEI,cAAc,EAAE,EAAE;IAAEG,UAAU,EAAE;EAAG,CACtC,CAAC;AACF","ignoreList":[]}
@@ -64,7 +64,11 @@ export function convertLegacyData(data) {
64
64
  }, 'panels', convertEditPostPanels);
65
65
  data = moveIndividualPreference(data, {
66
66
  from: 'core/editor',
67
- to: 'core/edit-post'
67
+ to: 'core'
68
+ }, 'isPublishSidebarEnabled');
69
+ data = moveIndividualPreference(data, {
70
+ from: 'core/edit-post',
71
+ to: 'core'
68
72
  }, 'isPublishSidebarEnabled');
69
73
  data = moveIndividualPreference(data, {
70
74
  from: 'core/edit-site',
@@ -1 +1 @@
1
- {"version":3,"names":["moveFeaturePreferences","moveThirdPartyFeaturePreferences","moveIndividualPreference","moveInterfaceEnableItems","convertEditPostPanels","getLegacyData","userId","key","unparsedData","window","localStorage","getItem","JSON","parse","convertLegacyData","data","from","to","preferences","convertLegacyLocalStorageData"],"sources":["@wordpress/preferences-persistence/src/migrations/legacy-local-storage-data/index.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport moveFeaturePreferences from './move-feature-preferences';\nimport moveThirdPartyFeaturePreferences from './move-third-party-feature-preferences';\nimport moveIndividualPreference from './move-individual-preference';\nimport moveInterfaceEnableItems from './move-interface-enable-items';\nimport convertEditPostPanels from './convert-edit-post-panels';\n\n/**\n * Gets the legacy local storage data for a given user.\n *\n * @param {string | number} userId The user id.\n *\n * @return {Object | null} The local storage data.\n */\nfunction getLegacyData( userId ) {\n\tconst key = `WP_DATA_USER_${ userId }`;\n\tconst unparsedData = window.localStorage.getItem( key );\n\treturn JSON.parse( unparsedData );\n}\n\n/**\n * Converts data from the old `@wordpress/data` package format.\n *\n * @param {Object | null | undefined} data The legacy data in its original format.\n *\n * @return {Object | undefined} The converted data or `undefined` if there was\n * nothing to convert.\n */\nexport function convertLegacyData( data ) {\n\tif ( ! data ) {\n\t\treturn;\n\t}\n\n\t// Move boolean feature preferences from each editor into the\n\t// preferences store data structure.\n\tdata = moveFeaturePreferences( data, 'core/edit-widgets' );\n\tdata = moveFeaturePreferences( data, 'core/customize-widgets' );\n\tdata = moveFeaturePreferences( data, 'core/edit-post' );\n\tdata = moveFeaturePreferences( data, 'core/edit-site' );\n\n\t// Move third party boolean feature preferences from the interface package\n\t// to the preferences store data structure.\n\tdata = moveThirdPartyFeaturePreferences( data );\n\n\t// Move and convert the interface store's `enableItems` data into the\n\t// preferences data structure.\n\tdata = moveInterfaceEnableItems( data );\n\n\t// Move individual ad-hoc preferences from various packages into the\n\t// preferences store data structure.\n\tdata = moveIndividualPreference(\n\t\tdata,\n\t\t{ from: 'core/edit-post', to: 'core/edit-post' },\n\t\t'hiddenBlockTypes'\n\t);\n\tdata = moveIndividualPreference(\n\t\tdata,\n\t\t{ from: 'core/edit-post', to: 'core/edit-post' },\n\t\t'editorMode'\n\t);\n\tdata = moveIndividualPreference(\n\t\tdata,\n\t\t{ from: 'core/edit-post', to: 'core/edit-post' },\n\t\t'panels',\n\t\tconvertEditPostPanels\n\t);\n\tdata = moveIndividualPreference(\n\t\tdata,\n\t\t{ from: 'core/editor', to: 'core/edit-post' },\n\t\t'isPublishSidebarEnabled'\n\t);\n\tdata = moveIndividualPreference(\n\t\tdata,\n\t\t{ from: 'core/edit-site', to: 'core/edit-site' },\n\t\t'editorMode'\n\t);\n\n\t// The new system is only concerned with persisting\n\t// 'core/preferences' preferences reducer, so only return that.\n\treturn data?.[ 'core/preferences' ]?.preferences;\n}\n\n/**\n * Gets the legacy local storage data for the given user and returns the\n * data converted to the new format.\n *\n * @param {string | number} userId The user id.\n *\n * @return {Object | undefined} The converted data or undefined if no local\n * storage data could be found.\n */\nexport default function convertLegacyLocalStorageData( userId ) {\n\tconst data = getLegacyData( userId );\n\treturn convertLegacyData( data );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,sBAAsB,MAAM,4BAA4B;AAC/D,OAAOC,gCAAgC,MAAM,wCAAwC;AACrF,OAAOC,wBAAwB,MAAM,8BAA8B;AACnE,OAAOC,wBAAwB,MAAM,+BAA+B;AACpE,OAAOC,qBAAqB,MAAM,4BAA4B;;AAE9D;AACA;AACA;AACA;AACA;AACA;AACA;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EAAiB,CAAC,EAC7C,yBACD,CAAC;EACDF,IAAI,GAAGb,wBAAwB,CAC9Ba,IAAI,EACJ;IAAEC,IAAI,EAAE,gBAAgB;IAAEC,EAAE,EAAE;EAAiB,CAAC,EAChD,YACD,CAAC;;EAED;EACA;EACA,OAAOF,IAAI,GAAI,kBAAkB,CAAE,EAAEG,WAAW;AACjD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,6BAA6BA,CAAEb,MAAM,EAAG;EAC/D,MAAMS,IAAI,GAAGV,aAAa,CAAEC,MAAO,CAAC;EACpC,OAAOQ,iBAAiB,CAAEC,IAAK,CAAC;AACjC"}
1
+ {"version":3,"names":["moveFeaturePreferences","moveThirdPartyFeaturePreferences","moveIndividualPreference","moveInterfaceEnableItems","convertEditPostPanels","getLegacyData","userId","key","unparsedData","window","localStorage","getItem","JSON","parse","convertLegacyData","data","from","to","preferences","convertLegacyLocalStorageData"],"sources":["@wordpress/preferences-persistence/src/migrations/legacy-local-storage-data/index.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport moveFeaturePreferences from './move-feature-preferences';\nimport moveThirdPartyFeaturePreferences from './move-third-party-feature-preferences';\nimport moveIndividualPreference from './move-individual-preference';\nimport moveInterfaceEnableItems from './move-interface-enable-items';\nimport convertEditPostPanels from './convert-edit-post-panels';\n\n/**\n * Gets the legacy local storage data for a given user.\n *\n * @param {string | number} userId The user id.\n *\n * @return {Object | null} The local storage data.\n */\nfunction getLegacyData( userId ) {\n\tconst key = `WP_DATA_USER_${ userId }`;\n\tconst unparsedData = window.localStorage.getItem( key );\n\treturn JSON.parse( unparsedData );\n}\n\n/**\n * Converts data from the old `@wordpress/data` package format.\n *\n * @param {Object | null | undefined} data The legacy data in its original format.\n *\n * @return {Object | undefined} The converted data or `undefined` if there was\n * nothing to convert.\n */\nexport function convertLegacyData( data ) {\n\tif ( ! data ) {\n\t\treturn;\n\t}\n\n\t// Move boolean feature preferences from each editor into the\n\t// preferences store data structure.\n\tdata = moveFeaturePreferences( data, 'core/edit-widgets' );\n\tdata = moveFeaturePreferences( data, 'core/customize-widgets' );\n\tdata = moveFeaturePreferences( data, 'core/edit-post' );\n\tdata = moveFeaturePreferences( data, 'core/edit-site' );\n\n\t// Move third party boolean feature preferences from the interface package\n\t// to the preferences store data structure.\n\tdata = moveThirdPartyFeaturePreferences( data );\n\n\t// Move and convert the interface store's `enableItems` data into the\n\t// preferences data structure.\n\tdata = moveInterfaceEnableItems( data );\n\n\t// Move individual ad-hoc preferences from various packages into the\n\t// preferences store data structure.\n\tdata = moveIndividualPreference(\n\t\tdata,\n\t\t{ from: 'core/edit-post', to: 'core/edit-post' },\n\t\t'hiddenBlockTypes'\n\t);\n\tdata = moveIndividualPreference(\n\t\tdata,\n\t\t{ from: 'core/edit-post', to: 'core/edit-post' },\n\t\t'editorMode'\n\t);\n\tdata = moveIndividualPreference(\n\t\tdata,\n\t\t{ from: 'core/edit-post', to: 'core/edit-post' },\n\t\t'panels',\n\t\tconvertEditPostPanels\n\t);\n\tdata = moveIndividualPreference(\n\t\tdata,\n\t\t{ from: 'core/editor', to: 'core' },\n\t\t'isPublishSidebarEnabled'\n\t);\n\tdata = moveIndividualPreference(\n\t\tdata,\n\t\t{ from: 'core/edit-post', to: 'core' },\n\t\t'isPublishSidebarEnabled'\n\t);\n\tdata = moveIndividualPreference(\n\t\tdata,\n\t\t{ from: 'core/edit-site', to: 'core/edit-site' },\n\t\t'editorMode'\n\t);\n\n\t// The new system is only concerned with persisting\n\t// 'core/preferences' preferences reducer, so only return that.\n\treturn data?.[ 'core/preferences' ]?.preferences;\n}\n\n/**\n * Gets the legacy local storage data for the given user and returns the\n * data converted to the new format.\n *\n * @param {string | number} userId The user id.\n *\n * @return {Object | undefined} The converted data or undefined if no local\n * storage data could be found.\n */\nexport default function convertLegacyLocalStorageData( userId ) {\n\tconst data = getLegacyData( userId );\n\treturn convertLegacyData( data );\n}\n"],"mappings":"AAAA;AACA;AACA;AAC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wBAAwB,CAC9Ba,IAAI,EACJ;IAAEC,IAAI,EAAE,gBAAgB;IAAEC,EAAE,EAAE;EAAiB,CAAC,EAChD,QAAQ,EACRb,qBACD,CAAC;EACDW,IAAI,GAAGb,wBAAwB,CAC9Ba,IAAI,EACJ;IAAEC,IAAI,EAAE,aAAa;IAAEC,EAAE,EAAE;EAAO,CAAC,EACnC,yBACD,CAAC;EACDF,IAAI,GAAGb,wBAAwB,CAC9Ba,IAAI,EACJ;IAAEC,IAAI,EAAE,gBAAgB;IAAEC,EAAE,EAAE;EAAO,CAAC,EACtC,yBACD,CAAC;EACDF,IAAI,GAAGb,wBAAwB,CAC9Ba,IAAI,EACJ;IAAEC,IAAI,EAAE,gBAAgB;IAAEC,EAAE,EAAE;EAAiB,CAAC,EAChD,YACD,CAAC;;EAED;EACA;EACA,OAAOF,IAAI,GAAI,kBAAkB,CAAE,EAAEG,WAAW;AACjD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,6BAA6BA,CAAEb,MAAM,EAAG;EAC/D,MAAMS,IAAI,GAAGV,aAAa,CAAEC,MAAO,CAAC;EACpC,OAAOQ,iBAAiB,CAAEC,IAAK,CAAC;AACjC","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["moveFeaturePreferences","state","sourceStoreName","preferencesStoreName","interfaceStoreName","interfaceFeatures","preferences","features","sourceFeatures","featuresToMigrate","existingPreferences","updatedInterfaceState","otherInterfaceState","otherInterfaceScopes","undefined","updatedSourceState","otherSourceState","sourcePreferences"],"sources":["@wordpress/preferences-persistence/src/migrations/legacy-local-storage-data/move-feature-preferences.js"],"sourcesContent":["/**\n * Move the 'features' object in local storage from the sourceStoreName to the\n * preferences store data structure.\n *\n * Previously, editors used a data structure like this for feature preferences:\n * ```js\n * {\n * 'core/edit-post': {\n * preferences: {\n * features; {\n * topToolbar: true,\n * // ... other boolean 'feature' preferences\n * },\n * },\n * },\n * }\n * ```\n *\n * And for a while these feature preferences lived in the interface package:\n * ```js\n * {\n * 'core/interface': {\n * preferences: {\n * features: {\n * 'core/edit-post': {\n * topToolbar: true\n * }\n * }\n * }\n * }\n * }\n * ```\n *\n * In the preferences store, 'features' aren't considered special, they're\n * merged to the root level of the scope along with other preferences:\n * ```js\n * {\n * 'core/preferences': {\n * preferences: {\n * 'core/edit-post': {\n * topToolbar: true,\n * // ... any other preferences.\n * }\n * }\n * }\n * }\n * ```\n *\n * This function handles moving from either the source store or the interface\n * store to the preferences data structure.\n *\n * @param {Object} state The state before migration.\n * @param {string} sourceStoreName The name of the store that has persisted\n * preferences to migrate to the preferences\n * package.\n * @return {Object} The migrated state\n */\nexport default function moveFeaturePreferences( state, sourceStoreName ) {\n\tconst preferencesStoreName = 'core/preferences';\n\tconst interfaceStoreName = 'core/interface';\n\n\t// Features most recently (and briefly) lived in the interface package.\n\t// If data exists there, prioritize using that for the migration. If not\n\t// also check the original package as the user may have updated from an\n\t// older block editor version.\n\tconst interfaceFeatures =\n\t\tstate?.[ interfaceStoreName ]?.preferences?.features?.[\n\t\t\tsourceStoreName\n\t\t];\n\tconst sourceFeatures = state?.[ sourceStoreName ]?.preferences?.features;\n\tconst featuresToMigrate = interfaceFeatures\n\t\t? interfaceFeatures\n\t\t: sourceFeatures;\n\n\tif ( ! featuresToMigrate ) {\n\t\treturn state;\n\t}\n\n\tconst existingPreferences = state?.[ preferencesStoreName ]?.preferences;\n\n\t// Avoid migrating features again if they've previously been migrated.\n\tif ( existingPreferences?.[ sourceStoreName ] ) {\n\t\treturn state;\n\t}\n\n\tlet updatedInterfaceState;\n\tif ( interfaceFeatures ) {\n\t\tconst otherInterfaceState = state?.[ interfaceStoreName ];\n\t\tconst otherInterfaceScopes =\n\t\t\tstate?.[ interfaceStoreName ]?.preferences?.features;\n\n\t\tupdatedInterfaceState = {\n\t\t\t[ interfaceStoreName ]: {\n\t\t\t\t...otherInterfaceState,\n\t\t\t\tpreferences: {\n\t\t\t\t\tfeatures: {\n\t\t\t\t\t\t...otherInterfaceScopes,\n\t\t\t\t\t\t[ sourceStoreName ]: undefined,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\t}\n\n\tlet updatedSourceState;\n\tif ( sourceFeatures ) {\n\t\tconst otherSourceState = state?.[ sourceStoreName ];\n\t\tconst sourcePreferences = state?.[ sourceStoreName ]?.preferences;\n\n\t\tupdatedSourceState = {\n\t\t\t[ sourceStoreName ]: {\n\t\t\t\t...otherSourceState,\n\t\t\t\tpreferences: {\n\t\t\t\t\t...sourcePreferences,\n\t\t\t\t\tfeatures: undefined,\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\t}\n\n\t// Set the feature values in the interface store, the features\n\t// object is keyed by 'scope', which matches the store name for\n\t// the source.\n\treturn {\n\t\t...state,\n\t\t[ preferencesStoreName ]: {\n\t\t\tpreferences: {\n\t\t\t\t...existingPreferences,\n\t\t\t\t[ sourceStoreName ]: featuresToMigrate,\n\t\t\t},\n\t\t},\n\t\t...updatedInterfaceState,\n\t\t...updatedSourceState,\n\t};\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASA,sBAAsBA,CAAEC,KAAK,EAAEC,eAAe,EAAG;EACxE,MAAMC,oBAAoB,GAAG,kBAAkB;EAC/C,MAAMC,kBAAkB,GAAG,gBAAgB;;EAE3C;EACA;EACA;EACA;EACA,MAAMC,iBAAiB,GACtBJ,KAAK,GAAIG,kBAAkB,CAAE,EAAEE,WAAW,EAAEC,QAAQ,GACnDL,eAAe,CACf;EACF,MAAMM,cAAc,GAAGP,KAAK,G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"}
1
+ {"version":3,"names":["moveFeaturePreferences","state","sourceStoreName","preferencesStoreName","interfaceStoreName","interfaceFeatures","preferences","features","sourceFeatures","featuresToMigrate","existingPreferences","updatedInterfaceState","otherInterfaceState","otherInterfaceScopes","undefined","updatedSourceState","otherSourceState","sourcePreferences"],"sources":["@wordpress/preferences-persistence/src/migrations/legacy-local-storage-data/move-feature-preferences.js"],"sourcesContent":["/**\n * Move the 'features' object in local storage from the sourceStoreName to the\n * preferences store data structure.\n *\n * Previously, editors used a data structure like this for feature preferences:\n * ```js\n * {\n * 'core/edit-post': {\n * preferences: {\n * features; {\n * topToolbar: true,\n * // ... other boolean 'feature' preferences\n * },\n * },\n * },\n * }\n * ```\n *\n * And for a while these feature preferences lived in the interface package:\n * ```js\n * {\n * 'core/interface': {\n * preferences: {\n * features: {\n * 'core/edit-post': {\n * topToolbar: true\n * }\n * }\n * }\n * }\n * }\n * ```\n *\n * In the preferences store, 'features' aren't considered special, they're\n * merged to the root level of the scope along with other preferences:\n * ```js\n * {\n * 'core/preferences': {\n * preferences: {\n * 'core/edit-post': {\n * topToolbar: true,\n * // ... any other preferences.\n * }\n * }\n * }\n * }\n * ```\n *\n * This function handles moving from either the source store or the interface\n * store to the preferences data structure.\n *\n * @param {Object} state The state before migration.\n * @param {string} sourceStoreName The name of the store that has persisted\n * preferences to migrate to the preferences\n * package.\n * @return {Object} The migrated state\n */\nexport default function moveFeaturePreferences( state, sourceStoreName ) {\n\tconst preferencesStoreName = 'core/preferences';\n\tconst interfaceStoreName = 'core/interface';\n\n\t// Features most recently (and briefly) lived in the interface package.\n\t// If data exists there, prioritize using that for the migration. If not\n\t// also check the original package as the user may have updated from an\n\t// older block editor version.\n\tconst interfaceFeatures =\n\t\tstate?.[ interfaceStoreName ]?.preferences?.features?.[\n\t\t\tsourceStoreName\n\t\t];\n\tconst sourceFeatures = state?.[ sourceStoreName ]?.preferences?.features;\n\tconst featuresToMigrate = interfaceFeatures\n\t\t? interfaceFeatures\n\t\t: sourceFeatures;\n\n\tif ( ! featuresToMigrate ) {\n\t\treturn state;\n\t}\n\n\tconst existingPreferences = state?.[ preferencesStoreName ]?.preferences;\n\n\t// Avoid migrating features again if they've previously been migrated.\n\tif ( existingPreferences?.[ sourceStoreName ] ) {\n\t\treturn state;\n\t}\n\n\tlet updatedInterfaceState;\n\tif ( interfaceFeatures ) {\n\t\tconst otherInterfaceState = state?.[ interfaceStoreName ];\n\t\tconst otherInterfaceScopes =\n\t\t\tstate?.[ interfaceStoreName ]?.preferences?.features;\n\n\t\tupdatedInterfaceState = {\n\t\t\t[ interfaceStoreName ]: {\n\t\t\t\t...otherInterfaceState,\n\t\t\t\tpreferences: {\n\t\t\t\t\tfeatures: {\n\t\t\t\t\t\t...otherInterfaceScopes,\n\t\t\t\t\t\t[ sourceStoreName ]: undefined,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\t}\n\n\tlet updatedSourceState;\n\tif ( sourceFeatures ) {\n\t\tconst otherSourceState = state?.[ sourceStoreName ];\n\t\tconst sourcePreferences = state?.[ sourceStoreName ]?.preferences;\n\n\t\tupdatedSourceState = {\n\t\t\t[ sourceStoreName ]: {\n\t\t\t\t...otherSourceState,\n\t\t\t\tpreferences: {\n\t\t\t\t\t...sourcePreferences,\n\t\t\t\t\tfeatures: undefined,\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\t}\n\n\t// Set the feature values in the interface store, the features\n\t// object is keyed by 'scope', which matches the store name for\n\t// the source.\n\treturn {\n\t\t...state,\n\t\t[ preferencesStoreName ]: {\n\t\t\tpreferences: {\n\t\t\t\t...existingPreferences,\n\t\t\t\t[ sourceStoreName ]: featuresToMigrate,\n\t\t\t},\n\t\t},\n\t\t...updatedInterfaceState,\n\t\t...updatedSourceState,\n\t};\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAC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K,GAAIC,eAAe,CAAE;IACnD,MAAMe,iBAAiB,GAAGhB,KAAK,GAAIC,eAAe,CAAE,EAAEI,WAAW;IAEjES,kBAAkB,GAAG;MACpB,CAAEb,eAAe,GAAI;QACpB,GAAGc,gBAAgB;QACnBV,WAAW,EAAE;UACZ,GAAGW,iBAAiB;UACpBV,QAAQ,EAAEO;QACX;MACD;IACD,CAAC;EACF;;EAEA;EACA;EACA;EACA,OAAO;IACN,GAAGb,KAAK;IACR,CAAEE,oBAAoB,GAAI;MACzBG,WAAW,EAAE;QACZ,GAAGI,mBAAmB;QACtB,CAAER,eAAe,GAAIO;MACtB;IACD,CAAC;IACD,GAAGE,qBAAqB;IACxB,GAAGI;EACJ,CAAC;AACF","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["identity","arg","moveIndividualPreferenceToPreferences","state","from","sourceStoreName","to","scope","key","convert","preferencesStoreName","sourcePreference","preferences","undefined","targetPreference","otherScopes","otherPreferences","otherSourceState","allSourcePreferences","convertedPreferences"],"sources":["@wordpress/preferences-persistence/src/migrations/legacy-local-storage-data/move-individual-preference.js"],"sourcesContent":["const identity = ( arg ) => arg;\n\n/**\n * Migrates an individual item inside the `preferences` object for a package's store.\n *\n * Previously, some packages had individual 'preferences' of any data type, and many used\n * complex nested data structures. For example:\n * ```js\n * {\n * 'core/edit-post': {\n * preferences: {\n * panels: {\n * publish: {\n * opened: true,\n * enabled: true,\n * }\n * },\n * // ...other preferences.\n * },\n * },\n * }\n *\n * This function supports moving an individual preference like 'panels' above into the\n * preferences package data structure.\n *\n * It supports moving a preference to a particular scope in the preferences store and\n * optionally converting the data using a `convert` function.\n *\n * ```\n *\n * @param {Object} state The original state.\n * @param {Object} migrate An options object that contains details of the migration.\n * @param {string} migrate.from The name of the store to migrate from.\n * @param {string} migrate.to The scope in the preferences store to migrate to.\n * @param {string} key The key in the preferences object to migrate.\n * @param {?Function} convert A function that converts preferences from one format to another.\n */\nexport default function moveIndividualPreferenceToPreferences(\n\tstate,\n\t{ from: sourceStoreName, to: scope },\n\tkey,\n\tconvert = identity\n) {\n\tconst preferencesStoreName = 'core/preferences';\n\tconst sourcePreference = state?.[ sourceStoreName ]?.preferences?.[ key ];\n\n\t// There's nothing to migrate, exit early.\n\tif ( sourcePreference === undefined ) {\n\t\treturn state;\n\t}\n\n\tconst targetPreference =\n\t\tstate?.[ preferencesStoreName ]?.preferences?.[ scope ]?.[ key ];\n\n\t// There's existing data at the target, so don't overwrite it, exit early.\n\tif ( targetPreference ) {\n\t\treturn state;\n\t}\n\n\tconst otherScopes = state?.[ preferencesStoreName ]?.preferences;\n\tconst otherPreferences =\n\t\tstate?.[ preferencesStoreName ]?.preferences?.[ scope ];\n\n\tconst otherSourceState = state?.[ sourceStoreName ];\n\tconst allSourcePreferences = state?.[ sourceStoreName ]?.preferences;\n\n\t// Pass an object with the key and value as this allows the convert\n\t// function to convert to a data structure that has different keys.\n\tconst convertedPreferences = convert( { [ key ]: sourcePreference } );\n\n\treturn {\n\t\t...state,\n\t\t[ preferencesStoreName ]: {\n\t\t\tpreferences: {\n\t\t\t\t...otherScopes,\n\t\t\t\t[ scope ]: {\n\t\t\t\t\t...otherPreferences,\n\t\t\t\t\t...convertedPreferences,\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t[ sourceStoreName ]: {\n\t\t\t...otherSourceState,\n\t\t\tpreferences: {\n\t\t\t\t...allSourcePreferences,\n\t\t\t\t[ key ]: undefined,\n\t\t\t},\n\t\t},\n\t};\n}\n"],"mappings":"AAAA,MAAMA,QAAQ,GAAKC,GAAG,IAAMA,GAAG;;AAE/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,qCAAqCA,CAC5DC,KAAK,EACL;EAAEC,IAAI,EAAEC,eAAe;EAAEC,EAAE,EAAEC;AAAM,CAAC,EACpCC,GAAG,EACHC,OAAO,GAAGT,QAAQ,EACjB;EACD,MAAMU,oBAAoB,GAAG,kBAAkB;EAC/C,MAAMC,gBAAgB,GAAGR,KAAK,GAAIE,eAAe,CAAE,EAAEO,WAAW,GAAIJ,GAAG,CAAE;;EAEzE;EACA,IAAKG,gBAAgB,KAAKE,SAAS,EAAG;IACrC,OAAOV,KAAK;EACb;EAEA,MAAMW,gBAAgB,GACrBX,KAAK,GAAIO,oBAAoB,CAAE,EAAEE,WAAW,GAAIL,KAAK,CAAE,GAAIC,GAAG,CAAE;;EAEjE;EACA,IAAKM,gBAAgB,EAAG;IACvB,OAAOX,KAAK;EACb;EAEA,MAAMY,WAAW,GAAGZ,KAAK,GAAIO,oBAAoB,CAAE,EAAEE,WAAW;EAChE,MAAMI,gBAAgB,GACrBb,KAAK,GAAIO,oBAAoB,CAAE,EAAEE,WAAW,GAAIL,KAAK,CAAE;EAExD,MAAMU,gBAAgB,GAAGd,KAAK,GAAIE,eAAe,CAAE;EACnD,MAAMa,oBAAoB,GAAGf,KAAK,GAAIE,eAAe,CAAE,EAAEO,WAAW;;EAEpE;EACA;EACA,MAAMO,oBAAoB,GAAGV,OAAO,CAAE;IAAE,CAAED,GAAG,GAAIG;EAAiB,CAAE,CAAC;EAErE,OAAO;IACN,GAAGR,KAAK;IACR,CAAEO,oBAAoB,GAAI;MACzBE,WAAW,EAAE;QACZ,GAAGG,WAAW;QACd,CAAER,KAAK,GAAI;UACV,GAAGS,gBAAgB;UACnB,GAAGG;QACJ;MACD;IACD,CAAC;IACD,CAAEd,eAAe,GAAI;MACpB,GAAGY,gBAAgB;MACnBL,WAAW,EAAE;QACZ,GAAGM,oBAAoB;QACvB,CAAEV,GAAG,GAAIK;MACV;IACD;EACD,CAAC;AACF"}
1
+ {"version":3,"names":["identity","arg","moveIndividualPreferenceToPreferences","state","from","sourceStoreName","to","scope","key","convert","preferencesStoreName","sourcePreference","preferences","undefined","targetPreference","otherScopes","otherPreferences","otherSourceState","allSourcePreferences","convertedPreferences"],"sources":["@wordpress/preferences-persistence/src/migrations/legacy-local-storage-data/move-individual-preference.js"],"sourcesContent":["const identity = ( arg ) => arg;\n\n/**\n * Migrates an individual item inside the `preferences` object for a package's store.\n *\n * Previously, some packages had individual 'preferences' of any data type, and many used\n * complex nested data structures. For example:\n * ```js\n * {\n * 'core/edit-post': {\n * preferences: {\n * panels: {\n * publish: {\n * opened: true,\n * enabled: true,\n * }\n * },\n * // ...other preferences.\n * },\n * },\n * }\n *\n * This function supports moving an individual preference like 'panels' above into the\n * preferences package data structure.\n *\n * It supports moving a preference to a particular scope in the preferences store and\n * optionally converting the data using a `convert` function.\n *\n * ```\n *\n * @param {Object} state The original state.\n * @param {Object} migrate An options object that contains details of the migration.\n * @param {string} migrate.from The name of the store to migrate from.\n * @param {string} migrate.to The scope in the preferences store to migrate to.\n * @param {string} key The key in the preferences object to migrate.\n * @param {?Function} convert A function that converts preferences from one format to another.\n */\nexport default function moveIndividualPreferenceToPreferences(\n\tstate,\n\t{ from: sourceStoreName, to: scope },\n\tkey,\n\tconvert = identity\n) {\n\tconst preferencesStoreName = 'core/preferences';\n\tconst sourcePreference = state?.[ sourceStoreName ]?.preferences?.[ key ];\n\n\t// There's nothing to migrate, exit early.\n\tif ( sourcePreference === undefined ) {\n\t\treturn state;\n\t}\n\n\tconst targetPreference =\n\t\tstate?.[ preferencesStoreName ]?.preferences?.[ scope ]?.[ key ];\n\n\t// There's existing data at the target, so don't overwrite it, exit early.\n\tif ( targetPreference ) {\n\t\treturn state;\n\t}\n\n\tconst otherScopes = state?.[ preferencesStoreName ]?.preferences;\n\tconst otherPreferences =\n\t\tstate?.[ preferencesStoreName ]?.preferences?.[ scope ];\n\n\tconst otherSourceState = state?.[ sourceStoreName ];\n\tconst allSourcePreferences = state?.[ sourceStoreName ]?.preferences;\n\n\t// Pass an object with the key and value as this allows the convert\n\t// function to convert to a data structure that has different keys.\n\tconst convertedPreferences = convert( { [ key ]: sourcePreference } );\n\n\treturn {\n\t\t...state,\n\t\t[ preferencesStoreName ]: {\n\t\t\tpreferences: {\n\t\t\t\t...otherScopes,\n\t\t\t\t[ scope ]: {\n\t\t\t\t\t...otherPreferences,\n\t\t\t\t\t...convertedPreferences,\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t[ sourceStoreName ]: {\n\t\t\t...otherSourceState,\n\t\t\tpreferences: {\n\t\t\t\t...allSourcePreferences,\n\t\t\t\t[ key ]: undefined,\n\t\t\t},\n\t\t},\n\t};\n}\n"],"mappings":"AAAA,MAAMA,QAAQ,GAAKC,GAAG,IAAMA,GAAG;;AAE/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,qCAAqCA,CAC5DC,KAAK,EACL;EAAEC,IAAI,EAAEC,eAAe;EAAEC,EAAE,EAAEC;AAAM,CAAC,EACpCC,GAAG,EACHC,OAAO,GAAGT,QAAQ,EACjB;EACD,MAAMU,oBAAoB,GAAG,kBAAkB;EAC/C,MAAMC,gBAAgB,GAAGR,KAAK,GAAIE,eAAe,CAAE,EAAEO,WAAW,GAAIJ,GAAG,CAAE;;EAEzE;EACA,IAAKG,gBAAgB,KAAKE,SAAS,EAAG;IACrC,OAAOV,KAAK;EACb;EAEA,MAAMW,gBAAgB,GACrBX,KAAK,GAAIO,oBAAoB,CAAE,EAAEE,WAAW,GAAIL,KAAK,CAAE,GAAIC,GAAG,CAAE;;EAEjE;EACA,IAAKM,gBAAgB,EAAG;IACvB,OAAOX,KAAK;EACb;EAEA,MAAMY,WAAW,GAAGZ,KAAK,GAAIO,oBAAoB,CAAE,EAAEE,WAAW;EAChE,MAAMI,gBAAgB,GACrBb,KAAK,GAAIO,oBAAoB,CAAE,EAAEE,WAAW,GAAIL,KAAK,CAAE;EAExD,MAAMU,gBAAgB,GAAGd,KAAK,GAAIE,eAAe,CAAE;EACnD,MAAMa,oBAAoB,GAAGf,KAAK,GAAIE,eAAe,CAAE,EAAEO,WAAW;;EAEpE;EACA;EACA,MAAMO,oBAAoB,GAAGV,OAAO,CAAE;IAAE,CAAED,GAAG,GAAIG;EAAiB,CAAE,CAAC;EAErE,OAAO;IACN,GAAGR,KAAK;IACR,CAAEO,oBAAoB,GAAI;MACzBE,WAAW,EAAE;QACZ,GAAGG,WAAW;QACd,CAAER,KAAK,GAAI;UACV,GAAGS,gBAAgB;UACnB,GAAGG;QACJ;MACD;IACD,CAAC;IACD,CAAEd,eAAe,GAAI;MACpB,GAAGY,gBAAgB;MACnBL,WAAW,EAAE;QACZ,GAAGM,oBAAoB;QACvB,CAAEV,GAAG,GAAIK;MACV;IACD;EACD,CAAC;AACF","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["moveInterfaceEnableItems","state","_state$preferencesSto","_sourceEnableItems$si","_sourceEnableItems$mu","interfaceStoreName","preferencesStoreName","sourceEnableItems","enableItems","allPreferences","preferences","sourceComplementaryAreas","singleEnableItems","complementaryArea","preferencesWithConvertedComplementaryAreas","Object","keys","reduce","accumulator","scope","data","sourcePinnedItems","multipleEnableItems","pinnedItems","allConvertedData","otherInterfaceItems","undefined"],"sources":["@wordpress/preferences-persistence/src/migrations/legacy-local-storage-data/move-interface-enable-items.js"],"sourcesContent":["/**\n * Migrates interface 'enableItems' data to the preferences store.\n *\n * The interface package stores this data in this format:\n * ```js\n * {\n * enableItems: {\n * singleEnableItems: {\n * \t complementaryArea: {\n * 'core/edit-post': 'edit-post/document',\n * 'core/edit-site': 'edit-site/global-styles',\n * }\n * },\n * multipleEnableItems: {\n * pinnedItems: {\n * 'core/edit-post': {\n * 'plugin-1': true,\n * },\n * 'core/edit-site': {\n * 'plugin-2': true,\n * },\n * },\n * }\n * }\n * }\n * ```\n *\n * and it should be converted it to:\n * ```js\n * {\n * 'core/edit-post': {\n * complementaryArea: 'edit-post/document',\n * pinnedItems: {\n * 'plugin-1': true,\n * },\n * },\n * 'core/edit-site': {\n * complementaryArea: 'edit-site/global-styles',\n * pinnedItems: {\n * 'plugin-2': true,\n * },\n * },\n * }\n * ```\n *\n * @param {Object} state The local storage state.\n */\nexport default function moveInterfaceEnableItems( state ) {\n\tconst interfaceStoreName = 'core/interface';\n\tconst preferencesStoreName = 'core/preferences';\n\tconst sourceEnableItems = state?.[ interfaceStoreName ]?.enableItems;\n\n\t// There's nothing to migrate, exit early.\n\tif ( ! sourceEnableItems ) {\n\t\treturn state;\n\t}\n\n\tconst allPreferences = state?.[ preferencesStoreName ]?.preferences ?? {};\n\n\t// First convert complementaryAreas into the right format.\n\t// Use the existing preferences as the accumulator so that the data is\n\t// merged.\n\tconst sourceComplementaryAreas =\n\t\tsourceEnableItems?.singleEnableItems?.complementaryArea ?? {};\n\n\tconst preferencesWithConvertedComplementaryAreas = Object.keys(\n\t\tsourceComplementaryAreas\n\t).reduce( ( accumulator, scope ) => {\n\t\tconst data = sourceComplementaryAreas[ scope ];\n\n\t\t// Don't overwrite any existing data in the preferences store.\n\t\tif ( accumulator?.[ scope ]?.complementaryArea ) {\n\t\t\treturn accumulator;\n\t\t}\n\n\t\treturn {\n\t\t\t...accumulator,\n\t\t\t[ scope ]: {\n\t\t\t\t...accumulator[ scope ],\n\t\t\t\tcomplementaryArea: data,\n\t\t\t},\n\t\t};\n\t}, allPreferences );\n\n\t// Next feed the converted complementary areas back into a reducer that\n\t// converts the pinned items, resulting in the fully migrated data.\n\tconst sourcePinnedItems =\n\t\tsourceEnableItems?.multipleEnableItems?.pinnedItems ?? {};\n\tconst allConvertedData = Object.keys( sourcePinnedItems ).reduce(\n\t\t( accumulator, scope ) => {\n\t\t\tconst data = sourcePinnedItems[ scope ];\n\t\t\t// Don't overwrite any existing data in the preferences store.\n\t\t\tif ( accumulator?.[ scope ]?.pinnedItems ) {\n\t\t\t\treturn accumulator;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\t...accumulator,\n\t\t\t\t[ scope ]: {\n\t\t\t\t\t...accumulator[ scope ],\n\t\t\t\t\tpinnedItems: data,\n\t\t\t\t},\n\t\t\t};\n\t\t},\n\t\tpreferencesWithConvertedComplementaryAreas\n\t);\n\n\tconst otherInterfaceItems = state[ interfaceStoreName ];\n\n\treturn {\n\t\t...state,\n\t\t[ preferencesStoreName ]: {\n\t\t\tpreferences: allConvertedData,\n\t\t},\n\t\t[ interfaceStoreName ]: {\n\t\t\t...otherInterfaceItems,\n\t\t\tenableItems: undefined,\n\t\t},\n\t};\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASA,wBAAwBA,CAAEC,KAAK,EAAG;EAAA,IAAAC,qBAAA,EAAAC,qBAAA,EAAAC,qBAAA;EACzD,MAAMC,kBAAkB,GAAG,gBAAgB;EAC3C,MAAMC,oBAAoB,GAAG,kBAAkB;EAC/C,MAAMC,iBAAiB,GAAGN,KAAK,GAAII,kBAAkB,CAAE,EAAEG,WAAW;;EAEpE;EACA,IAAK,CAAED,iBAAiB,EAAG;IAC1B,OAAON,KAAK;EACb;EAEA,MAAMQ,cAAc,IAAAP,qBAAA,GAAGD,KAAK,GAAIK,oBAAoB,CAAE,EAAEI,WAAW,cAAAR,qBAAA,cAAAA,qBAAA,GAAI,CAAC,CAAC;;EAEzE;EACA;EACA;EACA,MAAMS,wBAAwB,IAAAR,qBAAA,GAC7BI,iBAAiB,EAAEK,iBAAiB,EAAEC,iBAAiB,cAAAV,qBAAA,cAAAA,qBAAA,GAAI,CAAC,CAAC;EAE9D,MAAMW,0CAA0C,GAA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faceEnableItems","state","_state$preferencesSto","_sourceEnableItems$si","_sourceEnableItems$mu","interfaceStoreName","preferencesStoreName","sourceEnableItems","enableItems","allPreferences","preferences","sourceComplementaryAreas","singleEnableItems","complementaryArea","preferencesWithConvertedComplementaryAreas","Object","keys","reduce","accumulator","scope","data","sourcePinnedItems","multipleEnableItems","pinnedItems","allConvertedData","otherInterfaceItems","undefined"],"sources":["@wordpress/preferences-persistence/src/migrations/legacy-local-storage-data/move-interface-enable-items.js"],"sourcesContent":["/**\n * Migrates interface 'enableItems' data to the preferences store.\n *\n * The interface package stores this data in this format:\n * ```js\n * {\n * enableItems: {\n * singleEnableItems: {\n * \t complementaryArea: {\n * 'core/edit-post': 'edit-post/document',\n * 'core/edit-site': 'edit-site/global-styles',\n * }\n * },\n * multipleEnableItems: {\n * pinnedItems: {\n * 'core/edit-post': {\n * 'plugin-1': true,\n * },\n * 'core/edit-site': {\n * 'plugin-2': true,\n * },\n * },\n * }\n * }\n * }\n * ```\n *\n * and it should be converted it to:\n * ```js\n * {\n * 'core/edit-post': {\n * complementaryArea: 'edit-post/document',\n * pinnedItems: {\n * 'plugin-1': true,\n * },\n * },\n * 'core/edit-site': {\n * complementaryArea: 'edit-site/global-styles',\n * pinnedItems: {\n * 'plugin-2': true,\n * },\n * },\n * }\n * ```\n *\n * @param {Object} state The local storage state.\n */\nexport default function moveInterfaceEnableItems( state ) {\n\tconst interfaceStoreName = 'core/interface';\n\tconst preferencesStoreName = 'core/preferences';\n\tconst sourceEnableItems = state?.[ interfaceStoreName ]?.enableItems;\n\n\t// There's nothing to migrate, exit early.\n\tif ( ! sourceEnableItems ) {\n\t\treturn state;\n\t}\n\n\tconst allPreferences = state?.[ preferencesStoreName ]?.preferences ?? {};\n\n\t// First convert complementaryAreas into the right format.\n\t// Use the existing preferences as the accumulator so that the data is\n\t// merged.\n\tconst sourceComplementaryAreas =\n\t\tsourceEnableItems?.singleEnableItems?.complementaryArea ?? {};\n\n\tconst preferencesWithConvertedComplementaryAreas = Object.keys(\n\t\tsourceComplementaryAreas\n\t).reduce( ( accumulator, scope ) => {\n\t\tconst data = sourceComplementaryAreas[ scope ];\n\n\t\t// Don't overwrite any existing data in the preferences store.\n\t\tif ( accumulator?.[ scope ]?.complementaryArea ) {\n\t\t\treturn accumulator;\n\t\t}\n\n\t\treturn {\n\t\t\t...accumulator,\n\t\t\t[ scope ]: {\n\t\t\t\t...accumulator[ scope ],\n\t\t\t\tcomplementaryArea: data,\n\t\t\t},\n\t\t};\n\t}, allPreferences );\n\n\t// Next feed the converted complementary areas back into a reducer that\n\t// converts the pinned items, resulting in the fully migrated data.\n\tconst sourcePinnedItems =\n\t\tsourceEnableItems?.multipleEnableItems?.pinnedItems ?? {};\n\tconst allConvertedData = Object.keys( sourcePinnedItems ).reduce(\n\t\t( accumulator, scope ) => {\n\t\t\tconst data = sourcePinnedItems[ scope ];\n\t\t\t// Don't overwrite any existing data in the preferences store.\n\t\t\tif ( accumulator?.[ scope ]?.pinnedItems ) {\n\t\t\t\treturn accumulator;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\t...accumulator,\n\t\t\t\t[ scope ]: {\n\t\t\t\t\t...accumulator[ scope ],\n\t\t\t\t\tpinnedItems: data,\n\t\t\t\t},\n\t\t\t};\n\t\t},\n\t\tpreferencesWithConvertedComplementaryAreas\n\t);\n\n\tconst otherInterfaceItems = state[ interfaceStoreName ];\n\n\treturn {\n\t\t...state,\n\t\t[ preferencesStoreName ]: {\n\t\t\tpreferences: allConvertedData,\n\t\t},\n\t\t[ interfaceStoreName ]: {\n\t\t\t...otherInterfaceItems,\n\t\t\tenableItems: undefined,\n\t\t},\n\t};\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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,CAAEK,iBAAkB,CAAC,CAACJ,MAAM,CAC/D,CAAEC,WAAW,EAAEC,KAAK,KAAM;IACzB,MAAMC,IAAI,GAAGC,iBAAiB,CAAEF,KAAK,CAAE;IACvC;IACA,IAAKD,WAAW,GAAIC,KAAK,CAAE,EAAEI,WAAW,EAAG;MAC1C,OAAOL,WAAW;IACnB;IAEA,OAAO;MACN,GAAGA,WAAW;MACd,CAAEC,KAAK,GAAI;QACV,GAAGD,WAAW,CAAEC,KAAK,CAAE;QACvBI,WAAW,EAAEH;MACd;IACD,CAAC;EACF,CAAC,EACDN,0CACD,CAAC;EAED,MAAMW,mBAAmB,GAAGxB,KAAK,CAAEI,kBAAkB,CAAE;EAEvD,OAAO;IACN,GAAGJ,KAAK;IACR,CAAEK,oBAAoB,GAAI;MACzBI,WAAW,EAAEc;IACd,CAAC;IACD,CAAEnB,kBAAkB,GAAI;MACvB,GAAGoB,mBAAmB;MACtBjB,WAAW,EAAEkB;IACd;EACD,CAAC;AACF","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["moveThirdPartyFeaturePreferencesToPreferences","state","interfaceStoreName","preferencesStoreName","interfaceScopes","preferences","features","interfaceScopeKeys","Object","keys","length","reduce","convertedState","scope","startsWith","featuresToMigrate","existingMigratedData","otherPreferencesScopes","otherInterfaceState","otherInterfaceScopes","undefined"],"sources":["@wordpress/preferences-persistence/src/migrations/legacy-local-storage-data/move-third-party-feature-preferences.js"],"sourcesContent":["/**\n * The interface package previously had a public API that could be used by\n * plugins to set persisted boolean 'feature' preferences.\n *\n * While usage was likely non-existent or very small, this function ensures\n * those are migrated to the preferences data structure. The interface\n * package's APIs have now been deprecated and use the preferences store.\n *\n * This will convert data that looks like this:\n * ```js\n * {\n * 'core/interface': {\n * preferences: {\n * features: {\n * 'my-plugin': {\n * myPluginFeature: true\n * }\n * }\n * }\n * }\n * }\n * ```\n *\n * To this:\n * ```js\n * * {\n * 'core/preferences': {\n * preferences: {\n * 'my-plugin': {\n * myPluginFeature: true\n * }\n * }\n * }\n * }\n * ```\n *\n * @param {Object} state The local storage state\n *\n * @return {Object} The state with third party preferences moved to the\n * preferences data structure.\n */\nexport default function moveThirdPartyFeaturePreferencesToPreferences( state ) {\n\tconst interfaceStoreName = 'core/interface';\n\tconst preferencesStoreName = 'core/preferences';\n\n\tconst interfaceScopes =\n\t\tstate?.[ interfaceStoreName ]?.preferences?.features;\n\tconst interfaceScopeKeys = interfaceScopes\n\t\t? Object.keys( interfaceScopes )\n\t\t: [];\n\n\tif ( ! interfaceScopeKeys?.length ) {\n\t\treturn state;\n\t}\n\n\treturn interfaceScopeKeys.reduce( function ( convertedState, scope ) {\n\t\tif ( scope.startsWith( 'core' ) ) {\n\t\t\treturn convertedState;\n\t\t}\n\n\t\tconst featuresToMigrate = interfaceScopes?.[ scope ];\n\t\tif ( ! featuresToMigrate ) {\n\t\t\treturn convertedState;\n\t\t}\n\n\t\tconst existingMigratedData =\n\t\t\tconvertedState?.[ preferencesStoreName ]?.preferences?.[ scope ];\n\n\t\tif ( existingMigratedData ) {\n\t\t\treturn convertedState;\n\t\t}\n\n\t\tconst otherPreferencesScopes =\n\t\t\tconvertedState?.[ preferencesStoreName ]?.preferences;\n\t\tconst otherInterfaceState = convertedState?.[ interfaceStoreName ];\n\t\tconst otherInterfaceScopes =\n\t\t\tconvertedState?.[ interfaceStoreName ]?.preferences?.features;\n\n\t\treturn {\n\t\t\t...convertedState,\n\t\t\t[ preferencesStoreName ]: {\n\t\t\t\tpreferences: {\n\t\t\t\t\t...otherPreferencesScopes,\n\t\t\t\t\t[ scope ]: featuresToMigrate,\n\t\t\t\t},\n\t\t\t},\n\t\t\t[ interfaceStoreName ]: {\n\t\t\t\t...otherInterfaceState,\n\t\t\t\tpreferences: {\n\t\t\t\t\tfeatures: {\n\t\t\t\t\t\t...otherInterfaceScopes,\n\t\t\t\t\t\t[ scope ]: undefined,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\t}, state );\n}\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AAc;MACjB,CAAET,oBAAoB,GAAI;QACzBE,WAAW,EAAE;UACZ,GAAGY,sBAAsB;UACzB,CAAEJ,KAAK,GAAIE;QACZ;MACD,CAAC;MACD,CAAEb,kBAAkB,GAAI;QACvB,GAAGgB,mBAAmB;QACtBb,WAAW,EAAE;UACZC,QAAQ,EAAE;YACT,GAAGa,oBAAoB;YACvB,CAAEN,KAAK,GAAIO;UACZ;QACD;MACD;IACD,CAAC;EACF,CAAC,EAAEnB,KAAM,CAAC;AACX"}
1
+ {"version":3,"names":["moveThirdPartyFeaturePreferencesToPreferences","state","interfaceStoreName","preferencesStoreName","interfaceScopes","preferences","features","interfaceScopeKeys","Object","keys","length","reduce","convertedState","scope","startsWith","featuresToMigrate","existingMigratedData","otherPreferencesScopes","otherInterfaceState","otherInterfaceScopes","undefined"],"sources":["@wordpress/preferences-persistence/src/migrations/legacy-local-storage-data/move-third-party-feature-preferences.js"],"sourcesContent":["/**\n * The interface package previously had a public API that could be used by\n * plugins to set persisted boolean 'feature' preferences.\n *\n * While usage was likely non-existent or very small, this function ensures\n * those are migrated to the preferences data structure. The interface\n * package's APIs have now been deprecated and use the preferences store.\n *\n * This will convert data that looks like this:\n * ```js\n * {\n * 'core/interface': {\n * preferences: {\n * features: {\n * 'my-plugin': {\n * myPluginFeature: true\n * }\n * }\n * }\n * }\n * }\n * ```\n *\n * To this:\n * ```js\n * * {\n * 'core/preferences': {\n * preferences: {\n * 'my-plugin': {\n * myPluginFeature: true\n * }\n * }\n * }\n * }\n * ```\n *\n * @param {Object} state The local storage state\n *\n * @return {Object} The state with third party preferences moved to the\n * preferences data structure.\n */\nexport default function moveThirdPartyFeaturePreferencesToPreferences( state ) {\n\tconst interfaceStoreName = 'core/interface';\n\tconst preferencesStoreName = 'core/preferences';\n\n\tconst interfaceScopes =\n\t\tstate?.[ interfaceStoreName ]?.preferences?.features;\n\tconst interfaceScopeKeys = interfaceScopes\n\t\t? Object.keys( interfaceScopes )\n\t\t: [];\n\n\tif ( ! interfaceScopeKeys?.length ) {\n\t\treturn state;\n\t}\n\n\treturn interfaceScopeKeys.reduce( function ( convertedState, scope ) {\n\t\tif ( scope.startsWith( 'core' ) ) {\n\t\t\treturn convertedState;\n\t\t}\n\n\t\tconst featuresToMigrate = interfaceScopes?.[ scope ];\n\t\tif ( ! featuresToMigrate ) {\n\t\t\treturn convertedState;\n\t\t}\n\n\t\tconst existingMigratedData =\n\t\t\tconvertedState?.[ preferencesStoreName ]?.preferences?.[ scope ];\n\n\t\tif ( existingMigratedData ) {\n\t\t\treturn convertedState;\n\t\t}\n\n\t\tconst otherPreferencesScopes =\n\t\t\tconvertedState?.[ preferencesStoreName ]?.preferences;\n\t\tconst otherInterfaceState = convertedState?.[ interfaceStoreName ];\n\t\tconst otherInterfaceScopes =\n\t\t\tconvertedState?.[ interfaceStoreName ]?.preferences?.features;\n\n\t\treturn {\n\t\t\t...convertedState,\n\t\t\t[ preferencesStoreName ]: {\n\t\t\t\tpreferences: {\n\t\t\t\t\t...otherPreferencesScopes,\n\t\t\t\t\t[ scope ]: featuresToMigrate,\n\t\t\t\t},\n\t\t\t},\n\t\t\t[ interfaceStoreName ]: {\n\t\t\t\t...otherInterfaceState,\n\t\t\t\tpreferences: {\n\t\t\t\t\tfeatures: {\n\t\t\t\t\t\t...otherInterfaceScopes,\n\t\t\t\t\t\t[ scope ]: undefined,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\t}, state );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASA,6CAA6CA,CAAEC,KAAK,EAAG;EAC9E,MAAMC,kBAAkB,GAAG,gBAAgB;EAC3C,MAAMC,oBAAoB,GAAG,kBA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
@@ -1 +1 @@
1
- {"version":3,"names":["convertComplementaryAreas","state","Object","keys","reduce","stateAccumulator","scope","scopeData","complementaryArea","updatedScopeData","isComplementaryAreaVisible"],"sources":["@wordpress/preferences-persistence/src/migrations/preferences-package-data/convert-complementary-areas.js"],"sourcesContent":["export default function convertComplementaryAreas( state ) {\n\treturn Object.keys( state ).reduce( ( stateAccumulator, scope ) => {\n\t\tconst scopeData = state[ scope ];\n\n\t\t// If a complementary area is truthy, convert it to the `isComplementaryAreaVisible` boolean.\n\t\tif ( scopeData?.complementaryArea ) {\n\t\t\tconst updatedScopeData = { ...scopeData };\n\t\t\tdelete updatedScopeData.complementaryArea;\n\t\t\tupdatedScopeData.isComplementaryAreaVisible = true;\n\t\t\tstateAccumulator[ scope ] = updatedScopeData;\n\t\t\treturn stateAccumulator;\n\t\t}\n\n\t\treturn stateAccumulator;\n\t}, state );\n}\n"],"mappings":"AAAA,eAAe,SAASA,yBAAyBA,CAAEC,KAAK,EAAG;EAC1D,OAAOC,MAAM,CAACC,IAAI,CAAEF,KAAM,CAAC,CAACG,MAAM,CAAE,CAAEC,gBAAgB,EAAEC,KAAK,KAAM;IAClE,MAAMC,SAAS,GAAGN,KAAK,CAAEK,KAAK,CAAE;;IAEhC;IACA,IAAKC,SAAS,EAAEC,iBAAiB,EAAG;MACnC,MAAMC,gBAAgB,GAAG;QAAE,GAAGF;MAAU,CAAC;MACzC,OAAOE,gBAAgB,CAACD,iBAAiB;MACzCC,gBAAgB,CAACC,0BAA0B,GAAG,IAAI;MAClDL,gBAAgB,CAAEC,KAAK,CAAE,GAAGG,gBAAgB;MAC5C,OAAOJ,gBAAgB;IACxB;IAEA,OAAOA,gBAAgB;EACxB,CAAC,EAAEJ,KAAM,CAAC;AACX"}
1
+ {"version":3,"names":["convertComplementaryAreas","state","Object","keys","reduce","stateAccumulator","scope","scopeData","complementaryArea","updatedScopeData","isComplementaryAreaVisible"],"sources":["@wordpress/preferences-persistence/src/migrations/preferences-package-data/convert-complementary-areas.js"],"sourcesContent":["export default function convertComplementaryAreas( state ) {\n\treturn Object.keys( state ).reduce( ( stateAccumulator, scope ) => {\n\t\tconst scopeData = state[ scope ];\n\n\t\t// If a complementary area is truthy, convert it to the `isComplementaryAreaVisible` boolean.\n\t\tif ( scopeData?.complementaryArea ) {\n\t\t\tconst updatedScopeData = { ...scopeData };\n\t\t\tdelete updatedScopeData.complementaryArea;\n\t\t\tupdatedScopeData.isComplementaryAreaVisible = true;\n\t\t\tstateAccumulator[ scope ] = updatedScopeData;\n\t\t\treturn stateAccumulator;\n\t\t}\n\n\t\treturn stateAccumulator;\n\t}, state );\n}\n"],"mappings":"AAAA,eAAe,SAASA,yBAAyBA,CAAEC,KAAK,EAAG;EAC1D,OAAOC,MAAM,CAACC,IAAI,CAAEF,KAAM,CAAC,CAACG,MAAM,CAAE,CAAEC,gBAAgB,EAAEC,KAAK,KAAM;IAClE,MAAMC,SAAS,GAAGN,KAAK,CAAEK,KAAK,CAAE;;IAEhC;IACA,IAAKC,SAAS,EAAEC,iBAAiB,EAAG;MACnC,MAAMC,gBAAgB,GAAG;QAAE,GAAGF;MAAU,CAAC;MACzC,OAAOE,gBAAgB,CAACD,iBAAiB;MACzCC,gBAAgB,CAACC,0BAA0B,GAAG,IAAI;MAClDL,gBAAgB,CAAEC,KAAK,CAAE,GAAGG,gBAAgB;MAC5C,OAAOJ,gBAAgB;IACxB;IAEA,OAAOA,gBAAgB;EACxB,CAAC,EAAEJ,KAAM,CAAC;AACX","ignoreList":[]}
@@ -5,7 +5,7 @@
5
5
  export default function convertEditorSettings(data) {
6
6
  var _newData$coreEditPo, _newData$coreEditSi;
7
7
  let newData = data;
8
- const settingsToMoveToCore = ['allowRightClickOverrides', 'distractionFree', 'editorMode', 'fixedToolbar', 'focusMode', 'hiddenBlockTypes', 'inactivePanels', 'keepCaretInsideBlock', 'mostUsedBlocks', 'openPanels', 'showBlockBreadcrumbs', 'showIconLabels', 'showListViewByDefault'];
8
+ const settingsToMoveToCore = ['allowRightClickOverrides', 'distractionFree', 'editorMode', 'fixedToolbar', 'focusMode', 'hiddenBlockTypes', 'inactivePanels', 'keepCaretInsideBlock', 'mostUsedBlocks', 'openPanels', 'showBlockBreadcrumbs', 'showIconLabels', 'showListViewByDefault', 'isPublishSidebarEnabled', 'isComplementaryAreaVisible', 'pinnedItems'];
9
9
  settingsToMoveToCore.forEach(setting => {
10
10
  if (data?.['core/edit-post']?.[setting] !== undefined) {
11
11
  newData = {
@@ -1 +1 @@
1
- {"version":3,"names":["convertEditorSettings","data","_newData$coreEditPo","_newData$coreEditSi","newData","settingsToMoveToCore","forEach","setting","undefined","core","Object","keys","length"],"sources":["@wordpress/preferences-persistence/src/migrations/preferences-package-data/convert-editor-settings.js"],"sourcesContent":["/**\n * Internal dependencies\n */\n\nexport default function convertEditorSettings( data ) {\n\tlet newData = data;\n\tconst settingsToMoveToCore = [\n\t\t'allowRightClickOverrides',\n\t\t'distractionFree',\n\t\t'editorMode',\n\t\t'fixedToolbar',\n\t\t'focusMode',\n\t\t'hiddenBlockTypes',\n\t\t'inactivePanels',\n\t\t'keepCaretInsideBlock',\n\t\t'mostUsedBlocks',\n\t\t'openPanels',\n\t\t'showBlockBreadcrumbs',\n\t\t'showIconLabels',\n\t\t'showListViewByDefault',\n\t];\n\n\tsettingsToMoveToCore.forEach( ( setting ) => {\n\t\tif ( data?.[ 'core/edit-post' ]?.[ setting ] !== undefined ) {\n\t\t\tnewData = {\n\t\t\t\t...newData,\n\t\t\t\tcore: {\n\t\t\t\t\t...newData?.core,\n\t\t\t\t\t[ setting ]: data[ 'core/edit-post' ][ setting ],\n\t\t\t\t},\n\t\t\t};\n\t\t\tdelete newData[ 'core/edit-post' ][ setting ];\n\t\t}\n\n\t\tif ( data?.[ 'core/edit-site' ]?.[ setting ] !== undefined ) {\n\t\t\tdelete newData[ 'core/edit-site' ][ setting ];\n\t\t}\n\t} );\n\n\tif ( Object.keys( newData?.[ 'core/edit-post' ] ?? {} )?.length === 0 ) {\n\t\tdelete newData[ 'core/edit-post' ];\n\t}\n\n\tif ( Object.keys( newData?.[ 'core/edit-site' ] ?? {} )?.length === 0 ) {\n\t\tdelete newData[ 'core/edit-site' ];\n\t}\n\n\treturn newData;\n}\n"],"mappings":"AAAA;AACA;AACA;;AAEA,eAAe,SAASA,qBAAqBA,CAAEC,IAAI,EAAG;EAAA,IAAAC,mBAAA,EAAAC,mBAAA;EACrD,IAAIC,OAAO,GAAGH,IAAI;EAClB,MAAMI,oBAAoB,GAAG,CAC5B,0BAA0B,EAC1B,iBAAiB,EACjB,YAAY,EACZ,cAAc,EACd,WAAW,EACX,kBAAkB,EAClB,gBAAgB,EAChB,sBAAsB,EACtB,gBAAgB,EAChB,YAAY,EACZ,sBAAsB,EACtB,gBAAgB,EAChB,uBAAuB,CACvB;EAEDA,oBAAoB,CAACC,OAAO,CAAIC,OAAO,IAAM;IAC5C,IAAKN,IAAI,GAAI,gBAAgB,CAAE,GAAIM,OAAO,CAAE,KAAKC,SAAS,EAAG;MAC5DJ,OAAO,GAAG;QACT,GAAGA,OAAO;QACVK,IAAI,EAAE;UACL,GAAGL,OAAO,EAAEK,IAAI;UAChB,CAAEF,OAAO,GAAIN,IAAI,CAAE,gBAAgB,CAAE,CAAEM,OAAO;QAC/C;MACD,CAAC;MACD,OAAOH,OAAO,CAAE,gBAAgB,CAAE,CAAEG,OAAO,CAAE;IAC9C;IAEA,IAAKN,IAAI,GAAI,gBAAgB,CAAE,GAAIM,OAAO,CAAE,KAAKC,SAAS,EAAG;MAC5D,OAAOJ,OAAO,CAAE,gBAAgB,CAAE,CAAEG,OAAO,CAAE;IAC9C;EACD,CAAE,CAAC;EAEH,IAAKG,MAAM,CAACC,IAAI,EAAAT,mBAAA,GAAEE,OAAO,GAAI,gBAAgB,CAAE,cAAAF,mBAAA,cAAAA,mBAAA,GAAI,CAAC,CAAE,CAAC,EAAEU,MAAM,KAAK,CAAC,EAAG;IACvE,OAAOR,OAAO,CAAE,gBAAgB,CAAE;EACnC;EAEA,IAAKM,MAAM,CAACC,IAAI,EAAAR,mBAAA,GAAEC,OAAO,GAAI,gBAAgB,CAAE,cAAAD,mBAAA,cAAAA,mBAAA,GAAI,CAAC,CAAE,CAAC,EAAES,MAAM,KAAK,CAAC,EAAG;IACvE,OAAOR,OAAO,CAAE,gBAAgB,CAAE;EACnC;EAEA,OAAOA,OAAO;AACf"}
1
+ {"version":3,"names":["convertEditorSettings","data","_newData$coreEditPo","_newData$coreEditSi","newData","settingsToMoveToCore","forEach","setting","undefined","core","Object","keys","length"],"sources":["@wordpress/preferences-persistence/src/migrations/preferences-package-data/convert-editor-settings.js"],"sourcesContent":["/**\n * Internal dependencies\n */\n\nexport default function convertEditorSettings( data ) {\n\tlet newData = data;\n\tconst settingsToMoveToCore = [\n\t\t'allowRightClickOverrides',\n\t\t'distractionFree',\n\t\t'editorMode',\n\t\t'fixedToolbar',\n\t\t'focusMode',\n\t\t'hiddenBlockTypes',\n\t\t'inactivePanels',\n\t\t'keepCaretInsideBlock',\n\t\t'mostUsedBlocks',\n\t\t'openPanels',\n\t\t'showBlockBreadcrumbs',\n\t\t'showIconLabels',\n\t\t'showListViewByDefault',\n\t\t'isPublishSidebarEnabled',\n\t\t'isComplementaryAreaVisible',\n\t\t'pinnedItems',\n\t];\n\n\tsettingsToMoveToCore.forEach( ( setting ) => {\n\t\tif ( data?.[ 'core/edit-post' ]?.[ setting ] !== undefined ) {\n\t\t\tnewData = {\n\t\t\t\t...newData,\n\t\t\t\tcore: {\n\t\t\t\t\t...newData?.core,\n\t\t\t\t\t[ setting ]: data[ 'core/edit-post' ][ setting ],\n\t\t\t\t},\n\t\t\t};\n\t\t\tdelete newData[ 'core/edit-post' ][ setting ];\n\t\t}\n\n\t\tif ( data?.[ 'core/edit-site' ]?.[ setting ] !== undefined ) {\n\t\t\tdelete newData[ 'core/edit-site' ][ setting ];\n\t\t}\n\t} );\n\n\tif ( Object.keys( newData?.[ 'core/edit-post' ] ?? {} )?.length === 0 ) {\n\t\tdelete newData[ 'core/edit-post' ];\n\t}\n\n\tif ( Object.keys( newData?.[ 'core/edit-site' ] ?? {} )?.length === 0 ) {\n\t\tdelete newData[ 'core/edit-site' ];\n\t}\n\n\treturn newData;\n}\n"],"mappings":"AAAA;AACA;AACA;;AAEA,eAAe,SAASA,qBAAqBA,CAAEC,IAAI,EAAG;EAAA,IAAAC,mBAAA,EAAAC,mBAAA;EACrD,IAAIC,OAAO,GAAGH,IAAI;EAClB,MAAMI,oBAAoB,GAAG,CAC5B,0BAA0B,EAC1B,iBAAiB,EACjB,YAAY,EACZ,cAAc,EACd,WAAW,EACX,kBAAkB,EAClB,gBAAgB,EAChB,sBAAsB,EACtB,gBAAgB,EAChB,YAAY,EACZ,sBAAsB,EACtB,gBAAgB,EAChB,uBAAuB,EACvB,yBAAyB,EACzB,4BAA4B,EAC5B,aAAa,CACb;EAEDA,oBAAoB,CAACC,OAAO,CAAIC,OAAO,IAAM;IAC5C,IAAKN,IAAI,GAAI,gBAAgB,CAAE,GAAIM,OAAO,CAAE,KAAKC,SAAS,EAAG;MAC5DJ,OAAO,GAAG;QACT,GAAGA,OAAO;QACVK,IAAI,EAAE;UACL,GAAGL,OAAO,EAAEK,IAAI;UAChB,CAAEF,OAAO,GAAIN,IAAI,CAAE,gBAAgB,CAAE,CAAEM,OAAO;QAC/C;MACD,CAAC;MACD,OAAOH,OAAO,CAAE,gBAAgB,CAAE,CAAEG,OAAO,CAAE;IAC9C;IAEA,IAAKN,IAAI,GAAI,gBAAgB,CAAE,GAAIM,OAAO,CAAE,KAAKC,SAAS,EAAG;MAC5D,OAAOJ,OAAO,CAAE,gBAAgB,CAAE,CAAEG,OAAO,CAAE;IAC9C;EACD,CAAE,CAAC;EAEH,IAAKG,MAAM,CAACC,IAAI,EAAAT,mBAAA,GAAEE,OAAO,GAAI,gBAAgB,CAAE,cAAAF,mBAAA,cAAAA,mBAAA,GAAI,CAAC,CAAE,CAAC,EAAEU,MAAM,KAAK,CAAC,EAAG;IACvE,OAAOR,OAAO,CAAE,gBAAgB,CAAE;EACnC;EAEA,IAAKM,MAAM,CAACC,IAAI,EAAAR,mBAAA,GAAEC,OAAO,GAAI,gBAAgB,CAAE,cAAAD,mBAAA,cAAAA,mBAAA,GAAI,CAAC,CAAE,CAAC,EAAES,MAAM,KAAK,CAAC,EAAG;IACvE,OAAOR,OAAO,CAAE,gBAAgB,CAAE;EACnC;EAEA,OAAOA,OAAO;AACf","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["convertComplementaryAreas","convertEditorSettings","convertPreferencesPackageData","data","newData"],"sources":["@wordpress/preferences-persistence/src/migrations/preferences-package-data/index.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport convertComplementaryAreas from './convert-complementary-areas';\nimport convertEditorSettings from './convert-editor-settings';\n\nexport default function convertPreferencesPackageData( data ) {\n\tlet newData = convertComplementaryAreas( data );\n\tnewData = convertEditorSettings( newData );\n\treturn newData;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,yBAAyB,MAAM,+BAA+B;AACrE,OAAOC,qBAAqB,MAAM,2BAA2B;AAE7D,eAAe,SAASC,6BAA6BA,CAAEC,IAAI,EAAG;EAC7D,IAAIC,OAAO,GAAGJ,yBAAyB,CAAEG,IAAK,CAAC;EAC/CC,OAAO,GAAGH,qBAAqB,CAAEG,OAAQ,CAAC;EAC1C,OAAOA,OAAO;AACf"}
1
+ {"version":3,"names":["convertComplementaryAreas","convertEditorSettings","convertPreferencesPackageData","data","newData"],"sources":["@wordpress/preferences-persistence/src/migrations/preferences-package-data/index.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport convertComplementaryAreas from './convert-complementary-areas';\nimport convertEditorSettings from './convert-editor-settings';\n\nexport default function convertPreferencesPackageData( data ) {\n\tlet newData = convertComplementaryAreas( data );\n\tnewData = convertEditorSettings( newData );\n\treturn newData;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,yBAAyB,MAAM,+BAA+B;AACrE,OAAOC,qBAAqB,MAAM,2BAA2B;AAE7D,eAAe,SAASC,6BAA6BA,CAAEC,IAAI,EAAG;EAC7D,IAAIC,OAAO,GAAGJ,yBAAyB,CAAEG,IAAK,CAAC;EAC/CC,OAAO,GAAGH,qBAAqB,CAAEG,OAAQ,CAAC;EAC1C,OAAOA,OAAO;AACf","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/preferences-persistence",
3
- "version": "1.46.0",
3
+ "version": "1.48.0",
4
4
  "description": "Persistence utilities for `wordpress/preferences`.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -28,10 +28,10 @@
28
28
  "sideEffects": false,
29
29
  "dependencies": {
30
30
  "@babel/runtime": "^7.16.0",
31
- "@wordpress/api-fetch": "^6.51.0"
31
+ "@wordpress/api-fetch": "^6.53.0"
32
32
  },
33
33
  "publishConfig": {
34
34
  "access": "public"
35
35
  },
36
- "gitHead": "ffc07735d0abfb3f69e91d48f25b7fe8d1ef92d2"
36
+ "gitHead": "280403b4c1cf6cc2c55a6c4d56f9ef91145e4191"
37
37
  }
@@ -68,7 +68,12 @@ export function convertLegacyData( data ) {
68
68
  );
69
69
  data = moveIndividualPreference(
70
70
  data,
71
- { from: 'core/editor', to: 'core/edit-post' },
71
+ { from: 'core/editor', to: 'core' },
72
+ 'isPublishSidebarEnabled'
73
+ );
74
+ data = moveIndividualPreference(
75
+ data,
76
+ { from: 'core/edit-post', to: 'core' },
72
77
  'isPublishSidebarEnabled'
73
78
  );
74
79
  data = moveIndividualPreference(
@@ -18,6 +18,9 @@ export default function convertEditorSettings( data ) {
18
18
  'showBlockBreadcrumbs',
19
19
  'showIconLabels',
20
20
  'showListViewByDefault',
21
+ 'isPublishSidebarEnabled',
22
+ 'isComplementaryAreaVisible',
23
+ 'pinnedItems',
21
24
  ];
22
25
 
23
26
  settingsToMoveToCore.forEach( ( setting ) => {
@@ -10,7 +10,7 @@ describe( 'convertComplementaryAreas', () => {
10
10
  complementaryArea: 'edit-post/block',
11
11
  },
12
12
  'core/edit-site': {
13
- complementaryArea: 'edit-site/template',
13
+ complementaryArea: 'edit-post/document',
14
14
  },
15
15
  'core/edit-post': {
16
16
  complementaryArea: 'edit-post/block',
@@ -50,6 +50,9 @@ describe( 'convertPreferencesPackageData', () => {
50
50
  "openPanels": [
51
51
  "post-status",
52
52
  ],
53
+ "pinnedItems": {
54
+ "my-sidebar-plugin/title-sidebar": false,
55
+ },
53
56
  },
54
57
  "core/customize-widgets": {
55
58
  "fixedToolbar": true,
@@ -57,13 +60,9 @@ describe( 'convertPreferencesPackageData', () => {
57
60
  },
58
61
  "core/edit-post": {
59
62
  "fullscreenMode": false,
60
- "pinnedItems": {
61
- "my-sidebar-plugin/title-sidebar": false,
62
- },
63
63
  "welcomeGuide": false,
64
64
  },
65
65
  "core/edit-site": {
66
- "isComplementaryAreaVisible": true,
67
66
  "welcomeGuide": false,
68
67
  "welcomeGuideStyles": false,
69
68
  },