@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.
- package/README.md +7 -7
- package/build/create/debounce-async.cjs +55 -58
- package/build/create/debounce-async.cjs.map +1 -7
- package/build/create/index.cjs +75 -91
- package/build/create/index.cjs.map +1 -7
- package/build/get-newest-data.cjs +64 -0
- package/build/get-newest-data.cjs.map +1 -0
- package/build/index.cjs +52 -53
- package/build/index.cjs.map +1 -7
- package/build/is-preferences-data.cjs +20 -0
- package/build/is-preferences-data.cjs.map +1 -0
- package/build/local-storage.cjs +39 -0
- package/build/local-storage.cjs.map +1 -0
- package/build/migrations/legacy-local-storage-data/convert-edit-post-panels.cjs +49 -38
- package/build/migrations/legacy-local-storage-data/convert-edit-post-panels.cjs.map +1 -7
- package/build/migrations/legacy-local-storage-data/index.cjs +95 -83
- package/build/migrations/legacy-local-storage-data/index.cjs.map +1 -7
- package/build/migrations/legacy-local-storage-data/move-feature-preferences.cjs +106 -77
- package/build/migrations/legacy-local-storage-data/move-feature-preferences.cjs.map +1 -7
- package/build/migrations/legacy-local-storage-data/move-individual-preference.cjs +70 -58
- package/build/migrations/legacy-local-storage-data/move-individual-preference.cjs.map +1 -7
- package/build/migrations/legacy-local-storage-data/move-interface-enable-items.cjs +93 -75
- package/build/migrations/legacy-local-storage-data/move-interface-enable-items.cjs.map +1 -7
- package/build/migrations/legacy-local-storage-data/move-third-party-feature-preferences.cjs +77 -65
- package/build/migrations/legacy-local-storage-data/move-third-party-feature-preferences.cjs.map +1 -7
- package/build/migrations/legacy-local-storage-data/types.cjs +5 -0
- package/build/migrations/preferences-package-data/convert-complementary-areas.cjs +19 -35
- package/build/migrations/preferences-package-data/convert-complementary-areas.cjs.map +1 -7
- package/build/migrations/preferences-package-data/convert-editor-settings.cjs +62 -60
- package/build/migrations/preferences-package-data/convert-editor-settings.cjs.map +1 -7
- package/build/migrations/preferences-package-data/index.cjs +29 -32
- package/build/migrations/preferences-package-data/index.cjs.map +1 -7
- package/build/types.cjs +5 -0
- package/build-module/create/debounce-async.mjs +51 -39
- package/build-module/create/debounce-async.mjs.map +1 -7
- package/build-module/create/index.mjs +51 -67
- package/build-module/create/index.mjs.map +1 -7
- package/build-module/get-newest-data.mjs +36 -0
- package/build-module/get-newest-data.mjs.map +1 -0
- package/build-module/index.mjs +24 -25
- package/build-module/index.mjs.map +1 -7
- package/build-module/is-preferences-data.mjs +15 -0
- package/build-module/is-preferences-data.mjs.map +1 -0
- package/build-module/local-storage.mjs +33 -0
- package/build-module/local-storage.mjs.map +1 -0
- package/build-module/migrations/legacy-local-storage-data/convert-edit-post-panels.mjs +45 -19
- package/build-module/migrations/legacy-local-storage-data/convert-edit-post-panels.mjs.map +1 -7
- package/build-module/migrations/legacy-local-storage-data/index.mjs +65 -52
- package/build-module/migrations/legacy-local-storage-data/index.mjs.map +1 -7
- package/build-module/migrations/legacy-local-storage-data/move-feature-preferences.mjs +102 -58
- package/build-module/migrations/legacy-local-storage-data/move-feature-preferences.mjs.map +1 -7
- package/build-module/migrations/legacy-local-storage-data/move-individual-preference.mjs +66 -39
- package/build-module/migrations/legacy-local-storage-data/move-individual-preference.mjs.map +1 -7
- package/build-module/migrations/legacy-local-storage-data/move-interface-enable-items.mjs +89 -56
- package/build-module/migrations/legacy-local-storage-data/move-interface-enable-items.mjs.map +1 -7
- package/build-module/migrations/legacy-local-storage-data/move-third-party-feature-preferences.mjs +73 -46
- package/build-module/migrations/legacy-local-storage-data/move-third-party-feature-preferences.mjs.map +1 -7
- package/build-module/migrations/legacy-local-storage-data/types.mjs +0 -0
- package/build-module/migrations/preferences-package-data/convert-complementary-areas.mjs +15 -16
- package/build-module/migrations/preferences-package-data/convert-complementary-areas.mjs.map +1 -7
- package/build-module/migrations/preferences-package-data/convert-editor-settings.mjs +41 -46
- package/build-module/migrations/preferences-package-data/convert-editor-settings.mjs.map +1 -7
- package/build-module/migrations/preferences-package-data/index.mjs +7 -8
- package/build-module/migrations/preferences-package-data/index.mjs.map +1 -7
- package/build-module/types.mjs +0 -0
- package/build-types/create/debounce-async.d.ts +19 -0
- package/build-types/create/debounce-async.d.ts.map +1 -0
- package/build-types/create/index.d.ts +20 -0
- package/build-types/create/index.d.ts.map +1 -0
- package/build-types/get-newest-data.d.ts +11 -0
- package/build-types/get-newest-data.d.ts.map +1 -0
- package/build-types/index.d.ts +20 -0
- package/build-types/index.d.ts.map +1 -0
- package/build-types/is-preferences-data.d.ts +11 -0
- package/build-types/is-preferences-data.d.ts.map +1 -0
- package/build-types/local-storage.d.ts +19 -0
- package/build-types/local-storage.d.ts.map +1 -0
- package/build-types/migrations/legacy-local-storage-data/convert-edit-post-panels.d.ts +35 -0
- package/build-types/migrations/legacy-local-storage-data/convert-edit-post-panels.d.ts.map +1 -0
- package/build-types/migrations/legacy-local-storage-data/index.d.ts +22 -0
- package/build-types/migrations/legacy-local-storage-data/index.d.ts.map +1 -0
- package/build-types/migrations/legacy-local-storage-data/move-feature-preferences.d.ts +60 -0
- package/build-types/migrations/legacy-local-storage-data/move-feature-preferences.d.ts.map +1 -0
- package/build-types/migrations/legacy-local-storage-data/move-individual-preference.d.ts +42 -0
- package/build-types/migrations/legacy-local-storage-data/move-individual-preference.d.ts.map +1 -0
- package/build-types/migrations/legacy-local-storage-data/move-interface-enable-items.d.ts +50 -0
- package/build-types/migrations/legacy-local-storage-data/move-interface-enable-items.d.ts.map +1 -0
- package/build-types/migrations/legacy-local-storage-data/move-third-party-feature-preferences.d.ts +44 -0
- package/build-types/migrations/legacy-local-storage-data/move-third-party-feature-preferences.d.ts.map +1 -0
- package/build-types/migrations/legacy-local-storage-data/types.d.ts +60 -0
- package/build-types/migrations/legacy-local-storage-data/types.d.ts.map +1 -0
- package/build-types/migrations/preferences-package-data/convert-complementary-areas.d.ts +5 -0
- package/build-types/migrations/preferences-package-data/convert-complementary-areas.d.ts.map +1 -0
- package/build-types/migrations/preferences-package-data/convert-editor-settings.d.ts +5 -0
- package/build-types/migrations/preferences-package-data/convert-editor-settings.d.ts.map +1 -0
- package/build-types/migrations/preferences-package-data/index.d.ts +5 -0
- package/build-types/migrations/preferences-package-data/index.d.ts.map +1 -0
- package/build-types/types.d.ts +40 -0
- package/build-types/types.d.ts.map +1 -0
- package/package.json +8 -7
- package/src/create/{debounce-async.js → debounce-async.ts} +13 -10
- package/src/create/index.ts +95 -0
- package/src/create/test/{debounce-async.js → debounce-async.ts} +7 -3
- package/src/create/test/{index.jsdom.test.js → index.jsdom.test.ts} +52 -4
- package/src/get-newest-data.ts +50 -0
- package/src/index.ts +40 -0
- package/src/is-preferences-data.ts +15 -0
- package/src/local-storage.ts +30 -0
- package/src/migrations/legacy-local-storage-data/{convert-edit-post-panels.js → convert-edit-post-panels.ts} +13 -5
- package/src/migrations/legacy-local-storage-data/{index.js → index.ts} +22 -15
- package/src/migrations/legacy-local-storage-data/{move-feature-preferences.js → move-feature-preferences.ts} +13 -7
- package/src/migrations/legacy-local-storage-data/{move-individual-preference.js → move-individual-preference.ts} +15 -12
- package/src/migrations/legacy-local-storage-data/{move-interface-enable-items.js → move-interface-enable-items.ts} +6 -2
- package/src/migrations/legacy-local-storage-data/{move-third-party-feature-preferences.js → move-third-party-feature-preferences.ts} +8 -4
- package/src/migrations/legacy-local-storage-data/test/{index.js → index.ts} +11 -0
- package/src/migrations/legacy-local-storage-data/types.ts +66 -0
- package/src/migrations/preferences-package-data/convert-complementary-areas.ts +21 -0
- package/src/migrations/preferences-package-data/convert-editor-settings.ts +58 -0
- package/src/migrations/preferences-package-data/{index.js → index.ts} +4 -1
- package/src/migrations/preferences-package-data/test/{convert-complementary-areas.js → convert-complementary-areas.ts} +10 -0
- package/src/migrations/preferences-package-data/test/convert-editor-settings.ts +58 -0
- package/src/test/index.jsdom.test.ts +97 -0
- package/src/test/local-storage.jsdom.test.ts +50 -0
- package/src/types.ts +43 -0
- package/CHANGELOG.md +0 -228
- package/src/create/index.js +0 -105
- package/src/index.js +0 -47
- package/src/migrations/preferences-package-data/convert-complementary-areas.js +0 -16
- package/src/migrations/preferences-package-data/convert-editor-settings.js +0 -48
- package/src/migrations/preferences-package-data/test/convert-editor-settings.js +0 -20
- /package/src/migrations/legacy-local-storage-data/test/{convert-edit-post-panels.js → convert-edit-post-panels.ts} +0 -0
- /package/src/migrations/legacy-local-storage-data/test/{move-feature-preferences.js → move-feature-preferences.ts} +0 -0
- /package/src/migrations/legacy-local-storage-data/test/{move-individual-preference.js → move-individual-preference.ts} +0 -0
- /package/src/migrations/legacy-local-storage-data/test/{move-interface-enable-items.js → move-interface-enable-items.ts} +0 -0
- /package/src/migrations/legacy-local-storage-data/test/{move-third-party-feature-preferences.js → move-third-party-feature-preferences.ts} +0 -0
- /package/src/migrations/preferences-package-data/test/{index.js → index.ts} +0 -0
|
@@ -1,61 +1,73 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
|
|
19
|
-
// packages/preferences-persistence/src/migrations/legacy-local-storage-data/move-individual-preference.js
|
|
20
|
-
var move_individual_preference_exports = {};
|
|
21
|
-
__export(move_individual_preference_exports, {
|
|
22
|
-
default: () => moveIndividualPreferenceToPreferences
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, {
|
|
3
|
+
__esModule: { value: true },
|
|
4
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
23
5
|
});
|
|
24
|
-
|
|
25
|
-
|
|
6
|
+
// packages/preferences-persistence/src/migrations/legacy-local-storage-data/move-individual-preference.ts
|
|
7
|
+
const identity = (arg) => arg;
|
|
8
|
+
/**
|
|
9
|
+
* Migrates an individual item inside the `preferences` object for a package's store.
|
|
10
|
+
*
|
|
11
|
+
* Previously, some packages had individual 'preferences' of any data type, and many used
|
|
12
|
+
* complex nested data structures. For example:
|
|
13
|
+
* ```js
|
|
14
|
+
* {
|
|
15
|
+
* 'core/edit-post': {
|
|
16
|
+
* preferences: {
|
|
17
|
+
* panels: {
|
|
18
|
+
* publish: {
|
|
19
|
+
* opened: true,
|
|
20
|
+
* enabled: true,
|
|
21
|
+
* }
|
|
22
|
+
* },
|
|
23
|
+
* // ...other preferences.
|
|
24
|
+
* },
|
|
25
|
+
* },
|
|
26
|
+
* }
|
|
27
|
+
*
|
|
28
|
+
* This function supports moving an individual preference like 'panels' above into the
|
|
29
|
+
* preferences package data structure.
|
|
30
|
+
*
|
|
31
|
+
* It supports moving a preference to a particular scope in the preferences store and
|
|
32
|
+
* optionally converting the data using a `convert` function.
|
|
33
|
+
*
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @param state The original state.
|
|
37
|
+
* @param migrate An options object that contains details of the migration.
|
|
38
|
+
* @param migrate.from The name of the store to migrate from.
|
|
39
|
+
* @param migrate.to The scope in the preferences store to migrate to.
|
|
40
|
+
* @param key The key in the preferences object to migrate.
|
|
41
|
+
* @param convert A function that converts preferences from one format to another.
|
|
42
|
+
*/
|
|
26
43
|
function moveIndividualPreferenceToPreferences(state, { from: sourceStoreName, to: scope }, key, convert = identity) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
...otherSourceState,
|
|
54
|
-
preferences: {
|
|
55
|
-
...allSourcePreferences,
|
|
56
|
-
[key]: void 0
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
};
|
|
44
|
+
const preferencesStoreName = "core/preferences";
|
|
45
|
+
const sourcePreference = state?.[sourceStoreName]?.preferences?.[key];
|
|
46
|
+
if (sourcePreference === void 0) return state;
|
|
47
|
+
if (state?.[preferencesStoreName]?.preferences?.[scope]?.[key]) return state;
|
|
48
|
+
const otherScopes = state?.[preferencesStoreName]?.preferences;
|
|
49
|
+
const otherPreferences = state?.[preferencesStoreName]?.preferences?.[scope];
|
|
50
|
+
const otherSourceState = state?.[sourceStoreName];
|
|
51
|
+
const allSourcePreferences = state?.[sourceStoreName]?.preferences;
|
|
52
|
+
const convertedPreferences = convert({ [key]: sourcePreference });
|
|
53
|
+
return {
|
|
54
|
+
...state,
|
|
55
|
+
[preferencesStoreName]: { preferences: {
|
|
56
|
+
...otherScopes,
|
|
57
|
+
[scope]: {
|
|
58
|
+
...otherPreferences,
|
|
59
|
+
...convertedPreferences
|
|
60
|
+
}
|
|
61
|
+
} },
|
|
62
|
+
[sourceStoreName]: {
|
|
63
|
+
...otherSourceState,
|
|
64
|
+
preferences: {
|
|
65
|
+
...allSourcePreferences,
|
|
66
|
+
[key]: void 0
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
};
|
|
60
70
|
}
|
|
61
|
-
|
|
71
|
+
exports.default = moveIndividualPreferenceToPreferences;
|
|
72
|
+
|
|
73
|
+
//# sourceMappingURL=move-individual-preference.cjs.map
|
|
@@ -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;AAAA;AAAA;AAAA;AAAA;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.cjs","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,78 +1,96 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
|
|
19
|
-
// packages/preferences-persistence/src/migrations/legacy-local-storage-data/move-interface-enable-items.js
|
|
20
|
-
var move_interface_enable_items_exports = {};
|
|
21
|
-
__export(move_interface_enable_items_exports, {
|
|
22
|
-
default: () => moveInterfaceEnableItems
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, {
|
|
3
|
+
__esModule: { value: true },
|
|
4
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
23
5
|
});
|
|
24
|
-
|
|
6
|
+
// packages/preferences-persistence/src/migrations/legacy-local-storage-data/move-interface-enable-items.ts
|
|
7
|
+
/**
|
|
8
|
+
* Migrates interface 'enableItems' data to the preferences store.
|
|
9
|
+
*
|
|
10
|
+
* The interface package stores this data in this format:
|
|
11
|
+
* ```js
|
|
12
|
+
* {
|
|
13
|
+
* enableItems: {
|
|
14
|
+
* singleEnableItems: {
|
|
15
|
+
* complementaryArea: {
|
|
16
|
+
* 'core/edit-post': 'edit-post/document',
|
|
17
|
+
* 'core/edit-site': 'edit-site/global-styles',
|
|
18
|
+
* }
|
|
19
|
+
* },
|
|
20
|
+
* multipleEnableItems: {
|
|
21
|
+
* pinnedItems: {
|
|
22
|
+
* 'core/edit-post': {
|
|
23
|
+
* 'plugin-1': true,
|
|
24
|
+
* },
|
|
25
|
+
* 'core/edit-site': {
|
|
26
|
+
* 'plugin-2': true,
|
|
27
|
+
* },
|
|
28
|
+
* },
|
|
29
|
+
* }
|
|
30
|
+
* }
|
|
31
|
+
* }
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* and it should be converted it to:
|
|
35
|
+
* ```js
|
|
36
|
+
* {
|
|
37
|
+
* 'core/edit-post': {
|
|
38
|
+
* complementaryArea: 'edit-post/document',
|
|
39
|
+
* pinnedItems: {
|
|
40
|
+
* 'plugin-1': true,
|
|
41
|
+
* },
|
|
42
|
+
* },
|
|
43
|
+
* 'core/edit-site': {
|
|
44
|
+
* complementaryArea: 'edit-site/global-styles',
|
|
45
|
+
* pinnedItems: {
|
|
46
|
+
* 'plugin-2': true,
|
|
47
|
+
* },
|
|
48
|
+
* },
|
|
49
|
+
* }
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* @param state The local storage state.
|
|
53
|
+
*/
|
|
25
54
|
function moveInterfaceEnableItems(state) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
preferencesWithConvertedComplementaryAreas
|
|
65
|
-
);
|
|
66
|
-
const otherInterfaceItems = state[interfaceStoreName];
|
|
67
|
-
return {
|
|
68
|
-
...state,
|
|
69
|
-
[preferencesStoreName]: {
|
|
70
|
-
preferences: allConvertedData
|
|
71
|
-
},
|
|
72
|
-
[interfaceStoreName]: {
|
|
73
|
-
...otherInterfaceItems,
|
|
74
|
-
enableItems: void 0
|
|
75
|
-
}
|
|
76
|
-
};
|
|
55
|
+
const interfaceStoreName = "core/interface";
|
|
56
|
+
const preferencesStoreName = "core/preferences";
|
|
57
|
+
const sourceEnableItems = state?.[interfaceStoreName]?.enableItems;
|
|
58
|
+
if (!sourceEnableItems) return state;
|
|
59
|
+
const allPreferences = state?.[preferencesStoreName]?.preferences ?? {};
|
|
60
|
+
const sourceComplementaryAreas = sourceEnableItems?.singleEnableItems?.complementaryArea ?? {};
|
|
61
|
+
const preferencesWithConvertedComplementaryAreas = Object.keys(sourceComplementaryAreas).reduce((accumulator, scope) => {
|
|
62
|
+
const data = sourceComplementaryAreas[scope];
|
|
63
|
+
if (accumulator?.[scope]?.complementaryArea) return accumulator;
|
|
64
|
+
return {
|
|
65
|
+
...accumulator,
|
|
66
|
+
[scope]: {
|
|
67
|
+
...accumulator[scope],
|
|
68
|
+
complementaryArea: data
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
}, allPreferences);
|
|
72
|
+
const sourcePinnedItems = sourceEnableItems?.multipleEnableItems?.pinnedItems ?? {};
|
|
73
|
+
const allConvertedData = Object.keys(sourcePinnedItems).reduce((accumulator, scope) => {
|
|
74
|
+
const data = sourcePinnedItems[scope];
|
|
75
|
+
if (accumulator?.[scope]?.pinnedItems) return accumulator;
|
|
76
|
+
return {
|
|
77
|
+
...accumulator,
|
|
78
|
+
[scope]: {
|
|
79
|
+
...accumulator[scope],
|
|
80
|
+
pinnedItems: data
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
}, preferencesWithConvertedComplementaryAreas);
|
|
84
|
+
const otherInterfaceItems = state[interfaceStoreName];
|
|
85
|
+
return {
|
|
86
|
+
...state,
|
|
87
|
+
[preferencesStoreName]: { preferences: allConvertedData },
|
|
88
|
+
[interfaceStoreName]: {
|
|
89
|
+
...otherInterfaceItems,
|
|
90
|
+
enableItems: void 0
|
|
91
|
+
}
|
|
92
|
+
};
|
|
77
93
|
}
|
|
78
|
-
|
|
94
|
+
exports.default = moveInterfaceEnableItems;
|
|
95
|
+
|
|
96
|
+
//# sourceMappingURL=move-interface-enable-items.cjs.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": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;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.cjs","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,68 +1,80 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
|
|
19
|
-
// packages/preferences-persistence/src/migrations/legacy-local-storage-data/move-third-party-feature-preferences.js
|
|
20
|
-
var move_third_party_feature_preferences_exports = {};
|
|
21
|
-
__export(move_third_party_feature_preferences_exports, {
|
|
22
|
-
default: () => moveThirdPartyFeaturePreferencesToPreferences
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, {
|
|
3
|
+
__esModule: { value: true },
|
|
4
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
23
5
|
});
|
|
24
|
-
|
|
6
|
+
// packages/preferences-persistence/src/migrations/legacy-local-storage-data/move-third-party-feature-preferences.ts
|
|
7
|
+
/**
|
|
8
|
+
* The interface package previously had a public API that could be used by
|
|
9
|
+
* plugins to set persisted boolean 'feature' preferences.
|
|
10
|
+
*
|
|
11
|
+
* While usage was likely non-existent or very small, this function ensures
|
|
12
|
+
* those are migrated to the preferences data structure. The interface
|
|
13
|
+
* package's APIs have now been deprecated and use the preferences store.
|
|
14
|
+
*
|
|
15
|
+
* This will convert data that looks like this:
|
|
16
|
+
* ```js
|
|
17
|
+
* {
|
|
18
|
+
* 'core/interface': {
|
|
19
|
+
* preferences: {
|
|
20
|
+
* features: {
|
|
21
|
+
* 'my-plugin': {
|
|
22
|
+
* myPluginFeature: true
|
|
23
|
+
* }
|
|
24
|
+
* }
|
|
25
|
+
* }
|
|
26
|
+
* }
|
|
27
|
+
* }
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* To this:
|
|
31
|
+
* ```js
|
|
32
|
+
* * {
|
|
33
|
+
* 'core/preferences': {
|
|
34
|
+
* preferences: {
|
|
35
|
+
* 'my-plugin': {
|
|
36
|
+
* myPluginFeature: true
|
|
37
|
+
* }
|
|
38
|
+
* }
|
|
39
|
+
* }
|
|
40
|
+
* }
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* @param state The local storage state
|
|
44
|
+
*
|
|
45
|
+
* @return The state with third party preferences moved to the
|
|
46
|
+
* preferences data structure.
|
|
47
|
+
*/
|
|
25
48
|
function moveThirdPartyFeaturePreferencesToPreferences(state) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
[interfaceStoreName]: {
|
|
57
|
-
...otherInterfaceState,
|
|
58
|
-
preferences: {
|
|
59
|
-
features: {
|
|
60
|
-
...otherInterfaceScopes,
|
|
61
|
-
[scope]: void 0
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
}, state);
|
|
49
|
+
const interfaceStoreName = "core/interface";
|
|
50
|
+
const preferencesStoreName = "core/preferences";
|
|
51
|
+
const interfaceScopes = state?.[interfaceStoreName]?.preferences?.features;
|
|
52
|
+
const interfaceScopeKeys = interfaceScopes ? Object.keys(interfaceScopes) : [];
|
|
53
|
+
if (!interfaceScopeKeys?.length) return state;
|
|
54
|
+
return interfaceScopeKeys.reduce(function(convertedState, scope) {
|
|
55
|
+
if (scope.startsWith("core")) return convertedState;
|
|
56
|
+
const featuresToMigrate = interfaceScopes?.[scope];
|
|
57
|
+
if (!featuresToMigrate) return convertedState;
|
|
58
|
+
if (convertedState?.[preferencesStoreName]?.preferences?.[scope]) return convertedState;
|
|
59
|
+
const otherPreferencesScopes = convertedState?.[preferencesStoreName]?.preferences;
|
|
60
|
+
const otherInterfaceState = convertedState?.[interfaceStoreName];
|
|
61
|
+
const otherInterfaceScopes = convertedState?.[interfaceStoreName]?.preferences?.features;
|
|
62
|
+
return {
|
|
63
|
+
...convertedState,
|
|
64
|
+
[preferencesStoreName]: { preferences: {
|
|
65
|
+
...otherPreferencesScopes,
|
|
66
|
+
[scope]: featuresToMigrate
|
|
67
|
+
} },
|
|
68
|
+
[interfaceStoreName]: {
|
|
69
|
+
...otherInterfaceState,
|
|
70
|
+
preferences: { features: {
|
|
71
|
+
...otherInterfaceScopes,
|
|
72
|
+
[scope]: void 0
|
|
73
|
+
} }
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
}, state);
|
|
67
77
|
}
|
|
68
|
-
|
|
78
|
+
exports.default = moveThirdPartyFeaturePreferencesToPreferences;
|
|
79
|
+
|
|
80
|
+
//# sourceMappingURL=move-third-party-feature-preferences.cjs.map
|
package/build/migrations/legacy-local-storage-data/move-third-party-feature-preferences.cjs.map
CHANGED
|
@@ -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": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;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.cjs","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,38 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
|
|
19
|
-
// packages/preferences-persistence/src/migrations/preferences-package-data/convert-complementary-areas.js
|
|
20
|
-
var convert_complementary_areas_exports = {};
|
|
21
|
-
__export(convert_complementary_areas_exports, {
|
|
22
|
-
default: () => convertComplementaryAreas
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, {
|
|
3
|
+
__esModule: { value: true },
|
|
4
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
23
5
|
});
|
|
24
|
-
|
|
6
|
+
// packages/preferences-persistence/src/migrations/preferences-package-data/convert-complementary-areas.ts
|
|
25
7
|
function convertComplementaryAreas(state) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
8
|
+
return Object.keys(state).reduce((stateAccumulator, scope) => {
|
|
9
|
+
const scopeData = state[scope];
|
|
10
|
+
if (scopeData?.complementaryArea) {
|
|
11
|
+
const updatedScopeData = { ...scopeData };
|
|
12
|
+
delete updatedScopeData.complementaryArea;
|
|
13
|
+
updatedScopeData.isComplementaryAreaVisible = true;
|
|
14
|
+
stateAccumulator[scope] = updatedScopeData;
|
|
15
|
+
return stateAccumulator;
|
|
16
|
+
}
|
|
17
|
+
return stateAccumulator;
|
|
18
|
+
}, { ...state });
|
|
37
19
|
}
|
|
38
|
-
|
|
20
|
+
exports.default = convertComplementaryAreas;
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=convert-complementary-areas.cjs.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": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;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.cjs","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"}
|