@wordpress/preferences-persistence 2.57.0 → 3.1.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 (136) hide show
  1. package/README.md +7 -7
  2. package/build/create/debounce-async.cjs +55 -58
  3. package/build/create/debounce-async.cjs.map +1 -7
  4. package/build/create/index.cjs +75 -91
  5. package/build/create/index.cjs.map +1 -7
  6. package/build/get-newest-data.cjs +64 -0
  7. package/build/get-newest-data.cjs.map +1 -0
  8. package/build/index.cjs +52 -53
  9. package/build/index.cjs.map +1 -7
  10. package/build/is-preferences-data.cjs +20 -0
  11. package/build/is-preferences-data.cjs.map +1 -0
  12. package/build/local-storage.cjs +39 -0
  13. package/build/local-storage.cjs.map +1 -0
  14. package/build/migrations/legacy-local-storage-data/convert-edit-post-panels.cjs +49 -38
  15. package/build/migrations/legacy-local-storage-data/convert-edit-post-panels.cjs.map +1 -7
  16. package/build/migrations/legacy-local-storage-data/index.cjs +95 -83
  17. package/build/migrations/legacy-local-storage-data/index.cjs.map +1 -7
  18. package/build/migrations/legacy-local-storage-data/move-feature-preferences.cjs +106 -77
  19. package/build/migrations/legacy-local-storage-data/move-feature-preferences.cjs.map +1 -7
  20. package/build/migrations/legacy-local-storage-data/move-individual-preference.cjs +70 -58
  21. package/build/migrations/legacy-local-storage-data/move-individual-preference.cjs.map +1 -7
  22. package/build/migrations/legacy-local-storage-data/move-interface-enable-items.cjs +93 -75
  23. package/build/migrations/legacy-local-storage-data/move-interface-enable-items.cjs.map +1 -7
  24. package/build/migrations/legacy-local-storage-data/move-third-party-feature-preferences.cjs +77 -65
  25. package/build/migrations/legacy-local-storage-data/move-third-party-feature-preferences.cjs.map +1 -7
  26. package/build/migrations/legacy-local-storage-data/types.cjs +5 -0
  27. package/build/migrations/preferences-package-data/convert-complementary-areas.cjs +19 -35
  28. package/build/migrations/preferences-package-data/convert-complementary-areas.cjs.map +1 -7
  29. package/build/migrations/preferences-package-data/convert-editor-settings.cjs +62 -60
  30. package/build/migrations/preferences-package-data/convert-editor-settings.cjs.map +1 -7
  31. package/build/migrations/preferences-package-data/index.cjs +29 -32
  32. package/build/migrations/preferences-package-data/index.cjs.map +1 -7
  33. package/build/types.cjs +5 -0
  34. package/build-module/create/debounce-async.mjs +51 -39
  35. package/build-module/create/debounce-async.mjs.map +1 -7
  36. package/build-module/create/index.mjs +51 -67
  37. package/build-module/create/index.mjs.map +1 -7
  38. package/build-module/get-newest-data.mjs +36 -0
  39. package/build-module/get-newest-data.mjs.map +1 -0
  40. package/build-module/index.mjs +24 -25
  41. package/build-module/index.mjs.map +1 -7
  42. package/build-module/is-preferences-data.mjs +15 -0
  43. package/build-module/is-preferences-data.mjs.map +1 -0
  44. package/build-module/local-storage.mjs +33 -0
  45. package/build-module/local-storage.mjs.map +1 -0
  46. package/build-module/migrations/legacy-local-storage-data/convert-edit-post-panels.mjs +45 -19
  47. package/build-module/migrations/legacy-local-storage-data/convert-edit-post-panels.mjs.map +1 -7
  48. package/build-module/migrations/legacy-local-storage-data/index.mjs +65 -52
  49. package/build-module/migrations/legacy-local-storage-data/index.mjs.map +1 -7
  50. package/build-module/migrations/legacy-local-storage-data/move-feature-preferences.mjs +102 -58
  51. package/build-module/migrations/legacy-local-storage-data/move-feature-preferences.mjs.map +1 -7
  52. package/build-module/migrations/legacy-local-storage-data/move-individual-preference.mjs +66 -39
  53. package/build-module/migrations/legacy-local-storage-data/move-individual-preference.mjs.map +1 -7
  54. package/build-module/migrations/legacy-local-storage-data/move-interface-enable-items.mjs +89 -56
  55. package/build-module/migrations/legacy-local-storage-data/move-interface-enable-items.mjs.map +1 -7
  56. package/build-module/migrations/legacy-local-storage-data/move-third-party-feature-preferences.mjs +73 -46
  57. package/build-module/migrations/legacy-local-storage-data/move-third-party-feature-preferences.mjs.map +1 -7
  58. package/build-module/migrations/legacy-local-storage-data/types.mjs +0 -0
  59. package/build-module/migrations/preferences-package-data/convert-complementary-areas.mjs +15 -16
  60. package/build-module/migrations/preferences-package-data/convert-complementary-areas.mjs.map +1 -7
  61. package/build-module/migrations/preferences-package-data/convert-editor-settings.mjs +41 -46
  62. package/build-module/migrations/preferences-package-data/convert-editor-settings.mjs.map +1 -7
  63. package/build-module/migrations/preferences-package-data/index.mjs +7 -8
  64. package/build-module/migrations/preferences-package-data/index.mjs.map +1 -7
  65. package/build-module/types.mjs +0 -0
  66. package/build-types/create/debounce-async.d.ts +19 -0
  67. package/build-types/create/debounce-async.d.ts.map +1 -0
  68. package/build-types/create/index.d.ts +20 -0
  69. package/build-types/create/index.d.ts.map +1 -0
  70. package/build-types/get-newest-data.d.ts +11 -0
  71. package/build-types/get-newest-data.d.ts.map +1 -0
  72. package/build-types/index.d.ts +20 -0
  73. package/build-types/index.d.ts.map +1 -0
  74. package/build-types/is-preferences-data.d.ts +11 -0
  75. package/build-types/is-preferences-data.d.ts.map +1 -0
  76. package/build-types/local-storage.d.ts +19 -0
  77. package/build-types/local-storage.d.ts.map +1 -0
  78. package/build-types/migrations/legacy-local-storage-data/convert-edit-post-panels.d.ts +35 -0
  79. package/build-types/migrations/legacy-local-storage-data/convert-edit-post-panels.d.ts.map +1 -0
  80. package/build-types/migrations/legacy-local-storage-data/index.d.ts +22 -0
  81. package/build-types/migrations/legacy-local-storage-data/index.d.ts.map +1 -0
  82. package/build-types/migrations/legacy-local-storage-data/move-feature-preferences.d.ts +60 -0
  83. package/build-types/migrations/legacy-local-storage-data/move-feature-preferences.d.ts.map +1 -0
  84. package/build-types/migrations/legacy-local-storage-data/move-individual-preference.d.ts +42 -0
  85. package/build-types/migrations/legacy-local-storage-data/move-individual-preference.d.ts.map +1 -0
  86. package/build-types/migrations/legacy-local-storage-data/move-interface-enable-items.d.ts +50 -0
  87. package/build-types/migrations/legacy-local-storage-data/move-interface-enable-items.d.ts.map +1 -0
  88. package/build-types/migrations/legacy-local-storage-data/move-third-party-feature-preferences.d.ts +44 -0
  89. package/build-types/migrations/legacy-local-storage-data/move-third-party-feature-preferences.d.ts.map +1 -0
  90. package/build-types/migrations/legacy-local-storage-data/types.d.ts +60 -0
  91. package/build-types/migrations/legacy-local-storage-data/types.d.ts.map +1 -0
  92. package/build-types/migrations/preferences-package-data/convert-complementary-areas.d.ts +5 -0
  93. package/build-types/migrations/preferences-package-data/convert-complementary-areas.d.ts.map +1 -0
  94. package/build-types/migrations/preferences-package-data/convert-editor-settings.d.ts +5 -0
  95. package/build-types/migrations/preferences-package-data/convert-editor-settings.d.ts.map +1 -0
  96. package/build-types/migrations/preferences-package-data/index.d.ts +5 -0
  97. package/build-types/migrations/preferences-package-data/index.d.ts.map +1 -0
  98. package/build-types/types.d.ts +40 -0
  99. package/build-types/types.d.ts.map +1 -0
  100. package/package.json +8 -7
  101. package/src/create/{debounce-async.js → debounce-async.ts} +13 -10
  102. package/src/create/index.ts +95 -0
  103. package/src/create/test/{debounce-async.js → debounce-async.ts} +7 -3
  104. package/src/create/test/{index.jsdom.test.js → index.jsdom.test.ts} +52 -4
  105. package/src/get-newest-data.ts +50 -0
  106. package/src/index.ts +40 -0
  107. package/src/is-preferences-data.ts +15 -0
  108. package/src/local-storage.ts +30 -0
  109. package/src/migrations/legacy-local-storage-data/{convert-edit-post-panels.js → convert-edit-post-panels.ts} +13 -5
  110. package/src/migrations/legacy-local-storage-data/{index.js → index.ts} +22 -15
  111. package/src/migrations/legacy-local-storage-data/{move-feature-preferences.js → move-feature-preferences.ts} +13 -7
  112. package/src/migrations/legacy-local-storage-data/{move-individual-preference.js → move-individual-preference.ts} +15 -12
  113. package/src/migrations/legacy-local-storage-data/{move-interface-enable-items.js → move-interface-enable-items.ts} +6 -2
  114. package/src/migrations/legacy-local-storage-data/{move-third-party-feature-preferences.js → move-third-party-feature-preferences.ts} +8 -4
  115. package/src/migrations/legacy-local-storage-data/test/{index.js → index.ts} +11 -0
  116. package/src/migrations/legacy-local-storage-data/types.ts +66 -0
  117. package/src/migrations/preferences-package-data/convert-complementary-areas.ts +21 -0
  118. package/src/migrations/preferences-package-data/convert-editor-settings.ts +58 -0
  119. package/src/migrations/preferences-package-data/{index.js → index.ts} +4 -1
  120. package/src/migrations/preferences-package-data/test/{convert-complementary-areas.js → convert-complementary-areas.ts} +10 -0
  121. package/src/migrations/preferences-package-data/test/convert-editor-settings.ts +58 -0
  122. package/src/test/index.jsdom.test.ts +97 -0
  123. package/src/test/local-storage.jsdom.test.ts +50 -0
  124. package/src/types.ts +43 -0
  125. package/CHANGELOG.md +0 -228
  126. package/src/create/index.js +0 -105
  127. package/src/index.js +0 -47
  128. package/src/migrations/preferences-package-data/convert-complementary-areas.js +0 -16
  129. package/src/migrations/preferences-package-data/convert-editor-settings.js +0 -48
  130. package/src/migrations/preferences-package-data/test/convert-editor-settings.js +0 -20
  131. /package/src/migrations/legacy-local-storage-data/test/{convert-edit-post-panels.js → convert-edit-post-panels.ts} +0 -0
  132. /package/src/migrations/legacy-local-storage-data/test/{move-feature-preferences.js → move-feature-preferences.ts} +0 -0
  133. /package/src/migrations/legacy-local-storage-data/test/{move-individual-preference.js → move-individual-preference.ts} +0 -0
  134. /package/src/migrations/legacy-local-storage-data/test/{move-interface-enable-items.js → move-interface-enable-items.ts} +0 -0
  135. /package/src/migrations/legacy-local-storage-data/test/{move-third-party-feature-preferences.js → move-third-party-feature-preferences.ts} +0 -0
  136. /package/src/migrations/preferences-package-data/test/{index.js → index.ts} +0 -0
