@wordpress/preferences-persistence 2.9.0 → 2.11.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
CHANGED
package/build/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_create","_interopRequireDefault","require","_legacyLocalStorageData","_preferencesPackageData","__unstableCreatePersistenceLayer","serverData","userId","localStorageRestoreKey","localData","JSON","parse","window","localStorage","getItem","serverModified","Date","_modified","localModified","preloadedData","convertPreferencesPackageData","convertLegacyLocalStorageData","create"],"sources":["@wordpress/preferences-persistence/src/index.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport create from './create';\nimport convertLegacyLocalStorageData from './migrations/legacy-local-storage-data';\nimport convertPreferencesPackageData from './migrations/preferences-package-data';\n\nexport { create };\n\n/**\n * Creates the persistence layer with preloaded data.\n *\n * It prioritizes any data from the server, but falls back first to localStorage\n * restore data, and then to any legacy data.\n *\n * This function is used internally by WordPress in an inline script, so\n * prefixed with `__unstable`.\n *\n * @param {Object} serverData Preferences data preloaded from the server.\n * @param {string} userId The user id.\n *\n * @return {Object} The persistence layer initialized with the preloaded data.\n */\nexport function __unstableCreatePersistenceLayer( serverData, userId ) {\n\tconst localStorageRestoreKey = `WP_PREFERENCES_USER_${ userId }`;\n\tconst localData = JSON.parse(\n\t\twindow.localStorage.getItem( localStorageRestoreKey )\n\t);\n\n\t// Date parse returns NaN for invalid input. Coerce anything invalid\n\t// into a conveniently comparable zero.\n\tconst serverModified =\n\t\tDate.parse( serverData && serverData._modified ) || 0;\n\tconst localModified = Date.parse( localData && localData._modified ) || 0;\n\n\tlet preloadedData;\n\tif ( serverData && serverModified >= localModified ) {\n\t\tpreloadedData = convertPreferencesPackageData( serverData );\n\t} else if ( localData ) {\n\t\tpreloadedData = convertPreferencesPackageData( localData );\n\t} else {\n\t\t// Check if there is data in the legacy format from the old persistence system.\n\t\tpreloadedData = convertLegacyLocalStorageData( userId );\n\t}\n\n\treturn create( {\n\t\tpreloadedData,\n\t\tlocalStorageRestoreKey,\n\t} );\n}\n"],"mappings":";;;;;;;;;;;;;AAGA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,uBAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,uBAAA,GAAAH,sBAAA,CAAAC,OAAA;AALA;AACA;AACA;;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASG,gCAAgCA,CAAEC,UAAU,EAAEC,MAAM,EAAG;EACtE,MAAMC,sBAAsB,
|
1
|
+
{"version":3,"names":["_create","_interopRequireDefault","require","_legacyLocalStorageData","_preferencesPackageData","__unstableCreatePersistenceLayer","serverData","userId","localStorageRestoreKey","localData","JSON","parse","window","localStorage","getItem","serverModified","Date","_modified","localModified","preloadedData","convertPreferencesPackageData","convertLegacyLocalStorageData","create"],"sources":["@wordpress/preferences-persistence/src/index.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport create from './create';\nimport convertLegacyLocalStorageData from './migrations/legacy-local-storage-data';\nimport convertPreferencesPackageData from './migrations/preferences-package-data';\n\nexport { create };\n\n/**\n * Creates the persistence layer with preloaded data.\n *\n * It prioritizes any data from the server, but falls back first to localStorage\n * restore data, and then to any legacy data.\n *\n * This function is used internally by WordPress in an inline script, so\n * prefixed with `__unstable`.\n *\n * @param {Object} serverData Preferences data preloaded from the server.\n * @param {string} userId The user id.\n *\n * @return {Object} The persistence layer initialized with the preloaded data.\n */\nexport function __unstableCreatePersistenceLayer( serverData, userId ) {\n\tconst localStorageRestoreKey = `WP_PREFERENCES_USER_${ userId }`;\n\tconst localData = JSON.parse(\n\t\twindow.localStorage.getItem( localStorageRestoreKey )\n\t);\n\n\t// Date parse returns NaN for invalid input. Coerce anything invalid\n\t// into a conveniently comparable zero.\n\tconst serverModified =\n\t\tDate.parse( serverData && serverData._modified ) || 0;\n\tconst localModified = Date.parse( localData && localData._modified ) || 0;\n\n\tlet preloadedData;\n\tif ( serverData && serverModified >= localModified ) {\n\t\tpreloadedData = convertPreferencesPackageData( serverData );\n\t} else if ( localData ) {\n\t\tpreloadedData = convertPreferencesPackageData( localData );\n\t} else {\n\t\t// Check if there is data in the legacy format from the old persistence system.\n\t\tpreloadedData = convertLegacyLocalStorageData( userId );\n\t}\n\n\treturn create( {\n\t\tpreloadedData,\n\t\tlocalStorageRestoreKey,\n\t} );\n}\n"],"mappings":";;;;;;;;;;;;;AAGA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,uBAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,uBAAA,GAAAH,sBAAA,CAAAC,OAAA;AALA;AACA;AACA;;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASG,gCAAgCA,CAAEC,UAAU,EAAEC,MAAM,EAAG;EACtE,MAAMC,sBAAsB,GAAG,uBAAwBD,MAAM,EAAG;EAChE,MAAME,SAAS,GAAGC,IAAI,CAACC,KAAK,CAC3BC,MAAM,CAACC,YAAY,CAACC,OAAO,CAAEN,sBAAuB,CACrD,CAAC;;EAED;EACA;EACA,MAAMO,cAAc,GACnBC,IAAI,CAACL,KAAK,CAAEL,UAAU,IAAIA,UAAU,CAACW,SAAU,CAAC,IAAI,CAAC;EACtD,MAAMC,aAAa,GAAGF,IAAI,CAACL,KAAK,CAAEF,SAAS,IAAIA,SAAS,CAACQ,SAAU,CAAC,IAAI,CAAC;EAEzE,IAAIE,aAAa;EACjB,IAAKb,UAAU,IAAIS,cAAc,IAAIG,aAAa,EAAG;IACpDC,aAAa,GAAG,IAAAC,+BAA6B,EAAEd,UAAW,CAAC;EAC5D,CAAC,MAAM,IAAKG,SAAS,EAAG;IACvBU,aAAa,GAAG,IAAAC,+BAA6B,EAAEX,SAAU,CAAC;EAC3D,CAAC,MAAM;IACN;IACAU,aAAa,GAAG,IAAAE,+BAA6B,EAAEd,MAAO,CAAC;EACxD;EAEA,OAAO,IAAAe,eAAM,EAAE;IACdH,aAAa;IACbX;EACD,CAAE,CAAC;AACJ","ignoreList":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_moveFeaturePreferences","_interopRequireDefault","require","_moveThirdPartyFeaturePreferences","_moveIndividualPreference","_moveInterfaceEnableItems","_convertEditPostPanels","getLegacyData","userId","key","unparsedData","window","localStorage","getItem","JSON","parse","convertLegacyData","data","moveFeaturePreferences","moveThirdPartyFeaturePreferences","moveInterfaceEnableItems","moveIndividualPreference","from","to","convertEditPostPanels","preferences","convertLegacyLocalStorageData"],"sources":["@wordpress/preferences-persistence/src/migrations/legacy-local-storage-data/index.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport moveFeaturePreferences from './move-feature-preferences';\nimport moveThirdPartyFeaturePreferences from './move-third-party-feature-preferences';\nimport moveIndividualPreference from './move-individual-preference';\nimport moveInterfaceEnableItems from './move-interface-enable-items';\nimport convertEditPostPanels from './convert-edit-post-panels';\n\n/**\n * Gets the legacy local storage data for a given user.\n *\n * @param {string | number} userId The user id.\n *\n * @return {Object | null} The local storage data.\n */\nfunction getLegacyData( userId ) {\n\tconst key = `WP_DATA_USER_${ userId }`;\n\tconst unparsedData = window.localStorage.getItem( key );\n\treturn JSON.parse( unparsedData );\n}\n\n/**\n * Converts data from the old `@wordpress/data` package format.\n *\n * @param {Object | null | undefined} data The legacy data in its original format.\n *\n * @return {Object | undefined} The converted data or `undefined` if there was\n * nothing to convert.\n */\nexport function convertLegacyData( data ) {\n\tif ( ! data ) {\n\t\treturn;\n\t}\n\n\t// Move boolean feature preferences from each editor into the\n\t// preferences store data structure.\n\tdata = moveFeaturePreferences( data, 'core/edit-widgets' );\n\tdata = moveFeaturePreferences( data, 'core/customize-widgets' );\n\tdata = moveFeaturePreferences( data, 'core/edit-post' );\n\tdata = moveFeaturePreferences( data, 'core/edit-site' );\n\n\t// Move third party boolean feature preferences from the interface package\n\t// to the preferences store data structure.\n\tdata = moveThirdPartyFeaturePreferences( data );\n\n\t// Move and convert the interface store's `enableItems` data into the\n\t// preferences data structure.\n\tdata = moveInterfaceEnableItems( data );\n\n\t// Move individual ad-hoc preferences from various packages into the\n\t// preferences store data structure.\n\tdata = moveIndividualPreference(\n\t\tdata,\n\t\t{ from: 'core/edit-post', to: 'core/edit-post' },\n\t\t'hiddenBlockTypes'\n\t);\n\tdata = moveIndividualPreference(\n\t\tdata,\n\t\t{ from: 'core/edit-post', to: 'core/edit-post' },\n\t\t'editorMode'\n\t);\n\tdata = moveIndividualPreference(\n\t\tdata,\n\t\t{ from: 'core/edit-post', to: 'core/edit-post' },\n\t\t'panels',\n\t\tconvertEditPostPanels\n\t);\n\tdata = moveIndividualPreference(\n\t\tdata,\n\t\t{ from: 'core/editor', to: 'core' },\n\t\t'isPublishSidebarEnabled'\n\t);\n\tdata = moveIndividualPreference(\n\t\tdata,\n\t\t{ from: 'core/edit-post', to: 'core' },\n\t\t'isPublishSidebarEnabled'\n\t);\n\tdata = moveIndividualPreference(\n\t\tdata,\n\t\t{ from: 'core/edit-site', to: 'core/edit-site' },\n\t\t'editorMode'\n\t);\n\n\t// The new system is only concerned with persisting\n\t// 'core/preferences' preferences reducer, so only return that.\n\treturn data?.[ 'core/preferences' ]?.preferences;\n}\n\n/**\n * Gets the legacy local storage data for the given user and returns the\n * data converted to the new format.\n *\n * @param {string | number} userId The user id.\n *\n * @return {Object | undefined} The converted data or undefined if no local\n * storage data could be found.\n */\nexport default function convertLegacyLocalStorageData( userId ) {\n\tconst data = getLegacyData( userId );\n\treturn convertLegacyData( data );\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,uBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,iCAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,yBAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,yBAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,sBAAA,GAAAL,sBAAA,CAAAC,OAAA;AAPA;AACA;AACA;;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASK,aAAaA,CAAEC,MAAM,EAAG;EAChC,MAAMC,GAAG,
|
1
|
+
{"version":3,"names":["_moveFeaturePreferences","_interopRequireDefault","require","_moveThirdPartyFeaturePreferences","_moveIndividualPreference","_moveInterfaceEnableItems","_convertEditPostPanels","getLegacyData","userId","key","unparsedData","window","localStorage","getItem","JSON","parse","convertLegacyData","data","moveFeaturePreferences","moveThirdPartyFeaturePreferences","moveInterfaceEnableItems","moveIndividualPreference","from","to","convertEditPostPanels","preferences","convertLegacyLocalStorageData"],"sources":["@wordpress/preferences-persistence/src/migrations/legacy-local-storage-data/index.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport moveFeaturePreferences from './move-feature-preferences';\nimport moveThirdPartyFeaturePreferences from './move-third-party-feature-preferences';\nimport moveIndividualPreference from './move-individual-preference';\nimport moveInterfaceEnableItems from './move-interface-enable-items';\nimport convertEditPostPanels from './convert-edit-post-panels';\n\n/**\n * Gets the legacy local storage data for a given user.\n *\n * @param {string | number} userId The user id.\n *\n * @return {Object | null} The local storage data.\n */\nfunction getLegacyData( userId ) {\n\tconst key = `WP_DATA_USER_${ userId }`;\n\tconst unparsedData = window.localStorage.getItem( key );\n\treturn JSON.parse( unparsedData );\n}\n\n/**\n * Converts data from the old `@wordpress/data` package format.\n *\n * @param {Object | null | undefined} data The legacy data in its original format.\n *\n * @return {Object | undefined} The converted data or `undefined` if there was\n * nothing to convert.\n */\nexport function convertLegacyData( data ) {\n\tif ( ! data ) {\n\t\treturn;\n\t}\n\n\t// Move boolean feature preferences from each editor into the\n\t// preferences store data structure.\n\tdata = moveFeaturePreferences( data, 'core/edit-widgets' );\n\tdata = moveFeaturePreferences( data, 'core/customize-widgets' );\n\tdata = moveFeaturePreferences( data, 'core/edit-post' );\n\tdata = moveFeaturePreferences( data, 'core/edit-site' );\n\n\t// Move third party boolean feature preferences from the interface package\n\t// to the preferences store data structure.\n\tdata = moveThirdPartyFeaturePreferences( data );\n\n\t// Move and convert the interface store's `enableItems` data into the\n\t// preferences data structure.\n\tdata = moveInterfaceEnableItems( data );\n\n\t// Move individual ad-hoc preferences from various packages into the\n\t// preferences store data structure.\n\tdata = moveIndividualPreference(\n\t\tdata,\n\t\t{ from: 'core/edit-post', to: 'core/edit-post' },\n\t\t'hiddenBlockTypes'\n\t);\n\tdata = moveIndividualPreference(\n\t\tdata,\n\t\t{ from: 'core/edit-post', to: 'core/edit-post' },\n\t\t'editorMode'\n\t);\n\tdata = moveIndividualPreference(\n\t\tdata,\n\t\t{ from: 'core/edit-post', to: 'core/edit-post' },\n\t\t'panels',\n\t\tconvertEditPostPanels\n\t);\n\tdata = moveIndividualPreference(\n\t\tdata,\n\t\t{ from: 'core/editor', to: 'core' },\n\t\t'isPublishSidebarEnabled'\n\t);\n\tdata = moveIndividualPreference(\n\t\tdata,\n\t\t{ from: 'core/edit-post', to: 'core' },\n\t\t'isPublishSidebarEnabled'\n\t);\n\tdata = moveIndividualPreference(\n\t\tdata,\n\t\t{ from: 'core/edit-site', to: 'core/edit-site' },\n\t\t'editorMode'\n\t);\n\n\t// The new system is only concerned with persisting\n\t// 'core/preferences' preferences reducer, so only return that.\n\treturn data?.[ 'core/preferences' ]?.preferences;\n}\n\n/**\n * Gets the legacy local storage data for the given user and returns the\n * data converted to the new format.\n *\n * @param {string | number} userId The user id.\n *\n * @return {Object | undefined} The converted data or undefined if no local\n * storage data could be found.\n */\nexport default function convertLegacyLocalStorageData( userId ) {\n\tconst data = getLegacyData( userId );\n\treturn convertLegacyData( data );\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,uBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,iCAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,yBAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,yBAAA,GAAAJ,sBA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AAEC,EAAE,EAAE;EAAiB,CAAC,EAChD,QAAQ,EACRC,8BACD,CAAC;EACDP,IAAI,GAAG,IAAAI,iCAAwB,EAC9BJ,IAAI,EACJ;IAAEK,IAAI,EAAE,aAAa;IAAEC,EAAE,EAAE;EAAO,CAAC,EACnC,yBACD,CAAC;EACDN,IAAI,GAAG,IAAAI,iCAAwB,EAC9BJ,IAAI,EACJ;IAAEK,IAAI,EAAE,gBAAgB;IAAEC,EAAE,EAAE;EAAO,CAAC,EACtC,yBACD,CAAC;EACDN,IAAI,GAAG,IAAAI,iCAAwB,EAC9BJ,IAAI,EACJ;IAAEK,IAAI,EAAE,gBAAgB;IAAEC,EAAE,EAAE;EAAiB,CAAC,EAChD,YACD,CAAC;;EAED;EACA;EACA,OAAON,IAAI,GAAI,kBAAkB,CAAE,EAAEQ,WAAW;AACjD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASC,6BAA6BA,CAAElB,MAAM,EAAG;EAC/D,MAAMS,IAAI,GAAGV,aAAa,CAAEC,MAAO,CAAC;EACpC,OAAOQ,iBAAiB,CAAEC,IAAK,CAAC;AACjC","ignoreList":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["create","convertLegacyLocalStorageData","convertPreferencesPackageData","__unstableCreatePersistenceLayer","serverData","userId","localStorageRestoreKey","localData","JSON","parse","window","localStorage","getItem","serverModified","Date","_modified","localModified","preloadedData"],"sources":["@wordpress/preferences-persistence/src/index.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport create from './create';\nimport convertLegacyLocalStorageData from './migrations/legacy-local-storage-data';\nimport convertPreferencesPackageData from './migrations/preferences-package-data';\n\nexport { create };\n\n/**\n * Creates the persistence layer with preloaded data.\n *\n * It prioritizes any data from the server, but falls back first to localStorage\n * restore data, and then to any legacy data.\n *\n * This function is used internally by WordPress in an inline script, so\n * prefixed with `__unstable`.\n *\n * @param {Object} serverData Preferences data preloaded from the server.\n * @param {string} userId The user id.\n *\n * @return {Object} The persistence layer initialized with the preloaded data.\n */\nexport function __unstableCreatePersistenceLayer( serverData, userId ) {\n\tconst localStorageRestoreKey = `WP_PREFERENCES_USER_${ userId }`;\n\tconst localData = JSON.parse(\n\t\twindow.localStorage.getItem( localStorageRestoreKey )\n\t);\n\n\t// Date parse returns NaN for invalid input. Coerce anything invalid\n\t// into a conveniently comparable zero.\n\tconst serverModified =\n\t\tDate.parse( serverData && serverData._modified ) || 0;\n\tconst localModified = Date.parse( localData && localData._modified ) || 0;\n\n\tlet preloadedData;\n\tif ( serverData && serverModified >= localModified ) {\n\t\tpreloadedData = convertPreferencesPackageData( serverData );\n\t} else if ( localData ) {\n\t\tpreloadedData = convertPreferencesPackageData( localData );\n\t} else {\n\t\t// Check if there is data in the legacy format from the old persistence system.\n\t\tpreloadedData = convertLegacyLocalStorageData( userId );\n\t}\n\n\treturn create( {\n\t\tpreloadedData,\n\t\tlocalStorageRestoreKey,\n\t} );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,MAAM,MAAM,UAAU;AAC7B,OAAOC,6BAA6B,MAAM,wCAAwC;AAClF,OAAOC,6BAA6B,MAAM,uCAAuC;AAEjF,SAASF,MAAM;;AAEf;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASG,gCAAgCA,CAAEC,UAAU,EAAEC,MAAM,EAAG;EACtE,MAAMC,sBAAsB,
|
1
|
+
{"version":3,"names":["create","convertLegacyLocalStorageData","convertPreferencesPackageData","__unstableCreatePersistenceLayer","serverData","userId","localStorageRestoreKey","localData","JSON","parse","window","localStorage","getItem","serverModified","Date","_modified","localModified","preloadedData"],"sources":["@wordpress/preferences-persistence/src/index.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport create from './create';\nimport convertLegacyLocalStorageData from './migrations/legacy-local-storage-data';\nimport convertPreferencesPackageData from './migrations/preferences-package-data';\n\nexport { create };\n\n/**\n * Creates the persistence layer with preloaded data.\n *\n * It prioritizes any data from the server, but falls back first to localStorage\n * restore data, and then to any legacy data.\n *\n * This function is used internally by WordPress in an inline script, so\n * prefixed with `__unstable`.\n *\n * @param {Object} serverData Preferences data preloaded from the server.\n * @param {string} userId The user id.\n *\n * @return {Object} The persistence layer initialized with the preloaded data.\n */\nexport function __unstableCreatePersistenceLayer( serverData, userId ) {\n\tconst localStorageRestoreKey = `WP_PREFERENCES_USER_${ userId }`;\n\tconst localData = JSON.parse(\n\t\twindow.localStorage.getItem( localStorageRestoreKey )\n\t);\n\n\t// Date parse returns NaN for invalid input. Coerce anything invalid\n\t// into a conveniently comparable zero.\n\tconst serverModified =\n\t\tDate.parse( serverData && serverData._modified ) || 0;\n\tconst localModified = Date.parse( localData && localData._modified ) || 0;\n\n\tlet preloadedData;\n\tif ( serverData && serverModified >= localModified ) {\n\t\tpreloadedData = convertPreferencesPackageData( serverData );\n\t} else if ( localData ) {\n\t\tpreloadedData = convertPreferencesPackageData( localData );\n\t} else {\n\t\t// Check if there is data in the legacy format from the old persistence system.\n\t\tpreloadedData = convertLegacyLocalStorageData( userId );\n\t}\n\n\treturn create( {\n\t\tpreloadedData,\n\t\tlocalStorageRestoreKey,\n\t} );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,MAAM,MAAM,UAAU;AAC7B,OAAOC,6BAA6B,MAAM,wCAAwC;AAClF,OAAOC,6BAA6B,MAAM,uCAAuC;AAEjF,SAASF,MAAM;;AAEf;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASG,gCAAgCA,CAAEC,UAAU,EAAEC,MAAM,EAAG;EACtE,MAAMC,sBAAsB,GAAG,uBAAwBD,MAAM,EAAG;EAChE,MAAME,SAAS,GAAGC,IAAI,CAACC,KAAK,CAC3BC,MAAM,CAACC,YAAY,CAACC,OAAO,CAAEN,sBAAuB,CACrD,CAAC;;EAED;EACA;EACA,MAAMO,cAAc,GACnBC,IAAI,CAACL,KAAK,CAAEL,UAAU,IAAIA,UAAU,CAACW,SAAU,CAAC,IAAI,CAAC;EACtD,MAAMC,aAAa,GAAGF,IAAI,CAACL,KAAK,CAAEF,SAAS,IAAIA,SAAS,CAACQ,SAAU,CAAC,IAAI,CAAC;EAEzE,IAAIE,aAAa;EACjB,IAAKb,UAAU,IAAIS,cAAc,IAAIG,aAAa,EAAG;IACpDC,aAAa,GAAGf,6BAA6B,CAAEE,UAAW,CAAC;EAC5D,CAAC,MAAM,IAAKG,SAAS,EAAG;IACvBU,aAAa,GAAGf,6BAA6B,CAAEK,SAAU,CAAC;EAC3D,CAAC,MAAM;IACN;IACAU,aAAa,GAAGhB,6BAA6B,CAAEI,MAAO,CAAC;EACxD;EAEA,OAAOL,MAAM,CAAE;IACdiB,aAAa;IACbX;EACD,CAAE,CAAC;AACJ","ignoreList":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["moveFeaturePreferences","moveThirdPartyFeaturePreferences","moveIndividualPreference","moveInterfaceEnableItems","convertEditPostPanels","getLegacyData","userId","key","unparsedData","window","localStorage","getItem","JSON","parse","convertLegacyData","data","from","to","preferences","convertLegacyLocalStorageData"],"sources":["@wordpress/preferences-persistence/src/migrations/legacy-local-storage-data/index.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport moveFeaturePreferences from './move-feature-preferences';\nimport moveThirdPartyFeaturePreferences from './move-third-party-feature-preferences';\nimport moveIndividualPreference from './move-individual-preference';\nimport moveInterfaceEnableItems from './move-interface-enable-items';\nimport convertEditPostPanels from './convert-edit-post-panels';\n\n/**\n * Gets the legacy local storage data for a given user.\n *\n * @param {string | number} userId The user id.\n *\n * @return {Object | null} The local storage data.\n */\nfunction getLegacyData( userId ) {\n\tconst key = `WP_DATA_USER_${ userId }`;\n\tconst unparsedData = window.localStorage.getItem( key );\n\treturn JSON.parse( unparsedData );\n}\n\n/**\n * Converts data from the old `@wordpress/data` package format.\n *\n * @param {Object | null | undefined} data The legacy data in its original format.\n *\n * @return {Object | undefined} The converted data or `undefined` if there was\n * nothing to convert.\n */\nexport function convertLegacyData( data ) {\n\tif ( ! data ) {\n\t\treturn;\n\t}\n\n\t// Move boolean feature preferences from each editor into the\n\t// preferences store data structure.\n\tdata = moveFeaturePreferences( data, 'core/edit-widgets' );\n\tdata = moveFeaturePreferences( data, 'core/customize-widgets' );\n\tdata = moveFeaturePreferences( data, 'core/edit-post' );\n\tdata = moveFeaturePreferences( data, 'core/edit-site' );\n\n\t// Move third party boolean feature preferences from the interface package\n\t// to the preferences store data structure.\n\tdata = moveThirdPartyFeaturePreferences( data );\n\n\t// Move and convert the interface store's `enableItems` data into the\n\t// preferences data structure.\n\tdata = moveInterfaceEnableItems( data );\n\n\t// Move individual ad-hoc preferences from various packages into the\n\t// preferences store data structure.\n\tdata = moveIndividualPreference(\n\t\tdata,\n\t\t{ from: 'core/edit-post', to: 'core/edit-post' },\n\t\t'hiddenBlockTypes'\n\t);\n\tdata = moveIndividualPreference(\n\t\tdata,\n\t\t{ from: 'core/edit-post', to: 'core/edit-post' },\n\t\t'editorMode'\n\t);\n\tdata = moveIndividualPreference(\n\t\tdata,\n\t\t{ from: 'core/edit-post', to: 'core/edit-post' },\n\t\t'panels',\n\t\tconvertEditPostPanels\n\t);\n\tdata = moveIndividualPreference(\n\t\tdata,\n\t\t{ from: 'core/editor', to: 'core' },\n\t\t'isPublishSidebarEnabled'\n\t);\n\tdata = moveIndividualPreference(\n\t\tdata,\n\t\t{ from: 'core/edit-post', to: 'core' },\n\t\t'isPublishSidebarEnabled'\n\t);\n\tdata = moveIndividualPreference(\n\t\tdata,\n\t\t{ from: 'core/edit-site', to: 'core/edit-site' },\n\t\t'editorMode'\n\t);\n\n\t// The new system is only concerned with persisting\n\t// 'core/preferences' preferences reducer, so only return that.\n\treturn data?.[ 'core/preferences' ]?.preferences;\n}\n\n/**\n * Gets the legacy local storage data for the given user and returns the\n * data converted to the new format.\n *\n * @param {string | number} userId The user id.\n *\n * @return {Object | undefined} The converted data or undefined if no local\n * storage data could be found.\n */\nexport default function convertLegacyLocalStorageData( userId ) {\n\tconst data = getLegacyData( userId );\n\treturn convertLegacyData( data );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,sBAAsB,MAAM,4BAA4B;AAC/D,OAAOC,gCAAgC,MAAM,wCAAwC;AACrF,OAAOC,wBAAwB,MAAM,8BAA8B;AACnE,OAAOC,wBAAwB,MAAM,+BAA+B;AACpE,OAAOC,qBAAqB,MAAM,4BAA4B;;AAE9D;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,aAAaA,CAAEC,MAAM,EAAG;EAChC,MAAMC,GAAG,
|
1
|
+
{"version":3,"names":["moveFeaturePreferences","moveThirdPartyFeaturePreferences","moveIndividualPreference","moveInterfaceEnableItems","convertEditPostPanels","getLegacyData","userId","key","unparsedData","window","localStorage","getItem","JSON","parse","convertLegacyData","data","from","to","preferences","convertLegacyLocalStorageData"],"sources":["@wordpress/preferences-persistence/src/migrations/legacy-local-storage-data/index.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport moveFeaturePreferences from './move-feature-preferences';\nimport moveThirdPartyFeaturePreferences from './move-third-party-feature-preferences';\nimport moveIndividualPreference from './move-individual-preference';\nimport moveInterfaceEnableItems from './move-interface-enable-items';\nimport convertEditPostPanels from './convert-edit-post-panels';\n\n/**\n * Gets the legacy local storage data for a given user.\n *\n * @param {string | number} userId The user id.\n *\n * @return {Object | null} The local storage data.\n */\nfunction getLegacyData( userId ) {\n\tconst key = `WP_DATA_USER_${ userId }`;\n\tconst unparsedData = window.localStorage.getItem( key );\n\treturn JSON.parse( unparsedData );\n}\n\n/**\n * Converts data from the old `@wordpress/data` package format.\n *\n * @param {Object | null | undefined} data The legacy data in its original format.\n *\n * @return {Object | undefined} The converted data or `undefined` if there was\n * nothing to convert.\n */\nexport function convertLegacyData( data ) {\n\tif ( ! data ) {\n\t\treturn;\n\t}\n\n\t// Move boolean feature preferences from each editor into the\n\t// preferences store data structure.\n\tdata = moveFeaturePreferences( data, 'core/edit-widgets' );\n\tdata = moveFeaturePreferences( data, 'core/customize-widgets' );\n\tdata = moveFeaturePreferences( data, 'core/edit-post' );\n\tdata = moveFeaturePreferences( data, 'core/edit-site' );\n\n\t// Move third party boolean feature preferences from the interface package\n\t// to the preferences store data structure.\n\tdata = moveThirdPartyFeaturePreferences( data );\n\n\t// Move and convert the interface store's `enableItems` data into the\n\t// preferences data structure.\n\tdata = moveInterfaceEnableItems( data );\n\n\t// Move individual ad-hoc preferences from various packages into the\n\t// preferences store data structure.\n\tdata = moveIndividualPreference(\n\t\tdata,\n\t\t{ from: 'core/edit-post', to: 'core/edit-post' },\n\t\t'hiddenBlockTypes'\n\t);\n\tdata = moveIndividualPreference(\n\t\tdata,\n\t\t{ from: 'core/edit-post', to: 'core/edit-post' },\n\t\t'editorMode'\n\t);\n\tdata = moveIndividualPreference(\n\t\tdata,\n\t\t{ from: 'core/edit-post', to: 'core/edit-post' },\n\t\t'panels',\n\t\tconvertEditPostPanels\n\t);\n\tdata = moveIndividualPreference(\n\t\tdata,\n\t\t{ from: 'core/editor', to: 'core' },\n\t\t'isPublishSidebarEnabled'\n\t);\n\tdata = moveIndividualPreference(\n\t\tdata,\n\t\t{ from: 'core/edit-post', to: 'core' },\n\t\t'isPublishSidebarEnabled'\n\t);\n\tdata = moveIndividualPreference(\n\t\tdata,\n\t\t{ from: 'core/edit-site', to: 'core/edit-site' },\n\t\t'editorMode'\n\t);\n\n\t// The new system is only concerned with persisting\n\t// 'core/preferences' preferences reducer, so only return that.\n\treturn data?.[ 'core/preferences' ]?.preferences;\n}\n\n/**\n * Gets the legacy local storage data for the given user and returns the\n * data converted to the new format.\n *\n * @param {string | number} userId The user id.\n *\n * @return {Object | undefined} The converted data or undefined if no local\n * storage data could be found.\n */\nexport default function convertLegacyLocalStorageData( userId ) {\n\tconst data = getLegacyData( userId );\n\treturn convertLegacyData( data );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAO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CAC9Ba,IAAI,EACJ;IAAEC,IAAI,EAAE,gBAAgB;IAAEC,EAAE,EAAE;EAAiB,CAAC,EAChD,QAAQ,EACRb,qBACD,CAAC;EACDW,IAAI,GAAGb,wBAAwB,CAC9Ba,IAAI,EACJ;IAAEC,IAAI,EAAE,aAAa;IAAEC,EAAE,EAAE;EAAO,CAAC,EACnC,yBACD,CAAC;EACDF,IAAI,GAAGb,wBAAwB,CAC9Ba,IAAI,EACJ;IAAEC,IAAI,EAAE,gBAAgB;IAAEC,EAAE,EAAE;EAAO,CAAC,EACtC,yBACD,CAAC;EACDF,IAAI,GAAGb,wBAAwB,CAC9Ba,IAAI,EACJ;IAAEC,IAAI,EAAE,gBAAgB;IAAEC,EAAE,EAAE;EAAiB,CAAC,EAChD,YACD,CAAC;;EAED;EACA;EACA,OAAOF,IAAI,GAAI,kBAAkB,CAAE,EAAEG,WAAW;AACjD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,6BAA6BA,CAAEb,MAAM,EAAG;EAC/D,MAAMS,IAAI,GAAGV,aAAa,CAAEC,MAAO,CAAC;EACpC,OAAOQ,iBAAiB,CAAEC,IAAK,CAAC;AACjC","ignoreList":[]}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@wordpress/preferences-persistence",
|
3
|
-
"version": "2.
|
3
|
+
"version": "2.11.0",
|
4
4
|
"description": "Persistence utilities for `wordpress/preferences`.",
|
5
5
|
"author": "The WordPress Contributors",
|
6
6
|
"license": "GPL-2.0-or-later",
|
@@ -28,11 +28,12 @@
|
|
28
28
|
"react-native": "src/index",
|
29
29
|
"sideEffects": false,
|
30
30
|
"dependencies": {
|
31
|
-
"@babel/runtime": "
|
32
|
-
"@wordpress/api-fetch": "
|
31
|
+
"@babel/runtime": "7.25.7",
|
32
|
+
"@wordpress/api-fetch": "*"
|
33
33
|
},
|
34
34
|
"publishConfig": {
|
35
35
|
"access": "public"
|
36
36
|
},
|
37
|
-
"
|
37
|
+
"wpScript": true,
|
38
|
+
"gitHead": "dcf4613b33b0eda14e203ac30f700ed0db70347f"
|
38
39
|
}
|