PluginProbe
Gutenberg / 24.1.0
Gutenberg v24.1.0
24.1.0 24.0.0 23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 All 404 releases
← All changes | build/scripts/core-data/index.js +417 -376 23.8.0 → 24.1.0 View file →
@@ -453,9 +453,9 @@
453 453 useEntityRecord: () => useEntityRecord,
454 454 useEntityRecords: () => useEntityRecords,
455 455 useResourcePermissions: () => use_resource_permissions_default
456 456 });
457 - var import_data19 = __toESM(require_data(), 1);
457 + var import_data20 = __toESM(require_data(), 1);
458 458
459 459 // packages/core-data/build-module/reducer.mjs
460 460 var import_es65 = __toESM(require_es6(), 1);
461 461 var import_compose2 = __toESM(require_compose(), 1);
@@ -516,8 +516,58 @@
516 516 return null;
517 517 }
518 518 var get_normalized_comma_separable_default = getNormalizedCommaSeparable;
519 519
520 + // packages/core-data/build-module/utils/set-nested-value.mjs
521 + function setNestedValue(object, path, value) {
522 + if (!object || typeof object !== "object") {
523 + return object;
524 + }
525 + const normalizedPath = Array.isArray(path) ? path : path.split(".");
526 + normalizedPath.reduce((acc, key, idx) => {
527 + if (acc[key] === void 0) {
528 + if (Number.isInteger(normalizedPath[idx + 1])) {
529 + acc[key] = [];
530 + } else {
531 + acc[key] = {};
532 + }
533 + }
534 + if (idx === normalizedPath.length - 1) {
535 + acc[key] = value;
536 + }
537 + return acc[key];
538 + }, object);
539 + return object;
540 + }
541 +
542 + // packages/core-data/build-module/utils/get-filtered-item.mjs
543 + var filteredItemCache = /* @__PURE__ */ new WeakMap();
544 + function getFilteredItem(item, _fields) {
545 + const fields = get_normalized_comma_separable_default(_fields) ?? [];
546 + const fieldsKey = fields.join(",");
547 + let itemCache = filteredItemCache.get(item);
548 + if (itemCache) {
549 + const filtered = itemCache.get(fieldsKey);
550 + if (filtered !== void 0) {
551 + return filtered;
552 + }
553 + } else if (item !== null && typeof item === "object") {
554 + itemCache = /* @__PURE__ */ new Map();
555 + filteredItemCache.set(item, itemCache);
556 + }
557 + const filteredItem = {};
558 + for (let f = 0; f < fields.length; f++) {
559 + const field = fields[f].split(".");
560 + let value = item;
561 + field.forEach((fieldName) => {
562 + value = value?.[fieldName];
563 + });
564 + setNestedValue(filteredItem, field, value);
565 + }
566 + itemCache?.set(fieldsKey, filteredItem);
567 + return filteredItem;
568 + }
569 +
520 570 // packages/core-data/build-module/utils/if-matching-action.mjs
521 571 var ifMatchingAction = (isMatch) => (reducer) => (state, action) => {
522 572 if (state === void 0 || isMatch(action)) {
523 573 return reducer(state, action);
@@ -555,30 +605,8 @@
555 605 };
556 606 }
557 607 var with_weak_map_cache_default = withWeakMapCache;
558 608
559 - // packages/core-data/build-module/utils/set-nested-value.mjs
560 - function setNestedValue(object, path, value) {
561 - if (!object || typeof object !== "object") {
562 - return object;
563 - }
564 - const normalizedPath = Array.isArray(path) ? path : path.split(".");
565 - normalizedPath.reduce((acc, key, idx) => {
566 - if (acc[key] === void 0) {
567 - if (Number.isInteger(normalizedPath[idx + 1])) {
568 - acc[key] = [];
569 - } else {
570 - acc[key] = {};
571 - }
572 - }
573 - if (idx === normalizedPath.length - 1) {
574 - acc[key] = value;
575 - }
576 - return acc[key];
577 - }, object);
578 - return object;
579 - }
580 -
581 609 // packages/core-data/build-module/utils/get-nested-value.mjs
582 610 function getNestedValue(object, path, defaultValue) {
583 611 if (!object || typeof object !== "object" || typeof path !== "string" && !Array.isArray(path)) {
584 612 return object;
@@ -730,8 +758,18 @@
730 758 }
731 759 }
732 760 }
733 761
762 + // packages/core-data/build-module/utils/get-pagination-meta.mjs
763 + function getPaginationMeta(headers) {
764 + const totalItems = parseInt(headers.get("X-WP-Total") ?? "");
765 + const totalPages = parseInt(headers.get("X-WP-TotalPages") ?? "");
766 + return {
767 + totalItems: Number.isFinite(totalItems) ? totalItems : null,
768 + totalPages: Number.isFinite(totalPages) ? totalPages : null
769 + };
770 + }
771 +
734 772 // packages/core-data/build-module/queried-data/actions.mjs
735 773 function receiveItems(items2, edits, meta) {
736 774 return {
737 775 type: "RECEIVE_ITEMS",
@@ -1050,18 +1088,49 @@
1050 1088 return Object.entries(collaboratorInfo1).every(([key, value]) => {
1051 1089 return value === collaboratorInfo2[key];
1052 1090 });
1053 1091 }
1054 - function generateCollaboratorInfo(currentCollaborator) {
1055 - const { avatar_urls, id, name, slug } = currentCollaborator;
1092 + function hasValidAvatarUrls(value) {
1093 + if ("object" !== typeof value || null === value || Array.isArray(value)) {
1094 + return false;
1095 + }
1096 + return ["24", "48", "96"].every(
1097 + (size) => !(size in value) || "string" === typeof value[size]
1098 + );
1099 + }
1100 + function isCollaboratorInfo(value) {
1101 + if ("object" !== typeof value || null === value) {
1102 + return false;
1103 + }
1104 + return "id" in value && "name" in value && "slug" in value && "browserType" in value && "enteredAt" in value && (null === value.id || "number" === typeof value.id && Number.isInteger(value.id) && value.id > 0) && "string" === typeof value.name && "" !== value.name.trim() && "string" === typeof value.slug && (!("avatar_urls" in value) || hasValidAvatarUrls(value.avatar_urls)) && "string" === typeof value.browserType && "number" === typeof value.enteredAt && Number.isFinite(value.enteredAt);
1105 + }
1106 + function generateCollaboratorInfo(currentCollaborator, clientId) {
1107 + const presentationInfo = {
1108 + browserType: getBrowserName(),
1109 + enteredAt: Date.now()
1110 + };
1111 + if ("object" === typeof currentCollaborator && currentCollaborator) {
1112 + const user = currentCollaborator;
1113 + if ("id" in user && "name" in user) {
1114 + const collaboratorInfo = {
1115 + ...presentationInfo,
1116 + ..."avatar_urls" in user && hasValidAvatarUrls(user.avatar_urls) ? { avatar_urls: user.avatar_urls } : {},
1117 + id: user.id,
1118 + name: user.name,
1119 + slug: "slug" in user && "string" === typeof user.slug ? user.slug : ""
1120 + };
1121 + if (isCollaboratorInfo(collaboratorInfo) && null !== collaboratorInfo.id) {
1122 + return collaboratorInfo;
1123 + }
1124 + }
1125 + }
1056 1126 return {
1057 - avatar_urls,
1058 - // eslint-disable-line camelcase
1059 - browserType: getBrowserName(),
1060 - enteredAt: Date.now(),
1061 - id,
1062 - name,
1063 - slug
1127 + ...presentationInfo,
1128 + id: null,
1129 + // Keep shared awareness data language-neutral. The editor localizes this
1130 + // fallback name for the viewer when it is displayed.
1131 + name: "Anonymous User",
1132 + slug: `anonymous-${clientId}`
1064 1133 };
1065 1134 }
1066 1135 function getRecordValue(obj, key) {
1067 1136 if ("object" === typeof obj && null !== obj && key in obj) {
@@ -1346,11 +1415,17 @@
1346 1415 /**
1347 1416 * Set the current collaborator info in the local state.
1348 1417 */
1349 1418 async setCurrentCollaboratorInfo() {
1350 - const currentUser2 = await (0, import_data.resolveSelect)(STORE_NAME).getCurrentUser();
1351 - const collaboratorInfo = generateCollaboratorInfo(currentUser2);
1352 - this.setLocalStateField("collaboratorInfo", collaboratorInfo);
1419 + let currentUser2;
1420 + try {
1421 + currentUser2 = await (0, import_data.resolveSelect)(STORE_NAME).getCurrentUser();
1422 + } catch {
1423 + }
1424 + this.setLocalStateField(
1425 + "collaboratorInfo",
1426 + generateCollaboratorInfo(currentUser2, this.clientID)
1427 + );
1353 1428 }
1354 1429 };
1355 1430 var baseEqualityFieldChecks = {
1356 1431 collaboratorInfo: areCollaboratorInfosEqual
@@ -1418,11 +1493,11 @@
1418 1493 }
1419 1494 return null;
1420 1495 }
1421 1496 function usePostContentBlocks() {
1422 - return (0, import_data2.useSelect)((select4) => {
1497 + return (0, import_data2.useSelect)((select5) => {
1423 1498 const { getBlocksByName, getClientIdsTree } = unlock(
1424 - select4(import_block_editor.store)
1499 + select5(import_block_editor.store)
1425 1500 );
1426 1501 const [postContentClientId] = getBlocksByName("core/post-content");
1427 1502 return getClientIdsTree(postContentClientId ?? "");
1428 1503 }, []);
@@ -1987,17 +2062,17 @@
1987 2062 value.toJSON()
1988 2063 ])
1989 2064 );
1990 2065 const collaboratorMapData = new Map(
1991 - Array.from(this.getSeenStates().entries()).map(
1992 - ([clientId, collaboratorState]) => [
1993 - String(clientId),
1994 - {
1995 - name: collaboratorState.collaboratorInfo.name,
1996 - wpUserId: collaboratorState.collaboratorInfo.id
1997 - }
1998 - ]
1999 - )
2066 + Array.from(this.getSeenStates().entries()).filter(
2067 + ([, collaboratorState]) => isCollaboratorInfo(collaboratorState.collaboratorInfo)
2068 + ).map(([clientId, collaboratorState]) => [
2069 + String(clientId),
2070 + {
2071 + name: collaboratorState.collaboratorInfo.name,
2072 + wpUserId: collaboratorState.collaboratorInfo.id
2073 + }
2074 + ])
2000 2075 );
2001 2076 const serializableClientItems = {};
2002 2077 ydoc.store.clients.forEach((structs, clientId) => {
2003 2078 const items2 = structs.filter(this.isYItem);
@@ -3332,16 +3407,8 @@
3332 3407 key: "slug",
3333 3408 supportsPagination: false
3334 3409 },
3335 3410 {
3336 - label: (0, import_i18n.__)("Registered Templates"),
3337 - name: "registeredTemplate",
3338 - kind: "root",
3339 - baseURL: "/wp/v2/registered-templates",
3340 - key: "id",
3341 - supportsPagination: false
3342 - },
3343 - {
3344 3411 label: (0, import_i18n.__)("Font Collections"),
3345 3412 name: "fontCollection",
3346 3413 kind: "root",
3347 3414 baseURL: "/wp/v2/font-collections",
@@ -3462,11 +3529,13 @@
3462 3529 rawAttributes: POST_RAW_ATTRIBUTES,
3463 3530 getTitle: (record) => record?.title?.rendered || record?.title || (isTemplate ? capitalCase(record.slug ?? "") : String(record.id)),
3464 3531 __unstablePrePersist: (persistedRecord, edits) => prePersistPostType(persistedRecord, edits, name, isTemplate),
3465 3532 __unstable_rest_base: postType.rest_base,
3466 - supportsPagination: true,
3533 + // The templates controller returns the whole collection and never
3534 + // paginates.
3535 + supportsPagination: !isTemplate,
3467 3536 getRevisionsUrl: (parentId, revisionId) => `/${namespace}/${postType.rest_base}/${parentId}/revisions${revisionId ? "/" + revisionId : ""}`,
3468 - revisionKey: isTemplate && !window?.__experimentalTemplateActivate ? "wp_id" : DEFAULT_ENTITY_KEY
3537 + revisionKey: isTemplate ? "wp_id" : DEFAULT_ENTITY_KEY
3469 3538 };
3470 3539 if (!window.__experimentalEnableRealTimeCollaboration) {
3471 3540 return entity2;
3472 3541 }
@@ -3715,8 +3784,29 @@
3715 3784 ),
3716 3785 meta: action.meta
3717 3786 };
3718 3787 });
3788 + function removeQueryItems(queryItems, removedItems) {
3789 + const itemIds = queryItems.itemIds.filter(
3790 + (itemId) => !removedItems[itemId]
3791 + );
3792 + const removedCount = queryItems.itemIds.length - itemIds.length;
3793 + if (removedCount === 0) {
3794 + return queryItems;
3795 + }
3796 + const nextQueryItems = { ...queryItems, itemIds };
3797 + if (Number.isFinite(queryItems.meta?.totalItems)) {
3798 + nextQueryItems.meta = {
3799 + ...queryItems.meta,
3800 + totalItems: Math.max(
3801 + 0,
3802 + queryItems.meta.totalItems - removedCount
3803 + ),
3804 + totalPages: null
3805 + };
3806 + }
3807 + return nextQueryItems;
3808 + }
3719 3809 var queries = (state = {}, action) => {
3720 3810 switch (action.type) {
3721 3811 case "RECEIVE_ITEMS":
3722 3812 return receiveQueries(state, action);
@@ -3732,14 +3822,12 @@
3732 3822 Object.fromEntries(
3733 3823 Object.entries(contextQueries).map(
3734 3824 ([query, queryItems]) => [
3735 3825 query,
3736 - {
3737 - ...queryItems,
3738 - itemIds: queryItems.itemIds.filter(
3739 - (queryId) => !removedItems[queryId]
3740 - )
3741 - }
3826 + removeQueryItems(
3827 + queryItems,
3828 + removedItems
3829 + )
3742 3830 ]
3743 3831 )
3744 3832 )
3745 3833 ]
@@ -4352,26 +4440,26 @@
4352 4440 function getNavigationFallbackId(state) {
4353 4441 return state.navigationFallbackId;
4354 4442 }
4355 4443 var getBlockPatternsForPostType = (0, import_data8.createRegistrySelector)(
4356 - (select4) => (0, import_data8.createSelector)(
4357 - (state, postType) => select4(STORE_NAME).getBlockPatterns().filter(
4444 + (select5) => (0, import_data8.createSelector)(
4445 + (state, postType) => select5(STORE_NAME).getBlockPatterns().filter(
4358 4446 ({ postTypes }) => !postTypes || Array.isArray(postTypes) && postTypes.includes(postType)
4359 4447 ),
4360 - () => [select4(STORE_NAME).getBlockPatterns()]
4448 + () => [select5(STORE_NAME).getBlockPatterns()]
4361 4449 )
4362 4450 );
4363 4451 var getEntityRecordsPermissions = (0, import_data8.createRegistrySelector)(
4364 - (select4) => (0, import_data8.createSelector)(
4452 + (select5) => (0, import_data8.createSelector)(
4365 4453 (state, kind, name, ids) => {
4366 4454 const normalizedIds = Array.isArray(ids) ? ids : [ids];
4367 4455 return normalizedIds.map((id) => ({
4368 - delete: select4(STORE_NAME).canUser("delete", {
4456 + delete: select5(STORE_NAME).canUser("delete", {
4369 4457 kind,
4370 4458 name,
4371 4459 id
4372 4460 }),
4373 - update: select4(STORE_NAME).canUser("update", {
4461 + update: select5(STORE_NAME).canUser("update", {
4374 4462 kind,
4375 4463 name,
4376 4464 id
4377 4465 })
@@ -4396,11 +4484,11 @@
4396 4484 }
4397 4485 return value.toString();
4398 4486 }
4399 4487 var getHomePage = (0, import_data8.createRegistrySelector)(
4400 - (select4) => (0, import_data8.createSelector)(
4488 + (select5) => (0, import_data8.createSelector)(
4401 4489 () => {
4402 - const siteData = select4(STORE_NAME).getEntityRecord(
4490 + const siteData = select5(STORE_NAME).getEntityRecord(
4403 4491 "root",
4404 4492 "__unstableBase"
4405 4493 );
4406 4494 if (!siteData) {
@@ -4409,9 +4497,9 @@
4409 4497 const homepageId = siteData?.show_on_front === "page" ? normalizePageId(siteData.page_on_front) : null;
4410 4498 if (homepageId) {
4411 4499 return { postType: "page", postId: homepageId };
4412 4500 }
4413 - const frontPageTemplateId = select4(
4501 + const frontPageTemplateId = select5(
4414 4502 STORE_NAME
4415 4503 ).getDefaultTemplateId({
4416 4504 slug: "front-page"
4417 4505 });
@@ -4436,10 +4524,10 @@
4436 4524 })
4437 4525 ]
4438 4526 )
4439 4527 );
4440 - var getPostsPageId = (0, import_data8.createRegistrySelector)((select4) => () => {
4441 - const siteData = select4(STORE_NAME).getEntityRecord(
4528 + var getPostsPageId = (0, import_data8.createRegistrySelector)((select5) => () => {
4529 + const siteData = select5(STORE_NAME).getEntityRecord(
4442 4530 "root",
4443 4531 "__unstableBase"
4444 4532 );
4445 4533 return siteData?.show_on_front === "page" ? normalizePageId(siteData.page_for_posts) : null;
@@ -4444,15 +4532,15 @@
4444 4532 );
4445 4533 return siteData?.show_on_front === "page" ? normalizePageId(siteData.page_for_posts) : null;
4446 4534 });
4447 4535 var getTemplateId = (0, import_data8.createRegistrySelector)(
4448 - (select4) => (state, postType, postId) => {
4449 - const homepage = unlock(select4(STORE_NAME)).getHomePage();
4536 + (select5) => (state, postType, postId) => {
4537 + const homepage = unlock(select5(STORE_NAME)).getHomePage();
4450 4538 if (!homepage) {
4451 4539 return;
4452 4540 }
4453 4541 if (postType === "page" && postType === homepage?.postType && postId.toString() === homepage?.postId) {
4454 - const templates = select4(STORE_NAME).getEntityRecords(
4542 + const templates = select5(STORE_NAME).getEntityRecords(
4455 4543 "postType",
4456 4544 "wp_template",
4457 4545 {
4458 4546 per_page: -1
@@ -4460,14 +4548,16 @@
4460 4548 );
4461 4549 if (!templates) {
4462 4550 return;
4463 4551 }
4464 - const id = templates.find(({ slug }) => slug === "front-page")?.id;
4552 + const id = templates.find(
4553 + ({ slug }) => slug === "front-page"
4554 + )?.id;
4465 4555 if (id) {
4466 4556 return id;
4467 4557 }
4468 4558 }
4469 - const editedEntity = select4(STORE_NAME).getEditedEntityRecord(
4559 + const editedEntity = select5(STORE_NAME).getEditedEntityRecord(
4470 4560 "postType",
4471 4561 postType,
4472 4562 postId
4473 4563 );
@@ -4473,17 +4563,17 @@
4473 4563 );
4474 4564 if (!editedEntity) {
4475 4565 return;
4476 4566 }
4477 - const postsPageId = unlock(select4(STORE_NAME)).getPostsPageId();
4567 + const postsPageId = unlock(select5(STORE_NAME)).getPostsPageId();
4478 4568 if (postType === "page" && postsPageId === postId.toString()) {
4479 - return select4(STORE_NAME).getDefaultTemplateId({
4569 + return select5(STORE_NAME).getDefaultTemplateId({
4480 4570 slug: "home"
4481 4571 });
4482 4572 }
4483 4573 const currentTemplateSlug = editedEntity.template;
4484 4574 if (currentTemplateSlug) {
4485 - const currentTemplate = select4(STORE_NAME).getEntityRecords("postType", "wp_template", {
4575 + const currentTemplate = select5(STORE_NAME).getEntityRecords("postType", "wp_template", {
4486 4576 per_page: -1
4487 4577 })?.find(({ slug }) => slug === currentTemplateSlug);
4488 4578 if (currentTemplate) {
4489 4579 return currentTemplate.id;
@@ -4494,9 +4584,9 @@
4494 4584 slugToCheck = postType === "page" ? `${postType}-${editedEntity.slug}` : `single-${postType}-${editedEntity.slug}`;
4495 4585 } else {
4496 4586 slugToCheck = postType === "page" ? "page" : `single-${postType}`;
4497 4587 }
4498 - return select4(STORE_NAME).getDefaultTemplateId({
4588 + return select5(STORE_NAME).getDefaultTemplateId({
4499 4589 slug: slugToCheck
4500 4590 });
4501 4591 }
4502 4592 );
@@ -4536,10 +4626,10 @@
4536 4626
4537 4627 // packages/core-data/build-module/selectors.mjs
4538 4628 var EMPTY_OBJECT2 = {};
4539 4629 var isRequestingEmbedPreview = (0, import_data9.createRegistrySelector)(
4540 - (select4) => (state, url) => {
4541 - return select4(STORE_NAME).isResolving("getEmbedPreview", [
4630 + (select5) => (state, url) => {
4631 + return select5(STORE_NAME).isResolving("getEmbedPreview", [
4542 4632 url
4543 4633 ]);
4544 4634 }
4545 4635 );
@@ -4592,54 +4682,34 @@
4592 4682 return state.entities.config?.find(
4593 4683 (config) => config.kind === kind && config.name === name
4594 4684 );
4595 4685 }
4596 - var getEntityRecord = (0, import_data9.createSelector)(
4597 - ((state, kind, name, key, query) => {
4598 - logEntityDeprecation(kind, name, "getEntityRecord");
4599 - const queriedState = state.entities.records?.[kind]?.[name]?.queriedData;
4600 - if (!queriedState) {
4686 + var getEntityRecord = ((state, kind, name, recordId, query) => {
4687 + logEntityDeprecation(kind, name, "getEntityRecord");
4688 + const queriedState = state.entities.records?.[kind]?.[name]?.queriedData;
4689 + if (!queriedState) {
4690 + return void 0;
4691 + }
4692 + const context = query?.context ?? "default";
4693 + if (!query || !query._fields) {
4694 + if (!queriedState.itemIsComplete[context]?.[recordId]) {
4601 4695 return void 0;
4602 4696 }
4603 - const context = query?.context ?? "default";
4604 - if (!query || !query._fields) {
4605 - if (!queriedState.itemIsComplete[context]?.[key]) {
4606 - return void 0;
4607 - }
4608 - return queriedState.items[context][key];
4609 - }
4610 - const item = queriedState.items[context]?.[key];
4611 - if (!item) {
4612 - return item;
4613 - }
4614 - const filteredItem = {};
4615 - const fields = get_normalized_comma_separable_default(query._fields) ?? [];
4616 - for (let f = 0; f < fields.length; f++) {
4617 - const field = fields[f].split(".");
4618 - let value = item;
4619 - field.forEach((fieldName) => {
4620 - value = value?.[fieldName];
4621 - });
4622 - setNestedValue(filteredItem, field, value);
4623 - }
4624 - return filteredItem;
4625 - }),
4626 - (state, kind, name, recordId, query) => {
4627 - const context = query?.context ?? "default";
4628 - const queriedState = state.entities.records?.[kind]?.[name]?.queriedData;
4629 - return [
4630 - queriedState?.items[context]?.[recordId],
4631 - queriedState?.itemIsComplete[context]?.[recordId]
4632 - ];
4697 + return queriedState.items[context][recordId];
4633 4698 }
4634 - );
4635 - getEntityRecord.__unstableNormalizeArgs = (args) => {
4699 + const item = queriedState.items[context]?.[recordId];
4700 + if (!item) {
4701 + return item;
4702 + }
4703 + return getFilteredItem(item, query._fields);
4704 + });
4705 + getEntityRecord.normalizeArgs = (args) => {
4636 4706 const newArgs = [...args];
4637 4707 const recordKey = newArgs?.[2];
4638 4708 newArgs[2] = isNumericID(recordKey) ? Number(recordKey) : recordKey;
4639 4709 return newArgs;
4640 4710 };
4641 - function hasEntityRecord(state, kind, name, key, query) {
4711 + function hasEntityRecord(state, kind, name, recordId, query) {
4642 4712 const queriedState = state.entities.records?.[kind]?.[name]?.queriedData;
4643 4713 if (!queriedState) {
4644 4714 return false;
4645 4715 }
@@ -4644,11 +4714,11 @@
4644 4714 return false;
4645 4715 }
4646 4716 const context = query?.context ?? "default";
4647 4717 if (!query || !query._fields) {
4648 - return !!queriedState.itemIsComplete[context]?.[key];
4718 + return !!queriedState.itemIsComplete[context]?.[recordId];
4649 4719 }
4650 - const item = queriedState.items[context]?.[key];
4720 + const item = queriedState.items[context]?.[recordId];
4651 4721 if (!item) {
4652 4722 return false;
4653 4723 }
4654 4724 const fields = get_normalized_comma_separable_default(query._fields) ?? [];
@@ -4664,19 +4734,19 @@
4664 4734 }
4665 4735 }
4666 4736 return true;
4667 4737 }
4668 - function __experimentalGetEntityRecordNoResolver(state, kind, name, key) {
4669 - return getEntityRecord(state, kind, name, key);
4738 + function __experimentalGetEntityRecordNoResolver(state, kind, name, recordId) {
4739 + return getEntityRecord(state, kind, name, recordId);
4670 4740 }
4671 4741 var getRawEntityRecord = (0, import_data9.createSelector)(
4672 - (state, kind, name, key) => {
4742 + (state, kind, name, recordId) => {
4673 4743 logEntityDeprecation(kind, name, "getRawEntityRecord");
4674 4744 const record = getEntityRecord(
4675 4745 state,
4676 4746 kind,
4677 4747 name,
4678 - key
4748 + recordId
4679 4749 );
4680 4750 const config = getEntityConfig(state, kind, name);
4681 4751 if (!record || !config?.rawAttributes?.length) {
4682 4752 return record;
@@ -4681,17 +4751,17 @@
4681 4751 if (!record || !config?.rawAttributes?.length) {
4682 4752 return record;
4683 4753 }
4684 4754 return Object.fromEntries(
4685 - Object.keys(record).map((_key) => {
4686 - if (config.rawAttributes.includes(_key)) {
4687 - const rawValue = record[_key]?.raw;
4755 + Object.keys(record).map((key) => {
4756 + if (config.rawAttributes.includes(key)) {
4757 + const rawValue = record[key]?.raw;
4688 4758 return [
4689 - _key,
4690 - rawValue !== void 0 ? rawValue : record[_key]
4759 + key,
4760 + rawValue !== void 0 ? rawValue : record[key]
4691 4761 ];
4692 4762 }
4693 - return [_key, record[_key]];
4763 + return [key, record[key]];
4694 4764 })
4695 4765 );
4696 4766 },
4697 4767 (state, kind, name, recordId, query) => {
@@ -4820,9 +4890,9 @@
4820 4890 (state) => [state.entities.records]
4821 4891 );
4822 4892 function getEntityRecordEdits(state, kind, name, recordId) {
4823 4893 logEntityDeprecation(kind, name, "getEntityRecordEdits");
4824 - return state.entities.records?.[kind]?.[name]?.edits?.[recordId];
4894 + return state.entities.records?.[kind]?.[name]?.edits?.[String(recordId)];
4825 4895 }
4826 4896 var getEntityRecordNonTransientEdits = (0, import_data9.createSelector)(
4827 4897 (state, kind, name, recordId) => {
4828 4898 logEntityDeprecation(kind, name, "getEntityRecordNonTransientEdits");
@@ -4839,9 +4909,9 @@
4839 4909 }, {});
4840 4910 },
4841 4911 (state, kind, name, recordId) => [
4842 4912 state.entities.config,
4843 - state.entities.records?.[kind]?.[name]?.edits?.[recordId]
4913 + state.entities.records?.[kind]?.[name]?.edits?.[String(recordId)]
4844 4914 ]
4845 4915 );
4846 4916 function hasEditsForEntityRecord(state, kind, name, recordId) {
4847 4917 logEntityDeprecation(kind, name, "hasEditsForEntityRecord");
@@ -4867,9 +4937,9 @@
4867 4937 return [
4868 4938 state.entities.config,
4869 4939 state.entities.records?.[kind]?.[name]?.queriedData.items[context]?.[recordId],
4870 4940 state.entities.records?.[kind]?.[name]?.queriedData.itemIsComplete[context]?.[recordId],
4871 - state.entities.records?.[kind]?.[name]?.edits?.[recordId]
4941 + state.entities.records?.[kind]?.[name]?.edits?.[String(recordId)]
4872 4942 ];
4873 4943 }
4874 4944 );
4875 4945 function isAutosavingEntityRecord(state, kind, name, recordId) {
@@ -4878,17 +4948,17 @@
4878 4948 return Boolean(pending && isAutosave);
4879 4949 }
4880 4950 function isSavingEntityRecord(state, kind, name, recordId) {
4881 4951 logEntityDeprecation(kind, name, "isSavingEntityRecord");
4882 - return state.entities.records?.[kind]?.[name]?.saving?.[recordId]?.pending ?? false;
4952 + return state.entities.records?.[kind]?.[name]?.saving?.[String(recordId)]?.pending ?? false;
4883 4953 }
4884 4954 function isDeletingEntityRecord(state, kind, name, recordId) {
4885 4955 logEntityDeprecation(kind, name, "isDeletingEntityRecord");
4886 - return state.entities.records?.[kind]?.[name]?.deleting?.[recordId]?.pending ?? false;
4956 + return state.entities.records?.[kind]?.[name]?.deleting?.[String(recordId)]?.pending ?? false;
4887 4957 }
4888 4958 function getLastEntitySaveError(state, kind, name, recordId) {
4889 4959 logEntityDeprecation(kind, name, "getLastEntitySaveError");
4890 - return state.entities.records?.[kind]?.[name]?.saving?.[recordId]?.error;
4960 + return state.entities.records?.[kind]?.[name]?.saving?.[String(recordId)]?.error;
4891 4961 }
4892 4962 function getLastEntityDeleteError(state, kind, name, recordId) {
4893 4963 logEntityDeprecation(kind, name, "getLastEntityDeleteError");
4894 4964 return state.entities.records?.[kind]?.[name]?.deleting?.[recordId]?.error;
@@ -4970,10 +5040,10 @@
4970 5040 (autosave) => autosave.author === authorId
4971 5041 );
4972 5042 }
4973 5043 var hasFetchedAutosaves = (0, import_data9.createRegistrySelector)(
4974 - (select4) => (state, postType, postId) => {
4975 - return select4(STORE_NAME).hasFinishedResolution("getAutosaves", [
5044 + (select5) => (state, postType, postId) => {
5045 + return select5(STORE_NAME).hasFinishedResolution("getAutosaves", [
4976 5046 postType,
4977 5047 postId
4978 5048 ]);
4979 5049 }
@@ -5052,47 +5122,27 @@
5052 5122 }
5053 5123 }
5054 5124 return true;
5055 5125 }
5056 - var getRevision = (0, import_data9.createSelector)(
5057 - (state, kind, name, recordKey, revisionKey, query) => {
5058 - logEntityDeprecation(kind, name, "getRevision");
5059 - const queriedState = state.entities.records?.[kind]?.[name]?.revisions?.[recordKey];
5060 - if (!queriedState) {
5126 + var getRevision = (state, kind, name, recordKey, revisionKey, query) => {
5127 + logEntityDeprecation(kind, name, "getRevision");
5128 + const queriedState = state.entities.records?.[kind]?.[name]?.revisions?.[recordKey];
5129 + if (!queriedState) {
5130 + return void 0;
5131 + }
5132 + const context = query?.context ?? "default";
5133 + if (!query || !query._fields) {
5134 + if (!queriedState.itemIsComplete[context]?.[revisionKey]) {
5061 5135 return void 0;
5062 5136 }
5063 - const context = query?.context ?? "default";
5064 - if (!query || !query._fields) {
5065 - if (!queriedState.itemIsComplete[context]?.[revisionKey]) {
5066 - return void 0;
5067 - }
5068 - return queriedState.items[context][revisionKey];
5069 - }
5070 - const item = queriedState.items[context]?.[revisionKey];
5071 - if (!item) {
5072 - return item;
5073 - }
5074 - const filteredItem = {};
5075 - const fields = get_normalized_comma_separable_default(query._fields) ?? [];
5076 - for (let f = 0; f < fields.length; f++) {
5077 - const field = fields[f].split(".");
5078 - let value = item;
5079 - field.forEach((fieldName) => {
5080 - value = value?.[fieldName];
5081 - });
5082 - setNestedValue(filteredItem, field, value);
5083 - }
5084 - return filteredItem;
5085 - },
5086 - (state, kind, name, recordKey, revisionKey, query) => {
5087 - const context = query?.context ?? "default";
5088 - const queriedState = state.entities.records?.[kind]?.[name]?.revisions?.[recordKey];
5089 - return [
5090 - queriedState?.items?.[context]?.[revisionKey],
5091 - queriedState?.itemIsComplete?.[context]?.[revisionKey]
5092 - ];
5137 + return queriedState.items[context][revisionKey];
5093 5138 }
5094 - );
5139 + const item = queriedState.items[context]?.[revisionKey];
5140 + if (!item) {
5141 + return item;
5142 + }
5143 + return getFilteredItem(item, query._fields);
5144 + };
5095 5145
5096 5146 // packages/core-data/build-module/actions.mjs
5097 5147 var actions_exports = {};
5098 5148 __export(actions_exports, {
@@ -5460,12 +5510,9 @@
5460 5510 name,
5461 5511 recordId
5462 5512 });
5463 5513 let hasError = false;
5464 - let { baseURL } = entityConfig;
5465 - if (kind === "postType" && name === "wp_template" && (recordId && typeof recordId === "string" && !/^\d+$/.test(recordId) || !window?.__experimentalTemplateActivate)) {
5466 - baseURL = baseURL.slice(0, baseURL.lastIndexOf("/")) + "/templates";
5467 - }
5514 + const { baseURL } = entityConfig;
5468 5515 try {
5469 5516 let path = `${baseURL}/${recordId}`;
5470 5517 if (query) {
5471 5518 path = (0, import_url3.addQueryArgs)(path, query);
@@ -5498,11 +5545,11 @@
5498 5545 } finally {
5499 5546 dispatch3.__unstableReleaseStoreLock(lock2);
5500 5547 }
5501 5548 };
5502 - var editEntityRecord = (kind, name, recordId, edits, options = {}) => ({ select: select4, dispatch: dispatch3 }) => {
5549 + var editEntityRecord = (kind, name, recordId, edits, options = {}) => ({ select: select5, dispatch: dispatch3 }) => {
5503 5550 logEntityDeprecation(kind, name, "editEntityRecord");
5504 - const entityConfig = select4.getEntityConfig(kind, name);
5551 + const entityConfig = select5.getEntityConfig(kind, name);
5505 5552 if (!entityConfig) {
5506 5553 throw new Error(
5507 5554 `The entity being edited (${kind}, ${name}) does not have a loaded config.`
5508 5555 );
@@ -5507,10 +5554,10 @@
5507 5554 `The entity being edited (${kind}, ${name}) does not have a loaded config.`
5508 5555 );
5509 5556 }
5510 5557 const { mergedEdits = {} } = entityConfig;
5511 - const record = select4.getRawEntityRecord(kind, name, recordId);
5512 - const editedRecord = select4.getEditedEntityRecord(
5558 + const record = select5.getRawEntityRecord(kind, name, recordId);
5559 + const editedRecord = select5.getEditedEntityRecord(
5513 5560 kind,
5514 5561 name,
5515 5562 recordId
5516 5563 );
@@ -5539,9 +5586,9 @@
5539 5586 { isNewUndoLevel }
5540 5587 );
5541 5588 }
5542 5589 if (!options.undoIgnore) {
5543 - select4.getUndoManager().addRecord(
5590 + select5.getUndoManager().addRecord(
5544 5591 [
5545 5592 {
5546 5593 id: { kind, name, recordId },
5547 5594 changes: Object.keys(edits).reduce((acc, key) => {
@@ -5560,10 +5607,10 @@
5560 5607 type: "EDIT_ENTITY_RECORD",
5561 5608 ...edit
5562 5609 });
5563 5610 };
5564 - var clearEntityRecordEdits = (kind, name, recordId) => ({ select: select4, dispatch: dispatch3 }) => {
5565 - const entityConfig = select4.getEntityConfig(kind, name);
5611 + var clearEntityRecordEdits = (kind, name, recordId) => ({ select: select5, dispatch: dispatch3 }) => {
5612 + const entityConfig = select5.getEntityConfig(kind, name);
5566 5613 logEntityDeprecation(kind, name, "clearEntityRecordEdits");
5567 5614 if (!entityConfig) {
5568 5615 throw new Error(
5569 5616 `The entity being edited (${kind}, ${name}) does not have a loaded config.`
@@ -5568,9 +5615,9 @@
5568 5615 throw new Error(
5569 5616 `The entity being edited (${kind}, ${name}) does not have a loaded config.`
5570 5617 );
5571 5618 }
5572 - const currentEdits = select4.getEntityRecordEdits(
5619 + const currentEdits = select5.getEntityRecordEdits(
5573 5620 kind,
5574 5621 name,
5575 5622 recordId
5576 5623 );
@@ -5591,10 +5638,10 @@
5591 5638 recordId,
5592 5639 edits: clearedEdits
5593 5640 });
5594 5641 };
5595 - var undo = () => ({ select: select4, dispatch: dispatch3 }) => {
5596 - const undoRecord = select4.getUndoManager().undo();
5642 + var undo = () => ({ select: select5, dispatch: dispatch3 }) => {
5643 + const undoRecord = select5.getUndoManager().undo();
5597 5644 if (!undoRecord) {
5598 5645 return;
5599 5646 }
5600 5647 dispatch3({
@@ -5601,10 +5648,10 @@
5601 5648 type: "UNDO",
5602 5649 record: undoRecord
5603 5650 });
5604 5651 };
5605 - var redo = () => ({ select: select4, dispatch: dispatch3 }) => {
5606 - const redoRecord = select4.getUndoManager().redo();
5652 + var redo = () => ({ select: select5, dispatch: dispatch3 }) => {
5653 + const redoRecord = select5.getUndoManager().redo();
5607 5654 if (!redoRecord) {
5608 5655 return;
5609 5656 }
5610 5657 dispatch3({
@@ -5611,12 +5658,12 @@
5611 5658 type: "REDO",
5612 5659 record: redoRecord
5613 5660 });
5614 5661 };
5615 - var __unstableCreateUndoLevel = () => ({ select: select4 }) => {
5616 - select4.getUndoManager().addRecord();
5662 + var __unstableCreateUndoLevel = () => ({ select: select5 }) => {
5663 + select5.getUndoManager().addRecord();
5617 5664 };
5618 - var saveEntityRecord = (kind, name, record, options = {}) => async ({ select: select4, resolveSelect: resolveSelect2, dispatch: dispatch3 }) => {
5665 + var saveEntityRecord = (kind, name, record, options = {}) => async ({ select: select5, resolveSelect: resolveSelect2, dispatch: dispatch3 }) => {
5619 5666 const {
5620 5667 isAutosave = false,
5621 5668 __unstableFetch = import_api_fetch4.default,
5622 5669 __unstableSkipSyncUpdate = false,
@@ -5641,9 +5688,9 @@
5641 5688 try {
5642 5689 for (const [key, value] of Object.entries(record)) {
5643 5690 if (typeof value === "function") {
5644 5691 const evaluatedValue = value(
5645 - select4.getEditedEntityRecord(kind, name, recordId)
5692 + select5.getEditedEntityRecord(kind, name, recordId)
5646 5693 );
5647 5694 dispatch3.editEntityRecord(
5648 5695 kind,
5649 5696 name,
@@ -5665,15 +5712,12 @@
5665 5712 });
5666 5713 let updatedRecord;
5667 5714 let error;
5668 5715 let hasError = false;
5669 - let { baseURL } = entityConfig;
5670 - if (kind === "postType" && name === "wp_template" && (recordId && typeof recordId === "string" && !/^\d+$/.test(recordId) || !window?.__experimentalTemplateActivate)) {
5671 - baseURL = baseURL.slice(0, baseURL.lastIndexOf("/")) + "/templates";
5672 - }
5716 + const { baseURL } = entityConfig;
5673 5717 try {
5674 5718 const path = `${baseURL}${recordId ? "/" + recordId : ""}`;
5675 - const persistedRecord = !isNewRecord ? select4.getRawEntityRecord(kind, name, recordId) : {};
5719 + const persistedRecord = !isNewRecord ? select5.getRawEntityRecord(kind, name, recordId) : {};
5676 5720 if (entityConfig.syncConfig && !__unstableSkipSyncUpdate && !isNewRecord && persistedRecord) {
5677 5721 getSyncManager()?.update(
5678 5722 `${kind}/${name}`,
5679 5723 recordId,
@@ -5854,11 +5898,11 @@
5854 5898 ...resultPromises
5855 5899 ]);
5856 5900 return results;
5857 5901 };
5858 - var saveEditedEntityRecord = (kind, name, recordId, options) => async ({ select: select4, dispatch: dispatch3, resolveSelect: resolveSelect2 }) => {
5902 + var saveEditedEntityRecord = (kind, name, recordId, options) => async ({ select: select5, dispatch: dispatch3, resolveSelect: resolveSelect2 }) => {
5859 5903 logEntityDeprecation(kind, name, "saveEditedEntityRecord");
5860 - if (!select4.hasEditsForEntityRecord(kind, name, recordId)) {
5904 + if (!select5.hasEditsForEntityRecord(kind, name, recordId)) {
5861 5905 return;
5862 5906 }
5863 5907 const configs = await resolveSelect2.getEntitiesConfig(kind);
5864 5908 const entityConfig = configs.find(
@@ -5867,9 +5911,9 @@
5867 5911 if (!entityConfig) {
5868 5912 return;
5869 5913 }
5870 5914 const entityIdKey = entityConfig.key || DEFAULT_ENTITY_KEY;
5871 - const edits = select4.getEntityRecordNonTransientEdits(
5915 + const edits = select5.getEntityRecordNonTransientEdits(
5872 5916 kind,
5873 5917 name,
5874 5918 recordId
5875 5919 );
@@ -5875,18 +5919,18 @@
5875 5919 );
5876 5920 const record = { [entityIdKey]: recordId, ...edits };
5877 5921 return await dispatch3.saveEntityRecord(kind, name, record, options);
5878 5922 };
5879 - var __experimentalSaveSpecifiedEntityEdits = (kind, name, recordId, itemsToSave, options) => async ({ select: select4, dispatch: dispatch3, resolveSelect: resolveSelect2 }) => {
5923 + var __experimentalSaveSpecifiedEntityEdits = (kind, name, recordId, itemsToSave, options) => async ({ select: select5, dispatch: dispatch3, resolveSelect: resolveSelect2 }) => {
5880 5924 logEntityDeprecation(
5881 5925 kind,
5882 5926 name,
5883 5927 "__experimentalSaveSpecifiedEntityEdits"
5884 5928 );
5885 - if (!select4.hasEditsForEntityRecord(kind, name, recordId)) {
5929 + if (!select5.hasEditsForEntityRecord(kind, name, recordId)) {
5886 5930 return;
5887 5931 }
5888 - const edits = select4.getEntityRecordNonTransientEdits(
5932 + const edits = select5.getEntityRecordNonTransientEdits(
5889 5933 kind,
5890 5934 name,
5891 5935 recordId
5892 5936 );
@@ -6404,8 +6448,9 @@
6404 6448 return results;
6405 6449 }
6406 6450 function sortResults(results, search) {
6407 6451 const searchTokens = tokenize(search);
6452 + const scoreKey = (result) => `${result.kind}:${result.type}:${result.id}`;
6408 6453 const scores = {};
6409 6454 for (const result of results) {
6410 6455 if (result.title) {
6411 6456 const titleTokens = tokenize(result.title);
@@ -6420,14 +6465,16 @@
6420 6465 )
6421 6466 );
6422 6467 const exactMatchScore = exactMatchingTokens.length / titleTokens.length * 10;
6423 6468 const subMatchScore = subMatchingTokens.length / titleTokens.length;
6424 - scores[result.id] = exactMatchScore + subMatchScore;
6469 + scores[scoreKey(result)] = exactMatchScore + subMatchScore;
6425 6470 } else {
6426 - scores[result.id] = 0;
6471 + scores[scoreKey(result)] = 0;
6427 6472 }
6428 6473 }
6429 - return results.sort((a, b) => scores[b.id] - scores[a.id]);
6474 + return results.sort(
6475 + (a, b) => scores[scoreKey(b)] - scores[scoreKey(a)]
6476 + );
6430 6477 }
6431 6478 function tokenize(text) {
6432 6479 return text.toLowerCase().match(/[\p{L}\p{N}]+/gu) || [];
6433 6480 }
@@ -6481,12 +6528,32 @@
6481 6528 );
6482 6529 }
6483 6530
6484 6531 // packages/core-data/build-module/parsed-blocks-cache.mjs
6485 - var parsedBlocksCache = /* @__PURE__ */ new Map();
6532 + var import_data10 = __toESM(require_data(), 1);
6533 + var import_blocks5 = __toESM(require_blocks(), 1);
6534 + var caches = /* @__PURE__ */ new WeakMap();
6486 6535 function getCacheKey(kind, name, id) {
6487 6536 return `${kind}:${name}:${id}`;
6488 6537 }
6538 + function getBlockTypes2() {
6539 + return (0, import_data10.select)(import_blocks5.store).getBlockTypes();
6540 + }
6541 + function getCachedBlocks(kind, name, id, content) {
6542 + const cached = caches.get(getBlockTypes2())?.get(getCacheKey(kind, name, id));
6543 + if (cached && cached.content === content) {
6544 + return cached.blocks;
6545 + }
6546 + }
6547 + function setCachedBlocks(kind, name, id, content, blocks) {
6548 + const blockTypes = getBlockTypes2();
6549 + let cache3 = caches.get(blockTypes);
6550 + if (!cache3) {
6551 + cache3 = /* @__PURE__ */ new Map();
6552 + caches.set(blockTypes, cache3);
6553 + }
6554 + cache3.set(getCacheKey(kind, name, id), { content, blocks });
6555 + }
6489 6556
6490 6557 // packages/core-data/build-module/resolvers.mjs
6491 6558 var getAuthors2 = (query) => async ({ dispatch: dispatch3 }) => {
6492 6559 const path = (0, import_url6.addQueryArgs)(
@@ -6499,9 +6566,9 @@
6499 6566 var getCurrentUser2 = () => async ({ dispatch: dispatch3 }) => {
6500 6567 const currentUser2 = await (0, import_api_fetch9.default)({ path: "/wp/v2/users/me" });
6501 6568 dispatch3.receiveCurrentUser(currentUser2);
6502 6569 };
6503 - var getEntityRecord2 = (kind, name, key = "", query) => async ({ select: select4, dispatch: dispatch3, registry, resolveSelect: resolveSelect2 }) => {
6570 + var getEntityRecord2 = (kind, name, key = "", query) => async ({ select: select5, dispatch: dispatch3, registry, resolveSelect: resolveSelect2 }) => {
6504 6571 const configs = await resolveSelect2.getEntitiesConfig(kind);
6505 6572 const entityConfig = configs.find(
6506 6573 (config) => config.name === name && config.kind === kind
6507 6574 );
@@ -6525,9 +6592,9 @@
6525 6592 ].join()
6526 6593 };
6527 6594 }
6528 6595 if (query !== void 0 && query._fields) {
6529 - const hasRecord = select4.hasEntityRecord(
6596 + const hasRecord = select5.hasEntityRecord(
6530 6597 kind,
6531 6598 name,
6532 6599 key,
6533 6600 query
@@ -6535,12 +6602,9 @@
6535 6602 if (hasRecord) {
6536 6603 return;
6537 6604 }
6538 6605 }
6539 - let { baseURL } = entityConfig;
6540 - if (kind === "postType" && name === "wp_template" && (key && typeof key === "string" && !/^\d+$/.test(key) || !window?.__experimentalTemplateActivate)) {
6541 - baseURL = baseURL.slice(0, baseURL.lastIndexOf("/")) + "/templates";
6542 - }
6606 + const { baseURL } = entityConfig;
6543 6607 const path = (0, import_url6.addQueryArgs)(baseURL + (key ? "/" + key : ""), {
6544 6608 ...entityConfig.baseURLParams,
6545 6609 ...query
6546 6610 });
@@ -6548,9 +6612,8 @@
6548 6612 const record = await response.json();
6549 6613 const permissions = getUserPermissionsFromAllowHeader(
6550 6614 response.headers?.get("allow")
6551 6615 );
6552 - const canUserResolutionsArgs = [];
6553 6616 const receiveUserPermissionArgs = {};
6554 6617 for (const action of ALLOWED_RESOURCE_ACTIONS) {
6555 6618 receiveUserPermissionArgs[getUserPermissionCacheKey(action, {
6556 6619 kind,
@@ -6556,13 +6619,10 @@
6556 6619 kind,
6557 6620 name,
6558 6621 id: key
6559 6622 })] = permissions[action];
6560 - canUserResolutionsArgs.push([
6561 - action,
6562 - { kind, name, id: key }
6563 - ]);
6564 6623 }
6624 + const canUserResolutionsArgs = [[{ kind, name, id: key }]];
6565 6625 if (entityConfig.syncConfig && isNumericID(key) && !query) {
6566 6626 const objectType = `${kind}/${name}`;
6567 6627 const objectId = key;
6568 6628 const recordWithTransients = { ...record };
@@ -6571,14 +6631,17 @@
6571 6631 ).forEach(([propName, transientConfig]) => {
6572 6632 recordWithTransients[propName] = transientConfig.read(recordWithTransients);
6573 6633 });
6574 6634 if (recordWithTransients.blocks && typeof recordWithTransients.content?.raw === "string") {
6575 - parsedBlocksCache.set(getCacheKey(kind, name, key), {
6576 - content: recordWithTransients.content.raw,
6577 - blocks: recordWithTransients.blocks
6578 - });
6635 + setCachedBlocks(
6636 + kind,
6637 + name,
6638 + key,
6639 + recordWithTransients.content.raw,
6640 + recordWithTransients.blocks
6641 + );
6579 6642 }
6580 - const syncManager2 = select4?.isCollaborationSupported?.() === false ? void 0 : getSyncManager();
6643 + const syncManager2 = select5?.isCollaborationSupported?.() === false ? void 0 : getSyncManager();
6581 6644 void syncManager2?.load(
6582 6645 entityConfig.syncConfig,
6583 6646 objectType,
6584 6647 objectId,
@@ -6725,13 +6788,9 @@
6725 6788 ])
6726 6789 ].join()
6727 6790 };
6728 6791 }
6729 - let { baseURL } = entityConfig;
6730 - const { combinedTemplates = true } = query;
6731 - if (kind === "postType" && name === "wp_template" && combinedTemplates) {
6732 - baseURL = baseURL.slice(0, baseURL.lastIndexOf("/")) + "/templates";
6733 - }
6792 + const { baseURL } = entityConfig;
6734 6793 const path = (0, import_url6.addQueryArgs)(baseURL, {
6735 6794 ...entityConfig.baseURLParams,
6736 6795 ...query
6737 6796 });
@@ -6738,16 +6797,9 @@
6738 6797 let records = [], meta;
6739 6798 if (entityConfig.supportsPagination && query.per_page !== -1) {
6740 6799 const response = await (0, import_api_fetch9.default)({ path, parse: false });
6741 6800 records = Object.values(await response.json());
6742 - meta = {
6743 - totalItems: parseInt(
6744 - response.headers.get("X-WP-Total")
6745 - ),
6746 - totalPages: parseInt(
6747 - response.headers.get("X-WP-TotalPages")
6748 - )
6749 - };
6801 + meta = getPaginationMeta(response.headers);
6750 6802 } else if (query.per_page === -1 && query[RECEIVE_INTERMEDIATE_RESULTS] === true) {
6751 6803 let page = 1;
6752 6804 let totalPages;
6753 6805 do {
@@ -6755,16 +6807,13 @@
6755 6807 path: (0, import_url6.addQueryArgs)(path, { page, per_page: 100 }),
6756 6808 parse: false
6757 6809 });
6758 6810 const pageRecords = Object.values(await response.json());
6759 - totalPages = parseInt(
6760 - response.headers.get("X-WP-TotalPages")
6761 - );
6811 + const pageMeta = getPaginationMeta(response.headers);
6812 + totalPages = pageMeta.totalPages ?? 1;
6762 6813 if (!meta) {
6763 6814 meta = {
6764 - totalItems: parseInt(
6765 - response.headers.get("X-WP-Total")
6766 - ),
6815 + totalItems: pageMeta.totalItems,
6767 6816 totalPages: 1
6768 6817 };
6769 6818 }
6770 6819 records.push(...pageRecords);
@@ -6847,13 +6896,12 @@
6847 6896 }));
6848 6897 const canUserResolutionsArgs = [];
6849 6898 const receiveUserPermissionArgs = {};
6850 6899 for (const targetHint of targetHints) {
6900 + canUserResolutionsArgs.push([
6901 + { kind, name, id: targetHint.id }
6902 + ]);
6851 6903 for (const action of ALLOWED_RESOURCE_ACTIONS) {
6852 - canUserResolutionsArgs.push([
6853 - action,
6854 - { kind, name, id: targetHint.id }
6855 - ]);
6856 6904 receiveUserPermissionArgs[getUserPermissionCacheKey(action, {
6857 6905 kind,
6858 6906 name,
6859 6907 id: targetHint.id
@@ -6902,26 +6950,9 @@
6902 6950 } catch {
6903 6951 dispatch3.receiveEmbedPreview(url, false);
6904 6952 }
6905 6953 };
6906 - var canUser2 = (requestedAction, resource, id) => async ({ dispatch: dispatch3, registry, resolveSelect: resolveSelect2 }) => {
6907 - if (!ALLOWED_RESOURCE_ACTIONS.includes(requestedAction)) {
6908 - throw new Error(`'${requestedAction}' is not a valid action.`);
6909 - }
6910 - const { hasStartedResolution } = registry.select(STORE_NAME);
6911 - for (const relatedAction of ALLOWED_RESOURCE_ACTIONS) {
6912 - if (relatedAction === requestedAction) {
6913 - continue;
6914 - }
6915 - const isAlreadyResolving = hasStartedResolution("canUser", [
6916 - relatedAction,
6917 - resource,
6918 - id
6919 - ]);
6920 - if (isAlreadyResolving) {
6921 - return;
6922 - }
6923 - }
6954 + var canUser2 = (resource, id) => async ({ dispatch: dispatch3, resolveSelect: resolveSelect2 }) => {
6924 6955 let resourcePath = null;
6925 6956 if (typeof resource === "object") {
6926 6957 if (!resource.kind || !resource.name) {
6927 6958 throw new Error("The entity resource object is not valid.");
@@ -6952,22 +6983,16 @@
6952 6983 const permissions = getUserPermissionsFromAllowHeader(
6953 6984 response.headers?.get("allow")
6954 6985 );
6955 6986 const receiveUserPermissionArgs = {};
6956 - const canUserResolutionsArgs = [];
6957 6987 for (const action of ALLOWED_RESOURCE_ACTIONS) {
6958 6988 receiveUserPermissionArgs[getUserPermissionCacheKey(action, resource, id)] = permissions[action];
6959 - if (action !== requestedAction) {
6960 - canUserResolutionsArgs.push([action, resource, id]);
6961 - }
6962 6989 }
6963 - registry.batch(() => {
6964 - dispatch3.receiveUserPermissions(receiveUserPermissionArgs);
6965 - dispatch3.finishResolutions("canUser", canUserResolutionsArgs);
6966 - });
6990 + dispatch3.receiveUserPermissions(receiveUserPermissionArgs);
6967 6991 };
6968 - var canUserEditEntityRecord2 = (kind, name, recordId) => async ({ dispatch: dispatch3 }) => {
6969 - await dispatch3(canUser2("update", { kind, name, id: recordId }));
6992 + canUser2.getResolutionArgs = (action, resource, id) => [resource, id];
6993 + var canUserEditEntityRecord2 = (kind, name, recordId) => async ({ resolveSelect: resolveSelect2 }) => {
6994 + await resolveSelect2.canUser("update", { kind, name, id: recordId });
6970 6995 };
6971 6996 var getAutosaves2 = (postType, postId) => async ({ dispatch: dispatch3, resolveSelect: resolveSelect2 }) => {
6972 6997 const {
6973 6998 rest_base: restBase,
@@ -7081,9 +7106,9 @@
7081 7106 type: "RECEIVE_USER_PATTERN_CATEGORIES",
7082 7107 patternCategories: mappedPatternCategories
7083 7108 });
7084 7109 };
7085 - var getNavigationFallbackId2 = () => async ({ dispatch: dispatch3, select: select4, registry }) => {
7110 + var getNavigationFallbackId2 = () => async ({ dispatch: dispatch3, select: select5, registry }) => {
7086 7111 const fallback = await (0, import_api_fetch9.default)({
7087 7112 path: (0, import_url6.addQueryArgs)("/wp-block-editor/v1/navigation-fallback", {
7088 7113 _embed: true
7089 7114 })
@@ -7093,9 +7118,9 @@
7093 7118 dispatch3.receiveNavigationFallbackId(fallback?.id);
7094 7119 if (!record) {
7095 7120 return;
7096 7121 }
7097 - const existingFallbackEntityRecord = select4.getEntityRecord(
7122 + const existingFallbackEntityRecord = select5.getEntityRecord(
7098 7123 "postType",
7099 7124 "wp_navigation",
7100 7125 fallback.id
7101 7126 );
@@ -7118,9 +7143,9 @@
7118 7143 const template = await (0, import_api_fetch9.default)({
7119 7144 path: (0, import_url6.addQueryArgs)("/wp/v2/templates/lookup", query)
7120 7145 });
7121 7146 await resolveSelect2.getEntitiesConfig("postType");
7122 - const id = window?.__experimentalTemplateActivate ? template?.wp_id || template?.id : template?.id;
7147 + const id = template?.id;
7123 7148 registry.batch(() => {
7124 7149 dispatch3.receiveDefaultTemplateId(query, id || "");
7125 7150 if (id) {
7126 7151 template.id = id;
@@ -7136,11 +7161,8 @@
7136 7161 ]);
7137 7162 }
7138 7163 });
7139 7164 };
7140 - getDefaultTemplateId2.shouldInvalidate = (action) => {
7141 - return action.type === "RECEIVE_ITEMS" && action.kind === "root" && action.name === "site" && !!action.persistedEdits;
7142 - };
7143 7165 var getRevisions2 = (kind, name, recordKey, query = {}) => async ({ dispatch: dispatch3, resolveSelect: resolveSelect2 }) => {
7144 7166 const configs = await resolveSelect2.getEntitiesConfig(kind);
7145 7167 const entityConfig = configs.find(
7146 7168 (config) => config.name === name && config.kind === kind
@@ -7180,11 +7202,11 @@
7180 7202 }
7181 7203 if (response) {
7182 7204 if (isPaginated) {
7183 7205 records = Object.values(await response.json());
7184 - meta.totalItems = parseInt(
7185 - response.headers.get("X-WP-Total")
7186 - );
7206 + meta.totalItems = getPaginationMeta(
7207 + response.headers
7208 + ).totalItems;
7187 7209 } else {
7188 7210 records = Object.values(response);
7189 7211 }
7190 7212 if (query._fields) {
@@ -7221,9 +7243,9 @@
7221 7243 dispatch3.__unstableReleaseStoreLock(lock2);
7222 7244 }
7223 7245 };
7224 7246 getRevisions2.shouldInvalidate = (action, kind, name, recordKey) => action.type === "SAVE_ENTITY_RECORD_FINISH" && name === action.name && kind === action.kind && !action.error && recordKey === action.recordId;
7225 - var getRevision2 = (kind, name, recordKey, revisionKey, query) => async ({ select: select4, dispatch: dispatch3, resolveSelect: resolveSelect2 }) => {
7247 + var getRevision2 = (kind, name, recordKey, revisionKey, query) => async ({ select: select5, dispatch: dispatch3, resolveSelect: resolveSelect2 }) => {
7226 7248 const configs = await resolveSelect2.getEntitiesConfig(kind);
7227 7249 const entityConfig = configs.find(
7228 7250 (config) => config.name === name && config.kind === kind
7229 7251 );
@@ -7254,9 +7276,9 @@
7254 7276 ],
7255 7277 { exclusive: false }
7256 7278 );
7257 7279 try {
7258 - if (select4.hasRevision(kind, name, recordKey, revisionKey, query)) {
7280 + if (select5.hasRevision(kind, name, recordKey, revisionKey, query)) {
7259 7281 return;
7260 7282 }
7261 7283 const path = (0, import_url6.addQueryArgs)(
7262 7284 entityConfig.getRevisionsUrl(recordKey, revisionKey),
@@ -7547,9 +7569,17 @@
7547 7569 ...parent?.[kind],
7548 7570 [name]: id
7549 7571 }
7550 7572 },
7551 - ...revisionId !== void 0 && { revisionId }
7573 + ...revisionId !== void 0 && kind && {
7574 + revision: {
7575 + ...parent?.revision,
7576 + [kind]: {
7577 + ...parent?.revision?.[kind],
7578 + [name]: revisionId
7579 + }
7580 + }
7581 + }
7552 7582 }),
7553 7583 [parent, kind, name, id, revisionId]
7554 7584 );
7555 7585 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(EntityContext.Provider, { value: childContext, children });
@@ -7555,9 +7585,9 @@
7555 7585 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(EntityContext.Provider, { value: childContext, children });
7556 7586 }
7557 7587
7558 7588 // packages/core-data/build-module/hooks/use-entity-record.mjs
7559 - var import_data10 = __toESM(require_data(), 1);
7589 + var import_data11 = __toESM(require_data(), 1);
7560 7590 var import_deprecated4 = __toESM(require_deprecated(), 1);
7561 7591 var import_element3 = __toESM(require_element(), 1);
7562 7592
7563 7593 // packages/core-data/build-module/hooks/constants.mjs
@@ -7595,9 +7625,9 @@
7595 7625
7596 7626 // packages/core-data/build-module/hooks/use-entity-record.mjs
7597 7627 var EMPTY_OBJECT3 = {};
7598 7628 function useEntityRecord(kind, name, recordId, options = { enabled: true }) {
7599 - const { editEntityRecord: editEntityRecord2, saveEditedEntityRecord: saveEditedEntityRecord2 } = (0, import_data10.useDispatch)(store);
7629 + const { editEntityRecord: editEntityRecord2, saveEditedEntityRecord: saveEditedEntityRecord2 } = (0, import_data11.useDispatch)(store);
7600 7630 const mutations = (0, import_element3.useMemo)(
7601 7631 () => ({
7602 7632 edit: (record2, editOptions = {}) => editEntityRecord2(kind, name, recordId, record2, editOptions),
7603 7633 save: (saveOptions = {}) => saveEditedEntityRecord2(kind, name, recordId, {
@@ -7606,10 +7636,10 @@
7606 7636 })
7607 7637 }),
7608 7638 [editEntityRecord2, kind, name, recordId, saveEditedEntityRecord2]
7609 7639 );
7610 - const { record, editedRecord, hasEdits, edits, ...resolution } = (0, import_data10.useSelect)(
7611 - (select4) => {
7640 + const { record, editedRecord, hasEdits, edits, ...resolution } = (0, import_data11.useSelect)(
7641 + (select5) => {
7612 7642 if (!options.enabled) {
7613 7643 return {
7614 7644 record: null,
7615 7645 editedRecord: EMPTY_OBJECT3,
@@ -7617,9 +7647,9 @@
7617 7647 edits: EMPTY_OBJECT3,
7618 7648 ...getResolutionStatus()
7619 7649 };
7620 7650 }
7621 - const storeSelectors = select4(store);
7651 + const storeSelectors = select5(store);
7622 7652 const resolutionStatus = storeSelectors.getResolutionState(
7623 7653 "getEntityRecord",
7624 7654 [kind, name, recordId]
7625 7655 )?.status;
@@ -7668,15 +7698,15 @@
7668 7698
7669 7699 // packages/core-data/build-module/hooks/use-entity-records.mjs
7670 7700 var import_url7 = __toESM(require_url(), 1);
7671 7701 var import_deprecated5 = __toESM(require_deprecated(), 1);
7672 - var import_data11 = __toESM(require_data(), 1);
7702 + var import_data12 = __toESM(require_data(), 1);
7673 7703 var import_element4 = __toESM(require_element(), 1);
7674 7704 var EMPTY_ARRAY = [];
7675 7705 function useEntityRecords(kind, name, queryArgs = {}, options = { enabled: true }) {
7676 7706 const queryAsString = (0, import_url7.addQueryArgs)("", queryArgs);
7677 - const { records, totalItems, totalPages, ...rest } = (0, import_data11.useSelect)(
7678 - (select4) => {
7707 + const { records, totalItems, totalPages, ...rest } = (0, import_data12.useSelect)(
7708 + (select5) => {
7679 7709 if (!options.enabled) {
7680 7710 return {
7681 7711 // Avoiding returning a new reference on every execution.
7682 7712 records: EMPTY_ARRAY,
@@ -7684,9 +7714,9 @@
7684 7714 totalPages: null,
7685 7715 ...getResolutionStatus()
7686 7716 };
7687 7717 }
7688 - const storeSelectors = select4(store);
7718 + const storeSelectors = select5(store);
7689 7719 const resolutionStatus = storeSelectors.getResolutionState(
7690 7720 "getEntityRecords",
7691 7721 [kind, name, queryArgs]
7692 7722 )?.status;
@@ -7725,10 +7755,10 @@
7725 7755 });
7726 7756 return useEntityRecords(kind, name, queryArgs, options);
7727 7757 }
7728 7758 function useEntityRecordsWithPermissions(kind, name, queryArgs = {}, options = { enabled: true }) {
7729 - const entityConfig = (0, import_data11.useSelect)(
7730 - (select4) => select4(store).getEntityConfig(kind, name),
7759 + const entityConfig = (0, import_data12.useSelect)(
7760 + (select5) => select5(store).getEntityConfig(kind, name),
7731 7761 [kind, name]
7732 7762 );
7733 7763 const { records: data, ...ret } = useEntityRecords(
7734 7764 kind,
@@ -7755,12 +7785,12 @@
7755 7785 (record) => record[entityConfig?.key ?? "id"]
7756 7786 ) ?? [],
7757 7787 [data, entityConfig?.key]
7758 7788 );
7759 - const permissions = (0, import_data11.useSelect)(
7760 - (select4) => {
7789 + const permissions = (0, import_data12.useSelect)(
7790 + (select5) => {
7761 7791 const { getEntityRecordsPermissions: getEntityRecordsPermissions2 } = unlock(
7762 - select4(store)
7792 + select5(store)
7763 7793 );
7764 7794 return getEntityRecordsPermissions2(kind, name, ids);
7765 7795 },
7766 7796 [ids, kind, name]
@@ -7780,9 +7810,9 @@
7780 7810 var import_deprecated6 = __toESM(require_deprecated(), 1);
7781 7811 var import_warning = __toESM(require_warning(), 1);
7782 7812
7783 7813 // packages/core-data/build-module/hooks/use-query-select.mjs
7784 - var import_data12 = __toESM(require_data(), 1);
7814 + var import_data13 = __toESM(require_data(), 1);
7785 7815
7786 7816 // node_modules/memize/dist/index.js
7787 7817 function memize(fn, options) {
7788 7818 var size = 0;
@@ -7859,10 +7889,10 @@
7859 7889 "isResolving",
7860 7890 "getCachedResolvers"
7861 7891 ];
7862 7892 function useQuerySelect(mapQuerySelect, deps) {
7863 - return (0, import_data12.useSelect)((select4, registry) => {
7864 - const resolve = (store2) => enrichSelectors(select4(store2));
7893 + return (0, import_data13.useSelect)((select5, registry) => {
7894 + const resolve = (store2) => enrichSelectors(select5(store2));
7865 7895 return mapQuerySelect(resolve, registry);
7866 7896 }, deps);
7867 7897 }
7868 7898 var enrichSelectors = memize(((selectors) => {
@@ -7955,10 +7985,10 @@
7955 7985 }
7956 7986
7957 7987 // packages/core-data/build-module/hooks/use-entity-block-editor.mjs
7958 7988 var import_element6 = __toESM(require_element(), 1);
7959 - var import_data13 = __toESM(require_data(), 1);
7960 - var import_blocks5 = __toESM(require_blocks(), 1);
7989 + var import_data14 = __toESM(require_data(), 1);
7990 + var import_blocks6 = __toESM(require_blocks(), 1);
7961 7991
7962 7992 // packages/core-data/build-module/hooks/use-entity-id.mjs
7963 7993 var import_element5 = __toESM(require_element(), 1);
7964 7994 function useEntityId(kind, name) {
@@ -8116,14 +8146,14 @@
8116 8146 var EMPTY_ARRAY2 = [];
8117 8147 function useEntityBlockEditor(kind, name, { id: _id } = {}) {
8118 8148 const providerId = useEntityId(kind, name);
8119 8149 const id = _id ?? providerId;
8120 - const { content, editedBlocks, meta } = (0, import_data13.useSelect)(
8121 - (select4) => {
8150 + const { content, editedBlocks, meta } = (0, import_data14.useSelect)(
8151 + (select5) => {
8122 8152 if (!id) {
8123 8153 return {};
8124 8154 }
8125 - const { getEditedEntityRecord: getEditedEntityRecord3 } = select4(STORE_NAME);
8155 + const { getEditedEntityRecord: getEditedEntityRecord3 } = select5(STORE_NAME);
8126 8156 const editedRecord = getEditedEntityRecord3(kind, name, id);
8127 8157 return {
8128 8158 editedBlocks: editedRecord.blocks,
8129 8159 content: editedRecord.content,
@@ -8131,9 +8161,9 @@
8131 8161 };
8132 8162 },
8133 8163 [kind, name, id]
8134 8164 );
8135 - const { __unstableCreateUndoLevel: __unstableCreateUndoLevel2, editEntityRecord: editEntityRecord2 } = (0, import_data13.useDispatch)(STORE_NAME);
8165 + const { __unstableCreateUndoLevel: __unstableCreateUndoLevel2, editEntityRecord: editEntityRecord2 } = (0, import_data14.useDispatch)(STORE_NAME);
8136 8166 const blocks = (0, import_element6.useMemo)(() => {
8137 8167 if (!id) {
8138 8168 return void 0;
8139 8169 }
@@ -8142,16 +8172,12 @@
8142 8172 }
8143 8173 if (!content || typeof content !== "string") {
8144 8174 return EMPTY_ARRAY2;
8145 8175 }
8146 - const cacheKey = getCacheKey(kind, name, id);
8147 - const cached = parsedBlocksCache.get(cacheKey);
8148 - let _blocks;
8149 - if (cached && cached.content === content) {
8150 - _blocks = cached.blocks;
8151 - } else {
8152 - _blocks = (0, import_blocks5.parse)(content);
8153 - parsedBlocksCache.set(cacheKey, { content, blocks: _blocks });
8176 + let _blocks = getCachedBlocks(kind, name, id, content);
8177 + if (!_blocks) {
8178 + _blocks = (0, import_blocks6.parse)(content);
8179 + setCachedBlocks(kind, name, id, content, _blocks);
8154 8180 }
8155 8181 return _blocks;
8156 8182 }, [kind, name, id, editedBlocks, content]);
8157 8183 const onChange = (0, import_element6.useCallback)(
@@ -8162,9 +8188,9 @@
8162 8188 }
8163 8189 const { selection, ...rest } = options;
8164 8190 const edits = {
8165 8191 selection,
8166 - content: ({ blocks: blocksForSerialization = [] }) => (0, import_blocks5.__unstableSerializeAndClean)(blocksForSerialization),
8192 + content: ({ blocks: blocksForSerialization = [] }) => (0, import_blocks6.__unstableSerializeAndClean)(blocksForSerialization),
8167 8193 ...updateFootnotesFromMeta(newBlocks, meta)
8168 8194 };
8169 8195 editEntityRecord2(kind, name, id, edits, {
8170 8196 isCached: false,
@@ -8199,41 +8225,39 @@
8199 8225 }
8200 8226
8201 8227 // packages/core-data/build-module/hooks/use-entity-prop.mjs
8202 8228 var import_element7 = __toESM(require_element(), 1);
8203 - var import_data14 = __toESM(require_data(), 1);
8229 + var import_data15 = __toESM(require_data(), 1);
8230 + var REVISION_QUERY = {
8231 + context: "edit",
8232 + _fields: "id,date,author,meta,title,excerpt,content.raw"
8233 + };
8204 8234 function useEntityProp(kind, name, prop, _id) {
8205 8235 const providerId = useEntityId(kind, name);
8206 8236 const id = _id ?? providerId;
8207 8237 const context = (0, import_element7.useContext)(EntityContext);
8208 - const revisionId = context?.revisionId;
8209 - const { value, fullValue } = (0, import_data14.useSelect)(
8210 - (select4) => {
8238 + const revisionId = String(id) === String(providerId) ? context?.revision?.[kind]?.[name] : void 0;
8239 + const { value, fullValue } = (0, import_data15.useSelect)(
8240 + (select5) => {
8211 8241 if (revisionId) {
8212 - const revisions = select4(STORE_NAME).getRevisions(
8242 + const revision = select5(STORE_NAME).getRevision(
8213 8243 kind,
8214 8244 name,
8215 8245 id,
8216 - {
8217 - per_page: -1,
8218 - context: "edit",
8219 - _fields: "id,date,author,meta,title.raw,excerpt.raw,content.raw"
8220 - }
8246 + revisionId,
8247 + REVISION_QUERY
8221 8248 );
8222 - const entityConfig = select4(STORE_NAME).getEntityConfig(
8223 - kind,
8224 - name
8225 - );
8226 - const revKey = entityConfig?.revisionKey || DEFAULT_ENTITY_KEY;
8227 - const revision = revisions?.find(
8228 - (r2) => r2[revKey] === revisionId
8229 - );
8230 - return revision ? {
8231 - value: revision[prop]?.raw ?? revision[prop],
8232 - fullValue: revision[prop]
8233 - } : {};
8249 + const propValue = revision?.[prop];
8250 + if (propValue === void 0) {
8251 + return {};
8252 + }
8253 + const isRawAttribute = propValue !== null && typeof propValue === "object" && "raw" in propValue;
8254 + return {
8255 + value: isRawAttribute ? propValue.raw : propValue,
8256 + fullValue: propValue
8257 + };
8234 8258 }
8235 - const { getEntityRecord: getEntityRecord3, getEditedEntityRecord: getEditedEntityRecord3 } = select4(STORE_NAME);
8259 + const { getEntityRecord: getEntityRecord3, getEditedEntityRecord: getEditedEntityRecord3 } = select5(STORE_NAME);
8236 8260 const record = getEntityRecord3(kind, name, id);
8237 8261 const editedRecord = getEditedEntityRecord3(kind, name, id);
8238 8262 return record && editedRecord ? {
8239 8263 value: editedRecord[prop],
@@ -8241,9 +8265,9 @@
8241 8265 } : {};
8242 8266 },
8243 8267 [kind, name, id, prop, revisionId]
8244 8268 );
8245 - const { editEntityRecord: editEntityRecord2 } = (0, import_data14.useDispatch)(STORE_NAME);
8269 + const { editEntityRecord: editEntityRecord2 } = (0, import_data15.useDispatch)(STORE_NAME);
8246 8270 const setValue = (0, import_element7.useCallback)(
8247 8271 (newValue) => {
8248 8272 if (revisionId) {
8249 8273 return;
@@ -8275,9 +8299,11 @@
8275 8299 }),
8276 8300 isCurrentCollaboratorDisconnected: false
8277 8301 };
8278 8302 function getAwarenessState(awareness, newState) {
8279 - const activeCollaborators = newState ?? awareness.getCurrentState();
8303 + const activeCollaborators = (newState ?? awareness.getCurrentState()).filter(
8304 + (collaborator) => isCollaboratorInfo(collaborator.collaboratorInfo)
8305 + );
8280 8306 return {
8281 8307 activeCollaborators,
8282 8308 resolveSelection: (selection, blocks) => awareness.convertSelectionStateToAbsolute(selection, blocks),
8283 8309 getDebugData: () => awareness.getDebugData(),
@@ -8438,34 +8464,49 @@
8438 8464
8439 8465 // packages/icons/build-module/library/footer.mjs
8440 8466 var import_primitives = __toESM(require_primitives(), 1);
8441 8467 var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
8442 - var footer_default = /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_primitives.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_primitives.Path, { fillRule: "evenodd", d: "M18 5.5h-8v8h8.5V6a.5.5 0 00-.5-.5zm-9.5 8h-3V6a.5.5 0 01.5-.5h2.5v8zM6 4h12a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6a2 2 0 012-2z" }) });
8468 + var footer_default = /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_primitives.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", style: { fill: "none" }, stroke: "currentColor", strokeWidth: "1.5", children: [
8469 + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_primitives.Path, { d: "M9.75 4.75H18C18.6904 4.75 19.25 5.30964 19.25 6V14.25M9.75 4.75H6C5.30964 4.75 4.75 5.30964 4.75 6V14.25M9.75 4.75V14.25M19.25 14.25V18C19.25 18.6904 18.6904 19.25 18 19.25H6C5.30964 19.25 4.75 18.6904 4.75 18V14.25M19.25 14.25H9.75M9.75 14.25H4.75", vectorEffect: "non-scaling-stroke" }),
8470 + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_primitives.Path, { d: "M19.25 15.5V18C19.25 18.6904 18.6904 19.25 18 19.25H6C5.30964 19.25 4.75 18.6904 4.75 18V15.5C4.75 14.8096 5.30964 14.25 6 14.25H18C18.6904 14.25 19.25 14.8096 19.25 15.5Z", fill: "currentColor", vectorEffect: "non-scaling-stroke" })
8471 + ] });
8443 8472
8444 8473 // packages/icons/build-module/library/header.mjs
8445 8474 var import_primitives2 = __toESM(require_primitives(), 1);
8446 8475 var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
8447 - var header_default = /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_primitives2.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_primitives2.Path, { d: "M18.5 10.5H10v8h8a.5.5 0 00.5-.5v-7.5zm-10 0h-3V18a.5.5 0 00.5.5h2.5v-8zM6 4h12a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6a2 2 0 012-2z" }) });
8476 + var header_default = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_primitives2.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", style: { fill: "none" }, stroke: "currentColor", strokeWidth: "1.5", children: [
8477 + /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_primitives2.Path, { d: "M9.75 19.25H18C18.6904 19.25 19.25 18.6904 19.25 18V9.75M9.75 19.25H6C5.30964 19.25 4.75 18.6904 4.75 18V9.75M9.75 19.25V9.75M19.25 9.75V6C19.25 5.30964 18.6904 4.75 18 4.75H6C5.30964 4.75 4.75 5.30964 4.75 6V9.75M19.25 9.75H9.75M9.75 9.75H4.75", vectorEffect: "non-scaling-stroke" }),
8478 + /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_primitives2.Path, { d: "M19.25 8.5V6C19.25 5.30964 18.6904 4.75 18 4.75H6C5.30964 4.75 4.75 5.30964 4.75 6V8.5C4.75 9.19036 5.30964 9.75 6 9.75H18C18.6904 9.75 19.25 9.19036 19.25 8.5Z", fill: "currentColor", vectorEffect: "non-scaling-stroke" })
8479 + ] });
8448 8480
8449 8481 // packages/icons/build-module/library/layout.mjs
8450 8482 var import_primitives3 = __toESM(require_primitives(), 1);
8451 8483 var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
8452 - var layout_default = /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_primitives3.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_primitives3.Path, { d: "M18 5.5H6a.5.5 0 00-.5.5v3h13V6a.5.5 0 00-.5-.5zm.5 5H10v8h8a.5.5 0 00.5-.5v-7.5zm-10 0h-3V18a.5.5 0 00.5.5h2.5v-8zM6 4h12a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6a2 2 0 012-2z" }) });
8484 + var layout_default = /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_primitives3.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", style: { fill: "none" }, stroke: "currentColor", strokeWidth: "1.5", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_primitives3.Path, { d: "M9.75 19.25H18C18.6904 19.25 19.25 18.6904 19.25 18V9.75M9.75 19.25H6C5.30964 19.25 4.75 18.6904 4.75 18V9.75M9.75 19.25V9.75M19.25 9.75V6C19.25 5.30964 18.6904 4.75 18 4.75H6C5.30964 4.75 4.75 5.30964 4.75 6V9.75M19.25 9.75H9.75M9.75 9.75H4.75", vectorEffect: "non-scaling-stroke" }) });
8453 8485
8454 8486 // packages/icons/build-module/library/navigation-overlay.mjs
8455 8487 var import_primitives4 = __toESM(require_primitives(), 1);
8456 8488 var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1);
8457 - var navigation_overlay_default = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_primitives4.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_primitives4.Path, { d: "M18.5 10a1.5 1.5 0 0 1 1.5 1.5v7a1.5 1.5 0 0 1-1.5 1.5h-7a1.5 1.5 0 0 1-1.5-1.5v-7a1.5 1.5 0 0 1 1.5-1.5zM16 4a2 2 0 0 1 2 2v2h-1.5V6a.5.5 0 0 0-.5-.5H6a.5.5 0 0 0-.5.5v3H8v1.5H5.5V16a.5.5 0 0 0 .5.5h2V18H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2z" }) });
8489 + var navigation_overlay_default = /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_primitives4.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", style: { fill: "none" }, stroke: "currentColor", strokeWidth: "1.5", children: [
8490 + /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_primitives4.Path, { d: "M4.75 9.25V16C4.75 16.6904 5.30964 17.25 6 17.25H8M4.75 9.25V6C4.75 5.30964 5.30964 4.75 6 4.75H16C16.6904 4.75 17.25 5.30964 17.25 6V8M4.75 9.25H8", vectorEffect: "non-scaling-stroke" }),
8491 + /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_primitives4.Path, { d: "M10.75 11.25C10.75 10.9739 10.9739 10.75 11.25 10.75H18.75C19.0261 10.75 19.25 10.9739 19.25 11.25V18.75C19.25 19.0261 19.0261 19.25 18.75 19.25H11.25C10.9739 19.25 10.75 19.0261 10.75 18.75V11.25Z", fill: "currentColor", vectorEffect: "non-scaling-stroke" })
8492 + ] });
8458 8493
8459 8494 // packages/icons/build-module/library/sidebar.mjs
8460 8495 var import_primitives5 = __toESM(require_primitives(), 1);
8461 8496 var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1);
8462 - var sidebar_default = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_primitives5.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_primitives5.Path, { d: "M18 5.5H6a.5.5 0 00-.5.5v3h13V6a.5.5 0 00-.5-.5zm.5 5H10v8h8a.5.5 0 00.5-.5v-7.5zM6 4h12a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6a2 2 0 012-2z" }) });
8497 + var sidebar_default = /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_primitives5.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", style: { fill: "none" }, stroke: "currentColor", strokeWidth: "1.5", children: [
8498 + /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_primitives5.Path, { d: "M9.75 19.25H18C18.6904 19.25 19.25 18.6904 19.25 18V9.75M9.75 19.25H6C5.30964 19.25 4.75 18.6904 4.75 18V9.75M9.75 19.25V9.75M19.25 9.75V6C19.25 5.30964 18.6904 4.75 18 4.75H6C5.30964 4.75 4.75 5.30964 4.75 6V9.75M19.25 9.75H9.75M9.75 9.75H4.75", vectorEffect: "non-scaling-stroke" }),
8499 + /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_primitives5.Path, { d: "M6 19.25H9.75V9.75H4.75V18C4.75 18.6904 5.30964 19.25 6 19.25Z", fill: "currentColor", vectorEffect: "non-scaling-stroke" })
8500 + ] });
8463 8501
8464 8502 // packages/icons/build-module/library/symbol-filled.mjs
8465 8503 var import_primitives6 = __toESM(require_primitives(), 1);
8466 8504 var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1);
8467 - var symbol_filled_default = /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_primitives6.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_primitives6.Path, { d: "M21.3 10.8l-5.6-5.6c-.7-.7-1.8-.7-2.5 0l-5.6 5.6c-.7.7-.7 1.8 0 2.5l5.6 5.6c.3.3.8.5 1.2.5s.9-.2 1.2-.5l5.6-5.6c.8-.7.8-1.9.1-2.5zm-17.6 1L10 5.5l-1-1-6.3 6.3c-.7.7-.7 1.8 0 2.5L9 19.5l1.1-1.1-6.3-6.3c-.2 0-.2-.2-.1-.3z" }) });
8505 + var symbol_filled_default = /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_primitives6.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", style: { fill: "none" }, stroke: "currentColor", strokeWidth: "1.5", children: [
8506 + /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_primitives6.Path, { d: "M15.2071 6.20711L20.2929 11.2929C20.6834 11.6834 20.6834 12.3166 20.2929 12.7071L15.2071 17.7929C14.8166 18.1834 14.1834 18.1834 13.7929 17.7929L8.70711 12.7071C8.31658 12.3166 8.31658 11.6834 8.70711 11.2929L13.7929 6.20711C14.1834 5.81658 14.8166 5.81658 15.2071 6.20711Z", fill: "currentColor", vectorEffect: "non-scaling-stroke" }),
8507 + /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_primitives6.Path, { d: "M9.5 5.5L3.70711 11.2929C3.31658 11.6834 3.31658 12.3166 3.70711 12.7071L9.5 18.5", vectorEffect: "non-scaling-stroke" })
8508 + ] });
8468 8509
8469 8510 // packages/core-data/build-module/utils/get-template-part-icon.mjs
8470 8511 function getTemplatePartIcon(areaOrIconName) {
8471 8512 if ("header" === areaOrIconName) {
@@ -8523,18 +8564,18 @@
8523 8564 var import_components3 = __toESM(require_components(), 1);
8524 8565 var import_i18n7 = __toESM(require_i18n(), 1);
8525 8566 var import_element10 = __toESM(require_element(), 1);
8526 8567 var import_compose4 = __toESM(require_compose(), 1);
8527 - var import_data18 = __toESM(require_data(), 1);
8568 + var import_data19 = __toESM(require_data(), 1);
8528 8569
8529 8570 // packages/core-data/build-module/components/entities-saved-states/entity-type-list.mjs
8530 8571 var import_i18n6 = __toESM(require_i18n(), 1);
8531 - var import_data16 = __toESM(require_data(), 1);
8572 + var import_data17 = __toESM(require_data(), 1);
8532 8573 var import_components2 = __toESM(require_components(), 1);
8533 8574
8534 8575 // packages/global-styles-engine/build-module/utils/get-global-styles-changes.mjs
8535 8576 var import_i18n4 = __toESM(require_i18n(), 1);
8536 - var import_blocks6 = __toESM(require_blocks(), 1);
8577 + var import_blocks7 = __toESM(require_blocks(), 1);
8537 8578 var globalStylesChangesCache = /* @__PURE__ */ new Map();
8538 8579 var EMPTY_ARRAY3 = [];
8539 8580 var translationMap = {
8540 8581 caption: (0, import_i18n4.__)("Caption"),
@@ -8561,9 +8602,9 @@
8561 8602 "styles.filter": (0, import_i18n4.__)("Filter"),
8562 8603 "styles.dimensions": (0, import_i18n4.__)("Dimensions")
8563 8604 };
8564 8605 var getBlockNames = memize(
8565 - () => (0, import_blocks6.getBlockTypes)().reduce(
8606 + () => (0, import_blocks7.getBlockTypes)().reduce(
8566 8607 (accumulator, {
8567 8608 name,
8568 8609 title
8569 8610 }) => {
@@ -8729,26 +8770,26 @@
8729 8770
8730 8771 // packages/core-data/build-module/components/entities-saved-states/entity-record-item.mjs
8731 8772 var import_components = __toESM(require_components(), 1);
8732 8773 var import_i18n5 = __toESM(require_i18n(), 1);
8733 - var import_data15 = __toESM(require_data(), 1);
8774 + var import_data16 = __toESM(require_data(), 1);
8734 8775 var import_html_entities4 = __toESM(require_html_entities(), 1);
8735 8776 var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1);
8736 8777 function EntityRecordItem({ record, checked, onChange }) {
8737 8778 const { name, kind, title, key } = record;
8738 - const { entityRecordTitle } = (0, import_data15.useSelect)(
8739 - (select4) => {
8779 + const { entityRecordTitle } = (0, import_data16.useSelect)(
8780 + (select5) => {
8740 8781 if ("postType" !== kind || "wp_template" !== name) {
8741 8782 return {
8742 8783 entityRecordTitle: title
8743 8784 };
8744 8785 }
8745 - const template = select4(STORE_NAME).getEditedEntityRecord(
8786 + const template = select5(STORE_NAME).getEditedEntityRecord(
8746 8787 kind,
8747 8788 name,
8748 8789 key
8749 8790 );
8750 - const { default_template_types: templateTypes = [] } = select4(STORE_NAME).getCurrentTheme() ?? {};
8791 + const { default_template_types: templateTypes = [] } = select5(STORE_NAME).getCurrentTheme() ?? {};
8751 8792 return {
8752 8793 entityRecordTitle: getTemplateInfo({
8753 8794 template,
8754 8795 templateTypes
@@ -8783,11 +8824,11 @@
8783 8824 return (0, import_i18n6.__)("The following has been modified.");
8784 8825 }
8785 8826 }
8786 8827 function GlobalStylesDescription({ record }) {
8787 - const { editedRecord, savedRecord } = (0, import_data16.useSelect)(
8788 - (select4) => {
8789 - const { getEditedEntityRecord: getEditedEntityRecord3, getEntityRecord: getEntityRecord3 } = select4(STORE_NAME);
8828 + const { editedRecord, savedRecord } = (0, import_data17.useSelect)(
8829 + (select5) => {
8830 + const { getEditedEntityRecord: getEditedEntityRecord3, getEntityRecord: getEntityRecord3 } = select5(STORE_NAME);
8790 8831 return {
8791 8832 editedRecord: getEditedEntityRecord3(
8792 8833 record.kind,
8793 8834 record.name,
@@ -8824,10 +8865,10 @@
8824 8865 setUnselectedEntities
8825 8866 }) {
8826 8867 const count = list.length;
8827 8868 const firstRecord = list[0];
8828 - const entityConfig = (0, import_data16.useSelect)(
8829 - (select4) => select4(STORE_NAME).getEntityConfig(
8869 + const entityConfig = (0, import_data17.useSelect)(
8870 + (select5) => select5(STORE_NAME).getEntityConfig(
8830 8871 firstRecord.kind,
8831 8872 firstRecord.name
8832 8873 ),
8833 8874 [firstRecord.kind, firstRecord.name]
@@ -8863,18 +8904,18 @@
8863 8904 );
8864 8905 }
8865 8906
8866 8907 // packages/core-data/build-module/components/entities-saved-states/hooks/use-is-dirty.mjs
8867 - var import_data17 = __toESM(require_data(), 1);
8908 + var import_data18 = __toESM(require_data(), 1);
8868 8909 var import_element9 = __toESM(require_element(), 1);
8869 8910 var useIsDirty = () => {
8870 - const { editedEntities, siteEdits, siteEntityConfig } = (0, import_data17.useSelect)(
8871 - (select4) => {
8911 + const { editedEntities, siteEdits, siteEntityConfig } = (0, import_data18.useSelect)(
8912 + (select5) => {
8872 8913 const {
8873 8914 __experimentalGetDirtyEntityRecords: __experimentalGetDirtyEntityRecords2,
8874 8915 getEntityRecordEdits: getEntityRecordEdits2,
8875 8916 getEntityConfig: getEntityConfig2
8876 - } = select4(STORE_NAME);
8917 + } = select5(STORE_NAME);
8877 8918 return {
8878 8919 editedEntities: __experimentalGetDirtyEntityRecords2(),
8879 8920 siteEdits: getEntityRecordEdits2("root", "site"),
8880 8921 siteEntityConfig: getEntityConfig2("root", "site")
@@ -8967,9 +9008,9 @@
8967 9008 variant = "default",
8968 9009 successNoticeContent
8969 9010 }) {
8970 9011 const saveButtonRef = (0, import_element10.useRef)();
8971 - const { saveDirtyEntities: saveDirtyEntities2 } = unlock((0, import_data18.useDispatch)(STORE_NAME));
9012 + const { saveDirtyEntities: saveDirtyEntities2 } = unlock((0, import_data19.useDispatch)(STORE_NAME));
8972 9013 const partitionedSavables = dirtyEntityRecords.reduce((acc, record) => {
8973 9014 const { name } = record;
8974 9015 if (!acc[name]) {
8975 9016 acc[name] = [];
@@ -9209,12 +9250,12 @@
9209 9250 ...entitySelectors
9210 9251 },
9211 9252 resolvers: { ...resolvers_exports, ...entityResolvers }
9212 9253 });
9213 - var store = (0, import_data19.createReduxStore)(STORE_NAME, storeConfig());
9254 + var store = (0, import_data20.createReduxStore)(STORE_NAME, storeConfig());
9214 9255 unlock(store).registerPrivateSelectors(private_selectors_exports);
9215 9256 unlock(store).registerPrivateActions(private_actions_exports);
9216 - (0, import_data19.register)(store);
9257 + (0, import_data20.register)(store);
9217 9258 return __toCommonJS(index_exports);
9218 9259 })();
9219 9260 (window.wp ||= {}).coreData = wp.coreData;
9220 9261 })();