@wordpress/data 6.5.0 → 6.7.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/CHANGELOG.md +4 -0
- package/build/components/use-select/index.js +25 -32
- package/build/components/use-select/index.js.map +1 -1
- package/build/plugins/persistence/index.js +218 -13
- package/build/plugins/persistence/index.js.map +1 -1
- package/build/redux-store/index.js +42 -27
- package/build/redux-store/index.js.map +1 -1
- package/build/registry.js +10 -17
- package/build/registry.js.map +1 -1
- package/build-module/components/use-select/index.js +25 -32
- package/build-module/components/use-select/index.js.map +1 -1
- package/build-module/plugins/persistence/index.js +215 -14
- package/build-module/plugins/persistence/index.js.map +1 -1
- package/build-module/redux-store/index.js +42 -27
- package/build-module/redux-store/index.js.map +1 -1
- package/build-module/registry.js +10 -17
- package/build-module/registry.js.map +1 -1
- package/package.json +8 -8
- package/src/components/use-select/index.js +28 -36
- package/src/components/use-select/test/index.js +439 -265
- package/src/plugins/persistence/index.js +214 -19
- package/src/plugins/persistence/test/index.js +233 -3
- package/src/redux-store/index.js +23 -12
- package/src/redux-store/test/index.js +15 -5
- package/src/registry.js +10 -10
- package/src/test/registry.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -132,15 +132,15 @@ function useSelect(mapSelect, deps) {
|
|
|
132
132
|
queue: true
|
|
133
133
|
}), [registry]);
|
|
134
134
|
const [, forceRender] = (0, _element.useReducer)(s => s + 1, 0);
|
|
135
|
+
const latestRegistry = (0, _element.useRef)(registry);
|
|
135
136
|
const latestMapSelect = (0, _element.useRef)();
|
|
136
137
|
const latestIsAsync = (0, _element.useRef)(isAsync);
|
|
137
138
|
const latestMapOutput = (0, _element.useRef)();
|
|
138
|
-
const latestMapOutputError = (0, _element.useRef)();
|
|
139
|
-
const isMountedAndNotUnsubscribing = (0, _element.useRef)(); // Keep track of the stores being selected in the _mapSelect function,
|
|
139
|
+
const latestMapOutputError = (0, _element.useRef)(); // Keep track of the stores being selected in the _mapSelect function,
|
|
140
140
|
// and only subscribe to those stores later.
|
|
141
141
|
|
|
142
142
|
const listeningStores = (0, _element.useRef)([]);
|
|
143
|
-
const
|
|
143
|
+
const wrapSelect = (0, _element.useCallback)(callback => registry.__unstableMarkListeningStores(() => callback(registry.select, registry), listeningStores), [registry]); // Generate a "flag" for used in the effect dependency array.
|
|
144
144
|
// It's different than just using `mapSelect` since deps could be undefined,
|
|
145
145
|
// in that case, we would still want to memoize it.
|
|
146
146
|
|
|
@@ -149,12 +149,13 @@ function useSelect(mapSelect, deps) {
|
|
|
149
149
|
|
|
150
150
|
if (_mapSelect) {
|
|
151
151
|
mapOutput = latestMapOutput.current;
|
|
152
|
+
const hasReplacedRegistry = latestRegistry.current !== registry;
|
|
152
153
|
const hasReplacedMapSelect = latestMapSelect.current !== _mapSelect;
|
|
153
154
|
const lastMapSelectFailed = !!latestMapOutputError.current;
|
|
154
155
|
|
|
155
|
-
if (hasReplacedMapSelect || lastMapSelectFailed) {
|
|
156
|
+
if (hasReplacedRegistry || hasReplacedMapSelect || lastMapSelectFailed) {
|
|
156
157
|
try {
|
|
157
|
-
mapOutput =
|
|
158
|
+
mapOutput = wrapSelect(_mapSelect);
|
|
158
159
|
} catch (error) {
|
|
159
160
|
let errorMessage = `An error occurred while running 'mapSelect': ${error.message}`;
|
|
160
161
|
|
|
@@ -175,10 +176,10 @@ function useSelect(mapSelect, deps) {
|
|
|
175
176
|
return;
|
|
176
177
|
}
|
|
177
178
|
|
|
179
|
+
latestRegistry.current = registry;
|
|
178
180
|
latestMapSelect.current = _mapSelect;
|
|
179
181
|
latestMapOutput.current = mapOutput;
|
|
180
|
-
latestMapOutputError.current = undefined;
|
|
181
|
-
isMountedAndNotUnsubscribing.current = true; // This has to run after the other ref updates
|
|
182
|
+
latestMapOutputError.current = undefined; // This has to run after the other ref updates
|
|
182
183
|
// to avoid using stale values in the flushed
|
|
183
184
|
// callbacks or potentially overwriting a
|
|
184
185
|
// changed `latestMapOutput.current`.
|
|
@@ -194,30 +195,20 @@ function useSelect(mapSelect, deps) {
|
|
|
194
195
|
}
|
|
195
196
|
|
|
196
197
|
const onStoreChange = () => {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
const newMapOutput = trapSelect(() => latestMapSelect.current(registry.select, registry));
|
|
200
|
-
|
|
201
|
-
if ((0, _isShallowEqual.default)(latestMapOutput.current, newMapOutput)) {
|
|
202
|
-
return;
|
|
203
|
-
}
|
|
198
|
+
try {
|
|
199
|
+
const newMapOutput = wrapSelect(latestMapSelect.current);
|
|
204
200
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
latestMapOutputError.current = error;
|
|
201
|
+
if ((0, _isShallowEqual.default)(latestMapOutput.current, newMapOutput)) {
|
|
202
|
+
return;
|
|
208
203
|
}
|
|
209
204
|
|
|
210
|
-
|
|
205
|
+
latestMapOutput.current = newMapOutput;
|
|
206
|
+
} catch (error) {
|
|
207
|
+
latestMapOutputError.current = error;
|
|
211
208
|
}
|
|
212
|
-
}; // Catch any possible state changes during mount before the subscription
|
|
213
|
-
// could be set.
|
|
214
|
-
|
|
215
209
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
} else {
|
|
219
|
-
onStoreChange();
|
|
220
|
-
}
|
|
210
|
+
forceRender();
|
|
211
|
+
};
|
|
221
212
|
|
|
222
213
|
const onChange = () => {
|
|
223
214
|
if (latestIsAsync.current) {
|
|
@@ -225,18 +216,20 @@ function useSelect(mapSelect, deps) {
|
|
|
225
216
|
} else {
|
|
226
217
|
onStoreChange();
|
|
227
218
|
}
|
|
228
|
-
};
|
|
219
|
+
}; // Catch any possible state changes during mount before the subscription
|
|
220
|
+
// could be set.
|
|
229
221
|
|
|
230
|
-
const unsubscribers = listeningStores.current.map(storeName => registry.__experimentalSubscribeStore(storeName, onChange));
|
|
231
|
-
return () => {
|
|
232
|
-
isMountedAndNotUnsubscribing.current = false; // The return value of the subscribe function could be undefined if the store is a custom generic store.
|
|
233
222
|
|
|
223
|
+
onStoreChange();
|
|
224
|
+
const unsubscribers = listeningStores.current.map(storeName => registry.__unstableSubscribeStore(storeName, onChange));
|
|
225
|
+
return () => {
|
|
226
|
+
// The return value of the subscribe function could be undefined if the store is a custom generic store.
|
|
234
227
|
unsubscribers.forEach(unsubscribe => unsubscribe === null || unsubscribe === void 0 ? void 0 : unsubscribe());
|
|
235
|
-
renderQueue.
|
|
228
|
+
renderQueue.cancel(queueContext);
|
|
236
229
|
}; // If you're tempted to eliminate the spread dependencies below don't do it!
|
|
237
230
|
// We're passing these in from the calling function and want to make sure we're
|
|
238
231
|
// examining every individual value inside the `deps` array.
|
|
239
|
-
}, [registry,
|
|
232
|
+
}, [registry, wrapSelect, hasMappingFunction, depsChangedFlag]);
|
|
240
233
|
return hasMappingFunction ? mapOutput : registry.select(mapSelect);
|
|
241
234
|
}
|
|
242
235
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/data/src/components/use-select/index.js"],"names":["noop","renderQueue","useSelect","mapSelect","deps","hasMappingFunction","callbackMapper","_mapSelect","registry","isAsync","queueContext","queue","forceRender","s","latestMapSelect","latestIsAsync","latestMapOutput","latestMapOutputError","isMountedAndNotUnsubscribing","listeningStores","trapSelect","callback","__experimentalMarkListeningStores","depsChangedFlag","mapOutput","current","hasReplacedMapSelect","lastMapSelectFailed","select","error","errorMessage","message","stack","console","undefined","flush","onStoreChange","newMapOutput","add","onChange","unsubscribers","map","storeName","__experimentalSubscribeStore","forEach","unsubscribe"],"mappings":";;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAjBA;AACA;AACA;;AAGA;AACA;AACA;;AAMA;AACA;AACA;AAIA,MAAMA,IAAI,GAAG,MAAM,CAAE,CAArB;;AACA,MAAMC,WAAW,GAAG,iCAApB;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A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ADqB,CAAtB;AAIA,WAAO,MAAM;AACZrB,MAAAA,4BAA4B,CAACO,OAA7B,GAAuC,KAAvC,CADY,CAEZ;;AACAe,MAAAA,aAAa,CAACI,OAAd,CAAyBC,WAAF,IAAmBA,WAAnB,aAAmBA,WAAnB,uBAAmBA,WAAW,EAArD;AACA5C,MAAAA,WAAW,CAACkC,KAAZ,CAAmBzB,YAAnB;AACA,KALD,CA7CgC,CAmDhC;AACA;AACA;AACA,GAtDD,EAsDG,CAAEF,QAAF,EAAYY,UAAZ,EAAwBf,kBAAxB,EAA4CkB,eAA5C,CAtDH;AAwDA,SAAOlB,kBAAkB,GAAGmB,SAAH,GAAehB,QAAQ,CAACoB,MAAT,CAAiBzB,SAAjB,CAAxC;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { useMemoOne } from 'use-memo-one';\n\n/**\n * WordPress dependencies\n */\nimport { createQueue } from '@wordpress/priority-queue';\nimport { useRef, useCallback, useMemo, useReducer } from '@wordpress/element';\nimport isShallowEqual from '@wordpress/is-shallow-equal';\nimport { useIsomorphicLayoutEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport useRegistry from '../registry-provider/use-registry';\nimport useAsyncMode from '../async-mode-provider/use-async-mode';\n\nconst noop = () => {};\nconst renderQueue = createQueue();\n\n/** @typedef {import('../../types').StoreDescriptor} StoreDescriptor */\n\n/**\n * Custom react hook for retrieving props from registered selectors.\n *\n * In general, this custom React hook follows the\n * [rules of hooks](https://reactjs.org/docs/hooks-rules.html).\n *\n * @param {Function|StoreDescriptor|string} mapSelect Function called on every state change. The\n * returned value is exposed to the component\n * implementing this hook. The function receives\n * the `registry.select` method on the first\n * argument and the `registry` on the second\n * argument.\n * When a store key is passed, all selectors for\n * the store will be returned. This is only meant\n * for usage of these selectors in event\n * callbacks, not for data needed to create the\n * element tree.\n * @param {Array} deps If provided, this memoizes the mapSelect so the\n * same `mapSelect` is invoked on every state\n * change unless the dependencies change.\n *\n * @example\n * ```js\n * import { useSelect } from '@wordpress/data';\n *\n * function HammerPriceDisplay( { currency } ) {\n * const price = useSelect( ( select ) => {\n * return select( 'my-shop' ).getPrice( 'hammer', currency )\n * }, [ currency ] );\n * return new Intl.NumberFormat( 'en-US', {\n * style: 'currency',\n * currency,\n * } ).format( price );\n * }\n *\n * // Rendered in the application:\n * // <HammerPriceDisplay currency=\"USD\" />\n * ```\n *\n * In the above example, when `HammerPriceDisplay` is rendered into an\n * application, the price will be retrieved from the store state using the\n * `mapSelect` callback on `useSelect`. If the currency prop changes then\n * any price in the state for that currency is retrieved. If the currency prop\n * doesn't change and other props are passed in that do change, the price will\n * not change because the dependency is just the currency.\n *\n * When data is only used in an event callback, the data should not be retrieved\n * on render, so it may be useful to get the selectors function instead.\n *\n * **Don't use `useSelect` this way when calling the selectors in the render\n * function because your component won't re-render on a data change.**\n *\n * ```js\n * import { useSelect } from '@wordpress/data';\n *\n * function Paste( { children } ) {\n * const { getSettings } = useSelect( 'my-shop' );\n * function onPaste() {\n * // Do something with the settings.\n * const settings = getSettings();\n * }\n * return <div onPaste={ onPaste }>{ children }</div>;\n * }\n * ```\n *\n * @return {Function} A custom react hook.\n */\nexport default function useSelect( mapSelect, deps ) {\n\tconst hasMappingFunction = 'function' === typeof mapSelect;\n\n\t// If we're recalling a store by its name or by\n\t// its descriptor then we won't be caching the\n\t// calls to `mapSelect` because we won't be calling it.\n\tif ( ! hasMappingFunction ) {\n\t\tdeps = [];\n\t}\n\n\t// Because of the \"rule of hooks\" we have to call `useCallback`\n\t// on every invocation whether or not we have a real function\n\t// for `mapSelect`. we'll create this intermediate variable to\n\t// fulfill that need and then reference it with our \"real\"\n\t// `_mapSelect` if we can.\n\tconst callbackMapper = useCallback(\n\t\thasMappingFunction ? mapSelect : noop,\n\t\tdeps\n\t);\n\tconst _mapSelect = hasMappingFunction ? callbackMapper : null;\n\n\tconst registry = useRegistry();\n\tconst isAsync = useAsyncMode();\n\t// React can sometimes clear the `useMemo` cache.\n\t// We use the cache-stable `useMemoOne` to avoid\n\t// losing queues.\n\tconst queueContext = useMemoOne( () => ( { queue: true } ), [ registry ] );\n\tconst [ , forceRender ] = useReducer( ( s ) => s + 1, 0 );\n\n\tconst latestMapSelect = useRef();\n\tconst latestIsAsync = useRef( isAsync );\n\tconst latestMapOutput = useRef();\n\tconst latestMapOutputError = useRef();\n\tconst isMountedAndNotUnsubscribing = useRef();\n\n\t// Keep track of the stores being selected in the _mapSelect function,\n\t// and only subscribe to those stores later.\n\tconst listeningStores = useRef( [] );\n\tconst trapSelect = useCallback(\n\t\t( callback ) =>\n\t\t\tregistry.__experimentalMarkListeningStores(\n\t\t\t\tcallback,\n\t\t\t\tlisteningStores\n\t\t\t),\n\t\t[ registry ]\n\t);\n\n\t// Generate a \"flag\" for used in the effect dependency array.\n\t// It's different than just using `mapSelect` since deps could be undefined,\n\t// in that case, we would still want to memoize it.\n\tconst depsChangedFlag = useMemo( () => ( {} ), deps || [] );\n\n\tlet mapOutput;\n\n\tif ( _mapSelect ) {\n\t\tmapOutput = latestMapOutput.current;\n\t\tconst hasReplacedMapSelect = latestMapSelect.current !== _mapSelect;\n\t\tconst lastMapSelectFailed = !! latestMapOutputError.current;\n\n\t\tif ( hasReplacedMapSelect || lastMapSelectFailed ) {\n\t\t\ttry {\n\t\t\t\tmapOutput = trapSelect( () =>\n\t\t\t\t\t_mapSelect( registry.select, registry )\n\t\t\t\t);\n\t\t\t} catch ( error ) {\n\t\t\t\tlet errorMessage = `An error occurred while running 'mapSelect': ${ error.message }`;\n\n\t\t\t\tif ( latestMapOutputError.current ) {\n\t\t\t\t\terrorMessage += `\\nThe error may be correlated with this previous error:\\n`;\n\t\t\t\t\terrorMessage += `${ latestMapOutputError.current.stack }\\n\\n`;\n\t\t\t\t\terrorMessage += 'Original stack trace:';\n\t\t\t\t}\n\n\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\tconsole.error( errorMessage );\n\t\t\t}\n\t\t}\n\t}\n\n\tuseIsomorphicLayoutEffect( () => {\n\t\tif ( ! hasMappingFunction ) {\n\t\t\treturn;\n\t\t}\n\n\t\tlatestMapSelect.current = _mapSelect;\n\t\tlatestMapOutput.current = mapOutput;\n\t\tlatestMapOutputError.current = undefined;\n\t\tisMountedAndNotUnsubscribing.current = true;\n\n\t\t// This has to run after the other ref updates\n\t\t// to avoid using stale values in the flushed\n\t\t// callbacks or potentially overwriting a\n\t\t// changed `latestMapOutput.current`.\n\t\tif ( latestIsAsync.current !== isAsync ) {\n\t\t\tlatestIsAsync.current = isAsync;\n\t\t\trenderQueue.flush( queueContext );\n\t\t}\n\t} );\n\n\tuseIsomorphicLayoutEffect( () => {\n\t\tif ( ! hasMappingFunction ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst onStoreChange = () => {\n\t\t\tif ( isMountedAndNotUnsubscribing.current ) {\n\t\t\t\ttry {\n\t\t\t\t\tconst newMapOutput = trapSelect( () =>\n\t\t\t\t\t\tlatestMapSelect.current( registry.select, registry )\n\t\t\t\t\t);\n\n\t\t\t\t\tif (\n\t\t\t\t\t\tisShallowEqual( latestMapOutput.current, newMapOutput )\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tlatestMapOutput.current = newMapOutput;\n\t\t\t\t} catch ( error ) {\n\t\t\t\t\tlatestMapOutputError.current = error;\n\t\t\t\t}\n\t\t\t\tforceRender();\n\t\t\t}\n\t\t};\n\n\t\t// Catch any possible state changes during mount before the subscription\n\t\t// could be set.\n\t\tif ( latestIsAsync.current ) {\n\t\t\trenderQueue.add( queueContext, onStoreChange );\n\t\t} else {\n\t\t\tonStoreChange();\n\t\t}\n\n\t\tconst onChange = () => {\n\t\t\tif ( latestIsAsync.current ) {\n\t\t\t\trenderQueue.add( queueContext, onStoreChange );\n\t\t\t} else {\n\t\t\t\tonStoreChange();\n\t\t\t}\n\t\t};\n\n\t\tconst unsubscribers = listeningStores.current.map( ( storeName ) =>\n\t\t\tregistry.__experimentalSubscribeStore( storeName, onChange )\n\t\t);\n\n\t\treturn () => {\n\t\t\tisMountedAndNotUnsubscribing.current = false;\n\t\t\t// The return value of the subscribe function could be undefined if the store is a custom generic store.\n\t\t\tunsubscribers.forEach( ( unsubscribe ) => unsubscribe?.() );\n\t\t\trenderQueue.flush( queueContext );\n\t\t};\n\t\t// If you're tempted to eliminate the spread dependencies below don't do it!\n\t\t// We're passing these in from the calling function and want to make sure we're\n\t\t// examining every individual value inside the `deps` array.\n\t}, [ registry, trapSelect, hasMappingFunction, depsChangedFlag ] );\n\n\treturn hasMappingFunction ? mapOutput : registry.select( mapSelect );\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/data/src/components/use-select/index.js"],"names":["noop","renderQueue","useSelect","mapSelect","deps","hasMappingFunction","callbackMapper","_mapSelect","registry","isAsync","queueContext","queue","forceRender","s","latestRegistry","latestMapSelect","latestIsAsync","latestMapOutput","latestMapOutputError","listeningStores","wrapSelect","callback","__unstableMarkListeningStores","select","depsChangedFlag","mapOutput","current","hasReplacedRegistry","hasReplacedMapSelect","lastMapSelectFailed","error","errorMessage","message","stack","console","undefined","flush","onStoreChange","newMapOutput","onChange","add","unsubscribers","map","storeName","__unstableSubscribeStore","forEach","unsubscribe","cancel"],"mappings":";;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAjBA;AACA;AACA;;AAGA;AACA;AACA;;AAMA;AACA;AACA;AAIA,MAAMA,IAAI,GAAG,MAAM,CAAE,CAArB;;AACA,MAAMC,WAAW,GAAG,iCAApB;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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,GAAGoB,SAAH,GAAejB,QAAQ,CAACe,MAAT,CAAiBpB,SAAjB,CAAxC;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { useMemoOne } from 'use-memo-one';\n\n/**\n * WordPress dependencies\n */\nimport { createQueue } from '@wordpress/priority-queue';\nimport { useRef, useCallback, useMemo, useReducer } from '@wordpress/element';\nimport isShallowEqual from '@wordpress/is-shallow-equal';\nimport { useIsomorphicLayoutEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport useRegistry from '../registry-provider/use-registry';\nimport useAsyncMode from '../async-mode-provider/use-async-mode';\n\nconst noop = () => {};\nconst renderQueue = createQueue();\n\n/** @typedef {import('../../types').StoreDescriptor} StoreDescriptor */\n\n/**\n * Custom react hook for retrieving props from registered selectors.\n *\n * In general, this custom React hook follows the\n * [rules of hooks](https://reactjs.org/docs/hooks-rules.html).\n *\n * @param {Function|StoreDescriptor|string} mapSelect Function called on every state change. The\n * returned value is exposed to the component\n * implementing this hook. The function receives\n * the `registry.select` method on the first\n * argument and the `registry` on the second\n * argument.\n * When a store key is passed, all selectors for\n * the store will be returned. This is only meant\n * for usage of these selectors in event\n * callbacks, not for data needed to create the\n * element tree.\n * @param {Array} deps If provided, this memoizes the mapSelect so the\n * same `mapSelect` is invoked on every state\n * change unless the dependencies change.\n *\n * @example\n * ```js\n * import { useSelect } from '@wordpress/data';\n *\n * function HammerPriceDisplay( { currency } ) {\n * const price = useSelect( ( select ) => {\n * return select( 'my-shop' ).getPrice( 'hammer', currency )\n * }, [ currency ] );\n * return new Intl.NumberFormat( 'en-US', {\n * style: 'currency',\n * currency,\n * } ).format( price );\n * }\n *\n * // Rendered in the application:\n * // <HammerPriceDisplay currency=\"USD\" />\n * ```\n *\n * In the above example, when `HammerPriceDisplay` is rendered into an\n * application, the price will be retrieved from the store state using the\n * `mapSelect` callback on `useSelect`. If the currency prop changes then\n * any price in the state for that currency is retrieved. If the currency prop\n * doesn't change and other props are passed in that do change, the price will\n * not change because the dependency is just the currency.\n *\n * When data is only used in an event callback, the data should not be retrieved\n * on render, so it may be useful to get the selectors function instead.\n *\n * **Don't use `useSelect` this way when calling the selectors in the render\n * function because your component won't re-render on a data change.**\n *\n * ```js\n * import { useSelect } from '@wordpress/data';\n *\n * function Paste( { children } ) {\n * const { getSettings } = useSelect( 'my-shop' );\n * function onPaste() {\n * // Do something with the settings.\n * const settings = getSettings();\n * }\n * return <div onPaste={ onPaste }>{ children }</div>;\n * }\n * ```\n *\n * @return {Function} A custom react hook.\n */\nexport default function useSelect( mapSelect, deps ) {\n\tconst hasMappingFunction = 'function' === typeof mapSelect;\n\n\t// If we're recalling a store by its name or by\n\t// its descriptor then we won't be caching the\n\t// calls to `mapSelect` because we won't be calling it.\n\tif ( ! hasMappingFunction ) {\n\t\tdeps = [];\n\t}\n\n\t// Because of the \"rule of hooks\" we have to call `useCallback`\n\t// on every invocation whether or not we have a real function\n\t// for `mapSelect`. we'll create this intermediate variable to\n\t// fulfill that need and then reference it with our \"real\"\n\t// `_mapSelect` if we can.\n\tconst callbackMapper = useCallback(\n\t\thasMappingFunction ? mapSelect : noop,\n\t\tdeps\n\t);\n\tconst _mapSelect = hasMappingFunction ? callbackMapper : null;\n\n\tconst registry = useRegistry();\n\tconst isAsync = useAsyncMode();\n\t// React can sometimes clear the `useMemo` cache.\n\t// We use the cache-stable `useMemoOne` to avoid\n\t// losing queues.\n\tconst queueContext = useMemoOne( () => ( { queue: true } ), [ registry ] );\n\tconst [ , forceRender ] = useReducer( ( s ) => s + 1, 0 );\n\n\tconst latestRegistry = useRef( registry );\n\tconst latestMapSelect = useRef();\n\tconst latestIsAsync = useRef( isAsync );\n\tconst latestMapOutput = useRef();\n\tconst latestMapOutputError = useRef();\n\n\t// Keep track of the stores being selected in the _mapSelect function,\n\t// and only subscribe to those stores later.\n\tconst listeningStores = useRef( [] );\n\tconst wrapSelect = useCallback(\n\t\t( callback ) =>\n\t\t\tregistry.__unstableMarkListeningStores(\n\t\t\t\t() => callback( registry.select, registry ),\n\t\t\t\tlisteningStores\n\t\t\t),\n\t\t[ registry ]\n\t);\n\n\t// Generate a \"flag\" for used in the effect dependency array.\n\t// It's different than just using `mapSelect` since deps could be undefined,\n\t// in that case, we would still want to memoize it.\n\tconst depsChangedFlag = useMemo( () => ( {} ), deps || [] );\n\n\tlet mapOutput;\n\n\tif ( _mapSelect ) {\n\t\tmapOutput = latestMapOutput.current;\n\t\tconst hasReplacedRegistry = latestRegistry.current !== registry;\n\t\tconst hasReplacedMapSelect = latestMapSelect.current !== _mapSelect;\n\t\tconst lastMapSelectFailed = !! latestMapOutputError.current;\n\n\t\tif (\n\t\t\thasReplacedRegistry ||\n\t\t\thasReplacedMapSelect ||\n\t\t\tlastMapSelectFailed\n\t\t) {\n\t\t\ttry {\n\t\t\t\tmapOutput = wrapSelect( _mapSelect );\n\t\t\t} catch ( error ) {\n\t\t\t\tlet errorMessage = `An error occurred while running 'mapSelect': ${ error.message }`;\n\n\t\t\t\tif ( latestMapOutputError.current ) {\n\t\t\t\t\terrorMessage += `\\nThe error may be correlated with this previous error:\\n`;\n\t\t\t\t\terrorMessage += `${ latestMapOutputError.current.stack }\\n\\n`;\n\t\t\t\t\terrorMessage += 'Original stack trace:';\n\t\t\t\t}\n\n\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\tconsole.error( errorMessage );\n\t\t\t}\n\t\t}\n\t}\n\n\tuseIsomorphicLayoutEffect( () => {\n\t\tif ( ! hasMappingFunction ) {\n\t\t\treturn;\n\t\t}\n\n\t\tlatestRegistry.current = registry;\n\t\tlatestMapSelect.current = _mapSelect;\n\t\tlatestMapOutput.current = mapOutput;\n\t\tlatestMapOutputError.current = undefined;\n\n\t\t// This has to run after the other ref updates\n\t\t// to avoid using stale values in the flushed\n\t\t// callbacks or potentially overwriting a\n\t\t// changed `latestMapOutput.current`.\n\t\tif ( latestIsAsync.current !== isAsync ) {\n\t\t\tlatestIsAsync.current = isAsync;\n\t\t\trenderQueue.flush( queueContext );\n\t\t}\n\t} );\n\n\tuseIsomorphicLayoutEffect( () => {\n\t\tif ( ! hasMappingFunction ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst onStoreChange = () => {\n\t\t\ttry {\n\t\t\t\tconst newMapOutput = wrapSelect( latestMapSelect.current );\n\n\t\t\t\tif ( isShallowEqual( latestMapOutput.current, newMapOutput ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlatestMapOutput.current = newMapOutput;\n\t\t\t} catch ( error ) {\n\t\t\t\tlatestMapOutputError.current = error;\n\t\t\t}\n\t\t\tforceRender();\n\t\t};\n\n\t\tconst onChange = () => {\n\t\t\tif ( latestIsAsync.current ) {\n\t\t\t\trenderQueue.add( queueContext, onStoreChange );\n\t\t\t} else {\n\t\t\t\tonStoreChange();\n\t\t\t}\n\t\t};\n\n\t\t// Catch any possible state changes during mount before the subscription\n\t\t// could be set.\n\t\tonStoreChange();\n\n\t\tconst unsubscribers = listeningStores.current.map( ( storeName ) =>\n\t\t\tregistry.__unstableSubscribeStore( storeName, onChange )\n\t\t);\n\n\t\treturn () => {\n\t\t\t// The return value of the subscribe function could be undefined if the store is a custom generic store.\n\t\t\tunsubscribers.forEach( ( unsubscribe ) => unsubscribe?.() );\n\t\t\trenderQueue.cancel( queueContext );\n\t\t};\n\t\t// If you're tempted to eliminate the spread dependencies below don't do it!\n\t\t// We're passing these in from the calling function and want to make sure we're\n\t\t// examining every individual value inside the `deps` array.\n\t}, [ registry, wrapSelect, hasMappingFunction, depsChangedFlag ] );\n\n\treturn hasMappingFunction ? mapOutput : registry.select( mapSelect );\n}\n"]}
|
|
@@ -5,10 +5,12 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
+
exports.convertEditPostPanels = convertEditPostPanels;
|
|
8
9
|
exports.createPersistenceInterface = createPersistenceInterface;
|
|
9
10
|
exports.default = void 0;
|
|
10
11
|
exports.migrateFeaturePreferencesToPreferencesStore = migrateFeaturePreferencesToPreferencesStore;
|
|
11
12
|
exports.migrateIndividualPreferenceToPreferencesStore = migrateIndividualPreferenceToPreferencesStore;
|
|
13
|
+
exports.migrateInterfaceEnableItemsToPreferencesStore = migrateInterfaceEnableItemsToPreferencesStore;
|
|
12
14
|
exports.migrateThirdPartyFeaturePreferencesToPreferencesStore = migrateThirdPartyFeaturePreferencesToPreferencesStore;
|
|
13
15
|
exports.withLazySameState = void 0;
|
|
14
16
|
|
|
@@ -298,30 +300,51 @@ function migrateFeaturePreferencesToPreferencesStore(persistence, sourceStoreNam
|
|
|
298
300
|
}
|
|
299
301
|
}
|
|
300
302
|
}
|
|
303
|
+
/**
|
|
304
|
+
* Migrates an individual item inside the `preferences` object for a store.
|
|
305
|
+
*
|
|
306
|
+
* @param {Object} persistence The persistence interface.
|
|
307
|
+
* @param {Object} migrate An options object that contains details of the migration.
|
|
308
|
+
* @param {string} migrate.from The name of the store to migrate from.
|
|
309
|
+
* @param {string} migrate.scope The scope in the preferences store to migrate to.
|
|
310
|
+
* @param {string} key The key in the preferences object to migrate.
|
|
311
|
+
* @param {?Function} convert A function that converts preferences from one format to another.
|
|
312
|
+
*/
|
|
313
|
+
|
|
301
314
|
|
|
302
|
-
function migrateIndividualPreferenceToPreferencesStore(persistence,
|
|
315
|
+
function migrateIndividualPreferenceToPreferencesStore(persistence, _ref, key) {
|
|
303
316
|
var _state$sourceStoreNam4, _state$sourceStoreNam5, _state$preferencesSto2, _state$preferencesSto3, _state$preferencesSto4, _state$preferencesSto5, _state$preferencesSto6, _state$preferencesSto7, _state$sourceStoreNam6;
|
|
304
317
|
|
|
318
|
+
let {
|
|
319
|
+
from: sourceStoreName,
|
|
320
|
+
scope
|
|
321
|
+
} = _ref;
|
|
322
|
+
let convert = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _lodash.identity;
|
|
305
323
|
const preferencesStoreName = 'core/preferences';
|
|
306
324
|
const state = persistence.get();
|
|
307
325
|
const sourcePreference = (_state$sourceStoreNam4 = state[sourceStoreName]) === null || _state$sourceStoreNam4 === void 0 ? void 0 : (_state$sourceStoreNam5 = _state$sourceStoreNam4.preferences) === null || _state$sourceStoreNam5 === void 0 ? void 0 : _state$sourceStoreNam5[key]; // There's nothing to migrate, exit early.
|
|
308
326
|
|
|
309
|
-
if (
|
|
327
|
+
if (sourcePreference === undefined) {
|
|
310
328
|
return;
|
|
311
329
|
}
|
|
312
330
|
|
|
313
|
-
const targetPreference = (_state$preferencesSto2 = state[preferencesStoreName]) === null || _state$preferencesSto2 === void 0 ? void 0 : (_state$preferencesSto3 = _state$preferencesSto2.preferences) === null || _state$preferencesSto3 === void 0 ? void 0 : (_state$preferencesSto4 = _state$preferencesSto3[
|
|
331
|
+
const targetPreference = (_state$preferencesSto2 = state[preferencesStoreName]) === null || _state$preferencesSto2 === void 0 ? void 0 : (_state$preferencesSto3 = _state$preferencesSto2.preferences) === null || _state$preferencesSto3 === void 0 ? void 0 : (_state$preferencesSto4 = _state$preferencesSto3[scope]) === null || _state$preferencesSto4 === void 0 ? void 0 : _state$preferencesSto4[key]; // There's existing data at the target, so don't overwrite it, exit early.
|
|
314
332
|
|
|
315
333
|
if (targetPreference) {
|
|
316
334
|
return;
|
|
317
335
|
}
|
|
318
336
|
|
|
319
|
-
const
|
|
320
|
-
const
|
|
337
|
+
const otherScopes = (_state$preferencesSto5 = state[preferencesStoreName]) === null || _state$preferencesSto5 === void 0 ? void 0 : _state$preferencesSto5.preferences;
|
|
338
|
+
const otherPreferences = (_state$preferencesSto6 = state[preferencesStoreName]) === null || _state$preferencesSto6 === void 0 ? void 0 : (_state$preferencesSto7 = _state$preferencesSto6.preferences) === null || _state$preferencesSto7 === void 0 ? void 0 : _state$preferencesSto7[scope]; // Pass an object with the key and value as this allows the convert
|
|
339
|
+
// function to convert to a data structure that has different keys.
|
|
340
|
+
|
|
341
|
+
const convertedPreferences = convert({
|
|
342
|
+
[key]: sourcePreference
|
|
343
|
+
});
|
|
321
344
|
persistence.set(preferencesStoreName, {
|
|
322
|
-
preferences: { ...
|
|
323
|
-
[
|
|
324
|
-
|
|
345
|
+
preferences: { ...otherScopes,
|
|
346
|
+
[scope]: { ...otherPreferences,
|
|
347
|
+
...convertedPreferences
|
|
325
348
|
}
|
|
326
349
|
}
|
|
327
350
|
}); // Remove migrated feature preferences from the source.
|
|
@@ -334,6 +357,60 @@ function migrateIndividualPreferenceToPreferencesStore(persistence, sourceStoreN
|
|
|
334
357
|
}
|
|
335
358
|
});
|
|
336
359
|
}
|
|
360
|
+
/**
|
|
361
|
+
* Convert from:
|
|
362
|
+
* ```
|
|
363
|
+
* {
|
|
364
|
+
* panels: {
|
|
365
|
+
* tags: {
|
|
366
|
+
* enabled: true,
|
|
367
|
+
* opened: true,
|
|
368
|
+
* },
|
|
369
|
+
* permalinks: {
|
|
370
|
+
* enabled: false,
|
|
371
|
+
* opened: false,
|
|
372
|
+
* },
|
|
373
|
+
* },
|
|
374
|
+
* }
|
|
375
|
+
* ```
|
|
376
|
+
*
|
|
377
|
+
* to:
|
|
378
|
+
* {
|
|
379
|
+
* inactivePanels: [
|
|
380
|
+
* 'permalinks',
|
|
381
|
+
* ],
|
|
382
|
+
* openPanels: [
|
|
383
|
+
* 'tags',
|
|
384
|
+
* ],
|
|
385
|
+
* }
|
|
386
|
+
*
|
|
387
|
+
* @param {Object} preferences A preferences object.
|
|
388
|
+
*
|
|
389
|
+
* @return {Object} The converted data.
|
|
390
|
+
*/
|
|
391
|
+
|
|
392
|
+
|
|
393
|
+
function convertEditPostPanels(preferences) {
|
|
394
|
+
var _preferences$panels;
|
|
395
|
+
|
|
396
|
+
const panels = (_preferences$panels = preferences === null || preferences === void 0 ? void 0 : preferences.panels) !== null && _preferences$panels !== void 0 ? _preferences$panels : {};
|
|
397
|
+
return Object.keys(panels).reduce((convertedData, panelName) => {
|
|
398
|
+
const panel = panels[panelName];
|
|
399
|
+
|
|
400
|
+
if ((panel === null || panel === void 0 ? void 0 : panel.enabled) === false) {
|
|
401
|
+
convertedData.inactivePanels.push(panelName);
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
if ((panel === null || panel === void 0 ? void 0 : panel.opened) === true) {
|
|
405
|
+
convertedData.openPanels.push(panelName);
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
return convertedData;
|
|
409
|
+
}, {
|
|
410
|
+
inactivePanels: [],
|
|
411
|
+
openPanels: []
|
|
412
|
+
});
|
|
413
|
+
}
|
|
337
414
|
|
|
338
415
|
function migrateThirdPartyFeaturePreferencesToPreferencesStore(persistence) {
|
|
339
416
|
var _state$interfaceStore6, _state$interfaceStore7;
|
|
@@ -349,7 +426,7 @@ function migrateThirdPartyFeaturePreferencesToPreferencesStore(persistence) {
|
|
|
349
426
|
// Don't migrate any core 'scopes'.
|
|
350
427
|
if (scope.startsWith('core')) {
|
|
351
428
|
continue;
|
|
352
|
-
} // Skip this scope if there are no features to
|
|
429
|
+
} // Skip this scope if there are no features to migrate.
|
|
353
430
|
|
|
354
431
|
|
|
355
432
|
const featuresToMigrate = interfaceScopes[scope];
|
|
@@ -380,6 +457,113 @@ function migrateThirdPartyFeaturePreferencesToPreferencesStore(persistence) {
|
|
|
380
457
|
});
|
|
381
458
|
}
|
|
382
459
|
}
|
|
460
|
+
/**
|
|
461
|
+
* Migrates interface 'enableItems' data to the preferences store.
|
|
462
|
+
*
|
|
463
|
+
* The interface package stores this data in this format:
|
|
464
|
+
* ```js
|
|
465
|
+
* {
|
|
466
|
+
* enableItems: {
|
|
467
|
+
* singleEnableItems: {
|
|
468
|
+
* complementaryArea: {
|
|
469
|
+
* 'core/edit-post': 'edit-post/document',
|
|
470
|
+
* 'core/edit-site': 'edit-site/global-styles',
|
|
471
|
+
* }
|
|
472
|
+
* },
|
|
473
|
+
* multipleEnableItems: {
|
|
474
|
+
* pinnedItems: {
|
|
475
|
+
* 'core/edit-post': {
|
|
476
|
+
* 'plugin-1': true,
|
|
477
|
+
* },
|
|
478
|
+
* 'core/edit-site': {
|
|
479
|
+
* 'plugin-2': true,
|
|
480
|
+
* },
|
|
481
|
+
* },
|
|
482
|
+
* }
|
|
483
|
+
* }
|
|
484
|
+
* }
|
|
485
|
+
* ```
|
|
486
|
+
* and it should be migrated it to:
|
|
487
|
+
* ```js
|
|
488
|
+
* {
|
|
489
|
+
* 'core/edit-post': {
|
|
490
|
+
* complementaryArea: 'edit-post/document',
|
|
491
|
+
* pinnedItems: {
|
|
492
|
+
* 'plugin-1': true,
|
|
493
|
+
* },
|
|
494
|
+
* },
|
|
495
|
+
* 'core/edit-site': {
|
|
496
|
+
* complementaryArea: 'edit-site/global-styles',
|
|
497
|
+
* pinnedItems: {
|
|
498
|
+
* 'plugin-2': true,
|
|
499
|
+
* },
|
|
500
|
+
* },
|
|
501
|
+
* }
|
|
502
|
+
* ```
|
|
503
|
+
*
|
|
504
|
+
* @param {Object} persistence The persistence interface.
|
|
505
|
+
*/
|
|
506
|
+
|
|
507
|
+
|
|
508
|
+
function migrateInterfaceEnableItemsToPreferencesStore(persistence) {
|
|
509
|
+
var _state$interfaceStore10, _state$preferencesSto9, _state$preferencesSto10, _sourceEnableItems$si, _sourceEnableItems$si2, _sourceEnableItems$mu, _sourceEnableItems$mu2;
|
|
510
|
+
|
|
511
|
+
const interfaceStoreName = 'core/interface';
|
|
512
|
+
const preferencesStoreName = 'core/preferences';
|
|
513
|
+
const state = persistence.get();
|
|
514
|
+
const sourceEnableItems = (_state$interfaceStore10 = state[interfaceStoreName]) === null || _state$interfaceStore10 === void 0 ? void 0 : _state$interfaceStore10.enableItems; // There's nothing to migrate, exit early.
|
|
515
|
+
|
|
516
|
+
if (!sourceEnableItems) {
|
|
517
|
+
return;
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
const allPreferences = (_state$preferencesSto9 = (_state$preferencesSto10 = state[preferencesStoreName]) === null || _state$preferencesSto10 === void 0 ? void 0 : _state$preferencesSto10.preferences) !== null && _state$preferencesSto9 !== void 0 ? _state$preferencesSto9 : {}; // First convert complementaryAreas into the right format.
|
|
521
|
+
// Use the existing preferences as the accumulator so that the data is
|
|
522
|
+
// merged.
|
|
523
|
+
|
|
524
|
+
const sourceComplementaryAreas = (_sourceEnableItems$si = sourceEnableItems === null || sourceEnableItems === void 0 ? void 0 : (_sourceEnableItems$si2 = sourceEnableItems.singleEnableItems) === null || _sourceEnableItems$si2 === void 0 ? void 0 : _sourceEnableItems$si2.complementaryArea) !== null && _sourceEnableItems$si !== void 0 ? _sourceEnableItems$si : {};
|
|
525
|
+
const convertedComplementaryAreas = Object.keys(sourceComplementaryAreas).reduce((accumulator, scope) => {
|
|
526
|
+
var _accumulator$scope;
|
|
527
|
+
|
|
528
|
+
const data = sourceComplementaryAreas[scope]; // Don't overwrite any existing data in the preferences store.
|
|
529
|
+
|
|
530
|
+
if ((_accumulator$scope = accumulator[scope]) !== null && _accumulator$scope !== void 0 && _accumulator$scope.complementaryArea) {
|
|
531
|
+
return accumulator;
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
return { ...accumulator,
|
|
535
|
+
[scope]: { ...accumulator[scope],
|
|
536
|
+
complementaryArea: data
|
|
537
|
+
}
|
|
538
|
+
};
|
|
539
|
+
}, allPreferences); // Next feed the converted complementary areas back into a reducer that
|
|
540
|
+
// converts the pinned items, resulting in the fully migrated data.
|
|
541
|
+
|
|
542
|
+
const sourcePinnedItems = (_sourceEnableItems$mu = sourceEnableItems === null || sourceEnableItems === void 0 ? void 0 : (_sourceEnableItems$mu2 = sourceEnableItems.multipleEnableItems) === null || _sourceEnableItems$mu2 === void 0 ? void 0 : _sourceEnableItems$mu2.pinnedItems) !== null && _sourceEnableItems$mu !== void 0 ? _sourceEnableItems$mu : {};
|
|
543
|
+
const allConvertedData = Object.keys(sourcePinnedItems).reduce((accumulator, scope) => {
|
|
544
|
+
var _accumulator$scope2;
|
|
545
|
+
|
|
546
|
+
const data = sourcePinnedItems[scope]; // Don't overwrite any existing data in the preferences store.
|
|
547
|
+
|
|
548
|
+
if ((_accumulator$scope2 = accumulator[scope]) !== null && _accumulator$scope2 !== void 0 && _accumulator$scope2.pinnedItems) {
|
|
549
|
+
return accumulator;
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
return { ...accumulator,
|
|
553
|
+
[scope]: { ...accumulator[scope],
|
|
554
|
+
pinnedItems: data
|
|
555
|
+
}
|
|
556
|
+
};
|
|
557
|
+
}, convertedComplementaryAreas);
|
|
558
|
+
persistence.set(preferencesStoreName, {
|
|
559
|
+
preferences: allConvertedData
|
|
560
|
+
}); // Remove migrated preferences.
|
|
561
|
+
|
|
562
|
+
const otherInterfaceItems = state[interfaceStoreName];
|
|
563
|
+
persistence.set(interfaceStoreName, { ...otherInterfaceItems,
|
|
564
|
+
enableItems: undefined
|
|
565
|
+
});
|
|
566
|
+
}
|
|
383
567
|
|
|
384
568
|
persistencePlugin.__unstableMigrate = pluginOptions => {
|
|
385
569
|
const persistence = createPersistenceInterface(pluginOptions); // Boolean feature preferences.
|
|
@@ -390,10 +574,31 @@ persistencePlugin.__unstableMigrate = pluginOptions => {
|
|
|
390
574
|
migrateFeaturePreferencesToPreferencesStore(persistence, 'core/edit-site');
|
|
391
575
|
migrateThirdPartyFeaturePreferencesToPreferencesStore(persistence); // Other ad-hoc preferences.
|
|
392
576
|
|
|
393
|
-
migrateIndividualPreferenceToPreferencesStore(persistence,
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
577
|
+
migrateIndividualPreferenceToPreferencesStore(persistence, {
|
|
578
|
+
from: 'core/edit-post',
|
|
579
|
+
scope: 'core/edit-post'
|
|
580
|
+
}, 'hiddenBlockTypes');
|
|
581
|
+
migrateIndividualPreferenceToPreferencesStore(persistence, {
|
|
582
|
+
from: 'core/edit-post',
|
|
583
|
+
scope: 'core/edit-post'
|
|
584
|
+
}, 'editorMode');
|
|
585
|
+
migrateIndividualPreferenceToPreferencesStore(persistence, {
|
|
586
|
+
from: 'core/edit-post',
|
|
587
|
+
scope: 'core/edit-post'
|
|
588
|
+
}, 'preferredStyleVariations');
|
|
589
|
+
migrateIndividualPreferenceToPreferencesStore(persistence, {
|
|
590
|
+
from: 'core/edit-post',
|
|
591
|
+
scope: 'core/edit-post'
|
|
592
|
+
}, 'panels', convertEditPostPanels);
|
|
593
|
+
migrateIndividualPreferenceToPreferencesStore(persistence, {
|
|
594
|
+
from: 'core/editor',
|
|
595
|
+
scope: 'core/edit-post'
|
|
596
|
+
}, 'isPublishSidebarEnabled');
|
|
597
|
+
migrateIndividualPreferenceToPreferencesStore(persistence, {
|
|
598
|
+
from: 'core/edit-site',
|
|
599
|
+
scope: 'core/edit-site'
|
|
600
|
+
}, 'editorMode');
|
|
601
|
+
migrateInterfaceEnableItemsToPreferencesStore(persistence);
|
|
397
602
|
};
|
|
398
603
|
|
|
399
604
|
var _default = persistencePlugin;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/data/src/plugins/persistence/index.js"],"names":["DEFAULT_STORAGE","defaultStorage","DEFAULT_STORAGE_KEY","withLazySameState","reducer","state","action","nextState","createPersistenceInterface","options","storage","storageKey","data","getData","undefined","persisted","getItem","JSON","parse","error","setData","key","value","setItem","stringify","get","set","persistencePlugin","registry","pluginOptions","persistence","createPersistOnChange","getState","storeName","keys","getPersistedState","Array","isArray","reducers","reduce","accumulator","Object","assign","lastState","registerStore","persist","persistedState","initialState","type","store","subscribe","migrateFeaturePreferencesToPreferencesStore","sourceStoreName","preferencesStoreName","interfaceStoreName","interfaceFeatures","preferences","features","sourceFeatures","featuresToMigrate","existingPreferences","otherInterfaceState","otherInterfaceScopes","otherSourceState","sourcePreferences","migrateIndividualPreferenceToPreferencesStore","sourcePreference","targetPreference","allPreferences","targetPreferences","allSourcePreferences","migrateThirdPartyFeaturePreferencesToPreferencesStore","interfaceScopes","scope","startsWith","__unstableMigrate"],"mappings":";;;;;;;;;;;;;;AAGA;;AAKA;;AACA;;AATA;AACA;AACA;;AAGA;AACA;AACA;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4C,CAA7C;AAKAmC,EAAAA,6CAA6C,CAC5CnC,WAD4C,EAE5C,gBAF4C,EAG5C,YAH4C,CAA7C;AAKA,CA3CD;;eA6CeH,iB","sourcesContent":["/**\n * External dependencies\n */\nimport { merge, isPlainObject } from 'lodash';\n\n/**\n * Internal dependencies\n */\nimport defaultStorage from './storage/default';\nimport { combineReducers } from '../../';\n\n/** @typedef {import('../../registry').WPDataRegistry} WPDataRegistry */\n\n/** @typedef {import('../../registry').WPDataPlugin} WPDataPlugin */\n\n/**\n * @typedef {Object} WPDataPersistencePluginOptions Persistence plugin options.\n *\n * @property {Storage} storage Persistent storage implementation. This must\n * at least implement `getItem` and `setItem` of\n * the Web Storage API.\n * @property {string} storageKey Key on which to set in persistent storage.\n *\n */\n\n/**\n * Default plugin storage.\n *\n * @type {Storage}\n */\nconst DEFAULT_STORAGE = defaultStorage;\n\n/**\n * Default plugin storage key.\n *\n * @type {string}\n */\nconst DEFAULT_STORAGE_KEY = 'WP_DATA';\n\n/**\n * Higher-order reducer which invokes the original reducer only if state is\n * inequal from that of the action's `nextState` property, otherwise returning\n * the original state reference.\n *\n * @param {Function} reducer Original reducer.\n *\n * @return {Function} Enhanced reducer.\n */\nexport const withLazySameState = ( reducer ) => ( state, action ) => {\n\tif ( action.nextState === state ) {\n\t\treturn state;\n\t}\n\n\treturn reducer( state, action );\n};\n\n/**\n * Creates a persistence interface, exposing getter and setter methods (`get`\n * and `set` respectively).\n *\n * @param {WPDataPersistencePluginOptions} options Plugin options.\n *\n * @return {Object} Persistence interface.\n */\nexport function createPersistenceInterface( options ) {\n\tconst {\n\t\tstorage = DEFAULT_STORAGE,\n\t\tstorageKey = DEFAULT_STORAGE_KEY,\n\t} = options;\n\n\tlet data;\n\n\t/**\n\t * Returns the persisted data as an object, defaulting to an empty object.\n\t *\n\t * @return {Object} Persisted data.\n\t */\n\tfunction getData() {\n\t\tif ( data === undefined ) {\n\t\t\t// If unset, getItem is expected to return null. Fall back to\n\t\t\t// empty object.\n\t\t\tconst persisted = storage.getItem( storageKey );\n\t\t\tif ( persisted === null ) {\n\t\t\t\tdata = {};\n\t\t\t} else {\n\t\t\t\ttry {\n\t\t\t\t\tdata = JSON.parse( persisted );\n\t\t\t\t} catch ( error ) {\n\t\t\t\t\t// Similarly, should any error be thrown during parse of\n\t\t\t\t\t// the string (malformed JSON), fall back to empty object.\n\t\t\t\t\tdata = {};\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn data;\n\t}\n\n\t/**\n\t * Merges an updated reducer state into the persisted data.\n\t *\n\t * @param {string} key Key to update.\n\t * @param {*} value Updated value.\n\t */\n\tfunction setData( key, value ) {\n\t\tdata = { ...data, [ key ]: value };\n\t\tstorage.setItem( storageKey, JSON.stringify( data ) );\n\t}\n\n\treturn {\n\t\tget: getData,\n\t\tset: setData,\n\t};\n}\n\n/**\n * Data plugin to persist store state into a single storage key.\n *\n * @param {WPDataRegistry} registry Data registry.\n * @param {?WPDataPersistencePluginOptions} pluginOptions Plugin options.\n *\n * @return {WPDataPlugin} Data plugin.\n */\nfunction persistencePlugin( registry, pluginOptions ) {\n\tconst persistence = createPersistenceInterface( pluginOptions );\n\n\t/**\n\t * Creates an enhanced store dispatch function, triggering the state of the\n\t * given store name to be persisted when changed.\n\t *\n\t * @param {Function} getState Function which returns current state.\n\t * @param {string} storeName Store name.\n\t * @param {?Array<string>} keys Optional subset of keys to save.\n\t *\n\t * @return {Function} Enhanced dispatch function.\n\t */\n\tfunction createPersistOnChange( getState, storeName, keys ) {\n\t\tlet getPersistedState;\n\t\tif ( Array.isArray( keys ) ) {\n\t\t\t// Given keys, the persisted state should by produced as an object\n\t\t\t// of the subset of keys. This implementation uses combineReducers\n\t\t\t// to leverage its behavior of returning the same object when none\n\t\t\t// of the property values changes. This allows a strict reference\n\t\t\t// equality to bypass a persistence set on an unchanging state.\n\t\t\tconst reducers = keys.reduce(\n\t\t\t\t( accumulator, key ) =>\n\t\t\t\t\tObject.assign( accumulator, {\n\t\t\t\t\t\t[ key ]: ( state, action ) => action.nextState[ key ],\n\t\t\t\t\t} ),\n\t\t\t\t{}\n\t\t\t);\n\n\t\t\tgetPersistedState = withLazySameState(\n\t\t\t\tcombineReducers( reducers )\n\t\t\t);\n\t\t} else {\n\t\t\tgetPersistedState = ( state, action ) => action.nextState;\n\t\t}\n\n\t\tlet lastState = getPersistedState( undefined, {\n\t\t\tnextState: getState(),\n\t\t} );\n\n\t\treturn () => {\n\t\t\tconst state = getPersistedState( lastState, {\n\t\t\t\tnextState: getState(),\n\t\t\t} );\n\t\t\tif ( state !== lastState ) {\n\t\t\t\tpersistence.set( storeName, state );\n\t\t\t\tlastState = state;\n\t\t\t}\n\t\t};\n\t}\n\n\treturn {\n\t\tregisterStore( storeName, options ) {\n\t\t\tif ( ! options.persist ) {\n\t\t\t\treturn registry.registerStore( storeName, options );\n\t\t\t}\n\n\t\t\t// Load from persistence to use as initial state.\n\t\t\tconst persistedState = persistence.get()[ storeName ];\n\t\t\tif ( persistedState !== undefined ) {\n\t\t\t\tlet initialState = options.reducer( options.initialState, {\n\t\t\t\t\ttype: '@@WP/PERSISTENCE_RESTORE',\n\t\t\t\t} );\n\n\t\t\t\tif (\n\t\t\t\t\tisPlainObject( initialState ) &&\n\t\t\t\t\tisPlainObject( persistedState )\n\t\t\t\t) {\n\t\t\t\t\t// If state is an object, ensure that:\n\t\t\t\t\t// - Other keys are left intact when persisting only a\n\t\t\t\t\t// subset of keys.\n\t\t\t\t\t// - New keys in what would otherwise be used as initial\n\t\t\t\t\t// state are deeply merged as base for persisted value.\n\t\t\t\t\tinitialState = merge( {}, initialState, persistedState );\n\t\t\t\t} else {\n\t\t\t\t\t// If there is a mismatch in object-likeness of default\n\t\t\t\t\t// initial or persisted state, defer to persisted value.\n\t\t\t\t\tinitialState = persistedState;\n\t\t\t\t}\n\n\t\t\t\toptions = {\n\t\t\t\t\t...options,\n\t\t\t\t\tinitialState,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst store = registry.registerStore( storeName, options );\n\n\t\t\tstore.subscribe(\n\t\t\t\tcreatePersistOnChange(\n\t\t\t\t\tstore.getState,\n\t\t\t\t\tstoreName,\n\t\t\t\t\toptions.persist\n\t\t\t\t)\n\t\t\t);\n\n\t\t\treturn store;\n\t\t},\n\t};\n}\n\n/**\n * Move the 'features' object in local storage from the sourceStoreName to the\n * preferences store.\n *\n * @param {Object} persistence The persistence interface.\n * @param {string} sourceStoreName The name of the store that has persisted\n * preferences to migrate to the preferences\n * package.\n */\nexport function migrateFeaturePreferencesToPreferencesStore(\n\tpersistence,\n\tsourceStoreName\n) {\n\tconst preferencesStoreName = 'core/preferences';\n\tconst interfaceStoreName = 'core/interface';\n\n\tconst state = persistence.get();\n\n\t// Features most recently (and briefly) lived in the interface package.\n\t// If data exists there, prioritize using that for the migration. If not\n\t// also check the original package as the user may have updated from an\n\t// older block editor version.\n\tconst interfaceFeatures =\n\t\tstate[ interfaceStoreName ]?.preferences?.features?.[ sourceStoreName ];\n\tconst sourceFeatures = state[ sourceStoreName ]?.preferences?.features;\n\tconst featuresToMigrate = interfaceFeatures\n\t\t? interfaceFeatures\n\t\t: sourceFeatures;\n\n\tif ( featuresToMigrate ) {\n\t\tconst existingPreferences = state[ preferencesStoreName ]?.preferences;\n\n\t\t// Avoid migrating features again if they've previously been migrated.\n\t\tif ( ! existingPreferences?.[ sourceStoreName ] ) {\n\t\t\t// Set the feature values in the interface store, the features\n\t\t\t// object is keyed by 'scope', which matches the store name for\n\t\t\t// the source.\n\t\t\tpersistence.set( preferencesStoreName, {\n\t\t\t\tpreferences: {\n\t\t\t\t\t...existingPreferences,\n\t\t\t\t\t[ sourceStoreName ]: featuresToMigrate,\n\t\t\t\t},\n\t\t\t} );\n\n\t\t\t// Remove migrated feature preferences from `interface`.\n\t\t\tif ( interfaceFeatures ) {\n\t\t\t\tconst otherInterfaceState = state[ interfaceStoreName ];\n\t\t\t\tconst otherInterfaceScopes =\n\t\t\t\t\tstate[ interfaceStoreName ]?.preferences?.features;\n\n\t\t\t\tpersistence.set( interfaceStoreName, {\n\t\t\t\t\t...otherInterfaceState,\n\t\t\t\t\tpreferences: {\n\t\t\t\t\t\tfeatures: {\n\t\t\t\t\t\t\t...otherInterfaceScopes,\n\t\t\t\t\t\t\t[ sourceStoreName ]: undefined,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\t// Remove migrated feature preferences from the source.\n\t\t\tif ( sourceFeatures ) {\n\t\t\t\tconst otherSourceState = state[ sourceStoreName ];\n\t\t\t\tconst sourcePreferences = state[ sourceStoreName ]?.preferences;\n\n\t\t\t\tpersistence.set( sourceStoreName, {\n\t\t\t\t\t...otherSourceState,\n\t\t\t\t\tpreferences: {\n\t\t\t\t\t\t...sourcePreferences,\n\t\t\t\t\t\tfeatures: undefined,\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport function migrateIndividualPreferenceToPreferencesStore(\n\tpersistence,\n\tsourceStoreName,\n\tkey\n) {\n\tconst preferencesStoreName = 'core/preferences';\n\tconst state = persistence.get();\n\tconst sourcePreference = state[ sourceStoreName ]?.preferences?.[ key ];\n\n\t// There's nothing to migrate, exit early.\n\tif ( ! sourcePreference ) {\n\t\treturn;\n\t}\n\n\tconst targetPreference =\n\t\tstate[ preferencesStoreName ]?.preferences?.[ sourceStoreName ]?.[\n\t\t\tkey\n\t\t];\n\n\t// There's existing data at the target, so don't overwrite it, exit early.\n\tif ( targetPreference ) {\n\t\treturn;\n\t}\n\n\tconst allPreferences = state[ preferencesStoreName ]?.preferences;\n\tconst targetPreferences =\n\t\tstate[ preferencesStoreName ]?.preferences?.[ sourceStoreName ];\n\n\tpersistence.set( preferencesStoreName, {\n\t\tpreferences: {\n\t\t\t...allPreferences,\n\t\t\t[ sourceStoreName ]: {\n\t\t\t\t...targetPreferences,\n\t\t\t\t[ key ]: sourcePreference,\n\t\t\t},\n\t\t},\n\t} );\n\n\t// Remove migrated feature preferences from the source.\n\tconst otherSourceState = state[ sourceStoreName ];\n\tconst allSourcePreferences = state[ sourceStoreName ]?.preferences;\n\tpersistence.set( sourceStoreName, {\n\t\t...otherSourceState,\n\t\tpreferences: {\n\t\t\t...allSourcePreferences,\n\t\t\t[ key ]: undefined,\n\t\t},\n\t} );\n}\n\nexport function migrateThirdPartyFeaturePreferencesToPreferencesStore(\n\tpersistence\n) {\n\tconst interfaceStoreName = 'core/interface';\n\tconst preferencesStoreName = 'core/preferences';\n\n\tlet state = persistence.get();\n\n\tconst interfaceScopes = state[ interfaceStoreName ]?.preferences?.features;\n\n\tfor ( const scope in interfaceScopes ) {\n\t\t// Don't migrate any core 'scopes'.\n\t\tif ( scope.startsWith( 'core' ) ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// Skip this scope if there are no features to migrates\n\t\tconst featuresToMigrate = interfaceScopes[ scope ];\n\t\tif ( ! featuresToMigrate ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst existingPreferences = state[ preferencesStoreName ]?.preferences;\n\n\t\t// Add the data to the preferences store structure.\n\t\tpersistence.set( preferencesStoreName, {\n\t\t\tpreferences: {\n\t\t\t\t...existingPreferences,\n\t\t\t\t[ scope ]: featuresToMigrate,\n\t\t\t},\n\t\t} );\n\n\t\t// Remove the data from the interface store structure.\n\t\t// Call `persistence.get` again to make sure `state` is up-to-date with\n\t\t// any changes from the previous iteration of this loop.\n\t\tstate = persistence.get();\n\t\tconst otherInterfaceState = state[ interfaceStoreName ];\n\t\tconst otherInterfaceScopes =\n\t\t\tstate[ interfaceStoreName ]?.preferences?.features;\n\n\t\tpersistence.set( interfaceStoreName, {\n\t\t\t...otherInterfaceState,\n\t\t\tpreferences: {\n\t\t\t\tfeatures: {\n\t\t\t\t\t...otherInterfaceScopes,\n\t\t\t\t\t[ scope ]: undefined,\n\t\t\t\t},\n\t\t\t},\n\t\t} );\n\t}\n}\n\npersistencePlugin.__unstableMigrate = ( pluginOptions ) => {\n\tconst persistence = createPersistenceInterface( pluginOptions );\n\n\t// Boolean feature preferences.\n\tmigrateFeaturePreferencesToPreferencesStore(\n\t\tpersistence,\n\t\t'core/edit-widgets'\n\t);\n\tmigrateFeaturePreferencesToPreferencesStore(\n\t\tpersistence,\n\t\t'core/customize-widgets'\n\t);\n\tmigrateFeaturePreferencesToPreferencesStore(\n\t\tpersistence,\n\t\t'core/edit-post'\n\t);\n\tmigrateFeaturePreferencesToPreferencesStore(\n\t\tpersistence,\n\t\t'core/edit-site'\n\t);\n\tmigrateThirdPartyFeaturePreferencesToPreferencesStore( persistence );\n\n\t// Other ad-hoc preferences.\n\tmigrateIndividualPreferenceToPreferencesStore(\n\t\tpersistence,\n\t\t'core/edit-post',\n\t\t'hiddenBlockTypes'\n\t);\n\tmigrateIndividualPreferenceToPreferencesStore(\n\t\tpersistence,\n\t\t'core/edit-post',\n\t\t'editorMode'\n\t);\n\tmigrateIndividualPreferenceToPreferencesStore(\n\t\tpersistence,\n\t\t'core/edit-post',\n\t\t'preferredStyleVariations'\n\t);\n\tmigrateIndividualPreferenceToPreferencesStore(\n\t\tpersistence,\n\t\t'core/edit-site',\n\t\t'editorMode'\n\t);\n};\n\nexport default persistencePlugin;\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/data/src/plugins/persistence/index.js"],"names":["DEFAULT_STORAGE","defaultStorage","DEFAULT_STORAGE_KEY","withLazySameState","reducer","state","action","nextState","createPersistenceInterface","options","storage","storageKey","data","getData","undefined","persisted","getItem","JSON","parse","error","setData","key","value","setItem","stringify","get","set","persistencePlugin","registry","pluginOptions","persistence","createPersistOnChange","getState","storeName","keys","getPersistedState","Array","isArray","reducers","reduce","accumulator","Object","assign","lastState","registerStore","persist","persistedState","initialState","type","store","subscribe","migrateFeaturePreferencesToPreferencesStore","sourceStoreName","preferencesStoreName","interfaceStoreName","interfaceFeatures","preferences","features","sourceFeatures","featuresToMigrate","existingPreferences","otherInterfaceState","otherInterfaceScopes","otherSourceState","sourcePreferences","migrateIndividualPreferenceToPreferencesStore","from","scope","convert","identity","sourcePreference","targetPreference","otherScopes","otherPreferences","convertedPreferences","allSourcePreferences","convertEditPostPanels","panels","convertedData","panelName","panel","enabled","inactivePanels","push","opened","openPanels","migrateThirdPartyFeaturePreferencesToPreferencesStore","interfaceScopes","startsWith","migrateInterfaceEnableItemsToPreferencesStore","sourceEnableItems","enableItems","allPreferences","sourceComplementaryAreas","singleEnableItems","complementaryArea","convertedComplementaryAreas","sourcePinnedItems","multipleEnableItems","pinnedItems","allConvertedData","otherInterfaceItems","__unstableMigrate"],"mappings":";;;;;;;;;;;;;;;;AAGA;;AAKA;;AACA;;AATA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,MAAMA,eAAe,GAAGC,iBAAxB;AAEA;AACA;AACA;AACA;AACA;;AACA,MAAMC,mBAAmB,GAAG,SAA5B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACO,MAAMC,iBAAiB,GAAKC,OAAF,IAAe,CAAEC,KAAF,EAASC,MAAT,KAAqB;AACpE,MAAKA,MAAM,CAACC,SAAP,KAAqBF,KAA1B,EAAkC;AACjC,WAAOA,KAAP;AACA;;AAED,SAAOD,OAAO,CAAEC,KAAF,EAASC,MAAT,CAAd;AACA,CANM;AAQP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AACO,SAASE,0BAAT,CAAqCC,OAArC,EAA+C;AACrD,QAAM;AACLC,IAAAA,OAAO,GAAGV,eADL;AAELW,IAAAA,UAAU,GAAGT;AAFR,MAGFO,OAHJ;AAKA,MAAIG,IAAJ;AAEA;AACD;AACA;AACA;AACA;;AACC,WAASC,OAAT,GAAmB;AAClB,QAAKD,IAAI,KAAKE,SAAd,EAA0B;AACzB;AACA;AACA,YAAMC,SAAS,GAAGL,OAAO,CAACM,OAAR,CAAiBL,UAAjB,CAAlB;;AACA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;AAAjC,GAF4C,EAG5C,kBAH4C,CAA7C;AAKAF,EAAAA,6CAA6C,CAC5CnC,WAD4C,EAE5C;AAAEoC,IAAAA,IAAI,EAAE,gBAAR;AAA0BC,IAAAA,KAAK,EAAE;AAAjC,GAF4C,EAG5C,YAH4C,CAA7C;AAKAF,EAAAA,6CAA6C,CAC5CnC,WAD4C,EAE5C;AAAEoC,IAAAA,IAAI,EAAE,gBAAR;AAA0BC,IAAAA,KAAK,EAAE;AAAjC,GAF4C,EAG5C,0BAH4C,CAA7C;AAKAF,EAAAA,6CAA6C,CAC5CnC,WAD4C,EAE5C;AAAEoC,IAAAA,IAAI,EAAE,gBAAR;AAA0BC,IAAAA,KAAK,EAAE;AAAjC,GAF4C,EAG5C,QAH4C,EAI5CS,qBAJ4C,CAA7C;AAMAX,EAAAA,6CAA6C,CAC5CnC,WAD4C,EAE5C;AAAEoC,IAAAA,IAAI,EAAE,aAAR;AAAuBC,IAAAA,KAAK,EAAE;AAA9B,GAF4C,EAG5C,yBAH4C,CAA7C;AAKAF,EAAAA,6CAA6C,CAC5CnC,WAD4C,EAE5C;AAAEoC,IAAAA,IAAI,EAAE,gBAAR;AAA0BC,IAAAA,KAAK,EAAE;AAAjC,GAF4C,EAG5C,YAH4C,CAA7C;AAKAsB,EAAAA,6CAA6C,CAAE3D,WAAF,CAA7C;AACA,CAvDD;;eAyDeH,iB","sourcesContent":["/**\n * External dependencies\n */\nimport { merge, isPlainObject, identity } from 'lodash';\n\n/**\n * Internal dependencies\n */\nimport defaultStorage from './storage/default';\nimport { combineReducers } from '../../';\n\n/** @typedef {import('../../registry').WPDataRegistry} WPDataRegistry */\n\n/** @typedef {import('../../registry').WPDataPlugin} WPDataPlugin */\n\n/**\n * @typedef {Object} WPDataPersistencePluginOptions Persistence plugin options.\n *\n * @property {Storage} storage Persistent storage implementation. This must\n * at least implement `getItem` and `setItem` of\n * the Web Storage API.\n * @property {string} storageKey Key on which to set in persistent storage.\n *\n */\n\n/**\n * Default plugin storage.\n *\n * @type {Storage}\n */\nconst DEFAULT_STORAGE = defaultStorage;\n\n/**\n * Default plugin storage key.\n *\n * @type {string}\n */\nconst DEFAULT_STORAGE_KEY = 'WP_DATA';\n\n/**\n * Higher-order reducer which invokes the original reducer only if state is\n * inequal from that of the action's `nextState` property, otherwise returning\n * the original state reference.\n *\n * @param {Function} reducer Original reducer.\n *\n * @return {Function} Enhanced reducer.\n */\nexport const withLazySameState = ( reducer ) => ( state, action ) => {\n\tif ( action.nextState === state ) {\n\t\treturn state;\n\t}\n\n\treturn reducer( state, action );\n};\n\n/**\n * Creates a persistence interface, exposing getter and setter methods (`get`\n * and `set` respectively).\n *\n * @param {WPDataPersistencePluginOptions} options Plugin options.\n *\n * @return {Object} Persistence interface.\n */\nexport function createPersistenceInterface( options ) {\n\tconst {\n\t\tstorage = DEFAULT_STORAGE,\n\t\tstorageKey = DEFAULT_STORAGE_KEY,\n\t} = options;\n\n\tlet data;\n\n\t/**\n\t * Returns the persisted data as an object, defaulting to an empty object.\n\t *\n\t * @return {Object} Persisted data.\n\t */\n\tfunction getData() {\n\t\tif ( data === undefined ) {\n\t\t\t// If unset, getItem is expected to return null. Fall back to\n\t\t\t// empty object.\n\t\t\tconst persisted = storage.getItem( storageKey );\n\t\t\tif ( persisted === null ) {\n\t\t\t\tdata = {};\n\t\t\t} else {\n\t\t\t\ttry {\n\t\t\t\t\tdata = JSON.parse( persisted );\n\t\t\t\t} catch ( error ) {\n\t\t\t\t\t// Similarly, should any error be thrown during parse of\n\t\t\t\t\t// the string (malformed JSON), fall back to empty object.\n\t\t\t\t\tdata = {};\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn data;\n\t}\n\n\t/**\n\t * Merges an updated reducer state into the persisted data.\n\t *\n\t * @param {string} key Key to update.\n\t * @param {*} value Updated value.\n\t */\n\tfunction setData( key, value ) {\n\t\tdata = { ...data, [ key ]: value };\n\t\tstorage.setItem( storageKey, JSON.stringify( data ) );\n\t}\n\n\treturn {\n\t\tget: getData,\n\t\tset: setData,\n\t};\n}\n\n/**\n * Data plugin to persist store state into a single storage key.\n *\n * @param {WPDataRegistry} registry Data registry.\n * @param {?WPDataPersistencePluginOptions} pluginOptions Plugin options.\n *\n * @return {WPDataPlugin} Data plugin.\n */\nfunction persistencePlugin( registry, pluginOptions ) {\n\tconst persistence = createPersistenceInterface( pluginOptions );\n\n\t/**\n\t * Creates an enhanced store dispatch function, triggering the state of the\n\t * given store name to be persisted when changed.\n\t *\n\t * @param {Function} getState Function which returns current state.\n\t * @param {string} storeName Store name.\n\t * @param {?Array<string>} keys Optional subset of keys to save.\n\t *\n\t * @return {Function} Enhanced dispatch function.\n\t */\n\tfunction createPersistOnChange( getState, storeName, keys ) {\n\t\tlet getPersistedState;\n\t\tif ( Array.isArray( keys ) ) {\n\t\t\t// Given keys, the persisted state should by produced as an object\n\t\t\t// of the subset of keys. This implementation uses combineReducers\n\t\t\t// to leverage its behavior of returning the same object when none\n\t\t\t// of the property values changes. This allows a strict reference\n\t\t\t// equality to bypass a persistence set on an unchanging state.\n\t\t\tconst reducers = keys.reduce(\n\t\t\t\t( accumulator, key ) =>\n\t\t\t\t\tObject.assign( accumulator, {\n\t\t\t\t\t\t[ key ]: ( state, action ) => action.nextState[ key ],\n\t\t\t\t\t} ),\n\t\t\t\t{}\n\t\t\t);\n\n\t\t\tgetPersistedState = withLazySameState(\n\t\t\t\tcombineReducers( reducers )\n\t\t\t);\n\t\t} else {\n\t\t\tgetPersistedState = ( state, action ) => action.nextState;\n\t\t}\n\n\t\tlet lastState = getPersistedState( undefined, {\n\t\t\tnextState: getState(),\n\t\t} );\n\n\t\treturn () => {\n\t\t\tconst state = getPersistedState( lastState, {\n\t\t\t\tnextState: getState(),\n\t\t\t} );\n\t\t\tif ( state !== lastState ) {\n\t\t\t\tpersistence.set( storeName, state );\n\t\t\t\tlastState = state;\n\t\t\t}\n\t\t};\n\t}\n\n\treturn {\n\t\tregisterStore( storeName, options ) {\n\t\t\tif ( ! options.persist ) {\n\t\t\t\treturn registry.registerStore( storeName, options );\n\t\t\t}\n\n\t\t\t// Load from persistence to use as initial state.\n\t\t\tconst persistedState = persistence.get()[ storeName ];\n\t\t\tif ( persistedState !== undefined ) {\n\t\t\t\tlet initialState = options.reducer( options.initialState, {\n\t\t\t\t\ttype: '@@WP/PERSISTENCE_RESTORE',\n\t\t\t\t} );\n\n\t\t\t\tif (\n\t\t\t\t\tisPlainObject( initialState ) &&\n\t\t\t\t\tisPlainObject( persistedState )\n\t\t\t\t) {\n\t\t\t\t\t// If state is an object, ensure that:\n\t\t\t\t\t// - Other keys are left intact when persisting only a\n\t\t\t\t\t// subset of keys.\n\t\t\t\t\t// - New keys in what would otherwise be used as initial\n\t\t\t\t\t// state are deeply merged as base for persisted value.\n\t\t\t\t\tinitialState = merge( {}, initialState, persistedState );\n\t\t\t\t} else {\n\t\t\t\t\t// If there is a mismatch in object-likeness of default\n\t\t\t\t\t// initial or persisted state, defer to persisted value.\n\t\t\t\t\tinitialState = persistedState;\n\t\t\t\t}\n\n\t\t\t\toptions = {\n\t\t\t\t\t...options,\n\t\t\t\t\tinitialState,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst store = registry.registerStore( storeName, options );\n\n\t\t\tstore.subscribe(\n\t\t\t\tcreatePersistOnChange(\n\t\t\t\t\tstore.getState,\n\t\t\t\t\tstoreName,\n\t\t\t\t\toptions.persist\n\t\t\t\t)\n\t\t\t);\n\n\t\t\treturn store;\n\t\t},\n\t};\n}\n\n/**\n * Move the 'features' object in local storage from the sourceStoreName to the\n * preferences store.\n *\n * @param {Object} persistence The persistence interface.\n * @param {string} sourceStoreName The name of the store that has persisted\n * preferences to migrate to the preferences\n * package.\n */\nexport function migrateFeaturePreferencesToPreferencesStore(\n\tpersistence,\n\tsourceStoreName\n) {\n\tconst preferencesStoreName = 'core/preferences';\n\tconst interfaceStoreName = 'core/interface';\n\n\tconst state = persistence.get();\n\n\t// Features most recently (and briefly) lived in the interface package.\n\t// If data exists there, prioritize using that for the migration. If not\n\t// also check the original package as the user may have updated from an\n\t// older block editor version.\n\tconst interfaceFeatures =\n\t\tstate[ interfaceStoreName ]?.preferences?.features?.[ sourceStoreName ];\n\tconst sourceFeatures = state[ sourceStoreName ]?.preferences?.features;\n\tconst featuresToMigrate = interfaceFeatures\n\t\t? interfaceFeatures\n\t\t: sourceFeatures;\n\n\tif ( featuresToMigrate ) {\n\t\tconst existingPreferences = state[ preferencesStoreName ]?.preferences;\n\n\t\t// Avoid migrating features again if they've previously been migrated.\n\t\tif ( ! existingPreferences?.[ sourceStoreName ] ) {\n\t\t\t// Set the feature values in the interface store, the features\n\t\t\t// object is keyed by 'scope', which matches the store name for\n\t\t\t// the source.\n\t\t\tpersistence.set( preferencesStoreName, {\n\t\t\t\tpreferences: {\n\t\t\t\t\t...existingPreferences,\n\t\t\t\t\t[ sourceStoreName ]: featuresToMigrate,\n\t\t\t\t},\n\t\t\t} );\n\n\t\t\t// Remove migrated feature preferences from `interface`.\n\t\t\tif ( interfaceFeatures ) {\n\t\t\t\tconst otherInterfaceState = state[ interfaceStoreName ];\n\t\t\t\tconst otherInterfaceScopes =\n\t\t\t\t\tstate[ interfaceStoreName ]?.preferences?.features;\n\n\t\t\t\tpersistence.set( interfaceStoreName, {\n\t\t\t\t\t...otherInterfaceState,\n\t\t\t\t\tpreferences: {\n\t\t\t\t\t\tfeatures: {\n\t\t\t\t\t\t\t...otherInterfaceScopes,\n\t\t\t\t\t\t\t[ sourceStoreName ]: undefined,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\t// Remove migrated feature preferences from the source.\n\t\t\tif ( sourceFeatures ) {\n\t\t\t\tconst otherSourceState = state[ sourceStoreName ];\n\t\t\t\tconst sourcePreferences = state[ sourceStoreName ]?.preferences;\n\n\t\t\t\tpersistence.set( sourceStoreName, {\n\t\t\t\t\t...otherSourceState,\n\t\t\t\t\tpreferences: {\n\t\t\t\t\t\t...sourcePreferences,\n\t\t\t\t\t\tfeatures: undefined,\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Migrates an individual item inside the `preferences` object for a store.\n *\n * @param {Object} persistence The persistence interface.\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.scope 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 function migrateIndividualPreferenceToPreferencesStore(\n\tpersistence,\n\t{ from: sourceStoreName, scope },\n\tkey,\n\tconvert = identity\n) {\n\tconst preferencesStoreName = 'core/preferences';\n\tconst state = persistence.get();\n\tconst sourcePreference = state[ sourceStoreName ]?.preferences?.[ key ];\n\n\t// There's nothing to migrate, exit early.\n\tif ( sourcePreference === undefined ) {\n\t\treturn;\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;\n\t}\n\n\tconst otherScopes = state[ preferencesStoreName ]?.preferences;\n\tconst otherPreferences =\n\t\tstate[ preferencesStoreName ]?.preferences?.[ scope ];\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\tpersistence.set( preferencesStoreName, {\n\t\tpreferences: {\n\t\t\t...otherScopes,\n\t\t\t[ scope ]: {\n\t\t\t\t...otherPreferences,\n\t\t\t\t...convertedPreferences,\n\t\t\t},\n\t\t},\n\t} );\n\n\t// Remove migrated feature preferences from the source.\n\tconst otherSourceState = state[ sourceStoreName ];\n\tconst allSourcePreferences = state[ sourceStoreName ]?.preferences;\n\tpersistence.set( sourceStoreName, {\n\t\t...otherSourceState,\n\t\tpreferences: {\n\t\t\t...allSourcePreferences,\n\t\t\t[ key ]: undefined,\n\t\t},\n\t} );\n}\n\n/**\n * Convert from:\n * ```\n * {\n * panels: {\n * tags: {\n * enabled: true,\n * opened: true,\n * },\n * permalinks: {\n * enabled: false,\n * opened: false,\n * },\n * },\n * }\n * ```\n *\n * to:\n * {\n * inactivePanels: [\n * 'permalinks',\n * ],\n * openPanels: [\n * 'tags',\n * ],\n * }\n *\n * @param {Object} preferences A preferences object.\n *\n * @return {Object} The converted data.\n */\nexport function convertEditPostPanels( preferences ) {\n\tconst panels = preferences?.panels ?? {};\n\treturn Object.keys( panels ).reduce(\n\t\t( convertedData, panelName ) => {\n\t\t\tconst panel = panels[ panelName ];\n\n\t\t\tif ( panel?.enabled === false ) {\n\t\t\t\tconvertedData.inactivePanels.push( panelName );\n\t\t\t}\n\n\t\t\tif ( panel?.opened === true ) {\n\t\t\t\tconvertedData.openPanels.push( panelName );\n\t\t\t}\n\n\t\t\treturn convertedData;\n\t\t},\n\t\t{ inactivePanels: [], openPanels: [] }\n\t);\n}\n\nexport function migrateThirdPartyFeaturePreferencesToPreferencesStore(\n\tpersistence\n) {\n\tconst interfaceStoreName = 'core/interface';\n\tconst preferencesStoreName = 'core/preferences';\n\n\tlet state = persistence.get();\n\n\tconst interfaceScopes = state[ interfaceStoreName ]?.preferences?.features;\n\n\tfor ( const scope in interfaceScopes ) {\n\t\t// Don't migrate any core 'scopes'.\n\t\tif ( scope.startsWith( 'core' ) ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// Skip this scope if there are no features to migrate.\n\t\tconst featuresToMigrate = interfaceScopes[ scope ];\n\t\tif ( ! featuresToMigrate ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst existingPreferences = state[ preferencesStoreName ]?.preferences;\n\n\t\t// Add the data to the preferences store structure.\n\t\tpersistence.set( preferencesStoreName, {\n\t\t\tpreferences: {\n\t\t\t\t...existingPreferences,\n\t\t\t\t[ scope ]: featuresToMigrate,\n\t\t\t},\n\t\t} );\n\n\t\t// Remove the data from the interface store structure.\n\t\t// Call `persistence.get` again to make sure `state` is up-to-date with\n\t\t// any changes from the previous iteration of this loop.\n\t\tstate = persistence.get();\n\t\tconst otherInterfaceState = state[ interfaceStoreName ];\n\t\tconst otherInterfaceScopes =\n\t\t\tstate[ interfaceStoreName ]?.preferences?.features;\n\n\t\tpersistence.set( interfaceStoreName, {\n\t\t\t...otherInterfaceState,\n\t\t\tpreferences: {\n\t\t\t\tfeatures: {\n\t\t\t\t\t...otherInterfaceScopes,\n\t\t\t\t\t[ scope ]: undefined,\n\t\t\t\t},\n\t\t\t},\n\t\t} );\n\t}\n}\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 * and it should be migrated 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} persistence The persistence interface.\n */\nexport function migrateInterfaceEnableItemsToPreferencesStore( persistence ) {\n\tconst interfaceStoreName = 'core/interface';\n\tconst preferencesStoreName = 'core/preferences';\n\tconst state = persistence.get();\n\tconst sourceEnableItems = state[ interfaceStoreName ]?.enableItems;\n\n\t// There's nothing to migrate, exit early.\n\tif ( ! sourceEnableItems ) {\n\t\treturn;\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 convertedComplementaryAreas = 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\tconvertedComplementaryAreas\n\t);\n\n\tpersistence.set( preferencesStoreName, {\n\t\tpreferences: allConvertedData,\n\t} );\n\n\t// Remove migrated preferences.\n\tconst otherInterfaceItems = state[ interfaceStoreName ];\n\tpersistence.set( interfaceStoreName, {\n\t\t...otherInterfaceItems,\n\t\tenableItems: undefined,\n\t} );\n}\n\npersistencePlugin.__unstableMigrate = ( pluginOptions ) => {\n\tconst persistence = createPersistenceInterface( pluginOptions );\n\n\t// Boolean feature preferences.\n\tmigrateFeaturePreferencesToPreferencesStore(\n\t\tpersistence,\n\t\t'core/edit-widgets'\n\t);\n\tmigrateFeaturePreferencesToPreferencesStore(\n\t\tpersistence,\n\t\t'core/customize-widgets'\n\t);\n\tmigrateFeaturePreferencesToPreferencesStore(\n\t\tpersistence,\n\t\t'core/edit-post'\n\t);\n\tmigrateFeaturePreferencesToPreferencesStore(\n\t\tpersistence,\n\t\t'core/edit-site'\n\t);\n\tmigrateThirdPartyFeaturePreferencesToPreferencesStore( persistence );\n\n\t// Other ad-hoc preferences.\n\tmigrateIndividualPreferenceToPreferencesStore(\n\t\tpersistence,\n\t\t{ from: 'core/edit-post', scope: 'core/edit-post' },\n\t\t'hiddenBlockTypes'\n\t);\n\tmigrateIndividualPreferenceToPreferencesStore(\n\t\tpersistence,\n\t\t{ from: 'core/edit-post', scope: 'core/edit-post' },\n\t\t'editorMode'\n\t);\n\tmigrateIndividualPreferenceToPreferencesStore(\n\t\tpersistence,\n\t\t{ from: 'core/edit-post', scope: 'core/edit-post' },\n\t\t'preferredStyleVariations'\n\t);\n\tmigrateIndividualPreferenceToPreferencesStore(\n\t\tpersistence,\n\t\t{ from: 'core/edit-post', scope: 'core/edit-post' },\n\t\t'panels',\n\t\tconvertEditPostPanels\n\t);\n\tmigrateIndividualPreferenceToPreferencesStore(\n\t\tpersistence,\n\t\t{ from: 'core/editor', scope: 'core/edit-post' },\n\t\t'isPublishSidebarEnabled'\n\t);\n\tmigrateIndividualPreferenceToPreferencesStore(\n\t\tpersistence,\n\t\t{ from: 'core/edit-site', scope: 'core/edit-site' },\n\t\t'editorMode'\n\t);\n\tmigrateInterfaceEnableItemsToPreferencesStore( persistence );\n};\n\nexport default persistencePlugin;\n"]}
|