@@ -1,7 +1 @@
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,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;",
6
- "names": []
7
- }
1
+ {"version":3,"file":"move-individual-preference.mjs","names":[],"sources":["../../../src/migrations/legacy-local-storage-data/move-individual-preference.ts"],"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"],"mappings":";AAGA,MAAM,YAAkB,QAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCpC,SAAwB,sCACvB,OACA,EAAE,MAAM,iBAAiB,IAAI,SAC7B,KACA,UAAuD,UAC1C;CACb,MAAM,uBAAuB;CAC7B,MAAM,mBAAmB,QAAS,gBAAiB,EAAE,cAAe;CAGpE,IAAK,qBAAqB,KAAA,GACzB,OAAO;CAOR,IAHC,QAAS,qBAAsB,EAAE,cAAe,MAAO,GAAI,MAI3D,OAAO;CAGR,MAAM,cAAc,QAAS,qBAAsB,EAAE;CACrD,MAAM,mBACL,QAAS,qBAAsB,EAAE,cAAe;CAEjD,MAAM,mBAAmB,QAAS;CAClC,MAAM,uBAAuB,QAAS,gBAAiB,EAAE;CAIzD,MAAM,uBAAuB,QAAS,GAAI,MAAO,iBAAiB,CAAE;CAEpE,OAAO;EACN,GAAG;GACD,uBAAwB,EACzB,aAAa;GACZ,GAAG;IACD,QAAS;IACV,GAAG;IACH,GAAG;GACJ;EACD,EACD;GACE,kBAAmB;GACpB,GAAG;GACH,aAAa;IACZ,GAAG;KACD,MAAO,KAAA;GACV;EACD;CACD;AACD"}
@@ -1,58 +1,91 @@
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
+ /**
3
+ * Migrates interface 'enableItems' data to the preferences store.
4
+ *
5
+ * The interface package stores this data in this format:
6
+ * ```js
7
+ * {
8
+ * enableItems: {
9
+ * singleEnableItems: {
10
+ * complementaryArea: {
11
+ * 'core/edit-post': 'edit-post/document',
12
+ * 'core/edit-site': 'edit-site/global-styles',
13
+ * }
14
+ * },
15
+ * multipleEnableItems: {
16
+ * pinnedItems: {
17
+ * 'core/edit-post': {
18
+ * 'plugin-1': true,
19
+ * },
20
+ * 'core/edit-site': {
21
+ * 'plugin-2': true,
22
+ * },
23
+ * },
24
+ * }
25
+ * }
26
+ * }
27
+ * ```
28
+ *
29
+ * and it should be converted it to:
30
+ * ```js
31
+ * {
32
+ * 'core/edit-post': {
33
+ * complementaryArea: 'edit-post/document',
34
+ * pinnedItems: {
35
+ * 'plugin-1': true,
36
+ * },
37
+ * },
38
+ * 'core/edit-site': {
39
+ * complementaryArea: 'edit-site/global-styles',
40
+ * pinnedItems: {
41
+ * 'plugin-2': true,
42
+ * },
43
+ * },
44
+ * }
45
+ * ```
46
+ *
47
+ * @param state The local storage state.
48
+ */
2
49
  function moveInterfaceEnableItems(state) {
3
- const interfaceStoreName = "core/interface";
4
- const preferencesStoreName = "core/preferences";
5
- const sourceEnableItems = state?.[interfaceStoreName]?.enableItems;
6
- if (!sourceEnableItems) {
7
- return state;
8
- }
9
- const allPreferences = state?.[preferencesStoreName]?.preferences ?? {};
10
- const sourceComplementaryAreas = sourceEnableItems?.singleEnableItems?.complementaryArea ?? {};
11
- const preferencesWithConvertedComplementaryAreas = Object.keys(
12
- sourceComplementaryAreas
13
- ).reduce((accumulator, scope) => {
14
- const data = sourceComplementaryAreas[scope];
15
- if (accumulator?.[scope]?.complementaryArea) {
16
- return accumulator;
17
- }
18
- return {
19
- ...accumulator,
20
- [scope]: {
21
- ...accumulator[scope],
22
- complementaryArea: data
23
- }
24
- };
25
- }, allPreferences);
26
- const sourcePinnedItems = sourceEnableItems?.multipleEnableItems?.pinnedItems ?? {};
27
- const allConvertedData = Object.keys(sourcePinnedItems).reduce(
28
- (accumulator, scope) => {
29
- const data = sourcePinnedItems[scope];
30
- if (accumulator?.[scope]?.pinnedItems) {
31
- return accumulator;
32
- }
33
- return {
34
- ...accumulator,
35
- [scope]: {
36
- ...accumulator[scope],
37
- pinnedItems: data
38
- }
39
- };
40
- },
41
- preferencesWithConvertedComplementaryAreas
42
- );
43
- const otherInterfaceItems = state[interfaceStoreName];
44
- return {
45
- ...state,
46
- [preferencesStoreName]: {
47
- preferences: allConvertedData
48
- },
49
- [interfaceStoreName]: {
50
- ...otherInterfaceItems,
51
- enableItems: void 0
52
- }
53
- };
50
+ const interfaceStoreName = "core/interface";
51
+ const preferencesStoreName = "core/preferences";
52
+ const sourceEnableItems = state?.[interfaceStoreName]?.enableItems;
53
+ if (!sourceEnableItems) return state;
54
+ const allPreferences = state?.[preferencesStoreName]?.preferences ?? {};
55
+ const sourceComplementaryAreas = sourceEnableItems?.singleEnableItems?.complementaryArea ?? {};
56
+ const preferencesWithConvertedComplementaryAreas = Object.keys(sourceComplementaryAreas).reduce((accumulator, scope) => {
57
+ const data = sourceComplementaryAreas[scope];
58
+ if (accumulator?.[scope]?.complementaryArea) return accumulator;
59
+ return {
60
+ ...accumulator,
61
+ [scope]: {
62
+ ...accumulator[scope],
63
+ complementaryArea: data
64
+ }
65
+ };
66
+ }, allPreferences);
67
+ const sourcePinnedItems = sourceEnableItems?.multipleEnableItems?.pinnedItems ?? {};
68
+ const allConvertedData = Object.keys(sourcePinnedItems).reduce((accumulator, scope) => {
69
+ const data = sourcePinnedItems[scope];
70
+ if (accumulator?.[scope]?.pinnedItems) return accumulator;
71
+ return {
72
+ ...accumulator,
73
+ [scope]: {
74
+ ...accumulator[scope],
75
+ pinnedItems: data
76
+ }
77
+ };
78
+ }, preferencesWithConvertedComplementaryAreas);
79
+ const otherInterfaceItems = state[interfaceStoreName];
80
+ return {
81
+ ...state,
82
+ [preferencesStoreName]: { preferences: allConvertedData },
83
+ [interfaceStoreName]: {
84
+ ...otherInterfaceItems,
85
+ enableItems: void 0
86
+ }
87
+ };
54
88
  }
