@wordpress/preferences-persistence 2.32.0 → 2.32.1-next.b8c8708f3.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 (49) hide show
  1. package/build/create/debounce-async.js +24 -39
  2. package/build/create/debounce-async.js.map +7 -1
  3. package/build/create/index.js +50 -61
  4. package/build/create/index.js.map +7 -1
  5. package/build/index.js +47 -42
  6. package/build/index.js.map +7 -1
  7. package/build/migrations/legacy-local-storage-data/convert-edit-post-panels.js +36 -52
  8. package/build/migrations/legacy-local-storage-data/convert-edit-post-panels.js.map +7 -1
  9. package/build/migrations/legacy-local-storage-data/index.js +80 -89
  10. package/build/migrations/legacy-local-storage-data/index.js.map +7 -1
  11. package/build/migrations/legacy-local-storage-data/move-feature-preferences.js +26 -78
  12. package/build/migrations/legacy-local-storage-data/move-feature-preferences.js.map +7 -1
  13. package/build/migrations/legacy-local-storage-data/move-individual-preference.js +28 -60
  14. package/build/migrations/legacy-local-storage-data/move-individual-preference.js.map +7 -1
  15. package/build/migrations/legacy-local-storage-data/move-interface-enable-items.js +46 -85
  16. package/build/migrations/legacy-local-storage-data/move-interface-enable-items.js.map +7 -1
  17. package/build/migrations/legacy-local-storage-data/move-third-party-feature-preferences.js +27 -52
  18. package/build/migrations/legacy-local-storage-data/move-third-party-feature-preferences.js.map +7 -1
  19. package/build/migrations/preferences-package-data/convert-complementary-areas.js +23 -11
  20. package/build/migrations/preferences-package-data/convert-complementary-areas.js.map +7 -1
  21. package/build/migrations/preferences-package-data/convert-editor-settings.js +50 -22
  22. package/build/migrations/preferences-package-data/convert-editor-settings.js.map +7 -1
  23. package/build/migrations/preferences-package-data/index.js +36 -15
  24. package/build/migrations/preferences-package-data/index.js.map +7 -1
  25. package/build-module/create/debounce-async.js +7 -35
  26. package/build-module/create/debounce-async.js.map +7 -1
  27. package/build-module/create/index.js +21 -53
  28. package/build-module/create/index.js.map +7 -1
  29. package/build-module/index.js +12 -29
  30. package/build-module/index.js.map +7 -1
  31. package/build-module/migrations/legacy-local-storage-data/convert-edit-post-panels.js +19 -48
  32. package/build-module/migrations/legacy-local-storage-data/convert-edit-post-panels.js.map +7 -1
  33. package/build-module/migrations/legacy-local-storage-data/index.js +48 -82
  34. package/build-module/migrations/legacy-local-storage-data/index.js.map +7 -1
  35. package/build-module/migrations/legacy-local-storage-data/move-feature-preferences.js +9 -74
  36. package/build-module/migrations/legacy-local-storage-data/move-feature-preferences.js.map +7 -1
  37. package/build-module/migrations/legacy-local-storage-data/move-individual-preference.js +10 -55
  38. package/build-module/migrations/legacy-local-storage-data/move-individual-preference.js.map +7 -1
  39. package/build-module/migrations/legacy-local-storage-data/move-interface-enable-items.js +29 -81
  40. package/build-module/migrations/legacy-local-storage-data/move-interface-enable-items.js.map +7 -1
  41. package/build-module/migrations/legacy-local-storage-data/move-third-party-feature-preferences.js +10 -48
  42. package/build-module/migrations/legacy-local-storage-data/move-third-party-feature-preferences.js.map +7 -1
  43. package/build-module/migrations/preferences-package-data/convert-complementary-areas.js +6 -7
  44. package/build-module/migrations/preferences-package-data/convert-complementary-areas.js.map +7 -1
  45. package/build-module/migrations/preferences-package-data/convert-editor-settings.js +33 -18
  46. package/build-module/migrations/preferences-package-data/convert-editor-settings.js.map +7 -1
  47. package/build-module/migrations/preferences-package-data/index.js +7 -7
  48. package/build-module/migrations/preferences-package-data/index.js.map +7 -1
  49. package/package.json +11 -4
