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 +1433 -414 23.5.2 → 24.1.0 View file →
@@ -1,4 +1,5 @@
1 +(function() {
1 2 "use strict";
2 3 var wp;
3 4 (wp ||= {}).coreData = (() => {
4 5 var __create = Object.create;
@@ -384,8 +385,15 @@
384 385 module.exports = window.wp.deprecated;
385 386 }
386 387 });
387 388
389 + // package-external:@wordpress/notices
390 + var require_notices = __commonJS({
391 + "package-external:@wordpress/notices"(exports, module) {
392 + module.exports = window.wp.notices;
393 + }
394 + });
395 +
388 396 // package-external:@wordpress/html-entities
389 397 var require_html_entities = __commonJS({
390 398 "package-external:@wordpress/html-entities"(exports, module) {
391 399 module.exports = window.wp.htmlEntities;
@@ -412,8 +420,22 @@
412 420 module.exports = window.wp.warning;
413 421 }
414 422 });
415 423
424 + // package-external:@wordpress/primitives
425 + var require_primitives = __commonJS({
426 + "package-external:@wordpress/primitives"(exports, module) {
427 + module.exports = window.wp.primitives;
428 + }
429 + });
430 +
431 + // package-external:@wordpress/components
432 + var require_components = __commonJS({
433 + "package-external:@wordpress/components"(exports, module) {
434 + module.exports = window.wp.components;
435 + }
436 + });
437 +
416 438 // packages/core-data/build-module/index.mjs
417 439 var index_exports = {};
418 440 __export(index_exports, {
419 441 EntityProvider: () => EntityProvider,
@@ -431,9 +453,9 @@
431 453 useEntityRecord: () => useEntityRecord,
432 454 useEntityRecords: () => useEntityRecords,
433 455 useResourcePermissions: () => use_resource_permissions_default
434 456 });
435 - var import_data15 = __toESM(require_data(), 1);
457 + var import_data20 = __toESM(require_data(), 1);
436 458
437 459 // packages/core-data/build-module/reducer.mjs
438 460 var import_es65 = __toESM(require_es6(), 1);
439 461 var import_compose2 = __toESM(require_compose(), 1);
@@ -494,8 +516,58 @@
494 516 return null;
495 517 }
496 518 var get_normalized_comma_separable_default = getNormalizedCommaSeparable;
497 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 +
498 570 // packages/core-data/build-module/utils/if-matching-action.mjs
499 571 var ifMatchingAction = (isMatch) => (reducer) => (state, action) => {
500 572 if (state === void 0 || isMatch(action)) {
501 573 return reducer(state, action);
@@ -533,30 +605,8 @@
533 605 };
534 606 }
535 607 var with_weak_map_cache_default = withWeakMapCache;
536 608
537 - // packages/core-data/build-module/utils/set-nested-value.mjs
538 - function setNestedValue(object, path, value) {
539 - if (!object || typeof object !== "object") {
540 - return object;
541 - }
542 - const normalizedPath = Array.isArray(path) ? path : path.split(".");
543 - normalizedPath.reduce((acc, key, idx) => {
544 - if (acc[key] === void 0) {
545 - if (Number.isInteger(normalizedPath[idx + 1])) {
546 - acc[key] = [];
547 - } else {
548 - acc[key] = {};
549 - }
550 - }
551 - if (idx === normalizedPath.length - 1) {
552 - acc[key] = value;
553 - }
554 - return acc[key];
555 - }, object);
556 - return object;
557 - }
558 -
559 609 // packages/core-data/build-module/utils/get-nested-value.mjs
560 610 function getNestedValue(object, path, defaultValue) {
561 611 if (!object || typeof object !== "object" || typeof path !== "string" && !Array.isArray(path)) {
562 612 return object;
@@ -638,13 +688,17 @@
638 688 LOCAL_EDITOR_ORIGIN,
639 689 LOCAL_UNDO_IGNORED_ORIGIN,
640 690 retrySyncConnection
641 691 } = unlock(import_sync.privateApis);
692 + var CRDT_AUTOSAVE_SNAPSHOT_KEY = "crdt_snapshot";
642 693 var syncManager;
643 694 function getSyncManager() {
644 695 if (syncManager) {
645 696 return syncManager;
646 697 }
698 + if (!globalThis.window?.__experimentalEnableRealTimeCollaboration) {
699 + return void 0;
700 + }
647 701 syncManager = createSyncManager();
648 702 return syncManager;
649 703 }
650 704 function hasSyncManager() {
@@ -649,8 +703,27 @@
649 703 }
650 704 function hasSyncManager() {
651 705 return Boolean(syncManager);
652 706 }
707 + function getEntitySnapshot(kind, name, recordId) {
708 + if (!hasSyncManager()) {
709 + return void 0;
710 + }
711 + return getSyncManager()?.getEntitySnapshot(
712 + `${kind}/${name}`,
713 + `${recordId}`
714 + );
715 + }
716 + function entityContainsSnapshot(kind, name, recordId, encodedSnapshot) {
717 + if (!hasSyncManager()) {
718 + return false;
719 + }
720 + return getSyncManager()?.entityContainsSnapshot(
721 + `${kind}/${name}`,
722 + `${recordId}`,
723 + encodedSnapshot
724 + ) ?? false;
725 + }
653 726
654 727 // packages/core-data/build-module/utils/save-crdt-doc.mjs
655 728 var SYNC_SAVE_API_PATH = "/wp-sync/v1/save";
656 729 var saveCRDTDocQueues = /* @__PURE__ */ new Map();
@@ -685,8 +758,18 @@
685 758 }
686 759 }
687 760 }
688 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 +
689 772 // packages/core-data/build-module/queried-data/actions.mjs
690 773 function receiveItems(items2, edits, meta) {
691 774 return {
692 775 type: "RECEIVE_ITEMS",
@@ -1005,18 +1088,49 @@
1005 1088 return Object.entries(collaboratorInfo1).every(([key, value]) => {
1006 1089 return value === collaboratorInfo2[key];
1007 1090 });
1008 1091 }
1009 - function generateCollaboratorInfo(currentCollaborator) {
1010 - 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 + }
1011 1126 return {
1012 - avatar_urls,
1013 - // eslint-disable-line camelcase
1014 - browserType: getBrowserName(),
1015 - enteredAt: Date.now(),
1016 - id,
1017 - name,
1018 - 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}`
1019 1133 };
1020 1134 }
1021 1135 function getRecordValue(obj, key) {
1022 1136 if ("object" === typeof obj && null !== obj && key in obj) {
@@ -1301,11 +1415,17 @@
1301 1415 /**
1302 1416 * Set the current collaborator info in the local state.
1303 1417 */
1304 1418 async setCurrentCollaboratorInfo() {
1305 - const currentUser2 = await (0, import_data.resolveSelect)(STORE_NAME).getCurrentUser();
1306 - const collaboratorInfo = generateCollaboratorInfo(currentUser2);
1307 - 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 + );
1308 1428 }
1309 1429 };
1310 1430 var baseEqualityFieldChecks = {
1311 1431 collaboratorInfo: areCollaboratorInfosEqual
@@ -1373,11 +1493,11 @@
1373 1493 }
1374 1494 return null;
1375 1495 }
1376 1496 function usePostContentBlocks() {
1377 - return (0, import_data2.useSelect)((select4) => {
1497 + return (0, import_data2.useSelect)((select5) => {
1378 1498 const { getBlocksByName, getClientIdsTree } = unlock(
1379 - select4(import_block_editor.store)
1499 + select5(import_block_editor.store)
1380 1500 );
1381 1501 const [postContentClientId] = getBlocksByName("core/post-content");
1382 1502 return getClientIdsTree(postContentClientId ?? "");
1383 1503 }, []);
@@ -1549,32 +1669,32 @@
1549 1669 type: "cursor",
1550 1670 cursorPosition
1551 1671 };
1552 1672 } else if (isSelectionInOneBlock) {
1553 - const cursorStartPosition2 = getCursorPosition(
1673 + const cursorStartPosition = getCursorPosition(
1554 1674 selectionStart,
1555 1675 yBlocks
1556 1676 );
1557 - const cursorEndPosition2 = getCursorPosition(selectionEnd, yBlocks);
1558 - if (!cursorStartPosition2 || !cursorEndPosition2) {
1677 + const cursorEndPosition = getCursorPosition(selectionEnd, yBlocks);
1678 + if (!cursorStartPosition || !cursorEndPosition) {
1559 1679 return noSelection;
1560 1680 }
1561 1681 return {
1562 1682 type: "selection-in-one-block",
1563 - cursorStartPosition: cursorStartPosition2,
1564 - cursorEndPosition: cursorEndPosition2,
1683 + cursorStartPosition,
1684 + cursorEndPosition,
1565 1685 selectionDirection
1566 1686 };
1567 1687 }
1568 - const cursorStartPosition = getCursorPosition(selectionStart, yBlocks);
1569 - const cursorEndPosition = getCursorPosition(selectionEnd, yBlocks);
1570 - if (!cursorStartPosition || !cursorEndPosition) {
1688 + const startEndpoint = getSelectionEndpoint(selectionStart, yBlocks);
1689 + const endEndpoint = getSelectionEndpoint(selectionEnd, yBlocks);
1690 + if (!startEndpoint || !endEndpoint) {
1571 1691 return noSelection;
1572 1692 }
1573 1693 return {
1574 1694 type: "selection-in-multiple-blocks",
1575 - cursorStartPosition,
1576 - cursorEndPosition,
1695 + startEndpoint,
1696 + endEndpoint,
1577 1697 selectionDirection
1578 1698 };
1579 1699 }
1580 1700 function getCursorPosition(selection, blocks) {
@@ -1600,8 +1720,20 @@
1600 1720 absoluteOffset: selection.offset,
1601 1721 attributeKey: selection.attributeKey
1602 1722 };
1603 1723 }
1724 + function getSelectionEndpoint(selection, blocks) {
1725 + const cursorPosition = getCursorPosition(selection, blocks);
1726 + if (cursorPosition) {
1727 + return { type: "cursor", cursorPosition };
1728 + }
1729 + const path = getBlockPathForLocalClientId(selection.clientId);
1730 + const blockPosition = path ? createRelativePositionForBlockPath(path, blocks) : null;
1731 + if (blockPosition) {
1732 + return { type: "whole-block", blockPosition };
1733 + }
1734 + return null;
1735 + }
1604 1736 function getBlockPathForLocalClientId(clientId) {
1605 1737 const { getBlockIndex, getBlockRootClientId, getBlockName } = (0, import_data3.select)(import_block_editor2.store);
1606 1738 const path = [];
1607 1739 let current = clientId;
@@ -1677,14 +1809,14 @@
1677 1809 selection1.cursorEndPosition,
1678 1810 selection2.cursorEndPosition
1679 1811 ) && selection1.selectionDirection === selection2.selectionDirection;
1680 1812 case "selection-in-multiple-blocks":
1681 - return areCursorPositionsEqual(
1682 - selection1.cursorStartPosition,
1683 - selection2.cursorStartPosition
1684 - ) && areCursorPositionsEqual(
1685 - selection1.cursorEndPosition,
1686 - selection2.cursorEndPosition
1813 + return areEndpointsEqual(
1814 + selection1.startEndpoint,
1815 + selection2.startEndpoint
1816 + ) && areEndpointsEqual(
1817 + selection1.endEndpoint,
1818 + selection2.endEndpoint
1687 1819 ) && selection1.selectionDirection === selection2.selectionDirection;
1688 1820 case "whole-block":
1689 1821 return import_sync7.Y.compareRelativePositions(
1690 1822 selection1.blockPosition,
@@ -1693,8 +1825,23 @@
1693 1825 default:
1694 1826 return false;
1695 1827 }
1696 1828 }
1829 + function areEndpointsEqual(ep1, ep2) {
1830 + if (ep1.type !== ep2.type) {
1831 + return false;
1832 + }
1833 + if (ep1.type === "cursor" && ep2.type === "cursor") {
1834 + return areCursorPositionsEqual(
1835 + ep1.cursorPosition,
1836 + ep2.cursorPosition
1837 + );
1838 + }
1839 + return import_sync7.Y.compareRelativePositions(
1840 + ep1.blockPosition,
1841 + ep2.blockPosition
1842 + );
1843 + }
1697 1844 function areCursorPositionsEqual(cursorPosition1, cursorPosition2) {
1698 1845 const isRelativePositionEqual = import_sync7.Y.compareRelativePositions(
1699 1846 cursorPosition1.relativePosition,
1700 1847 cursorPosition2.relativePosition
@@ -1862,8 +2009,15 @@
1862 2009 localClientId: localClientId2,
1863 2010 attributeKey: null
1864 2011 };
1865 2012 }
2013 + if (selection.type === SelectionType.SelectionInMultipleBlocks) {
2014 + return {
2015 + richTextOffset: null,
2016 + localClientId: null,
2017 + attributeKey: null
2018 + };
2019 + }
1866 2020 const cursorPos = "cursorPosition" in selection ? selection.cursorPosition : selection.cursorStartPosition;
1867 2021 const absolutePosition = import_sync9.Y.createAbsolutePositionFromRelativePosition(
1868 2022 cursorPos.relativePosition,
1869 2023 this.doc
@@ -1908,17 +2062,17 @@
1908 2062 value.toJSON()
1909 2063 ])
1910 2064 );
1911 2065 const collaboratorMapData = new Map(
1912 - Array.from(this.getSeenStates().entries()).map(
1913 - ([clientId, collaboratorState]) => [
1914 - String(clientId),
1915 - {
1916 - name: collaboratorState.collaboratorInfo.name,
1917 - wpUserId: collaboratorState.collaboratorInfo.id
1918 - }
1919 - ]
1920 - )
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 + ])
1921 2075 );
1922 2076 const serializableClientItems = {};
1923 2077 ydoc.store.clients.forEach((structs, clientId) => {
1924 2078 const items2 = structs.filter(this.isYItem);
@@ -3082,10 +3236,12 @@
3082 3236 _fields: [
3083 3237 "description",
3084 3238 "gmt_offset",
3085 3239 "home",
3240 + "image_max_bit_depth",
3086 3241 "image_sizes",
3087 3242 "image_size_threshold",
3243 + "image_strip_meta",
3088 3244 "name",
3089 3245 "site_icon",
3090 3246 "site_icon_url",
3091 3247 "site_logo",
@@ -3177,9 +3333,9 @@
3177 3333 baseURLParams: { context: "edit" },
3178 3334 plural: "comments",
3179 3335 label: (0, import_i18n.__)("Comment"),
3180 3336 supportsPagination: true,
3181 - syncConfig: defaultCollectionSyncConfig
3337 + ...globalThis.window?.__experimentalEnableRealTimeCollaboration ? { syncConfig: defaultCollectionSyncConfig } : {}
3182 3338 },
3183 3339 {
3184 3340 name: "menu",
3185 3341 kind: "root",
@@ -3251,16 +3407,8 @@
3251 3407 key: "slug",
3252 3408 supportsPagination: false
3253 3409 },
3254 3410 {
3255 - label: (0, import_i18n.__)("Registered Templates"),
3256 - name: "registeredTemplate",
3257 - kind: "root",
3258 - baseURL: "/wp/v2/registered-templates",
3259 - key: "id",
3260 - supportsPagination: false
3261 - },
3262 - {
3263 3411 label: (0, import_i18n.__)("Font Collections"),
3264 3412 name: "fontCollection",
3265 3413 kind: "root",
3266 3414 baseURL: "/wp/v2/font-collections",
@@ -3277,8 +3425,18 @@
3277 3425 baseURLParams: { context: "view" },
3278 3426 plural: "icons",
3279 3427 key: "name",
3280 3428 supportsPagination: false
3429 + },
3430 + {
3431 + label: (0, import_i18n.__)("Icon Collections"),
3432 + name: "iconCollection",
3433 + kind: "root",
3434 + baseURL: "/wp/v2/icon-collections",
3435 + baseURLParams: { context: "view" },
3436 + plural: "iconCollections",
3437 + key: "slug",
3438 + supportsPagination: false
3281 3439 }
3282 3440 ];
3283 3441 var deprecatedEntities = {
3284 3442 root: {
@@ -3310,12 +3468,12 @@
3310 3468 if ((!edits.title || edits.title === "Auto Draft") && !newEdits.title && (!persistedRecord?.title || persistedRecord?.title === "Auto Draft")) {
3311 3469 newEdits.title = "";
3312 3470 }
3313 3471 }
3314 - if (persistedRecord) {
3472 + if (window.__experimentalEnableRealTimeCollaboration && persistedRecord) {
3315 3473 const objectType = `postType/${name}`;
3316 3474 const objectId = persistedRecord.id;
3317 - const serializedDoc = getSyncManager()?.createPersistedCRDTDoc(
3475 + const serializedDoc = await getSyncManager()?.createPersistedCRDTDoc(
3318 3476 objectType,
3319 3477 objectId
3320 3478 );
3321 3479 if (serializedDoc) {
@@ -3328,9 +3486,9 @@
3328 3486 return newEdits;
3329 3487 };
3330 3488 async function loadPostTypeEntities() {
3331 3489 const postTypesPromise = (0, import_api_fetch2.default)({ path: "/wp/v2/types?context=view" });
3332 - const taxonomiesPromise = window._wpCollaborationEnabled ? (0, import_api_fetch2.default)({ path: "/wp/v2/taxonomies?context=view" }) : Promise.resolve({});
3490 + const taxonomiesPromise = window.__experimentalEnableRealTimeCollaboration ? (0, import_api_fetch2.default)({ path: "/wp/v2/taxonomies?context=view" }) : Promise.resolve({});
3333 3491 const [postTypes, taxonomies] = await Promise.all([
3334 3492 postTypesPromise,
3335 3493 taxonomiesPromise
3336 3494 ]);
@@ -3371,12 +3529,17 @@
3371 3529 rawAttributes: POST_RAW_ATTRIBUTES,
3372 3530 getTitle: (record) => record?.title?.rendered || record?.title || (isTemplate ? capitalCase(record.slug ?? "") : String(record.id)),
3373 3531 __unstablePrePersist: (persistedRecord, edits) => prePersistPostType(persistedRecord, edits, name, isTemplate),
3374 3532 __unstable_rest_base: postType.rest_base,
3375 - supportsPagination: true,
3533 + // The templates controller returns the whole collection and never
3534 + // paginates.
3535 + supportsPagination: !isTemplate,
3376 3536 getRevisionsUrl: (parentId, revisionId) => `/${namespace}/${postType.rest_base}/${parentId}/revisions${revisionId ? "/" + revisionId : ""}`,
3377 - revisionKey: isTemplate && !window?.__experimentalTemplateActivate ? "wp_id" : DEFAULT_ENTITY_KEY
3537 + revisionKey: isTemplate ? "wp_id" : DEFAULT_ENTITY_KEY
3378 3538 };
3539 + if (!window.__experimentalEnableRealTimeCollaboration) {
3540 + return entity2;
3541 + }
3379 3542 entity2.syncConfig = {
3380 3543 // Save a CRDT document with this entity
3381 3544 supportsPersistence: true,
3382 3545 /**
@@ -3442,9 +3605,11 @@
3442 3605 label: taxonomy.name,
3443 3606 getTitle: (record) => record?.name,
3444 3607 supportsPagination: true
3445 3608 };
3446 - entity2.syncConfig = defaultSyncConfig;
3609 + if (window.__experimentalEnableRealTimeCollaboration) {
3610 + entity2.syncConfig = defaultSyncConfig;
3611 + }
3447 3612 return entity2;
3448 3613 });
3449 3614 }
3450 3615 async function loadSiteEntity() {
@@ -3619,8 +3784,29 @@
3619 3784 ),
3620 3785 meta: action.meta
3621 3786 };
3622 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 + }
3623 3809 var queries = (state = {}, action) => {
3624 3810 switch (action.type) {
3625 3811 case "RECEIVE_ITEMS":
3626 3812 return receiveQueries(state, action);
@@ -3636,14 +3822,12 @@
3636 3822 Object.fromEntries(
3637 3823 Object.entries(contextQueries).map(
3638 3824 ([query, queryItems]) => [
3639 3825 query,
3640 - {
3641 - ...queryItems,
3642 - itemIds: queryItems.itemIds.filter(
3643 - (queryId) => !removedItems[queryId]
3644 - )
3645 - }
3826 + removeQueryItems(
3827 + queryItems,
3828 + removedItems
3829 + )
3646 3830 ]
3647 3831 )
3648 3832 )
3649 3833 ]
@@ -4205,8 +4389,9 @@
4205 4389 getEditorAssets: () => getEditorAssets,
4206 4390 getEditorSettings: () => getEditorSettings,
4207 4391 getEntityRecordPermissions: () => getEntityRecordPermissions,
4208 4392 getEntityRecordsPermissions: () => getEntityRecordsPermissions,
4393 + getEntitySyncConnectionStatus: () => getEntitySyncConnectionStatus,
4209 4394 getHomePage: () => getHomePage,
4210 4395 getNavigationFallbackId: () => getNavigationFallbackId,
4211 4396 getPostsPageId: () => getPostsPageId,
4212 4397 getRegisteredPostMeta: () => getRegisteredPostMeta,
@@ -4255,26 +4440,26 @@
4255 4440 function getNavigationFallbackId(state) {
4256 4441 return state.navigationFallbackId;
4257 4442 }
4258 4443 var getBlockPatternsForPostType = (0, import_data8.createRegistrySelector)(
4259 - (select4) => (0, import_data8.createSelector)(
4260 - (state, postType) => select4(STORE_NAME).getBlockPatterns().filter(
4444 + (select5) => (0, import_data8.createSelector)(
4445 + (state, postType) => select5(STORE_NAME).getBlockPatterns().filter(
4261 4446 ({ postTypes }) => !postTypes || Array.isArray(postTypes) && postTypes.includes(postType)
4262 4447 ),
4263 - () => [select4(STORE_NAME).getBlockPatterns()]
4448 + () => [select5(STORE_NAME).getBlockPatterns()]
4264 4449 )
4265 4450 );
4266 4451 var getEntityRecordsPermissions = (0, import_data8.createRegistrySelector)(
4267 - (select4) => (0, import_data8.createSelector)(
4452 + (select5) => (0, import_data8.createSelector)(
4268 4453 (state, kind, name, ids) => {
4269 4454 const normalizedIds = Array.isArray(ids) ? ids : [ids];
4270 4455 return normalizedIds.map((id) => ({
4271 - delete: select4(STORE_NAME).canUser("delete", {
4456 + delete: select5(STORE_NAME).canUser("delete", {
4272 4457 kind,
4273 4458 name,
4274 4459 id
4275 4460 }),
4276 - update: select4(STORE_NAME).canUser("update", {
4461 + update: select5(STORE_NAME).canUser("update", {
4277 4462 kind,
4278 4463 name,
4279 4464 id
4280 4465 })
@@ -4299,11 +4484,11 @@
4299 4484 }
4300 4485 return value.toString();
4301 4486 }
4302 4487 var getHomePage = (0, import_data8.createRegistrySelector)(
4303 - (select4) => (0, import_data8.createSelector)(
4488 + (select5) => (0, import_data8.createSelector)(
4304 4489 () => {
4305 - const siteData = select4(STORE_NAME).getEntityRecord(
4490 + const siteData = select5(STORE_NAME).getEntityRecord(
4306 4491 "root",
4307 4492 "__unstableBase"
4308 4493 );
4309 4494 if (!siteData) {
@@ -4312,9 +4497,9 @@
4312 4497 const homepageId = siteData?.show_on_front === "page" ? normalizePageId(siteData.page_on_front) : null;
4313 4498 if (homepageId) {
4314 4499 return { postType: "page", postId: homepageId };
4315 4500 }
4316 - const frontPageTemplateId = select4(
4501 + const frontPageTemplateId = select5(
4317 4502 STORE_NAME
4318 4503 ).getDefaultTemplateId({
4319 4504 slug: "front-page"
4320 4505 });
@@ -4339,10 +4524,10 @@
4339 4524 })
4340 4525 ]
4341 4526 )
4342 4527 );
4343 - var getPostsPageId = (0, import_data8.createRegistrySelector)((select4) => () => {
4344 - const siteData = select4(STORE_NAME).getEntityRecord(
4528 + var getPostsPageId = (0, import_data8.createRegistrySelector)((select5) => () => {
4529 + const siteData = select5(STORE_NAME).getEntityRecord(
4345 4530 "root",
4346 4531 "__unstableBase"
4347 4532 );
4348 4533 return siteData?.show_on_front === "page" ? normalizePageId(siteData.page_for_posts) : null;
@@ -4347,15 +4532,15 @@
4347 4532 );
4348 4533 return siteData?.show_on_front === "page" ? normalizePageId(siteData.page_for_posts) : null;
4349 4534 });
4350 4535 var getTemplateId = (0, import_data8.createRegistrySelector)(
4351 - (select4) => (state, postType, postId) => {
4352 - const homepage = unlock(select4(STORE_NAME)).getHomePage();
4536 + (select5) => (state, postType, postId) => {
4537 + const homepage = unlock(select5(STORE_NAME)).getHomePage();
4353 4538 if (!homepage) {
4354 4539 return;
4355 4540 }
4356 4541 if (postType === "page" && postType === homepage?.postType && postId.toString() === homepage?.postId) {
4357 - const templates = select4(STORE_NAME).getEntityRecords(
4542 + const templates = select5(STORE_NAME).getEntityRecords(
4358 4543 "postType",
4359 4544 "wp_template",
4360 4545 {
4361 4546 per_page: -1
@@ -4363,14 +4548,16 @@
4363 4548 );
4364 4549 if (!templates) {
4365 4550 return;
4366 4551 }
4367 - const id = templates.find(({ slug }) => slug === "front-page")?.id;
4552 + const id = templates.find(
4553 + ({ slug }) => slug === "front-page"
4554 + )?.id;
4368 4555 if (id) {
4369 4556 return id;
4370 4557 }
4371 4558 }
4372 - const editedEntity = select4(STORE_NAME).getEditedEntityRecord(
4559 + const editedEntity = select5(STORE_NAME).getEditedEntityRecord(
4373 4560 "postType",
4374 4561 postType,
4375 4562 postId
4376 4563 );
@@ -4376,17 +4563,17 @@
4376 4563 );
4377 4564 if (!editedEntity) {
4378 4565 return;
4379 4566 }
4380 - const postsPageId = unlock(select4(STORE_NAME)).getPostsPageId();
4567 + const postsPageId = unlock(select5(STORE_NAME)).getPostsPageId();
4381 4568 if (postType === "page" && postsPageId === postId.toString()) {
4382 - return select4(STORE_NAME).getDefaultTemplateId({
4569 + return select5(STORE_NAME).getDefaultTemplateId({
4383 4570 slug: "home"
4384 4571 });
4385 4572 }
4386 4573 const currentTemplateSlug = editedEntity.template;
4387 4574 if (currentTemplateSlug) {
4388 - const currentTemplate = select4(STORE_NAME).getEntityRecords("postType", "wp_template", {
4575 + const currentTemplate = select5(STORE_NAME).getEntityRecords("postType", "wp_template", {
4389 4576 per_page: -1
4390 4577 })?.find(({ slug }) => slug === currentTemplateSlug);
4391 4578 if (currentTemplate) {
4392 4579 return currentTemplate.id;
@@ -4397,9 +4584,9 @@
4397 4584 slugToCheck = postType === "page" ? `${postType}-${editedEntity.slug}` : `single-${postType}-${editedEntity.slug}`;
4398 4585 } else {
4399 4586 slugToCheck = postType === "page" ? "page" : `single-${postType}`;
4400 4587 }
4401 - return select4(STORE_NAME).getDefaultTemplateId({
4588 + return select5(STORE_NAME).getDefaultTemplateId({
4402 4589 slug: slugToCheck
4403 4590 });
4404 4591 }
4405 4592 );
@@ -4432,14 +4619,17 @@
4432 4619 }
4433 4620 }
4434 4621 return coalesced;
4435 4622 }
4623 + function getEntitySyncConnectionStatus(state, kind, name, recordId) {
4624 + return state.syncConnectionStatuses?.[`${kind}/${name}:${recordId}`];
4625 + }
4436 4626
4437 4627 // packages/core-data/build-module/selectors.mjs
4438 4628 var EMPTY_OBJECT2 = {};
4439 4629 var isRequestingEmbedPreview = (0, import_data9.createRegistrySelector)(
4440 - (select4) => (state, url) => {
4441 - return select4(STORE_NAME).isResolving("getEmbedPreview", [
4630 + (select5) => (state, url) => {
4631 + return select5(STORE_NAME).isResolving("getEmbedPreview", [
4442 4632 url
4443 4633 ]);
4444 4634 }
4445 4635 );
@@ -4492,54 +4682,34 @@
4492 4682 return state.entities.config?.find(
4493 4683 (config) => config.kind === kind && config.name === name
4494 4684 );
4495 4685 }
4496 - var getEntityRecord = (0, import_data9.createSelector)(
4497 - ((state, kind, name, key, query) => {
4498 - logEntityDeprecation(kind, name, "getEntityRecord");
4499 - const queriedState = state.entities.records?.[kind]?.[name]?.queriedData;
4500 - 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]) {
4501 4695 return void 0;
4502 4696 }
4503 - const context = query?.context ?? "default";
4504 - if (!query || !query._fields) {
4505 - if (!queriedState.itemIsComplete[context]?.[key]) {
4506 - return void 0;
4507 - }
4508 - return queriedState.items[context][key];
4509 - }
4510 - const item = queriedState.items[context]?.[key];
4511 - if (!item) {
4512 - return item;
4513 - }
4514 - const filteredItem = {};
4515 - const fields = get_normalized_comma_separable_default(query._fields) ?? [];
4516 - for (let f = 0; f < fields.length; f++) {
4517 - const field = fields[f].split(".");
4518 - let value = item;
4519 - field.forEach((fieldName) => {
4520 - value = value?.[fieldName];
4521 - });
4522 - setNestedValue(filteredItem, field, value);
4523 - }
4524 - return filteredItem;
4525 - }),
4526 - (state, kind, name, recordId, query) => {
4527 - const context = query?.context ?? "default";
4528 - const queriedState = state.entities.records?.[kind]?.[name]?.queriedData;
4529 - return [
4530 - queriedState?.items[context]?.[recordId],
4531 - queriedState?.itemIsComplete[context]?.[recordId]
4532 - ];
4697 + return queriedState.items[context][recordId];
4533 4698 }
4534 - );
4535 - 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) => {
4536 4706 const newArgs = [...args];
4537 4707 const recordKey = newArgs?.[2];
4538 4708 newArgs[2] = isNumericID(recordKey) ? Number(recordKey) : recordKey;
4539 4709 return newArgs;
4540 4710 };
4541 - function hasEntityRecord(state, kind, name, key, query) {
4711 + function hasEntityRecord(state, kind, name, recordId, query) {
4542 4712 const queriedState = state.entities.records?.[kind]?.[name]?.queriedData;
4543 4713 if (!queriedState) {
4544 4714 return false;
4545 4715 }
@@ -4544,11 +4714,11 @@
4544 4714 return false;
4545 4715 }
4546 4716 const context = query?.context ?? "default";
4547 4717 if (!query || !query._fields) {
4548 - return !!queriedState.itemIsComplete[context]?.[key];
4718 + return !!queriedState.itemIsComplete[context]?.[recordId];
4549 4719 }
4550 - const item = queriedState.items[context]?.[key];
4720 + const item = queriedState.items[context]?.[recordId];
4551 4721 if (!item) {
4552 4722 return false;
4553 4723 }
4554 4724 const fields = get_normalized_comma_separable_default(query._fields) ?? [];
@@ -4564,19 +4734,19 @@
4564 4734 }
4565 4735 }
4566 4736 return true;
4567 4737 }
4568 - function __experimentalGetEntityRecordNoResolver(state, kind, name, key) {
4569 - return getEntityRecord(state, kind, name, key);
4738 + function __experimentalGetEntityRecordNoResolver(state, kind, name, recordId) {
4739 + return getEntityRecord(state, kind, name, recordId);
4570 4740 }
4571 4741 var getRawEntityRecord = (0, import_data9.createSelector)(
4572 - (state, kind, name, key) => {
4742 + (state, kind, name, recordId) => {
4573 4743 logEntityDeprecation(kind, name, "getRawEntityRecord");
4574 4744 const record = getEntityRecord(
4575 4745 state,
4576 4746 kind,
4577 4747 name,
4578 - key
4748 + recordId
4579 4749 );
4580 4750 const config = getEntityConfig(state, kind, name);
4581 4751 if (!record || !config?.rawAttributes?.length) {
4582 4752 return record;
@@ -4581,17 +4751,17 @@
4581 4751 if (!record || !config?.rawAttributes?.length) {
4582 4752 return record;
4583 4753 }
4584 4754 return Object.fromEntries(
4585 - Object.keys(record).map((_key) => {
4586 - if (config.rawAttributes.includes(_key)) {
4587 - const rawValue = record[_key]?.raw;
4755 + Object.keys(record).map((key) => {
4756 + if (config.rawAttributes.includes(key)) {
4757 + const rawValue = record[key]?.raw;
4588 4758 return [
4589 - _key,
4590 - rawValue !== void 0 ? rawValue : record[_key]
4759 + key,
4760 + rawValue !== void 0 ? rawValue : record[key]
4591 4761 ];
4592 4762 }
4593 - return [_key, record[_key]];
4763 + return [key, record[key]];
4594 4764 })
4595 4765 );
4596 4766 },
4597 4767 (state, kind, name, recordId, query) => {
@@ -4720,9 +4890,9 @@
4720 4890 (state) => [state.entities.records]
4721 4891 );
4722 4892 function getEntityRecordEdits(state, kind, name, recordId) {
4723 4893 logEntityDeprecation(kind, name, "getEntityRecordEdits");
4724 - return state.entities.records?.[kind]?.[name]?.edits?.[recordId];
4894 + return state.entities.records?.[kind]?.[name]?.edits?.[String(recordId)];
4725 4895 }
4726 4896 var getEntityRecordNonTransientEdits = (0, import_data9.createSelector)(
4727 4897 (state, kind, name, recordId) => {
4728 4898 logEntityDeprecation(kind, name, "getEntityRecordNonTransientEdits");
@@ -4739,9 +4909,9 @@
4739 4909 }, {});
4740 4910 },
4741 4911 (state, kind, name, recordId) => [
4742 4912 state.entities.config,
4743 - state.entities.records?.[kind]?.[name]?.edits?.[recordId]
4913 + state.entities.records?.[kind]?.[name]?.edits?.[String(recordId)]
4744 4914 ]
4745 4915 );
4746 4916 function hasEditsForEntityRecord(state, kind, name, recordId) {
4747 4917 logEntityDeprecation(kind, name, "hasEditsForEntityRecord");
@@ -4767,9 +4937,9 @@
4767 4937 return [
4768 4938 state.entities.config,
4769 4939 state.entities.records?.[kind]?.[name]?.queriedData.items[context]?.[recordId],
4770 4940 state.entities.records?.[kind]?.[name]?.queriedData.itemIsComplete[context]?.[recordId],
4771 - state.entities.records?.[kind]?.[name]?.edits?.[recordId]
4941 + state.entities.records?.[kind]?.[name]?.edits?.[String(recordId)]
4772 4942 ];
4773 4943 }
4774 4944 );
4775 4945 function isAutosavingEntityRecord(state, kind, name, recordId) {
@@ -4778,17 +4948,17 @@
4778 4948 return Boolean(pending && isAutosave);
4779 4949 }
4780 4950 function isSavingEntityRecord(state, kind, name, recordId) {
4781 4951 logEntityDeprecation(kind, name, "isSavingEntityRecord");
4782 - return state.entities.records?.[kind]?.[name]?.saving?.[recordId]?.pending ?? false;
4952 + return state.entities.records?.[kind]?.[name]?.saving?.[String(recordId)]?.pending ?? false;
4783 4953 }
4784 4954 function isDeletingEntityRecord(state, kind, name, recordId) {
4785 4955 logEntityDeprecation(kind, name, "isDeletingEntityRecord");
4786 - return state.entities.records?.[kind]?.[name]?.deleting?.[recordId]?.pending ?? false;
4956 + return state.entities.records?.[kind]?.[name]?.deleting?.[String(recordId)]?.pending ?? false;
4787 4957 }
4788 4958 function getLastEntitySaveError(state, kind, name, recordId) {
4789 4959 logEntityDeprecation(kind, name, "getLastEntitySaveError");
4790 - return state.entities.records?.[kind]?.[name]?.saving?.[recordId]?.error;
4960 + return state.entities.records?.[kind]?.[name]?.saving?.[String(recordId)]?.error;
4791 4961 }
4792 4962 function getLastEntityDeleteError(state, kind, name, recordId) {
4793 4963 logEntityDeprecation(kind, name, "getLastEntityDeleteError");
4794 4964 return state.entities.records?.[kind]?.[name]?.deleting?.[recordId]?.error;
@@ -4870,10 +5040,10 @@
4870 5040 (autosave) => autosave.author === authorId
4871 5041 );
4872 5042 }
4873 5043 var hasFetchedAutosaves = (0, import_data9.createRegistrySelector)(
4874 - (select4) => (state, postType, postId) => {
4875 - return select4(STORE_NAME).hasFinishedResolution("getAutosaves", [
5044 + (select5) => (state, postType, postId) => {
5045 + return select5(STORE_NAME).hasFinishedResolution("getAutosaves", [
4876 5046 postType,
4877 5047 postId
4878 5048 ]);
4879 5049 }
@@ -4952,47 +5122,27 @@
4952 5122 }
4953 5123 }
4954 5124 return true;
4955 5125 }
4956 - var getRevision = (0, import_data9.createSelector)(
4957 - (state, kind, name, recordKey, revisionKey, query) => {
4958 - logEntityDeprecation(kind, name, "getRevision");
4959 - const queriedState = state.entities.records?.[kind]?.[name]?.revisions?.[recordKey];
4960 - 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]) {
4961 5135 return void 0;
4962 5136 }
4963 - const context = query?.context ?? "default";
4964 - if (!query || !query._fields) {
4965 - if (!queriedState.itemIsComplete[context]?.[revisionKey]) {
4966 - return void 0;
4967 - }
4968 - return queriedState.items[context][revisionKey];
4969 - }
4970 - const item = queriedState.items[context]?.[revisionKey];
4971 - if (!item) {
4972 - return item;
4973 - }
4974 - const filteredItem = {};
4975 - const fields = get_normalized_comma_separable_default(query._fields) ?? [];
4976 - for (let f = 0; f < fields.length; f++) {
4977 - const field = fields[f].split(".");
4978 - let value = item;
4979 - field.forEach((fieldName) => {
4980 - value = value?.[fieldName];
4981 - });
4982 - setNestedValue(filteredItem, field, value);
4983 - }
4984 - return filteredItem;
4985 - },
4986 - (state, kind, name, recordKey, revisionKey, query) => {
4987 - const context = query?.context ?? "default";
4988 - const queriedState = state.entities.records?.[kind]?.[name]?.revisions?.[recordKey];
4989 - return [
4990 - queriedState?.items?.[context]?.[revisionKey],
4991 - queriedState?.itemIsComplete?.[context]?.[revisionKey]
4992 - ];
5137 + return queriedState.items[context][revisionKey];
4993 5138 }
4994 - );
5139 + const item = queriedState.items[context]?.[revisionKey];
5140 + if (!item) {
5141 + return item;
5142 + }
5143 + return getFilteredItem(item, query._fields);
5144 + };
4995 5145
4996 5146 // packages/core-data/build-module/actions.mjs
4997 5147 var actions_exports = {};
4998 5148 __export(actions_exports, {
@@ -5024,8 +5174,9 @@
5024 5174 saveEditedEntityRecord: () => saveEditedEntityRecord,
5025 5175 saveEntityRecord: () => saveEntityRecord,
5026 5176 undo: () => undo
5027 5177 });
5178 + var import_es66 = __toESM(require_es6(), 1);
5028 5179 var import_api_fetch4 = __toESM(require_api_fetch(), 1);
5029 5180 var import_url3 = __toESM(require_url(), 1);
5030 5181 var import_deprecated3 = __toESM(require_deprecated(), 1);
5031 5182
@@ -5213,8 +5364,39 @@
5213 5364 // packages/core-data/build-module/actions.mjs
5214 5365 function addTitleToAutoDraft(record) {
5215 5366 return record.status === "auto-draft" ? { ...record, title: "" } : record;
5216 5367 }
5368 + function getServerMutatedMetaFields(updatedMeta, persistedMeta, syncedMeta) {
5369 + const baseline = { ...persistedMeta, ...syncedMeta };
5370 + return Object.fromEntries(
5371 + Object.entries(updatedMeta ?? {}).filter(([key, value]) => {
5372 + if (key === POST_META_KEY_FOR_CRDT_DOC_PERSISTENCE) {
5373 + return false;
5374 + }
5375 + return !(0, import_es66.default)(value, baseline[key]);
5376 + })
5377 + );
5378 + }
5379 + function getServerMutatedFields(updatedRecord, persistedRecord, syncedChanges) {
5380 + return Object.fromEntries(
5381 + Object.entries(updatedRecord).flatMap(([key, value]) => {
5382 + if (key === "meta") {
5383 + const serverMutatedMeta = getServerMutatedMetaFields(
5384 + value,
5385 + persistedRecord.meta,
5386 + syncedChanges.meta
5387 + );
5388 + return Object.keys(serverMutatedMeta).length ? [[key, serverMutatedMeta]] : [];
5389 + }
5390 + const baseline = key in syncedChanges ? syncedChanges[key] : persistedRecord[key];
5391 + const wasServerMutated = !(0, import_es66.default)(
5392 + getRawValue(value) ?? value,
5393 + getRawValue(baseline) ?? baseline
5394 + );
5395 + return wasServerMutated ? [[key, value]] : [];
5396 + })
5397 + );
5398 + }
5217 5399 function receiveUserQuery(queryID, users2) {
5218 5400 return {
5219 5401 type: "RECEIVE_USER_QUERY",
5220 5402 users: Array.isArray(users2) ? users2 : [users2],
@@ -5328,12 +5510,9 @@
5328 5510 name,
5329 5511 recordId
5330 5512 });
5331 5513 let hasError = false;
5332 - let { baseURL } = entityConfig;
5333 - if (kind === "postType" && name === "wp_template" && (recordId && typeof recordId === "string" && !/^\d+$/.test(recordId) || !window?.__experimentalTemplateActivate)) {
5334 - baseURL = baseURL.slice(0, baseURL.lastIndexOf("/")) + "/templates";
5335 - }
5514 + const { baseURL } = entityConfig;
5336 5515 try {
5337 5516 let path = `${baseURL}/${recordId}`;
5338 5517 if (query) {
5339 5518 path = (0, import_url3.addQueryArgs)(path, query);
@@ -5366,11 +5545,11 @@
5366 5545 } finally {
5367 5546 dispatch3.__unstableReleaseStoreLock(lock2);
5368 5547 }
5369 5548 };
5370 - var editEntityRecord = (kind, name, recordId, edits, options = {}) => ({ select: select4, dispatch: dispatch3 }) => {
5549 + var editEntityRecord = (kind, name, recordId, edits, options = {}) => ({ select: select5, dispatch: dispatch3 }) => {
5371 5550 logEntityDeprecation(kind, name, "editEntityRecord");
5372 - const entityConfig = select4.getEntityConfig(kind, name);
5551 + const entityConfig = select5.getEntityConfig(kind, name);
5373 5552 if (!entityConfig) {
5374 5553 throw new Error(
5375 5554 `The entity being edited (${kind}, ${name}) does not have a loaded config.`
5376 5555 );
@@ -5375,10 +5554,10 @@
5375 5554 `The entity being edited (${kind}, ${name}) does not have a loaded config.`
5376 5555 );
5377 5556 }
5378 5557 const { mergedEdits = {} } = entityConfig;
5379 - const record = select4.getRawEntityRecord(kind, name, recordId);
5380 - const editedRecord = select4.getEditedEntityRecord(
5558 + const record = select5.getRawEntityRecord(kind, name, recordId);
5559 + const editedRecord = select5.getEditedEntityRecord(
5381 5560 kind,
5382 5561 name,
5383 5562 recordId
5384 5563 );
@@ -5407,9 +5586,9 @@
5407 5586 { isNewUndoLevel }
5408 5587 );
5409 5588 }
5410 5589 if (!options.undoIgnore) {
5411 - select4.getUndoManager().addRecord(
5590 + select5.getUndoManager().addRecord(
5412 5591 [
5413 5592 {
5414 5593 id: { kind, name, recordId },
5415 5594 changes: Object.keys(edits).reduce((acc, key) => {
@@ -5428,10 +5607,10 @@
5428 5607 type: "EDIT_ENTITY_RECORD",
5429 5608 ...edit
5430 5609 });
5431 5610 };
5432 - var clearEntityRecordEdits = (kind, name, recordId) => ({ select: select4, dispatch: dispatch3 }) => {
5433 - const entityConfig = select4.getEntityConfig(kind, name);
5611 + var clearEntityRecordEdits = (kind, name, recordId) => ({ select: select5, dispatch: dispatch3 }) => {
5612 + const entityConfig = select5.getEntityConfig(kind, name);
5434 5613 logEntityDeprecation(kind, name, "clearEntityRecordEdits");
5435 5614 if (!entityConfig) {
5436 5615 throw new Error(
5437 5616 `The entity being edited (${kind}, ${name}) does not have a loaded config.`
@@ -5436,9 +5615,9 @@
5436 5615 throw new Error(
5437 5616 `The entity being edited (${kind}, ${name}) does not have a loaded config.`
5438 5617 );
5439 5618 }
5440 - const currentEdits = select4.getEntityRecordEdits(
5619 + const currentEdits = select5.getEntityRecordEdits(
5441 5620 kind,
5442 5621 name,
5443 5622 recordId
5444 5623 );
@@ -5459,10 +5638,10 @@
5459 5638 recordId,
5460 5639 edits: clearedEdits
5461 5640 });
5462 5641 };
5463 - var undo = () => ({ select: select4, dispatch: dispatch3 }) => {
5464 - const undoRecord = select4.getUndoManager().undo();
5642 + var undo = () => ({ select: select5, dispatch: dispatch3 }) => {
5643 + const undoRecord = select5.getUndoManager().undo();
5465 5644 if (!undoRecord) {
5466 5645 return;
5467 5646 }
5468 5647 dispatch3({
@@ -5469,10 +5648,10 @@
5469 5648 type: "UNDO",
5470 5649 record: undoRecord
5471 5650 });
5472 5651 };
5473 - var redo = () => ({ select: select4, dispatch: dispatch3 }) => {
5474 - const redoRecord = select4.getUndoManager().redo();
5652 + var redo = () => ({ select: select5, dispatch: dispatch3 }) => {
5653 + const redoRecord = select5.getUndoManager().redo();
5475 5654 if (!redoRecord) {
5476 5655 return;
5477 5656 }
5478 5657 dispatch3({
@@ -5479,12 +5658,12 @@
5479 5658 type: "REDO",
5480 5659 record: redoRecord
5481 5660 });
5482 5661 };
5483 - var __unstableCreateUndoLevel = () => ({ select: select4 }) => {
5484 - select4.getUndoManager().addRecord();
5662 + var __unstableCreateUndoLevel = () => ({ select: select5 }) => {
5663 + select5.getUndoManager().addRecord();
5485 5664 };
5486 - 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 }) => {
5487 5666 const {
5488 5667 isAutosave = false,
5489 5668 __unstableFetch = import_api_fetch4.default,
5490 5669 __unstableSkipSyncUpdate = false,
@@ -5509,9 +5688,9 @@
5509 5688 try {
5510 5689 for (const [key, value] of Object.entries(record)) {
5511 5690 if (typeof value === "function") {
5512 5691 const evaluatedValue = value(
5513 - select4.getEditedEntityRecord(kind, name, recordId)
5692 + select5.getEditedEntityRecord(kind, name, recordId)
5514 5693 );
5515 5694 dispatch3.editEntityRecord(
5516 5695 kind,
5517 5696 name,
@@ -5533,15 +5712,20 @@
5533 5712 });
5534 5713 let updatedRecord;
5535 5714 let error;
5536 5715 let hasError = false;
5537 - let { baseURL } = entityConfig;
5538 - if (kind === "postType" && name === "wp_template" && (recordId && typeof recordId === "string" && !/^\d+$/.test(recordId) || !window?.__experimentalTemplateActivate)) {
5539 - baseURL = baseURL.slice(0, baseURL.lastIndexOf("/")) + "/templates";
5540 - }
5716 + const { baseURL } = entityConfig;
5541 5717 try {
5542 5718 const path = `${baseURL}${recordId ? "/" + recordId : ""}`;
5543 - const persistedRecord = !isNewRecord ? select4.getRawEntityRecord(kind, name, recordId) : {};
5719 + const persistedRecord = !isNewRecord ? select5.getRawEntityRecord(kind, name, recordId) : {};
5720 + if (entityConfig.syncConfig && !__unstableSkipSyncUpdate && !isNewRecord && persistedRecord) {
5721 + getSyncManager()?.update(
5722 + `${kind}/${name}`,
5723 + recordId,
5724 + record,
5725 + LOCAL_UNDO_IGNORED_ORIGIN
5726 + );
5727 + }
5544 5728 if (isAutosave) {
5545 5729 const merged = { ...persistedRecord, ...record };
5546 5730 const data = [
5547 5731 "title",
@@ -5562,8 +5746,17 @@
5562 5746 // have a draft post and change the status to publish.
5563 5747 status: merged.status === "auto-draft" ? "draft" : void 0
5564 5748 }
5565 5749 );
5750 + if (entityConfig.syncConfig) {
5751 + const crdtSnapshot = getSyncManager()?.getEntitySnapshot(
5752 + `${kind}/${name}`,
5753 + recordId
5754 + );
5755 + if (crdtSnapshot) {
5756 + data[CRDT_AUTOSAVE_SNAPSHOT_KEY] = crdtSnapshot;
5757 + }
5758 + }
5566 5759 updatedRecord = await __unstableFetch({
5567 5760 path: `${path}/autosaves`,
5568 5761 method: "POST",
5569 5762 data
@@ -5626,15 +5819,27 @@
5626 5819 name,
5627 5820 updatedRecord,
5628 5821 void 0,
5629 5822 true,
5630 - edits
5823 + record
5631 5824 );
5632 5825 if (entityConfig.syncConfig) {
5826 + let syncChanges;
5827 + if (__unstableSkipSyncUpdate) {
5828 + syncChanges = {};
5829 + } else if (isNewRecord || !persistedRecord) {
5830 + syncChanges = updatedRecord;
5831 + } else {
5832 + syncChanges = getServerMutatedFields(
5833 + updatedRecord,
5834 + persistedRecord,
5835 + record
5836 + );
5837 + }
5633 5838 getSyncManager()?.update(
5634 5839 `${kind}/${name}`,
5635 5840 recordId,
5636 - __unstableSkipSyncUpdate ? {} : updatedRecord,
5841 + syncChanges,
5637 5842 LOCAL_UNDO_IGNORED_ORIGIN,
5638 5843 { isSave: true }
5639 5844 );
5640 5845 }
@@ -5693,11 +5898,11 @@
5693 5898 ...resultPromises
5694 5899 ]);
5695 5900 return results;
5696 5901 };
5697 - 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 }) => {
5698 5903 logEntityDeprecation(kind, name, "saveEditedEntityRecord");
5699 - if (!select4.hasEditsForEntityRecord(kind, name, recordId)) {
5904 + if (!select5.hasEditsForEntityRecord(kind, name, recordId)) {
5700 5905 return;
5701 5906 }
5702 5907 const configs = await resolveSelect2.getEntitiesConfig(kind);
5703 5908 const entityConfig = configs.find(
@@ -5706,9 +5911,9 @@
5706 5911 if (!entityConfig) {
5707 5912 return;
5708 5913 }
5709 5914 const entityIdKey = entityConfig.key || DEFAULT_ENTITY_KEY;
5710 - const edits = select4.getEntityRecordNonTransientEdits(
5915 + const edits = select5.getEntityRecordNonTransientEdits(
5711 5916 kind,
5712 5917 name,
5713 5918 recordId
5714 5919 );
@@ -5714,18 +5919,18 @@
5714 5919 );
5715 5920 const record = { [entityIdKey]: recordId, ...edits };
5716 5921 return await dispatch3.saveEntityRecord(kind, name, record, options);
5717 5922 };
5718 - 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 }) => {
5719 5924 logEntityDeprecation(
5720 5925 kind,
5721 5926 name,
5722 5927 "__experimentalSaveSpecifiedEntityEdits"
5723 5928 );
5724 - if (!select4.hasEditsForEntityRecord(kind, name, recordId)) {
5929 + if (!select5.hasEditsForEntityRecord(kind, name, recordId)) {
5725 5930 return;
5726 5931 }
5727 - const edits = select4.getEntityRecordNonTransientEdits(
5932 + const edits = select5.getEntityRecordNonTransientEdits(
5728 5933 kind,
5729 5934 name,
5730 5935 recordId
5731 5936 );
@@ -5816,12 +6021,17 @@
5816 6021 receiveEditorAssets: () => receiveEditorAssets,
5817 6022 receiveEditorSettings: () => receiveEditorSettings,
5818 6023 receiveRegisteredPostMeta: () => receiveRegisteredPostMeta,
5819 6024 receiveViewConfig: () => receiveViewConfig,
6025 + saveDirtyEntities: () => saveDirtyEntities,
5820 6026 setCollaborationSupported: () => setCollaborationSupported,
5821 6027 setSyncConnectionStatus: () => setSyncConnectionStatus
5822 6028 });
5823 6029 var import_api_fetch5 = __toESM(require_api_fetch(), 1);
6030 + var import_notices = __toESM(require_notices(), 1);
6031 + var import_block_editor5 = __toESM(require_block_editor(), 1);
6032 + var import_html_entities = __toESM(require_html_entities(), 1);
6033 + var import_i18n2 = __toESM(require_i18n(), 1);
5824 6034 function receiveRegisteredPostMeta(postType, registeredPostMeta2) {
5825 6035 return {
5826 6036 type: "RECEIVE_REGISTERED_POST_META",
5827 6037 postType,
@@ -5911,8 +6121,12 @@
5911 6121 var setCollaborationSupported = (supported) => ({ dispatch: dispatch3 }) => {
5912 6122 dispatch3({ type: "SET_COLLABORATION_SUPPORTED", supported });
5913 6123 if (!supported && hasSyncManager()) {
5914 6124 getSyncManager().unloadAll();
6125 + dispatch3.__unstableNotifySyncUndoManagerChange({
6126 + hasUndo: false,
6127 + hasRedo: false
6128 + });
5915 6129 }
5916 6130 };
5917 6131 function receiveViewConfig(kind, name, config) {
5918 6132 return {
@@ -5944,8 +6158,134 @@
5944 6158 key,
5945 6159 status
5946 6160 };
5947 6161 }
6162 + var saveDirtyEntities = ({
6163 + onSave,
6164 + dirtyEntityRecords = [],
6165 + entitiesToSkip = [],
6166 + close,
6167 + successNoticeContent
6168 + } = {}) => ({ registry }) => {
6169 + const PUBLISH_ON_SAVE_ENTITIES = [
6170 + { kind: "postType", name: "wp_navigation" }
6171 + ];
6172 + const saveNoticeId = "site-editor-save-success";
6173 + const homeUrl = registry.select(STORE_NAME).getEntityRecord("root", "__unstableBase")?.home;
6174 + registry.dispatch(import_notices.store).removeNotice(saveNoticeId);
6175 + const entitiesToSave = dirtyEntityRecords.filter(
6176 + ({ kind, name, key, property }) => {
6177 + return !entitiesToSkip.some(
6178 + (elt) => elt.kind === kind && elt.name === name && elt.key === key && elt.property === property
6179 + );
6180 + }
6181 + );
6182 + close?.(entitiesToSave);
6183 + const siteItemsToSave = [];
6184 + const pendingSavedRecords = [];
6185 + entitiesToSave.forEach(({ kind, name, key, property }) => {
6186 + if ("root" === kind && "site" === name) {
6187 + siteItemsToSave.push(property);
6188 + } else {
6189 + if (PUBLISH_ON_SAVE_ENTITIES.some(
6190 + (typeToPublish) => typeToPublish.kind === kind && typeToPublish.name === name
6191 + )) {
6192 + registry.dispatch(STORE_NAME).editEntityRecord(kind, name, key, {
6193 + status: "publish"
6194 + });
6195 + }
6196 + pendingSavedRecords.push(
6197 + registry.dispatch(STORE_NAME).saveEditedEntityRecord(kind, name, key, {
6198 + throwOnError: true
6199 + }).catch(ensureError)
6200 + );
6201 + }
6202 + });
6203 + if (siteItemsToSave.length) {
6204 + pendingSavedRecords.push(
6205 + registry.dispatch(STORE_NAME).__experimentalSaveSpecifiedEntityEdits(
6206 + "root",
6207 + "site",
6208 + void 0,
6209 + siteItemsToSave,
6210 + {
6211 + throwOnError: true
6212 + }
6213 + ).catch(ensureError)
6214 + );
6215 + }
6216 + registry.dispatch(import_block_editor5.store).__unstableMarkLastChangeAsPersistent();
6217 + return Promise.all(pendingSavedRecords).then(async (values) => {
6218 + if (onSave) {
6219 + await onSave();
6220 + }
6221 + return values;
6222 + }).then((values) => {
6223 + const errors = values.filter((v) => v instanceof Error);
6224 + if (errors.length) {
6225 + const firstMessage = errors.find(
6226 + (e) => e.message
6227 + )?.message;
6228 + registry.dispatch(import_notices.store).createErrorNotice(
6229 + (0, import_html_entities.decodeEntities)(
6230 + firstMessage || (0, import_i18n2.__)("Saving failed.")
6231 + ),
6232 + {
6233 + type: "snackbar",
6234 + id: saveNoticeId
6235 + }
6236 + );
6237 + } else {
6238 + registry.dispatch(import_notices.store).createSuccessNotice(
6239 + successNoticeContent || (0, import_i18n2.__)("Site updated."),
6240 + {
6241 + type: "snackbar",
6242 + id: saveNoticeId,
6243 + actions: [
6244 + {
6245 + label: (0, import_i18n2.__)("View site"),
6246 + url: homeUrl,
6247 + openInNewTab: true
6248 + }
6249 + ]
6250 + }
6251 + );
6252 + }
6253 + }).catch(
6254 + (error) => registry.dispatch(import_notices.store).createErrorNotice(
6255 + (0, import_html_entities.decodeEntities)(
6256 + error?.message || (0, import_i18n2.__)("Saving failed.")
6257 + ),
6258 + {
6259 + type: "snackbar",
6260 + id: saveNoticeId
6261 + }
6262 + )
6263 + );
6264 + function ensureError(error) {
6265 + if (error instanceof Error) {
6266 + return error;
6267 + }
6268 + let message;
6269 + if (!error) {
6270 + } else if (typeof error.message === "string") {
6271 + message = error.message;
6272 + } else if (typeof error === "string") {
6273 + message = error;
6274 + } else if (
6275 + // Only consider own method, lest we erroneously end up calling
6276 + // `Object#toString` at the end of the prototype chain, thereby
6277 + // returning `"[object Object]"`.
6278 + Object.hasOwn(error, "toString") && typeof error.toString === "function"
6279 + ) {
6280 + const result = error.toString();
6281 + if (typeof result === "string") {
6282 + message = result;
6283 + }
6284 + }
6285 + return new Error(message, { cause: error });
6286 + }
6287 + };
5948 6288
5949 6289 // packages/core-data/build-module/resolvers.mjs
5950 6290 var resolvers_exports = {};
5951 6291 __export(resolvers_exports, {
@@ -5981,9 +6321,9 @@
5981 6321 getUserPatternCategories: () => getUserPatternCategories2,
5982 6322 getViewConfig: () => getViewConfig2
5983 6323 });
5984 6324 var import_url6 = __toESM(require_url(), 1);
5985 - var import_html_entities2 = __toESM(require_html_entities(), 1);
6325 + var import_html_entities3 = __toESM(require_html_entities(), 1);
5986 6326 var import_api_fetch9 = __toESM(require_api_fetch(), 1);
5987 6327
5988 6328 // packages/core-data/build-module/fetch/index.mjs
5989 6329 var import_api_fetch8 = __toESM(require_api_fetch(), 1);
@@ -5990,10 +6330,10 @@
5990 6330
5991 6331 // packages/core-data/build-module/fetch/__experimental-fetch-link-suggestions.mjs
5992 6332 var import_api_fetch6 = __toESM(require_api_fetch(), 1);
5993 6333 var import_url4 = __toESM(require_url(), 1);
5994 - var import_html_entities = __toESM(require_html_entities(), 1);
5995 - var import_i18n2 = __toESM(require_i18n(), 1);
6334 + var import_html_entities2 = __toESM(require_html_entities(), 1);
6335 + var import_i18n3 = __toESM(require_i18n(), 1);
5996 6336 async function fetchLinkSuggestions(search, searchOptions = {}, editorSettings2 = {}) {
5997 6337 const searchOptionsToUse = searchOptions.isInitialSuggestions && searchOptions.initialSuggestionsSearchOptions ? {
5998 6338 ...searchOptions,
5999 6339 ...searchOptions.initialSuggestionsSearchOptions
@@ -6020,9 +6360,9 @@
6020 6360 return results2.map((result) => {
6021 6361 return {
6022 6362 id: result.id,
6023 6363 url: result.url,
6024 - title: (0, import_html_entities.decodeEntities)(result.title || "") || (0, import_i18n2.__)("(no title)"),
6364 + title: (0, import_html_entities2.decodeEntities)(result.title || "") || (0, import_i18n3.__)("(no title)"),
6025 6365 type: result.subtype || result.type,
6026 6366 kind: "post-type"
6027 6367 };
6028 6368 });
@@ -6044,9 +6384,9 @@
6044 6384 return results2.map((result) => {
6045 6385 return {
6046 6386 id: result.id,
6047 6387 url: result.url,
6048 - title: (0, import_html_entities.decodeEntities)(result.title || "") || (0, import_i18n2.__)("(no title)"),
6388 + title: (0, import_html_entities2.decodeEntities)(result.title || "") || (0, import_i18n3.__)("(no title)"),
6049 6389 type: result.subtype || result.type,
6050 6390 kind: "taxonomy"
6051 6391 };
6052 6392 });
@@ -6068,9 +6408,9 @@
6068 6408 return results2.map((result) => {
6069 6409 return {
6070 6410 id: result.id,
6071 6411 url: result.url,
6072 - title: (0, import_html_entities.decodeEntities)(result.title || "") || (0, import_i18n2.__)("(no title)"),
6412 + title: (0, import_html_entities2.decodeEntities)(result.title || "") || (0, import_i18n3.__)("(no title)"),
6073 6413 type: result.subtype || result.type,
6074 6414 kind: "taxonomy"
6075 6415 };
6076 6416 });
@@ -6090,9 +6430,9 @@
6090 6430 return results2.map((result) => {
6091 6431 return {
6092 6432 id: result.id,
6093 6433 url: result.source_url,
6094 - title: (0, import_html_entities.decodeEntities)(result.title.rendered || "") || (0, import_i18n2.__)("(no title)"),
6434 + title: (0, import_html_entities2.decodeEntities)(result.title.rendered || "") || (0, import_i18n3.__)("(no title)"),
6095 6435 type: result.type,
6096 6436 kind: "media"
6097 6437 };
6098 6438 });
@@ -6108,8 +6448,9 @@
6108 6448 return results;
6109 6449 }
6110 6450 function sortResults(results, search) {
6111 6451 const searchTokens = tokenize(search);
6452 + const scoreKey = (result) => `${result.kind}:${result.type}:${result.id}`;
6112 6453 const scores = {};
6113 6454 for (const result of results) {
6114 6455 if (result.title) {
6115 6456 const titleTokens = tokenize(result.title);
@@ -6124,14 +6465,16 @@
6124 6465 )
6125 6466 );
6126 6467 const exactMatchScore = exactMatchingTokens.length / titleTokens.length * 10;
6127 6468 const subMatchScore = subMatchingTokens.length / titleTokens.length;
6128 - scores[result.id] = exactMatchScore + subMatchScore;
6469 + scores[scoreKey(result)] = exactMatchScore + subMatchScore;
6129 6470 } else {
6130 - scores[result.id] = 0;
6471 + scores[scoreKey(result)] = 0;
6131 6472 }
6132 6473 }
6133 - 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 + );
6134 6477 }
6135 6478 function tokenize(text) {
6136 6479 return text.toLowerCase().match(/[\p{L}\p{N}]+/gu) || [];
6137 6480 }
@@ -6185,12 +6528,32 @@
6185 6528 );
6186 6529 }
6187 6530
6188 6531 // packages/core-data/build-module/parsed-blocks-cache.mjs
6189 - 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();
6190 6535 function getCacheKey(kind, name, id) {
6191 6536 return `${kind}:${name}:${id}`;
6192 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 + }
6193 6556
6194 6557 // packages/core-data/build-module/resolvers.mjs
6195 6558 var getAuthors2 = (query) => async ({ dispatch: dispatch3 }) => {
6196 6559 const path = (0, import_url6.addQueryArgs)(
@@ -6203,9 +6566,9 @@
6203 6566 var getCurrentUser2 = () => async ({ dispatch: dispatch3 }) => {
6204 6567 const currentUser2 = await (0, import_api_fetch9.default)({ path: "/wp/v2/users/me" });
6205 6568 dispatch3.receiveCurrentUser(currentUser2);
6206 6569 };
6207 - 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 }) => {
6208 6571 const configs = await resolveSelect2.getEntitiesConfig(kind);
6209 6572 const entityConfig = configs.find(
6210 6573 (config) => config.name === name && config.kind === kind
6211 6574 );
@@ -6229,9 +6592,9 @@
6229 6592 ].join()
6230 6593 };
6231 6594 }
6232 6595 if (query !== void 0 && query._fields) {
6233 - const hasRecord = select4.hasEntityRecord(
6596 + const hasRecord = select5.hasEntityRecord(
6234 6597 kind,
6235 6598 name,
6236 6599 key,
6237 6600 query
@@ -6239,12 +6602,9 @@
6239 6602 if (hasRecord) {
6240 6603 return;
6241 6604 }
6242 6605 }
6243 - let { baseURL } = entityConfig;
6244 - if (kind === "postType" && name === "wp_template" && (key && typeof key === "string" && !/^\d+$/.test(key) || !window?.__experimentalTemplateActivate)) {
6245 - baseURL = baseURL.slice(0, baseURL.lastIndexOf("/")) + "/templates";
6246 - }
6606 + const { baseURL } = entityConfig;
6247 6607 const path = (0, import_url6.addQueryArgs)(baseURL + (key ? "/" + key : ""), {
6248 6608 ...entityConfig.baseURLParams,
6249 6609 ...query
6250 6610 });
@@ -6252,9 +6612,8 @@
6252 6612 const record = await response.json();
6253 6613 const permissions = getUserPermissionsFromAllowHeader(
6254 6614 response.headers?.get("allow")
6255 6615 );
6256 - const canUserResolutionsArgs = [];
6257 6616 const receiveUserPermissionArgs = {};
6258 6617 for (const action of ALLOWED_RESOURCE_ACTIONS) {
6259 6618 receiveUserPermissionArgs[getUserPermissionCacheKey(action, {
6260 6619 kind,
@@ -6260,13 +6619,10 @@
6260 6619 kind,
6261 6620 name,
6262 6621 id: key
6263 6622 })] = permissions[action];
6264 - canUserResolutionsArgs.push([
6265 - action,
6266 - { kind, name, id: key }
6267 - ]);
6268 6623 }
6624 + const canUserResolutionsArgs = [[{ kind, name, id: key }]];
6269 6625 if (entityConfig.syncConfig && isNumericID(key) && !query) {
6270 6626 const objectType = `${kind}/${name}`;
6271 6627 const objectId = key;
6272 6628 const recordWithTransients = { ...record };
@@ -6275,14 +6631,18 @@
6275 6631 ).forEach(([propName, transientConfig]) => {
6276 6632 recordWithTransients[propName] = transientConfig.read(recordWithTransients);
6277 6633 });
6278 6634 if (recordWithTransients.blocks && typeof recordWithTransients.content?.raw === "string") {
6279 - parsedBlocksCache.set(getCacheKey(kind, name, key), {
6280 - content: recordWithTransients.content.raw,
6281 - blocks: recordWithTransients.blocks
6282 - });
6635 + setCachedBlocks(
6636 + kind,
6637 + name,
6638 + key,
6639 + recordWithTransients.content.raw,
6640 + recordWithTransients.blocks
6641 + );
6283 6642 }
6284 - void getSyncManager()?.load(
6643 + const syncManager2 = select5?.isCollaborationSupported?.() === false ? void 0 : getSyncManager();
6644 + void syncManager2?.load(
6285 6645 entityConfig.syncConfig,
6286 6646 objectType,
6287 6647 objectId,
6288 6648 recordWithTransients,
@@ -6428,13 +6788,9 @@
6428 6788 ])
6429 6789 ].join()
6430 6790 };
6431 6791 }
6432 - let { baseURL } = entityConfig;
6433 - const { combinedTemplates = true } = query;
6434 - if (kind === "postType" && name === "wp_template" && combinedTemplates) {
6435 - baseURL = baseURL.slice(0, baseURL.lastIndexOf("/")) + "/templates";
6436 - }
6792 + const { baseURL } = entityConfig;
6437 6793 const path = (0, import_url6.addQueryArgs)(baseURL, {
6438 6794 ...entityConfig.baseURLParams,
6439 6795 ...query
6440 6796 });
@@ -6441,16 +6797,9 @@
6441 6797 let records = [], meta;
6442 6798 if (entityConfig.supportsPagination && query.per_page !== -1) {
6443 6799 const response = await (0, import_api_fetch9.default)({ path, parse: false });
6444 6800 records = Object.values(await response.json());
6445 - meta = {
6446 - totalItems: parseInt(
6447 - response.headers.get("X-WP-Total")
6448 - ),
6449 - totalPages: parseInt(
6450 - response.headers.get("X-WP-TotalPages")
6451 - )
6452 - };
6801 + meta = getPaginationMeta(response.headers);
6453 6802 } else if (query.per_page === -1 && query[RECEIVE_INTERMEDIATE_RESULTS] === true) {
6454 6803 let page = 1;
6455 6804 let totalPages;
6456 6805 do {
@@ -6458,16 +6807,13 @@
6458 6807 path: (0, import_url6.addQueryArgs)(path, { page, per_page: 100 }),
6459 6808 parse: false
6460 6809 });
6461 6810 const pageRecords = Object.values(await response.json());
6462 - totalPages = parseInt(
6463 - response.headers.get("X-WP-TotalPages")
6464 - );
6811 + const pageMeta = getPaginationMeta(response.headers);
6812 + totalPages = pageMeta.totalPages ?? 1;
6465 6813 if (!meta) {
6466 6814 meta = {
6467 - totalItems: parseInt(
6468 - response.headers.get("X-WP-Total")
6469 - ),
6815 + totalItems: pageMeta.totalItems,
6470 6816 totalPages: 1
6471 6817 };
6472 6818 }
6473 6819 records.push(...pageRecords);
@@ -6550,13 +6896,12 @@
6550 6896 }));
6551 6897 const canUserResolutionsArgs = [];
6552 6898 const receiveUserPermissionArgs = {};
6553 6899 for (const targetHint of targetHints) {
6900 + canUserResolutionsArgs.push([
6901 + { kind, name, id: targetHint.id }
6902 + ]);
6554 6903 for (const action of ALLOWED_RESOURCE_ACTIONS) {
6555 - canUserResolutionsArgs.push([
6556 - action,
6557 - { kind, name, id: targetHint.id }
6558 - ]);
6559 6904 receiveUserPermissionArgs[getUserPermissionCacheKey(action, {
6560 6905 kind,
6561 6906 name,
6562 6907 id: targetHint.id
@@ -6605,26 +6950,9 @@
6605 6950 } catch {
6606 6951 dispatch3.receiveEmbedPreview(url, false);
6607 6952 }
6608 6953 };
6609 - var canUser2 = (requestedAction, resource, id) => async ({ dispatch: dispatch3, registry, resolveSelect: resolveSelect2 }) => {
6610 - if (!ALLOWED_RESOURCE_ACTIONS.includes(requestedAction)) {
6611 - throw new Error(`'${requestedAction}' is not a valid action.`);
6612 - }
6613 - const { hasStartedResolution } = registry.select(STORE_NAME);
6614 - for (const relatedAction of ALLOWED_RESOURCE_ACTIONS) {
6615 - if (relatedAction === requestedAction) {
6616 - continue;
6617 - }
6618 - const isAlreadyResolving = hasStartedResolution("canUser", [
6619 - relatedAction,
6620 - resource,
6621 - id
6622 - ]);
6623 - if (isAlreadyResolving) {
6624 - return;
6625 - }
6626 - }
6954 + var canUser2 = (resource, id) => async ({ dispatch: dispatch3, resolveSelect: resolveSelect2 }) => {
6627 6955 let resourcePath = null;
6628 6956 if (typeof resource === "object") {
6629 6957 if (!resource.kind || !resource.name) {
6630 6958 throw new Error("The entity resource object is not valid.");
@@ -6655,22 +6983,16 @@
6655 6983 const permissions = getUserPermissionsFromAllowHeader(
6656 6984 response.headers?.get("allow")
6657 6985 );
6658 6986 const receiveUserPermissionArgs = {};
6659 - const canUserResolutionsArgs = [];
6660 6987 for (const action of ALLOWED_RESOURCE_ACTIONS) {
6661 6988 receiveUserPermissionArgs[getUserPermissionCacheKey(action, resource, id)] = permissions[action];
6662 - if (action !== requestedAction) {
6663 - canUserResolutionsArgs.push([action, resource, id]);
6664 - }
6665 6989 }
6666 - registry.batch(() => {
6667 - dispatch3.receiveUserPermissions(receiveUserPermissionArgs);
6668 - dispatch3.finishResolutions("canUser", canUserResolutionsArgs);
6669 - });
6990 + dispatch3.receiveUserPermissions(receiveUserPermissionArgs);
6670 6991 };
6671 - var canUserEditEntityRecord2 = (kind, name, recordId) => async ({ dispatch: dispatch3 }) => {
6672 - 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 });
6673 6995 };
6674 6996 var getAutosaves2 = (postType, postId) => async ({ dispatch: dispatch3, resolveSelect: resolveSelect2 }) => {
6675 6997 const {
6676 6998 rest_base: restBase,
@@ -6776,9 +7098,9 @@
6776 7098 }
6777 7099 );
6778 7100 const mappedPatternCategories = patternCategories?.map((userCategory) => ({
6779 7101 ...userCategory,
6780 - label: (0, import_html_entities2.decodeEntities)(userCategory.name),
7102 + label: (0, import_html_entities3.decodeEntities)(userCategory.name),
6781 7103 name: userCategory.slug
6782 7104 })) || [];
6783 7105 dispatch3({
6784 7106 type: "RECEIVE_USER_PATTERN_CATEGORIES",
@@ -6784,9 +7106,9 @@
6784 7106 type: "RECEIVE_USER_PATTERN_CATEGORIES",
6785 7107 patternCategories: mappedPatternCategories
6786 7108 });
6787 7109 };
6788 - var getNavigationFallbackId2 = () => async ({ dispatch: dispatch3, select: select4, registry }) => {
7110 + var getNavigationFallbackId2 = () => async ({ dispatch: dispatch3, select: select5, registry }) => {
6789 7111 const fallback = await (0, import_api_fetch9.default)({
6790 7112 path: (0, import_url6.addQueryArgs)("/wp-block-editor/v1/navigation-fallback", {
6791 7113 _embed: true
6792 7114 })
@@ -6796,9 +7118,9 @@
6796 7118 dispatch3.receiveNavigationFallbackId(fallback?.id);
6797 7119 if (!record) {
6798 7120 return;
6799 7121 }
6800 - const existingFallbackEntityRecord = select4.getEntityRecord(
7122 + const existingFallbackEntityRecord = select5.getEntityRecord(
6801 7123 "postType",
6802 7124 "wp_navigation",
6803 7125 fallback.id
6804 7126 );
@@ -6821,9 +7143,9 @@
6821 7143 const template = await (0, import_api_fetch9.default)({
6822 7144 path: (0, import_url6.addQueryArgs)("/wp/v2/templates/lookup", query)
6823 7145 });
6824 7146 await resolveSelect2.getEntitiesConfig("postType");
6825 - const id = window?.__experimentalTemplateActivate ? template?.wp_id || template?.id : template?.id;
7147 + const id = template?.id;
6826 7148 registry.batch(() => {
6827 7149 dispatch3.receiveDefaultTemplateId(query, id || "");
6828 7150 if (id) {
6829 7151 template.id = id;
@@ -6839,12 +7161,9 @@
6839 7161 ]);
6840 7162 }
6841 7163 });
6842 7164 };
6843 - getDefaultTemplateId2.shouldInvalidate = (action) => {
6844 - return action.type === "RECEIVE_ITEMS" && action.kind === "root" && action.name === "site" && !!action.persistedEdits;
6845 - };
6846 - var getRevisions2 = (kind, name, recordKey, query = {}) => async ({ dispatch: dispatch3, registry, resolveSelect: resolveSelect2 }) => {
7165 + var getRevisions2 = (kind, name, recordKey, query = {}) => async ({ dispatch: dispatch3, resolveSelect: resolveSelect2 }) => {
6847 7166 const configs = await resolveSelect2.getEntitiesConfig(kind);
6848 7167 const entityConfig = configs.find(
6849 7168 (config) => config.name === name && config.kind === kind
6850 7169 );
@@ -6883,11 +7202,11 @@
6883 7202 }
6884 7203 if (response) {
6885 7204 if (isPaginated) {
6886 7205 records = Object.values(await response.json());
6887 - meta.totalItems = parseInt(
6888 - response.headers.get("X-WP-Total")
6889 - );
7206 + meta.totalItems = getPaginationMeta(
7207 + response.headers
7208 + ).totalItems;
6890 7209 } else {
6891 7210 records = Object.values(response);
6892 7211 }
6893 7212 if (query._fields) {
@@ -6899,32 +7218,27 @@
6899 7218 });
6900 7219 return record;
6901 7220 });
6902 7221 }
6903 - registry.batch(() => {
6904 - dispatch3.receiveRevisions(
6905 - kind,
6906 - name,
6907 - recordKey,
6908 - records,
6909 - query,
6910 - false,
6911 - meta
6912 - );
6913 - const key = entityConfig.revisionKey || DEFAULT_ENTITY_KEY;
6914 - const normalizedQuery = normalizeQueryForResolution(rawQuery);
6915 - const resolutionsArgs = records.filter((record) => record[key]).map((record) => [
6916 - kind,
6917 - name,
6918 - recordKey,
6919 - record[key],
6920 - normalizedQuery
6921 - ]);
6922 - dispatch3.finishResolutions(
6923 - "getRevision",
6924 - resolutionsArgs
6925 - );
6926 - });
7222 + await dispatch3.receiveRevisions(
7223 + kind,
7224 + name,
7225 + recordKey,
7226 + records,
7227 + query,
7228 + false,
7229 + meta
7230 + );
7231 + const key = entityConfig.revisionKey || DEFAULT_ENTITY_KEY;
7232 + const normalizedQuery = normalizeQueryForResolution(rawQuery);
7233 + const resolutionsArgs = records.filter((record) => record[key]).map((record) => [
7234 + kind,
7235 + name,
7236 + recordKey,
7237 + record[key],
7238 + normalizedQuery
7239 + ]);
7240 + dispatch3.finishResolutions("getRevision", resolutionsArgs);
6927 7241 }
6928 7242 } finally {
6929 7243 dispatch3.__unstableReleaseStoreLock(lock2);
6930 7244 }
@@ -6929,9 +7243,9 @@
6929 7243 dispatch3.__unstableReleaseStoreLock(lock2);
6930 7244 }
6931 7245 };
6932 7246 getRevisions2.shouldInvalidate = (action, kind, name, recordKey) => action.type === "SAVE_ENTITY_RECORD_FINISH" && name === action.name && kind === action.kind && !action.error && recordKey === action.recordId;
6933 - 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 }) => {
6934 7248 const configs = await resolveSelect2.getEntitiesConfig(kind);
6935 7249 const entityConfig = configs.find(
6936 7250 (config) => config.name === name && config.kind === kind
6937 7251 );
@@ -6962,9 +7276,9 @@
6962 7276 ],
6963 7277 { exclusive: false }
6964 7278 );
6965 7279 try {
6966 - if (select4.hasRevision(kind, name, recordKey, revisionKey, query)) {
7280 + if (select5.hasRevision(kind, name, recordKey, revisionKey, query)) {
6967 7281 return;
6968 7282 }
6969 7283 const path = (0, import_url6.addQueryArgs)(
6970 7284 entityConfig.getRevisionsUrl(recordKey, revisionKey),
@@ -6976,9 +7290,9 @@
6976 7290 } catch {
6977 7291 return;
6978 7292 }
6979 7293 if (record) {
6980 - dispatch3.receiveRevisions(
7294 + await dispatch3.receiveRevisions(
6981 7295 kind,
6982 7296 name,
6983 7297 recordKey,
6984 7298 record,
@@ -7133,9 +7447,9 @@
7133 7447 const node = getNode(newTree, storePath);
7134 7448 node.locks = [...node.locks, lock2];
7135 7449 return {
7136 7450 ...state,
7137 - requests: state.requests.filter((r) => r !== request),
7451 + requests: state.requests.filter((r2) => r2 !== request),
7138 7452 tree: newTree
7139 7453 };
7140 7454 }
7141 7455 case "RELEASE_LOCK": {
@@ -7255,9 +7569,17 @@
7255 7569 ...parent?.[kind],
7256 7570 [name]: id
7257 7571 }
7258 7572 },
7259 - ...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 + }
7260 7582 }),
7261 7583 [parent, kind, name, id, revisionId]
7262 7584 );
7263 7585 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(EntityContext.Provider, { value: childContext, children });
@@ -7263,9 +7585,9 @@
7263 7585 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(EntityContext.Provider, { value: childContext, children });
7264 7586 }
7265 7587
7266 7588 // packages/core-data/build-module/hooks/use-entity-record.mjs
7267 - var import_data10 = __toESM(require_data(), 1);
7589 + var import_data11 = __toESM(require_data(), 1);
7268 7590 var import_deprecated4 = __toESM(require_deprecated(), 1);
7269 7591 var import_element3 = __toESM(require_element(), 1);
7270 7592
7271 7593 // packages/core-data/build-module/hooks/constants.mjs
@@ -7303,9 +7625,9 @@
7303 7625
7304 7626 // packages/core-data/build-module/hooks/use-entity-record.mjs
7305 7627 var EMPTY_OBJECT3 = {};
7306 7628 function useEntityRecord(kind, name, recordId, options = { enabled: true }) {
7307 - const { editEntityRecord: editEntityRecord2, saveEditedEntityRecord: saveEditedEntityRecord2 } = (0, import_data10.useDispatch)(store);
7629 + const { editEntityRecord: editEntityRecord2, saveEditedEntityRecord: saveEditedEntityRecord2 } = (0, import_data11.useDispatch)(store);
7308 7630 const mutations = (0, import_element3.useMemo)(
7309 7631 () => ({
7310 7632 edit: (record2, editOptions = {}) => editEntityRecord2(kind, name, recordId, record2, editOptions),
7311 7633 save: (saveOptions = {}) => saveEditedEntityRecord2(kind, name, recordId, {
@@ -7314,10 +7636,10 @@
7314 7636 })
7315 7637 }),
7316 7638 [editEntityRecord2, kind, name, recordId, saveEditedEntityRecord2]
7317 7639 );
7318 - const { record, editedRecord, hasEdits, edits, ...resolution } = (0, import_data10.useSelect)(
7319 - (select4) => {
7640 + const { record, editedRecord, hasEdits, edits, ...resolution } = (0, import_data11.useSelect)(
7641 + (select5) => {
7320 7642 if (!options.enabled) {
7321 7643 return {
7322 7644 record: null,
7323 7645 editedRecord: EMPTY_OBJECT3,
@@ -7325,9 +7647,9 @@
7325 7647 edits: EMPTY_OBJECT3,
7326 7648 ...getResolutionStatus()
7327 7649 };
7328 7650 }
7329 - const storeSelectors = select4(store);
7651 + const storeSelectors = select5(store);
7330 7652 const resolutionStatus = storeSelectors.getResolutionState(
7331 7653 "getEntityRecord",
7332 7654 [kind, name, recordId]
7333 7655 )?.status;
@@ -7376,15 +7698,15 @@
7376 7698
7377 7699 // packages/core-data/build-module/hooks/use-entity-records.mjs
7378 7700 var import_url7 = __toESM(require_url(), 1);
7379 7701 var import_deprecated5 = __toESM(require_deprecated(), 1);
7380 - var import_data11 = __toESM(require_data(), 1);
7702 + var import_data12 = __toESM(require_data(), 1);
7381 7703 var import_element4 = __toESM(require_element(), 1);
7382 7704 var EMPTY_ARRAY = [];
7383 7705 function useEntityRecords(kind, name, queryArgs = {}, options = { enabled: true }) {
7384 7706 const queryAsString = (0, import_url7.addQueryArgs)("", queryArgs);
7385 - const { records, totalItems, totalPages, ...rest } = (0, import_data11.useSelect)(
7386 - (select4) => {
7707 + const { records, totalItems, totalPages, ...rest } = (0, import_data12.useSelect)(
7708 + (select5) => {
7387 7709 if (!options.enabled) {
7388 7710 return {
7389 7711 // Avoiding returning a new reference on every execution.
7390 7712 records: EMPTY_ARRAY,
@@ -7392,9 +7714,9 @@
7392 7714 totalPages: null,
7393 7715 ...getResolutionStatus()
7394 7716 };
7395 7717 }
7396 - const storeSelectors = select4(store);
7718 + const storeSelectors = select5(store);
7397 7719 const resolutionStatus = storeSelectors.getResolutionState(
7398 7720 "getEntityRecords",
7399 7721 [kind, name, queryArgs]
7400 7722 )?.status;
@@ -7433,10 +7755,10 @@
7433 7755 });
7434 7756 return useEntityRecords(kind, name, queryArgs, options);
7435 7757 }
7436 7758 function useEntityRecordsWithPermissions(kind, name, queryArgs = {}, options = { enabled: true }) {
7437 - const entityConfig = (0, import_data11.useSelect)(
7438 - (select4) => select4(store).getEntityConfig(kind, name),
7759 + const entityConfig = (0, import_data12.useSelect)(
7760 + (select5) => select5(store).getEntityConfig(kind, name),
7439 7761 [kind, name]
7440 7762 );
7441 7763 const { records: data, ...ret } = useEntityRecords(
7442 7764 kind,
@@ -7458,17 +7780,17 @@
7458 7780 options
7459 7781 );
7460 7782 const ids = (0, import_element4.useMemo)(
7461 7783 () => data?.map(
7462 - // @ts-ignore
7784 + // @ts-expect-error `data` is `unknown[]`, so the callback signature does not line up.
7463 7785 (record) => record[entityConfig?.key ?? "id"]
7464 7786 ) ?? [],
7465 7787 [data, entityConfig?.key]
7466 7788 );
7467 - const permissions = (0, import_data11.useSelect)(
7468 - (select4) => {
7789 + const permissions = (0, import_data12.useSelect)(
7790 + (select5) => {
7469 7791 const { getEntityRecordsPermissions: getEntityRecordsPermissions2 } = unlock(
7470 - select4(store)
7792 + select5(store)
7471 7793 );
7472 7794 return getEntityRecordsPermissions2(kind, name, ids);
7473 7795 },
7474 7796 [ids, kind, name]
@@ -7474,9 +7796,9 @@
7474 7796 [ids, kind, name]
7475 7797 );
7476 7798 const dataWithPermissions = (0, import_element4.useMemo)(
7477 7799 () => data?.map((record, index) => ({
7478 - // @ts-ignore
7800 + // @ts-expect-error `record` is `unknown`, which cannot be spread.
7479 7801 ...record,
7480 7802 permissions: permissions[index]
7481 7803 })) ?? [],
7482 7804 [data, permissions]
@@ -7488,9 +7810,9 @@
7488 7810 var import_deprecated6 = __toESM(require_deprecated(), 1);
7489 7811 var import_warning = __toESM(require_warning(), 1);
7490 7812
7491 7813 // packages/core-data/build-module/hooks/use-query-select.mjs
7492 - var import_data12 = __toESM(require_data(), 1);
7814 + var import_data13 = __toESM(require_data(), 1);
7493 7815
7494 7816 // node_modules/memize/dist/index.js
7495 7817 function memize(fn, options) {
7496 7818 var size = 0;
@@ -7567,10 +7889,10 @@
7567 7889 "isResolving",
7568 7890 "getCachedResolvers"
7569 7891 ];
7570 7892 function useQuerySelect(mapQuerySelect, deps) {
7571 - return (0, import_data12.useSelect)((select4, registry) => {
7572 - const resolve = (store2) => enrichSelectors(select4(store2));
7893 + return (0, import_data13.useSelect)((select5, registry) => {
7894 + const resolve = (store2) => enrichSelectors(select5(store2));
7573 7895 return mapQuerySelect(resolve, registry);
7574 7896 }, deps);
7575 7897 }
7576 7898 var enrichSelectors = memize(((selectors) => {
@@ -7663,10 +7985,10 @@
7663 7985 }
7664 7986
7665 7987 // packages/core-data/build-module/hooks/use-entity-block-editor.mjs
7666 7988 var import_element6 = __toESM(require_element(), 1);
7667 - var import_data13 = __toESM(require_data(), 1);
7668 - var import_blocks5 = __toESM(require_blocks(), 1);
7989 + var import_data14 = __toESM(require_data(), 1);
7990 + var import_blocks6 = __toESM(require_blocks(), 1);
7669 7991
7670 7992 // packages/core-data/build-module/hooks/use-entity-id.mjs
7671 7993 var import_element5 = __toESM(require_element(), 1);
7672 7994 function useEntityId(kind, name) {
@@ -7675,16 +7997,17 @@
7675 7997 }
7676 7998
7677 7999 // packages/core-data/build-module/footnotes/index.mjs
7678 8000 var import_rich_text4 = __toESM(require_rich_text(), 1);
8001 + var import_warning2 = __toESM(require_warning(), 1);
7679 8002
7680 8003 // packages/core-data/build-module/footnotes/get-rich-text-values-cached.mjs
7681 - var import_block_editor5 = __toESM(require_block_editor(), 1);
8004 + var import_block_editor6 = __toESM(require_block_editor(), 1);
7682 8005 var unlockedApis;
7683 8006 var cache = /* @__PURE__ */ new WeakMap();
7684 8007 function getRichTextValuesCached(block) {
7685 8008 if (!unlockedApis) {
7686 - unlockedApis = unlock(import_block_editor5.privateApis);
8009 + unlockedApis = unlock(import_block_editor6.privateApis);
7687 8010 }
7688 8011 if (!cache.has(block)) {
7689 8012 const values = unlockedApis.getRichTextValues([block]);
7690 8013 cache.set(block, values);
@@ -7725,9 +8048,19 @@
7725 8048 if (meta.footnotes === void 0) {
7726 8049 return output;
7727 8050 }
7728 8051 const newOrder = getFootnotesOrder(blocks);
7729 - const footnotes = meta.footnotes ? JSON.parse(meta.footnotes) : [];
8052 + let parsed;
8053 + try {
8054 + parsed = JSON.parse(meta.footnotes || "[]");
8055 + } catch {
8056 + }
8057 + let footnotes = [];
8058 + if (Array.isArray(parsed)) {
8059 + footnotes = parsed;
8060 + } else {
8061 + (0, import_warning2.default)("Footnotes post meta is not a JSON array; ignoring it.");
8062 + }
7730 8063 const currentOrder = footnotes.map((fn) => fn.id);
7731 8064 if (currentOrder.join("") === newOrder.join("")) {
7732 8065 return output;
7733 8066 }
@@ -7813,14 +8146,14 @@
7813 8146 var EMPTY_ARRAY2 = [];
7814 8147 function useEntityBlockEditor(kind, name, { id: _id } = {}) {
7815 8148 const providerId = useEntityId(kind, name);
7816 8149 const id = _id ?? providerId;
7817 - const { content, editedBlocks, meta } = (0, import_data13.useSelect)(
7818 - (select4) => {
8150 + const { content, editedBlocks, meta } = (0, import_data14.useSelect)(
8151 + (select5) => {
7819 8152 if (!id) {
7820 8153 return {};
7821 8154 }
7822 - const { getEditedEntityRecord: getEditedEntityRecord3 } = select4(STORE_NAME);
8155 + const { getEditedEntityRecord: getEditedEntityRecord3 } = select5(STORE_NAME);
7823 8156 const editedRecord = getEditedEntityRecord3(kind, name, id);
7824 8157 return {
7825 8158 editedBlocks: editedRecord.blocks,
7826 8159 content: editedRecord.content,
@@ -7828,9 +8161,9 @@
7828 8161 };
7829 8162 },
7830 8163 [kind, name, id]
7831 8164 );
7832 - const { __unstableCreateUndoLevel: __unstableCreateUndoLevel2, editEntityRecord: editEntityRecord2 } = (0, import_data13.useDispatch)(STORE_NAME);
8165 + const { __unstableCreateUndoLevel: __unstableCreateUndoLevel2, editEntityRecord: editEntityRecord2 } = (0, import_data14.useDispatch)(STORE_NAME);
7833 8166 const blocks = (0, import_element6.useMemo)(() => {
7834 8167 if (!id) {
7835 8168 return void 0;
7836 8169 }
@@ -7839,16 +8172,12 @@
7839 8172 }
7840 8173 if (!content || typeof content !== "string") {
7841 8174 return EMPTY_ARRAY2;
7842 8175 }
7843 - const cacheKey = getCacheKey(kind, name, id);
7844 - const cached = parsedBlocksCache.get(cacheKey);
7845 - let _blocks;
7846 - if (cached && cached.content === content) {
7847 - _blocks = cached.blocks;
7848 - } else {
7849 - _blocks = (0, import_blocks5.parse)(content);
7850 - 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);
7851 8180 }
7852 8181 return _blocks;
7853 8182 }, [kind, name, id, editedBlocks, content]);
7854 8183 const onChange = (0, import_element6.useCallback)(
@@ -7859,9 +8188,9 @@
7859 8188 }
7860 8189 const { selection, ...rest } = options;
7861 8190 const edits = {
7862 8191 selection,
7863 - content: ({ blocks: blocksForSerialization = [] }) => (0, import_blocks5.__unstableSerializeAndClean)(blocksForSerialization),
8192 + content: ({ blocks: blocksForSerialization = [] }) => (0, import_blocks6.__unstableSerializeAndClean)(blocksForSerialization),
7864 8193 ...updateFootnotesFromMeta(newBlocks, meta)
7865 8194 };
7866 8195 editEntityRecord2(kind, name, id, edits, {
7867 8196 isCached: false,
@@ -7896,41 +8225,39 @@
7896 8225 }
7897 8226
7898 8227 // packages/core-data/build-module/hooks/use-entity-prop.mjs
7899 8228 var import_element7 = __toESM(require_element(), 1);
7900 - 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 + };
7901 8234 function useEntityProp(kind, name, prop, _id) {
7902 8235 const providerId = useEntityId(kind, name);
7903 8236 const id = _id ?? providerId;
7904 8237 const context = (0, import_element7.useContext)(EntityContext);
7905 - const revisionId = context?.revisionId;
7906 - const { value, fullValue } = (0, import_data14.useSelect)(
7907 - (select4) => {
8238 + const revisionId = String(id) === String(providerId) ? context?.revision?.[kind]?.[name] : void 0;
8239 + const { value, fullValue } = (0, import_data15.useSelect)(
8240 + (select5) => {
7908 8241 if (revisionId) {
7909 - const revisions = select4(STORE_NAME).getRevisions(
8242 + const revision = select5(STORE_NAME).getRevision(
7910 8243 kind,
7911 8244 name,
7912 8245 id,
7913 - {
7914 - per_page: -1,
7915 - context: "edit",
7916 - _fields: "id,date,author,meta,title.raw,excerpt.raw,content.raw"
7917 - }
8246 + revisionId,
8247 + REVISION_QUERY
7918 8248 );
7919 - const entityConfig = select4(STORE_NAME).getEntityConfig(
7920 - kind,
7921 - name
7922 - );
7923 - const revKey = entityConfig?.revisionKey || DEFAULT_ENTITY_KEY;
7924 - const revision = revisions?.find(
7925 - (r) => r[revKey] === revisionId
7926 - );
7927 - return revision ? {
7928 - value: revision[prop]?.raw ?? revision[prop],
7929 - fullValue: revision[prop]
7930 - } : {};
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 + };
7931 8258 }
7932 - const { getEntityRecord: getEntityRecord3, getEditedEntityRecord: getEditedEntityRecord3 } = select4(STORE_NAME);
8259 + const { getEntityRecord: getEntityRecord3, getEditedEntityRecord: getEditedEntityRecord3 } = select5(STORE_NAME);
7933 8260 const record = getEntityRecord3(kind, name, id);
7934 8261 const editedRecord = getEditedEntityRecord3(kind, name, id);
7935 8262 return record && editedRecord ? {
7936 8263 value: editedRecord[prop],
@@ -7938,9 +8265,9 @@
7938 8265 } : {};
7939 8266 },
7940 8267 [kind, name, id, prop, revisionId]
7941 8268 );
7942 - const { editEntityRecord: editEntityRecord2 } = (0, import_data14.useDispatch)(STORE_NAME);
8269 + const { editEntityRecord: editEntityRecord2 } = (0, import_data15.useDispatch)(STORE_NAME);
7943 8270 const setValue = (0, import_element7.useCallback)(
7944 8271 (newValue) => {
7945 8272 if (revisionId) {
7946 8273 return;
@@ -7972,9 +8299,11 @@
7972 8299 }),
7973 8300 isCurrentCollaboratorDisconnected: false
7974 8301 };
7975 8302 function getAwarenessState(awareness, newState) {
7976 - const activeCollaborators = newState ?? awareness.getCurrentState();
8303 + const activeCollaborators = (newState ?? awareness.getCurrentState()).filter(
8304 + (collaborator) => isCollaboratorInfo(collaborator.collaboratorInfo)
8305 + );
7977 8306 return {
7978 8307 activeCollaborators,
7979 8308 resolveSelection: (selection, blocks) => awareness.convertSelectionStateToAbsolute(selection, blocks),
7980 8309 getDebugData: () => awareness.getDebugData(),
@@ -8132,12 +8461,700 @@
8132 8461 callback(lastPostSave, saver, prevPostSave ?? null);
8133 8462 }, [lastPostSave, prevPostSave, activeCollaborators, callback]);
8134 8463 }
8135 8464
8465 + // packages/icons/build-module/library/footer.mjs
8466 + var import_primitives = __toESM(require_primitives(), 1);
8467 + var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
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 + ] });
8472 +
8473 + // packages/icons/build-module/library/header.mjs
8474 + var import_primitives2 = __toESM(require_primitives(), 1);
8475 + var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
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 + ] });
8480 +
8481 + // packages/icons/build-module/library/layout.mjs
8482 + var import_primitives3 = __toESM(require_primitives(), 1);
8483 + var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
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" }) });
8485 +
8486 + // packages/icons/build-module/library/navigation-overlay.mjs
8487 + var import_primitives4 = __toESM(require_primitives(), 1);
8488 + var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1);
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 + ] });
8493 +
8494 + // packages/icons/build-module/library/sidebar.mjs
8495 + var import_primitives5 = __toESM(require_primitives(), 1);
8496 + var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1);
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 + ] });
8501 +
8502 + // packages/icons/build-module/library/symbol-filled.mjs
8503 + var import_primitives6 = __toESM(require_primitives(), 1);
8504 + var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1);
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 + ] });
8509 +
8510 + // packages/core-data/build-module/utils/get-template-part-icon.mjs
8511 + function getTemplatePartIcon(areaOrIconName) {
8512 + if ("header" === areaOrIconName) {
8513 + return header_default;
8514 + } else if ("footer" === areaOrIconName) {
8515 + return footer_default;
8516 + } else if ("sidebar" === areaOrIconName) {
8517 + return sidebar_default;
8518 + } else if ("navigation-overlay" === areaOrIconName) {
8519 + return navigation_overlay_default;
8520 + }
8521 + return symbol_filled_default;
8522 + }
8523 +
8524 + // packages/core-data/build-module/utils/get-template-info.mjs
8525 + var EMPTY_OBJECT4 = {};
8526 + var getTemplateInfo = (params) => {
8527 + if (!params) {
8528 + return EMPTY_OBJECT4;
8529 + }
8530 + const { templateTypes, templateAreas, template } = params;
8531 + const { description, slug, title, area } = template;
8532 + const { title: defaultTitle, description: defaultDescription } = Object.values(templateTypes).find((type) => type.slug === slug) ?? EMPTY_OBJECT4;
8533 + const templateTitle = typeof title === "string" ? title : title?.rendered;
8534 + const templateDescription = typeof description === "string" ? description : description?.raw;
8535 + const templateAreasWithIcon = templateAreas?.map((item) => ({
8536 + ...item,
8537 + icon: getTemplatePartIcon(item.icon)
8538 + }));
8539 + const templateIcon = templateAreasWithIcon?.find((item) => area === item.area)?.icon || layout_default;
8540 + return {
8541 + title: templateTitle && templateTitle !== slug ? templateTitle : defaultTitle || slug,
8542 + description: templateDescription || defaultDescription,
8543 + icon: templateIcon
8544 + };
8545 + };
8546 +
8547 + // node_modules/clsx/dist/clsx.mjs
8548 + function r(e) {
8549 + var t, f, n = "";
8550 + if ("string" == typeof e || "number" == typeof e) n += e;
8551 + else if ("object" == typeof e) if (Array.isArray(e)) {
8552 + var o = e.length;
8553 + for (t = 0; t < o; t++) e[t] && (f = r(e[t])) && (n && (n += " "), n += f);
8554 + } else for (f in e) e[f] && (n && (n += " "), n += f);
8555 + return n;
8556 + }
8557 + function clsx() {
8558 + for (var e, t, f = 0, n = "", o = arguments.length; f < o; f++) (e = arguments[f]) && (t = r(e)) && (n && (n += " "), n += t);
8559 + return n;
8560 + }
8561 + var clsx_default = clsx;
8562 +
8563 + // packages/core-data/build-module/components/entities-saved-states/index.mjs
8564 + var import_components3 = __toESM(require_components(), 1);
8565 + var import_i18n7 = __toESM(require_i18n(), 1);
8566 + var import_element10 = __toESM(require_element(), 1);
8567 + var import_compose4 = __toESM(require_compose(), 1);
8568 + var import_data19 = __toESM(require_data(), 1);
8569 +
8570 + // packages/core-data/build-module/components/entities-saved-states/entity-type-list.mjs
8571 + var import_i18n6 = __toESM(require_i18n(), 1);
8572 + var import_data17 = __toESM(require_data(), 1);
8573 + var import_components2 = __toESM(require_components(), 1);
8574 +
8575 + // packages/global-styles-engine/build-module/utils/get-global-styles-changes.mjs
8576 + var import_i18n4 = __toESM(require_i18n(), 1);
8577 + var import_blocks7 = __toESM(require_blocks(), 1);
8578 + var globalStylesChangesCache = /* @__PURE__ */ new Map();
8579 + var EMPTY_ARRAY3 = [];
8580 + var translationMap = {
8581 + caption: (0, import_i18n4.__)("Caption"),
8582 + link: (0, import_i18n4.__)("Link"),
8583 + button: (0, import_i18n4.__)("Button"),
8584 + heading: (0, import_i18n4.__)("Heading"),
8585 + h1: (0, import_i18n4.__)("H1"),
8586 + h2: (0, import_i18n4.__)("H2"),
8587 + h3: (0, import_i18n4.__)("H3"),
8588 + h4: (0, import_i18n4.__)("H4"),
8589 + h5: (0, import_i18n4.__)("H5"),
8590 + h6: (0, import_i18n4.__)("H6"),
8591 + "settings.color": (0, import_i18n4.__)("Color"),
8592 + "settings.typography": (0, import_i18n4.__)("Typography"),
8593 + "settings.shadow": (0, import_i18n4.__)("Shadow"),
8594 + "settings.layout": (0, import_i18n4.__)("Layout"),
8595 + "styles.color": (0, import_i18n4.__)("Colors"),
8596 + "styles.spacing": (0, import_i18n4.__)("Spacing"),
8597 + "styles.background": (0, import_i18n4.__)("Background"),
8598 + "styles.typography": (0, import_i18n4.__)("Typography"),
8599 + "styles.border": (0, import_i18n4.__)("Border"),
8600 + "styles.shadow": (0, import_i18n4.__)("Shadow"),
8601 + "styles.outline": (0, import_i18n4.__)("Outline"),
8602 + "styles.filter": (0, import_i18n4.__)("Filter"),
8603 + "styles.dimensions": (0, import_i18n4.__)("Dimensions")
8604 + };
8605 + var getBlockNames = memize(
8606 + () => (0, import_blocks7.getBlockTypes)().reduce(
8607 + (accumulator, {
8608 + name,
8609 + title
8610 + }) => {
8611 + accumulator[name] = title;
8612 + return accumulator;
8613 + },
8614 + {}
8615 + )
8616 + );
8617 + var isObject = (obj) => obj !== null && typeof obj === "object";
8618 + function getTranslation(key) {
8619 + if (translationMap[key]) {
8620 + return translationMap[key];
8621 + }
8622 + const keyArray = key.split(".");
8623 + if (keyArray?.[0] === "blocks") {
8624 + const blockName = getBlockNames()?.[keyArray[1]];
8625 + return blockName || keyArray[1];
8626 + }
8627 + if (keyArray?.[0] === "elements") {
8628 + return translationMap[keyArray[1]] || keyArray[1];
8629 + }
8630 + return void 0;
8631 + }
8632 + function deepCompare(changedObject, originalObject, parentPath = "") {
8633 + if (!isObject(changedObject) && !isObject(originalObject)) {
8634 + return changedObject !== originalObject ? parentPath.split(".").slice(0, 2).join(".") : void 0;
8635 + }
8636 + changedObject = isObject(changedObject) ? changedObject : {};
8637 + originalObject = isObject(originalObject) ? originalObject : {};
8638 + const allKeys = /* @__PURE__ */ new Set([
8639 + ...Object.keys(changedObject),
8640 + ...Object.keys(originalObject)
8641 + ]);
8642 + let diffs = [];
8643 + for (const key of allKeys) {
8644 + const path = parentPath ? parentPath + "." + key : key;
8645 + const changedPath = deepCompare(
8646 + changedObject[key],
8647 + originalObject[key],
8648 + path
8649 + );
8650 + if (changedPath) {
8651 + diffs = diffs.concat(changedPath);
8652 + }
8653 + }
8654 + return diffs;
8655 + }
8656 + var COMPARED_STYLE_KEYS = [
8657 + "background",
8658 + "color",
8659 + "typography",
8660 + "spacing",
8661 + "border",
8662 + "shadow",
8663 + "outline",
8664 + "filter",
8665 + "dimensions"
8666 + ];
8667 + function pickComparedStyles(config) {
8668 + return Object.fromEntries(
8669 + COMPARED_STYLE_KEYS.map((key) => [key, config?.styles?.[key]])
8670 + );
8671 + }
8672 + function getGlobalStylesChangelist(next, previous) {
8673 + const cacheKey = JSON.stringify({ next, previous });
8674 + if (globalStylesChangesCache.has(cacheKey)) {
8675 + return globalStylesChangesCache.get(cacheKey);
8676 + }
8677 + const changedValueTree = deepCompare(
8678 + {
8679 + styles: pickComparedStyles(next),
8680 + blocks: next?.styles?.blocks,
8681 + elements: next?.styles?.elements,
8682 + settings: next?.settings
8683 + },
8684 + {
8685 + styles: pickComparedStyles(previous),
8686 + blocks: previous?.styles?.blocks,
8687 + elements: previous?.styles?.elements,
8688 + settings: previous?.settings
8689 + }
8690 + );
8691 + if (!changedValueTree || Array.isArray(changedValueTree) && !changedValueTree.length) {
8692 + globalStylesChangesCache.set(cacheKey, []);
8693 + return [];
8694 + }
8695 + const changedValueArray = Array.isArray(changedValueTree) ? changedValueTree : [changedValueTree];
8696 + const result = [...new Set(changedValueArray)].reduce((acc, curr) => {
8697 + const translation = getTranslation(curr);
8698 + if (translation) {
8699 + acc.push([curr.split(".")[0], translation]);
8700 + }
8701 + return acc;
8702 + }, []);
8703 + globalStylesChangesCache.set(cacheKey, result);
8704 + return result;
8705 + }
8706 + function getGlobalStylesChanges(next, previous, options = {}) {
8707 + let changeList = getGlobalStylesChangelist(next, previous);
8708 + const changesLength = changeList.length;
8709 + const { maxResults } = options;
8710 + if (changesLength) {
8711 + if (!!maxResults && changesLength > maxResults) {
8712 + changeList = changeList.slice(0, maxResults);
8713 + }
8714 + return Object.entries(
8715 + changeList.reduce((acc, curr) => {
8716 + const group = acc[curr[0]] || [];
8717 + if (!group.includes(curr[1])) {
8718 + acc[curr[0]] = [...group, curr[1]];
8719 + }
8720 + return acc;
8721 + }, {})
8722 + ).map(([key, changeValues]) => {
8723 + const changeValuesLength = changeValues.length;
8724 + const joinedChangesValue = changeValues.join(
8725 + /* translators: Used between list items, there is a space after the comma. */
8726 + (0, import_i18n4.__)(", ")
8727 + // eslint-disable-line @wordpress/i18n-no-flanking-whitespace
8728 + );
8729 + switch (key) {
8730 + case "blocks": {
8731 + return (0, import_i18n4.sprintf)(
8732 + // translators: %s: a list of block names separated by a comma.
8733 + (0, import_i18n4._n)("%s block.", "%s blocks.", changeValuesLength),
8734 + joinedChangesValue
8735 + );
8736 + }
8737 + case "elements": {
8738 + return (0, import_i18n4.sprintf)(
8739 + // translators: %s: a list of element names separated by a comma.
8740 + (0, import_i18n4._n)("%s element.", "%s elements.", changeValuesLength),
8741 + joinedChangesValue
8742 + );
8743 + }
8744 + case "settings": {
8745 + return (0, import_i18n4.sprintf)(
8746 + // translators: %s: a list of theme.json setting labels separated by a comma.
8747 + (0, import_i18n4.__)("%s settings."),
8748 + joinedChangesValue
8749 + );
8750 + }
8751 + case "styles": {
8752 + return (0, import_i18n4.sprintf)(
8753 + // translators: %s: a list of theme.json top-level styles labels separated by a comma.
8754 + (0, import_i18n4.__)("%s styles."),
8755 + joinedChangesValue
8756 + );
8757 + }
8758 + default: {
8759 + return (0, import_i18n4.sprintf)(
8760 + // translators: %s: a list of global styles changes separated by a comma.
8761 + (0, import_i18n4.__)("%s."),
8762 + joinedChangesValue
8763 + );
8764 + }
8765 + }
8766 + });
8767 + }
8768 + return EMPTY_ARRAY3;
8769 + }
8770 +
8771 + // packages/core-data/build-module/components/entities-saved-states/entity-record-item.mjs
8772 + var import_components = __toESM(require_components(), 1);
8773 + var import_i18n5 = __toESM(require_i18n(), 1);
8774 + var import_data16 = __toESM(require_data(), 1);
8775 + var import_html_entities4 = __toESM(require_html_entities(), 1);
8776 + var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1);
8777 + function EntityRecordItem({ record, checked, onChange }) {
8778 + const { name, kind, title, key } = record;
8779 + const { entityRecordTitle } = (0, import_data16.useSelect)(
8780 + (select5) => {
8781 + if ("postType" !== kind || "wp_template" !== name) {
8782 + return {
8783 + entityRecordTitle: title
8784 + };
8785 + }
8786 + const template = select5(STORE_NAME).getEditedEntityRecord(
8787 + kind,
8788 + name,
8789 + key
8790 + );
8791 + const { default_template_types: templateTypes = [] } = select5(STORE_NAME).getCurrentTheme() ?? {};
8792 + return {
8793 + entityRecordTitle: getTemplateInfo({
8794 + template,
8795 + templateTypes
8796 + }).title
8797 + };
8798 + },
8799 + [name, kind, title, key]
8800 + );
8801 + return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_jsx_runtime8.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_components.PanelRow, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
8802 + import_components.CheckboxControl,
8803 + {
8804 + label: (0, import_html_entities4.decodeEntities)(entityRecordTitle) || (0, import_i18n5.__)("Untitled"),
8805 + checked,
8806 + onChange,
8807 + className: "entities-saved-states__change-control"
8808 + }
8809 + ) }) });
8810 + }
8811 +
8812 + // packages/core-data/build-module/components/entities-saved-states/entity-type-list.mjs
8813 + var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1);
8814 + function getEntityDescription(entity2, count) {
8815 + switch (entity2) {
8816 + case "site":
8817 + return 1 === count ? (0, import_i18n6.__)("This change will affect your whole site.") : (0, import_i18n6.__)("These changes will affect your whole site.");
8818 + case "wp_template":
8819 + return (0, import_i18n6.__)(
8820 + "This change will affect other parts of your site that use this template."
8821 + );
8822 + case "page":
8823 + case "post":
8824 + return (0, import_i18n6.__)("The following has been modified.");
8825 + }
8826 + }
8827 + function GlobalStylesDescription({ record }) {
8828 + const { editedRecord, savedRecord } = (0, import_data17.useSelect)(
8829 + (select5) => {
8830 + const { getEditedEntityRecord: getEditedEntityRecord3, getEntityRecord: getEntityRecord3 } = select5(STORE_NAME);
8831 + return {
8832 + editedRecord: getEditedEntityRecord3(
8833 + record.kind,
8834 + record.name,
8835 + record.key
8836 + ),
8837 + savedRecord: getEntityRecord3(
8838 + record.kind,
8839 + record.name,
8840 + record.key
8841 + )
8842 + };
8843 + },
8844 + [record.kind, record.name, record.key]
8845 + );
8846 + const globalStylesChanges = getGlobalStylesChanges(
8847 + editedRecord,
8848 + savedRecord,
8849 + {
8850 + maxResults: 10
8851 + }
8852 + );
8853 + return globalStylesChanges.length ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("ul", { className: "entities-saved-states__changes", children: globalStylesChanges.map((change) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("li", { children: change }, change)) }) : null;
8854 + }
8855 + function EntityDescription({ record, count }) {
8856 + if ("globalStyles" === record?.name) {
8857 + return null;
8858 + }
8859 + const description = getEntityDescription(record?.name, count);
8860 + return description ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_components2.PanelRow, { children: description }) : null;
8861 + }
8862 + function EntityTypeList({
8863 + list,
8864 + unselectedEntities,
8865 + setUnselectedEntities
8866 + }) {
8867 + const count = list.length;
8868 + const firstRecord = list[0];
8869 + const entityConfig = (0, import_data17.useSelect)(
8870 + (select5) => select5(STORE_NAME).getEntityConfig(
8871 + firstRecord.kind,
8872 + firstRecord.name
8873 + ),
8874 + [firstRecord.kind, firstRecord.name]
8875 + );
8876 + let entityLabel = entityConfig.label;
8877 + if (firstRecord?.name === "wp_template_part") {
8878 + entityLabel = 1 === count ? (0, import_i18n6.__)("Template Part") : (0, import_i18n6.__)("Template Parts");
8879 + }
8880 + return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
8881 + import_components2.PanelBody,
8882 + {
8883 + title: entityLabel,
8884 + initialOpen: true,
8885 + className: "entities-saved-states__panel-body",
8886 + children: [
8887 + /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(EntityDescription, { record: firstRecord, count }),
8888 + list.map((record) => {
8889 + return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
8890 + EntityRecordItem,
8891 + {
8892 + record,
8893 + checked: !unselectedEntities.some(
8894 + (elt) => elt.kind === record.kind && elt.name === record.name && elt.key === record.key && elt.property === record.property
8895 + ),
8896 + onChange: (value) => setUnselectedEntities(record, value)
8897 + },
8898 + record.key || record.property
8899 + );
8900 + }),
8901 + "globalStyles" === firstRecord?.name && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(GlobalStylesDescription, { record: firstRecord })
8902 + ]
8903 + }
8904 + );
8905 + }
8906 +
8907 + // packages/core-data/build-module/components/entities-saved-states/hooks/use-is-dirty.mjs
8908 + var import_data18 = __toESM(require_data(), 1);
8909 + var import_element9 = __toESM(require_element(), 1);
8910 + var useIsDirty = () => {
8911 + const { editedEntities, siteEdits, siteEntityConfig } = (0, import_data18.useSelect)(
8912 + (select5) => {
8913 + const {
8914 + __experimentalGetDirtyEntityRecords: __experimentalGetDirtyEntityRecords2,
8915 + getEntityRecordEdits: getEntityRecordEdits2,
8916 + getEntityConfig: getEntityConfig2
8917 + } = select5(STORE_NAME);
8918 + return {
8919 + editedEntities: __experimentalGetDirtyEntityRecords2(),
8920 + siteEdits: getEntityRecordEdits2("root", "site"),
8921 + siteEntityConfig: getEntityConfig2("root", "site")
8922 + };
8923 + },
8924 + []
8925 + );
8926 + const dirtyEntityRecords = (0, import_element9.useMemo)(() => {
8927 + const editedEntitiesWithoutSite = editedEntities.filter(
8928 + (record) => !(record.kind === "root" && record.name === "site")
8929 + );
8930 + const siteEntityLabels = siteEntityConfig?.meta?.labels ?? {};
8931 + const {
8932 + title: siteTitleEdit,
8933 + description: siteDescriptionEdit,
8934 + site_logo: siteLogoEdit,
8935 + site_icon: siteIconEdit,
8936 + ...otherSiteEdits
8937 + } = siteEdits ?? {};
8938 + const orderedSiteProperties = [
8939 + siteTitleEdit !== void 0 && "title",
8940 + siteDescriptionEdit !== void 0 && "description",
8941 + siteLogoEdit !== void 0 && "site_logo",
8942 + siteIconEdit !== void 0 && "site_icon",
8943 + ...Object.keys(otherSiteEdits)
8944 + ].filter(Boolean);
8945 + const editedSiteEntities = orderedSiteProperties.map(
8946 + (property) => ({
8947 + kind: "root",
8948 + name: "site",
8949 + title: siteEntityLabels[property] || property,
8950 + property
8951 + })
8952 + );
8953 + return [...editedEntitiesWithoutSite, ...editedSiteEntities];
8954 + }, [editedEntities, siteEdits, siteEntityConfig]);
8955 + const [unselectedEntities, _setUnselectedEntities] = (0, import_element9.useState)([]);
8956 + const setUnselectedEntities = ({ kind, name, key, property }, checked) => {
8957 + if (checked) {
8958 + _setUnselectedEntities(
8959 + unselectedEntities.filter(
8960 + (elt) => elt.kind !== kind || elt.name !== name || elt.key !== key || elt.property !== property
8961 + )
8962 + );
8963 + } else {
8964 + _setUnselectedEntities([
8965 + ...unselectedEntities,
8966 + { kind, name, key, property }
8967 + ]);
8968 + }
8969 + };
8970 + const isDirty = dirtyEntityRecords.length - unselectedEntities.length > 0;
8971 + return {
8972 + dirtyEntityRecords,
8973 + isDirty,
8974 + setUnselectedEntities,
8975 + unselectedEntities
8976 + };
8977 + };
8978 +
8979 + // packages/core-data/build-module/components/entities-saved-states/index.mjs
8980 + var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1);
8981 + function EntitiesSavedStates({
8982 + close,
8983 + renderDialog,
8984 + variant
8985 + }) {
8986 + const isDirtyProps = useIsDirty();
8987 + return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
8988 + EntitiesSavedStatesExtensible,
8989 + {
8990 + close,
8991 + renderDialog,
8992 + variant,
8993 + ...isDirtyProps
8994 + }
8995 + );
8996 + }
8997 + function EntitiesSavedStatesExtensible({
8998 + additionalPrompt = void 0,
8999 + close,
9000 + onSave = void 0,
9001 + saveEnabled: saveEnabledProp = void 0,
9002 + saveLabel = (0, import_i18n7.__)("Save"),
9003 + renderDialog,
9004 + dirtyEntityRecords,
9005 + isDirty,
9006 + setUnselectedEntities,
9007 + unselectedEntities,
9008 + variant = "default",
9009 + successNoticeContent
9010 + }) {
9011 + const saveButtonRef = (0, import_element10.useRef)();
9012 + const { saveDirtyEntities: saveDirtyEntities2 } = unlock((0, import_data19.useDispatch)(STORE_NAME));
9013 + const partitionedSavables = dirtyEntityRecords.reduce((acc, record) => {
9014 + const { name } = record;
9015 + if (!acc[name]) {
9016 + acc[name] = [];
9017 + }
9018 + acc[name].push(record);
9019 + return acc;
9020 + }, {});
9021 + const {
9022 + site: siteSavables,
9023 + wp_template: templateSavables,
9024 + wp_template_part: templatePartSavables,
9025 + ...contentSavables
9026 + } = partitionedSavables;
9027 + const sortedPartitionedSavables = [
9028 + siteSavables,
9029 + templateSavables,
9030 + templatePartSavables,
9031 + ...Object.values(contentSavables)
9032 + ].filter(Array.isArray);
9033 + const saveEnabled = saveEnabledProp ?? isDirty;
9034 + const dismissPanel = (0, import_element10.useCallback)(() => close(), [close]);
9035 + const [saveDialogRef, saveDialogProps] = (0, import_compose4.__experimentalUseDialog)({
9036 + onClose: () => dismissPanel()
9037 + });
9038 + const dialogLabelId = (0, import_compose4.useInstanceId)(
9039 + EntitiesSavedStatesExtensible,
9040 + "entities-saved-states__panel-label"
9041 + );
9042 + const dialogDescriptionId = (0, import_compose4.useInstanceId)(
9043 + EntitiesSavedStatesExtensible,
9044 + "entities-saved-states__panel-description"
9045 + );
9046 + const selectItemsToSaveDescription = !!dirtyEntityRecords.length ? (0, import_i18n7.__)("Select the items you want to save.") : void 0;
9047 + const isInline = variant === "inline";
9048 + const actionButtons = /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
9049 + /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
9050 + import_components3.FlexItem,
9051 + {
9052 + isBlock: isInline ? false : true,
9053 + as: import_components3.Button,
9054 + variant: isInline ? "tertiary" : "secondary",
9055 + size: isInline ? void 0 : "compact",
9056 + onClick: dismissPanel,
9057 + children: (0, import_i18n7.__)("Cancel")
9058 + }
9059 + ),
9060 + /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
9061 + import_components3.FlexItem,
9062 + {
9063 + isBlock: isInline ? false : true,
9064 + as: import_components3.Button,
9065 + ref: saveButtonRef,
9066 + variant: "primary",
9067 + size: isInline ? void 0 : "compact",
9068 + disabled: !saveEnabled,
9069 + accessibleWhenDisabled: true,
9070 + onClick: () => saveDirtyEntities2({
9071 + onSave,
9072 + dirtyEntityRecords,
9073 + entitiesToSkip: unselectedEntities,
9074 + close,
9075 + successNoticeContent
9076 + }),
9077 + className: "entities-saved-states__save-button",
9078 + children: saveLabel
9079 + }
9080 + )
9081 + ] });
9082 + return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
9083 + "div",
9084 + {
9085 + ref: renderDialog ? saveDialogRef : void 0,
9086 + ...renderDialog && saveDialogProps,
9087 + className: clsx_default("entities-saved-states__panel", {
9088 + "is-inline": isInline
9089 + }),
9090 + role: renderDialog ? "dialog" : void 0,
9091 + "aria-labelledby": renderDialog ? dialogLabelId : void 0,
9092 + "aria-describedby": renderDialog ? dialogDescriptionId : void 0,
9093 + children: [
9094 + !isInline && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_components3.Flex, { className: "entities-saved-states__panel-header", gap: 2, children: actionButtons }),
9095 + /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "entities-saved-states__text-prompt", children: [
9096 + /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "entities-saved-states__text-prompt--header-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
9097 + "strong",
9098 + {
9099 + id: renderDialog ? dialogLabelId : void 0,
9100 + className: "entities-saved-states__text-prompt--header",
9101 + children: (0, import_i18n7.__)("Are you ready to save?")
9102 + }
9103 + ) }),
9104 + /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { id: renderDialog ? dialogDescriptionId : void 0, children: [
9105 + additionalPrompt,
9106 + /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "entities-saved-states__text-prompt--changes-count", children: isDirty ? (0, import_element10.createInterpolateElement)(
9107 + (0, import_i18n7.sprintf)(
9108 + /* translators: %d: number of site changes waiting to be saved. */
9109 + (0, import_i18n7._n)(
9110 + "There is <strong>%d site change</strong> waiting to be saved.",
9111 + "There are <strong>%d site changes</strong> waiting to be saved.",
9112 + dirtyEntityRecords.length
9113 + ),
9114 + dirtyEntityRecords.length
9115 + ),
9116 + { strong: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("strong", {}) }
9117 + ) : selectItemsToSaveDescription })
9118 + ] })
9119 + ] }),
9120 + sortedPartitionedSavables.map((list) => {
9121 + return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
9122 + EntityTypeList,
9123 + {
9124 + list,
9125 + unselectedEntities,
9126 + setUnselectedEntities
9127 + },
9128 + list[0].name
9129 + );
9130 + }),
9131 + isInline && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
9132 + import_components3.Flex,
9133 + {
9134 + direction: "row",
9135 + justify: "flex-end",
9136 + className: "entities-saved-states__panel-footer",
9137 + children: actionButtons
9138 + }
9139 + )
9140 + ]
9141 + }
9142 + );
9143 + }
9144 +
8136 9145 // packages/core-data/build-module/private-apis.mjs
8137 9146 var lockedApis = {
9147 + EntitiesSavedStates,
9148 + EntitiesSavedStatesExtensible,
9149 + getTemplateInfo,
9150 + getTemplatePartIcon,
9151 + useEntitiesSavedStatesIsDirty: useIsDirty,
8138 9152 useEntityRecordsWithPermissions,
8139 9153 RECEIVE_INTERMEDIATE_RESULTS,
9154 + CRDT_AUTOSAVE_SNAPSHOT_KEY,
9155 + entityContainsSnapshot,
9156 + getEntitySnapshot,
8140 9157 retrySyncConnection,
8141 9158 useActiveCollaborators,
8142 9159 useResolvedSelection,
8143 9160 useOnCollaboratorJoin,
@@ -8233,11 +9250,13 @@
8233 9250 ...entitySelectors
8234 9251 },
8235 9252 resolvers: { ...resolvers_exports, ...entityResolvers }
8236 9253 });
8237 - var store = (0, import_data15.createReduxStore)(STORE_NAME, storeConfig());
9254 + var store = (0, import_data20.createReduxStore)(STORE_NAME, storeConfig());
8238 9255 unlock(store).registerPrivateSelectors(private_selectors_exports);
8239 9256 unlock(store).registerPrivateActions(private_actions_exports);
8240 - (0, import_data15.register)(store);
9257 + (0, import_data20.register)(store);
8241 9258 return __toCommonJS(index_exports);
9259 +})();
9260 +(window.wp ||= {}).coreData = wp.coreData;
8242 9261 })();
8243 9262 //# sourceMappingURL=index.js.map