55
- export {
56
- moveInterfaceEnableItems as default
57
- };
58
- //# sourceMappingURL=move-interface-enable-items.mjs.map
89
+ export { moveInterfaceEnableItems as default };
90
+
91
+ //# sourceMappingURL=move-interface-enable-items.mjs.map
@@ -1,7 +1 @@
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
+ {"version":3,"file":"move-interface-enable-items.mjs","names":[],"sources":["../../../src/migrations/legacy-local-storage-data/move-interface-enable-items.ts"],"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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiDA,SAAwB,yBACvB,OACa;CACb,MAAM,qBAAqB;CAC3B,MAAM,uBAAuB;CAC7B,MAAM,oBAAoB,QAAS,mBAAoB,EAAE;CAGzD,IAAK,CAAE,mBACN,OAAO;CAGR,MAAM,iBAAiB,QAAS,qBAAsB,EAAE,eAAe,CAAC;CAKxE,MAAM,2BACL,mBAAmB,mBAAmB,qBAAqB,CAAC;CAE7D,MAAM,6CAA6C,OAAO,KACzD,wBACD,CAAC,CAAC,QAAU,aAAa,UAAW;EACnC,MAAM,OAAO,yBAA0B;EAGvC,IAAK,cAAe,MAAO,EAAE,mBAC5B,OAAO;EAGR,OAAO;GACN,GAAG;IACD,QAAS;IACV,GAAG,YAAa;IAChB,mBAAmB;GACpB;EACD;CACD,GAAG,cAAe;CAIlB,MAAM,oBACL,mBAAmB,qBAAqB,eAAe,CAAC;CACzD,MAAM,mBAAmB,OAAO,KAAM,iBAAkB,CAAC,CAAC,QACvD,aAAa,UAAW;EACzB,MAAM,OAAO,kBAAmB;EAEhC,IAAK,cAAe,MAAO,EAAE,aAC5B,OAAO;EAGR,OAAO;GACN,GAAG;IACD,QAAS;IACV,GAAG,YAAa;IAChB,aAAa;GACd;EACD;CACD,GACA,0CACD;CAEA,MAAM,sBAAsB,MAAO;CAEnC,OAAO;EACN,GAAG;GACD,uBAAwB,EACzB,aAAa,iBACd;GACE,qBAAsB;GACvB,GAAG;GACH,aAAa,KAAA;EACd;CACD;AACD"}
@@ -1,48 +1,75 @@
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
+ /**
3
+ * The interface package previously had a public API that could be used by
4
+ * plugins to set persisted boolean 'feature' preferences.
5
+ *
6
+ * While usage was likely non-existent or very small, this function ensures
7
+ * those are migrated to the preferences data structure. The interface
8
+ * package's APIs have now been deprecated and use the preferences store.
9
+ *
10
+ * This will convert data that looks like this:
11
+ * ```js
12
+ * {
13
+ * 'core/interface': {
14
+ * preferences: {
15
+ * features: {
16
+ * 'my-plugin': {
17
+ * myPluginFeature: true
18
+ * }
19
+ * }
20
+ * }
21
+ * }
22
+ * }
23
+ * ```
24
+ *
25
+ * To this:
26
+ * ```js
27
+ * * {
28
+ * 'core/preferences': {
29
+ * preferences: {
30
+ * 'my-plugin': {
31
+ * myPluginFeature: true
32
+ * }
33
+ * }
34
+ * }
35
+ * }
36
+ * ```
37
+ *
38
+ * @param state The local storage state
39
+ *
40
+ * @return The state with third party preferences moved to the
41
+ * preferences data structure.
42
+ */
2
43
  function moveThirdPartyFeaturePreferencesToPreferences(state) {
3
- const interfaceStoreName = "core/interface";
4
- const preferencesStoreName = "core/preferences";
5
- const interfaceScopes = state?.[interfaceStoreName]?.preferences?.features;
6
- const interfaceScopeKeys = interfaceScopes ? Object.keys(interfaceScopes) : [];
7
- if (!interfaceScopeKeys?.length) {
8
- return state;
9
- }
10
- return interfaceScopeKeys.reduce(function(convertedState, scope) {
11
- if (scope.startsWith("core")) {
12
- return convertedState;
13
- }
14
- const featuresToMigrate = interfaceScopes?.[scope];
15
- if (!featuresToMigrate) {
16
- return convertedState;
17
- }
18
- const existingMigratedData = convertedState?.[preferencesStoreName]?.preferences?.[scope];
19
- if (existingMigratedData) {
20
- return convertedState;
21
- }
22
- const otherPreferencesScopes = convertedState?.[preferencesStoreName]?.preferences;
23
- const otherInterfaceState = convertedState?.[interfaceStoreName];
24
- const otherInterfaceScopes = convertedState?.[interfaceStoreName]?.preferences?.features;
25
- return {
26
- ...convertedState,
27
- [preferencesStoreName]: {
28
- preferences: {
29
- ...otherPreferencesScopes,
30
- [scope]: featuresToMigrate
31
- }
32
- },
33
- [interfaceStoreName]: {
34
- ...otherInterfaceState,
35
- preferences: {
36
- features: {
37
- ...otherInterfaceScopes,
38
- [scope]: void 0
39
- }
40
- }
41
- }
42
- };
43
- }, state);
44
+ const interfaceStoreName = "core/interface";
45
+ const preferencesStoreName = "core/preferences";
46
+ const interfaceScopes = state?.[interfaceStoreName]?.preferences?.features;
47
+ const interfaceScopeKeys = interfaceScopes ? Object.keys(interfaceScopes) : [];
48
+ if (!interfaceScopeKeys?.length) return state;
49
+ return interfaceScopeKeys.reduce(function(convertedState, scope) {
50
+ if (scope.startsWith("core")) return convertedState;
51
+ const featuresToMigrate = interfaceScopes?.[scope];
52
+ if (!featuresToMigrate) return convertedState;
53
+ if (convertedState?.[preferencesStoreName]?.preferences?.[scope]) return convertedState;
54
+ const otherPreferencesScopes = convertedState?.[preferencesStoreName]?.preferences;
55
+ const otherInterfaceState = convertedState?.[interfaceStoreName];
56
+ const otherInterfaceScopes = convertedState?.[interfaceStoreName]?.preferences?.features;
57
+ return {
58
+ ...convertedState,
59
+ [preferencesStoreName]: { preferences: {
60
+ ...otherPreferencesScopes,
61
+ [scope]: featuresToMigrate
62
+ } },
63
+ [interfaceStoreName]: {
64
+ ...otherInterfaceState,
65
+ preferences: { features: {
66
+ ...otherInterfaceScopes,
67
+ [scope]: void 0
68
+ } }
69
+ }
70
+ };
71
+ }, state);
44
72
  }
