@wordpress/preferences-persistence 2.56.0 → 3.0.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 (133) hide show
  1. package/README.md +7 -7
  2. package/build/create/debounce-async.cjs +2 -1
  3. package/build/create/debounce-async.cjs.map +3 -3
  4. package/build/create/index.cjs +11 -21
  5. package/build/create/index.cjs.map +4 -4
  6. package/build/get-newest-data.cjs +53 -0
  7. package/build/get-newest-data.cjs.map +7 -0
  8. package/build/index.cjs +8 -16
  9. package/build/index.cjs.map +4 -4
  10. package/build/is-preferences-data.cjs +29 -0
  11. package/build/is-preferences-data.cjs.map +7 -0
  12. package/build/local-storage.cjs +46 -0
  13. package/build/local-storage.cjs.map +7 -0
  14. package/build/migrations/legacy-local-storage-data/convert-edit-post-panels.cjs +2 -1
  15. package/build/migrations/legacy-local-storage-data/convert-edit-post-panels.cjs.map +3 -3
  16. package/build/migrations/legacy-local-storage-data/index.cjs +7 -5
  17. package/build/migrations/legacy-local-storage-data/index.cjs.map +4 -4
  18. package/build/migrations/legacy-local-storage-data/move-feature-preferences.cjs +2 -1
  19. package/build/migrations/legacy-local-storage-data/move-feature-preferences.cjs.map +3 -3
  20. package/build/migrations/legacy-local-storage-data/move-individual-preference.cjs +2 -1
  21. package/build/migrations/legacy-local-storage-data/move-individual-preference.cjs.map +3 -3
  22. package/build/migrations/legacy-local-storage-data/move-interface-enable-items.cjs +2 -1
  23. package/build/migrations/legacy-local-storage-data/move-interface-enable-items.cjs.map +3 -3
  24. package/build/migrations/legacy-local-storage-data/move-third-party-feature-preferences.cjs +2 -1
  25. package/build/migrations/legacy-local-storage-data/move-third-party-feature-preferences.cjs.map +3 -3
  26. package/build/migrations/legacy-local-storage-data/types.cjs +19 -0
  27. package/build/migrations/legacy-local-storage-data/types.cjs.map +7 -0
  28. package/build/migrations/preferences-package-data/convert-complementary-areas.cjs +15 -11
  29. package/build/migrations/preferences-package-data/convert-complementary-areas.cjs.map +3 -3
  30. package/build/migrations/preferences-package-data/convert-editor-settings.cjs +30 -14
  31. package/build/migrations/preferences-package-data/convert-editor-settings.cjs.map +4 -4
  32. package/build/migrations/preferences-package-data/index.cjs +2 -1
  33. package/build/migrations/preferences-package-data/index.cjs.map +3 -3
  34. package/build/types.cjs +19 -0
  35. package/build/types.cjs.map +7 -0
  36. package/build-module/create/debounce-async.mjs +1 -1
  37. package/build-module/create/debounce-async.mjs.map +3 -3
  38. package/build-module/create/index.mjs +10 -21
  39. package/build-module/create/index.mjs.map +3 -3
  40. package/build-module/get-newest-data.mjs +22 -0
  41. package/build-module/get-newest-data.mjs.map +7 -0
  42. package/build-module/index.mjs +7 -16
  43. package/build-module/index.mjs.map +3 -3
  44. package/build-module/is-preferences-data.mjs +8 -0
  45. package/build-module/is-preferences-data.mjs.map +7 -0
  46. package/build-module/local-storage.mjs +20 -0
  47. package/build-module/local-storage.mjs.map +7 -0
  48. package/build-module/migrations/legacy-local-storage-data/convert-edit-post-panels.mjs +1 -1
  49. package/build-module/migrations/legacy-local-storage-data/convert-edit-post-panels.mjs.map +3 -3
  50. package/build-module/migrations/legacy-local-storage-data/index.mjs +6 -5
  51. package/build-module/migrations/legacy-local-storage-data/index.mjs.map +3 -3
  52. package/build-module/migrations/legacy-local-storage-data/move-feature-preferences.mjs +1 -1
  53. package/build-module/migrations/legacy-local-storage-data/move-feature-preferences.mjs.map +3 -3
  54. package/build-module/migrations/legacy-local-storage-data/move-individual-preference.mjs +1 -1
  55. package/build-module/migrations/legacy-local-storage-data/move-individual-preference.mjs.map +3 -3
  56. package/build-module/migrations/legacy-local-storage-data/move-interface-enable-items.mjs +1 -1
  57. package/build-module/migrations/legacy-local-storage-data/move-interface-enable-items.mjs.map +3 -3
  58. package/build-module/migrations/legacy-local-storage-data/move-third-party-feature-preferences.mjs +1 -1
  59. package/build-module/migrations/legacy-local-storage-data/move-third-party-feature-preferences.mjs.map +3 -3
  60. package/build-module/migrations/legacy-local-storage-data/types.mjs +1 -0
  61. package/build-module/migrations/legacy-local-storage-data/types.mjs.map +7 -0
  62. package/build-module/migrations/preferences-package-data/convert-complementary-areas.mjs +14 -11
  63. package/build-module/migrations/preferences-package-data/convert-complementary-areas.mjs.map +3 -3
  64. package/build-module/migrations/preferences-package-data/convert-editor-settings.mjs +19 -14
  65. package/build-module/migrations/preferences-package-data/convert-editor-settings.mjs.map +3 -3
  66. package/build-module/migrations/preferences-package-data/index.mjs +1 -1
  67. package/build-module/migrations/preferences-package-data/index.mjs.map +3 -3
  68. package/build-module/types.mjs +1 -0
  69. package/build-module/types.mjs.map +7 -0
  70. package/build-types/create/debounce-async.d.ts +19 -0
  71. package/build-types/create/debounce-async.d.ts.map +1 -0
  72. package/build-types/create/index.d.ts +20 -0
  73. package/build-types/create/index.d.ts.map +1 -0
  74. package/build-types/get-newest-data.d.ts +11 -0
  75. package/build-types/get-newest-data.d.ts.map +1 -0
  76. package/build-types/index.d.ts +20 -0
  77. package/build-types/index.d.ts.map +1 -0
  78. package/build-types/is-preferences-data.d.ts +11 -0
  79. package/build-types/is-preferences-data.d.ts.map +1 -0
  80. package/build-types/local-storage.d.ts +19 -0
  81. package/build-types/local-storage.d.ts.map +1 -0
  82. package/build-types/migrations/legacy-local-storage-data/convert-edit-post-panels.d.ts +35 -0
  83. package/build-types/migrations/legacy-local-storage-data/convert-edit-post-panels.d.ts.map +1 -0
  84. package/build-types/migrations/legacy-local-storage-data/index.d.ts +22 -0
  85. package/build-types/migrations/legacy-local-storage-data/index.d.ts.map +1 -0
  86. package/build-types/migrations/legacy-local-storage-data/move-feature-preferences.d.ts +60 -0
  87. package/build-types/migrations/legacy-local-storage-data/move-feature-preferences.d.ts.map +1 -0
  88. package/build-types/migrations/legacy-local-storage-data/move-individual-preference.d.ts +42 -0
  89. package/build-types/migrations/legacy-local-storage-data/move-individual-preference.d.ts.map +1 -0
  90. package/build-types/migrations/legacy-local-storage-data/move-interface-enable-items.d.ts +50 -0
  91. package/build-types/migrations/legacy-local-storage-data/move-interface-enable-items.d.ts.map +1 -0
  92. package/build-types/migrations/legacy-local-storage-data/move-third-party-feature-preferences.d.ts +44 -0
  93. package/build-types/migrations/legacy-local-storage-data/move-third-party-feature-preferences.d.ts.map +1 -0
  94. package/build-types/migrations/legacy-local-storage-data/types.d.ts +60 -0
  95. package/build-types/migrations/legacy-local-storage-data/types.d.ts.map +1 -0
  96. package/build-types/migrations/preferences-package-data/convert-complementary-areas.d.ts +5 -0
  97. package/build-types/migrations/preferences-package-data/convert-complementary-areas.d.ts.map +1 -0
  98. package/build-types/migrations/preferences-package-data/convert-editor-settings.d.ts +5 -0
  99. package/build-types/migrations/preferences-package-data/convert-editor-settings.d.ts.map +1 -0
  100. package/build-types/migrations/preferences-package-data/index.d.ts +5 -0
  101. package/build-types/migrations/preferences-package-data/index.d.ts.map +1 -0
  102. package/build-types/types.d.ts +40 -0
  103. package/build-types/types.d.ts.map +1 -0
  104. package/package.json +7 -7
  105. package/src/create/{debounce-async.js → debounce-async.ts} +13 -10
  106. package/src/create/index.ts +95 -0
  107. package/src/create/test/debounce-async.js +2 -3
  108. package/src/create/test/index.jsdom.test.js +45 -0
  109. package/src/get-newest-data.ts +50 -0
  110. package/src/index.ts +40 -0
  111. package/src/is-preferences-data.ts +15 -0
  112. package/src/local-storage.ts +30 -0
  113. package/src/migrations/legacy-local-storage-data/{convert-edit-post-panels.js → convert-edit-post-panels.ts} +13 -5
  114. package/src/migrations/legacy-local-storage-data/{index.js → index.ts} +22 -15
  115. package/src/migrations/legacy-local-storage-data/{move-feature-preferences.js → move-feature-preferences.ts} +13 -7
  116. package/src/migrations/legacy-local-storage-data/{move-individual-preference.js → move-individual-preference.ts} +15 -12
  117. package/src/migrations/legacy-local-storage-data/{move-interface-enable-items.js → move-interface-enable-items.ts} +6 -2
  118. package/src/migrations/legacy-local-storage-data/{move-third-party-feature-preferences.js → move-third-party-feature-preferences.ts} +8 -4
  119. package/src/migrations/legacy-local-storage-data/test/index.js +6 -0
  120. package/src/migrations/legacy-local-storage-data/types.ts +66 -0
  121. package/src/migrations/preferences-package-data/convert-complementary-areas.ts +21 -0
  122. package/src/migrations/preferences-package-data/convert-editor-settings.ts +58 -0
  123. package/src/migrations/preferences-package-data/{index.js → index.ts} +4 -1
  124. package/src/migrations/preferences-package-data/test/convert-complementary-areas.js +10 -0
  125. package/src/migrations/preferences-package-data/test/convert-editor-settings.js +35 -0
  126. package/src/test/index.jsdom.test.js +95 -0
  127. package/src/test/local-storage.jsdom.test.js +50 -0
  128. package/src/types.ts +43 -0
  129. package/CHANGELOG.md +0 -226
  130. package/src/create/index.js +0 -105
  131. package/src/index.js +0 -47
  132. package/src/migrations/preferences-package-data/convert-complementary-areas.js +0 -16
  133. package/src/migrations/preferences-package-data/convert-editor-settings.js +0 -48
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/local-storage.ts"],
4
+ "sourcesContent": ["/**\n * Reads and parses a JSON value from local storage.\n *\n * @param key The local storage key.\n *\n * @return The parsed value, or `null` when the value is missing or invalid,\n * or local storage is unavailable.\n */\nexport function readStoredJSON( key: string ): unknown {\n\ttry {\n\t\tconst value = window.localStorage.getItem( key );\n\t\treturn value === null ? null : JSON.parse( value );\n\t} catch {\n\t\treturn null;\n\t}\n}\n\n/**\n * Stores a value in local storage as JSON.\n *\n * Failures, such as blocked storage or an exceeded quota, are ignored.\n *\n * @param key The local storage key.\n * @param value The value to store.\n */\nexport function writeStoredJSON( key: string, value: unknown ) {\n\ttry {\n\t\twindow.localStorage.setItem( key, JSON.stringify( value ) );\n\t} catch {}\n}\n"],
5
+ "mappings": ";AAQO,SAAS,eAAgB,KAAuB;AACtD,MAAI;AACH,UAAM,QAAQ,OAAO,aAAa,QAAS,GAAI;AAC/C,WAAO,UAAU,OAAO,OAAO,KAAK,MAAO,KAAM;AAAA,EAClD,QAAQ;AACP,WAAO;AAAA,EACR;AACD;AAUO,SAAS,gBAAiB,KAAa,OAAiB;AAC9D,MAAI;AACH,WAAO,aAAa,QAAS,KAAK,KAAK,UAAW,KAAM,CAAE;AAAA,EAC3D,QAAQ;AAAA,EAAC;AACV;",
6
+ "names": []
7
+ }
@@ -1,4 +1,4 @@
1
- // packages/preferences-persistence/src/migrations/legacy-local-storage-data/convert-edit-post-panels.js
1
+ // packages/preferences-persistence/src/migrations/legacy-local-storage-data/convert-edit-post-panels.ts
2
2
  function convertEditPostPanels(preferences) {
3
3
  const panels = preferences?.panels ?? {};
4
4
  return Object.keys(panels).reduce(
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../../src/migrations/legacy-local-storage-data/convert-edit-post-panels.js"],
4
- "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"],
5
- "mappings": ";AA+Be,SAAR,sBAAwC,aAAc;AAC5D,QAAM,SAAS,aAAa,UAAU,CAAC;AACvC,SAAO,OAAO,KAAM,MAAO,EAAE;AAAA,IAC5B,CAAE,eAAe,cAAe;AAC/B,YAAM,QAAQ,OAAQ,SAAU;AAEhC,UAAK,OAAO,YAAY,OAAQ;AAC/B,sBAAc,eAAe,KAAM,SAAU;AAAA,MAC9C;AAEA,UAAK,OAAO,WAAW,MAAO;AAC7B,sBAAc,WAAW,KAAM,SAAU;AAAA,MAC1C;AAEA,aAAO;AAAA,IACR;AAAA,IACA,EAAE,gBAAgB,CAAC,GAAG,YAAY,CAAC,EAAE;AAAA,EACtC;AACD;",
3
+ "sources": ["../../../src/migrations/legacy-local-storage-data/convert-edit-post-panels.ts"],
4
+ "sourcesContent": ["import type { ScopePreferences } from '../../types';\nimport type { EditPostPanels, LegacyEditPostPanel } from './types';\n\n/**\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 preferences A preferences object.\n *\n * @return The converted data.\n */\nexport default function convertEditPostPanels(\n\tpreferences: ScopePreferences\n): EditPostPanels {\n\tconst panels = ( preferences?.panels ?? {} ) as Record<\n\t\tstring,\n\t\tLegacyEditPostPanel | undefined\n\t>;\n\treturn Object.keys( panels ).reduce< EditPostPanels >(\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"],
5
+ "mappings": ";AAkCe,SAAR,sBACN,aACiB;AACjB,QAAM,SAAW,aAAa,UAAU,CAAC;AAIzC,SAAO,OAAO,KAAM,MAAO,EAAE;AAAA,IAC5B,CAAE,eAAe,cAAe;AAC/B,YAAM,QAAQ,OAAQ,SAAU;AAEhC,UAAK,OAAO,YAAY,OAAQ;AAC/B,sBAAc,eAAe,KAAM,SAAU;AAAA,MAC9C;AAEA,UAAK,OAAO,WAAW,MAAO;AAC7B,sBAAc,WAAW,KAAM,SAAU;AAAA,MAC1C;AAEA,aAAO;AAAA,IACR;AAAA,IACA,EAAE,gBAAgB,CAAC,GAAG,YAAY,CAAC,EAAE;AAAA,EACtC;AACD;",
6
6
  "names": []
7
7
  }