@@ -1 +1,7 @@
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,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","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/migrations/legacy-local-storage-data/move-feature-preferences.js"],
4
+ "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"],
5
+ "mappings": "AAyDe,SAAR,uBAAyC,OAAO,iBAAkB;AACxE,QAAM,uBAAuB;AAC7B,QAAM,qBAAqB;AAM3B,QAAM,oBACL,QAAS,kBAAmB,GAAG,aAAa,WAC3C,eACD;AACD,QAAM,iBAAiB,QAAS,eAAgB,GAAG,aAAa;AAChE,QAAM,oBAAoB,oBACvB,oBACA;AAEH,MAAK,CAAE,mBAAoB;AAC1B,WAAO;AAAA,EACR;AAEA,QAAM,sBAAsB,QAAS,oBAAqB,GAAG;AAG7D,MAAK,sBAAuB,eAAgB,GAAI;AAC/C,WAAO;AAAA,EACR;AAEA,MAAI;AACJ,MAAK,mBAAoB;AACxB,UAAM,sBAAsB,QAAS,kBAAmB;AACxD,UAAM,uBACL,QAAS,kBAAmB,GAAG,aAAa;AAE7C,4BAAwB;AAAA,MACvB,CAAE,kBAAmB,GAAG;AAAA,QACvB,GAAG;AAAA,QACH,aAAa;AAAA,UACZ,UAAU;AAAA,YACT,GAAG;AAAA,YACH,CAAE,eAAgB,GAAG;AAAA,UACtB;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAAA,EACD;AAEA,MAAI;AACJ,MAAK,gBAAiB;AACrB,UAAM,mBAAmB,QAAS,eAAgB;AAClD,UAAM,oBAAoB,QAAS,eAAgB,GAAG;AAEtD,yBAAqB;AAAA,MACpB,CAAE,eAAgB,GAAG;AAAA,QACpB,GAAG;AAAA,QACH,aAAa;AAAA,UACZ,GAAG;AAAA,UACH,UAAU;AAAA,QACX;AAAA,MACD;AAAA,IACD;AAAA,EACD;AAKA,SAAO;AAAA,IACN,GAAG;AAAA,IACH,CAAE,oBAAqB,GAAG;AAAA,MACzB,aAAa;AAAA,QACZ,GAAG;AAAA,QACH,CAAE,eAAgB,GAAG;AAAA,MACtB;AAAA,IACD;AAAA,IACA,GAAG;AAAA,IACH,GAAG;AAAA,EACJ;AACD;",
6
+ "names": []
7
+ }
@@ -1,54 +1,11 @@
1
- const identity = arg => arg;
2
-
3
- /**
4
- * Migrates an individual item inside the `preferences` object for a package's store.
5
- *
6
- * Previously, some packages had individual 'preferences' of any data type, and many used
7
- * complex nested data structures. For example:
8
- * ```js
9
- * {
10
- * 'core/edit-post': {
11
- * preferences: {
12
- * panels: {
13
- * publish: {
14
- * opened: true,
15
- * enabled: true,
16
- * }
17
- * },
18
- * // ...other preferences.
19
- * },
20
- * },
21
- * }
22
- *
23
- * This function supports moving an individual preference like 'panels' above into the
24
- * preferences package data structure.
25
- *
26
- * It supports moving a preference to a particular scope in the preferences store and
27
- * optionally converting the data using a `convert` function.
28
- *
29
- * ```
30
- *
31
- * @param {Object} state The original state.
32
- * @param {Object} migrate An options object that contains details of the migration.
33
- * @param {string} migrate.from The name of the store to migrate from.
34
- * @param {string} migrate.to The scope in the preferences store to migrate to.
35
- * @param {string} key The key in the preferences object to migrate.
36
- * @param {?Function} convert A function that converts preferences from one format to another.
37
- */
38
- export default function moveIndividualPreferenceToPreferences(state, {
39
- from: sourceStoreName,
40
- to: scope
41
- }, key, convert = identity) {
42
- const preferencesStoreName = 'core/preferences';
1
+ const identity = (arg) => arg;
2
+ function moveIndividualPreferenceToPreferences(state, { from: sourceStoreName, to: scope }, key, convert = identity) {
3
+ const preferencesStoreName = "core/preferences";
43
4
  const sourcePreference = state?.[sourceStoreName]?.preferences?.[key];
44
-
45
- // There's nothing to migrate, exit early.
46
- if (sourcePreference === undefined) {
5
+ if (sourcePreference === void 0) {
47
6
  return state;
48
7
  }
49
8
  const targetPreference = state?.[preferencesStoreName]?.preferences?.[scope]?.[key];
50
-
51
- // There's existing data at the target, so don't overwrite it, exit early.
52
9
  if (targetPreference) {
53
10
  return state;
54
11
  }
@@ -56,12 +13,7 @@ export default function moveIndividualPreferenceToPreferences(state, {
56
13
  const otherPreferences = state?.[preferencesStoreName]?.preferences?.[scope];
57
14
  const otherSourceState = state?.[sourceStoreName];
58
15
  const allSourcePreferences = state?.[sourceStoreName]?.preferences;
59
-
60
- // Pass an object with the key and value as this allows the convert
61
- // function to convert to a data structure that has different keys.
62
- const convertedPreferences = convert({
63
- [key]: sourcePreference
64
- });
16
+ const convertedPreferences = convert({ [key]: sourcePreference });
65
17
  return {
66
18
  ...state,
67
19
  [preferencesStoreName]: {
@@ -77,9 +29,12 @@ export default function moveIndividualPreferenceToPreferences(state, {
77
29
  ...otherSourceState,
78
30
  preferences: {
79
31
  ...allSourcePreferences,
80
- [key]: undefined
32
+ [key]: void 0
81
33
  }
82
34
  }
83
35
  };
84
36
  }
85
- //# sourceMappingURL=move-individual-preference.js.map
37
+ export {
38
+ moveIndividualPreferenceToPreferences as default
39
+ };
40
+ //# sourceMappingURL=move-individual-preference.js.map
@@ -1 +1,7 @@
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
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/migrations/legacy-local-storage-data/move-individual-preference.js"],
4
+ "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"],
5
+ "mappings": "AAAA,MAAM,WAAW,CAAE,QAAS;AAqCb,SAAR,sCACN,OACA,EAAE,MAAM,iBAAiB,IAAI,MAAM,GACnC,KACA,UAAU,UACT;AACD,QAAM,uBAAuB;AAC7B,QAAM,mBAAmB,QAAS,eAAgB,GAAG,cAAe,GAAI;AAGxE,MAAK,qBAAqB,QAAY;AACrC,WAAO;AAAA,EACR;AAEA,QAAM,mBACL,QAAS,oBAAqB,GAAG,cAAe,KAAM,IAAK,GAAI;AAGhE,MAAK,kBAAmB;AACvB,WAAO;AAAA,EACR;AAEA,QAAM,cAAc,QAAS,oBAAqB,GAAG;AACrD,QAAM,mBACL,QAAS,oBAAqB,GAAG,cAAe,KAAM;AAEvD,QAAM,mBAAmB,QAAS,eAAgB;AAClD,QAAM,uBAAuB,QAAS,eAAgB,GAAG;AAIzD,QAAM,uBAAuB,QAAS,EAAE,CAAE,GAAI,GAAG,iBAAiB,CAAE;AAEpE,SAAO;AAAA,IACN,GAAG;AAAA,IACH,CAAE,oBAAqB,GAAG;AAAA,MACzB,aAAa;AAAA,QACZ,GAAG;AAAA,QACH,CAAE,KAAM,GAAG;AAAA,UACV,GAAG;AAAA,UACH,GAAG;AAAA,QACJ;AAAA,MACD;AAAA,IACD;AAAA,IACA,CAAE,eAAgB,GAAG;AAAA,MACpB,GAAG;AAAA,MACH,aAAa;AAAA,QACZ,GAAG;AAAA,QACH,CAAE,GAAI,GAAG;AAAA,MACV;AAAA,IACD;AAAA,EACD;AACD;",
6
+ "names": []
7
+ }
@@ -1,70 +1,16 @@
1
- /**
2
- * Migrates interface 'enableItems' data to the preferences store.
3
- *
4
- * The interface package stores this data in this format:
5
- * ```js
6
- * {
7
- * enableItems: {
8
- * singleEnableItems: {
9
- * complementaryArea: {
10
- * 'core/edit-post': 'edit-post/document',
11
- * 'core/edit-site': 'edit-site/global-styles',
12
- * }
13
- * },
14
- * multipleEnableItems: {
15
- * pinnedItems: {
16
- * 'core/edit-post': {
17
- * 'plugin-1': true,
18
- * },
19
- * 'core/edit-site': {
20
- * 'plugin-2': true,
21
- * },
22
- * },
23
- * }
24
- * }
25
- * }
26
- * ```
27
- *
28
- * and it should be converted it to:
29
- * ```js
30
- * {
31
- * 'core/edit-post': {
32
- * complementaryArea: 'edit-post/document',
33
- * pinnedItems: {
34
- * 'plugin-1': true,
35
- * },
36
- * },
37
- * 'core/edit-site': {
38
- * complementaryArea: 'edit-site/global-styles',
39
- * pinnedItems: {
40
- * 'plugin-2': true,
41
- * },
42
- * },
43
- * }
44
- * ```
45
- *
46
- * @param {Object} state The local storage state.
47
- */
48
- export default function moveInterfaceEnableItems(state) {
49
- var _state$preferencesSto, _sourceEnableItems$si, _sourceEnableItems$mu;
50
- const interfaceStoreName = 'core/interface';
51
- const preferencesStoreName = 'core/preferences';
1
+ function moveInterfaceEnableItems(state) {
2
+ const interfaceStoreName = "core/interface";
3
+ const preferencesStoreName = "core/preferences";
52
4
  const sourceEnableItems = state?.[interfaceStoreName]?.enableItems;
53
-
54
- // There's nothing to migrate, exit early.
55
5
  if (!sourceEnableItems) {
56
6
  return state;
57
7
  }
58
- const allPreferences = (_state$preferencesSto = state?.[preferencesStoreName]?.preferences) !== null && _state$preferencesSto !== void 0 ? _state$preferencesSto : {};
59
-
60
- // First convert complementaryAreas into the right format.
61
- // Use the existing preferences as the accumulator so that the data is
62
- // merged.
63
- const sourceComplementaryAreas = (_sourceEnableItems$si = sourceEnableItems?.singleEnableItems?.complementaryArea) !== null && _sourceEnableItems$si !== void 0 ? _sourceEnableItems$si : {};
64
- const preferencesWithConvertedComplementaryAreas = Object.keys(sourceComplementaryAreas).reduce((accumulator, scope) => {
8
+ const allPreferences = state?.[preferencesStoreName]?.preferences ?? {};
9
+ const sourceComplementaryAreas = sourceEnableItems?.singleEnableItems?.complementaryArea ?? {};
10
+ const preferencesWithConvertedComplementaryAreas = Object.keys(
11
+ sourceComplementaryAreas
12
+ ).reduce((accumulator, scope) => {
65
13
  const data = sourceComplementaryAreas[scope];
66
-
67
- // Don't overwrite any existing data in the preferences store.
68
14
  if (accumulator?.[scope]?.complementaryArea) {
69
15
  return accumulator;
70
16
  }
@@ -76,24 +22,23 @@ export default function moveInterfaceEnableItems(state) {
76
22
  }
77
23
  };
78
24
  }, allPreferences);
79
-
80
- // Next feed the converted complementary areas back into a reducer that
81
- // converts the pinned items, resulting in the fully migrated data.
82
- const sourcePinnedItems = (_sourceEnableItems$mu = sourceEnableItems?.multipleEnableItems?.pinnedItems) !== null && _sourceEnableItems$mu !== void 0 ? _sourceEnableItems$mu : {};
83
- const allConvertedData = Object.keys(sourcePinnedItems).reduce((accumulator, scope) => {
84
- const data = sourcePinnedItems[scope];
85
- // Don't overwrite any existing data in the preferences store.
86
- if (accumulator?.[scope]?.pinnedItems) {
87
- return accumulator;
88
- }
89
- return {
90
- ...accumulator,
91
- [scope]: {
92
- ...accumulator[scope],
93
- pinnedItems: data
25
+ const sourcePinnedItems = sourceEnableItems?.multipleEnableItems?.pinnedItems ?? {};
26
+ const allConvertedData = Object.keys(sourcePinnedItems).reduce(
27
+ (accumulator, scope) => {
28
+ const data = sourcePinnedItems[scope];
29
+ if (accumulator?.[scope]?.pinnedItems) {
30
+ return accumulator;
94
31
  }
95
- };
96
- }, preferencesWithConvertedComplementaryAreas);
32
+ return {
33
+ ...accumulator,
34
+ [scope]: {
35
+ ...accumulator[scope],
36
+ pinnedItems: data
37
+ }
38
+ };
39
+ },
40
+ preferencesWithConvertedComplementaryAreas
41
+ );
97
42
  const otherInterfaceItems = state[interfaceStoreName];
98
43
  return {
99
44
  ...state,
@@ -102,8 +47,11 @@ export default function moveInterfaceEnableItems(state) {
102
47
  },
103
48
  [interfaceStoreName]: {
104
49
  ...otherInterfaceItems,
105
- enableItems: undefined
50
+ enableItems: void 0
106
51
  }
107
52
  };
108
53
  }
109
- //# sourceMappingURL=move-interface-enable-items.js.map
54
+ export {
55
+ moveInterfaceEnableItems as default
56
+ };
57
+ //# sourceMappingURL=move-interface-enable-items.js.map
@@ -1 +1,7 @@
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,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","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/migrations/legacy-local-storage-data/move-interface-enable-items.js"],
4
+ "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"],
5
+ "mappings": "AA+Ce,SAAR,yBAA2C,OAAQ;AACzD,QAAM,qBAAqB;AAC3B,QAAM,uBAAuB;AAC7B,QAAM,oBAAoB,QAAS,kBAAmB,GAAG;AAGzD,MAAK,CAAE,mBAAoB;AAC1B,WAAO;AAAA,EACR;AAEA,QAAM,iBAAiB,QAAS,oBAAqB,GAAG,eAAe,CAAC;AAKxE,QAAM,2BACL,mBAAmB,mBAAmB,qBAAqB,CAAC;AAE7D,QAAM,6CAA6C,OAAO;AAAA,IACzD;AAAA,EACD,EAAE,OAAQ,CAAE,aAAa,UAAW;AACnC,UAAM,OAAO,yBAA0B,KAAM;AAG7C,QAAK,cAAe,KAAM,GAAG,mBAAoB;AAChD,aAAO;AAAA,IACR;AAEA,WAAO;AAAA,MACN,GAAG;AAAA,MACH,CAAE,KAAM,GAAG;AAAA,QACV,GAAG,YAAa,KAAM;AAAA,QACtB,mBAAmB;AAAA,MACpB;AAAA,IACD;AAAA,EACD,GAAG,cAAe;AAIlB,QAAM,oBACL,mBAAmB,qBAAqB,eAAe,CAAC;AACzD,QAAM,mBAAmB,OAAO,KAAM,iBAAkB,EAAE;AAAA,IACzD,CAAE,aAAa,UAAW;AACzB,YAAM,OAAO,kBAAmB,KAAM;AAEtC,UAAK,cAAe,KAAM,GAAG,aAAc;AAC1C,eAAO;AAAA,MACR;AAEA,aAAO;AAAA,QACN,GAAG;AAAA,QACH,CAAE,KAAM,GAAG;AAAA,UACV,GAAG,YAAa,KAAM;AAAA,UACtB,aAAa;AAAA,QACd;AAAA,MACD;AAAA,IACD;AAAA,IACA;AAAA,EACD;AAEA,QAAM,sBAAsB,MAAO,kBAAmB;AAEtD,SAAO;AAAA,IACN,GAAG;AAAA,IACH,CAAE,oBAAqB,GAAG;AAAA,MACzB,aAAa;AAAA,IACd;AAAA,IACA,CAAE,kBAAmB,GAAG;AAAA,MACvB,GAAG;AAAA,MACH,aAAa;AAAA,IACd;AAAA,EACD;AACD;",
6
+ "names": []
7
+ }
@@ -1,54 +1,13 @@
1
- /**
2
- * The interface package previously had a public API that could be used by
3
- * plugins to set persisted boolean 'feature' preferences.
4
- *
5
- * While usage was likely non-existent or very small, this function ensures
6
- * those are migrated to the preferences data structure. The interface
7
- * package's APIs have now been deprecated and use the preferences store.
8
- *
9
- * This will convert data that looks like this:
10
- * ```js
11
- * {
12
- * 'core/interface': {
13
- * preferences: {
14
- * features: {
15
- * 'my-plugin': {
16
- * myPluginFeature: true
17
- * }
18
- * }
19
- * }
20
- * }
21
- * }
22
- * ```
23
- *
24
- * To this:
25
- * ```js
26
- * * {
27
- * 'core/preferences': {
28
- * preferences: {
29
- * 'my-plugin': {
30
- * myPluginFeature: true
31
- * }
32
- * }
33
- * }
34
- * }
35
- * ```
36
- *
37
- * @param {Object} state The local storage state
38
- *
39
- * @return {Object} The state with third party preferences moved to the
40
- * preferences data structure.
41
- */
42
- export default function moveThirdPartyFeaturePreferencesToPreferences(state) {
43
- const interfaceStoreName = 'core/interface';
44
- const preferencesStoreName = 'core/preferences';
1
+ function moveThirdPartyFeaturePreferencesToPreferences(state) {
2
+ const interfaceStoreName = "core/interface";
3
+ const preferencesStoreName = "core/preferences";
45
4
  const interfaceScopes = state?.[interfaceStoreName]?.preferences?.features;
46
5
  const interfaceScopeKeys = interfaceScopes ? Object.keys(interfaceScopes) : [];
47
6
  if (!interfaceScopeKeys?.length) {
48
7
  return state;
49
8
  }
50
- return interfaceScopeKeys.reduce(function (convertedState, scope) {
51
- if (scope.startsWith('core')) {
9
+ return interfaceScopeKeys.reduce(function(convertedState, scope) {
10
+ if (scope.startsWith("core")) {
52
11
  return convertedState;
53
12
  }
54
13
  const featuresToMigrate = interfaceScopes?.[scope];
@@ -75,11 +34,14 @@ export default function moveThirdPartyFeaturePreferencesToPreferences(state) {
75
34
  preferences: {
76
35
  features: {
77
36
  ...otherInterfaceScopes,
78
- [scope]: undefined
37
+ [scope]: void 0
79
38
  }
80
39
  }
81
40
  }
82
41
  };
83
42
  }, state);
84
43
  }
85
- //# sourceMappingURL=move-third-party-feature-preferences.js.map
44
+ export {
45
+ moveThirdPartyFeaturePreferencesToPreferences as default
46
+ };
47
+ //# sourceMappingURL=move-third-party-feature-preferences.js.map
@@ -1 +1,7 @@
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,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
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/migrations/legacy-local-storage-data/move-third-party-feature-preferences.js"],
4
+ "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"],
5
+ "mappings": "AAyCe,SAAR,8CAAgE,OAAQ;AAC9E,QAAM,qBAAqB;AAC3B,QAAM,uBAAuB;AAE7B,QAAM,kBACL,QAAS,kBAAmB,GAAG,aAAa;AAC7C,QAAM,qBAAqB,kBACxB,OAAO,KAAM,eAAgB,IAC7B,CAAC;AAEJ,MAAK,CAAE,oBAAoB,QAAS;AACnC,WAAO;AAAA,EACR;AAEA,SAAO,mBAAmB,OAAQ,SAAW,gBAAgB,OAAQ;AACpE,QAAK,MAAM,WAAY,MAAO,GAAI;AACjC,aAAO;AAAA,IACR;AAEA,UAAM,oBAAoB,kBAAmB,KAAM;AACnD,QAAK,CAAE,mBAAoB;AAC1B,aAAO;AAAA,IACR;AAEA,UAAM,uBACL,iBAAkB,oBAAqB,GAAG,cAAe,KAAM;AAEhE,QAAK,sBAAuB;AAC3B,aAAO;AAAA,IACR;AAEA,UAAM,yBACL,iBAAkB,oBAAqB,GAAG;AAC3C,UAAM,sBAAsB,iBAAkB,kBAAmB;AACjE,UAAM,uBACL,iBAAkB,kBAAmB,GAAG,aAAa;AAEtD,WAAO;AAAA,MACN,GAAG;AAAA,MACH,CAAE,oBAAqB,GAAG;AAAA,QACzB,aAAa;AAAA,UACZ,GAAG;AAAA,UACH,CAAE,KAAM,GAAG;AAAA,QACZ;AAAA,MACD;AAAA,MACA,CAAE,kBAAmB,GAAG;AAAA,QACvB,GAAG;AAAA,QACH,aAAa;AAAA,UACZ,UAAU;AAAA,YACT,GAAG;AAAA,YACH,CAAE,KAAM,GAAG;AAAA,UACZ;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAAA,EACD,GAAG,KAAM;AACV;",
6
+ "names": []
7
+ }
@@ -1,12 +1,8 @@
1
- export default function convertComplementaryAreas(state) {
1
+ function convertComplementaryAreas(state) {
2
2
  return Object.keys(state).reduce((stateAccumulator, scope) => {
3
3
  const scopeData = state[scope];
4
-
5
- // If a complementary area is truthy, convert it to the `isComplementaryAreaVisible` boolean.
6
4
  if (scopeData?.complementaryArea) {
7
- const updatedScopeData = {
8
- ...scopeData
9
- };
5
+ const updatedScopeData = { ...scopeData };
10
6
  delete updatedScopeData.complementaryArea;
11
7
  updatedScopeData.isComplementaryAreaVisible = true;
12
8
  stateAccumulator[scope] = updatedScopeData;
@@ -15,4 +11,7 @@ export default function convertComplementaryAreas(state) {
15
11
  return stateAccumulator;
16
12
  }, state);
17
13
  }
18
- //# sourceMappingURL=convert-complementary-areas.js.map
14
+ export {
15
+ convertComplementaryAreas as default
16
+ };
17
+ //# sourceMappingURL=convert-complementary-areas.js.map
@@ -1 +1,7 @@
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":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/migrations/preferences-package-data/convert-complementary-areas.js"],
4
+ "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"],
5
+ "mappings": "AAAe,SAAR,0BAA4C,OAAQ;AAC1D,SAAO,OAAO,KAAM,KAAM,EAAE,OAAQ,CAAE,kBAAkB,UAAW;AAClE,UAAM,YAAY,MAAO,KAAM;AAG/B,QAAK,WAAW,mBAAoB;AACnC,YAAM,mBAAmB,EAAE,GAAG,UAAU;AACxC,aAAO,iBAAiB;AACxB,uBAAiB,6BAA6B;AAC9C,uBAAkB,KAAM,IAAI;AAC5B,aAAO;AAAA,IACR;AAEA,WAAO;AAAA,EACR,GAAG,KAAM;AACV;",
6
+ "names": []
7
+ }
@@ -1,32 +1,47 @@
1
- /**
2
- * Internal dependencies
3
- */
4
-
5
- export default function convertEditorSettings(data) {
6
- var _newData$coreEditPo, _newData$coreEditSi;
1
+ function convertEditorSettings(data) {
7
2
  let newData = data;
8
- const settingsToMoveToCore = ['allowRightClickOverrides', 'distractionFree', 'editorMode', 'fixedToolbar', 'focusMode', 'hiddenBlockTypes', 'inactivePanels', 'keepCaretInsideBlock', 'mostUsedBlocks', 'openPanels', 'showBlockBreadcrumbs', 'showIconLabels', 'showListViewByDefault', 'isPublishSidebarEnabled', 'isComplementaryAreaVisible', 'pinnedItems'];
9
- settingsToMoveToCore.forEach(setting => {
10
- if (data?.['core/edit-post']?.[setting] !== undefined) {
3
+ const settingsToMoveToCore = [
4
+ "allowRightClickOverrides",
5
+ "distractionFree",
6
+ "editorMode",
7
+ "fixedToolbar",
8
+ "focusMode",
9
+ "hiddenBlockTypes",
10
+ "inactivePanels",
11
+ "keepCaretInsideBlock",
12
+ "mostUsedBlocks",
13
+ "openPanels",
14
+ "showBlockBreadcrumbs",
15
+ "showIconLabels",
16
+ "showListViewByDefault",
17
+ "isPublishSidebarEnabled",
18
+ "isComplementaryAreaVisible",
19
+ "pinnedItems"
20
+ ];
21
+ settingsToMoveToCore.forEach((setting) => {
22
+ if (data?.["core/edit-post"]?.[setting] !== void 0) {
11
23
  newData = {
12
24
  ...newData,
13
25
  core: {
14
26
  ...newData?.core,
15
- [setting]: data['core/edit-post'][setting]
27
+ [setting]: data["core/edit-post"][setting]
16
28
  }
17
29
  };
18
- delete newData['core/edit-post'][setting];
30
+ delete newData["core/edit-post"][setting];
19
31
  }
20
- if (data?.['core/edit-site']?.[setting] !== undefined) {
21
- delete newData['core/edit-site'][setting];
32
+ if (data?.["core/edit-site"]?.[setting] !== void 0) {
33
+ delete newData["core/edit-site"][setting];
22
34
  }
23
35
  });
24
- if (Object.keys((_newData$coreEditPo = newData?.['core/edit-post']) !== null && _newData$coreEditPo !== void 0 ? _newData$coreEditPo : {})?.length === 0) {
25
- delete newData['core/edit-post'];
36
+ if (Object.keys(newData?.["core/edit-post"] ?? {})?.length === 0) {
37
+ delete newData["core/edit-post"];
26
38
  }
27
- if (Object.keys((_newData$coreEditSi = newData?.['core/edit-site']) !== null && _newData$coreEditSi !== void 0 ? _newData$coreEditSi : {})?.length === 0) {
28
- delete newData['core/edit-site'];
39
+ if (Object.keys(newData?.["core/edit-site"] ?? {})?.length === 0) {
40
+ delete newData["core/edit-site"];
29
41
  }
30
42
  return newData;
31
43
  }
32
- //# sourceMappingURL=convert-editor-settings.js.map
44
+ export {
45
+ convertEditorSettings as default
46
+ };
47
+ //# sourceMappingURL=convert-editor-settings.js.map
@@ -1 +1,7 @@
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
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/migrations/preferences-package-data/convert-editor-settings.js"],
4
+ "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"],
5
+ "mappings": "AAIe,SAAR,sBAAwC,MAAO;AACrD,MAAI,UAAU;AACd,QAAM,uBAAuB;AAAA,IAC5B;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AAEA,uBAAqB,QAAS,CAAE,YAAa;AAC5C,QAAK,OAAQ,gBAAiB,IAAK,OAAQ,MAAM,QAAY;AAC5D,gBAAU;AAAA,QACT,GAAG;AAAA,QACH,MAAM;AAAA,UACL,GAAG,SAAS;AAAA,UACZ,CAAE,OAAQ,GAAG,KAAM,gBAAiB,EAAG,OAAQ;AAAA,QAChD;AAAA,MACD;AACA,aAAO,QAAS,gBAAiB,EAAG,OAAQ;AAAA,IAC7C;AAEA,QAAK,OAAQ,gBAAiB,IAAK,OAAQ,MAAM,QAAY;AAC5D,aAAO,QAAS,gBAAiB,EAAG,OAAQ;AAAA,IAC7C;AAAA,EACD,CAAE;AAEF,MAAK,OAAO,KAAM,UAAW,gBAAiB,KAAK,CAAC,CAAE,GAAG,WAAW,GAAI;AACvE,WAAO,QAAS,gBAAiB;AAAA,EAClC;AAEA,MAAK,OAAO,KAAM,UAAW,gBAAiB,KAAK,CAAC,CAAE,GAAG,WAAW,GAAI;AACvE,WAAO,QAAS,gBAAiB;AAAA,EAClC;AAEA,SAAO;AACR;",
6
+ "names": []
7
+ }
@@ -1,11 +1,11 @@
1
- /**
2
- * Internal dependencies
3
- */
4
- import convertComplementaryAreas from './convert-complementary-areas';
5
- import convertEditorSettings from './convert-editor-settings';
6
- export default function convertPreferencesPackageData(data) {
1
+ import convertComplementaryAreas from "./convert-complementary-areas";
2
+ import convertEditorSettings from "./convert-editor-settings";
3
+ function convertPreferencesPackageData(data) {
7
4
  let newData = convertComplementaryAreas(data);
8
5
  newData = convertEditorSettings(newData);
9
6
  return newData;
10
7
  }
11
- //# sourceMappingURL=index.js.map
8
+ export {
9
+ convertPreferencesPackageData as default
10
+ };
11
+ //# sourceMappingURL=index.js.map
@@ -1 +1,7 @@
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":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/migrations/preferences-package-data/index.js"],
4
+ "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"],
5
+ "mappings": "AAGA,OAAO,+BAA+B;AACtC,OAAO,2BAA2B;AAEnB,SAAR,8BAAgD,MAAO;AAC7D,MAAI,UAAU,0BAA2B,IAAK;AAC9C,YAAU,sBAAuB,OAAQ;AACzC,SAAO;AACR;",
6
+ "names": []
7
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/preferences-persistence",
3
- "version": "2.32.0",
3
+ "version": "2.32.1-next.b8c8708f3.0",
4
4
  "description": "Persistence utilities for `wordpress/preferences`.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -25,15 +25,22 @@
25
25
  },
26
26
  "main": "build/index.js",
27
27
  "module": "build-module/index.js",
28
+ "exports": {
29
+ ".": {
30
+ "types": "./build-types/index.d.ts",
31
+ "import": "./build-module/index.js",
32
+ "require": "./build/index.js"
33
+ },
34
+ "./package.json": "./package.json"
35
+ },
28
36
  "react-native": "src/index",
29
37
  "wpScript": true,
30
38
  "sideEffects": false,
31
39
  "dependencies": {
32
- "@babel/runtime": "7.25.7",
33
- "@wordpress/api-fetch": "^7.32.0"
40
+ "@wordpress/api-fetch": "^7.32.1-next.b8c8708f3.0"
34
41
  },
35
42
  "publishConfig": {
36
43
  "access": "public"
37
44
  },
38
- "gitHead": "a030b4c0e0695239b942c7dc18511782b64f10ed"
45
+ "gitHead": "67cfd7e661931aeb0d06bec894599d287a4f8d0f"
39
46
  }