45
- export {
46
- moveThirdPartyFeaturePreferencesToPreferences as default
47
- };
48
- //# sourceMappingURL=move-third-party-feature-preferences.mjs.map
73
+ export { moveThirdPartyFeaturePreferencesToPreferences as default };
74
+
75
+ //# sourceMappingURL=move-third-party-feature-preferences.mjs.map
@@ -1,7 +1 @@
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
+ {"version":3,"file":"move-third-party-feature-preferences.mjs","names":[],"sources":["../../../src/migrations/legacy-local-storage-data/move-third-party-feature-preferences.ts"],"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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CA,SAAwB,8CACvB,OACa;CACb,MAAM,qBAAqB;CAC3B,MAAM,uBAAuB;CAE7B,MAAM,kBACL,QAAS,mBAAoB,EAAE,aAAa;CAC7C,MAAM,qBAAqB,kBACxB,OAAO,KAAM,eAAgB,IAC7B,CAAC;CAEJ,IAAK,CAAE,oBAAoB,QAC1B,OAAO;CAGR,OAAO,mBAAmB,OAAQ,SAAW,gBAAgB,OAAQ;EACpE,IAAK,MAAM,WAAY,MAAO,GAC7B,OAAO;EAGR,MAAM,oBAAoB,kBAAmB;EAC7C,IAAK,CAAE,mBACN,OAAO;EAMR,IAFC,iBAAkB,qBAAsB,EAAE,cAAe,QAGzD,OAAO;EAGR,MAAM,yBACL,iBAAkB,qBAAsB,EAAE;EAC3C,MAAM,sBAAsB,iBAAkB;EAC9C,MAAM,uBACL,iBAAkB,mBAAoB,EAAE,aAAa;EAEtD,OAAO;GACN,GAAG;IACD,uBAAwB,EACzB,aAAa;IACZ,GAAG;KACD,QAAS;GACZ,EACD;IACE,qBAAsB;IACvB,GAAG;IACH,aAAa,EACZ,UAAU;KACT,GAAG;MACD,QAAS,KAAA;IACZ,EACD;GACD;EACD;CACD,GAAG,KAAM;AACV"}
@@ -1,18 +1,17 @@
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;
10
- return stateAccumulator;
11
- }
12
- return stateAccumulator;
13
- }, 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;
10
+ return stateAccumulator;
11
+ }
12
+ return stateAccumulator;
13
+ }, { ...state });
14
14
  }