@@ -1,13 +1,13 @@
1
- // packages/preferences-persistence/src/migrations/legacy-local-storage-data/index.js
1
+ // packages/preferences-persistence/src/migrations/legacy-local-storage-data/index.ts
2
2
  import moveFeaturePreferences from "./move-feature-preferences.mjs";
3
3
  import moveThirdPartyFeaturePreferences from "./move-third-party-feature-preferences.mjs";
4
4
  import moveIndividualPreference from "./move-individual-preference.mjs";
5
5
  import moveInterfaceEnableItems from "./move-interface-enable-items.mjs";
6
6
  import convertEditPostPanels from "./convert-edit-post-panels.mjs";
7
+ import isPreferencesData from "../../is-preferences-data.mjs";
8
+ import { readStoredJSON } from "../../local-storage.mjs";
7
9
  function getLegacyData(userId) {
8
- const key = `WP_DATA_USER_${userId}`;
9
- const unparsedData = window.localStorage.getItem(key);
10
- return JSON.parse(unparsedData);
10
+ return readStoredJSON(`WP_DATA_USER_${userId}`);
11
11
  }
12
12
  function convertLegacyData(data) {
13
13
  if (!data) {
@@ -50,7 +50,8 @@ function convertLegacyData(data) {
50
50
  { from: "core/edit-site", to: "core/edit-site" },
51
51
  "editorMode"
52
52
  );
53
- return data?.["core/preferences"]?.preferences;
53
+ const preferences = data?.["core/preferences"]?.preferences;
54
+ return isPreferencesData(preferences) ? preferences : void 0;
54
55
  }
55
56
  function convertLegacyLocalStorageData(userId) {
56
57
  const data = getLegacyData(userId);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../../src/migrations/legacy-local-storage-data/index.js"],
4
- "sourcesContent": ["import 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"],
5
- "mappings": ";AAAA,OAAO,4BAA4B;AACnC,OAAO,sCAAsC;AAC7C,OAAO,8BAA8B;AACrC,OAAO,8BAA8B;AACrC,OAAO,2BAA2B;AASlC,SAAS,cAAe,QAAS;AAChC,QAAM,MAAM,gBAAiB,MAAO;AACpC,QAAM,eAAe,OAAO,aAAa,QAAS,GAAI;AACtD,SAAO,KAAK,MAAO,YAAa;AACjC;AAUO,SAAS,kBAAmB,MAAO;AACzC,MAAK,CAAE,MAAO;AACb;AAAA,EACD;AAIA,SAAO,uBAAwB,MAAM,mBAAoB;AACzD,SAAO,uBAAwB,MAAM,wBAAyB;AAC9D,SAAO,uBAAwB,MAAM,gBAAiB;AACtD,SAAO,uBAAwB,MAAM,gBAAiB;AAItD,SAAO,iCAAkC,IAAK;AAI9C,SAAO,yBAA0B,IAAK;AAItC,SAAO;AAAA,IACN;AAAA,IACA,EAAE,MAAM,kBAAkB,IAAI,iBAAiB;AAAA,IAC/C;AAAA,EACD;AACA,SAAO;AAAA,IACN;AAAA,IACA,EAAE,MAAM,kBAAkB,IAAI,iBAAiB;AAAA,IAC/C;AAAA,EACD;AACA,SAAO;AAAA,IACN;AAAA,IACA,EAAE,MAAM,kBAAkB,IAAI,iBAAiB;AAAA,IAC/C;AAAA,IACA;AAAA,EACD;AACA,SAAO;AAAA,IACN;AAAA,IACA,EAAE,MAAM,eAAe,IAAI,OAAO;AAAA,IAClC;AAAA,EACD;AACA,SAAO;AAAA,IACN;AAAA,IACA,EAAE,MAAM,kBAAkB,IAAI,OAAO;AAAA,IACrC;AAAA,EACD;AACA,SAAO;AAAA,IACN;AAAA,IACA,EAAE,MAAM,kBAAkB,IAAI,iBAAiB;AAAA,IAC/C;AAAA,EACD;AAIA,SAAO,OAAQ,kBAAmB,GAAG;AACtC;AAWe,SAAR,8BAAgD,QAAS;AAC/D,QAAM,OAAO,cAAe,MAAO;AACnC,SAAO,kBAAmB,IAAK;AAChC;",
3
+ "sources": ["../../../src/migrations/legacy-local-storage-data/index.ts"],
4
+ "sourcesContent": ["import 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';\nimport isPreferencesData from '../../is-preferences-data';\nimport { readStoredJSON } from '../../local-storage';\nimport type { ScopedPreferences } from '../../types';\nimport type { LegacyData } from './types';\n\n/**\n * Gets the legacy local storage data for a given user.\n *\n * @param userId The user id.\n *\n * @return The local storage data.\n */\nfunction getLegacyData( userId: string | number ): LegacyData | null {\n\treturn readStoredJSON( `WP_DATA_USER_${ userId }` ) as LegacyData | null;\n}\n\n/**\n * Converts data from the old `@wordpress/data` package format.\n *\n * @param data The legacy data in its original format.\n *\n * @return The converted data or `undefined` if there was\n * nothing to convert.\n */\nexport function convertLegacyData(\n\tdata: LegacyData | null | undefined\n): ScopedPreferences | undefined {\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\tconst preferences = data?.[ 'core/preferences' ]?.preferences;\n\treturn isPreferencesData( preferences ) ? preferences : undefined;\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 userId The user id.\n *\n * @return The converted data or undefined if no local\n * storage data could be found.\n */\nexport default function convertLegacyLocalStorageData(\n\tuserId: string | number\n): ScopedPreferences | undefined {\n\tconst data = getLegacyData( userId );\n\treturn convertLegacyData( data );\n}\n"],
5
+ "mappings": ";AAAA,OAAO,4BAA4B;AACnC,OAAO,sCAAsC;AAC7C,OAAO,8BAA8B;AACrC,OAAO,8BAA8B;AACrC,OAAO,2BAA2B;AAClC,OAAO,uBAAuB;AAC9B,SAAS,sBAAsB;AAW/B,SAAS,cAAe,QAA6C;AACpE,SAAO,eAAgB,gBAAiB,MAAO,EAAG;AACnD;AAUO,SAAS,kBACf,MACgC;AAChC,MAAK,CAAE,MAAO;AACb;AAAA,EACD;AAIA,SAAO,uBAAwB,MAAM,mBAAoB;AACzD,SAAO,uBAAwB,MAAM,wBAAyB;AAC9D,SAAO,uBAAwB,MAAM,gBAAiB;AACtD,SAAO,uBAAwB,MAAM,gBAAiB;AAItD,SAAO,iCAAkC,IAAK;AAI9C,SAAO,yBAA0B,IAAK;AAItC,SAAO;AAAA,IACN;AAAA,IACA,EAAE,MAAM,kBAAkB,IAAI,iBAAiB;AAAA,IAC/C;AAAA,EACD;AACA,SAAO;AAAA,IACN;AAAA,IACA,EAAE,MAAM,kBAAkB,IAAI,iBAAiB;AAAA,IAC/C;AAAA,EACD;AACA,SAAO;AAAA,IACN;AAAA,IACA,EAAE,MAAM,kBAAkB,IAAI,iBAAiB;AAAA,IAC/C;AAAA,IACA;AAAA,EACD;AACA,SAAO;AAAA,IACN;AAAA,IACA,EAAE,MAAM,eAAe,IAAI,OAAO;AAAA,IAClC;AAAA,EACD;AACA,SAAO;AAAA,IACN;AAAA,IACA,EAAE,MAAM,kBAAkB,IAAI,OAAO;AAAA,IACrC;AAAA,EACD;AACA,SAAO;AAAA,IACN;AAAA,IACA,EAAE,MAAM,kBAAkB,IAAI,iBAAiB;AAAA,IAC/C;AAAA,EACD;AAIA,QAAM,cAAc,OAAQ,kBAAmB,GAAG;AAClD,SAAO,kBAAmB,WAAY,IAAI,cAAc;AACzD;AAWe,SAAR,8BACN,QACgC;AAChC,QAAM,OAAO,cAAe,MAAO;AACnC,SAAO,kBAAmB,IAAK;AAChC;",
6
6
  "names": []
7
7
  }
@@ -1,4 +1,4 @@
1
- // packages/preferences-persistence/src/migrations/legacy-local-storage-data/move-feature-preferences.js
1
+ // packages/preferences-persistence/src/migrations/legacy-local-storage-data/move-feature-preferences.ts
2
2
  function moveFeaturePreferences(state, sourceStoreName) {
3
3
  const preferencesStoreName = "core/preferences";
4
4
  const interfaceStoreName = "core/interface";
@@ -1,7 +1,7 @@
1
1
  {
2
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;",
3
+ "sources": ["../../../src/migrations/legacy-local-storage-data/move-feature-preferences.ts"],
4
+ "sourcesContent": ["import type { FeaturePreferences, LegacyData } from './types';\n\n/**\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 state The state before migration.\n * @param sourceStoreName The name of the store that has persisted\n * preferences to migrate to the preferences\n * package.\n * @return The migrated state\n */\nexport default function moveFeaturePreferences(\n\tstate: LegacyData,\n\tsourceStoreName: string\n): LegacyData {\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 as\n\t\tFeaturePreferences | undefined;\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": ";AA2De,SAAR,uBACN,OACA,iBACa;AACb,QAAM,uBAAuB;AAC7B,QAAM,qBAAqB;AAM3B,QAAM,oBACL,QAAS,kBAAmB,GAAG,aAAa,WAC3C,eACD;AACD,QAAM,iBAAiB,QAAS,eAAgB,GAAG,aAAa;AAEhE,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
6
  "names": []
7
7
  }
@@ -1,4 +1,4 @@
1
- // packages/preferences-persistence/src/migrations/legacy-local-storage-data/move-individual-preference.js
1
+ // packages/preferences-persistence/src/migrations/legacy-local-storage-data/move-individual-preference.ts
2
2
  var identity = (arg) => arg;
3
3
  function moveIndividualPreferenceToPreferences(state, { from: sourceStoreName, to: scope }, key, convert = identity) {
4
4
  const preferencesStoreName = "core/preferences";
@@ -1,7 +1,7 @@
1
1
  {
2
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,IAAM,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;",
3
+ "sources": ["../../../src/migrations/legacy-local-storage-data/move-individual-preference.ts"],
4
+ "sourcesContent": ["import type { ScopePreferences } from '../../types';\nimport type { LegacyData } from './types';\n\nconst identity = < T >( arg: T ) => 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 state The original state.\n * @param migrate An options object that contains details of the migration.\n * @param migrate.from The name of the store to migrate from.\n * @param migrate.to The scope in the preferences store to migrate to.\n * @param key The key in the preferences object to migrate.\n * @param convert A function that converts preferences from one format to another.\n */\nexport default function moveIndividualPreferenceToPreferences(\n\tstate: LegacyData,\n\t{ from: sourceStoreName, to: scope }: { from: string; to: string },\n\tkey: string,\n\tconvert: ( preferences: ScopePreferences ) => object = identity\n): LegacyData {\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": ";AAGA,IAAM,WAAW,CAAO,QAAY;AAqCrB,SAAR,sCACN,OACA,EAAE,MAAM,iBAAiB,IAAI,MAAM,GACnC,KACA,UAAuD,UAC1C;AACb,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
6
  "names": []
7
7
  }
@@ -1,4 +1,4 @@
1
- // packages/preferences-persistence/src/migrations/legacy-local-storage-data/move-interface-enable-items.js
1
+ // packages/preferences-persistence/src/migrations/legacy-local-storage-data/move-interface-enable-items.ts
2
2
  function moveInterfaceEnableItems(state) {
3
3
  const interfaceStoreName = "core/interface";
4
4
  const preferencesStoreName = "core/preferences";
@@ -1,7 +1,7 @@
1
1
  {
2
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;",
3
+ "sources": ["../../../src/migrations/legacy-local-storage-data/move-interface-enable-items.ts"],
4
+ "sourcesContent": ["import type { LegacyData } from './types';\n\n/**\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 state The local storage state.\n */\nexport default function moveInterfaceEnableItems(\n\tstate: LegacyData\n): LegacyData {\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": ";AAiDe,SAAR,yBACN,OACa;AACb,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
6
  "names": []
7
7
  }
@@ -1,4 +1,4 @@
1
- // packages/preferences-persistence/src/migrations/legacy-local-storage-data/move-third-party-feature-preferences.js
1
+ // packages/preferences-persistence/src/migrations/legacy-local-storage-data/move-third-party-feature-preferences.ts
2
2
  function moveThirdPartyFeaturePreferencesToPreferences(state) {
3
3
  const interfaceStoreName = "core/interface";
4
4
  const preferencesStoreName = "core/preferences";
@@ -1,7 +1,7 @@
1
1
  {
2
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;",
3
+ "sources": ["../../../src/migrations/legacy-local-storage-data/move-third-party-feature-preferences.ts"],
4
+ "sourcesContent": ["import type { LegacyData } from './types';\n\n/**\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 state The local storage state\n *\n * @return The state with third party preferences moved to the\n * preferences data structure.\n */\nexport default function moveThirdPartyFeaturePreferencesToPreferences(\n\tstate: LegacyData\n): LegacyData {\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": ";AA2Ce,SAAR,8CACN,OACa;AACb,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
6
  "names": []
7
7
  }
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=types.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -1,16 +1,19 @@
1
- // packages/preferences-persistence/src/migrations/preferences-package-data/convert-complementary-areas.js
1
+ // packages/preferences-persistence/src/migrations/preferences-package-data/convert-complementary-areas.ts
2
2
  function convertComplementaryAreas(state) {
3
- return Object.keys(state).reduce((stateAccumulator, scope) => {
4
- const scopeData = state[scope];
5
- if (scopeData?.complementaryArea) {
6
- const updatedScopeData = { ...scopeData };
7
- delete updatedScopeData.complementaryArea;
8
- updatedScopeData.isComplementaryAreaVisible = true;
9
- stateAccumulator[scope] = updatedScopeData;
3
+ return Object.keys(state).reduce(
4
+ (stateAccumulator, scope) => {
5
+ const scopeData = state[scope];
6
+ if (scopeData?.complementaryArea) {
7
+ const updatedScopeData = { ...scopeData };
8
+ delete updatedScopeData.complementaryArea;
9
+ updatedScopeData.isComplementaryAreaVisible = true;
10
+ stateAccumulator[scope] = updatedScopeData;
11
+ return stateAccumulator;
12
+ }
10
13
  return stateAccumulator;
11
- }
12
- return stateAccumulator;
13
- }, state);
14
+ },
15
+ { ...state }
16
+ );
14
17
  }
15
18
  export {
16
19
  convertComplementaryAreas as default
@@ -1,7 +1,7 @@
1
1
  {
2
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;",
3
+ "sources": ["../../../src/migrations/preferences-package-data/convert-complementary-areas.ts"],
4
+ "sourcesContent": ["import type { ScopedPreferences } from '../../types';\n\nexport default function convertComplementaryAreas( state: ScopedPreferences ) {\n\treturn Object.keys( state ).reduce(\n\t\t( stateAccumulator, scope ) => {\n\t\t\tconst scopeData = state[ scope ];\n\n\t\t\t// If a complementary area is truthy, convert it to the `isComplementaryAreaVisible` boolean.\n\t\t\tif ( scopeData?.complementaryArea ) {\n\t\t\t\tconst updatedScopeData = { ...scopeData };\n\t\t\t\tdelete updatedScopeData.complementaryArea;\n\t\t\t\tupdatedScopeData.isComplementaryAreaVisible = true;\n\t\t\t\tstateAccumulator[ scope ] = updatedScopeData;\n\t\t\t\treturn stateAccumulator;\n\t\t\t}\n\n\t\t\treturn stateAccumulator;\n\t\t},\n\t\t{ ...state }\n\t);\n}\n"],
5
+ "mappings": ";AAEe,SAAR,0BAA4C,OAA2B;AAC7E,SAAO,OAAO,KAAM,KAAM,EAAE;AAAA,IAC3B,CAAE,kBAAkB,UAAW;AAC9B,YAAM,YAAY,MAAO,KAAM;AAG/B,UAAK,WAAW,mBAAoB;AACnC,cAAM,mBAAmB,EAAE,GAAG,UAAU;AACxC,eAAO,iBAAiB;AACxB,yBAAiB,6BAA6B;AAC9C,yBAAkB,KAAM,IAAI;AAC5B,eAAO;AAAA,MACR;AAEA,aAAO;AAAA,IACR;AAAA,IACA,EAAE,GAAG,MAAM;AAAA,EACZ;AACD;",
6
6
  "names": []
7
7
  }
@@ -1,6 +1,10 @@
1
- // packages/preferences-persistence/src/migrations/preferences-package-data/convert-editor-settings.js
1
+ // packages/preferences-persistence/src/migrations/preferences-package-data/convert-editor-settings.ts
2
+ import isPreferencesData from "../../is-preferences-data.mjs";
3
+ var copyScope = (scope) => isPreferencesData(scope) ? { ...scope } : void 0;
2
4
  function convertEditorSettings(data) {
3
- let newData = data;
5
+ const newData = { ...data };
6
+ const editPost = copyScope(data["core/edit-post"]);
7
+ const editSite = copyScope(data["core/edit-site"]);
4
8
  const settingsToMoveToCore = [
5
9
  "allowRightClickOverrides",
6
10
  "distractionFree",
@@ -20,24 +24,25 @@ function convertEditorSettings(data) {
20
24
  "pinnedItems"
21
25
  ];
22
26
  settingsToMoveToCore.forEach((setting) => {
23
- if (data?.["core/edit-post"]?.[setting] !== void 0) {
24
- newData = {
25
- ...newData,
26
- core: {
27
- ...newData?.core,
28
- [setting]: data["core/edit-post"][setting]
29
- }
27
+ if (editPost?.[setting] !== void 0) {
28
+ newData.core = {
29
+ ...copyScope(newData.core),
30
+ [setting]: editPost[setting]
30
31
  };
31
- delete newData["core/edit-post"][setting];
32
+ delete editPost[setting];
32
33
  }
33
- if (data?.["core/edit-site"]?.[setting] !== void 0) {
34
- delete newData["core/edit-site"][setting];
34
+ if (editSite?.[setting] !== void 0) {
35
+ delete editSite[setting];
35
36
  }
36
37
  });
37
- if (Object.keys(newData?.["core/edit-post"] ?? {})?.length === 0) {
38
+ if (editPost && Object.keys(editPost).length > 0) {
39
+ newData["core/edit-post"] = editPost;
40
+ } else {
38
41
  delete newData["core/edit-post"];
39
42
  }
40
- if (Object.keys(newData?.["core/edit-site"] ?? {})?.length === 0) {
43
+ if (editSite && Object.keys(editSite).length > 0) {
44
+ newData["core/edit-site"] = editSite;
45
+ } else {
41
46
  delete newData["core/edit-site"];
42
47
  }
43
48
  return newData;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../../src/migrations/preferences-package-data/convert-editor-settings.js"],
4
- "sourcesContent": ["export 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": ";AAAe,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;",
3
+ "sources": ["../../../src/migrations/preferences-package-data/convert-editor-settings.ts"],
4
+ "sourcesContent": ["import isPreferencesData from '../../is-preferences-data';\nimport type { ScopedPreferences } from '../../types';\n\nconst copyScope = ( scope: unknown ) =>\n\tisPreferencesData( scope ) ? { ...scope } : undefined;\n\nexport default function convertEditorSettings( data: ScopedPreferences ) {\n\tconst newData = { ...data };\n\tconst editPost = copyScope( data[ 'core/edit-post' ] );\n\tconst editSite = copyScope( data[ 'core/edit-site' ] );\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 ( editPost?.[ setting ] !== undefined ) {\n\t\t\tnewData.core = {\n\t\t\t\t...copyScope( newData.core ),\n\t\t\t\t[ setting ]: editPost[ setting ],\n\t\t\t};\n\t\t\tdelete editPost[ setting ];\n\t\t}\n\n\t\tif ( editSite?.[ setting ] !== undefined ) {\n\t\t\tdelete editSite[ setting ];\n\t\t}\n\t} );\n\n\t// Empty and invalid scopes are removed rather than persisted.\n\tif ( editPost && Object.keys( editPost ).length > 0 ) {\n\t\tnewData[ 'core/edit-post' ] = editPost;\n\t} else {\n\t\tdelete newData[ 'core/edit-post' ];\n\t}\n\n\tif ( editSite && Object.keys( editSite ).length > 0 ) {\n\t\tnewData[ 'core/edit-site' ] = editSite;\n\t} else {\n\t\tdelete newData[ 'core/edit-site' ];\n\t}\n\n\treturn newData;\n}\n"],
5
+ "mappings": ";AAAA,OAAO,uBAAuB;AAG9B,IAAM,YAAY,CAAE,UACnB,kBAAmB,KAAM,IAAI,EAAE,GAAG,MAAM,IAAI;AAE9B,SAAR,sBAAwC,MAA0B;AACxE,QAAM,UAAU,EAAE,GAAG,KAAK;AAC1B,QAAM,WAAW,UAAW,KAAM,gBAAiB,CAAE;AACrD,QAAM,WAAW,UAAW,KAAM,gBAAiB,CAAE;AACrD,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,WAAY,OAAQ,MAAM,QAAY;AAC1C,cAAQ,OAAO;AAAA,QACd,GAAG,UAAW,QAAQ,IAAK;AAAA,QAC3B,CAAE,OAAQ,GAAG,SAAU,OAAQ;AAAA,MAChC;AACA,aAAO,SAAU,OAAQ;AAAA,IAC1B;AAEA,QAAK,WAAY,OAAQ,MAAM,QAAY;AAC1C,aAAO,SAAU,OAAQ;AAAA,IAC1B;AAAA,EACD,CAAE;AAGF,MAAK,YAAY,OAAO,KAAM,QAAS,EAAE,SAAS,GAAI;AACrD,YAAS,gBAAiB,IAAI;AAAA,EAC/B,OAAO;AACN,WAAO,QAAS,gBAAiB;AAAA,EAClC;AAEA,MAAK,YAAY,OAAO,KAAM,QAAS,EAAE,SAAS,GAAI;AACrD,YAAS,gBAAiB,IAAI;AAAA,EAC/B,OAAO;AACN,WAAO,QAAS,gBAAiB;AAAA,EAClC;AAEA,SAAO;AACR;",
6
6
  "names": []
7
7
  }
@@ -1,4 +1,4 @@
1
- // packages/preferences-persistence/src/migrations/preferences-package-data/index.js
1
+ // packages/preferences-persistence/src/migrations/preferences-package-data/index.ts
2
2
  import convertComplementaryAreas from "./convert-complementary-areas.mjs";
3
3
  import convertEditorSettings from "./convert-editor-settings.mjs";
4
4
  function convertPreferencesPackageData(data) {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../../src/migrations/preferences-package-data/index.js"],
4
- "sourcesContent": ["import 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": ";AAAA,OAAO,+BAA+B;AACtC,OAAO,2BAA2B;AAEnB,SAAR,8BAAgD,MAAO;AAC7D,MAAI,UAAU,0BAA2B,IAAK;AAC9C,YAAU,sBAAuB,OAAQ;AACzC,SAAO;AACR;",
3
+ "sources": ["../../../src/migrations/preferences-package-data/index.ts"],
4
+ "sourcesContent": ["import convertComplementaryAreas from './convert-complementary-areas';\nimport convertEditorSettings from './convert-editor-settings';\nimport type { ScopedPreferences } from '../../types';\n\nexport default function convertPreferencesPackageData(\n\tdata: ScopedPreferences\n) {\n\tlet newData = convertComplementaryAreas( data );\n\tnewData = convertEditorSettings( newData );\n\treturn newData;\n}\n"],
5
+ "mappings": ";AAAA,OAAO,+BAA+B;AACtC,OAAO,2BAA2B;AAGnB,SAAR,8BACN,MACC;AACD,MAAI,UAAU,0BAA2B,IAAK;AAC9C,YAAU,sBAAuB,OAAQ;AACzC,SAAO;AACR;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=types.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Performs a leading edge debounce of async functions.
3
+ *
4
+ * If three functions are throttled at the same time:
5
+ * - The first happens immediately.
6
+ * - The second is never called.
7
+ * - The third happens `delayMS` milliseconds after the first has resolved.
8
+ *
9
+ * This is distinct from `{ debounce } from @wordpress/compose` in that it
10
+ * waits for promise resolution.
11
+ *
12
+ * @param func A function that returns a promise.
13
+ * @param delayMS A delay in milliseconds.
14
+ *
15
+ * @return A function that debounce whatever function is passed
16
+ * to it.
17
+ */
18
+ export default function debounceAsync<Args extends unknown[], Result>(func: (...args: Args) => Promise<Result>, delayMS: number): (...args: Args) => Promise<Result>;
19
+ //# sourceMappingURL=debounce-async.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debounce-async.d.ts","sourceRoot":"","sources":["../../src/create/debounce-async.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,OAAO,UAAU,aAAa,CAAE,IAAI,SAAS,OAAO,EAAE,EAAE,MAAM,EACpE,IAAI,EAAE,CAAE,GAAG,IAAI,EAAE,IAAI,KAAM,OAAO,CAAE,MAAM,CAAE,EAC5C,OAAO,EAAE,MAAM,GACb,CAAE,GAAG,IAAI,EAAE,IAAI,KAAM,OAAO,CAAE,MAAM,CAAE,CAyDxC"}
@@ -0,0 +1,20 @@
1
+ import type { CreateOptions, PersistenceLayer } from '../types';
2
+ /**
3
+ * Creates a persistence layer that stores data in WordPress user meta via the
4
+ * REST API.
5
+ *
6
+ * @param {CreateOptions} [options]
7
+ * @param {PreferencesData|null} [options.preloadedData] Any persisted preferences data that should be preloaded.
8
+ * When set, the persistence layer will avoid fetching data
9
+ * from the REST API.
10
+ * @param {string} [options.localStorageRestoreKey] The key to use for restoring the localStorage backup, used
11
+ * when the persistence layer calls `localStorage.getItem` or
12
+ * `localStorage.setItem`.
13
+ * @param {number} [options.requestDebounceMS] Debounce requests to the API so that they only occur at
14
+ * minimum every `requestDebounceMS` milliseconds, and don't
15
+ * swamp the server. Defaults to 2500ms.
16
+ *
17
+ * @return A persistence layer for WordPress user meta.
18
+ */
19
+ export default function create({ preloadedData, localStorageRestoreKey, requestDebounceMS, }?: CreateOptions): PersistenceLayer;
20
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/create/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACX,aAAa,EACb,gBAAgB,EAEhB,MAAM,UAAU,CAAC;AAElB;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,OAAO,UAAU,MAAM,CAAE,EAC/B,aAAa,EACb,sBAAsD,EACtD,iBAAwB,GACxB,GAAE,aAAkB,GAAI,gBAAgB,CA8DxC"}
@@ -0,0 +1,11 @@
1
+ import type { ScopedPreferences } from './types';
2
+ /**
3
+ * Gets the newest persisted preferences, migrated to the current format.
4
+ *
5
+ * @param serverData Preferences data from the server.
6
+ * @param localStorageRestoreKey The key of the local storage backup.
7
+ *
8
+ * @return The migrated preferences, or `undefined` when there are none.
9
+ */
10
+ export default function getNewestData(serverData: unknown, localStorageRestoreKey: string): ScopedPreferences | undefined;
11
+ //# sourceMappingURL=get-newest-data.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-newest-data.d.ts","sourceRoot":"","sources":["../src/get-newest-data.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAmB,iBAAiB,EAAE,MAAM,SAAS,CAAC;AA8BlE;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,UAAU,aAAa,CACpC,UAAU,EAAE,OAAO,EACnB,sBAAsB,EAAE,MAAM,GAC5B,iBAAiB,GAAG,SAAS,CAK/B"}
@@ -0,0 +1,20 @@
1
+ import create from './create';
2
+ import type { PersistenceLayer } from './types';
3
+ export { create };
4
+ export type * from './types';
5
+ /**
6
+ * Creates the persistence layer with preloaded data.
7
+ *
8
+ * It prioritizes any data from the server, but falls back first to localStorage
9
+ * restore data, and then to any legacy data.
10
+ *
11
+ * This function is used internally by WordPress in an inline script, so
12
+ * prefixed with `__unstable`.
13
+ *
14
+ * @param serverData Preferences data preloaded from the server.
15
+ * @param userId The user id.
16
+ *
17
+ * @return The persistence layer initialized with the preloaded data.
18
+ */
19
+ export declare function __unstableCreatePersistenceLayer(serverData: unknown, userId: string | number): PersistenceLayer;
20
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,UAAU,CAAC;AAG9B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD,OAAO,EAAE,MAAM,EAAE,CAAC;AAElB,mBAAmB,SAAS,CAAC;AAE7B;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gCAAgC,CAC/C,UAAU,EAAE,OAAO,EACnB,MAAM,EAAE,MAAM,GAAG,MAAM,GACrB,gBAAgB,CAalB"}
@@ -0,0 +1,11 @@
1
+ import type { PreferencesData } from './types';
2
+ /**
3
+ * Checks whether persisted data is a preferences object. Empty user meta
4
+ * reaches the client as `[]` or `''`, which must not be used as preferences.
5
+ *
6
+ * @param data The persisted data.
7
+ *
8
+ * @return Whether the data is a preferences object.
9
+ */
10
+ export default function isPreferencesData(data: unknown): data is PreferencesData;
11
+ //# sourceMappingURL=is-preferences-data.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-preferences-data.d.ts","sourceRoot":"","sources":["../src/is-preferences-data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,UAAU,iBAAiB,CACxC,IAAI,EAAE,OAAO,GACX,IAAI,IAAI,eAAe,CAEzB"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Reads and parses a JSON value from local storage.
3
+ *
4
+ * @param key The local storage key.
5
+ *
6
+ * @return The parsed value, or `null` when the value is missing or invalid,
7
+ * or local storage is unavailable.
8
+ */
9
+ export declare function readStoredJSON(key: string): unknown;
10
+ /**
11
+ * Stores a value in local storage as JSON.
12
+ *
13
+ * Failures, such as blocked storage or an exceeded quota, are ignored.
14
+ *
15
+ * @param key The local storage key.
16
+ * @param value The value to store.
17
+ */
18
+ export declare function writeStoredJSON(key: string, value: unknown): void;
19
+ //# sourceMappingURL=local-storage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"local-storage.d.ts","sourceRoot":"","sources":["../src/local-storage.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAE,GAAG,EAAE,MAAM,GAAI,OAAO,CAOrD;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,QAI3D"}
@@ -0,0 +1,35 @@
1
+ import type { ScopePreferences } from '../../types';
2
+ import type { EditPostPanels } from './types';
3
+ /**
4
+ * Convert the post editor's panels state from:
5
+ * ```
6
+ * {
7
+ * panels: {
8
+ * tags: {
9
+ * enabled: true,
10
+ * opened: true,
11
+ * },
12
+ * permalinks: {
13
+ * enabled: false,
14
+ * opened: false,
15
+ * },
16
+ * },
17
+ * }
18
+ * ```
19
+ *
20
+ * to a new, more concise data structure:
21
+ * {
22
+ * inactivePanels: [
23
+ * 'permalinks',
24
+ * ],
25
+ * openPanels: [
26
+ * 'tags',
27
+ * ],
28
+ * }
29
+ *
30
+ * @param preferences A preferences object.
31
+ *
32
+ * @return The converted data.
33
+ */
34
+ export default function convertEditPostPanels(preferences: ScopePreferences): EditPostPanels;
35
+ //# sourceMappingURL=convert-edit-post-panels.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convert-edit-post-panels.d.ts","sourceRoot":"","sources":["../../../src/migrations/legacy-local-storage-data/convert-edit-post-panels.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,KAAK,EAAE,cAAc,EAAuB,MAAM,SAAS,CAAC;AAEnE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAC5C,WAAW,EAAE,gBAAgB,GAC3B,cAAc,CAqBhB"}