@wordpress/core-data 7.38.0 → 7.38.1-next.v.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/awareness/config.cjs +34 -0
- package/build/awareness/config.cjs.map +7 -0
- package/build/awareness/post-editor-awareness.cjs +144 -0
- package/build/awareness/post-editor-awareness.cjs.map +7 -0
- package/build/awareness/types.cjs +19 -0
- package/build/awareness/types.cjs.map +7 -0
- package/build/awareness/utils.cjs +116 -0
- package/build/awareness/utils.cjs.map +7 -0
- package/build/entities.cjs +13 -0
- package/build/entities.cjs.map +2 -2
- package/build/resolvers.cjs +3 -2
- package/build/resolvers.cjs.map +2 -2
- package/build/utils/crdt-user-selections.cjs +171 -0
- package/build/utils/crdt-user-selections.cjs.map +7 -0
- package/build-module/awareness/config.mjs +8 -0
- package/build-module/awareness/config.mjs.map +7 -0
- package/build-module/awareness/post-editor-awareness.mjs +125 -0
- package/build-module/awareness/post-editor-awareness.mjs.map +7 -0
- package/build-module/awareness/types.mjs +1 -0
- package/build-module/awareness/types.mjs.map +7 -0
- package/build-module/awareness/utils.mjs +90 -0
- package/build-module/awareness/utils.mjs.map +7 -0
- package/build-module/entities.mjs +13 -0
- package/build-module/entities.mjs.map +2 -2
- package/build-module/resolvers.mjs +3 -2
- package/build-module/resolvers.mjs.map +2 -2
- package/build-module/utils/crdt-user-selections.mjs +144 -0
- package/build-module/utils/crdt-user-selections.mjs.map +7 -0
- package/build-types/awareness/config.d.ts +9 -0
- package/build-types/awareness/config.d.ts.map +1 -0
- package/build-types/awareness/post-editor-awareness.d.ts +39 -0
- package/build-types/awareness/post-editor-awareness.d.ts.map +1 -0
- package/build-types/awareness/types.d.ts +32 -0
- package/build-types/awareness/types.d.ts.map +1 -0
- package/build-types/awareness/utils.d.ts +22 -0
- package/build-types/awareness/utils.d.ts.map +1 -0
- package/build-types/entities.d.ts.map +1 -1
- package/build-types/resolvers.d.ts.map +1 -1
- package/build-types/utils/crdt-user-selections.d.ts +66 -0
- package/build-types/utils/crdt-user-selections.d.ts.map +1 -0
- package/package.json +19 -18
- package/src/awareness/config.ts +9 -0
- package/src/awareness/post-editor-awareness.ts +187 -0
- package/src/awareness/types.ts +38 -0
- package/src/awareness/utils.ts +159 -0
- package/src/entities.js +14 -0
- package/src/resolvers.js +2 -1
- package/src/test/entity-provider.js +2 -0
- package/src/utils/crdt-user-selections.ts +332 -0
- package/src/utils/test/crdt-blocks.ts +11 -4
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// packages/core-data/src/awareness/config.ts
|
|
21
|
+
var config_exports = {};
|
|
22
|
+
__export(config_exports, {
|
|
23
|
+
AWARENESS_CURSOR_UPDATE_THROTTLE_IN_MS: () => AWARENESS_CURSOR_UPDATE_THROTTLE_IN_MS,
|
|
24
|
+
LOCAL_CURSOR_UPDATE_DEBOUNCE_IN_MS: () => LOCAL_CURSOR_UPDATE_DEBOUNCE_IN_MS
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(config_exports);
|
|
27
|
+
var AWARENESS_CURSOR_UPDATE_THROTTLE_IN_MS = 100;
|
|
28
|
+
var LOCAL_CURSOR_UPDATE_DEBOUNCE_IN_MS = 5;
|
|
29
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
30
|
+
0 && (module.exports = {
|
|
31
|
+
AWARENESS_CURSOR_UPDATE_THROTTLE_IN_MS,
|
|
32
|
+
LOCAL_CURSOR_UPDATE_DEBOUNCE_IN_MS
|
|
33
|
+
});
|
|
34
|
+
//# sourceMappingURL=config.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/awareness/config.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Delay in milliseconds before throttling the cursor position updates.\n */\nexport const AWARENESS_CURSOR_UPDATE_THROTTLE_IN_MS = 100;\n\n/**\n * Delay in milliseconds before updating the cursor position.\n */\nexport const LOCAL_CURSOR_UPDATE_DEBOUNCE_IN_MS = 5;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGO,IAAM,yCAAyC;AAK/C,IAAM,qCAAqC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// packages/core-data/src/awareness/post-editor-awareness.ts
|
|
21
|
+
var post_editor_awareness_exports = {};
|
|
22
|
+
__export(post_editor_awareness_exports, {
|
|
23
|
+
PostEditorAwareness: () => PostEditorAwareness
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(post_editor_awareness_exports);
|
|
26
|
+
var import_data = require("@wordpress/data");
|
|
27
|
+
var import_sync = require("@wordpress/sync");
|
|
28
|
+
var import_block_editor = require("@wordpress/block-editor");
|
|
29
|
+
var import_config = require("./config.cjs");
|
|
30
|
+
var import_name = require("../name.cjs");
|
|
31
|
+
var import_utils = require("./utils.cjs");
|
|
32
|
+
var import_crdt_user_selections = require("../utils/crdt-user-selections.cjs");
|
|
33
|
+
var PostEditorAwareness = class extends import_sync.AwarenessState {
|
|
34
|
+
constructor(doc, kind, name, postId) {
|
|
35
|
+
super(doc);
|
|
36
|
+
this.kind = kind;
|
|
37
|
+
this.name = name;
|
|
38
|
+
this.postId = postId;
|
|
39
|
+
}
|
|
40
|
+
equalityFieldChecks = {
|
|
41
|
+
editorState: this.areEditorStatesEqual,
|
|
42
|
+
userInfo: import_utils.areUserInfosEqual
|
|
43
|
+
};
|
|
44
|
+
setUp() {
|
|
45
|
+
super.setUp();
|
|
46
|
+
this.setCurrentUserInfo();
|
|
47
|
+
this.subscribeToUserSelectionChanges();
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Set the current user info in the local state.
|
|
51
|
+
*/
|
|
52
|
+
setCurrentUserInfo() {
|
|
53
|
+
const states = this.getStates();
|
|
54
|
+
const otherUserColors = Array.from(states.entries()).filter(
|
|
55
|
+
([clientId, state]) => state.userInfo && clientId !== this.clientID
|
|
56
|
+
).map(([, state]) => state.userInfo.color).filter(Boolean);
|
|
57
|
+
const currentUser = (0, import_data.select)(import_name.STORE_NAME).getCurrentUser();
|
|
58
|
+
const userInfo = (0, import_utils.generateUserInfo)(currentUser, otherUserColors);
|
|
59
|
+
this.setLocalStateField("userInfo", userInfo);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Subscribe to user selection changes and update the selection state.
|
|
63
|
+
*/
|
|
64
|
+
subscribeToUserSelectionChanges() {
|
|
65
|
+
const {
|
|
66
|
+
getSelectionStart,
|
|
67
|
+
getSelectionEnd,
|
|
68
|
+
getSelectedBlocksInitialCaretPosition
|
|
69
|
+
} = (0, import_data.select)(import_block_editor.store);
|
|
70
|
+
let selectionStart = getSelectionStart();
|
|
71
|
+
let selectionEnd = getSelectionEnd();
|
|
72
|
+
let localCursorTimeout = null;
|
|
73
|
+
(0, import_data.subscribe)(() => {
|
|
74
|
+
const newSelectionStart = getSelectionStart();
|
|
75
|
+
const newSelectionEnd = getSelectionEnd();
|
|
76
|
+
if (newSelectionStart === selectionStart && newSelectionEnd === selectionEnd) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
selectionStart = newSelectionStart;
|
|
80
|
+
selectionEnd = newSelectionEnd;
|
|
81
|
+
const initialPosition = getSelectedBlocksInitialCaretPosition();
|
|
82
|
+
void this.updateSelectionInEntityRecord(
|
|
83
|
+
selectionStart,
|
|
84
|
+
selectionEnd,
|
|
85
|
+
initialPosition
|
|
86
|
+
);
|
|
87
|
+
if (localCursorTimeout) {
|
|
88
|
+
clearTimeout(localCursorTimeout);
|
|
89
|
+
}
|
|
90
|
+
localCursorTimeout = setTimeout(() => {
|
|
91
|
+
const selectionState = (0, import_crdt_user_selections.getSelectionState)(
|
|
92
|
+
selectionStart,
|
|
93
|
+
selectionEnd,
|
|
94
|
+
this.doc
|
|
95
|
+
);
|
|
96
|
+
this.setThrottledLocalStateField(
|
|
97
|
+
"editorState",
|
|
98
|
+
{ selection: selectionState },
|
|
99
|
+
import_config.AWARENESS_CURSOR_UPDATE_THROTTLE_IN_MS
|
|
100
|
+
);
|
|
101
|
+
}, import_config.LOCAL_CURSOR_UPDATE_DEBOUNCE_IN_MS);
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Update the entity record with the current user's selection.
|
|
106
|
+
*
|
|
107
|
+
* @param selectionStart - The start position of the selection.
|
|
108
|
+
* @param selectionEnd - The end position of the selection.
|
|
109
|
+
* @param initialPosition - The initial position of the selection.
|
|
110
|
+
*/
|
|
111
|
+
async updateSelectionInEntityRecord(selectionStart, selectionEnd, initialPosition) {
|
|
112
|
+
const edits = {
|
|
113
|
+
selection: { selectionStart, selectionEnd, initialPosition }
|
|
114
|
+
};
|
|
115
|
+
const options = {
|
|
116
|
+
undoIgnore: true
|
|
117
|
+
};
|
|
118
|
+
(0, import_data.dispatch)(import_name.STORE_NAME).editEntityRecord(
|
|
119
|
+
this.kind,
|
|
120
|
+
this.name,
|
|
121
|
+
this.postId,
|
|
122
|
+
edits,
|
|
123
|
+
options
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Check if two editor states are equal.
|
|
128
|
+
*
|
|
129
|
+
* @param state1 - The first editor state.
|
|
130
|
+
* @param state2 - The second editor state.
|
|
131
|
+
* @return True if the editor states are equal, false otherwise.
|
|
132
|
+
*/
|
|
133
|
+
areEditorStatesEqual(state1, state2) {
|
|
134
|
+
if (!state1 || !state2) {
|
|
135
|
+
return state1 === state2;
|
|
136
|
+
}
|
|
137
|
+
return (0, import_crdt_user_selections.areSelectionsStatesEqual)(state1.selection, state2.selection);
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
141
|
+
0 && (module.exports = {
|
|
142
|
+
PostEditorAwareness
|
|
143
|
+
});
|
|
144
|
+
//# sourceMappingURL=post-editor-awareness.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/awareness/post-editor-awareness.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { dispatch, select, subscribe } from '@wordpress/data';\nimport { AwarenessState, type Y } from '@wordpress/sync';\n// @ts-ignore No exported types for block editor store selectors.\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport {\n\tAWARENESS_CURSOR_UPDATE_THROTTLE_IN_MS,\n\tLOCAL_CURSOR_UPDATE_DEBOUNCE_IN_MS,\n} from './config';\nimport { STORE_NAME as coreStore } from '../name';\nimport { generateUserInfo, areUserInfosEqual } from './utils';\nimport {\n\tareSelectionsStatesEqual,\n\tgetSelectionState,\n} from '../utils/crdt-user-selections';\n\nimport type { WPBlockSelection } from '../types';\nimport type { EditorState, PostEditorState } from './types';\n\nexport class PostEditorAwareness extends AwarenessState< PostEditorState > {\n\tprotected equalityFieldChecks = {\n\t\teditorState: this.areEditorStatesEqual,\n\t\tuserInfo: areUserInfosEqual,\n\t};\n\n\tpublic constructor(\n\t\tdoc: Y.Doc,\n\t\tprivate kind: string,\n\t\tprivate name: string,\n\t\tprivate postId: number\n\t) {\n\t\tsuper( doc );\n\t}\n\n\tpublic setUp(): void {\n\t\tsuper.setUp();\n\n\t\tthis.setCurrentUserInfo();\n\t\tthis.subscribeToUserSelectionChanges();\n\t}\n\n\t/**\n\t * Set the current user info in the local state.\n\t */\n\tprivate setCurrentUserInfo(): void {\n\t\tconst states = this.getStates();\n\t\tconst otherUserColors = Array.from( states.entries() )\n\t\t\t.filter(\n\t\t\t\t( [ clientId, state ] ) =>\n\t\t\t\t\tstate.userInfo && clientId !== this.clientID\n\t\t\t)\n\t\t\t.map( ( [ , state ] ) => state.userInfo.color )\n\t\t\t.filter( Boolean );\n\n\t\t// Get current user info and set it in local state.\n\t\tconst currentUser = select( coreStore ).getCurrentUser();\n\t\tconst userInfo = generateUserInfo( currentUser, otherUserColors );\n\t\tthis.setLocalStateField( 'userInfo', userInfo );\n\t}\n\n\t/**\n\t * Subscribe to user selection changes and update the selection state.\n\t */\n\tprivate subscribeToUserSelectionChanges(): void {\n\t\tconst {\n\t\t\tgetSelectionStart,\n\t\t\tgetSelectionEnd,\n\t\t\tgetSelectedBlocksInitialCaretPosition,\n\t\t} = select( blockEditorStore );\n\n\t\t// Keep track of the current selection in the outer scope so we can compare\n\t\t// in the subscription.\n\t\tlet selectionStart = getSelectionStart();\n\t\tlet selectionEnd = getSelectionEnd();\n\t\tlet localCursorTimeout: NodeJS.Timeout | null = null;\n\n\t\tsubscribe( () => {\n\t\t\tconst newSelectionStart = getSelectionStart();\n\t\t\tconst newSelectionEnd = getSelectionEnd();\n\n\t\t\tif (\n\t\t\t\tnewSelectionStart === selectionStart &&\n\t\t\t\tnewSelectionEnd === selectionEnd\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tselectionStart = newSelectionStart;\n\t\t\tselectionEnd = newSelectionEnd;\n\n\t\t\t// Typically selection position is only persisted after typing in a block, which\n\t\t\t// can cause selection position to be reset by other users making block updates.\n\t\t\t// Ensure we update the controlled selection right away, persisting our cursor position locally.\n\t\t\tconst initialPosition = getSelectedBlocksInitialCaretPosition();\n\t\t\tvoid this.updateSelectionInEntityRecord(\n\t\t\t\tselectionStart,\n\t\t\t\tselectionEnd,\n\t\t\t\tinitialPosition\n\t\t\t);\n\n\t\t\t// We receive two selection changes in quick succession\n\t\t\t// from local selection events:\n\t\t\t// { clientId: \"123...\", attributeKey: \"content\", offset: undefined }\n\t\t\t// { clientId: \"123...\", attributeKey: \"content\", offset: 554 }\n\t\t\t// Add a short debounce to avoid sending the first selection change.\n\t\t\tif ( localCursorTimeout ) {\n\t\t\t\tclearTimeout( localCursorTimeout );\n\t\t\t}\n\n\t\t\tlocalCursorTimeout = setTimeout( () => {\n\t\t\t\tconst selectionState = getSelectionState(\n\t\t\t\t\tselectionStart,\n\t\t\t\t\tselectionEnd,\n\t\t\t\t\tthis.doc\n\t\t\t\t);\n\n\t\t\t\tthis.setThrottledLocalStateField(\n\t\t\t\t\t'editorState',\n\t\t\t\t\t{ selection: selectionState },\n\t\t\t\t\tAWARENESS_CURSOR_UPDATE_THROTTLE_IN_MS\n\t\t\t\t);\n\t\t\t}, LOCAL_CURSOR_UPDATE_DEBOUNCE_IN_MS );\n\t\t} );\n\t}\n\n\t/**\n\t * Update the entity record with the current user's selection.\n\t *\n\t * @param selectionStart - The start position of the selection.\n\t * @param selectionEnd - The end position of the selection.\n\t * @param initialPosition - The initial position of the selection.\n\t */\n\tprivate async updateSelectionInEntityRecord(\n\t\tselectionStart: WPBlockSelection,\n\t\tselectionEnd: WPBlockSelection,\n\t\tinitialPosition: number | null\n\t): Promise< void > {\n\t\t// Send an entityRecord `selection` update if we have a selection.\n\t\t//\n\t\t// Normally WordPress updates the `selection` property of the post when changes are made to blocks.\n\t\t// In a multi-user setup, block changes can occur from other users. When an entity is updated from another\n\t\t// user's changes, useBlockSync() in Gutenberg will reset the user's selection to the last saved selection.\n\t\t//\n\t\t// Manually adding an edit for each movement ensures that other user's changes to the document will\n\t\t// not cause the local user's selection to reset to the last local change location.\n\t\tconst edits = {\n\t\t\tselection: { selectionStart, selectionEnd, initialPosition },\n\t\t};\n\n\t\tconst options = {\n\t\t\tundoIgnore: true,\n\t\t};\n\n\t\t// @ts-ignore Types are not provided when using store name instead of store instance.\n\t\tdispatch( coreStore ).editEntityRecord(\n\t\t\tthis.kind,\n\t\t\tthis.name,\n\t\t\tthis.postId,\n\t\t\tedits,\n\t\t\toptions\n\t\t);\n\t}\n\n\t/**\n\t * Check if two editor states are equal.\n\t *\n\t * @param state1 - The first editor state.\n\t * @param state2 - The second editor state.\n\t * @return True if the editor states are equal, false otherwise.\n\t */\n\tprivate areEditorStatesEqual(\n\t\tstate1?: EditorState,\n\t\tstate2?: EditorState\n\t): boolean {\n\t\tif ( ! state1 || ! state2 ) {\n\t\t\treturn state1 === state2;\n\t\t}\n\n\t\treturn areSelectionsStatesEqual( state1.selection, state2.selection );\n\t}\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAA4C;AAC5C,kBAAuC;AAEvC,0BAA0C;AAK1C,oBAGO;AACP,kBAAwC;AACxC,mBAAoD;AACpD,kCAGO;AAKA,IAAM,sBAAN,cAAkC,2BAAkC;AAAA,EAMnE,YACN,KACQ,MACA,MACA,QACP;AACD,UAAO,GAAI;AAJH;AACA;AACA;AAAA,EAGT;AAAA,EAZU,sBAAsB;AAAA,IAC/B,aAAa,KAAK;AAAA,IAClB,UAAU;AAAA,EACX;AAAA,EAWO,QAAc;AACpB,UAAM,MAAM;AAEZ,SAAK,mBAAmB;AACxB,SAAK,gCAAgC;AAAA,EACtC;AAAA;AAAA;AAAA;AAAA,EAKQ,qBAA2B;AAClC,UAAM,SAAS,KAAK,UAAU;AAC9B,UAAM,kBAAkB,MAAM,KAAM,OAAO,QAAQ,CAAE,EACnD;AAAA,MACA,CAAE,CAAE,UAAU,KAAM,MACnB,MAAM,YAAY,aAAa,KAAK;AAAA,IACtC,EACC,IAAK,CAAE,CAAE,EAAE,KAAM,MAAO,MAAM,SAAS,KAAM,EAC7C,OAAQ,OAAQ;AAGlB,UAAM,kBAAc,oBAAQ,YAAAA,UAAU,EAAE,eAAe;AACvD,UAAM,eAAW,+BAAkB,aAAa,eAAgB;AAChE,SAAK,mBAAoB,YAAY,QAAS;AAAA,EAC/C;AAAA;AAAA;AAAA;AAAA,EAKQ,kCAAwC;AAC/C,UAAM;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,IACD,QAAI,oBAAQ,oBAAAC,KAAiB;AAI7B,QAAI,iBAAiB,kBAAkB;AACvC,QAAI,eAAe,gBAAgB;AACnC,QAAI,qBAA4C;AAEhD,+BAAW,MAAM;AAChB,YAAM,oBAAoB,kBAAkB;AAC5C,YAAM,kBAAkB,gBAAgB;AAExC,UACC,sBAAsB,kBACtB,oBAAoB,cACnB;AACD;AAAA,MACD;AAEA,uBAAiB;AACjB,qBAAe;AAKf,YAAM,kBAAkB,sCAAsC;AAC9D,WAAK,KAAK;AAAA,QACT;AAAA,QACA;AAAA,QACA;AAAA,MACD;AAOA,UAAK,oBAAqB;AACzB,qBAAc,kBAAmB;AAAA,MAClC;AAEA,2BAAqB,WAAY,MAAM;AACtC,cAAM,qBAAiB;AAAA,UACtB;AAAA,UACA;AAAA,UACA,KAAK;AAAA,QACN;AAEA,aAAK;AAAA,UACJ;AAAA,UACA,EAAE,WAAW,eAAe;AAAA,UAC5B;AAAA,QACD;AAAA,MACD,GAAG,gDAAmC;AAAA,IACvC,CAAE;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,MAAc,8BACb,gBACA,cACA,iBACkB;AASlB,UAAM,QAAQ;AAAA,MACb,WAAW,EAAE,gBAAgB,cAAc,gBAAgB;AAAA,IAC5D;AAEA,UAAM,UAAU;AAAA,MACf,YAAY;AAAA,IACb;AAGA,8BAAU,YAAAD,UAAU,EAAE;AAAA,MACrB,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL;AAAA,MACA;AAAA,IACD;AAAA,EACD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASQ,qBACP,QACA,QACU;AACV,QAAK,CAAE,UAAU,CAAE,QAAS;AAC3B,aAAO,WAAW;AAAA,IACnB;AAEA,eAAO,sDAA0B,OAAO,WAAW,OAAO,SAAU;AAAA,EACrE;AACD;",
|
|
6
|
+
"names": ["coreStore", "blockEditorStore"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
|
|
16
|
+
// packages/core-data/src/awareness/types.ts
|
|
17
|
+
var types_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(types_exports);
|
|
19
|
+
//# sourceMappingURL=types.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/awareness/types.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport type { SelectionState } from '../utils/crdt-user-selections';\nimport type { User } from '../entity-types';\n\nexport type UserInfo = Pick<\n\tUser< 'view' >,\n\t'id' | 'name' | 'slug' | 'avatar_urls'\n> & {\n\tbrowserType: string;\n\tcolor: string;\n\tenteredAt: number;\n};\n\n/**\n * This base state represents the presence of the user. We expect it to be\n * extended to include additional state describing the user's current activity.\n * This state must be serializable and compact.\n */\nexport interface BaseState {\n\tuserInfo: UserInfo;\n}\n\n/**\n * The editor state includes information about the user's current selection.\n */\nexport interface EditorState {\n\tselection: SelectionState;\n}\n\n/**\n * The post editor state extends the base state with information used to render\n * presence indicators in the post editor.\n */\nexport interface PostEditorState extends BaseState {\n\teditorState?: EditorState;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;AAAA;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// packages/core-data/src/awareness/utils.ts
|
|
21
|
+
var utils_exports = {};
|
|
22
|
+
__export(utils_exports, {
|
|
23
|
+
areUserInfosEqual: () => areUserInfosEqual,
|
|
24
|
+
generateUserInfo: () => generateUserInfo
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(utils_exports);
|
|
27
|
+
var COLOR_PALETTE = [
|
|
28
|
+
"#3858E9",
|
|
29
|
+
// blueberry
|
|
30
|
+
"#B42AED",
|
|
31
|
+
// purple
|
|
32
|
+
"#E33184",
|
|
33
|
+
// pink
|
|
34
|
+
"#F3661D",
|
|
35
|
+
// orange
|
|
36
|
+
"#ECBD3A",
|
|
37
|
+
// yellow
|
|
38
|
+
"#97FE17",
|
|
39
|
+
// green
|
|
40
|
+
"#00FDD9",
|
|
41
|
+
// teal
|
|
42
|
+
"#37C5F0"
|
|
43
|
+
// cyan
|
|
44
|
+
];
|
|
45
|
+
function generateRandomInt(min, max) {
|
|
46
|
+
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
47
|
+
}
|
|
48
|
+
function getNewUserColor(existingColors) {
|
|
49
|
+
const availableColors = COLOR_PALETTE.filter(
|
|
50
|
+
(color) => !existingColors.includes(color)
|
|
51
|
+
);
|
|
52
|
+
let hexColor;
|
|
53
|
+
if (availableColors.length > 0) {
|
|
54
|
+
const randomIndex = generateRandomInt(0, availableColors.length - 1);
|
|
55
|
+
hexColor = availableColors[randomIndex];
|
|
56
|
+
} else {
|
|
57
|
+
const randomIndex = generateRandomInt(0, COLOR_PALETTE.length - 1);
|
|
58
|
+
const baseColor = COLOR_PALETTE[randomIndex];
|
|
59
|
+
hexColor = generateColorVariation(baseColor);
|
|
60
|
+
}
|
|
61
|
+
return hexColor;
|
|
62
|
+
}
|
|
63
|
+
function generateColorVariation(hexColor) {
|
|
64
|
+
const r = parseInt(hexColor.slice(1, 3), 16);
|
|
65
|
+
const g = parseInt(hexColor.slice(3, 5), 16);
|
|
66
|
+
const b = parseInt(hexColor.slice(5, 7), 16);
|
|
67
|
+
const shift = generateRandomInt(-30, 30);
|
|
68
|
+
const newR = Math.min(255, Math.max(0, r + shift));
|
|
69
|
+
const newG = Math.min(255, Math.max(0, g + shift));
|
|
70
|
+
const newB = Math.min(255, Math.max(0, b + shift));
|
|
71
|
+
const toHex = (n) => n.toString(16).padStart(2, "0").toUpperCase();
|
|
72
|
+
return `#${toHex(newR)}${toHex(newG)}${toHex(newB)}`;
|
|
73
|
+
}
|
|
74
|
+
function getBrowserName() {
|
|
75
|
+
const userAgent = window.navigator.userAgent;
|
|
76
|
+
let browserName = "Unknown";
|
|
77
|
+
if (userAgent.includes("Firefox")) {
|
|
78
|
+
browserName = "Firefox";
|
|
79
|
+
} else if (userAgent.includes("Edg")) {
|
|
80
|
+
browserName = "Microsoft Edge";
|
|
81
|
+
} else if (userAgent.includes("Chrome") && !userAgent.includes("Edg")) {
|
|
82
|
+
browserName = "Chrome";
|
|
83
|
+
} else if (userAgent.includes("Safari") && !userAgent.includes("Chrome")) {
|
|
84
|
+
browserName = "Safari";
|
|
85
|
+
} else if (userAgent.includes("MSIE") || userAgent.includes("Trident")) {
|
|
86
|
+
browserName = "Internet Explorer";
|
|
87
|
+
} else if (userAgent.includes("Opera") || userAgent.includes("OPR")) {
|
|
88
|
+
browserName = "Opera";
|
|
89
|
+
}
|
|
90
|
+
return browserName;
|
|
91
|
+
}
|
|
92
|
+
function areUserInfosEqual(userInfo1, userInfo2) {
|
|
93
|
+
if (!userInfo1 || !userInfo2) {
|
|
94
|
+
return userInfo1 === userInfo2;
|
|
95
|
+
}
|
|
96
|
+
if (Object.keys(userInfo1).length !== Object.keys(userInfo2).length) {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
return Object.entries(userInfo1).every(([key, value]) => {
|
|
100
|
+
return value === userInfo2[key];
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
function generateUserInfo(currentUser, existingColors) {
|
|
104
|
+
return {
|
|
105
|
+
...currentUser,
|
|
106
|
+
browserType: getBrowserName(),
|
|
107
|
+
color: getNewUserColor(existingColors),
|
|
108
|
+
enteredAt: Date.now()
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
112
|
+
0 && (module.exports = {
|
|
113
|
+
areUserInfosEqual,
|
|
114
|
+
generateUserInfo
|
|
115
|
+
});
|
|
116
|
+
//# sourceMappingURL=utils.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/awareness/utils.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport type { User } from '../entity-types';\nimport type { UserInfo } from './types';\n\n/**\n * The color palette for the user highlight.\n */\nconst COLOR_PALETTE = [\n\t'#3858E9', // blueberry\n\t'#B42AED', // purple\n\t'#E33184', // pink\n\t'#F3661D', // orange\n\t'#ECBD3A', // yellow\n\t'#97FE17', // green\n\t'#00FDD9', // teal\n\t'#37C5F0', // cyan\n];\n\n/**\n * Generate a random integer between min and max, inclusive.\n *\n * @param min - The minimum value.\n * @param max - The maximum value.\n * @return A random integer between min and max.\n */\nfunction generateRandomInt( min: number, max: number ): number {\n\treturn Math.floor( Math.random() * ( max - min + 1 ) ) + min;\n}\n\n/**\n * Get a unique user color from the palette, or generate a variation if none are available.\n * If the previously used color is available from localStorage, use it.\n *\n * @param existingColors - Colors that are already in use.\n * @return The new user color, in hex format.\n */\nfunction getNewUserColor( existingColors: string[] ): string {\n\tconst availableColors = COLOR_PALETTE.filter(\n\t\t( color ) => ! existingColors.includes( color )\n\t);\n\n\tlet hexColor: string;\n\n\tif ( availableColors.length > 0 ) {\n\t\tconst randomIndex = generateRandomInt( 0, availableColors.length - 1 );\n\t\thexColor = availableColors[ randomIndex ];\n\t} else {\n\t\t// All colors are used, generate a variation of a random palette color\n\t\tconst randomIndex = generateRandomInt( 0, COLOR_PALETTE.length - 1 );\n\t\tconst baseColor = COLOR_PALETTE[ randomIndex ];\n\t\thexColor = generateColorVariation( baseColor );\n\t}\n\n\treturn hexColor;\n}\n\n/**\n * Generate a variation of a hex color by adjusting its lightness.\n *\n * @param hexColor - The base hex color (e.g., '#3858E9').\n * @return A varied hex color.\n */\nfunction generateColorVariation( hexColor: string ): string {\n\t// Parse hex to RGB\n\tconst r = parseInt( hexColor.slice( 1, 3 ), 16 );\n\tconst g = parseInt( hexColor.slice( 3, 5 ), 16 );\n\tconst b = parseInt( hexColor.slice( 5, 7 ), 16 );\n\n\t// Apply a random lightness shift (-30 to +30)\n\tconst shift = generateRandomInt( -30, 30 );\n\tconst newR = Math.min( 255, Math.max( 0, r + shift ) );\n\tconst newG = Math.min( 255, Math.max( 0, g + shift ) );\n\tconst newB = Math.min( 255, Math.max( 0, b + shift ) );\n\n\t// Convert back to hex\n\tconst toHex = ( n: number ) =>\n\t\tn.toString( 16 ).padStart( 2, '0' ).toUpperCase();\n\treturn `#${ toHex( newR ) }${ toHex( newG ) }${ toHex( newB ) }`;\n}\n\n/**\n * Get the browser name from the user agent.\n * @return The browser name.\n */\nfunction getBrowserName(): string {\n\tconst userAgent = window.navigator.userAgent;\n\tlet browserName = 'Unknown';\n\n\tif ( userAgent.includes( 'Firefox' ) ) {\n\t\tbrowserName = 'Firefox';\n\t} else if ( userAgent.includes( 'Edg' ) ) {\n\t\tbrowserName = 'Microsoft Edge';\n\t} else if (\n\t\tuserAgent.includes( 'Chrome' ) &&\n\t\t! userAgent.includes( 'Edg' )\n\t) {\n\t\tbrowserName = 'Chrome';\n\t} else if (\n\t\tuserAgent.includes( 'Safari' ) &&\n\t\t! userAgent.includes( 'Chrome' )\n\t) {\n\t\tbrowserName = 'Safari';\n\t} else if (\n\t\tuserAgent.includes( 'MSIE' ) ||\n\t\tuserAgent.includes( 'Trident' )\n\t) {\n\t\tbrowserName = 'Internet Explorer';\n\t} else if ( userAgent.includes( 'Opera' ) || userAgent.includes( 'OPR' ) ) {\n\t\tbrowserName = 'Opera';\n\t}\n\n\treturn browserName;\n}\n\n/**\n * Check if two user infos are equal.\n *\n * @param userInfo1 - The first user info.\n * @param userInfo2 - The second user info.\n * @return True if the user infos are equal, false otherwise.\n */\nexport function areUserInfosEqual(\n\tuserInfo1?: UserInfo,\n\tuserInfo2?: UserInfo\n): boolean {\n\tif ( ! userInfo1 || ! userInfo2 ) {\n\t\treturn userInfo1 === userInfo2;\n\t}\n\n\tif ( Object.keys( userInfo1 ).length !== Object.keys( userInfo2 ).length ) {\n\t\treturn false;\n\t}\n\n\treturn Object.entries( userInfo1 ).every( ( [ key, value ] ) => {\n\t\t// Update this function with any non-primitive fields added to UserInfo.\n\t\treturn value === userInfo2[ key as keyof UserInfo ];\n\t} );\n}\n\n/**\n * Generate a user info object from a current user and a list of existing colors.\n *\n * @param currentUser - The current user.\n * @param existingColors - The existing colors.\n * @return The user info object.\n */\nexport function generateUserInfo(\n\tcurrentUser: User< 'view' >,\n\texistingColors: string[]\n): UserInfo {\n\treturn {\n\t\t...currentUser,\n\t\tbrowserType: getBrowserName(),\n\t\tcolor: getNewUserColor( existingColors ),\n\t\tenteredAt: Date.now(),\n\t};\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,IAAM,gBAAgB;AAAA,EACrB;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AACD;AASA,SAAS,kBAAmB,KAAa,KAAsB;AAC9D,SAAO,KAAK,MAAO,KAAK,OAAO,KAAM,MAAM,MAAM,EAAI,IAAI;AAC1D;AASA,SAAS,gBAAiB,gBAAmC;AAC5D,QAAM,kBAAkB,cAAc;AAAA,IACrC,CAAE,UAAW,CAAE,eAAe,SAAU,KAAM;AAAA,EAC/C;AAEA,MAAI;AAEJ,MAAK,gBAAgB,SAAS,GAAI;AACjC,UAAM,cAAc,kBAAmB,GAAG,gBAAgB,SAAS,CAAE;AACrE,eAAW,gBAAiB,WAAY;AAAA,EACzC,OAAO;AAEN,UAAM,cAAc,kBAAmB,GAAG,cAAc,SAAS,CAAE;AACnE,UAAM,YAAY,cAAe,WAAY;AAC7C,eAAW,uBAAwB,SAAU;AAAA,EAC9C;AAEA,SAAO;AACR;AAQA,SAAS,uBAAwB,UAA2B;AAE3D,QAAM,IAAI,SAAU,SAAS,MAAO,GAAG,CAAE,GAAG,EAAG;AAC/C,QAAM,IAAI,SAAU,SAAS,MAAO,GAAG,CAAE,GAAG,EAAG;AAC/C,QAAM,IAAI,SAAU,SAAS,MAAO,GAAG,CAAE,GAAG,EAAG;AAG/C,QAAM,QAAQ,kBAAmB,KAAK,EAAG;AACzC,QAAM,OAAO,KAAK,IAAK,KAAK,KAAK,IAA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A,IACN,GAAG;AAAA,IACH,aAAa,eAAe;AAAA,IAC5B,OAAO,gBAAiB,cAAe;AAAA,IACvC,WAAW,KAAK,IAAI;AAAA,EACrB;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/build/entities.cjs
CHANGED
|
@@ -42,6 +42,7 @@ var import_change_case = require("change-case");
|
|
|
42
42
|
var import_api_fetch = __toESM(require("@wordpress/api-fetch"));
|
|
43
43
|
var import_blocks = require("@wordpress/blocks");
|
|
44
44
|
var import_i18n = require("@wordpress/i18n");
|
|
45
|
+
var import_post_editor_awareness = require("./awareness/post-editor-awareness.cjs");
|
|
45
46
|
var import_sync = require("./sync.cjs");
|
|
46
47
|
var import_crdt = require("./utils/crdt.cjs");
|
|
47
48
|
var DEFAULT_ENTITY_KEY = "id";
|
|
@@ -323,6 +324,18 @@ async function loadPostTypeEntities() {
|
|
|
323
324
|
* @return {void}
|
|
324
325
|
*/
|
|
325
326
|
applyChangesToCRDTDoc: (crdtDoc, changes) => (0, import_crdt.applyPostChangesToCRDTDoc)(crdtDoc, changes, postType),
|
|
327
|
+
/**
|
|
328
|
+
* Create the awareness instance for the entity's CRDT document.
|
|
329
|
+
*
|
|
330
|
+
* @param {import('@wordpress/sync').CRDTDoc} ydoc
|
|
331
|
+
* @param {import('@wordpress/sync').ObjectID} objectId
|
|
332
|
+
* @return {import('@wordpress/sync').AwarenessState} AwarenessState instance
|
|
333
|
+
*/
|
|
334
|
+
createAwareness: (ydoc, objectId) => {
|
|
335
|
+
const kind = "postType";
|
|
336
|
+
const id = parseInt(objectId, 10);
|
|
337
|
+
return new import_post_editor_awareness.PostEditorAwareness(ydoc, kind, name, id);
|
|
338
|
+
},
|
|
326
339
|
/**
|
|
327
340
|
* Extract changes from a CRDT document that can be used to update the
|
|
328
341
|
* local editor state.
|
package/build/entities.cjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/entities.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport { capitalCase, pascalCase } from 'change-case';\n\n/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\nimport { __unstableSerializeAndClean, parse } from '@wordpress/blocks';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { getSyncManager } from './sync';\nimport {\n\tapplyPostChangesToCRDTDoc,\n\tgetPostChangesFromCRDTDoc,\n} from './utils/crdt';\n\nexport const DEFAULT_ENTITY_KEY = 'id';\nconst POST_RAW_ATTRIBUTES = [ 'title', 'excerpt', 'content' ];\n\nconst blocksTransientEdits = {\n\tblocks: {\n\t\tread: ( record ) => parse( record.content?.raw ?? '' ),\n\t\twrite: ( record ) => ( {\n\t\t\tcontent: __unstableSerializeAndClean( record.blocks ),\n\t\t} ),\n\t},\n};\n\nexport const rootEntitiesConfig = [\n\t{\n\t\tlabel: __( 'Base' ),\n\t\tkind: 'root',\n\t\tkey: false,\n\t\tname: '__unstableBase',\n\t\tbaseURL: '/',\n\t\tbaseURLParams: {\n\t\t\t// Please also change the preload path when changing this.\n\t\t\t// @see lib/compat/wordpress-6.8/preload.php\n\t\t\t_fields: [\n\t\t\t\t'description',\n\t\t\t\t'gmt_offset',\n\t\t\t\t'home',\n\t\t\t\t'name',\n\t\t\t\t'site_icon',\n\t\t\t\t'site_icon_url',\n\t\t\t\t'site_logo',\n\t\t\t\t'timezone_string',\n\t\t\t\t'url',\n\t\t\t\t'page_for_posts',\n\t\t\t\t'page_on_front',\n\t\t\t\t'show_on_front',\n\t\t\t].join( ',' ),\n\t\t},\n\t\t// The entity doesn't support selecting multiple records.\n\t\t// The property is maintained for backward compatibility.\n\t\tplural: '__unstableBases',\n\t},\n\t{\n\t\tlabel: __( 'Post Type' ),\n\t\tname: 'postType',\n\t\tkind: 'root',\n\t\tkey: 'slug',\n\t\tbaseURL: '/wp/v2/types',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'postTypes',\n\t},\n\t{\n\t\tname: 'media',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/media',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'mediaItems',\n\t\tlabel: __( 'Media' ),\n\t\trawAttributes: [ 'caption', 'title', 'description' ],\n\t\tsupportsPagination: true,\n\t},\n\t{\n\t\tname: 'taxonomy',\n\t\tkind: 'root',\n\t\tkey: 'slug',\n\t\tbaseURL: '/wp/v2/taxonomies',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'taxonomies',\n\t\tlabel: __( 'Taxonomy' ),\n\t},\n\t{\n\t\tname: 'sidebar',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/sidebars',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'sidebars',\n\t\ttransientEdits: { blocks: true },\n\t\tlabel: __( 'Widget areas' ),\n\t},\n\t{\n\t\tname: 'widget',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/widgets',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'widgets',\n\t\ttransientEdits: { blocks: true },\n\t\tlabel: __( 'Widgets' ),\n\t},\n\t{\n\t\tname: 'widgetType',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/widget-types',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'widgetTypes',\n\t\tlabel: __( 'Widget types' ),\n\t},\n\t{\n\t\tlabel: __( 'User' ),\n\t\tname: 'user',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/users',\n\t\tgetTitle: ( record ) => record?.name || record?.slug,\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'users',\n\t\tsupportsPagination: true,\n\t},\n\t{\n\t\tname: 'comment',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/comments',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'comments',\n\t\tlabel: __( 'Comment' ),\n\t\tsupportsPagination: true,\n\t},\n\t{\n\t\tname: 'menu',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/menus',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'menus',\n\t\tlabel: __( 'Menu' ),\n\t\tsupportsPagination: true,\n\t},\n\t{\n\t\tname: 'menuItem',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/menu-items',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'menuItems',\n\t\tlabel: __( 'Menu Item' ),\n\t\trawAttributes: [ 'title' ],\n\t\tsupportsPagination: true,\n\t},\n\t{\n\t\tname: 'menuLocation',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/menu-locations',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'menuLocations',\n\t\tlabel: __( 'Menu Location' ),\n\t\tkey: 'name',\n\t},\n\t{\n\t\tlabel: __( 'Global Styles' ),\n\t\tname: 'globalStyles',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/global-styles',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'globalStylesVariations', // Should be different from name.\n\t\tgetTitle: () => __( 'Custom Styles' ),\n\t\tgetRevisionsUrl: ( parentId, revisionId ) =>\n\t\t\t`/wp/v2/global-styles/${ parentId }/revisions${\n\t\t\t\trevisionId ? '/' + revisionId : ''\n\t\t\t}`,\n\t\tsupportsPagination: true,\n\t},\n\t{\n\t\tlabel: __( 'Themes' ),\n\t\tname: 'theme',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/themes',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'themes',\n\t\tkey: 'stylesheet',\n\t},\n\t{\n\t\tlabel: __( 'Plugins' ),\n\t\tname: 'plugin',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/plugins',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'plugins',\n\t\tkey: 'plugin',\n\t},\n\t{\n\t\tlabel: __( 'Status' ),\n\t\tname: 'status',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/statuses',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'statuses',\n\t\tkey: 'slug',\n\t},\n\t{\n\t\tlabel: __( 'Registered Templates' ),\n\t\tname: 'registeredTemplate',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/registered-templates',\n\t\tkey: 'id',\n\t},\n\t{\n\t\tlabel: __( 'Font Collections' ),\n\t\tname: 'fontCollection',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/font-collections',\n\t\tbaseURLParams: { context: 'view' },\n\t\tplural: 'fontCollections',\n\t\tkey: 'slug',\n\t},\n];\n\nexport const deprecatedEntities = {\n\troot: {\n\t\tmedia: {\n\t\t\tsince: '6.9',\n\t\t\talternative: {\n\t\t\t\tkind: 'postType',\n\t\t\t\tname: 'attachment',\n\t\t\t},\n\t\t},\n\t},\n};\n\nexport const additionalEntityConfigLoaders = [\n\t{ kind: 'postType', loadEntities: loadPostTypeEntities },\n\t{ kind: 'taxonomy', loadEntities: loadTaxonomyEntities },\n\t{\n\t\tkind: 'root',\n\t\tname: 'site',\n\t\tplural: 'sites',\n\t\tloadEntities: loadSiteEntity,\n\t},\n];\n\n/**\n * Apply extra edits before persisting a post type.\n *\n * @param {Object} persistedRecord Already persisted Post\n * @param {Object} edits Edits.\n * @param {string} name Post type name.\n * @param {boolean} isTemplate Whether the post type is a template.\n * @return {Object} Updated edits.\n */\nexport const prePersistPostType = (\n\tpersistedRecord,\n\tedits,\n\tname,\n\tisTemplate\n) => {\n\tconst newEdits = {};\n\n\tif ( ! isTemplate && persistedRecord?.status === 'auto-draft' ) {\n\t\t// Saving an auto-draft should create a draft by default.\n\t\tif ( ! edits.status && ! newEdits.status ) {\n\t\t\tnewEdits.status = 'draft';\n\t\t}\n\n\t\t// Fix the auto-draft default title.\n\t\tif (\n\t\t\t( ! edits.title || edits.title === 'Auto Draft' ) &&\n\t\t\t! newEdits.title &&\n\t\t\t( ! persistedRecord?.title ||\n\t\t\t\tpersistedRecord?.title === 'Auto Draft' )\n\t\t) {\n\t\t\tnewEdits.title = '';\n\t\t}\n\t}\n\n\t// Add meta for persisted CRDT document.\n\tif ( globalThis.IS_GUTENBERG_PLUGIN ) {\n\t\tif ( persistedRecord ) {\n\t\t\tconst objectType = `postType/${ name }`;\n\t\t\tconst objectId = persistedRecord.id;\n\t\t\tconst meta = getSyncManager()?.createMeta( objectType, objectId );\n\t\t\tnewEdits.meta = {\n\t\t\t\t...edits.meta,\n\t\t\t\t...meta,\n\t\t\t};\n\t\t}\n\t}\n\n\treturn newEdits;\n};\n\n/**\n * Returns the list of post type entities.\n *\n * @return {Promise} Entities promise\n */\nasync function loadPostTypeEntities() {\n\tconst postTypes = await apiFetch( {\n\t\tpath: '/wp/v2/types?context=view',\n\t} );\n\treturn Object.entries( postTypes ?? {} ).map( ( [ name, postType ] ) => {\n\t\tconst isTemplate = [ 'wp_template', 'wp_template_part' ].includes(\n\t\t\tname\n\t\t);\n\t\tconst namespace = postType?.rest_namespace ?? 'wp/v2';\n\n\t\tconst entity = {\n\t\t\tkind: 'postType',\n\t\t\tbaseURL: `/${ namespace }/${ postType.rest_base }`,\n\t\t\tbaseURLParams: { context: 'edit' },\n\t\t\tname,\n\t\t\tlabel: postType.name,\n\t\t\ttransientEdits: {\n\t\t\t\t...blocksTransientEdits,\n\t\t\t\tselection: true,\n\t\t\t},\n\t\t\tmergedEdits: { meta: true },\n\t\t\trawAttributes: POST_RAW_ATTRIBUTES,\n\t\t\tgetTitle: ( record ) =>\n\t\t\t\trecord?.title?.rendered ||\n\t\t\t\trecord?.title ||\n\t\t\t\t( isTemplate\n\t\t\t\t\t? capitalCase( record.slug ?? '' )\n\t\t\t\t\t: String( record.id ) ),\n\t\t\t__unstablePrePersist: ( persistedRecord, edits ) =>\n\t\t\t\tprePersistPostType( persistedRecord, edits, name, isTemplate ),\n\t\t\t__unstable_rest_base: postType.rest_base,\n\t\t\tsupportsPagination: true,\n\t\t\tgetRevisionsUrl: ( parentId, revisionId ) =>\n\t\t\t\t`/${ namespace }/${\n\t\t\t\t\tpostType.rest_base\n\t\t\t\t}/${ parentId }/revisions${\n\t\t\t\t\trevisionId ? '/' + revisionId : ''\n\t\t\t\t}`,\n\t\t\trevisionKey:\n\t\t\t\tisTemplate && ! window?.__experimentalTemplateActivate\n\t\t\t\t\t? 'wp_id'\n\t\t\t\t\t: DEFAULT_ENTITY_KEY,\n\t\t};\n\n\t\tif ( globalThis.IS_GUTENBERG_PLUGIN ) {\n\t\t\t/**\n\t\t\t * @type {import('@wordpress/sync').SyncConfig}\n\t\t\t */\n\t\t\tentity.syncConfig = {\n\t\t\t\t/**\n\t\t\t\t * Apply changes from the local editor to the local CRDT document so\n\t\t\t\t * that those changes can be synced to other peers (via the provider).\n\t\t\t\t *\n\t\t\t\t * @param {import('@wordpress/sync').CRDTDoc} crdtDoc\n\t\t\t\t * @param {Partial< import('@wordpress/sync').ObjectData >} changes\n\t\t\t\t * @return {void}\n\t\t\t\t */\n\t\t\t\tapplyChangesToCRDTDoc: ( crdtDoc, changes ) =>\n\t\t\t\t\tapplyPostChangesToCRDTDoc( crdtDoc, changes, postType ),\n\n\t\t\t\t/**\n\t\t\t\t * Extract changes from a CRDT document that can be used to update the\n\t\t\t\t * local editor state.\n\t\t\t\t *\n\t\t\t\t * @param {import('@wordpress/sync').CRDTDoc} crdtDoc\n\t\t\t\t * @param {import('@wordpress/sync').ObjectData} editedRecord\n\t\t\t\t * @return {Partial< import('@wordpress/sync').ObjectData >} Changes to record\n\t\t\t\t */\n\t\t\t\tgetChangesFromCRDTDoc: ( crdtDoc, editedRecord ) =>\n\t\t\t\t\tgetPostChangesFromCRDTDoc(\n\t\t\t\t\t\tcrdtDoc,\n\t\t\t\t\t\teditedRecord,\n\t\t\t\t\t\tpostType\n\t\t\t\t\t),\n\n\t\t\t\t/**\n\t\t\t\t * Sync features supported by the entity.\n\t\t\t\t *\n\t\t\t\t * @type {Record< string, boolean >}\n\t\t\t\t */\n\t\t\t\tsupports: {\n\t\t\t\t\tcrdtPersistence: true,\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\n\t\treturn entity;\n\t} );\n}\n\n/**\n * Returns the list of the taxonomies entities.\n *\n * @return {Promise} Entities promise\n */\nasync function loadTaxonomyEntities() {\n\tconst taxonomies = await apiFetch( {\n\t\tpath: '/wp/v2/taxonomies?context=view',\n\t} );\n\treturn Object.entries( taxonomies ?? {} ).map( ( [ name, taxonomy ] ) => {\n\t\tconst namespace = taxonomy?.rest_namespace ?? 'wp/v2';\n\t\treturn {\n\t\t\tkind: 'taxonomy',\n\t\t\tbaseURL: `/${ namespace }/${ taxonomy.rest_base }`,\n\t\t\tbaseURLParams: { context: 'edit' },\n\t\t\tname,\n\t\t\tlabel: taxonomy.name,\n\t\t\tgetTitle: ( record ) => record?.name,\n\t\t\tsupportsPagination: true,\n\t\t};\n\t} );\n}\n\n/**\n * Returns the Site entity.\n *\n * @return {Promise} Entity promise\n */\nasync function loadSiteEntity() {\n\tconst entity = {\n\t\tlabel: __( 'Site' ),\n\t\tname: 'site',\n\t\tkind: 'root',\n\t\tkey: false,\n\t\tbaseURL: '/wp/v2/settings',\n\t\tmeta: {},\n\t};\n\n\tconst site = await apiFetch( {\n\t\tpath: entity.baseURL,\n\t\tmethod: 'OPTIONS',\n\t} );\n\n\tconst labels = {};\n\tObject.entries( site?.schema?.properties ?? {} ).forEach(\n\t\t( [ key, value ] ) => {\n\t\t\t// Ignore properties `title` and `type` keys.\n\t\t\tif ( typeof value === 'object' && value.title ) {\n\t\t\t\tlabels[ key ] = value.title;\n\t\t\t}\n\t\t}\n\t);\n\n\treturn [ { ...entity, meta: { labels } } ];\n}\n\n/**\n * Returns the entity's getter method name given its kind and name or plural name.\n *\n * @example\n * ```js\n * const nameSingular = getMethodName( 'root', 'theme', 'get' );\n * // nameSingular is getRootTheme\n *\n * const namePlural = getMethodName( 'root', 'themes', 'set' );\n * // namePlural is setRootThemes\n * ```\n *\n * @param {string} kind Entity kind.\n * @param {string} name Entity name or plural name.\n * @param {string} prefix Function prefix.\n *\n * @return {string} Method name\n */\nexport const getMethodName = ( kind, name, prefix = 'get' ) => {\n\tconst kindPrefix = kind === 'root' ? '' : pascalCase( kind );\n\tconst suffix = pascalCase( name );\n\treturn `${ prefix }${ kindPrefix }${ suffix }`;\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,yBAAwC;AAKxC,uBAAqB;AACrB,oBAAmD;AACnD,kBAAmB;AAKnB,kBAA+B;AAC/B,kBAGO;AAEA,IAAM,qBAAqB;AAClC,IAAM,sBAAsB,CAAE,SAAS,WAAW,SAAU;AAE5D,IAAM,uBAAuB;AAAA,EAC5B,QAAQ;AAAA,IACP,MAAM,CAAE,eAAY,qBAAO,OAAO,SAAS,OAAO,EAAG;AAAA,IACrD,OAAO,CAAE,YAAc;AAAA,MACtB,aAAS,2CAA6B,OAAO,MAAO;AAAA,IACrD;AAAA,EACD;AACD;AAEO,IAAM,qBAAqB;AAAA,EACjC;AAAA,IACC,WAAO,gBAAI,MAAO;AAAA,IAClB,MAAM;AAAA,IACN,KAAK;AAAA,IACL,MAAM;AAAA,IACN,SAAS;AAAA,IACT,eAAe;AAAA;AAAA;AAAA,MAGd,SAAS;AAAA,QACR;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACD,EAAE,KAAM,GAAI;AAAA,IACb;AAAA;AAAA;AAAA,IAGA,QAAQ;AAAA,EACT;AAAA,EACA;AAAA,IACC,WAAO,gBAAI,WAAY;AAAA,IACvB,MAAM;AAAA,IACN,MAAM;AAAA,IACN,KAAK;AAAA,IACL,SAAS;AAAA,IACT,eAAe,EAAE,SAAS,OAAO;AAAA,IACjC,QAAQ;AAAA,EACT;AAAA,EACA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AA,MACD,aACC,cAAc,CAAE,QAAQ,iCACrB,UACA;AAAA,IACL;AAEA,QAAK,WAAW,qBAAsB;AAIrC,aAAO,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QASnB,uBAAuB,CAAE,SAAS,gBACjC,uCAA2B,SAAS,SAAS,QAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport { capitalCase, pascalCase } from 'change-case';\n\n/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\nimport { __unstableSerializeAndClean, parse } from '@wordpress/blocks';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { PostEditorAwareness } from './awareness/post-editor-awareness';\nimport { getSyncManager } from './sync';\nimport {\n\tapplyPostChangesToCRDTDoc,\n\tgetPostChangesFromCRDTDoc,\n} from './utils/crdt';\n\nexport const DEFAULT_ENTITY_KEY = 'id';\nconst POST_RAW_ATTRIBUTES = [ 'title', 'excerpt', 'content' ];\n\nconst blocksTransientEdits = {\n\tblocks: {\n\t\tread: ( record ) => parse( record.content?.raw ?? '' ),\n\t\twrite: ( record ) => ( {\n\t\t\tcontent: __unstableSerializeAndClean( record.blocks ),\n\t\t} ),\n\t},\n};\n\nexport const rootEntitiesConfig = [\n\t{\n\t\tlabel: __( 'Base' ),\n\t\tkind: 'root',\n\t\tkey: false,\n\t\tname: '__unstableBase',\n\t\tbaseURL: '/',\n\t\tbaseURLParams: {\n\t\t\t// Please also change the preload path when changing this.\n\t\t\t// @see lib/compat/wordpress-6.8/preload.php\n\t\t\t_fields: [\n\t\t\t\t'description',\n\t\t\t\t'gmt_offset',\n\t\t\t\t'home',\n\t\t\t\t'name',\n\t\t\t\t'site_icon',\n\t\t\t\t'site_icon_url',\n\t\t\t\t'site_logo',\n\t\t\t\t'timezone_string',\n\t\t\t\t'url',\n\t\t\t\t'page_for_posts',\n\t\t\t\t'page_on_front',\n\t\t\t\t'show_on_front',\n\t\t\t].join( ',' ),\n\t\t},\n\t\t// The entity doesn't support selecting multiple records.\n\t\t// The property is maintained for backward compatibility.\n\t\tplural: '__unstableBases',\n\t},\n\t{\n\t\tlabel: __( 'Post Type' ),\n\t\tname: 'postType',\n\t\tkind: 'root',\n\t\tkey: 'slug',\n\t\tbaseURL: '/wp/v2/types',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'postTypes',\n\t},\n\t{\n\t\tname: 'media',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/media',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'mediaItems',\n\t\tlabel: __( 'Media' ),\n\t\trawAttributes: [ 'caption', 'title', 'description' ],\n\t\tsupportsPagination: true,\n\t},\n\t{\n\t\tname: 'taxonomy',\n\t\tkind: 'root',\n\t\tkey: 'slug',\n\t\tbaseURL: '/wp/v2/taxonomies',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'taxonomies',\n\t\tlabel: __( 'Taxonomy' ),\n\t},\n\t{\n\t\tname: 'sidebar',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/sidebars',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'sidebars',\n\t\ttransientEdits: { blocks: true },\n\t\tlabel: __( 'Widget areas' ),\n\t},\n\t{\n\t\tname: 'widget',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/widgets',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'widgets',\n\t\ttransientEdits: { blocks: true },\n\t\tlabel: __( 'Widgets' ),\n\t},\n\t{\n\t\tname: 'widgetType',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/widget-types',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'widgetTypes',\n\t\tlabel: __( 'Widget types' ),\n\t},\n\t{\n\t\tlabel: __( 'User' ),\n\t\tname: 'user',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/users',\n\t\tgetTitle: ( record ) => record?.name || record?.slug,\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'users',\n\t\tsupportsPagination: true,\n\t},\n\t{\n\t\tname: 'comment',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/comments',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'comments',\n\t\tlabel: __( 'Comment' ),\n\t\tsupportsPagination: true,\n\t},\n\t{\n\t\tname: 'menu',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/menus',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'menus',\n\t\tlabel: __( 'Menu' ),\n\t\tsupportsPagination: true,\n\t},\n\t{\n\t\tname: 'menuItem',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/menu-items',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'menuItems',\n\t\tlabel: __( 'Menu Item' ),\n\t\trawAttributes: [ 'title' ],\n\t\tsupportsPagination: true,\n\t},\n\t{\n\t\tname: 'menuLocation',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/menu-locations',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'menuLocations',\n\t\tlabel: __( 'Menu Location' ),\n\t\tkey: 'name',\n\t},\n\t{\n\t\tlabel: __( 'Global Styles' ),\n\t\tname: 'globalStyles',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/global-styles',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'globalStylesVariations', // Should be different from name.\n\t\tgetTitle: () => __( 'Custom Styles' ),\n\t\tgetRevisionsUrl: ( parentId, revisionId ) =>\n\t\t\t`/wp/v2/global-styles/${ parentId }/revisions${\n\t\t\t\trevisionId ? '/' + revisionId : ''\n\t\t\t}`,\n\t\tsupportsPagination: true,\n\t},\n\t{\n\t\tlabel: __( 'Themes' ),\n\t\tname: 'theme',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/themes',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'themes',\n\t\tkey: 'stylesheet',\n\t},\n\t{\n\t\tlabel: __( 'Plugins' ),\n\t\tname: 'plugin',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/plugins',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'plugins',\n\t\tkey: 'plugin',\n\t},\n\t{\n\t\tlabel: __( 'Status' ),\n\t\tname: 'status',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/statuses',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'statuses',\n\t\tkey: 'slug',\n\t},\n\t{\n\t\tlabel: __( 'Registered Templates' ),\n\t\tname: 'registeredTemplate',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/registered-templates',\n\t\tkey: 'id',\n\t},\n\t{\n\t\tlabel: __( 'Font Collections' ),\n\t\tname: 'fontCollection',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/font-collections',\n\t\tbaseURLParams: { context: 'view' },\n\t\tplural: 'fontCollections',\n\t\tkey: 'slug',\n\t},\n];\n\nexport const deprecatedEntities = {\n\troot: {\n\t\tmedia: {\n\t\t\tsince: '6.9',\n\t\t\talternative: {\n\t\t\t\tkind: 'postType',\n\t\t\t\tname: 'attachment',\n\t\t\t},\n\t\t},\n\t},\n};\n\nexport const additionalEntityConfigLoaders = [\n\t{ kind: 'postType', loadEntities: loadPostTypeEntities },\n\t{ kind: 'taxonomy', loadEntities: loadTaxonomyEntities },\n\t{\n\t\tkind: 'root',\n\t\tname: 'site',\n\t\tplural: 'sites',\n\t\tloadEntities: loadSiteEntity,\n\t},\n];\n\n/**\n * Apply extra edits before persisting a post type.\n *\n * @param {Object} persistedRecord Already persisted Post\n * @param {Object} edits Edits.\n * @param {string} name Post type name.\n * @param {boolean} isTemplate Whether the post type is a template.\n * @return {Object} Updated edits.\n */\nexport const prePersistPostType = (\n\tpersistedRecord,\n\tedits,\n\tname,\n\tisTemplate\n) => {\n\tconst newEdits = {};\n\n\tif ( ! isTemplate && persistedRecord?.status === 'auto-draft' ) {\n\t\t// Saving an auto-draft should create a draft by default.\n\t\tif ( ! edits.status && ! newEdits.status ) {\n\t\t\tnewEdits.status = 'draft';\n\t\t}\n\n\t\t// Fix the auto-draft default title.\n\t\tif (\n\t\t\t( ! edits.title || edits.title === 'Auto Draft' ) &&\n\t\t\t! newEdits.title &&\n\t\t\t( ! persistedRecord?.title ||\n\t\t\t\tpersistedRecord?.title === 'Auto Draft' )\n\t\t) {\n\t\t\tnewEdits.title = '';\n\t\t}\n\t}\n\n\t// Add meta for persisted CRDT document.\n\tif ( globalThis.IS_GUTENBERG_PLUGIN ) {\n\t\tif ( persistedRecord ) {\n\t\t\tconst objectType = `postType/${ name }`;\n\t\t\tconst objectId = persistedRecord.id;\n\t\t\tconst meta = getSyncManager()?.createMeta( objectType, objectId );\n\t\t\tnewEdits.meta = {\n\t\t\t\t...edits.meta,\n\t\t\t\t...meta,\n\t\t\t};\n\t\t}\n\t}\n\n\treturn newEdits;\n};\n\n/**\n * Returns the list of post type entities.\n *\n * @return {Promise} Entities promise\n */\nasync function loadPostTypeEntities() {\n\tconst postTypes = await apiFetch( {\n\t\tpath: '/wp/v2/types?context=view',\n\t} );\n\treturn Object.entries( postTypes ?? {} ).map( ( [ name, postType ] ) => {\n\t\tconst isTemplate = [ 'wp_template', 'wp_template_part' ].includes(\n\t\t\tname\n\t\t);\n\t\tconst namespace = postType?.rest_namespace ?? 'wp/v2';\n\n\t\tconst entity = {\n\t\t\tkind: 'postType',\n\t\t\tbaseURL: `/${ namespace }/${ postType.rest_base }`,\n\t\t\tbaseURLParams: { context: 'edit' },\n\t\t\tname,\n\t\t\tlabel: postType.name,\n\t\t\ttransientEdits: {\n\t\t\t\t...blocksTransientEdits,\n\t\t\t\tselection: true,\n\t\t\t},\n\t\t\tmergedEdits: { meta: true },\n\t\t\trawAttributes: POST_RAW_ATTRIBUTES,\n\t\t\tgetTitle: ( record ) =>\n\t\t\t\trecord?.title?.rendered ||\n\t\t\t\trecord?.title ||\n\t\t\t\t( isTemplate\n\t\t\t\t\t? capitalCase( record.slug ?? '' )\n\t\t\t\t\t: String( record.id ) ),\n\t\t\t__unstablePrePersist: ( persistedRecord, edits ) =>\n\t\t\t\tprePersistPostType( persistedRecord, edits, name, isTemplate ),\n\t\t\t__unstable_rest_base: postType.rest_base,\n\t\t\tsupportsPagination: true,\n\t\t\tgetRevisionsUrl: ( parentId, revisionId ) =>\n\t\t\t\t`/${ namespace }/${\n\t\t\t\t\tpostType.rest_base\n\t\t\t\t}/${ parentId }/revisions${\n\t\t\t\t\trevisionId ? '/' + revisionId : ''\n\t\t\t\t}`,\n\t\t\trevisionKey:\n\t\t\t\tisTemplate && ! window?.__experimentalTemplateActivate\n\t\t\t\t\t? 'wp_id'\n\t\t\t\t\t: DEFAULT_ENTITY_KEY,\n\t\t};\n\n\t\tif ( globalThis.IS_GUTENBERG_PLUGIN ) {\n\t\t\t/**\n\t\t\t * @type {import('@wordpress/sync').SyncConfig}\n\t\t\t */\n\t\t\tentity.syncConfig = {\n\t\t\t\t/**\n\t\t\t\t * Apply changes from the local editor to the local CRDT document so\n\t\t\t\t * that those changes can be synced to other peers (via the provider).\n\t\t\t\t *\n\t\t\t\t * @param {import('@wordpress/sync').CRDTDoc} crdtDoc\n\t\t\t\t * @param {Partial< import('@wordpress/sync').ObjectData >} changes\n\t\t\t\t * @return {void}\n\t\t\t\t */\n\t\t\t\tapplyChangesToCRDTDoc: ( crdtDoc, changes ) =>\n\t\t\t\t\tapplyPostChangesToCRDTDoc( crdtDoc, changes, postType ),\n\n\t\t\t\t/**\n\t\t\t\t * Create the awareness instance for the entity's CRDT document.\n\t\t\t\t *\n\t\t\t\t * @param {import('@wordpress/sync').CRDTDoc} ydoc\n\t\t\t\t * @param {import('@wordpress/sync').ObjectID} objectId\n\t\t\t\t * @return {import('@wordpress/sync').AwarenessState} AwarenessState instance\n\t\t\t\t */\n\t\t\t\tcreateAwareness: ( ydoc, objectId ) => {\n\t\t\t\t\tconst kind = 'postType';\n\t\t\t\t\tconst id = parseInt( objectId, 10 );\n\t\t\t\t\treturn new PostEditorAwareness( ydoc, kind, name, id );\n\t\t\t\t},\n\n\t\t\t\t/**\n\t\t\t\t * Extract changes from a CRDT document that can be used to update the\n\t\t\t\t * local editor state.\n\t\t\t\t *\n\t\t\t\t * @param {import('@wordpress/sync').CRDTDoc} crdtDoc\n\t\t\t\t * @param {import('@wordpress/sync').ObjectData} editedRecord\n\t\t\t\t * @return {Partial< import('@wordpress/sync').ObjectData >} Changes to record\n\t\t\t\t */\n\t\t\t\tgetChangesFromCRDTDoc: ( crdtDoc, editedRecord ) =>\n\t\t\t\t\tgetPostChangesFromCRDTDoc(\n\t\t\t\t\t\tcrdtDoc,\n\t\t\t\t\t\teditedRecord,\n\t\t\t\t\t\tpostType\n\t\t\t\t\t),\n\n\t\t\t\t/**\n\t\t\t\t * Sync features supported by the entity.\n\t\t\t\t *\n\t\t\t\t * @type {Record< string, boolean >}\n\t\t\t\t */\n\t\t\t\tsupports: {\n\t\t\t\t\tcrdtPersistence: true,\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\n\t\treturn entity;\n\t} );\n}\n\n/**\n * Returns the list of the taxonomies entities.\n *\n * @return {Promise} Entities promise\n */\nasync function loadTaxonomyEntities() {\n\tconst taxonomies = await apiFetch( {\n\t\tpath: '/wp/v2/taxonomies?context=view',\n\t} );\n\treturn Object.entries( taxonomies ?? {} ).map( ( [ name, taxonomy ] ) => {\n\t\tconst namespace = taxonomy?.rest_namespace ?? 'wp/v2';\n\t\treturn {\n\t\t\tkind: 'taxonomy',\n\t\t\tbaseURL: `/${ namespace }/${ taxonomy.rest_base }`,\n\t\t\tbaseURLParams: { context: 'edit' },\n\t\t\tname,\n\t\t\tlabel: taxonomy.name,\n\t\t\tgetTitle: ( record ) => record?.name,\n\t\t\tsupportsPagination: true,\n\t\t};\n\t} );\n}\n\n/**\n * Returns the Site entity.\n *\n * @return {Promise} Entity promise\n */\nasync function loadSiteEntity() {\n\tconst entity = {\n\t\tlabel: __( 'Site' ),\n\t\tname: 'site',\n\t\tkind: 'root',\n\t\tkey: false,\n\t\tbaseURL: '/wp/v2/settings',\n\t\tmeta: {},\n\t};\n\n\tconst site = await apiFetch( {\n\t\tpath: entity.baseURL,\n\t\tmethod: 'OPTIONS',\n\t} );\n\n\tconst labels = {};\n\tObject.entries( site?.schema?.properties ?? {} ).forEach(\n\t\t( [ key, value ] ) => {\n\t\t\t// Ignore properties `title` and `type` keys.\n\t\t\tif ( typeof value === 'object' && value.title ) {\n\t\t\t\tlabels[ key ] = value.title;\n\t\t\t}\n\t\t}\n\t);\n\n\treturn [ { ...entity, meta: { labels } } ];\n}\n\n/**\n * Returns the entity's getter method name given its kind and name or plural name.\n *\n * @example\n * ```js\n * const nameSingular = getMethodName( 'root', 'theme', 'get' );\n * // nameSingular is getRootTheme\n *\n * const namePlural = getMethodName( 'root', 'themes', 'set' );\n * // namePlural is setRootThemes\n * ```\n *\n * @param {string} kind Entity kind.\n * @param {string} name Entity name or plural name.\n * @param {string} prefix Function prefix.\n *\n * @return {string} Method name\n */\nexport const getMethodName = ( kind, name, prefix = 'get' ) => {\n\tconst kindPrefix = kind === 'root' ? '' : pascalCase( kind );\n\tconst suffix = pascalCase( name );\n\treturn `${ prefix }${ kindPrefix }${ suffix }`;\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,yBAAwC;AAKxC,uBAAqB;AACrB,oBAAmD;AACnD,kBAAmB;AAKnB,mCAAoC;AACpC,kBAA+B;AAC/B,kBAGO;AAEA,IAAM,qBAAqB;AAClC,IAAM,sBAAsB,CAAE,SAAS,WAAW,SAAU;AAE5D,IAAM,uBAAuB;AAAA,EAC5B,QAAQ;AAAA,IACP,MAAM,CAAE,eAAY,qBAAO,OAAO,S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SAAS,SAAS,SAAK,+BAAY,IAAK;AAC3D,QAAM,aAAS,+BAAY,IAAK;AAChC,SAAO,GAAI,MAAO,GAAI,UAAW,GAAI,MAAO;AAC7C;",
|
|
6
6
|
"names": ["apiFetch"]
|
|
7
7
|
}
|
package/build/resolvers.cjs
CHANGED
|
@@ -162,7 +162,7 @@ var getEntityRecord = (kind, name, key = "", query) => async ({ select, dispatch
|
|
|
162
162
|
recordWithTransients,
|
|
163
163
|
{
|
|
164
164
|
// Handle edits sourced from the sync manager.
|
|
165
|
-
editRecord: (edits) => {
|
|
165
|
+
editRecord: (edits, options = {}) => {
|
|
166
166
|
if (!Object.keys(edits).length) {
|
|
167
167
|
return;
|
|
168
168
|
}
|
|
@@ -174,7 +174,8 @@ var getEntityRecord = (kind, name, key = "", query) => async ({ select, dispatch
|
|
|
174
174
|
edits,
|
|
175
175
|
meta: {
|
|
176
176
|
undo: void 0
|
|
177
|
-
}
|
|
177
|
+
},
|
|
178
|
+
options
|
|
178
179
|
});
|
|
179
180
|
},
|
|
180
181
|
// Get the current entity record (with edits)
|