15
- export {
16
- convertComplementaryAreas as default
17
- };
18
- //# sourceMappingURL=convert-complementary-areas.mjs.map
15
+ export { convertComplementaryAreas as default };
16
+
17
+ //# sourceMappingURL=convert-complementary-areas.mjs.map
@@ -1,7 +1 @@
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
+ {"version":3,"file":"convert-complementary-areas.mjs","names":[],"sources":["../../../src/migrations/preferences-package-data/convert-complementary-areas.ts"],"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"],"mappings":";AAEA,SAAwB,0BAA2B,OAA2B;CAC7E,OAAO,OAAO,KAAM,KAAM,CAAC,CAAC,QACzB,kBAAkB,UAAW;EAC9B,MAAM,YAAY,MAAO;EAGzB,IAAK,WAAW,mBAAoB;GACnC,MAAM,mBAAmB,EAAE,GAAG,UAAU;GACxC,OAAO,iBAAiB;GACxB,iBAAiB,6BAA6B;GAC9C,iBAAkB,SAAU;GAC5B,OAAO;EACR;EAEA,OAAO;CACR,GACA,EAAE,GAAG,MAAM,CACZ;AACD"}
@@ -1,48 +1,43 @@
1
- // packages/preferences-persistence/src/migrations/preferences-package-data/convert-editor-settings.js
1
+ import isPreferencesData from "../../is-preferences-data.mjs";
2
+ // packages/preferences-persistence/src/migrations/preferences-package-data/convert-editor-settings.ts
3
+ const copyScope = (scope) => isPreferencesData(scope) ? { ...scope } : void 0;
2
4
  function convertEditorSettings(data) {
3
- let newData = data;
4
- const settingsToMoveToCore = [
5
- "allowRightClickOverrides",
6
- "distractionFree",
7
- "editorMode",
8
- "fixedToolbar",
9
- "focusMode",
10
- "hiddenBlockTypes",
11
- "inactivePanels",
12
- "keepCaretInsideBlock",
13
- "mostUsedBlocks",
14
- "openPanels",
15
- "showBlockBreadcrumbs",
16
- "showIconLabels",
17
- "showListViewByDefault",
18
- "isPublishSidebarEnabled",
19
- "isComplementaryAreaVisible",
20
- "pinnedItems"
21
- ];
22
- 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
- }
30
- };
31
- delete newData["core/edit-post"][setting];
32
- }
33
- if (data?.["core/edit-site"]?.[setting] !== void 0) {
34
- delete newData["core/edit-site"][setting];
35
- }
36
- });
37
- if (Object.keys(newData?.["core/edit-post"] ?? {})?.length === 0) {
38
- delete newData["core/edit-post"];
39
- }
40
- if (Object.keys(newData?.["core/edit-site"] ?? {})?.length === 0) {
41
- delete newData["core/edit-site"];
42
- }
43
- return newData;
5
+ const newData = { ...data };
6
+ const editPost = copyScope(data["core/edit-post"]);
7
+ const editSite = copyScope(data["core/edit-site"]);
8
+ [
9
+ "allowRightClickOverrides",
10
+ "distractionFree",
11
+ "editorMode",
12
+ "fixedToolbar",
13
+ "focusMode",
14
+ "hiddenBlockTypes",
15
+ "inactivePanels",
16
+ "keepCaretInsideBlock",
17
+ "mostUsedBlocks",
18
+ "openPanels",
19
+ "showBlockBreadcrumbs",
20
+ "showIconLabels",
21
+ "showListViewByDefault",
22
+ "isPublishSidebarEnabled",
23
+ "isComplementaryAreaVisible",
24
+ "pinnedItems"
25
+ ].forEach((setting) => {
26
+ if (editPost?.[setting] !== void 0) {
27
+ newData.core = {
28
+ ...copyScope(newData.core),
29
+ [setting]: editPost[setting]
30
+ };
31
+ delete editPost[setting];
32
+ }
33
+ if (editSite?.[setting] !== void 0) delete editSite[setting];
34
+ });
35
+ if (editPost && Object.keys(editPost).length > 0) newData["core/edit-post"] = editPost;
36
+ else delete newData["core/edit-post"];
37
+ if (editSite && Object.keys(editSite).length > 0) newData["core/edit-site"] = editSite;
38
+ else delete newData["core/edit-site"];
39
+ return newData;
44
40
  }
