PluginProbe
Gutenberg / trunk
Gutenberg vtrunk
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 +181 -202 23.9.1 → trunk View file →
@@ -516,8 +516,58 @@
516 516 return null;
517 517 }
518 518 var get_normalized_comma_separable_default = getNormalizedCommaSeparable;
519 519
520 + // packages/core-data/build-module/utils/set-nested-value.mjs
521 + function setNestedValue(object, path, value) {
522 + if (!object || typeof object !== "object") {
523 + return object;
524 + }
525 + const normalizedPath = Array.isArray(path) ? path : path.split(".");
526 + normalizedPath.reduce((acc, key, idx) => {
527 + if (acc[key] === void 0) {
528 + if (Number.isInteger(normalizedPath[idx + 1])) {
529 + acc[key] = [];
530 + } else {
531 + acc[key] = {};
532 + }
533 + }
534 + if (idx === normalizedPath.length - 1) {
535 + acc[key] = value;
536 + }
537 + return acc[key];
538 + }, object);
539 + return object;
540 + }
541 +
542 + // packages/core-data/build-module/utils/get-filtered-item.mjs
543 + var filteredItemCache = /* @__PURE__ */ new WeakMap();
544 + function getFilteredItem(item, _fields) {
545 + const fields = get_normalized_comma_separable_default(_fields) ?? [];
546 + const fieldsKey = fields.join(",");
547 + let itemCache = filteredItemCache.get(item);
548 + if (itemCache) {
549 + const filtered = itemCache.get(fieldsKey);
550 + if (filtered !== void 0) {
551 + return filtered;
552 + }
553 + } else if (item !== null && typeof item === "object") {
554 + itemCache = /* @__PURE__ */ new Map();
555 + filteredItemCache.set(item, itemCache);
556 + }
557 + const filteredItem = {};
558 + for (let f = 0; f < fields.length; f++) {
559 + const field = fields[f].split(".");
560 + let value = item;
561 + field.forEach((fieldName) => {
562 + value = value?.[fieldName];
563 + });
564 + setNestedValue(filteredItem, field, value);
565 + }
566 + itemCache?.set(fieldsKey, filteredItem);
567 + return filteredItem;
568 + }
569 +
520 570 // packages/core-data/build-module/utils/if-matching-action.mjs
521 571 var ifMatchingAction = (isMatch) => (reducer) => (state, action) => {
522 572 if (state === void 0 || isMatch(action)) {
523 573 return reducer(state, action);
@@ -555,30 +605,8 @@
555 605 };
556 606 }
557 607 var with_weak_map_cache_default = withWeakMapCache;
558 608
559 - // packages/core-data/build-module/utils/set-nested-value.mjs
560 - function setNestedValue(object, path, value) {
561 - if (!object || typeof object !== "object") {
562 - return object;
563 - }
564 - const normalizedPath = Array.isArray(path) ? path : path.split(".");
565 - normalizedPath.reduce((acc, key, idx) => {
566 - if (acc[key] === void 0) {
567 - if (Number.isInteger(normalizedPath[idx + 1])) {
568 - acc[key] = [];
569 - } else {
570 - acc[key] = {};
571 - }
572 - }
573 - if (idx === normalizedPath.length - 1) {
574 - acc[key] = value;
575 - }
576 - return acc[key];
577 - }, object);
578 - return object;
579 - }
580 -
581 609 // packages/core-data/build-module/utils/get-nested-value.mjs
582 610 function getNestedValue(object, path, defaultValue) {
583 611 if (!object || typeof object !== "object" || typeof path !== "string" && !Array.isArray(path)) {
584 612 return object;
@@ -3379,16 +3407,8 @@
3379 3407 key: "slug",
3380 3408 supportsPagination: false
3381 3409 },
3382 3410 {
3383 - label: (0, import_i18n.__)("Registered Templates"),
3384 - name: "registeredTemplate",
3385 - kind: "root",
3386 - baseURL: "/wp/v2/registered-templates",
3387 - key: "id",
3388 - supportsPagination: false
3389 - },
3390 - {
3391 3411 label: (0, import_i18n.__)("Font Collections"),
3392 3412 name: "fontCollection",
3393 3413 kind: "root",
3394 3414 baseURL: "/wp/v2/font-collections",
@@ -3510,14 +3530,12 @@
3510 3530 getTitle: (record) => record?.title?.rendered || record?.title || (isTemplate ? capitalCase(record.slug ?? "") : String(record.id)),
3511 3531 __unstablePrePersist: (persistedRecord, edits) => prePersistPostType(persistedRecord, edits, name, isTemplate),
3512 3532 __unstable_rest_base: postType.rest_base,
3513 3533 // The templates controller returns the whole collection and never
3514 - // paginates. It serves `wp_template_part` always, and `wp_template`
3515 - // until the template activate experiment moves it to a posts
3516 - // controller.
3517 - supportsPagination: window?.__experimentalTemplateActivate ? name !== "wp_template_part" : !isTemplate,
3534 + // paginates.
3535 + supportsPagination: !isTemplate,
3518 3536 getRevisionsUrl: (parentId, revisionId) => `/${namespace}/${postType.rest_base}/${parentId}/revisions${revisionId ? "/" + revisionId : ""}`,
3519 - revisionKey: isTemplate && !window?.__experimentalTemplateActivate ? "wp_id" : DEFAULT_ENTITY_KEY
3537 + revisionKey: isTemplate ? "wp_id" : DEFAULT_ENTITY_KEY
3520 3538 };
3521 3539 if (!window.__experimentalEnableRealTimeCollaboration) {
3522 3540 return entity2;
3523 3541 }
@@ -3766,8 +3784,29 @@
3766 3784 ),
3767 3785 meta: action.meta
3768 3786 };
3769 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 + }
3770 3809 var queries = (state = {}, action) => {
3771 3810 switch (action.type) {
3772 3811 case "RECEIVE_ITEMS":
3773 3812 return receiveQueries(state, action);
@@ -3783,14 +3822,12 @@
3783 3822 Object.fromEntries(
3784 3823 Object.entries(contextQueries).map(
3785 3824 ([query, queryItems]) => [
3786 3825 query,
3787 - {
3788 - ...queryItems,
3789 - itemIds: queryItems.itemIds.filter(
3790 - (queryId) => !removedItems[queryId]
3791 - )
3792 - }
3826 + removeQueryItems(
3827 + queryItems,
3828 + removedItems
3829 + )
3793 3830 ]
3794 3831 )
3795 3832 )
3796 3833 ]
@@ -4511,9 +4548,11 @@
4511 4548 );
4512 4549 if (!templates) {
4513 4550 return;
4514 4551 }
4515 - const id = templates.find(({ slug }) => slug === "front-page")?.id;
4552 + const id = templates.find(
4553 + ({ slug }) => slug === "front-page"
4554 + )?.id;
4516 4555 if (id) {
4517 4556 return id;
4518 4557 }
4519 4558 }
@@ -4643,48 +4682,28 @@
4643 4682 return state.entities.config?.find(
4644 4683 (config) => config.kind === kind && config.name === name
4645 4684 );
4646 4685 }
4647 - var getEntityRecord = (0, import_data9.createSelector)(
4648 - ((state, kind, name, recordId, query) => {
4649 - logEntityDeprecation(kind, name, "getEntityRecord");
4650 - const queriedState = state.entities.records?.[kind]?.[name]?.queriedData;
4651 - 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]) {
4652 4695 return void 0;
4653 4696 }
4654 - const context = query?.context ?? "default";
4655 - if (!query || !query._fields) {
4656 - if (!queriedState.itemIsComplete[context]?.[recordId]) {
4657 - return void 0;
4658 - }
4659 - return queriedState.items[context][recordId];
4660 - }
4661 - const item = queriedState.items[context]?.[recordId];
4662 - if (!item) {
4663 - return item;
4664 - }
4665 - const filteredItem = {};
4666 - const fields = get_normalized_comma_separable_default(query._fields) ?? [];
4667 - for (let f = 0; f < fields.length; f++) {
4668 - const field = fields[f].split(".");
4669 - let value = item;
4670 - field.forEach((fieldName) => {
4671 - value = value?.[fieldName];
4672 - });
4673 - setNestedValue(filteredItem, field, value);
4674 - }
4675 - return filteredItem;
4676 - }),
4677 - (state, kind, name, recordId, query) => {
4678 - const context = query?.context ?? "default";
4679 - const queriedState = state.entities.records?.[kind]?.[name]?.queriedData;
4680 - return [
4681 - queriedState?.items[context]?.[recordId],
4682 - queriedState?.itemIsComplete[context]?.[recordId]
4683 - ];
4697 + return queriedState.items[context][recordId];
4684 4698 }
4685 - );
4686 - 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) => {
4687 4706 const newArgs = [...args];
4688 4707 const recordKey = newArgs?.[2];
4689 4708 newArgs[2] = isNumericID(recordKey) ? Number(recordKey) : recordKey;
4690 4709 return newArgs;
@@ -5103,47 +5122,27 @@
5103 5122 }
5104 5123 }
5105 5124 return true;
5106 5125 }
5107 - var getRevision = (0, import_data9.createSelector)(
5108 - (state, kind, name, recordKey, revisionKey, query) => {
5109 - logEntityDeprecation(kind, name, "getRevision");
5110 - const queriedState = state.entities.records?.[kind]?.[name]?.revisions?.[recordKey];
5111 - 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]) {
5112 5135 return void 0;
5113 5136 }
5114 - const context = query?.context ?? "default";
5115 - if (!query || !query._fields) {
5116 - if (!queriedState.itemIsComplete[context]?.[revisionKey]) {
5117 - return void 0;
5118 - }
5119 - return queriedState.items[context][revisionKey];
5120 - }
5121 - const item = queriedState.items[context]?.[revisionKey];
5122 - if (!item) {
5123 - return item;
5124 - }
5125 - const filteredItem = {};
5126 - const fields = get_normalized_comma_separable_default(query._fields) ?? [];
5127 - for (let f = 0; f < fields.length; f++) {
5128 - const field = fields[f].split(".");
5129 - let value = item;
5130 - field.forEach((fieldName) => {
5131 - value = value?.[fieldName];
5132 - });
5133 - setNestedValue(filteredItem, field, value);
5134 - }
5135 - return filteredItem;
5136 - },
5137 - (state, kind, name, recordKey, revisionKey, query) => {
5138 - const context = query?.context ?? "default";
5139 - const queriedState = state.entities.records?.[kind]?.[name]?.revisions?.[recordKey];
5140 - return [
5141 - queriedState?.items?.[context]?.[revisionKey],
5142 - queriedState?.itemIsComplete?.[context]?.[revisionKey]
5143 - ];
5137 + return queriedState.items[context][revisionKey];
5144 5138 }
5145 - );
5139 + const item = queriedState.items[context]?.[revisionKey];
5140 + if (!item) {
5141 + return item;
5142 + }
5143 + return getFilteredItem(item, query._fields);
5144 + };
5146 5145
5147 5146 // packages/core-data/build-module/actions.mjs
5148 5147 var actions_exports = {};
5149 5148 __export(actions_exports, {
@@ -5511,12 +5510,9 @@
5511 5510 name,
5512 5511 recordId
5513 5512 });
5514 5513 let hasError = false;
5515 - let { baseURL } = entityConfig;
5516 - if (kind === "postType" && name === "wp_template" && (recordId && typeof recordId === "string" && !/^\d+$/.test(recordId) || !window?.__experimentalTemplateActivate)) {
5517 - baseURL = baseURL.slice(0, baseURL.lastIndexOf("/")) + "/templates";
5518 - }
5514 + const { baseURL } = entityConfig;
5519 5515 try {
5520 5516 let path = `${baseURL}/${recordId}`;
5521 5517 if (query) {
5522 5518 path = (0, import_url3.addQueryArgs)(path, query);
@@ -5716,12 +5712,9 @@
5716 5712 });
5717 5713 let updatedRecord;
5718 5714 let error;
5719 5715 let hasError = false;
5720 - let { baseURL } = entityConfig;
5721 - if (kind === "postType" && name === "wp_template" && (recordId && typeof recordId === "string" && !/^\d+$/.test(recordId) || !window?.__experimentalTemplateActivate)) {
5722 - baseURL = baseURL.slice(0, baseURL.lastIndexOf("/")) + "/templates";
5723 - }
5716 + const { baseURL } = entityConfig;
5724 5717 try {
5725 5718 const path = `${baseURL}${recordId ? "/" + recordId : ""}`;
5726 5719 const persistedRecord = !isNewRecord ? select5.getRawEntityRecord(kind, name, recordId) : {};
5727 5720 if (entityConfig.syncConfig && !__unstableSkipSyncUpdate && !isNewRecord && persistedRecord) {
@@ -6455,8 +6448,9 @@
6455 6448 return results;
6456 6449 }
6457 6450 function sortResults(results, search) {
6458 6451 const searchTokens = tokenize(search);
6452 + const scoreKey = (result) => `${result.kind}:${result.type}:${result.id}`;
6459 6453 const scores = {};
6460 6454 for (const result of results) {
6461 6455 if (result.title) {
6462 6456 const titleTokens = tokenize(result.title);
@@ -6471,14 +6465,16 @@
6471 6465 )
6472 6466 );
6473 6467 const exactMatchScore = exactMatchingTokens.length / titleTokens.length * 10;
6474 6468 const subMatchScore = subMatchingTokens.length / titleTokens.length;
6475 - scores[result.id] = exactMatchScore + subMatchScore;
6469 + scores[scoreKey(result)] = exactMatchScore + subMatchScore;
6476 6470 } else {
6477 - scores[result.id] = 0;
6471 + scores[scoreKey(result)] = 0;
6478 6472 }
6479 6473 }
6480 - 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 + );
6481 6477 }
6482 6478 function tokenize(text) {
6483 6479 return text.toLowerCase().match(/[\p{L}\p{N}]+/gu) || [];
6484 6480 }
@@ -6606,12 +6602,9 @@
6606 6602 if (hasRecord) {
6607 6603 return;
6608 6604 }
6609 6605 }
6610 - let { baseURL } = entityConfig;
6611 - if (kind === "postType" && name === "wp_template" && (key && typeof key === "string" && !/^\d+$/.test(key) || !window?.__experimentalTemplateActivate)) {
6612 - baseURL = baseURL.slice(0, baseURL.lastIndexOf("/")) + "/templates";
6613 - }
6606 + const { baseURL } = entityConfig;
6614 6607 const path = (0, import_url6.addQueryArgs)(baseURL + (key ? "/" + key : ""), {
6615 6608 ...entityConfig.baseURLParams,
6616 6609 ...query
6617 6610 });
@@ -6619,9 +6612,8 @@
6619 6612 const record = await response.json();
6620 6613 const permissions = getUserPermissionsFromAllowHeader(
6621 6614 response.headers?.get("allow")
6622 6615 );
6623 - const canUserResolutionsArgs = [];
6624 6616 const receiveUserPermissionArgs = {};
6625 6617 for (const action of ALLOWED_RESOURCE_ACTIONS) {
6626 6618 receiveUserPermissionArgs[getUserPermissionCacheKey(action, {
6627 6619 kind,
@@ -6627,13 +6619,10 @@
6627 6619 kind,
6628 6620 name,
6629 6621 id: key
6630 6622 })] = permissions[action];
6631 - canUserResolutionsArgs.push([
6632 - action,
6633 - { kind, name, id: key }
6634 - ]);
6635 6623 }
6624 + const canUserResolutionsArgs = [[{ kind, name, id: key }]];
6636 6625 if (entityConfig.syncConfig && isNumericID(key) && !query) {
6637 6626 const objectType = `${kind}/${name}`;
6638 6627 const objectId = key;
6639 6628 const recordWithTransients = { ...record };
@@ -6799,13 +6788,9 @@
6799 6788 ])
6800 6789 ].join()
6801 6790 };
6802 6791 }
6803 - let { baseURL } = entityConfig;
6804 - const { combinedTemplates = true } = query;
6805 - if (kind === "postType" && name === "wp_template" && combinedTemplates) {
6806 - baseURL = baseURL.slice(0, baseURL.lastIndexOf("/")) + "/templates";
6807 - }
6792 + const { baseURL } = entityConfig;
6808 6793 const path = (0, import_url6.addQueryArgs)(baseURL, {
6809 6794 ...entityConfig.baseURLParams,
6810 6795 ...query
6811 6796 });
@@ -6911,13 +6896,12 @@
6911 6896 }));
6912 6897 const canUserResolutionsArgs = [];
6913 6898 const receiveUserPermissionArgs = {};
6914 6899 for (const targetHint of targetHints) {
6900 + canUserResolutionsArgs.push([
6901 + { kind, name, id: targetHint.id }
6902 + ]);
6915 6903 for (const action of ALLOWED_RESOURCE_ACTIONS) {
6916 - canUserResolutionsArgs.push([
6917 - action,
6918 - { kind, name, id: targetHint.id }
6919 - ]);
6920 6904 receiveUserPermissionArgs[getUserPermissionCacheKey(action, {
6921 6905 kind,
6922 6906 name,
6923 6907 id: targetHint.id
@@ -6966,26 +6950,9 @@
6966 6950 } catch {
6967 6951 dispatch3.receiveEmbedPreview(url, false);
6968 6952 }
6969 6953 };
6970 - var canUser2 = (requestedAction, resource, id) => async ({ dispatch: dispatch3, registry, resolveSelect: resolveSelect2 }) => {
6971 - if (!ALLOWED_RESOURCE_ACTIONS.includes(requestedAction)) {
6972 - throw new Error(`'${requestedAction}' is not a valid action.`);
6973 - }
6974 - const { hasStartedResolution } = registry.select(STORE_NAME);
6975 - for (const relatedAction of ALLOWED_RESOURCE_ACTIONS) {
6976 - if (relatedAction === requestedAction) {
6977 - continue;
6978 - }
6979 - const isAlreadyResolving = hasStartedResolution("canUser", [
6980 - relatedAction,
6981 - resource,
6982 - id
6983 - ]);
6984 - if (isAlreadyResolving) {
6985 - return;
6986 - }
6987 - }
6954 + var canUser2 = (resource, id) => async ({ dispatch: dispatch3, resolveSelect: resolveSelect2 }) => {
6988 6955 let resourcePath = null;
6989 6956 if (typeof resource === "object") {
6990 6957 if (!resource.kind || !resource.name) {
6991 6958 throw new Error("The entity resource object is not valid.");
@@ -7016,22 +6983,16 @@
7016 6983 const permissions = getUserPermissionsFromAllowHeader(
7017 6984 response.headers?.get("allow")
7018 6985 );
7019 6986 const receiveUserPermissionArgs = {};
7020 - const canUserResolutionsArgs = [];
7021 6987 for (const action of ALLOWED_RESOURCE_ACTIONS) {
7022 6988 receiveUserPermissionArgs[getUserPermissionCacheKey(action, resource, id)] = permissions[action];
7023 - if (action !== requestedAction) {
7024 - canUserResolutionsArgs.push([action, resource, id]);
7025 - }
7026 6989 }
7027 - registry.batch(() => {
7028 - dispatch3.receiveUserPermissions(receiveUserPermissionArgs);
7029 - dispatch3.finishResolutions("canUser", canUserResolutionsArgs);
7030 - });
6990 + dispatch3.receiveUserPermissions(receiveUserPermissionArgs);
7031 6991 };
7032 - var canUserEditEntityRecord2 = (kind, name, recordId) => async ({ dispatch: dispatch3 }) => {
7033 - 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 });
7034 6995 };
7035 6996 var getAutosaves2 = (postType, postId) => async ({ dispatch: dispatch3, resolveSelect: resolveSelect2 }) => {
7036 6997 const {
7037 6998 rest_base: restBase,
@@ -7182,9 +7143,9 @@
7182 7143 const template = await (0, import_api_fetch9.default)({
7183 7144 path: (0, import_url6.addQueryArgs)("/wp/v2/templates/lookup", query)
7184 7145 });
7185 7146 await resolveSelect2.getEntitiesConfig("postType");
7186 - const id = window?.__experimentalTemplateActivate ? template?.wp_id || template?.id : template?.id;
7147 + const id = template?.id;
7187 7148 registry.batch(() => {
7188 7149 dispatch3.receiveDefaultTemplateId(query, id || "");
7189 7150 if (id) {
7190 7151 template.id = id;
@@ -7200,11 +7161,8 @@
7200 7161 ]);
7201 7162 }
7202 7163 });
7203 7164 };
7204 - getDefaultTemplateId2.shouldInvalidate = (action) => {
7205 - return action.type === "RECEIVE_ITEMS" && action.kind === "root" && action.name === "site" && !!action.persistedEdits;
7206 - };
7207 7165 var getRevisions2 = (kind, name, recordKey, query = {}) => async ({ dispatch: dispatch3, resolveSelect: resolveSelect2 }) => {
7208 7166 const configs = await resolveSelect2.getEntitiesConfig(kind);
7209 7167 const entityConfig = configs.find(
7210 7168 (config) => config.name === name && config.kind === kind
@@ -7611,9 +7569,17 @@
7611 7569 ...parent?.[kind],
7612 7570 [name]: id
7613 7571 }
7614 7572 },
7615 - ...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 + }
7616 7582 }),
7617 7583 [parent, kind, name, id, revisionId]
7618 7584 );
7619 7585 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(EntityContext.Provider, { value: childContext, children });
@@ -8260,38 +8226,36 @@
8260 8226
8261 8227 // packages/core-data/build-module/hooks/use-entity-prop.mjs
8262 8228 var import_element7 = __toESM(require_element(), 1);
8263 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 + };
8264 8234 function useEntityProp(kind, name, prop, _id) {
8265 8235 const providerId = useEntityId(kind, name);
8266 8236 const id = _id ?? providerId;
8267 8237 const context = (0, import_element7.useContext)(EntityContext);
8268 - const revisionId = context?.revisionId;
8238 + const revisionId = String(id) === String(providerId) ? context?.revision?.[kind]?.[name] : void 0;
8269 8239 const { value, fullValue } = (0, import_data15.useSelect)(
8270 8240 (select5) => {
8271 8241 if (revisionId) {
8272 - const revisions = select5(STORE_NAME).getRevisions(
8242 + const revision = select5(STORE_NAME).getRevision(
8273 8243 kind,
8274 8244 name,
8275 8245 id,
8276 - {
8277 - per_page: -1,
8278 - context: "edit",
8279 - _fields: "id,date,author,meta,title.raw,excerpt.raw,content.raw"
8280 - }
8246 + revisionId,
8247 + REVISION_QUERY
8281 8248 );
8282 - const entityConfig = select5(STORE_NAME).getEntityConfig(
8283 - kind,
8284 - name
8285 - );
8286 - const revKey = entityConfig?.revisionKey || DEFAULT_ENTITY_KEY;
8287 - const revision = revisions?.find(
8288 - (r2) => r2[revKey] === revisionId
8289 - );
8290 - return revision ? {
8291 - value: revision[prop]?.raw ?? revision[prop],
8292 - fullValue: revision[prop]
8293 - } : {};
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 + };
8294 8258 }
8295 8259 const { getEntityRecord: getEntityRecord3, getEditedEntityRecord: getEditedEntityRecord3 } = select5(STORE_NAME);
8296 8260 const record = getEntityRecord3(kind, name, id);
8297 8261 const editedRecord = getEditedEntityRecord3(kind, name, id);
@@ -8500,34 +8464,49 @@
8500 8464
8501 8465 // packages/icons/build-module/library/footer.mjs
8502 8466 var import_primitives = __toESM(require_primitives(), 1);
8503 8467 var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
8504 - var footer_default = /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_primitives.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_primitives.Path, { fillRule: "evenodd", d: "M18 5.5h-8v8h8.5V6a.5.5 0 00-.5-.5zm-9.5 8h-3V6a.5.5 0 01.5-.5h2.5v8zM6 4h12a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6a2 2 0 012-2z" }) });
8468 + var footer_default = /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_primitives.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", style: { fill: "none" }, stroke: "currentColor", strokeWidth: "1.5", children: [
8469 + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_primitives.Path, { d: "M9.75 4.75H18C18.6904 4.75 19.25 5.30964 19.25 6V14.25M9.75 4.75H6C5.30964 4.75 4.75 5.30964 4.75 6V14.25M9.75 4.75V14.25M19.25 14.25V18C19.25 18.6904 18.6904 19.25 18 19.25H6C5.30964 19.25 4.75 18.6904 4.75 18V14.25M19.25 14.25H9.75M9.75 14.25H4.75", vectorEffect: "non-scaling-stroke" }),
8470 + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_primitives.Path, { d: "M19.25 15.5V18C19.25 18.6904 18.6904 19.25 18 19.25H6C5.30964 19.25 4.75 18.6904 4.75 18V15.5C4.75 14.8096 5.30964 14.25 6 14.25H18C18.6904 14.25 19.25 14.8096 19.25 15.5Z", fill: "currentColor", vectorEffect: "non-scaling-stroke" })
8471 + ] });
8505 8472
8506 8473 // packages/icons/build-module/library/header.mjs
8507 8474 var import_primitives2 = __toESM(require_primitives(), 1);
8508 8475 var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
8509 - var header_default = /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_primitives2.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_primitives2.Path, { d: "M18.5 10.5H10v8h8a.5.5 0 00.5-.5v-7.5zm-10 0h-3V18a.5.5 0 00.5.5h2.5v-8zM6 4h12a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6a2 2 0 012-2z" }) });
8476 + var header_default = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_primitives2.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", style: { fill: "none" }, stroke: "currentColor", strokeWidth: "1.5", children: [
8477 + /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_primitives2.Path, { d: "M9.75 19.25H18C18.6904 19.25 19.25 18.6904 19.25 18V9.75M9.75 19.25H6C5.30964 19.25 4.75 18.6904 4.75 18V9.75M9.75 19.25V9.75M19.25 9.75V6C19.25 5.30964 18.6904 4.75 18 4.75H6C5.30964 4.75 4.75 5.30964 4.75 6V9.75M19.25 9.75H9.75M9.75 9.75H4.75", vectorEffect: "non-scaling-stroke" }),
8478 + /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_primitives2.Path, { d: "M19.25 8.5V6C19.25 5.30964 18.6904 4.75 18 4.75H6C5.30964 4.75 4.75 5.30964 4.75 6V8.5C4.75 9.19036 5.30964 9.75 6 9.75H18C18.6904 9.75 19.25 9.19036 19.25 8.5Z", fill: "currentColor", vectorEffect: "non-scaling-stroke" })
8479 + ] });
8510 8480
8511 8481 // packages/icons/build-module/library/layout.mjs
8512 8482 var import_primitives3 = __toESM(require_primitives(), 1);
8513 8483 var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
8514 - var layout_default = /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_primitives3.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_primitives3.Path, { d: "M18 5.5H6a.5.5 0 00-.5.5v3h13V6a.5.5 0 00-.5-.5zm.5 5H10v8h8a.5.5 0 00.5-.5v-7.5zm-10 0h-3V18a.5.5 0 00.5.5h2.5v-8zM6 4h12a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6a2 2 0 012-2z" }) });
8484 + var layout_default = /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_primitives3.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", style: { fill: "none" }, stroke: "currentColor", strokeWidth: "1.5", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_primitives3.Path, { d: "M9.75 19.25H18C18.6904 19.25 19.25 18.6904 19.25 18V9.75M9.75 19.25H6C5.30964 19.25 4.75 18.6904 4.75 18V9.75M9.75 19.25V9.75M19.25 9.75V6C19.25 5.30964 18.6904 4.75 18 4.75H6C5.30964 4.75 4.75 5.30964 4.75 6V9.75M19.25 9.75H9.75M9.75 9.75H4.75", vectorEffect: "non-scaling-stroke" }) });
8515 8485
8516 8486 // packages/icons/build-module/library/navigation-overlay.mjs
8517 8487 var import_primitives4 = __toESM(require_primitives(), 1);
8518 8488 var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1);
8519 - var navigation_overlay_default = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_primitives4.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_primitives4.Path, { d: "M18.5 10a1.5 1.5 0 0 1 1.5 1.5v7a1.5 1.5 0 0 1-1.5 1.5h-7a1.5 1.5 0 0 1-1.5-1.5v-7a1.5 1.5 0 0 1 1.5-1.5zM16 4a2 2 0 0 1 2 2v2h-1.5V6a.5.5 0 0 0-.5-.5H6a.5.5 0 0 0-.5.5v3H8v1.5H5.5V16a.5.5 0 0 0 .5.5h2V18H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2z" }) });
8489 + var navigation_overlay_default = /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_primitives4.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", style: { fill: "none" }, stroke: "currentColor", strokeWidth: "1.5", children: [
8490 + /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_primitives4.Path, { d: "M4.75 9.25V16C4.75 16.6904 5.30964 17.25 6 17.25H8M4.75 9.25V6C4.75 5.30964 5.30964 4.75 6 4.75H16C16.6904 4.75 17.25 5.30964 17.25 6V8M4.75 9.25H8", vectorEffect: "non-scaling-stroke" }),
8491 + /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_primitives4.Path, { d: "M10.75 11.25C10.75 10.9739 10.9739 10.75 11.25 10.75H18.75C19.0261 10.75 19.25 10.9739 19.25 11.25V18.75C19.25 19.0261 19.0261 19.25 18.75 19.25H11.25C10.9739 19.25 10.75 19.0261 10.75 18.75V11.25Z", fill: "currentColor", vectorEffect: "non-scaling-stroke" })
8492 + ] });
8520 8493
8521 8494 // packages/icons/build-module/library/sidebar.mjs
8522 8495 var import_primitives5 = __toESM(require_primitives(), 1);
8523 8496 var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1);
8524 - var sidebar_default = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_primitives5.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_primitives5.Path, { d: "M18 5.5H6a.5.5 0 00-.5.5v3h13V6a.5.5 0 00-.5-.5zm.5 5H10v8h8a.5.5 0 00.5-.5v-7.5zM6 4h12a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6a2 2 0 012-2z" }) });
8497 + var sidebar_default = /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_primitives5.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", style: { fill: "none" }, stroke: "currentColor", strokeWidth: "1.5", children: [
8498 + /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_primitives5.Path, { d: "M9.75 19.25H18C18.6904 19.25 19.25 18.6904 19.25 18V9.75M9.75 19.25H6C5.30964 19.25 4.75 18.6904 4.75 18V9.75M9.75 19.25V9.75M19.25 9.75V6C19.25 5.30964 18.6904 4.75 18 4.75H6C5.30964 4.75 4.75 5.30964 4.75 6V9.75M19.25 9.75H9.75M9.75 9.75H4.75", vectorEffect: "non-scaling-stroke" }),
8499 + /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_primitives5.Path, { d: "M6 19.25H9.75V9.75H4.75V18C4.75 18.6904 5.30964 19.25 6 19.25Z", fill: "currentColor", vectorEffect: "non-scaling-stroke" })
8500 + ] });
8525 8501
8526 8502 // packages/icons/build-module/library/symbol-filled.mjs
8527 8503 var import_primitives6 = __toESM(require_primitives(), 1);
8528 8504 var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1);
8529 - var symbol_filled_default = /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_primitives6.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_primitives6.Path, { d: "M21.3 10.8l-5.6-5.6c-.7-.7-1.8-.7-2.5 0l-5.6 5.6c-.7.7-.7 1.8 0 2.5l5.6 5.6c.3.3.8.5 1.2.5s.9-.2 1.2-.5l5.6-5.6c.8-.7.8-1.9.1-2.5zm-17.6 1L10 5.5l-1-1-6.3 6.3c-.7.7-.7 1.8 0 2.5L9 19.5l1.1-1.1-6.3-6.3c-.2 0-.2-.2-.1-.3z" }) });
8505 + var symbol_filled_default = /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_primitives6.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", style: { fill: "none" }, stroke: "currentColor", strokeWidth: "1.5", children: [
8506 + /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_primitives6.Path, { d: "M15.2071 6.20711L20.2929 11.2929C20.6834 11.6834 20.6834 12.3166 20.2929 12.7071L15.2071 17.7929C14.8166 18.1834 14.1834 18.1834 13.7929 17.7929L8.70711 12.7071C8.31658 12.3166 8.31658 11.6834 8.70711 11.2929L13.7929 6.20711C14.1834 5.81658 14.8166 5.81658 15.2071 6.20711Z", fill: "currentColor", vectorEffect: "non-scaling-stroke" }),
8507 + /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_primitives6.Path, { d: "M9.5 5.5L3.70711 11.2929C3.31658 11.6834 3.31658 12.3166 3.70711 12.7071L9.5 18.5", vectorEffect: "non-scaling-stroke" })
8508 + ] });
8530 8509
8531 8510 // packages/core-data/build-module/utils/get-template-part-icon.mjs
8532 8511 function getTemplatePartIcon(areaOrIconName) {
8533 8512 if ("header" === areaOrIconName) {