@wordpress/core-data 7.33.3 → 7.34.1-next.2f1c7c01b.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 +2 -0
- package/build/actions.js +12 -10
- package/build/actions.js.map +1 -1
- package/build/batch/create-batch.js +4 -2
- package/build/batch/create-batch.js.map +1 -1
- package/build/batch/default-processor.js +3 -1
- package/build/batch/default-processor.js.map +1 -1
- package/build/batch/index.js +2 -0
- package/build/batch/index.js.map +1 -1
- package/build/dynamic-entities.js +4 -2
- package/build/dynamic-entities.js.map +1 -1
- package/build/entities.js +27 -11
- package/build/entities.js.map +2 -2
- package/build/entity-context.js +3 -1
- package/build/entity-context.js.map +1 -1
- package/build/entity-provider.js +3 -1
- package/build/entity-provider.js.map +1 -1
- package/build/entity-types/attachment.js +2 -0
- package/build/entity-types/attachment.js.map +1 -1
- package/build/entity-types/base-entity-records.js +2 -0
- package/build/entity-types/base-entity-records.js.map +1 -1
- package/build/entity-types/base.js +2 -0
- package/build/entity-types/base.js.map +1 -1
- package/build/entity-types/comment.js +2 -0
- package/build/entity-types/comment.js.map +1 -1
- package/build/entity-types/global-styles-revision.js +2 -0
- package/build/entity-types/global-styles-revision.js.map +1 -1
- package/build/entity-types/helpers.js +2 -0
- package/build/entity-types/helpers.js.map +1 -1
- package/build/entity-types/index.js +2 -0
- package/build/entity-types/index.js.map +1 -1
- package/build/entity-types/menu-location.js +2 -0
- package/build/entity-types/menu-location.js.map +1 -1
- package/build/entity-types/nav-menu-item.js +2 -0
- package/build/entity-types/nav-menu-item.js.map +1 -1
- package/build/entity-types/nav-menu.js +2 -0
- package/build/entity-types/nav-menu.js.map +1 -1
- package/build/entity-types/page.js +2 -0
- package/build/entity-types/page.js.map +1 -1
- package/build/entity-types/plugin.js +2 -0
- package/build/entity-types/plugin.js.map +1 -1
- package/build/entity-types/post-revision.js +2 -0
- package/build/entity-types/post-revision.js.map +1 -1
- package/build/entity-types/post-status.js +2 -0
- package/build/entity-types/post-status.js.map +1 -1
- package/build/entity-types/post.js +2 -0
- package/build/entity-types/post.js.map +1 -1
- package/build/entity-types/settings.js +2 -0
- package/build/entity-types/settings.js.map +1 -1
- package/build/entity-types/sidebar.js +2 -0
- package/build/entity-types/sidebar.js.map +1 -1
- package/build/entity-types/taxonomy.js +2 -0
- package/build/entity-types/taxonomy.js.map +1 -1
- package/build/entity-types/term.js +2 -0
- package/build/entity-types/term.js.map +1 -1
- package/build/entity-types/theme.js +2 -0
- package/build/entity-types/theme.js.map +1 -1
- package/build/entity-types/type.js +2 -0
- package/build/entity-types/type.js.map +1 -1
- package/build/entity-types/user.js +2 -0
- package/build/entity-types/user.js.map +1 -1
- package/build/entity-types/widget-type.js +2 -0
- package/build/entity-types/widget-type.js.map +1 -1
- package/build/entity-types/widget.js +2 -0
- package/build/entity-types/widget.js.map +1 -1
- package/build/entity-types/wp-template-part.js +2 -0
- package/build/entity-types/wp-template-part.js.map +1 -1
- package/build/entity-types/wp-template.js +2 -0
- package/build/entity-types/wp-template.js.map +1 -1
- package/build/fetch/__experimental-fetch-link-suggestions.js +2 -0
- package/build/fetch/__experimental-fetch-link-suggestions.js.map +1 -1
- package/build/fetch/__experimental-fetch-url-data.js +4 -2
- package/build/fetch/__experimental-fetch-url-data.js.map +1 -1
- package/build/fetch/index.js +2 -0
- package/build/fetch/index.js.map +1 -1
- package/build/footnotes/get-footnotes-order.js +3 -1
- package/build/footnotes/get-footnotes-order.js.map +1 -1
- package/build/footnotes/get-rich-text-values-cached.js +4 -2
- package/build/footnotes/get-rich-text-values-cached.js.map +1 -1
- package/build/footnotes/index.js +3 -1
- package/build/footnotes/index.js.map +1 -1
- package/build/hooks/constants.js +2 -0
- package/build/hooks/constants.js.map +1 -1
- package/build/hooks/index.js +2 -0
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/memoize.js +2 -0
- package/build/hooks/memoize.js.map +1 -1
- package/build/hooks/use-entity-block-editor.js +4 -2
- package/build/hooks/use-entity-block-editor.js.map +1 -1
- package/build/hooks/use-entity-id.js +2 -0
- package/build/hooks/use-entity-id.js.map +1 -1
- package/build/hooks/use-entity-prop.js +2 -0
- package/build/hooks/use-entity-prop.js.map +1 -1
- package/build/hooks/use-entity-record.js +3 -1
- package/build/hooks/use-entity-record.js.map +1 -1
- package/build/hooks/use-entity-records.js +3 -1
- package/build/hooks/use-entity-records.js.map +1 -1
- package/build/hooks/use-query-select.js +4 -2
- package/build/hooks/use-query-select.js.map +1 -1
- package/build/hooks/use-resource-permissions.js +2 -0
- package/build/hooks/use-resource-permissions.js.map +1 -1
- package/build/index.js +8 -6
- package/build/index.js.map +1 -1
- package/build/lock-unlock.js +3 -1
- package/build/lock-unlock.js.map +1 -1
- package/build/locks/actions.js +2 -0
- package/build/locks/actions.js.map +1 -1
- package/build/locks/engine.js +2 -0
- package/build/locks/engine.js.map +1 -1
- package/build/locks/reducer.js +3 -1
- package/build/locks/reducer.js.map +1 -1
- package/build/locks/selectors.js +2 -0
- package/build/locks/selectors.js.map +1 -1
- package/build/locks/utils.js +2 -0
- package/build/locks/utils.js.map +1 -1
- package/build/name.js +3 -1
- package/build/name.js.map +1 -1
- package/build/private-actions.js +3 -1
- package/build/private-actions.js.map +1 -1
- package/build/private-apis.js +3 -1
- package/build/private-apis.js.map +1 -1
- package/build/private-selectors.js +7 -5
- package/build/private-selectors.js.map +1 -1
- package/build/queried-data/actions.js +2 -0
- package/build/queried-data/actions.js.map +1 -1
- package/build/queried-data/get-query-parts.js +2 -0
- package/build/queried-data/get-query-parts.js.map +1 -1
- package/build/queried-data/index.js +2 -0
- package/build/queried-data/index.js.map +1 -1
- package/build/queried-data/reducer.js +4 -2
- package/build/queried-data/reducer.js.map +1 -1
- package/build/queried-data/selectors.js +4 -2
- package/build/queried-data/selectors.js.map +1 -1
- package/build/reducer.js +4 -2
- package/build/reducer.js.map +1 -1
- package/build/resolvers.js +39 -29
- package/build/resolvers.js.map +2 -2
- package/build/selectors.js +18 -16
- package/build/selectors.js.map +1 -1
- package/build/sync.js +7 -1
- package/build/sync.js.map +2 -2
- package/build/types.js +2 -0
- package/build/types.js.map +1 -1
- package/build/utils/conservative-map-item.js +2 -0
- package/build/utils/conservative-map-item.js.map +1 -1
- package/build/utils/crdt-blocks.js +4 -2
- package/build/utils/crdt-blocks.js.map +1 -1
- package/build/utils/crdt.js +63 -5
- package/build/utils/crdt.js.map +2 -2
- package/build/utils/forward-resolver.js +3 -1
- package/build/utils/forward-resolver.js.map +1 -1
- package/build/utils/get-nested-value.js +2 -0
- package/build/utils/get-nested-value.js.map +1 -1
- package/build/utils/get-normalized-comma-separable.js +2 -0
- package/build/utils/get-normalized-comma-separable.js.map +1 -1
- package/build/utils/if-matching-action.js +3 -1
- package/build/utils/if-matching-action.js.map +1 -1
- package/build/utils/index.js +2 -0
- package/build/utils/index.js.map +1 -1
- package/build/utils/is-numeric-id.js +2 -0
- package/build/utils/is-numeric-id.js.map +1 -1
- package/build/utils/is-raw-attribute.js +2 -0
- package/build/utils/is-raw-attribute.js.map +1 -1
- package/build/utils/log-entity-deprecation.js +3 -1
- package/build/utils/log-entity-deprecation.js.map +1 -1
- package/build/utils/on-sub-key.js +3 -1
- package/build/utils/on-sub-key.js.map +1 -1
- package/build/utils/receive-intermediate-results.js +3 -1
- package/build/utils/receive-intermediate-results.js.map +1 -1
- package/build/utils/replace-action.js +3 -1
- package/build/utils/replace-action.js.map +1 -1
- package/build/utils/set-nested-value.js +2 -0
- package/build/utils/set-nested-value.js.map +1 -1
- package/build/utils/user-permissions.js +3 -1
- package/build/utils/user-permissions.js.map +1 -1
- package/build/utils/with-weak-map-cache.js +2 -0
- package/build/utils/with-weak-map-cache.js.map +1 -1
- package/build-module/actions.js +11 -10
- package/build-module/actions.js.map +1 -1
- package/build-module/batch/create-batch.js +3 -2
- package/build-module/batch/create-batch.js.map +1 -1
- package/build-module/batch/default-processor.js +2 -1
- package/build-module/batch/default-processor.js.map +1 -1
- package/build-module/batch/index.js +1 -0
- package/build-module/batch/index.js.map +1 -1
- package/build-module/dynamic-entities.js +3 -2
- package/build-module/dynamic-entities.js.map +1 -1
- package/build-module/entities.js +26 -11
- package/build-module/entities.js.map +2 -2
- package/build-module/entity-context.js +2 -1
- package/build-module/entity-context.js.map +1 -1
- package/build-module/entity-provider.js +2 -1
- package/build-module/entity-provider.js.map +1 -1
- package/build-module/fetch/__experimental-fetch-link-suggestions.js +1 -0
- package/build-module/fetch/__experimental-fetch-link-suggestions.js.map +1 -1
- package/build-module/fetch/__experimental-fetch-url-data.js +3 -2
- package/build-module/fetch/__experimental-fetch-url-data.js.map +1 -1
- package/build-module/fetch/index.js +1 -0
- package/build-module/fetch/index.js.map +1 -1
- package/build-module/footnotes/get-footnotes-order.js +2 -1
- package/build-module/footnotes/get-footnotes-order.js.map +1 -1
- package/build-module/footnotes/get-rich-text-values-cached.js +3 -2
- package/build-module/footnotes/get-rich-text-values-cached.js.map +1 -1
- package/build-module/footnotes/index.js +2 -1
- package/build-module/footnotes/index.js.map +1 -1
- package/build-module/hooks/constants.js +1 -0
- package/build-module/hooks/constants.js.map +1 -1
- package/build-module/hooks/index.js +1 -0
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/memoize.js +1 -0
- package/build-module/hooks/memoize.js.map +1 -1
- package/build-module/hooks/use-entity-block-editor.js +3 -2
- package/build-module/hooks/use-entity-block-editor.js.map +1 -1
- package/build-module/hooks/use-entity-id.js +1 -0
- package/build-module/hooks/use-entity-id.js.map +1 -1
- package/build-module/hooks/use-entity-prop.js +1 -0
- package/build-module/hooks/use-entity-prop.js.map +1 -1
- package/build-module/hooks/use-entity-record.js +2 -1
- package/build-module/hooks/use-entity-record.js.map +1 -1
- package/build-module/hooks/use-entity-records.js +2 -1
- package/build-module/hooks/use-entity-records.js.map +1 -1
- package/build-module/hooks/use-query-select.js +3 -2
- package/build-module/hooks/use-query-select.js.map +1 -1
- package/build-module/hooks/use-resource-permissions.js +1 -0
- package/build-module/hooks/use-resource-permissions.js.map +1 -1
- package/build-module/index.js +13 -12
- package/build-module/index.js.map +1 -1
- package/build-module/lock-unlock.js +2 -1
- package/build-module/lock-unlock.js.map +1 -1
- package/build-module/locks/actions.js +1 -0
- package/build-module/locks/actions.js.map +1 -1
- package/build-module/locks/engine.js +1 -0
- package/build-module/locks/engine.js.map +1 -1
- package/build-module/locks/reducer.js +2 -1
- package/build-module/locks/reducer.js.map +1 -1
- package/build-module/locks/selectors.js +1 -0
- package/build-module/locks/selectors.js.map +1 -1
- package/build-module/locks/utils.js +1 -0
- package/build-module/locks/utils.js.map +1 -1
- package/build-module/name.js +2 -1
- package/build-module/name.js.map +1 -1
- package/build-module/private-actions.js +2 -1
- package/build-module/private-actions.js.map +1 -1
- package/build-module/private-apis.js +2 -1
- package/build-module/private-apis.js.map +1 -1
- package/build-module/private-selectors.js +6 -5
- package/build-module/private-selectors.js.map +1 -1
- package/build-module/queried-data/actions.js +1 -0
- package/build-module/queried-data/actions.js.map +1 -1
- package/build-module/queried-data/get-query-parts.js +1 -0
- package/build-module/queried-data/get-query-parts.js.map +1 -1
- package/build-module/queried-data/index.js +1 -0
- package/build-module/queried-data/index.js.map +1 -1
- package/build-module/queried-data/reducer.js +3 -2
- package/build-module/queried-data/reducer.js.map +1 -1
- package/build-module/queried-data/selectors.js +3 -2
- package/build-module/queried-data/selectors.js.map +1 -1
- package/build-module/reducer.js +3 -2
- package/build-module/reducer.js.map +1 -1
- package/build-module/resolvers.js +38 -29
- package/build-module/resolvers.js.map +2 -2
- package/build-module/selectors.js +17 -16
- package/build-module/selectors.js.map +1 -1
- package/build-module/sync.js +6 -1
- package/build-module/sync.js.map +2 -2
- package/build-module/utils/conservative-map-item.js +1 -0
- package/build-module/utils/conservative-map-item.js.map +1 -1
- package/build-module/utils/crdt-blocks.js +3 -2
- package/build-module/utils/crdt-blocks.js.map +1 -1
- package/build-module/utils/crdt.js +67 -6
- package/build-module/utils/crdt.js.map +2 -2
- package/build-module/utils/forward-resolver.js +2 -1
- package/build-module/utils/forward-resolver.js.map +1 -1
- package/build-module/utils/get-nested-value.js +1 -0
- package/build-module/utils/get-nested-value.js.map +1 -1
- package/build-module/utils/get-normalized-comma-separable.js +1 -0
- package/build-module/utils/get-normalized-comma-separable.js.map +1 -1
- package/build-module/utils/if-matching-action.js +2 -1
- package/build-module/utils/if-matching-action.js.map +1 -1
- package/build-module/utils/index.js +1 -0
- package/build-module/utils/index.js.map +1 -1
- package/build-module/utils/is-numeric-id.js +1 -0
- package/build-module/utils/is-numeric-id.js.map +1 -1
- package/build-module/utils/is-raw-attribute.js +1 -0
- package/build-module/utils/is-raw-attribute.js.map +1 -1
- package/build-module/utils/log-entity-deprecation.js +2 -1
- package/build-module/utils/log-entity-deprecation.js.map +1 -1
- package/build-module/utils/on-sub-key.js +2 -1
- package/build-module/utils/on-sub-key.js.map +1 -1
- package/build-module/utils/receive-intermediate-results.js +2 -1
- package/build-module/utils/receive-intermediate-results.js.map +1 -1
- package/build-module/utils/replace-action.js +2 -1
- package/build-module/utils/replace-action.js.map +1 -1
- package/build-module/utils/set-nested-value.js +1 -0
- package/build-module/utils/set-nested-value.js.map +1 -1
- package/build-module/utils/user-permissions.js +2 -1
- package/build-module/utils/user-permissions.js.map +1 -1
- package/build-module/utils/with-weak-map-cache.js +1 -0
- package/build-module/utils/with-weak-map-cache.js.map +1 -1
- package/build-types/entities.d.ts +1 -1
- package/build-types/entities.d.ts.map +1 -1
- package/build-types/resolvers.d.ts.map +1 -1
- package/build-types/sync.d.ts +2 -2
- package/build-types/sync.d.ts.map +1 -1
- package/build-types/utils/crdt.d.ts +4 -7
- package/build-types/utils/crdt.d.ts.map +1 -1
- package/package.json +18 -18
- package/src/entities.js +31 -7
- package/src/resolvers.js +8 -0
- package/src/sync.ts +9 -1
- package/src/test/entities.js +19 -4
- package/src/test/resolvers.js +80 -0
- package/src/utils/crdt.ts +108 -6
- package/src/utils/test/crdt.ts +124 -1
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/hooks/use-query-select.ts"],
|
|
4
4
|
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport memoize from './memoize';\nimport { Status } from './constants';\n\nexport const META_SELECTORS = [\n\t'getIsResolving',\n\t'hasStartedResolution',\n\t'hasFinishedResolution',\n\t'isResolving',\n\t'getCachedResolvers',\n];\n\ninterface QuerySelectResponse< Data > {\n\t/** the requested selector return value */\n\tdata: Data;\n\n\t/** is the record still being resolved? Via the `isResolving` meta-selector */\n\tisResolving: boolean;\n\n\t/** was the resolution started? Via the `hasStartedResolution` meta-selector */\n\thasStarted: boolean;\n\n\t/** has the resolution finished? Via the `hasFinishedResolution` meta-selector. */\n\thasResolved: boolean;\n}\n\n/**\n * Like useSelect, but the selectors return objects containing\n * both the original data AND the resolution info.\n *\n * @since 6.1.0 Introduced in WordPress core.\n * @private\n *\n * @param {Function} mapQuerySelect see useSelect\n * @param {Array} deps see useSelect\n *\n * @example\n * ```js\n * import { useQuerySelect } from '@wordpress/data';\n * import { store as coreDataStore } from '@wordpress/core-data';\n *\n * function PageTitleDisplay( { id } ) {\n * const { data: page, isResolving } = useQuerySelect( ( query ) => {\n * return query( coreDataStore ).getEntityRecord( 'postType', 'page', id )\n * }, [ id ] );\n *\n * if ( isResolving ) {\n * return 'Loading...';\n * }\n *\n * return page.title;\n * }\n *\n * // Rendered in the application:\n * // <PageTitleDisplay id={ 10 } />\n * ```\n *\n * In the above example, when `PageTitleDisplay` is rendered into an\n * application, the page and the resolution details will be retrieved from\n * the store state using the `mapSelect` callback on `useQuerySelect`.\n *\n * If the id prop changes then any page in the state for that id is\n * retrieved. If the id prop doesn't change and other props are passed in\n * that do change, the title will not change because the dependency is just\n * the id.\n * @see useSelect\n *\n * @return {QuerySelectResponse} Queried data.\n */\nexport default function useQuerySelect( mapQuerySelect, deps ) {\n\treturn useSelect( ( select, registry ) => {\n\t\tconst resolve = ( store ) => enrichSelectors( select( store ) );\n\t\treturn mapQuerySelect( resolve, registry );\n\t}, deps );\n}\n\ninterface EnrichedSelectors {\n\t< Selectors extends Record< string, ( ...args: any[] ) => any > >(\n\t\tselectors: Selectors\n\t): {\n\t\t[ Selector in keyof Selectors ]: (\n\t\t\t...args: Parameters< Selectors[ Selector ] >\n\t\t) => QuerySelectResponse< ReturnType< Selectors[ Selector ] > >;\n\t};\n}\n\n/**\n * Transform simple selectors into ones that return an object with the\n * original return value AND the resolution info.\n *\n * @param {Object} selectors Selectors to enrich\n * @return {EnrichedSelectors} Enriched selectors\n */\nconst enrichSelectors = memoize( ( ( selectors ) => {\n\tconst resolvers = {};\n\tfor ( const selectorName in selectors ) {\n\t\tif ( META_SELECTORS.includes( selectorName ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\tObject.defineProperty( resolvers, selectorName, {\n\t\t\tget:\n\t\t\t\t() =>\n\t\t\t\t( ...args: unknown[] ) => {\n\t\t\t\t\tconst data = selectors[ selectorName ]( ...args );\n\t\t\t\t\tconst resolutionStatus = selectors.getResolutionState(\n\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\targs\n\t\t\t\t\t)?.status;\n\n\t\t\t\t\tlet status;\n\t\t\t\t\tswitch ( resolutionStatus ) {\n\t\t\t\t\t\tcase 'resolving':\n\t\t\t\t\t\t\tstatus = Status.Resolving;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 'finished':\n\t\t\t\t\t\t\tstatus = Status.Success;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 'error':\n\t\t\t\t\t\t\tstatus = Status.Error;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase undefined:\n\t\t\t\t\t\t\tstatus = Status.Idle;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tdata,\n\t\t\t\t\t\tstatus,\n\t\t\t\t\t\tisResolving: status === Status.Resolving,\n\t\t\t\t\t\thasStarted: status !== Status.Idle,\n\t\t\t\t\t\thasResolved:\n\t\t\t\t\t\t\tstatus === Status.Success ||\n\t\t\t\t\t\t\tstatus === Status.Error,\n\t\t\t\t\t};\n\t\t\t\t},\n\t\t} );\n\t}\n\treturn resolvers;\n} ) as EnrichedSelectors );\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAA0B;AAK1B,qBAAoB;AACpB,uBAAuB;AAEhB,IAAM,iBAAiB;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;AA2De,SAAR,eAAiC,gBAAgB,MAAO;AAC9D,aAAO,uBAAW,CAAE,QAAQ,aAAc;AACzC,UAAM,UAAU,CAAE,UAAW,gBAAiB,OAAQ,KAAM,CAAE;AAC9D,WAAO,eAAgB,SAAS,QAAS;AAAA,EAC1C,GAAG,IAAK;AACT;AAmBA,IAAM,sBAAkB,eAAAA,UAAW,CAAE,cAAe;AACnD,QAAM,YAAY,CAAC;AACnB,aAAY,gBAAgB,WAAY;AACvC,QAAK,eAAe,SAAU,YAAa,GAAI;AAC9C;AAAA,IACD;AACA,WAAO,eAAgB,WAAW,cAAc;AAAA,MAC/C,KACC,MACA,IAAK,SAAqB;AACzB,cAAM,OAAO,UAAW,YAAa,EAAG,GAAG,IAAK;AAChD,cAAM,mBAAmB,UAAU;AAAA,UAClC;AAAA,UACA;AAAA,QACD,GAAG;AAEH,YAAI;AACJ,gBAAS,kBAAmB;AAAA,UAC3B,KAAK;AACJ,qBAAS,wBAAO;AAChB;AAAA,UACD,KAAK;AACJ,qBAAS,wBAAO;AAChB;AAAA,UACD,KAAK;AACJ,qBAAS,wBAAO;AAChB;AAAA,UACD,KAAK;AACJ,qBAAS,wBAAO;AAChB;AAAA,QACF;AAEA,eAAO;AAAA,UACN;AAAA,UACA;AAAA,UACA,aAAa,WAAW,wBAAO;AAAA,UAC/B,YAAY,WAAW,wBAAO;AAAA,UAC9B,aACC,WAAW,wBAAO,WAClB,WAAW,wBAAO;AAAA,QACpB;AAAA,MACD;AAAA,IACF,CAAE;AAAA,EACH;AACA,SAAO;AACR,EAAyB;",
|
|
6
6
|
"names": ["memoize"]
|
|
7
7
|
}
|
|
@@ -26,6 +26,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
mod
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// packages/core-data/src/hooks/use-resource-permissions.ts
|
|
29
31
|
var use_resource_permissions_exports = {};
|
|
30
32
|
__export(use_resource_permissions_exports, {
|
|
31
33
|
__experimentalUseResourcePermissions: () => __experimentalUseResourcePermissions,
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/hooks/use-resource-permissions.ts"],
|
|
4
4
|
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\nimport warning from '@wordpress/warning';\n\n/**\n * Internal dependencies\n */\nimport { store as coreStore } from '../';\nimport { Status } from './constants';\nimport useQuerySelect from './use-query-select';\n\ninterface GlobalResourcePermissionsResolution {\n\t/** Can the current user create new resources of this type? */\n\tcanCreate: boolean;\n}\ninterface SpecificResourcePermissionsResolution {\n\t/** Can the current user update resources of this type? */\n\tcanUpdate: boolean;\n\t/** Can the current user delete resources of this type? */\n\tcanDelete: boolean;\n}\ninterface ResolutionDetails {\n\t/** Resolution status */\n\tstatus: Status;\n\t/**\n\t * Is the data still being resolved?\n\t */\n\tisResolving: boolean;\n}\n\n/**\n * Is the data resolved by now?\n */\ntype HasResolved = boolean;\n\ntype ResourcePermissionsResolution< IdType > = [\n\tHasResolved,\n\tResolutionDetails &\n\t\tGlobalResourcePermissionsResolution &\n\t\t( IdType extends void ? SpecificResourcePermissionsResolution : {} ),\n];\n\ntype EntityResource = { kind: string; name: string; id?: string | number };\n\nfunction useResourcePermissions< IdType = void >(\n\tresource: string,\n\tid?: IdType\n): ResourcePermissionsResolution< IdType >;\n\nfunction useResourcePermissions< IdType = void >(\n\tresource: EntityResource,\n\tid?: never\n): ResourcePermissionsResolution< IdType >;\n\n/**\n * Resolves resource permissions.\n *\n * @since 6.1.0 Introduced in WordPress core.\n *\n * @param resource Entity resource to check. Accepts entity object `{ kind: 'postType', name: 'attachment', id: 1 }`\n * or REST base as a string - `media`.\n * @param id Optional ID of the resource to check, e.g. 10. Note: This argument is discouraged\n * when using an entity object as a resource to check permissions and will be ignored.\n *\n * @example\n * ```js\n * import { useResourcePermissions } from '@wordpress/core-data';\n *\n * function PagesList() {\n * const { canCreate, isResolving } = useResourcePermissions( { kind: 'postType', name: 'page' } );\n *\n * if ( isResolving ) {\n * return 'Loading ...';\n * }\n *\n * return (\n * <div>\n * {canCreate ? (<button>+ Create a new page</button>) : false}\n * // ...\n * </div>\n * );\n * }\n *\n * // Rendered in the application:\n * // <PagesList />\n * ```\n *\n * @example\n * ```js\n * import { useResourcePermissions } from '@wordpress/core-data';\n *\n * function Page({ pageId }) {\n * const {\n * canCreate,\n * canUpdate,\n * canDelete,\n * isResolving\n * } = useResourcePermissions( { kind: 'postType', name: 'page', id: pageId } );\n *\n * if ( isResolving ) {\n * return 'Loading ...';\n * }\n *\n * return (\n * <div>\n * {canCreate ? (<button>+ Create a new page</button>) : false}\n * {canUpdate ? (<button>Edit page</button>) : false}\n * {canDelete ? (<button>Delete page</button>) : false}\n * // ...\n * </div>\n * );\n * }\n *\n * // Rendered in the application:\n * // <Page pageId={ 15 } />\n * ```\n *\n * In the above example, when `PagesList` is rendered into an\n * application, the appropriate permissions and the resolution details will be retrieved from\n * the store state using `canUser()`, or resolved if missing.\n *\n * @return Entity records data.\n * @template IdType\n */\nfunction useResourcePermissions< IdType = void >(\n\tresource: string | EntityResource,\n\tid?: IdType\n): ResourcePermissionsResolution< IdType > {\n\t// Serialize `resource` to a string that can be safely used as a React dep.\n\t// We can't just pass `resource` as one of the deps, because if it is passed\n\t// as an object literal, then it will be a different object on each call even\n\t// if the values remain the same.\n\tconst isEntity = typeof resource === 'object';\n\tconst resourceAsString = isEntity ? JSON.stringify( resource ) : resource;\n\n\tif ( isEntity && typeof id !== 'undefined' ) {\n\t\twarning(\n\t\t\t`When 'resource' is an entity object, passing 'id' as a separate argument isn't supported.`\n\t\t);\n\t}\n\n\treturn useQuerySelect(\n\t\t( resolve ) => {\n\t\t\tconst hasId = isEntity ? !! resource.id : !! id;\n\t\t\tconst { canUser } = resolve( coreStore );\n\t\t\tconst create = canUser(\n\t\t\t\t'create',\n\t\t\t\tisEntity\n\t\t\t\t\t? { kind: resource.kind, name: resource.name }\n\t\t\t\t\t: resource\n\t\t\t);\n\n\t\t\tif ( ! hasId ) {\n\t\t\t\tconst read = canUser( 'read', resource );\n\n\t\t\t\tconst isResolving = create.isResolving || read.isResolving;\n\t\t\t\tconst hasResolved = create.hasResolved && read.hasResolved;\n\t\t\t\tlet status = Status.Idle;\n\t\t\t\tif ( isResolving ) {\n\t\t\t\t\tstatus = Status.Resolving;\n\t\t\t\t} else if ( hasResolved ) {\n\t\t\t\t\tstatus = Status.Success;\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\tstatus,\n\t\t\t\t\tisResolving,\n\t\t\t\t\thasResolved,\n\t\t\t\t\tcanCreate: create.hasResolved && create.data,\n\t\t\t\t\tcanRead: read.hasResolved && read.data,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst read = canUser( 'read', resource, id );\n\t\t\tconst update = canUser( 'update', resource, id );\n\t\t\tconst _delete = canUser( 'delete', resource, id );\n\t\t\tconst isResolving =\n\t\t\t\tread.isResolving ||\n\t\t\t\tcreate.isResolving ||\n\t\t\t\tupdate.isResolving ||\n\t\t\t\t_delete.isResolving;\n\t\t\tconst hasResolved =\n\t\t\t\tread.hasResolved &&\n\t\t\t\tcreate.hasResolved &&\n\t\t\t\tupdate.hasResolved &&\n\t\t\t\t_delete.hasResolved;\n\n\t\t\tlet status = Status.Idle;\n\t\t\tif ( isResolving ) {\n\t\t\t\tstatus = Status.Resolving;\n\t\t\t} else if ( hasResolved ) {\n\t\t\t\tstatus = Status.Success;\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tstatus,\n\t\t\t\tisResolving,\n\t\t\t\thasResolved,\n\t\t\t\tcanRead: hasResolved && read.data,\n\t\t\t\tcanCreate: hasResolved && create.data,\n\t\t\t\tcanUpdate: hasResolved && update.data,\n\t\t\t\tcanDelete: hasResolved && _delete.data,\n\t\t\t};\n\t\t},\n\t\t[ resourceAsString, id ]\n\t);\n}\n\nexport default useResourcePermissions;\n\nexport function __experimentalUseResourcePermissions(\n\tresource: string,\n\tid?: unknown\n) {\n\tdeprecated( `wp.data.__experimentalUseResourcePermissions`, {\n\t\talternative: 'wp.data.useResourcePermissions',\n\t\tsince: '6.1',\n\t} );\n\treturn useResourcePermissions( resource, id );\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAAuB;AACvB,qBAAoB;AAKpB,eAAmC;AACnC,uBAAuB;AACvB,8BAA2B;AAmH3B,SAAS,uBACR,UACA,IAC0C;AAK1C,QAAM,WAAW,OAAO,aAAa;AACrC,QAAM,mBAAmB,WAAW,KAAK,UAAW,QAAS,IAAI;AAEjE,MAAK,YAAY,OAAO,OAAO,aAAc;AAC5C,uBAAAA;AAAA,MACC;AAAA,IACD;AAAA,EACD;AAEA,aAAO,wBAAAC;AAAA,IACN,CAAE,YAAa;AACd,YAAM,QAAQ,WAAW,CAAC,CAAE,SAAS,KAAK,CAAC,CAAE;AAC7C,YAAM,EAAE,QAAQ,IAAI,QAAS,SAAAC,KAAU;AACvC,YAAM,SAAS;AAAA,QACd;AAAA,QACA,WACG,EAAE,MAAM,SAAS,MAAM,MAAM,SAAS,KAAK,IAC3C;AAAA,MACJ;AAEA,UAAK,CAAE,OAAQ;AACd,cAAMC,QAAO,QAAS,QAAQ,QAAS;AAEvC,cAAMC,eAAc,OAAO,eAAeD,MAAK;AAC/C,cAAME,eAAc,OAAO,eAAeF,MAAK;AAC/C,YAAIG,UAAS,wBAAO;AACpB,YAAKF,cAAc;AAClB,UAAAE,UAAS,wBAAO;AAAA,QACjB,WAAYD,cAAc;AACzB,UAAAC,UAAS,wBAAO;AAAA,QACjB;AAEA,eAAO;AAAA,UACN,QAAAA;AAAA,UACA,aAAAF;AAAA,UACA,aAAAC;AAAA,UACA,WAAW,OAAO,eAAe,OAAO;AAAA,UACxC,SAASF,MAAK,eAAeA,MAAK;AAAA,QACnC;AAAA,MACD;AAEA,YAAM,OAAO,QAAS,QAAQ,UAAU,EAAG;AAC3C,YAAM,SAAS,QAAS,UAAU,UAAU,EAAG;AAC/C,YAAM,UAAU,QAAS,UAAU,UAAU,EAAG;AAChD,YAAM,cACL,KAAK,eACL,OAAO,eACP,OAAO,eACP,QAAQ;AACT,YAAM,cACL,KAAK,eACL,OAAO,eACP,OAAO,eACP,QAAQ;AAET,UAAI,SAAS,wBAAO;AACpB,UAAK,aAAc;AAClB,iBAAS,wBAAO;AAAA,MACjB,WAAY,aAAc;AACzB,iBAAS,wBAAO;AAAA,MACjB;AACA,aAAO;AAAA,QACN;AAAA,QACA;AAAA,QACA;AAAA,QACA,SAAS,eAAe,KAAK;AAAA,QAC7B,WAAW,eAAe,OAAO;AAAA,QACjC,WAAW,eAAe,OAAO;AAAA,QACjC,WAAW,eAAe,QAAQ;AAAA,MACnC;AAAA,IACD;AAAA,IACA,CAAE,kBAAkB,EAAG;AAAA,EACxB;AACD;AAEA,IAAO,mCAAQ;AAER,SAAS,qCACf,UACA,IACC;AACD,wBAAAI,SAAY,gDAAgD;AAAA,IAC3D,aAAa;AAAA,IACb,OAAO;AAAA,EACR,CAAE;AACF,SAAO,uBAAwB,UAAU,EAAG;AAC7C;",
|
|
6
6
|
"names": ["warning", "useQuerySelect", "coreStore", "read", "isResolving", "hasResolved", "status", "deprecated"]
|
|
7
7
|
}
|
package/build/index.js
CHANGED
|
@@ -27,6 +27,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
27
|
mod
|
|
28
28
|
));
|
|
29
29
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
|
|
31
|
+
// packages/core-data/src/index.js
|
|
30
32
|
var index_exports = {};
|
|
31
33
|
__export(index_exports, {
|
|
32
34
|
EntityProvider: () => import_entity_provider.default,
|
|
@@ -52,11 +54,11 @@ __reExport(index_exports, require("./entity-types"), module.exports);
|
|
|
52
54
|
__reExport(index_exports, require("./fetch"), module.exports);
|
|
53
55
|
__reExport(index_exports, require("./hooks"), module.exports);
|
|
54
56
|
__reExport(index_exports, require("./private-apis"), module.exports);
|
|
55
|
-
|
|
57
|
+
var entitiesConfig = [
|
|
56
58
|
...import_entities.rootEntitiesConfig,
|
|
57
59
|
...import_entities.additionalEntityConfigLoaders.filter((config) => !!config.name)
|
|
58
60
|
];
|
|
59
|
-
|
|
61
|
+
var entitySelectors = entitiesConfig.reduce((result, entity) => {
|
|
60
62
|
const { kind, name, plural } = entity;
|
|
61
63
|
const getEntityRecordMethodName = (0, import_entities.getMethodName)(kind, name);
|
|
62
64
|
result[getEntityRecordMethodName] = (state, key, query) => {
|
|
@@ -78,7 +80,7 @@ const entitySelectors = entitiesConfig.reduce((result, entity) => {
|
|
|
78
80
|
}
|
|
79
81
|
return result;
|
|
80
82
|
}, {});
|
|
81
|
-
|
|
83
|
+
var entityResolvers = entitiesConfig.reduce((result, entity) => {
|
|
82
84
|
const { kind, name, plural } = entity;
|
|
83
85
|
const getEntityRecordMethodName = (0, import_entities.getMethodName)(kind, name);
|
|
84
86
|
result[getEntityRecordMethodName] = (key, query) => {
|
|
@@ -101,7 +103,7 @@ const entityResolvers = entitiesConfig.reduce((result, entity) => {
|
|
|
101
103
|
}
|
|
102
104
|
return result;
|
|
103
105
|
}, {});
|
|
104
|
-
|
|
106
|
+
var entityActions = entitiesConfig.reduce((result, entity) => {
|
|
105
107
|
const { kind, name } = entity;
|
|
106
108
|
const saveEntityRecordMethodName = (0, import_entities.getMethodName)(kind, name, "save");
|
|
107
109
|
result[saveEntityRecordMethodName] = (record, options) => {
|
|
@@ -121,7 +123,7 @@ const entityActions = entitiesConfig.reduce((result, entity) => {
|
|
|
121
123
|
};
|
|
122
124
|
return result;
|
|
123
125
|
}, {});
|
|
124
|
-
|
|
126
|
+
var storeConfig = () => ({
|
|
125
127
|
reducer: import_reducer.default,
|
|
126
128
|
actions: {
|
|
127
129
|
...import_dynamic_entities.dynamicActions,
|
|
@@ -136,7 +138,7 @@ const storeConfig = () => ({
|
|
|
136
138
|
},
|
|
137
139
|
resolvers: { ...resolvers, ...entityResolvers }
|
|
138
140
|
});
|
|
139
|
-
|
|
141
|
+
var store = (0, import_data.createReduxStore)(import_name.STORE_NAME, storeConfig());
|
|
140
142
|
(0, import_lock_unlock.unlock)(store).registerPrivateSelectors(privateSelectors);
|
|
141
143
|
(0, import_lock_unlock.unlock)(store).registerPrivateActions(privateActions);
|
|
142
144
|
(0, import_data.register)(store);
|
package/build/index.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.js"],
|
|
4
4
|
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createReduxStore, register } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport reducer from './reducer';\nimport * as selectors from './selectors';\nimport * as privateSelectors from './private-selectors';\nimport * as actions from './actions';\nimport * as privateActions from './private-actions';\nimport * as resolvers from './resolvers';\nimport createLocksActions from './locks/actions';\nimport {\n\trootEntitiesConfig,\n\tadditionalEntityConfigLoaders,\n\tgetMethodName,\n} from './entities';\nimport { STORE_NAME } from './name';\nimport { unlock } from './lock-unlock';\nimport { dynamicActions, dynamicSelectors } from './dynamic-entities';\nimport logEntityDeprecation from './utils/log-entity-deprecation';\n\n// The entity selectors/resolvers and actions are shortcuts to their generic equivalents\n// (getEntityRecord, getEntityRecords, updateEntityRecord, updateEntityRecords)\n// Instead of getEntityRecord, the consumer could use more user-friendly named selector: getPostType, getTaxonomy...\n// The \"kind\" and the \"name\" of the entity are combined to generate these shortcuts.\nconst entitiesConfig = [\n\t...rootEntitiesConfig,\n\t...additionalEntityConfigLoaders.filter( ( config ) => !! config.name ),\n];\n\nconst entitySelectors = entitiesConfig.reduce( ( result, entity ) => {\n\tconst { kind, name, plural } = entity;\n\n\tconst getEntityRecordMethodName = getMethodName( kind, name );\n\tresult[ getEntityRecordMethodName ] = ( state, key, query ) => {\n\t\tlogEntityDeprecation( kind, name, getEntityRecordMethodName, {\n\t\t\tisShorthandSelector: true,\n\t\t\talternativeFunctionName: 'getEntityRecord',\n\t\t} );\n\t\treturn selectors.getEntityRecord( state, kind, name, key, query );\n\t};\n\n\tif ( plural ) {\n\t\tconst getEntityRecordsMethodName = getMethodName( kind, plural, 'get' );\n\t\tresult[ getEntityRecordsMethodName ] = ( state, query ) => {\n\t\t\tlogEntityDeprecation( kind, name, getEntityRecordsMethodName, {\n\t\t\t\tisShorthandSelector: true,\n\t\t\t\talternativeFunctionName: 'getEntityRecords',\n\t\t\t} );\n\t\t\treturn selectors.getEntityRecords( state, kind, name, query );\n\t\t};\n\t}\n\treturn result;\n}, {} );\n\nconst entityResolvers = entitiesConfig.reduce( ( result, entity ) => {\n\tconst { kind, name, plural } = entity;\n\tconst getEntityRecordMethodName = getMethodName( kind, name );\n\tresult[ getEntityRecordMethodName ] = ( key, query ) => {\n\t\tlogEntityDeprecation( kind, name, getEntityRecordMethodName, {\n\t\t\tisShorthandSelector: true,\n\t\t\talternativeFunctionName: 'getEntityRecord',\n\t\t} );\n\t\treturn resolvers.getEntityRecord( kind, name, key, query );\n\t};\n\n\tif ( plural ) {\n\t\tconst getEntityRecordsMethodName = getMethodName( kind, plural, 'get' );\n\t\tresult[ getEntityRecordsMethodName ] = ( ...args ) => {\n\t\t\tlogEntityDeprecation( kind, plural, getEntityRecordsMethodName, {\n\t\t\t\tisShorthandSelector: true,\n\t\t\t\talternativeFunctionName: 'getEntityRecords',\n\t\t\t} );\n\t\t\treturn resolvers.getEntityRecords( kind, name, ...args );\n\t\t};\n\t\tresult[ getEntityRecordsMethodName ].shouldInvalidate = ( action ) =>\n\t\t\tresolvers.getEntityRecords.shouldInvalidate( action, kind, name );\n\t}\n\treturn result;\n}, {} );\n\nconst entityActions = entitiesConfig.reduce( ( result, entity ) => {\n\tconst { kind, name } = entity;\n\n\tconst saveEntityRecordMethodName = getMethodName( kind, name, 'save' );\n\tresult[ saveEntityRecordMethodName ] = ( record, options ) => {\n\t\tlogEntityDeprecation( kind, name, saveEntityRecordMethodName, {\n\t\t\tisShorthandSelector: true,\n\t\t\talternativeFunctionName: 'saveEntityRecord',\n\t\t} );\n\t\treturn actions.saveEntityRecord( kind, name, record, options );\n\t};\n\n\tconst deleteEntityRecordMethodName = getMethodName( kind, name, 'delete' );\n\tresult[ deleteEntityRecordMethodName ] = ( key, query, options ) => {\n\t\tlogEntityDeprecation( kind, name, deleteEntityRecordMethodName, {\n\t\t\tisShorthandSelector: true,\n\t\t\talternativeFunctionName: 'deleteEntityRecord',\n\t\t} );\n\t\treturn actions.deleteEntityRecord( kind, name, key, query, options );\n\t};\n\n\treturn result;\n}, {} );\n\nconst storeConfig = () => ( {\n\treducer,\n\tactions: {\n\t\t...dynamicActions,\n\t\t...actions,\n\t\t...entityActions,\n\t\t...createLocksActions(),\n\t},\n\tselectors: {\n\t\t...dynamicSelectors,\n\t\t...selectors,\n\t\t...entitySelectors,\n\t},\n\tresolvers: { ...resolvers, ...entityResolvers },\n} );\n\n/**\n * Store definition for the code data namespace.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore\n */\nexport const store = createReduxStore( STORE_NAME, storeConfig() );\nunlock( store ).registerPrivateSelectors( privateSelectors );\nunlock( store ).registerPrivateActions( privateActions );\nregister( store ); // Register store after unlocking private selectors to allow resolvers to use them.\n\nexport { default as EntityProvider } from './entity-provider';\nexport * from './entity-provider';\nexport * from './entity-types';\nexport * from './fetch';\nexport * from './hooks';\nexport * from './private-apis';\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAA2C;AAK3C,qBAAoB;AACpB,gBAA2B;AAC3B,uBAAkC;AAClC,cAAyB;AACzB,qBAAgC;AAChC,gBAA2B;AAC3B,qBAA+B;AAC/B,sBAIO;AACP,kBAA2B;AAC3B,yBAAuB;AACvB,8BAAiD;AACjD,oCAAiC;AAgHjC,6BAA0C;AAC1C,0BAAc,8BAxId;AAyIA,0BAAc,2BAzId;AA0IA,0BAAc,oBA1Id;AA2IA,0BAAc,oBA3Id;AA4IA,0BAAc,2BA5Id;AA6BA,IAAM,iBAAiB;AAAA,EACtB,GAAG;AAAA,EACH,GAAG,8CAA8B,OAAQ,CAAE,WAAY,CAAC,CAAE,OAAO,IAAK;AACvE;AAEA,IAAM,kBAAkB,eAAe,OAAQ,CAAE,QAAQ,WAAY;AACpE,QAAM,EAAE,MAAM,MAAM,OAAO,IAAI;AAE/B,QAAM,gCAA4B,+BAAe,MAAM,IAAK;AAC5D,SAAQ,yBAA0B,IAAI,CAAE,OAAO,KAAK,UAAW;AAC9D,sCAAAA,SAAsB,MAAM,MAAM,2BAA2B;AAAA,MAC5D,qBAAqB;AAAA,MACrB,yBAAyB;AAAA,IAC1B,CAAE;AACF,WAAiB,0BAAiB,OAAO,MAAM,MAAM,KAAK,KAAM;AAAA,EACjE;AAEA,MAAK,QAAS;AACb,UAAM,iCAA6B,+BAAe,MAAM,QAAQ,KAAM;AACtE,WAAQ,0BAA2B,IAAI,CAAE,OAAO,UAAW;AAC1D,wCAAAA,SAAsB,MAAM,MAAM,4BAA4B;AAAA,QAC7D,qBAAqB;AAAA,QACrB,yBAAyB;AAAA,MAC1B,CAAE;AACF,aAAiB,2BAAkB,OAAO,MAAM,MAAM,KAAM;AAAA,IAC7D;AAAA,EACD;AACA,SAAO;AACR,GAAG,CAAC,CAAE;AAEN,IAAM,kBAAkB,eAAe,OAAQ,CAAE,QAAQ,WAAY;AACpE,QAAM,EAAE,MAAM,MAAM,OAAO,IAAI;AAC/B,QAAM,gCAA4B,+BAAe,MAAM,IAAK;AAC5D,SAAQ,yBAA0B,IAAI,CAAE,KAAK,UAAW;AACvD,sCAAAA,SAAsB,MAAM,MAAM,2BAA2B;AAAA,MAC5D,qBAAqB;AAAA,MACrB,yBAAyB;AAAA,IAC1B,CAAE;AACF,WAAiB,0BAAiB,MAAM,MAAM,KAAK,KAAM;AAAA,EAC1D;AAEA,MAAK,QAAS;AACb,UAAM,iCAA6B,+BAAe,MAAM,QAAQ,KAAM;AACtE,WAAQ,0BAA2B,IAAI,IAAK,SAAU;AACrD,wCAAAA,SAAsB,MAAM,QAAQ,4BAA4B;AAAA,QAC/D,qBAAqB;AAAA,QACrB,yBAAyB;AAAA,MAC1B,CAAE;AACF,aAAiB,2BAAkB,MAAM,MAAM,GAAG,IAAK;AAAA,IACxD;AACA,WAAQ,0BAA2B,EAAE,mBAAmB,CAAE,WAC/C,2BAAiB,iBAAkB,QAAQ,MAAM,IAAK;AAAA,EAClE;AACA,SAAO;AACR,GAAG,CAAC,CAAE;AAEN,IAAM,gBAAgB,eAAe,OAAQ,CAAE,QAAQ,WAAY;AAClE,QAAM,EAAE,MAAM,KAAK,IAAI;AAEvB,QAAM,iCAA6B,+BAAe,MAAM,MAAM,MAAO;AACrE,SAAQ,0BAA2B,IAAI,CAAE,QAAQ,YAAa;AAC7D,sCAAAA,SAAsB,MAAM,MAAM,4BAA4B;AAAA,MAC7D,qBAAqB;AAAA,MACrB,yBAAyB;AAAA,IAC1B,CAAE;AACF,WAAe,yBAAkB,MAAM,MAAM,QAAQ,OAAQ;AAAA,EAC9D;AAEA,QAAM,mCAA+B,+BAAe,MAAM,MAAM,QAAS;AACzE,SAAQ,4BAA6B,IAAI,CAAE,KAAK,OAAO,YAAa;AACnE,sCAAAA,SAAsB,MAAM,MAAM,8BAA8B;AAAA,MAC/D,qBAAqB;AAAA,MACrB,yBAAyB;AAAA,IAC1B,CAAE;AACF,WAAe,2BAAoB,MAAM,MAAM,KAAK,OAAO,OAAQ;AAAA,EACpE;AAEA,SAAO;AACR,GAAG,CAAC,CAAE;AAEN,IAAM,cAAc,OAAQ;AAAA,EAC3B,wBAAAC;AAAA,EACA,SAAS;AAAA,IACR,GAAG;AAAA,IACH,GAAG;AAAA,IACH,GAAG;AAAA,IACH,OAAG,eAAAC,SAAmB;AAAA,EACvB;AAAA,EACA,WAAW;AAAA,IACV,GAAG;AAAA,IACH,GAAG;AAAA,IACH,GAAG;AAAA,EACJ;AAAA,EACA,WAAW,EAAE,GAAG,WAAW,GAAG,gBAAgB;AAC/C;AAOO,IAAM,YAAQ,8BAAkB,wBAAY,YAAY,CAAE;AAAA,IACjE,2BAAQ,KAAM,EAAE,yBAA0B,gBAAiB;AAAA,IAC3D,2BAAQ,KAAM,EAAE,uBAAwB,cAAe;AAAA,IACvD,sBAAU,KAAM;",
|
|
6
6
|
"names": ["logEntityDeprecation", "reducer", "createLocksActions"]
|
|
7
7
|
}
|
package/build/lock-unlock.js
CHANGED
|
@@ -16,6 +16,8 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// packages/core-data/src/lock-unlock.ts
|
|
19
21
|
var lock_unlock_exports = {};
|
|
20
22
|
__export(lock_unlock_exports, {
|
|
21
23
|
lock: () => lock,
|
|
@@ -23,7 +25,7 @@ __export(lock_unlock_exports, {
|
|
|
23
25
|
});
|
|
24
26
|
module.exports = __toCommonJS(lock_unlock_exports);
|
|
25
27
|
var import_private_apis = require("@wordpress/private-apis");
|
|
26
|
-
|
|
28
|
+
var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
|
|
27
29
|
"I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
|
|
28
30
|
"@wordpress/core-data"
|
|
29
31
|
);
|
package/build/lock-unlock.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/lock-unlock.ts"],
|
|
4
4
|
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';\n\nexport const { lock, unlock } =\n\t__dangerousOptInToUnstableAPIsOnlyForCoreModules(\n\t\t'I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.',\n\t\t'@wordpress/core-data'\n\t);\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,0BAAiE;AAE1D,IAAM,EAAE,MAAM,OAAO,QAC3B;AAAA,EACC;AAAA,EACA;AACD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/build/locks/actions.js
CHANGED
|
@@ -26,6 +26,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
mod
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// packages/core-data/src/locks/actions.js
|
|
29
31
|
var actions_exports = {};
|
|
30
32
|
__export(actions_exports, {
|
|
31
33
|
default: () => createLocksActions
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/locks/actions.js"],
|
|
4
4
|
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport createLocks from './engine';\n\nexport default function createLocksActions() {\n\tconst locks = createLocks();\n\n\tfunction __unstableAcquireStoreLock( store, path, { exclusive } ) {\n\t\treturn () => locks.acquire( store, path, exclusive );\n\t}\n\n\tfunction __unstableReleaseStoreLock( lock ) {\n\t\treturn () => locks.release( lock );\n\t}\n\n\treturn { __unstableAcquireStoreLock, __unstableReleaseStoreLock };\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAAwB;AAET,SAAR,qBAAsC;AAC5C,QAAM,YAAQ,cAAAA,SAAY;AAE1B,WAAS,2BAA4B,OAAO,MAAM,EAAE,UAAU,GAAI;AACjE,WAAO,MAAM,MAAM,QAAS,OAAO,MAAM,SAAU;AAAA,EACpD;AAEA,WAAS,2BAA4B,MAAO;AAC3C,WAAO,MAAM,MAAM,QAAS,IAAK;AAAA,EAClC;AAEA,SAAO,EAAE,4BAA4B,2BAA2B;AACjE;",
|
|
6
6
|
"names": ["createLocks"]
|
|
7
7
|
}
|
package/build/locks/engine.js
CHANGED
|
@@ -26,6 +26,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
mod
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// packages/core-data/src/locks/engine.js
|
|
29
31
|
var engine_exports = {};
|
|
30
32
|
__export(engine_exports, {
|
|
31
33
|
default: () => createLocks
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/locks/engine.js"],
|
|
4
4
|
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport reducer from './reducer';\nimport { isLockAvailable, getPendingLockRequests } from './selectors';\n\nexport default function createLocks() {\n\tlet state = reducer( undefined, { type: '@@INIT' } );\n\n\tfunction processPendingLockRequests() {\n\t\tfor ( const request of getPendingLockRequests( state ) ) {\n\t\t\tconst { store, path, exclusive, notifyAcquired } = request;\n\t\t\tif ( isLockAvailable( state, store, path, { exclusive } ) ) {\n\t\t\t\tconst lock = { store, path, exclusive };\n\t\t\t\tstate = reducer( state, {\n\t\t\t\t\ttype: 'GRANT_LOCK_REQUEST',\n\t\t\t\t\tlock,\n\t\t\t\t\trequest,\n\t\t\t\t} );\n\t\t\t\tnotifyAcquired( lock );\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction acquire( store, path, exclusive ) {\n\t\treturn new Promise( ( resolve ) => {\n\t\t\tstate = reducer( state, {\n\t\t\t\ttype: 'ENQUEUE_LOCK_REQUEST',\n\t\t\t\trequest: { store, path, exclusive, notifyAcquired: resolve },\n\t\t\t} );\n\t\t\tprocessPendingLockRequests();\n\t\t} );\n\t}\n\tfunction release( lock ) {\n\t\tstate = reducer( state, {\n\t\t\ttype: 'RELEASE_LOCK',\n\t\t\tlock,\n\t\t} );\n\t\tprocessPendingLockRequests();\n\t}\n\n\treturn { acquire, release };\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAoB;AACpB,uBAAwD;AAEzC,SAAR,cAA+B;AACrC,MAAI,YAAQ,eAAAA,SAAS,QAAW,EAAE,MAAM,SAAS,CAAE;AAEnD,WAAS,6BAA6B;AACrC,eAAY,eAAW,yCAAwB,KAAM,GAAI;AACxD,YAAM,EAAE,OAAO,MAAM,WAAW,eAAe,IAAI;AACnD,cAAK,kCAAiB,OAAO,OAAO,MAAM,EAAE,UAAU,CAAE,GAAI;AAC3D,cAAM,OAAO,EAAE,OAAO,MAAM,UAAU;AACtC,oBAAQ,eAAAA,SAAS,OAAO;AAAA,UACvB,MAAM;AAAA,UACN;AAAA,UACA;AAAA,QACD,CAAE;AACF,uBAAgB,IAAK;AAAA,MACtB;AAAA,IACD;AAAA,EACD;AAEA,WAAS,QAAS,OAAO,MAAM,WAAY;AAC1C,WAAO,IAAI,QAAS,CAAE,YAAa;AAClC,kBAAQ,eAAAA,SAAS,OAAO;AAAA,QACvB,MAAM;AAAA,QACN,SAAS,EAAE,OAAO,MAAM,WAAW,gBAAgB,QAAQ;AAAA,MAC5D,CAAE;AACF,iCAA2B;AAAA,IAC5B,CAAE;AAAA,EACH;AACA,WAAS,QAAS,MAAO;AACxB,gBAAQ,eAAAA,SAAS,OAAO;AAAA,MACvB,MAAM;AAAA,MACN;AAAA,IACD,CAAE;AACF,+BAA2B;AAAA,EAC5B;AAEA,SAAO,EAAE,SAAS,QAAQ;AAC3B;",
|
|
6
6
|
"names": ["reducer"]
|
|
7
7
|
}
|
package/build/locks/reducer.js
CHANGED
|
@@ -16,13 +16,15 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// packages/core-data/src/locks/reducer.js
|
|
19
21
|
var reducer_exports = {};
|
|
20
22
|
__export(reducer_exports, {
|
|
21
23
|
default: () => locks
|
|
22
24
|
});
|
|
23
25
|
module.exports = __toCommonJS(reducer_exports);
|
|
24
26
|
var import_utils = require("./utils");
|
|
25
|
-
|
|
27
|
+
var DEFAULT_STATE = {
|
|
26
28
|
requests: [],
|
|
27
29
|
tree: {
|
|
28
30
|
locks: [],
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/locks/reducer.js"],
|
|
4
4
|
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport { getNode, deepCopyLocksTreePath } from './utils';\n\nconst DEFAULT_STATE = {\n\trequests: [],\n\ttree: {\n\t\tlocks: [],\n\t\tchildren: {},\n\t},\n};\n\n/**\n * Reducer returning locks.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport default function locks( state = DEFAULT_STATE, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'ENQUEUE_LOCK_REQUEST': {\n\t\t\tconst { request } = action;\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\trequests: [ request, ...state.requests ],\n\t\t\t};\n\t\t}\n\t\tcase 'GRANT_LOCK_REQUEST': {\n\t\t\tconst { lock, request } = action;\n\t\t\tconst { store, path } = request;\n\t\t\tconst storePath = [ store, ...path ];\n\n\t\t\tconst newTree = deepCopyLocksTreePath( state.tree, storePath );\n\t\t\tconst node = getNode( newTree, storePath );\n\t\t\tnode.locks = [ ...node.locks, lock ];\n\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\trequests: state.requests.filter( ( r ) => r !== request ),\n\t\t\t\ttree: newTree,\n\t\t\t};\n\t\t}\n\t\tcase 'RELEASE_LOCK': {\n\t\t\tconst { lock } = action;\n\t\t\tconst storePath = [ lock.store, ...lock.path ];\n\n\t\t\tconst newTree = deepCopyLocksTreePath( state.tree, storePath );\n\t\t\tconst node = getNode( newTree, storePath );\n\t\t\tnode.locks = node.locks.filter( ( l ) => l !== lock );\n\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\ttree: newTree,\n\t\t\t};\n\t\t}\n\t}\n\n\treturn state;\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,mBAA+C;AAE/C,IAAM,gBAAgB;AAAA,EACrB,UAAU,CAAC;AAAA,EACX,MAAM;AAAA,IACL,OAAO,CAAC;AAAA,IACR,UAAU,CAAC;AAAA,EACZ;AACD;AAUe,SAAR,MAAwB,QAAQ,eAAe,QAAS;AAC9D,UAAS,OAAO,MAAO;AAAA,IACtB,KAAK,wBAAwB;AAC5B,YAAM,EAAE,QAAQ,IAAI;AACpB,aAAO;AAAA,QACN,GAAG;AAAA,QACH,UAAU,CAAE,SAAS,GAAG,MAAM,QAAS;AAAA,MACxC;AAAA,IACD;AAAA,IACA,KAAK,sBAAsB;AAC1B,YAAM,EAAE,MAAM,QAAQ,IAAI;AAC1B,YAAM,EAAE,OAAO,KAAK,IAAI;AACxB,YAAM,YAAY,CAAE,OAAO,GAAG,IAAK;AAEnC,YAAM,cAAU,oCAAuB,MAAM,MAAM,SAAU;AAC7D,YAAM,WAAO,sBAAS,SAAS,SAAU;AACzC,WAAK,QAAQ,CAAE,GAAG,KAAK,OAAO,IAAK;AAEnC,aAAO;AAAA,QACN,GAAG;AAAA,QACH,UAAU,MAAM,SAAS,OAAQ,CAAE,MAAO,MAAM,OAAQ;AAAA,QACxD,MAAM;AAAA,MACP;AAAA,IACD;AAAA,IACA,KAAK,gBAAgB;AACpB,YAAM,EAAE,KAAK,IAAI;AACjB,YAAM,YAAY,CAAE,KAAK,OAAO,GAAG,KAAK,IAAK;AAE7C,YAAM,cAAU,oCAAuB,MAAM,MAAM,SAAU;AAC7D,YAAM,WAAO,sBAAS,SAAS,SAAU;AACzC,WAAK,QAAQ,KAAK,MAAM,OAAQ,CAAE,MAAO,MAAM,IAAK;AAEpD,aAAO;AAAA,QACN,GAAG;AAAA,QACH,MAAM;AAAA,MACP;AAAA,IACD;AAAA,EACD;AAEA,SAAO;AACR;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/build/locks/selectors.js
CHANGED
|
@@ -16,6 +16,8 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// packages/core-data/src/locks/selectors.js
|
|
19
21
|
var selectors_exports = {};
|
|
20
22
|
__export(selectors_exports, {
|
|
21
23
|
getPendingLockRequests: () => getPendingLockRequests,
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/locks/selectors.js"],
|
|
4
4
|
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport {\n\titerateDescendants,\n\titeratePath,\n\thasConflictingLock,\n\tgetNode,\n} from './utils';\n\nexport function getPendingLockRequests( state ) {\n\treturn state.requests;\n}\n\nexport function isLockAvailable( state, store, path, { exclusive } ) {\n\tconst storePath = [ store, ...path ];\n\tconst locks = state.tree;\n\n\t// Validate all parents and the node itself\n\tfor ( const node of iteratePath( locks, storePath ) ) {\n\t\tif ( hasConflictingLock( { exclusive }, node.locks ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t// iteratePath terminates early if path is unreachable, let's\n\t// re-fetch the node and check it exists in the tree.\n\tconst node = getNode( locks, storePath );\n\tif ( ! node ) {\n\t\treturn true;\n\t}\n\n\t// Validate all nested nodes\n\tfor ( const descendant of iterateDescendants( node ) ) {\n\t\tif ( hasConflictingLock( { exclusive }, descendant.locks ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\treturn true;\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,mBAKO;AAEA,SAAS,uBAAwB,OAAQ;AAC/C,SAAO,MAAM;AACd;AAEO,SAAS,gBAAiB,OAAO,OAAO,MAAM,EAAE,UAAU,GAAI;AACpE,QAAM,YAAY,CAAE,OAAO,GAAG,IAAK;AACnC,QAAM,QAAQ,MAAM;AAGpB,aAAYA,aAAQ,0BAAa,OAAO,SAAU,GAAI;AACrD,YAAK,iCAAoB,EAAE,UAAU,GAAGA,MAAK,KAAM,GAAI;AACtD,aAAO;AAAA,IACR;AAAA,EACD;AAIA,QAAM,WAAO,sBAAS,OAAO,SAAU;AACvC,MAAK,CAAE,MAAO;AACb,WAAO;AAAA,EACR;AAGA,aAAY,kBAAc,iCAAoB,IAAK,GAAI;AACtD,YAAK,iCAAoB,EAAE,UAAU,GAAG,WAAW,KAAM,GAAI;AAC5D,aAAO;AAAA,IACR;AAAA,EACD;AAEA,SAAO;AACR;",
|
|
6
6
|
"names": ["node"]
|
|
7
7
|
}
|
package/build/locks/utils.js
CHANGED
|
@@ -16,6 +16,8 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// packages/core-data/src/locks/utils.js
|
|
19
21
|
var utils_exports = {};
|
|
20
22
|
__export(utils_exports, {
|
|
21
23
|
deepCopyLocksTreePath: () => deepCopyLocksTreePath,
|
package/build/locks/utils.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/locks/utils.js"],
|
|
4
4
|
"sourcesContent": ["export function deepCopyLocksTreePath( tree, path ) {\n\tconst newTree = { ...tree };\n\tlet currentNode = newTree;\n\tfor ( const branchName of path ) {\n\t\tcurrentNode.children = {\n\t\t\t...currentNode.children,\n\t\t\t[ branchName ]: {\n\t\t\t\tlocks: [],\n\t\t\t\tchildren: {},\n\t\t\t\t...currentNode.children[ branchName ],\n\t\t\t},\n\t\t};\n\t\tcurrentNode = currentNode.children[ branchName ];\n\t}\n\treturn newTree;\n}\n\nexport function getNode( tree, path ) {\n\tlet currentNode = tree;\n\tfor ( const branchName of path ) {\n\t\tconst nextNode = currentNode.children[ branchName ];\n\t\tif ( ! nextNode ) {\n\t\t\treturn null;\n\t\t}\n\t\tcurrentNode = nextNode;\n\t}\n\treturn currentNode;\n}\n\nexport function* iteratePath( tree, path ) {\n\tlet currentNode = tree;\n\tyield currentNode;\n\tfor ( const branchName of path ) {\n\t\tconst nextNode = currentNode.children[ branchName ];\n\t\tif ( ! nextNode ) {\n\t\t\tbreak;\n\t\t}\n\t\tyield nextNode;\n\t\tcurrentNode = nextNode;\n\t}\n}\n\nexport function* iterateDescendants( node ) {\n\tconst stack = Object.values( node.children );\n\twhile ( stack.length ) {\n\t\tconst childNode = stack.pop();\n\t\tyield childNode;\n\t\tstack.push( ...Object.values( childNode.children ) );\n\t}\n}\n\nexport function hasConflictingLock( { exclusive }, locks ) {\n\tif ( exclusive && locks.length ) {\n\t\treturn true;\n\t}\n\n\tif ( ! exclusive && locks.filter( ( lock ) => lock.exclusive ).length ) {\n\t\treturn true;\n\t}\n\n\treturn false;\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,SAAS,sBAAuB,MAAM,MAAO;AACnD,QAAM,UAAU,EAAE,GAAG,KAAK;AAC1B,MAAI,cAAc;AAClB,aAAY,cAAc,MAAO;AAChC,gBAAY,WAAW;AAAA,MACtB,GAAG,YAAY;AAAA,MACf,CAAE,UAAW,GAAG;AAAA,QACf,OAAO,CAAC;AAAA,QACR,UAAU,CAAC;AAAA,QACX,GAAG,YAAY,SAAU,UAAW;AAAA,MACrC;AAAA,IACD;AACA,kBAAc,YAAY,SAAU,UAAW;AAAA,EAChD;AACA,SAAO;AACR;AAEO,SAAS,QAAS,MAAM,MAAO;AACrC,MAAI,cAAc;AAClB,aAAY,cAAc,MAAO;AAChC,UAAM,WAAW,YAAY,SAAU,UAAW;AAClD,QAAK,CAAE,UAAW;AACjB,aAAO;AAAA,IACR;AACA,kBAAc;AAAA,EACf;AACA,SAAO;AACR;AAEO,UAAU,YAAa,MAAM,MAAO;AAC1C,MAAI,cAAc;AAClB,QAAM;AACN,aAAY,cAAc,MAAO;AAChC,UAAM,WAAW,YAAY,SAAU,UAAW;AAClD,QAAK,CAAE,UAAW;AACjB;AAAA,IACD;AACA,UAAM;AACN,kBAAc;AAAA,EACf;AACD;AAEO,UAAU,mBAAoB,MAAO;AAC3C,QAAM,QAAQ,OAAO,OAAQ,KAAK,QAAS;AAC3C,SAAQ,MAAM,QAAS;AACtB,UAAM,YAAY,MAAM,IAAI;AAC5B,UAAM;AACN,UAAM,KAAM,GAAG,OAAO,OAAQ,UAAU,QAAS,CAAE;AAAA,EACpD;AACD;AAEO,SAAS,mBAAoB,EAAE,UAAU,GAAG,OAAQ;AAC1D,MAAK,aAAa,MAAM,QAAS;AAChC,WAAO;AAAA,EACR;AAEA,MAAK,CAAE,aAAa,MAAM,OAAQ,CAAE,SAAU,KAAK,SAAU,EAAE,QAAS;AACvE,WAAO;AAAA,EACR;AAEA,SAAO;AACR;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/build/name.js
CHANGED
|
@@ -16,12 +16,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// packages/core-data/src/name.js
|
|
19
21
|
var name_exports = {};
|
|
20
22
|
__export(name_exports, {
|
|
21
23
|
STORE_NAME: () => STORE_NAME
|
|
22
24
|
});
|
|
23
25
|
module.exports = __toCommonJS(name_exports);
|
|
24
|
-
|
|
26
|
+
var STORE_NAME = "core";
|
|
25
27
|
// Annotate the CommonJS export names for ESM import in node:
|
|
26
28
|
0 && (module.exports = {
|
|
27
29
|
STORE_NAME
|
package/build/name.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/name.js"],
|
|
4
4
|
"sourcesContent": ["/**\n * The reducer key used by core data in store registration.\n * This is defined in a separate file to avoid cycle-dependency\n *\n * @type {string}\n */\nexport const STORE_NAME = 'core';\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMO,IAAM,aAAa;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/build/private-actions.js
CHANGED
|
@@ -26,6 +26,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
mod
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// packages/core-data/src/private-actions.js
|
|
29
31
|
var private_actions_exports = {};
|
|
30
32
|
__export(private_actions_exports, {
|
|
31
33
|
editMediaEntity: () => editMediaEntity,
|
|
@@ -41,7 +43,7 @@ function receiveRegisteredPostMeta(postType, registeredPostMeta) {
|
|
|
41
43
|
registeredPostMeta
|
|
42
44
|
};
|
|
43
45
|
}
|
|
44
|
-
|
|
46
|
+
var editMediaEntity = (recordId, edits = {}, { __unstableFetch = import_api_fetch.default, throwOnError = false } = {}) => async ({ dispatch, resolveSelect }) => {
|
|
45
47
|
if (!recordId) {
|
|
46
48
|
return;
|
|
47
49
|
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/private-actions.js"],
|
|
4
4
|
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\n\n/**\n * Internal dependencies\n */\nimport { STORE_NAME } from './name';\n\n/**\n * Returns an action object used in signalling that the registered post meta\n * fields for a post type have been received.\n *\n * @param {string} postType Post type slug.\n * @param {Object} registeredPostMeta Registered post meta.\n *\n * @return {Object} Action object.\n */\nexport function receiveRegisteredPostMeta( postType, registeredPostMeta ) {\n\treturn {\n\t\ttype: 'RECEIVE_REGISTERED_POST_META',\n\t\tpostType,\n\t\tregisteredPostMeta,\n\t};\n}\n\n/**\n * @typedef {Object} Modifier\n * @property {string} [type] - The type of modifier.\n * @property {Object} [args] - The arguments of the modifier.\n */\n\n/**\n * @typedef {Object} Edits\n * @property {string} [src] - The URL of the media item.\n * @property {Modifier[]} [modifiers] - The modifiers to apply to the media item.\n */\n\n/**\n * Duplicates a media (attachment) entity record and, optionally, modifies it.\n *\n * @param {string} recordId Entity record ID.\n * @param {Edits} edits Edits to apply to the record.\n * @param {Object} options Options object.\n * @param {Function} options.__unstableFetch Custom fetch function.\n * @param {boolean} options.throwOnError Whether to throw an error if the request fails.\n *\n * @return {Promise} Promise resolving to the updated record.\n */\nexport const editMediaEntity =\n\t(\n\t\trecordId,\n\t\tedits = {},\n\t\t{ __unstableFetch = apiFetch, throwOnError = false } = {}\n\t) =>\n\tasync ( { dispatch, resolveSelect } ) => {\n\t\tif ( ! recordId ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst kind = 'postType';\n\t\tconst name = 'attachment';\n\n\t\tconst configs = await resolveSelect.getEntitiesConfig( kind );\n\t\tconst entityConfig = configs.find(\n\t\t\t( config ) => config.kind === kind && config.name === name\n\t\t);\n\n\t\tif ( ! entityConfig ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst lock = await dispatch.__unstableAcquireStoreLock(\n\t\t\tSTORE_NAME,\n\t\t\t[ 'entities', 'records', kind, name, recordId ],\n\t\t\t{ exclusive: true }\n\t\t);\n\n\t\tlet updatedRecord;\n\t\tlet error;\n\t\tlet hasError = false;\n\n\t\ttry {\n\t\t\tdispatch( {\n\t\t\t\ttype: 'SAVE_ENTITY_RECORD_START',\n\t\t\t\tkind,\n\t\t\t\tname,\n\t\t\t\trecordId,\n\t\t\t} );\n\n\t\t\ttry {\n\t\t\t\tconst path = `${ entityConfig.baseURL }/${ recordId }/edit`;\n\t\t\t\tconst newRecord = await __unstableFetch( {\n\t\t\t\t\tpath,\n\t\t\t\t\tmethod: 'POST',\n\t\t\t\t\tdata: {\n\t\t\t\t\t\t...edits,\n\t\t\t\t\t},\n\t\t\t\t} );\n\n\t\t\t\tif ( newRecord ) {\n\t\t\t\t\tdispatch.receiveEntityRecords(\n\t\t\t\t\t\tkind,\n\t\t\t\t\t\tname,\n\t\t\t\t\t\t[ newRecord ],\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tundefined\n\t\t\t\t\t);\n\t\t\t\t\tupdatedRecord = newRecord;\n\t\t\t\t}\n\t\t\t} catch ( e ) {\n\t\t\t\terror = e;\n\t\t\t\thasError = true;\n\t\t\t}\n\n\t\t\tdispatch( {\n\t\t\t\ttype: 'SAVE_ENTITY_RECORD_FINISH',\n\t\t\t\tkind,\n\t\t\t\tname,\n\t\t\t\trecordId,\n\t\t\t\terror,\n\t\t\t} );\n\n\t\t\tif ( hasError && throwOnError ) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\treturn updatedRecord;\n\t\t} finally {\n\t\t\tdispatch.__unstableReleaseStoreLock( lock );\n\t\t}\n\t};\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,uBAAqB;AAKrB,kBAA2B;AAWpB,SAAS,0BAA2B,UAAU,oBAAqB;AACzE,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA;AAAA,EACD;AACD;AAyBO,IAAM,kBACZ,CACC,UACA,QAAQ,CAAC,GACT,EAAE,kBAAkB,iBAAAA,SAAU,eAAe,MAAM,IAAI,CAAC,MAEzD,OAAQ,EAAE,UAAU,cAAc,MAAO;AACxC,MAAK,CAAE,UAAW;AACjB;AAAA,EACD;AAEA,QAAM,OAAO;AACb,QAAM,OAAO;AAEb,QAAM,UAAU,MAAM,cAAc,kBAAmB,IAAK;AAC5D,QAAM,eAAe,QAAQ;AAAA,IAC5B,CAAE,WAAY,OAAO,SAAS,QAAQ,OAAO,SAAS;AAAA,EACvD;AAEA,MAAK,CAAE,cAAe;AACrB;AAAA,EACD;AAEA,QAAM,OAAO,MAAM,SAAS;AAAA,IAC3B;AAAA,IACA,CAAE,YAAY,WAAW,MAAM,MAAM,QAAS;AAAA,IAC9C,EAAE,WAAW,KAAK;AAAA,EACnB;AAEA,MAAI;AACJ,MAAI;AACJ,MAAI,WAAW;AAEf,MAAI;AACH,aAAU;AAAA,MACT,MAAM;AAAA,MACN;AAAA,MACA;AAAA,MACA;AAAA,IACD,CAAE;AAEF,QAAI;AACH,YAAM,OAAO,GAAI,aAAa,OAAQ,IAAK,QAAS;AACpD,YAAM,YAAY,MAAM,gBAAiB;AAAA,QACxC;AAAA,QACA,QAAQ;AAAA,QACR,MAAM;AAAA,UACL,GAAG;AAAA,QACJ;AAAA,MACD,CAAE;AAEF,UAAK,WAAY;AAChB,iBAAS;AAAA,UACR;AAAA,UACA;AAAA,UACA,CAAE,SAAU;AAAA,UACZ;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QACD;AACA,wBAAgB;AAAA,MACjB;AAAA,IACD,SAAU,GAAI;AACb,cAAQ;AACR,iBAAW;AAAA,IACZ;AAEA,aAAU;AAAA,MACT,MAAM;AAAA,MACN;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD,CAAE;AAEF,QAAK,YAAY,cAAe;AAC/B,YAAM;AAAA,IACP;AACA,WAAO;AAAA,EACR,UAAE;AACD,aAAS,2BAA4B,IAAK;AAAA,EAC3C;AACD;",
|
|
6
6
|
"names": ["apiFetch"]
|
|
7
7
|
}
|
package/build/private-apis.js
CHANGED
|
@@ -16,6 +16,8 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// packages/core-data/src/private-apis.js
|
|
19
21
|
var private_apis_exports = {};
|
|
20
22
|
__export(private_apis_exports, {
|
|
21
23
|
privateApis: () => privateApis
|
|
@@ -24,7 +26,7 @@ module.exports = __toCommonJS(private_apis_exports);
|
|
|
24
26
|
var import_use_entity_records = require("./hooks/use-entity-records");
|
|
25
27
|
var import_utils = require("./utils");
|
|
26
28
|
var import_lock_unlock = require("./lock-unlock");
|
|
27
|
-
|
|
29
|
+
var privateApis = {};
|
|
28
30
|
(0, import_lock_unlock.lock)(privateApis, {
|
|
29
31
|
useEntityRecordsWithPermissions: import_use_entity_records.useEntityRecordsWithPermissions,
|
|
30
32
|
RECEIVE_INTERMEDIATE_RESULTS: import_utils.RECEIVE_INTERMEDIATE_RESULTS
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/private-apis.js"],
|
|
4
4
|
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport { useEntityRecordsWithPermissions } from './hooks/use-entity-records';\nimport { RECEIVE_INTERMEDIATE_RESULTS } from './utils';\nimport { lock } from './lock-unlock';\n\nexport const privateApis = {};\nlock( privateApis, {\n\tuseEntityRecordsWithPermissions,\n\tRECEIVE_INTERMEDIATE_RESULTS,\n} );\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,gCAAgD;AAChD,mBAA6C;AAC7C,yBAAqB;AAEd,IAAM,cAAc,CAAC;AAAA,IAC5B,yBAAM,aAAa;AAAA,EAClB;AAAA,EACA;AACD,CAAE;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -26,6 +26,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
mod
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// packages/core-data/src/private-selectors.ts
|
|
29
31
|
var private_selectors_exports = {};
|
|
30
32
|
__export(private_selectors_exports, {
|
|
31
33
|
getBlockPatternsForPostType: () => getBlockPatternsForPostType,
|
|
@@ -50,7 +52,7 @@ function getUndoManager(state) {
|
|
|
50
52
|
function getNavigationFallbackId(state) {
|
|
51
53
|
return state.navigationFallbackId;
|
|
52
54
|
}
|
|
53
|
-
|
|
55
|
+
var getBlockPatternsForPostType = (0, import_data.createRegistrySelector)(
|
|
54
56
|
(select) => (0, import_data.createSelector)(
|
|
55
57
|
(state, postType) => select(import_name.STORE_NAME).getBlockPatterns().filter(
|
|
56
58
|
({ postTypes }) => !postTypes || Array.isArray(postTypes) && postTypes.includes(postType)
|
|
@@ -58,7 +60,7 @@ const getBlockPatternsForPostType = (0, import_data.createRegistrySelector)(
|
|
|
58
60
|
() => [select(import_name.STORE_NAME).getBlockPatterns()]
|
|
59
61
|
)
|
|
60
62
|
);
|
|
61
|
-
|
|
63
|
+
var getEntityRecordsPermissions = (0, import_data.createRegistrySelector)(
|
|
62
64
|
(select) => (0, import_data.createSelector)(
|
|
63
65
|
(state, kind, name, ids) => {
|
|
64
66
|
const normalizedIds = Array.isArray(ids) ? ids : [ids];
|
|
@@ -94,7 +96,7 @@ function normalizePageId(value) {
|
|
|
94
96
|
}
|
|
95
97
|
return value.toString();
|
|
96
98
|
}
|
|
97
|
-
|
|
99
|
+
var getHomePage = (0, import_data.createRegistrySelector)(
|
|
98
100
|
(select) => (0, import_data.createSelector)(
|
|
99
101
|
() => {
|
|
100
102
|
const siteData = select(import_name.STORE_NAME).getEntityRecord(
|
|
@@ -129,14 +131,14 @@ const getHomePage = (0, import_data.createRegistrySelector)(
|
|
|
129
131
|
]
|
|
130
132
|
)
|
|
131
133
|
);
|
|
132
|
-
|
|
134
|
+
var getPostsPageId = (0, import_data.createRegistrySelector)((select) => () => {
|
|
133
135
|
const siteData = select(import_name.STORE_NAME).getEntityRecord(
|
|
134
136
|
"root",
|
|
135
137
|
"__unstableBase"
|
|
136
138
|
);
|
|
137
139
|
return siteData?.show_on_front === "page" ? normalizePageId(siteData.page_for_posts) : null;
|
|
138
140
|
});
|
|
139
|
-
|
|
141
|
+
var getTemplateId = (0, import_data.createRegistrySelector)(
|
|
140
142
|
(select) => (state, postType, postId) => {
|
|
141
143
|
const homepage = (0, import_lock_unlock.unlock)(select(import_name.STORE_NAME)).getHomePage();
|
|
142
144
|
if (!homepage) {
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/private-selectors.ts"],
|
|
4
4
|
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createSelector, createRegistrySelector } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { getDefaultTemplateId, getEntityRecord, type State } from './selectors';\nimport { STORE_NAME } from './name';\nimport { unlock } from './lock-unlock';\nimport logEntityDeprecation from './utils/log-entity-deprecation';\n\ntype EntityRecordKey = string | number;\n\n/**\n * Returns the previous edit from the current undo offset\n * for the entity records edits history, if any.\n *\n * @param state State tree.\n *\n * @return The undo manager.\n */\nexport function getUndoManager( state: State ) {\n\treturn state.undoManager;\n}\n\n/**\n * Retrieve the fallback Navigation.\n *\n * @param state Data state.\n * @return The ID for the fallback Navigation post.\n */\nexport function getNavigationFallbackId(\n\tstate: State\n): EntityRecordKey | undefined {\n\treturn state.navigationFallbackId;\n}\n\nexport const getBlockPatternsForPostType = createRegistrySelector(\n\t( select: any ) =>\n\t\tcreateSelector(\n\t\t\t( state, postType ) =>\n\t\t\t\tselect( STORE_NAME )\n\t\t\t\t\t.getBlockPatterns()\n\t\t\t\t\t.filter(\n\t\t\t\t\t\t( { postTypes } ) =>\n\t\t\t\t\t\t\t! postTypes ||\n\t\t\t\t\t\t\t( Array.isArray( postTypes ) &&\n\t\t\t\t\t\t\t\tpostTypes.includes( postType ) )\n\t\t\t\t\t),\n\t\t\t() => [ select( STORE_NAME ).getBlockPatterns() ]\n\t\t)\n);\n\n/**\n * Returns the entity records permissions for the given entity record ids.\n */\nexport const getEntityRecordsPermissions = createRegistrySelector( ( select ) =>\n\tcreateSelector(\n\t\t(\n\t\t\tstate: State,\n\t\t\tkind: string,\n\t\t\tname: string,\n\t\t\tids: string | string[]\n\t\t) => {\n\t\t\tconst normalizedIds = Array.isArray( ids ) ? ids : [ ids ];\n\t\t\treturn normalizedIds.map( ( id ) => ( {\n\t\t\t\tdelete: select( STORE_NAME ).canUser( 'delete', {\n\t\t\t\t\tkind,\n\t\t\t\t\tname,\n\t\t\t\t\tid,\n\t\t\t\t} ),\n\t\t\t\tupdate: select( STORE_NAME ).canUser( 'update', {\n\t\t\t\t\tkind,\n\t\t\t\t\tname,\n\t\t\t\t\tid,\n\t\t\t\t} ),\n\t\t\t} ) );\n\t\t},\n\t\t( state ) => [ state.userPermissions ]\n\t)\n);\n\n/**\n * Returns the entity record permissions for the given entity record id.\n *\n * @param state Data state.\n * @param kind Entity kind.\n * @param name Entity name.\n * @param id Entity record id.\n *\n * @return The entity record permissions.\n */\nexport function getEntityRecordPermissions(\n\tstate: State,\n\tkind: string,\n\tname: string,\n\tid: string\n) {\n\tlogEntityDeprecation( kind, name, 'getEntityRecordPermissions' );\n\treturn getEntityRecordsPermissions( state, kind, name, id )[ 0 ];\n}\n\n/**\n * Returns the registered post meta fields for a given post type.\n *\n * @param state Data state.\n * @param postType Post type.\n *\n * @return Registered post meta fields.\n */\nexport function getRegisteredPostMeta( state: State, postType: string ) {\n\treturn state.registeredPostMeta?.[ postType ] ?? {};\n}\n\nfunction normalizePageId( value: number | string | undefined ): string | null {\n\tif ( ! value || ! [ 'number', 'string' ].includes( typeof value ) ) {\n\t\treturn null;\n\t}\n\n\t// We also need to check if it's not zero (`'0'`).\n\tif ( Number( value ) === 0 ) {\n\t\treturn null;\n\t}\n\n\treturn value.toString();\n}\n\ninterface SiteData {\n\tshow_on_front?: string;\n\tpage_on_front?: string | number;\n\tpage_for_posts?: string | number;\n}\n\nexport const getHomePage = createRegistrySelector( ( select ) =>\n\tcreateSelector(\n\t\t() => {\n\t\t\tconst siteData = select( STORE_NAME ).getEntityRecord(\n\t\t\t\t'root',\n\t\t\t\t'__unstableBase'\n\t\t\t) as SiteData | undefined;\n\t\t\t// Still resolving getEntityRecord.\n\t\t\tif ( ! siteData ) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tconst homepageId =\n\t\t\t\tsiteData?.show_on_front === 'page'\n\t\t\t\t\t? normalizePageId( siteData.page_on_front )\n\t\t\t\t\t: null;\n\t\t\tif ( homepageId ) {\n\t\t\t\treturn { postType: 'page', postId: homepageId };\n\t\t\t}\n\t\t\tconst frontPageTemplateId = select(\n\t\t\t\tSTORE_NAME\n\t\t\t).getDefaultTemplateId( {\n\t\t\t\tslug: 'front-page',\n\t\t\t} );\n\t\t\t// Still resolving getDefaultTemplateId.\n\t\t\tif ( ! frontPageTemplateId ) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\treturn { postType: 'wp_template', postId: frontPageTemplateId };\n\t\t},\n\t\t( state ) => [\n\t\t\t// Even though getDefaultTemplateId.shouldInvalidate returns true when root/site changes,\n\t\t\t// it doesn't seem to invalidate this cache, I'm not sure why.\n\t\t\tgetEntityRecord( state, 'root', 'site' ),\n\t\t\tgetEntityRecord( state, 'root', '__unstableBase' ),\n\t\t\tgetDefaultTemplateId( state, {\n\t\t\t\tslug: 'front-page',\n\t\t\t} ),\n\t\t]\n\t)\n);\n\nexport const getPostsPageId = createRegistrySelector( ( select ) => () => {\n\tconst siteData = select( STORE_NAME ).getEntityRecord(\n\t\t'root',\n\t\t'__unstableBase'\n\t) as SiteData | undefined;\n\treturn siteData?.show_on_front === 'page'\n\t\t? normalizePageId( siteData.page_for_posts )\n\t\t: null;\n} );\n\nexport const getTemplateId = createRegistrySelector(\n\t( select ) => ( state, postType, postId ) => {\n\t\tconst homepage = unlock( select( STORE_NAME ) ).getHomePage();\n\n\t\tif ( ! homepage ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// For the front page, we always use the front page template if existing.\n\t\tif (\n\t\t\tpostType === 'page' &&\n\t\t\tpostType === homepage?.postType &&\n\t\t\tpostId.toString() === homepage?.postId\n\t\t) {\n\t\t\t// The /lookup endpoint cannot currently handle a lookup\n\t\t\t// when a page is set as the front page, so specifically in\n\t\t\t// that case, we want to check if there is a front page\n\t\t\t// template, and instead of falling back to the home\n\t\t\t// template, we want to fall back to the page template.\n\t\t\tconst templates = select( STORE_NAME ).getEntityRecords(\n\t\t\t\t'postType',\n\t\t\t\t'wp_template',\n\t\t\t\t{\n\t\t\t\t\tper_page: -1,\n\t\t\t\t}\n\t\t\t);\n\t\t\tif ( ! templates ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst id = templates.find( ( { slug } ) => slug === 'front-page' )\n\t\t\t\t?.id;\n\t\t\tif ( id ) {\n\t\t\t\treturn id;\n\t\t\t}\n\t\t\t// If no front page template is found, continue with the\n\t\t\t// logic below (fetching the page template).\n\t\t}\n\n\t\tconst editedEntity = select( STORE_NAME ).getEditedEntityRecord(\n\t\t\t'postType',\n\t\t\tpostType,\n\t\t\tpostId\n\t\t);\n\t\tif ( ! editedEntity ) {\n\t\t\treturn;\n\t\t}\n\t\tconst postsPageId = unlock( select( STORE_NAME ) ).getPostsPageId();\n\t\t// Check if the current page is the posts page.\n\t\tif ( postType === 'page' && postsPageId === postId.toString() ) {\n\t\t\treturn select( STORE_NAME ).getDefaultTemplateId( {\n\t\t\t\tslug: 'home',\n\t\t\t} );\n\t\t}\n\t\t// First see if the post/page has an assigned template and fetch it.\n\t\tconst currentTemplateSlug = editedEntity.template;\n\t\tif ( currentTemplateSlug ) {\n\t\t\tconst currentTemplate = select( STORE_NAME )\n\t\t\t\t.getEntityRecords( 'postType', 'wp_template', {\n\t\t\t\t\tper_page: -1,\n\t\t\t\t} )\n\t\t\t\t?.find( ( { slug } ) => slug === currentTemplateSlug );\n\t\t\tif ( currentTemplate ) {\n\t\t\t\treturn currentTemplate.id;\n\t\t\t}\n\t\t}\n\t\t// If no template is assigned, use the default template.\n\t\tlet slugToCheck;\n\t\t// In `draft` status we might not have a slug available, so we use the `single`\n\t\t// post type templates slug(ex page, single-post, single-product etc..).\n\t\t// Pages do not need the `single` prefix in the slug to be prioritized\n\t\t// through template hierarchy.\n\t\tif ( editedEntity.slug ) {\n\t\t\tslugToCheck =\n\t\t\t\tpostType === 'page'\n\t\t\t\t\t? `${ postType }-${ editedEntity.slug }`\n\t\t\t\t\t: `single-${ postType }-${ editedEntity.slug }`;\n\t\t} else {\n\t\t\tslugToCheck = postType === 'page' ? 'page' : `single-${ postType }`;\n\t\t}\n\t\treturn select( STORE_NAME ).getDefaultTemplateId( {\n\t\t\tslug: slugToCheck,\n\t\t} );\n\t}\n);\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "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",
|
|
6
6
|
"names": ["logEntityDeprecation"]
|
|
7
7
|
}
|
|
@@ -16,6 +16,8 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// packages/core-data/src/queried-data/actions.js
|
|
19
21
|
var actions_exports = {};
|
|
20
22
|
__export(actions_exports, {
|
|
21
23
|
receiveItems: () => receiveItems,
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/queried-data/actions.js"],
|
|
4
4
|
"sourcesContent": ["/**\n * Returns an action object used in signalling that items have been received.\n *\n * @param {Array} items Items received.\n * @param {?Object} edits Optional edits to reset.\n * @param {?Object} meta Meta information about pagination.\n *\n * @return {Object} Action object.\n */\nexport function receiveItems( items, edits, meta ) {\n\treturn {\n\t\ttype: 'RECEIVE_ITEMS',\n\t\titems: Array.isArray( items ) ? items : [ items ],\n\t\tpersistedEdits: edits,\n\t\tmeta,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that entity records have been\n * deleted and they need to be removed from entities state.\n *\n * @param {string} kind Kind of the removed entities.\n * @param {string} name Name of the removed entities.\n * @param {Array|number|string} records Record IDs of the removed entities.\n * @param {boolean} invalidateCache Controls whether we want to invalidate the cache.\n * @return {Object} Action object.\n */\nexport function removeItems( kind, name, records, invalidateCache = false ) {\n\treturn {\n\t\ttype: 'REMOVE_ITEMS',\n\t\titemIds: Array.isArray( records ) ? records : [ records ],\n\t\tkind,\n\t\tname,\n\t\tinvalidateCache,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that queried data has been\n * received.\n *\n * @param {Array} items Queried items received.\n * @param {?Object} query Optional query object.\n * @param {?Object} edits Optional edits to reset.\n * @param {?Object} meta Meta information about pagination.\n *\n * @return {Object} Action object.\n */\nexport function receiveQueriedItems( items, query = {}, edits, meta ) {\n\treturn {\n\t\t...receiveItems( items, edits, meta ),\n\t\tquery,\n\t};\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASO,SAAS,aAAc,OAAO,OAAO,MAAO;AAClD,SAAO;AAAA,IACN,MAAM;AAAA,IACN,OAAO,MAAM,QAAS,KAAM,IAAI,QAAQ,CAAE,KAAM;AAAA,IAChD,gBAAgB;AAAA,IAChB;AAAA,EACD;AACD;AAYO,SAAS,YAAa,MAAM,MAAM,SAAS,kBAAkB,OAAQ;AAC3E,SAAO;AAAA,IACN,MAAM;AAAA,IACN,SAAS,MAAM,QAAS,OAAQ,IAAI,UAAU,CAAE,OAAQ;AAAA,IACxD;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD;AAaO,SAAS,oBAAqB,OAAO,QAAQ,CAAC,GAAG,OAAO,MAAO;AACrE,SAAO;AAAA,IACN,GAAG,aAAc,OAAO,OAAO,IAAK;AAAA,IACpC;AAAA,EACD;AACD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -16,6 +16,8 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// packages/core-data/src/queried-data/get-query-parts.js
|
|
19
21
|
var get_query_parts_exports = {};
|
|
20
22
|
__export(get_query_parts_exports, {
|
|
21
23
|
default: () => get_query_parts_default,
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/queried-data/get-query-parts.js"],
|
|
4
4
|
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { addQueryArgs } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { withWeakMapCache, getNormalizedCommaSeparable } from '../utils';\n\n/**\n * An object of properties describing a specific query.\n *\n * @typedef {Object} WPQueriedDataQueryParts\n *\n * @property {number} page The query page (1-based index, default 1).\n * @property {number} perPage Items per page for query (default 10).\n * @property {string} stableKey An encoded stable string of all non-\n * pagination, non-fields query parameters.\n * @property {?(string[])} fields Target subset of fields to derive from\n * item objects.\n * @property {?(number[])} include Specific item IDs to include.\n * @property {string} context Scope under which the request is made;\n * determines returned fields in response.\n */\n\n/**\n * Given a query object, returns an object of parts, including pagination\n * details (`page` and `perPage`, or default values). All other properties are\n * encoded into a stable (idempotent) `stableKey` value.\n *\n * @param {Object} query Optional query object.\n *\n * @return {WPQueriedDataQueryParts} Query parts.\n */\nexport function getQueryParts( query ) {\n\t/**\n\t * @type {WPQueriedDataQueryParts}\n\t */\n\tconst parts = {\n\t\tstableKey: '',\n\t\tpage: 1,\n\t\tperPage: 10,\n\t\tfields: null,\n\t\tinclude: null,\n\t\tcontext: 'default',\n\t};\n\n\t// Ensure stable key by sorting keys. Also more efficient for iterating.\n\tconst keys = Object.keys( query ).sort();\n\n\tfor ( let i = 0; i < keys.length; i++ ) {\n\t\tconst key = keys[ i ];\n\t\tlet value = query[ key ];\n\n\t\tswitch ( key ) {\n\t\t\tcase 'page':\n\t\t\t\tparts[ key ] = Number( value );\n\t\t\t\tbreak;\n\n\t\t\tcase 'per_page':\n\t\t\t\tparts.perPage = Number( value );\n\t\t\t\tbreak;\n\n\t\t\tcase 'context':\n\t\t\t\tparts.context = value;\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\t// While in theory, we could exclude \"_fields\" from the stableKey\n\t\t\t\t// because two request with different fields have the same results\n\t\t\t\t// We're not able to ensure that because the server can decide to omit\n\t\t\t\t// fields from the response even if we explicitly asked for it.\n\t\t\t\t// Example: Asking for titles in posts without title support.\n\t\t\t\tif ( key === '_fields' ) {\n\t\t\t\t\tparts.fields = getNormalizedCommaSeparable( value ) ?? [];\n\t\t\t\t\t// Make sure to normalize value for `stableKey`\n\t\t\t\t\tvalue = parts.fields.join();\n\t\t\t\t}\n\n\t\t\t\t// Two requests with different include values cannot have same results.\n\t\t\t\tif ( key === 'include' ) {\n\t\t\t\t\tif ( typeof value === 'number' ) {\n\t\t\t\t\t\tvalue = value.toString();\n\t\t\t\t\t}\n\t\t\t\t\tparts.include = (\n\t\t\t\t\t\tgetNormalizedCommaSeparable( value ) ?? []\n\t\t\t\t\t).map( Number );\n\t\t\t\t\t// Normalize value for `stableKey`.\n\t\t\t\t\tvalue = parts.include.join();\n\t\t\t\t}\n\n\t\t\t\t// While it could be any deterministic string, for simplicity's\n\t\t\t\t// sake mimic querystring encoding for stable key.\n\t\t\t\t//\n\t\t\t\t// TODO: For consistency with PHP implementation, addQueryArgs\n\t\t\t\t// should accept a key value pair, which may optimize its\n\t\t\t\t// implementation for our use here, vs. iterating an object\n\t\t\t\t// with only a single key.\n\t\t\t\tparts.stableKey +=\n\t\t\t\t\t( parts.stableKey ? '&' : '' ) +\n\t\t\t\t\taddQueryArgs( '', { [ key ]: value } ).slice( 1 );\n\t\t}\n\t}\n\n\treturn parts;\n}\n\nexport default withWeakMapCache( getQueryParts );\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,iBAA6B;AAK7B,mBAA8D;AA2BvD,SAAS,cAAe,OAAQ;AAItC,QAAM,QAAQ;AAAA,IACb,WAAW;AAAA,IACX,MAAM;AAAA,IACN,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,SAAS;AAAA,EACV;AAGA,QAAM,OAAO,OAAO,KAAM,KAAM,EAAE,KAAK;AAEvC,WAAU,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAM;AACvC,UAAM,MAAM,KAAM,CAAE;AACpB,QAAI,QAAQ,MAAO,GAAI;AAEvB,YAAS,KAAM;AAAA,MACd,KAAK;AACJ,cAAO,GAAI,IAAI,OAAQ,KAAM;AAC7B;AAAA,MAED,KAAK;AACJ,cAAM,UAAU,OAAQ,KAAM;AAC9B;AAAA,MAED,KAAK;AACJ,cAAM,UAAU;AAChB;AAAA,MAED;AAMC,YAAK,QAAQ,WAAY;AACxB,gBAAM,aAAS,0CAA6B,KAAM,KAAK,CAAC;AAExD,kBAAQ,MAAM,OAAO,KAAK;AAAA,QAC3B;AAGA,YAAK,QAAQ,WAAY;AACxB,cAAK,OAAO,UAAU,UAAW;AAChC,oBAAQ,MAAM,SAAS;AAAA,UACxB;AACA,gBAAM,eACL,0CAA6B,KAAM,KAAK,CAAC,GACxC,IAAK,MAAO;AAEd,kBAAQ,MAAM,QAAQ,KAAK;AAAA,QAC5B;AASA,cAAM,cACH,MAAM,YAAY,MAAM,UAC1B,yBAAc,IAAI,EAAE,CAAE,GAAI,GAAG,MAAM,CAAE,EAAE,MAAO,CAAE;AAAA,IACnD;AAAA,EACD;AAEA,SAAO;AACR;AAEA,IAAO,8BAAQ,+BAAkB,aAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -27,6 +27,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
27
|
mod
|
|
28
28
|
));
|
|
29
29
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
|
|
31
|
+
// packages/core-data/src/queried-data/index.js
|
|
30
32
|
var queried_data_exports = {};
|
|
31
33
|
__export(queried_data_exports, {
|
|
32
34
|
reducer: () => import_reducer.default
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/queried-data/index.js"],
|
|
4
4
|
"sourcesContent": ["export * from './actions';\nexport * from './selectors';\nexport { default as reducer } from './reducer';\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iCAAc,sBAAd;AACA,iCAAc,wBADd;AAEA,qBAAmC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -26,6 +26,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
mod
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// packages/core-data/src/queried-data/reducer.js
|
|
29
31
|
var reducer_exports = {};
|
|
30
32
|
__export(reducer_exports, {
|
|
31
33
|
default: () => reducer_default,
|
|
@@ -135,7 +137,7 @@ function itemIsComplete(state = {}, action) {
|
|
|
135
137
|
}
|
|
136
138
|
return state;
|
|
137
139
|
}
|
|
138
|
-
|
|
140
|
+
var receiveQueries = (0, import_compose.compose)([
|
|
139
141
|
// Limit to matching action type so we don't attempt to replace action on
|
|
140
142
|
// an unhandled action.
|
|
141
143
|
(0, import_utils.ifMatchingAction)((action) => "query" in action),
|
|
@@ -168,7 +170,7 @@ const receiveQueries = (0, import_compose.compose)([
|
|
|
168
170
|
meta: action.meta
|
|
169
171
|
};
|
|
170
172
|
});
|
|
171
|
-
|
|
173
|
+
var queries = (state = {}, action) => {
|
|
172
174
|
switch (action.type) {
|
|
173
175
|
case "RECEIVE_ITEMS":
|
|
174
176
|
return receiveQueries(state, action);
|