45
- export {
46
- convertEditorSettings as default
47
- };
48
- //# sourceMappingURL=convert-editor-settings.mjs.map
41
+ export { convertEditorSettings as default };
42
+
43
+ //# sourceMappingURL=convert-editor-settings.mjs.map
@@ -1,7 +1 @@
1
- {
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;",
6
- "names": []
7
- }
1
+ {"version":3,"file":"convert-editor-settings.mjs","names":[],"sources":["../../../src/migrations/preferences-package-data/convert-editor-settings.ts"],"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"],"mappings":";;AAGA,MAAM,aAAc,UACnB,kBAAmB,KAAM,IAAI,EAAE,GAAG,MAAM,IAAI,KAAA;AAE7C,SAAwB,sBAAuB,MAA0B;CACxE,MAAM,UAAU,EAAE,GAAG,KAAK;CAC1B,MAAM,WAAW,UAAW,KAAM,iBAAmB;CACrD,MAAM,WAAW,UAAW,KAAM,iBAAmB;CAoBrD;EAlBC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CAGkB,CAAC,CAAC,SAAW,YAAa;EAC5C,IAAK,WAAY,aAAc,KAAA,GAAY;GAC1C,QAAQ,OAAO;IACd,GAAG,UAAW,QAAQ,IAAK;KACzB,UAAW,SAAU;GACxB;GACA,OAAO,SAAU;EAClB;EAEA,IAAK,WAAY,aAAc,KAAA,GAC9B,OAAO,SAAU;CAEnB,CAAE;CAGF,IAAK,YAAY,OAAO,KAAM,QAAS,CAAC,CAAC,SAAS,GACjD,QAAS,oBAAqB;MAE9B,OAAO,QAAS;CAGjB,IAAK,YAAY,OAAO,KAAM,QAAS,CAAC,CAAC,SAAS,GACjD,QAAS,oBAAqB;MAE9B,OAAO,QAAS;CAGjB,OAAO;AACR"}
@@ -1,12 +1,11 @@
1
- // packages/preferences-persistence/src/migrations/preferences-package-data/index.js
2
1
  import convertComplementaryAreas from "./convert-complementary-areas.mjs";
3
2
  import convertEditorSettings from "./convert-editor-settings.mjs";
3
+ // packages/preferences-persistence/src/migrations/preferences-package-data/index.ts
4
4
  function convertPreferencesPackageData(data) {
5
- let newData = convertComplementaryAreas(data);
6
- newData = convertEditorSettings(newData);
7
- return newData;
5
+ let newData = convertComplementaryAreas(data);
6
+ newData = convertEditorSettings(newData);
7
+ return newData;
8
8
  }
9
- export {
10
- convertPreferencesPackageData as default
11
- };
12
- //# sourceMappingURL=index.mjs.map
9
+ export { convertPreferencesPackageData as default };
10
+
11
+ //# sourceMappingURL=index.mjs.map
@@ -1,7 +1 @@
1
- {
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;",
6
- "names": []
7
- }
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../../src/migrations/preferences-package-data/index.ts"],"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"],"mappings":";;;AAIA,SAAwB,8BACvB,MACC;CACD,IAAI,UAAU,0BAA2B,IAAK;CAC9C,UAAU,sBAAuB,OAAQ;CACzC,OAAO;AACR"}
File without changes
@@ -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"}