@wordpress/core-data 7.40.2-next.v.202602271551.0 → 7.40.2
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/README.md +0 -27
- package/build/actions.cjs +9 -26
- package/build/actions.cjs.map +2 -2
- package/build/awareness/post-editor-awareness.cjs +45 -6
- package/build/awareness/post-editor-awareness.cjs.map +2 -2
- package/build/awareness/types.cjs.map +1 -1
- package/build/entities.cjs +36 -16
- package/build/entities.cjs.map +2 -2
- package/build/entity-provider.cjs +15 -6
- package/build/entity-provider.cjs.map +2 -2
- package/build/hooks/use-entity-prop.cjs +33 -2
- package/build/hooks/use-entity-prop.cjs.map +2 -2
- package/build/hooks/use-post-editor-awareness-state.cjs +120 -1
- package/build/hooks/use-post-editor-awareness-state.cjs.map +2 -2
- package/build/index.cjs +0 -3
- package/build/index.cjs.map +2 -2
- package/build/private-actions.cjs +27 -3
- package/build/private-actions.cjs.map +2 -2
- package/build/private-apis.cjs +14 -5
- package/build/private-apis.cjs.map +3 -3
- package/build/private-selectors.cjs +22 -2
- package/build/private-selectors.cjs.map +2 -2
- package/build/queried-data/actions.cjs +1 -1
- package/build/queried-data/actions.cjs.map +2 -2
- package/build/queried-data/reducer.cjs +19 -13
- package/build/queried-data/reducer.cjs.map +2 -2
- package/build/reducer.cjs +19 -2
- package/build/reducer.cjs.map +2 -2
- package/build/resolvers.cjs +24 -17
- package/build/resolvers.cjs.map +2 -2
- package/build/selectors.cjs +0 -15
- package/build/selectors.cjs.map +2 -2
- package/build/sync.cjs +12 -3
- package/build/sync.cjs.map +2 -2
- package/build/types.cjs.map +1 -1
- package/build/utils/block-selection-history.cjs +1 -1
- package/build/utils/block-selection-history.cjs.map +2 -2
- package/build/utils/crdt-blocks.cjs +85 -28
- package/build/utils/crdt-blocks.cjs.map +2 -2
- package/build/utils/crdt-selection.cjs +4 -1
- package/build/utils/crdt-selection.cjs.map +2 -2
- package/build/utils/crdt-text.cjs +52 -0
- package/build/utils/crdt-text.cjs.map +7 -0
- package/build/utils/crdt-user-selections.cjs +16 -6
- package/build/utils/crdt-user-selections.cjs.map +3 -3
- package/build/utils/crdt-utils.cjs +54 -2
- package/build/utils/crdt-utils.cjs.map +2 -2
- package/build/utils/crdt.cjs +26 -28
- package/build/utils/crdt.cjs.map +2 -2
- package/build-module/actions.mjs +14 -26
- package/build-module/actions.mjs.map +2 -2
- package/build-module/awareness/post-editor-awareness.mjs +47 -7
- package/build-module/awareness/post-editor-awareness.mjs.map +2 -2
- package/build-module/entities.mjs +37 -16
- package/build-module/entities.mjs.map +2 -2
- package/build-module/entity-provider.mjs +15 -6
- package/build-module/entity-provider.mjs.map +2 -2
- package/build-module/hooks/use-entity-prop.mjs +34 -3
- package/build-module/hooks/use-entity-prop.mjs.map +2 -2
- package/build-module/hooks/use-post-editor-awareness-state.mjs +117 -1
- package/build-module/hooks/use-post-editor-awareness-state.mjs.map +2 -2
- package/build-module/index.mjs +0 -2
- package/build-module/index.mjs.map +2 -2
- package/build-module/private-actions.mjs +24 -2
- package/build-module/private-actions.mjs.map +2 -2
- package/build-module/private-apis.mjs +21 -6
- package/build-module/private-apis.mjs.map +3 -3
- package/build-module/private-selectors.mjs +19 -1
- package/build-module/private-selectors.mjs.map +2 -2
- package/build-module/queried-data/actions.mjs +1 -1
- package/build-module/queried-data/actions.mjs.map +2 -2
- package/build-module/queried-data/reducer.mjs +19 -13
- package/build-module/queried-data/reducer.mjs.map +2 -2
- package/build-module/reducer.mjs +18 -2
- package/build-module/reducer.mjs.map +2 -2
- package/build-module/resolvers.mjs +24 -17
- package/build-module/resolvers.mjs.map +2 -2
- package/build-module/selectors.mjs +0 -14
- package/build-module/selectors.mjs.map +2 -2
- package/build-module/sync.mjs +8 -2
- package/build-module/sync.mjs.map +2 -2
- package/build-module/utils/block-selection-history.mjs +5 -2
- package/build-module/utils/block-selection-history.mjs.map +2 -2
- package/build-module/utils/crdt-blocks.mjs +84 -28
- package/build-module/utils/crdt-blocks.mjs.map +2 -2
- package/build-module/utils/crdt-selection.mjs +8 -2
- package/build-module/utils/crdt-selection.mjs.map +2 -2
- package/build-module/utils/crdt-text.mjs +26 -0
- package/build-module/utils/crdt-text.mjs.map +7 -0
- package/build-module/utils/crdt-user-selections.mjs +16 -7
- package/build-module/utils/crdt-user-selections.mjs.map +3 -3
- package/build-module/utils/crdt-utils.mjs +51 -1
- package/build-module/utils/crdt-utils.mjs.map +2 -2
- package/build-module/utils/crdt.mjs +26 -28
- package/build-module/utils/crdt.mjs.map +2 -2
- package/build-types/actions.d.ts +0 -11
- package/build-types/actions.d.ts.map +1 -1
- package/build-types/awareness/post-editor-awareness.d.ts +2 -2
- package/build-types/awareness/post-editor-awareness.d.ts.map +1 -1
- package/build-types/awareness/types.d.ts +6 -1
- package/build-types/awareness/types.d.ts.map +1 -1
- package/build-types/entities.d.ts +20 -1
- package/build-types/entities.d.ts.map +1 -1
- package/build-types/entity-provider.d.ts +11 -6
- package/build-types/entity-provider.d.ts.map +1 -1
- package/build-types/hooks/use-entity-prop.d.ts.map +1 -1
- package/build-types/hooks/use-post-editor-awareness-state.d.ts +40 -7
- package/build-types/hooks/use-post-editor-awareness-state.d.ts.map +1 -1
- package/build-types/index.d.ts +0 -3
- package/build-types/index.d.ts.map +1 -1
- package/build-types/parsed-blocks-cache.d.ts +10 -0
- package/build-types/parsed-blocks-cache.d.ts.map +1 -0
- package/build-types/private-actions.d.ts +12 -0
- package/build-types/private-actions.d.ts.map +1 -1
- package/build-types/private-apis.d.ts +21 -1
- package/build-types/private-apis.d.ts.map +1 -1
- package/build-types/private-selectors.d.ts +17 -0
- package/build-types/private-selectors.d.ts.map +1 -1
- package/build-types/queried-data/reducer.d.ts.map +1 -1
- package/build-types/reducer.d.ts +15 -0
- package/build-types/reducer.d.ts.map +1 -1
- package/build-types/resolvers.d.ts.map +1 -1
- package/build-types/selectors.d.ts +1 -9
- package/build-types/selectors.d.ts.map +1 -1
- package/build-types/sync.d.ts +2 -2
- package/build-types/sync.d.ts.map +1 -1
- package/build-types/types.d.ts +10 -2
- package/build-types/types.d.ts.map +1 -1
- package/build-types/utils/block-selection-history.d.ts.map +1 -1
- package/build-types/utils/crdt-blocks.d.ts +11 -0
- package/build-types/utils/crdt-blocks.d.ts.map +1 -1
- package/build-types/utils/crdt-selection.d.ts.map +1 -1
- package/build-types/utils/crdt-text.d.ts +16 -0
- package/build-types/utils/crdt-text.d.ts.map +1 -0
- package/build-types/utils/crdt-user-selections.d.ts +17 -4
- package/build-types/utils/crdt-user-selections.d.ts.map +1 -1
- package/build-types/utils/crdt-utils.d.ts +20 -0
- package/build-types/utils/crdt-utils.d.ts.map +1 -1
- package/build-types/utils/crdt.d.ts +13 -7
- package/build-types/utils/crdt.d.ts.map +1 -1
- package/build-types/utils/normalize-query-for-resolution.d.ts +12 -0
- package/build-types/utils/normalize-query-for-resolution.d.ts.map +1 -0
- package/build-types/utils/save-crdt-doc.d.ts +8 -0
- package/build-types/utils/save-crdt-doc.d.ts.map +1 -0
- package/build-types/utils/test/crdt-utils.d.ts +2 -0
- package/build-types/utils/test/crdt-utils.d.ts.map +1 -0
- package/package.json +18 -18
- package/src/actions.js +26 -41
- package/src/awareness/post-editor-awareness.ts +106 -7
- package/src/awareness/test/post-editor-awareness.ts +50 -10
- package/src/awareness/types.ts +7 -1
- package/src/entities.js +43 -17
- package/src/entity-provider.js +24 -11
- package/src/hooks/test/use-post-editor-awareness-state.ts +446 -3
- package/src/hooks/use-entity-prop.js +43 -3
- package/src/hooks/use-post-editor-awareness-state.ts +229 -7
- package/src/index.js +0 -6
- package/src/private-actions.js +43 -1
- package/src/{private-apis.js → private-apis.ts} +21 -3
- package/src/private-selectors.ts +43 -0
- package/src/queried-data/actions.js +1 -1
- package/src/queried-data/reducer.js +26 -14
- package/src/reducer.js +36 -1
- package/src/resolvers.js +33 -23
- package/src/selectors.ts +1 -32
- package/src/sync.ts +6 -0
- package/src/test/entities.js +204 -16
- package/src/test/private-actions.js +1 -1
- package/src/test/resolvers.js +144 -57
- package/src/test/store.js +116 -0
- package/src/types.ts +20 -2
- package/src/utils/block-selection-history.ts +5 -2
- package/src/utils/crdt-blocks.ts +159 -56
- package/src/utils/crdt-selection.ts +8 -2
- package/src/utils/crdt-text.ts +43 -0
- package/src/utils/crdt-user-selections.ts +29 -8
- package/src/utils/crdt-utils.ts +99 -0
- package/src/utils/crdt.ts +50 -40
- package/src/utils/test/crdt-blocks.ts +588 -24
- package/src/utils/test/crdt-user-selections.ts +5 -0
- package/src/utils/test/crdt-utils.ts +387 -0
- package/src/utils/test/crdt.ts +291 -54
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
} from "@wordpress/sync";
|
|
7
7
|
import { BaseAwareness } from "../awareness/base-awareness.mjs";
|
|
8
8
|
import {
|
|
9
|
+
deserializeBlockAttributes,
|
|
9
10
|
mergeCrdtBlocks,
|
|
10
11
|
mergeRichTextUpdate
|
|
11
12
|
} from "./crdt-blocks.mjs";
|
|
@@ -21,25 +22,6 @@ import {
|
|
|
21
22
|
isYMap
|
|
22
23
|
} from "./crdt-utils.mjs";
|
|
23
24
|
var POST_META_KEY_FOR_CRDT_DOC_PERSISTENCE = "_crdt_document";
|
|
24
|
-
var allowedPostProperties = /* @__PURE__ */ new Set([
|
|
25
|
-
"author",
|
|
26
|
-
"blocks",
|
|
27
|
-
"content",
|
|
28
|
-
"categories",
|
|
29
|
-
"comment_status",
|
|
30
|
-
"date",
|
|
31
|
-
"excerpt",
|
|
32
|
-
"featured_media",
|
|
33
|
-
"format",
|
|
34
|
-
"meta",
|
|
35
|
-
"ping_status",
|
|
36
|
-
"slug",
|
|
37
|
-
"status",
|
|
38
|
-
"sticky",
|
|
39
|
-
"tags",
|
|
40
|
-
"template",
|
|
41
|
-
"title"
|
|
42
|
-
]);
|
|
43
25
|
var disallowedPostMetaKeys = /* @__PURE__ */ new Set([
|
|
44
26
|
POST_META_KEY_FOR_CRDT_DOC_PERSISTENCE
|
|
45
27
|
]);
|
|
@@ -58,10 +40,10 @@ function defaultApplyChangesToCRDTDoc(ydoc, changes) {
|
|
|
58
40
|
}
|
|
59
41
|
});
|
|
60
42
|
}
|
|
61
|
-
function applyPostChangesToCRDTDoc(ydoc, changes,
|
|
43
|
+
function applyPostChangesToCRDTDoc(ydoc, changes, syncedProperties) {
|
|
62
44
|
const ymap = getRootMap(ydoc, CRDT_RECORD_MAP_KEY);
|
|
63
45
|
Object.keys(changes).forEach((key) => {
|
|
64
|
-
if (!
|
|
46
|
+
if (!syncedProperties.has(key)) {
|
|
65
47
|
return;
|
|
66
48
|
}
|
|
67
49
|
const newValue = changes[key];
|
|
@@ -148,12 +130,12 @@ function applyPostChangesToCRDTDoc(ydoc, changes, _postType) {
|
|
|
148
130
|
function defaultGetChangesFromCRDTDoc(crdtDoc) {
|
|
149
131
|
return getRootMap(crdtDoc, CRDT_RECORD_MAP_KEY).toJSON();
|
|
150
132
|
}
|
|
151
|
-
function getPostChangesFromCRDTDoc(ydoc, editedRecord,
|
|
133
|
+
function getPostChangesFromCRDTDoc(ydoc, editedRecord, syncedProperties) {
|
|
152
134
|
const ymap = getRootMap(ydoc, CRDT_RECORD_MAP_KEY);
|
|
153
135
|
let allowedMetaChanges = {};
|
|
154
136
|
const changes = Object.fromEntries(
|
|
155
137
|
Object.entries(ymap.toJSON()).filter(([key, newValue]) => {
|
|
156
|
-
if (!
|
|
138
|
+
if (!syncedProperties.has(key)) {
|
|
157
139
|
return false;
|
|
158
140
|
}
|
|
159
141
|
const currentValue = editedRecord[key];
|
|
@@ -166,22 +148,26 @@ function getPostChangesFromCRDTDoc(ydoc, editedRecord, _postType) {
|
|
|
166
148
|
return true;
|
|
167
149
|
}
|
|
168
150
|
case "date": {
|
|
169
|
-
const currentDateIsFloating =
|
|
170
|
-
ymap.get("status")
|
|
171
|
-
) && (null === currentValue || editedRecord.modified === currentValue);
|
|
151
|
+
const currentDateIsFloating = null === currentValue || editedRecord.modified === currentValue;
|
|
172
152
|
if (currentDateIsFloating) {
|
|
173
153
|
return false;
|
|
174
154
|
}
|
|
175
155
|
return haveValuesChanged(currentValue, newValue);
|
|
176
156
|
}
|
|
177
157
|
case "meta": {
|
|
158
|
+
const currentMeta = currentValue ?? {};
|
|
178
159
|
allowedMetaChanges = Object.fromEntries(
|
|
179
160
|
Object.entries(newValue ?? {}).filter(
|
|
180
|
-
([metaKey]) =>
|
|
161
|
+
([metaKey]) => {
|
|
162
|
+
if (disallowedPostMetaKeys.has(metaKey)) {
|
|
163
|
+
return false;
|
|
164
|
+
}
|
|
165
|
+
return metaKey in currentMeta;
|
|
166
|
+
}
|
|
181
167
|
)
|
|
182
168
|
);
|
|
183
169
|
const mergedValue = {
|
|
184
|
-
...
|
|
170
|
+
...currentMeta,
|
|
185
171
|
...allowedMetaChanges
|
|
186
172
|
};
|
|
187
173
|
return haveValuesChanged(currentValue, mergedValue);
|
|
@@ -207,6 +193,11 @@ function getPostChangesFromCRDTDoc(ydoc, editedRecord, _postType) {
|
|
|
207
193
|
}
|
|
208
194
|
})
|
|
209
195
|
);
|
|
196
|
+
if (changes.blocks) {
|
|
197
|
+
changes.blocks = deserializeBlockAttributes(
|
|
198
|
+
changes.blocks
|
|
199
|
+
);
|
|
200
|
+
}
|
|
210
201
|
if ("object" === typeof changes.meta) {
|
|
211
202
|
changes.meta = {
|
|
212
203
|
...editedRecord.meta,
|
|
@@ -228,6 +219,12 @@ var defaultSyncConfig = {
|
|
|
228
219
|
createAwareness: (ydoc) => new BaseAwareness(ydoc),
|
|
229
220
|
getChangesFromCRDTDoc: defaultGetChangesFromCRDTDoc
|
|
230
221
|
};
|
|
222
|
+
var defaultCollectionSyncConfig = {
|
|
223
|
+
applyChangesToCRDTDoc: () => {
|
|
224
|
+
},
|
|
225
|
+
getChangesFromCRDTDoc: () => ({}),
|
|
226
|
+
shouldSync: (_, objectId) => null === objectId
|
|
227
|
+
};
|
|
231
228
|
function getRawValue(value) {
|
|
232
229
|
if ("string" === typeof value) {
|
|
233
230
|
return value;
|
|
@@ -252,6 +249,7 @@ function updateMapValue(map, key, currentValue, newValue) {
|
|
|
252
249
|
export {
|
|
253
250
|
POST_META_KEY_FOR_CRDT_DOC_PERSISTENCE,
|
|
254
251
|
applyPostChangesToCRDTDoc,
|
|
252
|
+
defaultCollectionSyncConfig,
|
|
255
253
|
defaultSyncConfig,
|
|
256
254
|
getPostChangesFromCRDTDoc
|
|
257
255
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/crdt.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport fastDeepEqual from 'fast-deep-equal/es6/index.js';\n\n/**\n * WordPress dependencies\n */\n// @ts-expect-error No exported types.\nimport { __unstableSerializeAndClean } from '@wordpress/blocks';\nimport {\n\ttype CRDTDoc,\n\ttype ObjectData,\n\ttype SyncConfig,\n\tY,\n} from '@wordpress/sync';\n\n/**\n * Internal dependencies\n */\nimport { BaseAwareness } from '../awareness/base-awareness';\nimport {\n\tmergeCrdtBlocks,\n\tmergeRichTextUpdate,\n\ttype Block,\n\ttype YBlock,\n\ttype YBlocks,\n} from './crdt-blocks';\nimport { type Post } from '../entity-types/post';\nimport { type Type } from '../entity-types';\nimport { CRDT_DOC_META_PERSISTENCE_KEY, CRDT_RECORD_MAP_KEY } from '../sync';\nimport type { WPSelection } from '../types';\nimport {\n\tgetSelectionHistory,\n\tgetShiftedSelection,\n\tupdateSelectionHistory,\n} from './crdt-selection';\nimport {\n\tcreateYMap,\n\tgetRootMap,\n\tisYMap,\n\ttype YMapRecord,\n\ttype YMapWrap,\n} from './crdt-utils';\n\n// Changes that can be applied to a post entity record.\nexport type PostChanges = Partial< Post > & {\n\tblocks?: Block[];\n\tcontent?: Post[ 'content' ] | string;\n\texcerpt?: Post[ 'excerpt' ] | string;\n\tselection?: WPSelection;\n\ttitle?: Post[ 'title' ] | string;\n};\n\n// A post record as represented in the CRDT document (Y.Map).\nexport interface YPostRecord extends YMapRecord {\n\tauthor: number;\n\t// Blocks are undefined when they need to be re-parsed from content.\n\tblocks: YBlocks | undefined;\n\tcontent: Y.Text;\n\tcategories: number[];\n\tcomment_status: string;\n\tdate: string | null;\n\texcerpt: Y.Text;\n\tfeatured_media: number;\n\tformat: string;\n\tmeta: YMapWrap< YMapRecord >;\n\tping_status: string;\n\tslug: string;\n\tstatus: string;\n\tsticky: boolean;\n\ttags: number[];\n\ttemplate: string;\n\ttitle: Y.Text;\n}\n\nexport const POST_META_KEY_FOR_CRDT_DOC_PERSISTENCE = '_crdt_document';\n\n// Properties that are allowed to be synced for a post.\nconst allowedPostProperties = new Set< string >( [\n\t'author',\n\t'blocks',\n\t'content',\n\t'categories',\n\t'comment_status',\n\t'date',\n\t'excerpt',\n\t'featured_media',\n\t'format',\n\t'meta',\n\t'ping_status',\n\t'slug',\n\t'status',\n\t'sticky',\n\t'tags',\n\t'template',\n\t'title',\n] );\n\n// Post meta keys that should *not* be synced.\nconst disallowedPostMetaKeys = new Set< string >( [\n\tPOST_META_KEY_FOR_CRDT_DOC_PERSISTENCE,\n] );\n\n/**\n * Given a set of local changes to a generic entity record, apply those changes\n * to the local Y.Doc.\n *\n * @param {CRDTDoc} ydoc\n * @param {Partial< ObjectData >} changes\n * @return {void}\n */\nfunction defaultApplyChangesToCRDTDoc(\n\tydoc: CRDTDoc,\n\tchanges: ObjectData\n): void {\n\tconst ymap = getRootMap( ydoc, CRDT_RECORD_MAP_KEY );\n\n\tObject.entries( changes ).forEach( ( [ key, newValue ] ) => {\n\t\t// Cannot serialize function values, so cannot sync them.\n\t\tif ( 'function' === typeof newValue ) {\n\t\t\treturn;\n\t\t}\n\n\t\tswitch ( key ) {\n\t\t\t// Add support for additional data types here.\n\n\t\t\tdefault: {\n\t\t\t\tconst currentValue = ymap.get( key );\n\t\t\t\tupdateMapValue( ymap, key, currentValue, newValue );\n\t\t\t}\n\t\t}\n\t} );\n}\n\n/**\n * Given a set of local changes to a post record, apply those changes to the\n * local Y.Doc.\n *\n * @param {CRDTDoc} ydoc\n * @param {PostChanges} changes\n * @param {Type} _postType\n * @return {void}\n */\nexport function applyPostChangesToCRDTDoc(\n\tydoc: CRDTDoc,\n\tchanges: PostChanges,\n\t_postType: Type // eslint-disable-line @typescript-eslint/no-unused-vars\n): void {\n\tconst ymap = getRootMap< YPostRecord >( ydoc, CRDT_RECORD_MAP_KEY );\n\n\tObject.keys( changes ).forEach( ( key ) => {\n\t\tif ( ! allowedPostProperties.has( key ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst newValue = changes[ key ];\n\n\t\t// Cannot serialize function values, so cannot sync them.\n\t\tif ( 'function' === typeof newValue ) {\n\t\t\treturn;\n\t\t}\n\n\t\tswitch ( key ) {\n\t\t\tcase 'blocks': {\n\t\t\t\t// Blocks are undefined when they need to be re-parsed from content.\n\t\t\t\tif ( ! newValue ) {\n\t\t\t\t\t// Set to undefined instead of deleting the key. This is important\n\t\t\t\t\t// since we iterate over the Y.Map keys in getPostChangesFromCRDTDoc.\n\t\t\t\t\tymap.set( key, undefined );\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tlet currentBlocks = ymap.get( key );\n\n\t\t\t\t// Initialize.\n\t\t\t\tif ( ! ( currentBlocks instanceof Y.Array ) ) {\n\t\t\t\t\tcurrentBlocks = new Y.Array< YBlock >();\n\t\t\t\t\tymap.set( key, currentBlocks );\n\t\t\t\t}\n\n\t\t\t\t// Block changes from typing are bundled with a 'selection' update.\n\t\t\t\t// Pass the resulting cursor position to the mergeCrdtBlocks function.\n\t\t\t\tconst cursorPosition =\n\t\t\t\t\tchanges.selection?.selectionStart?.offset ?? null;\n\n\t\t\t\t// Merge blocks does not need `setValue` because it is operating on a\n\t\t\t\t// Yjs type that is already in the Y.Doc.\n\t\t\t\tmergeCrdtBlocks( currentBlocks, newValue, cursorPosition );\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase 'content':\n\t\t\tcase 'excerpt':\n\t\t\tcase 'title': {\n\t\t\t\tconst currentValue = ymap.get( key );\n\t\t\t\tlet rawValue = getRawValue( newValue );\n\n\t\t\t\t// Copy logic from prePersistPostType to ensure that the \"Auto\n\t\t\t\t// Draft\" template title is not synced.\n\t\t\t\tif (\n\t\t\t\t\tkey === 'title' &&\n\t\t\t\t\t! currentValue?.toString() &&\n\t\t\t\t\t'Auto Draft' === rawValue\n\t\t\t\t) {\n\t\t\t\t\trawValue = '';\n\t\t\t\t}\n\n\t\t\t\tif ( currentValue instanceof Y.Text ) {\n\t\t\t\t\tmergeRichTextUpdate( currentValue, rawValue ?? '' );\n\t\t\t\t} else {\n\t\t\t\t\tconst newYText = new Y.Text( rawValue ?? '' );\n\t\t\t\t\tymap.set( key, newYText );\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t// \"Meta\" is overloaded term; here, it refers to post meta.\n\t\t\tcase 'meta': {\n\t\t\t\tlet metaMap = ymap.get( 'meta' );\n\n\t\t\t\t// Initialize.\n\t\t\t\tif ( ! isYMap( metaMap ) ) {\n\t\t\t\t\tmetaMap = createYMap< YMapRecord >();\n\t\t\t\t\tymap.set( 'meta', metaMap );\n\t\t\t\t}\n\n\t\t\t\t// Iterate over each meta property in the new value and merge it if it\n\t\t\t\t// should be synced.\n\t\t\t\tObject.entries( newValue ?? {} ).forEach(\n\t\t\t\t\t( [ metaKey, metaValue ] ) => {\n\t\t\t\t\t\tif ( disallowedPostMetaKeys.has( metaKey ) ) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tupdateMapValue(\n\t\t\t\t\t\t\tmetaMap,\n\t\t\t\t\t\t\tmetaKey,\n\t\t\t\t\t\t\tmetaMap.get( metaKey ), // current value in CRDT\n\t\t\t\t\t\t\tmetaValue // new value from changes\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase 'slug': {\n\t\t\t\t// Do not sync an empty slug. This indicates that the post is using\n\t\t\t\t// the default auto-generated slug.\n\t\t\t\tif ( ! newValue ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tconst currentValue = ymap.get( key );\n\t\t\t\tupdateMapValue( ymap, key, currentValue, newValue );\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t// Add support for additional properties here.\n\n\t\t\tdefault: {\n\t\t\t\tconst currentValue = ymap.get( key );\n\t\t\t\tupdateMapValue( ymap, key, currentValue, newValue );\n\t\t\t}\n\t\t}\n\t} );\n\n\t// Process changes that we don't want to persist to the CRDT document.\n\tif ( changes.selection ) {\n\t\tconst selection = changes.selection;\n\t\t// Persist selection changes at the end of the current event loop.\n\t\t// This allows undo meta to be saved with the current selection before\n\t\t// it is overwritten by the new selection from Gutenberg.\n\t\t// Without this, selection history will already contain the latest\n\t\t// selection (after this change) when the undo stack is saved.\n\t\tsetTimeout( () => {\n\t\t\tupdateSelectionHistory( ydoc, selection );\n\t\t}, 0 );\n\t}\n}\n\nfunction defaultGetChangesFromCRDTDoc( crdtDoc: CRDTDoc ): ObjectData {\n\treturn getRootMap( crdtDoc, CRDT_RECORD_MAP_KEY ).toJSON();\n}\n\n/**\n * Given a local Y.Doc that *may* contain changes from remote peers, compare\n * against the local record and determine if there are changes (edits) we want\n * to dispatch.\n *\n * @param {CRDTDoc} ydoc\n * @param {Post} editedRecord\n * @param {Type} _postType\n * @return {Partial<PostChanges>} The changes that should be applied to the local record.\n */\nexport function getPostChangesFromCRDTDoc(\n\tydoc: CRDTDoc,\n\teditedRecord: Post,\n\t_postType: Type // eslint-disable-line @typescript-eslint/no-unused-vars\n): PostChanges {\n\tconst ymap = getRootMap< YPostRecord >( ydoc, CRDT_RECORD_MAP_KEY );\n\n\tlet allowedMetaChanges: Post[ 'meta' ] = {};\n\n\tconst changes = Object.fromEntries(\n\t\tObject.entries( ymap.toJSON() ).filter( ( [ key, newValue ] ) => {\n\t\t\tif ( ! allowedPostProperties.has( key ) ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tconst currentValue = editedRecord[ key ];\n\n\t\t\tswitch ( key ) {\n\t\t\t\tcase 'blocks': {\n\t\t\t\t\t// When we are passed a persisted CRDT document, make a special\n\t\t\t\t\t// comparison of the content and blocks.\n\t\t\t\t\t//\n\t\t\t\t\t// When other fields (besides `blocks`) are mutated outside the block\n\t\t\t\t\t// editor, the change is caught by an equality check (see other cases\n\t\t\t\t\t// in this `switch` statement). As a transient property, `blocks`\n\t\t\t\t\t// cannot be directly mutated outside the block editor -- only\n\t\t\t\t\t// `content` can.\n\t\t\t\t\t//\n\t\t\t\t\t// Therefore, for this special comparison, we serialize the `blocks`\n\t\t\t\t\t// from the persisted CRDT document and compare that to the content\n\t\t\t\t\t// from the persisted record. If they differ, we know that the content\n\t\t\t\t\t// in the database has changed, and therefore the blocks have changed.\n\t\t\t\t\t//\n\t\t\t\t\t// We cannot directly compare the `blocks` from the CRDT document to\n\t\t\t\t\t// the `blocks` derived from the `content` in the persisted record,\n\t\t\t\t\t// because the latter will have different client IDs.\n\t\t\t\t\tif (\n\t\t\t\t\t\tydoc.meta?.get( CRDT_DOC_META_PERSISTENCE_KEY ) &&\n\t\t\t\t\t\teditedRecord.content\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst blocksJson = ymap.get( 'blocks' )?.toJSON() ?? [];\n\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t__unstableSerializeAndClean( blocksJson ).trim() !==\n\t\t\t\t\t\t\tgetRawValue( editedRecord.content )\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\t// The consumers of blocks have memoization that renders optimization\n\t\t\t\t\t// here unnecessary.\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\n\t\t\t\tcase 'date': {\n\t\t\t\t\t// Do not overwrite a \"floating\" date. Borrowing logic from the\n\t\t\t\t\t// isEditedPostDateFloating selector.\n\t\t\t\t\tconst currentDateIsFloating =\n\t\t\t\t\t\t[ 'draft', 'auto-draft', 'pending' ].includes(\n\t\t\t\t\t\t\tymap.get( 'status' ) as string\n\t\t\t\t\t\t) &&\n\t\t\t\t\t\t( null === currentValue ||\n\t\t\t\t\t\t\teditedRecord.modified === currentValue );\n\n\t\t\t\t\tif ( currentDateIsFloating ) {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn haveValuesChanged( currentValue, newValue );\n\t\t\t\t}\n\n\t\t\t\tcase 'meta': {\n\t\t\t\t\tallowedMetaChanges = Object.fromEntries(\n\t\t\t\t\t\tObject.entries( newValue ?? {} ).filter(\n\t\t\t\t\t\t\t( [ metaKey ] ) =>\n\t\t\t\t\t\t\t\t! disallowedPostMetaKeys.has( metaKey )\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\n\t\t\t\t\t// Merge the allowed meta changes with the current meta values since\n\t\t\t\t\t// not all meta properties are synced.\n\t\t\t\t\tconst mergedValue = {\n\t\t\t\t\t\t...( currentValue as PostChanges[ 'meta' ] ),\n\t\t\t\t\t\t...allowedMetaChanges,\n\t\t\t\t\t};\n\n\t\t\t\t\treturn haveValuesChanged( currentValue, mergedValue );\n\t\t\t\t}\n\n\t\t\t\tcase 'status': {\n\t\t\t\t\t// Do not sync an invalid status.\n\t\t\t\t\tif ( 'auto-draft' === newValue ) {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn haveValuesChanged( currentValue, newValue );\n\t\t\t\t}\n\n\t\t\t\tcase 'content':\n\t\t\t\tcase 'excerpt':\n\t\t\t\tcase 'title': {\n\t\t\t\t\treturn haveValuesChanged(\n\t\t\t\t\t\tgetRawValue( currentValue ),\n\t\t\t\t\t\tnewValue\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\t// Add support for additional data types here.\n\n\t\t\t\tdefault: {\n\t\t\t\t\treturn haveValuesChanged( currentValue, newValue );\n\t\t\t\t}\n\t\t\t}\n\t\t} )\n\t);\n\n\t// Meta changes must be merged with the edited record since not all meta\n\t// properties are synced.\n\tif ( 'object' === typeof changes.meta ) {\n\t\tchanges.meta = {\n\t\t\t...editedRecord.meta,\n\t\t\t...allowedMetaChanges,\n\t\t};\n\t}\n\n\t// When remote content changes are detected, recalculate the local user's\n\t// selection using Y.RelativePosition to account for text shifts. The ydoc\n\t// has already been updated with remote content at this point, so converting\n\t// relative positions to absolute gives corrected offsets. Including the\n\t// selection in PostChanges ensures it dispatches atomically with content.\n\tconst selectionHistory = getSelectionHistory( ydoc );\n\tconst shiftedSelection = getShiftedSelection( ydoc, selectionHistory );\n\tif ( shiftedSelection ) {\n\t\tchanges.selection = {\n\t\t\t...shiftedSelection,\n\t\t\tinitialPosition: 0,\n\t\t};\n\t}\n\n\treturn changes;\n}\n\n/**\n * This default sync config can be used for entities that are flat maps of\n * primitive values and do not require custom logic to merge changes.\n */\nexport const defaultSyncConfig: SyncConfig = {\n\tapplyChangesToCRDTDoc: defaultApplyChangesToCRDTDoc,\n\tcreateAwareness: ( ydoc: CRDTDoc ) => new BaseAwareness( ydoc ),\n\tgetChangesFromCRDTDoc: defaultGetChangesFromCRDTDoc,\n};\n\n/**\n * Extract the raw string value from a property that may be a string or an object\n * with a `raw` property (`RenderedText`).\n *\n * @param {unknown} value The value to extract from.\n * @return {string|undefined} The raw string value, or undefined if it could not be determined.\n */\nfunction getRawValue( value?: unknown ): string | undefined {\n\t// Value may be a string property or a nested object with a `raw` property.\n\tif ( 'string' === typeof value ) {\n\t\treturn value;\n\t}\n\n\tif (\n\t\tvalue &&\n\t\t'object' === typeof value &&\n\t\t'raw' in value &&\n\t\t'string' === typeof value.raw\n\t) {\n\t\treturn value.raw;\n\t}\n\n\treturn undefined;\n}\n\nfunction haveValuesChanged< ValueType >(\n\tcurrentValue: ValueType | undefined,\n\tnewValue: ValueType | undefined\n): boolean {\n\treturn ! fastDeepEqual( currentValue, newValue );\n}\n\nfunction updateMapValue< T extends YMapRecord, K extends keyof T >(\n\tmap: YMapWrap< T >,\n\tkey: K,\n\tcurrentValue: T[ K ] | undefined,\n\tnewValue: T[ K ] | undefined\n): void {\n\tif ( undefined === newValue ) {\n\t\tmap.delete( key );\n\t\treturn;\n\t}\n\n\tif ( haveValuesChanged< T[ K ] >( currentValue, newValue ) ) {\n\t\tmap.set( key, newValue );\n\t}\n}\n"],
|
|
5
|
-
"mappings": ";AAGA,OAAO,mBAAmB;AAM1B,SAAS,mCAAmC;AAC5C;AAAA,
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport fastDeepEqual from 'fast-deep-equal/es6/index.js';\n\n/**\n * WordPress dependencies\n */\n// @ts-expect-error No exported types.\nimport { __unstableSerializeAndClean } from '@wordpress/blocks';\nimport {\n\ttype CRDTDoc,\n\ttype ObjectData,\n\ttype ObjectID,\n\ttype ObjectType,\n\ttype SyncConfig,\n\tY,\n} from '@wordpress/sync';\n\n/**\n * Internal dependencies\n */\nimport { BaseAwareness } from '../awareness/base-awareness';\nimport {\n\tdeserializeBlockAttributes,\n\tmergeCrdtBlocks,\n\tmergeRichTextUpdate,\n\ttype Block,\n\ttype YBlock,\n\ttype YBlocks,\n} from './crdt-blocks';\nimport { type Post } from '../entity-types/post';\nimport { CRDT_DOC_META_PERSISTENCE_KEY, CRDT_RECORD_MAP_KEY } from '../sync';\nimport type { WPSelection } from '../types';\nimport {\n\tgetSelectionHistory,\n\tgetShiftedSelection,\n\tupdateSelectionHistory,\n} from './crdt-selection';\nimport {\n\tcreateYMap,\n\tgetRootMap,\n\tisYMap,\n\ttype YMapRecord,\n\ttype YMapWrap,\n} from './crdt-utils';\n\n// Changes that can be applied to a post entity record.\nexport type PostChanges = Partial< Post > & {\n\tblocks?: Block[];\n\tcontent?: Post[ 'content' ] | string;\n\texcerpt?: Post[ 'excerpt' ] | string;\n\tselection?: WPSelection;\n\ttitle?: Post[ 'title' ] | string;\n};\n\n// A post record as represented in the CRDT document (Y.Map).\nexport interface YPostRecord extends YMapRecord {\n\tauthor: number;\n\t// Blocks are undefined when they need to be re-parsed from content.\n\tblocks: YBlocks | undefined;\n\tcontent: Y.Text;\n\tcategories: number[];\n\tcomment_status: string;\n\tdate: string | null;\n\texcerpt: Y.Text;\n\tfeatured_media: number;\n\tformat: string;\n\tmeta: YMapWrap< YMapRecord >;\n\tping_status: string;\n\tslug: string;\n\tstatus: string;\n\tsticky: boolean;\n\ttags: number[];\n\ttemplate: string;\n\ttitle: Y.Text;\n}\n\nexport const POST_META_KEY_FOR_CRDT_DOC_PERSISTENCE = '_crdt_document';\n\n// Post meta keys that should *not* be synced.\nconst disallowedPostMetaKeys = new Set< string >( [\n\tPOST_META_KEY_FOR_CRDT_DOC_PERSISTENCE,\n] );\n\n/**\n * Given a set of local changes to a generic entity record, apply those changes\n * to the local Y.Doc.\n *\n * @param {CRDTDoc} ydoc\n * @param {Partial< ObjectData >} changes\n * @return {void}\n */\nfunction defaultApplyChangesToCRDTDoc(\n\tydoc: CRDTDoc,\n\tchanges: ObjectData\n): void {\n\tconst ymap = getRootMap( ydoc, CRDT_RECORD_MAP_KEY );\n\n\tObject.entries( changes ).forEach( ( [ key, newValue ] ) => {\n\t\t// Cannot serialize function values, so cannot sync them.\n\t\tif ( 'function' === typeof newValue ) {\n\t\t\treturn;\n\t\t}\n\n\t\tswitch ( key ) {\n\t\t\t// Add support for additional data types here.\n\n\t\t\tdefault: {\n\t\t\t\tconst currentValue = ymap.get( key );\n\t\t\t\tupdateMapValue( ymap, key, currentValue, newValue );\n\t\t\t}\n\t\t}\n\t} );\n}\n\n/**\n * Given a set of local changes to a post record, apply those changes to the\n * local Y.Doc.\n *\n * @param {CRDTDoc} ydoc\n * @param {PostChanges} changes\n * @param {Set<string>} syncedProperties\n * @return {void}\n */\nexport function applyPostChangesToCRDTDoc(\n\tydoc: CRDTDoc,\n\tchanges: PostChanges,\n\tsyncedProperties: Set< string >\n): void {\n\tconst ymap = getRootMap< YPostRecord >( ydoc, CRDT_RECORD_MAP_KEY );\n\n\tObject.keys( changes ).forEach( ( key ) => {\n\t\tif ( ! syncedProperties.has( key ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst newValue = changes[ key ];\n\n\t\t// Cannot serialize function values, so cannot sync them.\n\t\tif ( 'function' === typeof newValue ) {\n\t\t\treturn;\n\t\t}\n\n\t\tswitch ( key ) {\n\t\t\tcase 'blocks': {\n\t\t\t\t// Blocks are undefined when they need to be re-parsed from content.\n\t\t\t\tif ( ! newValue ) {\n\t\t\t\t\t// Set to undefined instead of deleting the key. This is important\n\t\t\t\t\t// since we iterate over the Y.Map keys in getPostChangesFromCRDTDoc.\n\t\t\t\t\tymap.set( key, undefined );\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tlet currentBlocks = ymap.get( key );\n\n\t\t\t\t// Initialize.\n\t\t\t\tif ( ! ( currentBlocks instanceof Y.Array ) ) {\n\t\t\t\t\tcurrentBlocks = new Y.Array< YBlock >();\n\t\t\t\t\tymap.set( key, currentBlocks );\n\t\t\t\t}\n\n\t\t\t\t// Block changes from typing are bundled with a 'selection' update.\n\t\t\t\t// Pass the resulting cursor position to the mergeCrdtBlocks function.\n\t\t\t\tconst cursorPosition =\n\t\t\t\t\tchanges.selection?.selectionStart?.offset ?? null;\n\n\t\t\t\t// Merge blocks does not need `setValue` because it is operating on a\n\t\t\t\t// Yjs type that is already in the Y.Doc.\n\t\t\t\tmergeCrdtBlocks( currentBlocks, newValue, cursorPosition );\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase 'content':\n\t\t\tcase 'excerpt':\n\t\t\tcase 'title': {\n\t\t\t\tconst currentValue = ymap.get( key );\n\t\t\t\tlet rawValue = getRawValue( newValue );\n\n\t\t\t\t// Copy logic from prePersistPostType to ensure that the \"Auto\n\t\t\t\t// Draft\" template title is not synced.\n\t\t\t\tif (\n\t\t\t\t\tkey === 'title' &&\n\t\t\t\t\t! currentValue?.toString() &&\n\t\t\t\t\t'Auto Draft' === rawValue\n\t\t\t\t) {\n\t\t\t\t\trawValue = '';\n\t\t\t\t}\n\n\t\t\t\tif ( currentValue instanceof Y.Text ) {\n\t\t\t\t\tmergeRichTextUpdate( currentValue, rawValue ?? '' );\n\t\t\t\t} else {\n\t\t\t\t\tconst newYText = new Y.Text( rawValue ?? '' );\n\t\t\t\t\tymap.set( key, newYText );\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t// \"Meta\" is overloaded term; here, it refers to post meta.\n\t\t\tcase 'meta': {\n\t\t\t\tlet metaMap = ymap.get( 'meta' );\n\n\t\t\t\t// Initialize.\n\t\t\t\tif ( ! isYMap( metaMap ) ) {\n\t\t\t\t\tmetaMap = createYMap< YMapRecord >();\n\t\t\t\t\tymap.set( 'meta', metaMap );\n\t\t\t\t}\n\n\t\t\t\t// Iterate over each meta property in the new value and merge it if it\n\t\t\t\t// should be synced.\n\t\t\t\tObject.entries( newValue ?? {} ).forEach(\n\t\t\t\t\t( [ metaKey, metaValue ] ) => {\n\t\t\t\t\t\tif ( disallowedPostMetaKeys.has( metaKey ) ) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tupdateMapValue(\n\t\t\t\t\t\t\tmetaMap,\n\t\t\t\t\t\t\tmetaKey,\n\t\t\t\t\t\t\tmetaMap.get( metaKey ), // current value in CRDT\n\t\t\t\t\t\t\tmetaValue // new value from changes\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase 'slug': {\n\t\t\t\t// Do not sync an empty slug. This indicates that the post is using\n\t\t\t\t// the default auto-generated slug.\n\t\t\t\tif ( ! newValue ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tconst currentValue = ymap.get( key );\n\t\t\t\tupdateMapValue( ymap, key, currentValue, newValue );\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t// Add support for additional properties here.\n\n\t\t\tdefault: {\n\t\t\t\tconst currentValue = ymap.get( key );\n\t\t\t\tupdateMapValue( ymap, key, currentValue, newValue );\n\t\t\t}\n\t\t}\n\t} );\n\n\t// Process changes that we don't want to persist to the CRDT document.\n\tif ( changes.selection ) {\n\t\tconst selection = changes.selection;\n\t\t// Persist selection changes at the end of the current event loop.\n\t\t// This allows undo meta to be saved with the current selection before\n\t\t// it is overwritten by the new selection from Gutenberg.\n\t\t// Without this, selection history will already contain the latest\n\t\t// selection (after this change) when the undo stack is saved.\n\t\tsetTimeout( () => {\n\t\t\tupdateSelectionHistory( ydoc, selection );\n\t\t}, 0 );\n\t}\n}\n\nfunction defaultGetChangesFromCRDTDoc( crdtDoc: CRDTDoc ): ObjectData {\n\treturn getRootMap( crdtDoc, CRDT_RECORD_MAP_KEY ).toJSON();\n}\n\n/**\n * Given a local Y.Doc that *may* contain changes from remote peers, compare\n * against the local record and determine if there are changes (edits) we want\n * to dispatch.\n *\n * @param {CRDTDoc} ydoc\n * @param {Post} editedRecord\n * @param {Set<string>} syncedProperties\n * @return {Partial<PostChanges>} The changes that should be applied to the local record.\n */\nexport function getPostChangesFromCRDTDoc(\n\tydoc: CRDTDoc,\n\teditedRecord: Post,\n\tsyncedProperties: Set< string >\n): PostChanges {\n\tconst ymap = getRootMap< YPostRecord >( ydoc, CRDT_RECORD_MAP_KEY );\n\n\tlet allowedMetaChanges: Post[ 'meta' ] = {};\n\n\tconst changes = Object.fromEntries(\n\t\tObject.entries( ymap.toJSON() ).filter( ( [ key, newValue ] ) => {\n\t\t\tif ( ! syncedProperties.has( key ) ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tconst currentValue = editedRecord[ key ];\n\n\t\t\tswitch ( key ) {\n\t\t\t\tcase 'blocks': {\n\t\t\t\t\t// When we are passed a persisted CRDT document, make a special\n\t\t\t\t\t// comparison of the content and blocks.\n\t\t\t\t\t//\n\t\t\t\t\t// When other fields (besides `blocks`) are mutated outside the block\n\t\t\t\t\t// editor, the change is caught by an equality check (see other cases\n\t\t\t\t\t// in this `switch` statement). As a transient property, `blocks`\n\t\t\t\t\t// cannot be directly mutated outside the block editor -- only\n\t\t\t\t\t// `content` can.\n\t\t\t\t\t//\n\t\t\t\t\t// Therefore, for this special comparison, we serialize the `blocks`\n\t\t\t\t\t// from the persisted CRDT document and compare that to the content\n\t\t\t\t\t// from the persisted record. If they differ, we know that the content\n\t\t\t\t\t// in the database has changed, and therefore the blocks have changed.\n\t\t\t\t\t//\n\t\t\t\t\t// We cannot directly compare the `blocks` from the CRDT document to\n\t\t\t\t\t// the `blocks` derived from the `content` in the persisted record,\n\t\t\t\t\t// because the latter will have different client IDs.\n\t\t\t\t\tif (\n\t\t\t\t\t\tydoc.meta?.get( CRDT_DOC_META_PERSISTENCE_KEY ) &&\n\t\t\t\t\t\teditedRecord.content\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst blocksJson = ymap.get( 'blocks' )?.toJSON() ?? [];\n\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t__unstableSerializeAndClean( blocksJson ).trim() !==\n\t\t\t\t\t\t\tgetRawValue( editedRecord.content )\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\n\t\t\t\tcase 'date': {\n\t\t\t\t\t// Do not overwrite a \"floating\" date. Borrowing logic from the\n\t\t\t\t\t// isEditedPostDateFloating selector.\n\t\t\t\t\tconst currentDateIsFloating =\n\t\t\t\t\t\tnull === currentValue ||\n\t\t\t\t\t\teditedRecord.modified === currentValue;\n\n\t\t\t\t\tif ( currentDateIsFloating ) {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn haveValuesChanged( currentValue, newValue );\n\t\t\t\t}\n\n\t\t\t\tcase 'meta': {\n\t\t\t\t\tconst currentMeta =\n\t\t\t\t\t\t( currentValue as PostChanges[ 'meta' ] ) ?? {};\n\n\t\t\t\t\tallowedMetaChanges = Object.fromEntries(\n\t\t\t\t\t\tObject.entries( newValue ?? {} ).filter(\n\t\t\t\t\t\t\t( [ metaKey ] ) => {\n\t\t\t\t\t\t\t\tif ( disallowedPostMetaKeys.has( metaKey ) ) {\n\t\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t// Ignore meta keys that are no longer registered\n\t\t\t\t\t\t\t\t// for this post (absent from the REST response).\n\t\t\t\t\t\t\t\t// Without this, orphaned CRDT meta would mark\n\t\t\t\t\t\t\t\t// the post permanently dirty.\n\t\t\t\t\t\t\t\treturn metaKey in currentMeta;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\n\t\t\t\t\t// Merge the allowed meta changes with the current meta values since\n\t\t\t\t\t// not all meta properties are synced.\n\t\t\t\t\tconst mergedValue = {\n\t\t\t\t\t\t...currentMeta,\n\t\t\t\t\t\t...allowedMetaChanges,\n\t\t\t\t\t};\n\n\t\t\t\t\treturn haveValuesChanged( currentValue, mergedValue );\n\t\t\t\t}\n\n\t\t\t\tcase 'status': {\n\t\t\t\t\t// Do not sync an invalid status.\n\t\t\t\t\tif ( 'auto-draft' === newValue ) {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn haveValuesChanged( currentValue, newValue );\n\t\t\t\t}\n\n\t\t\t\tcase 'content':\n\t\t\t\tcase 'excerpt':\n\t\t\t\tcase 'title': {\n\t\t\t\t\treturn haveValuesChanged(\n\t\t\t\t\t\tgetRawValue( currentValue ),\n\t\t\t\t\t\tnewValue\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\t// Add support for additional data types here.\n\n\t\t\t\tdefault: {\n\t\t\t\t\treturn haveValuesChanged( currentValue, newValue );\n\t\t\t\t}\n\t\t\t}\n\t\t} )\n\t);\n\n\t// Blocks extracted from the CRDT document have rich-text attributes as\n\t// plain strings (from Y.Text.toJSON()). Convert them back to RichTextData\n\t// so block edit components receive the same types as locally-created blocks.\n\tif ( changes.blocks ) {\n\t\tchanges.blocks = deserializeBlockAttributes(\n\t\t\tchanges.blocks as Block[]\n\t\t);\n\t}\n\n\t// Meta changes must be merged with the edited record since not all meta\n\t// properties are synced.\n\tif ( 'object' === typeof changes.meta ) {\n\t\tchanges.meta = {\n\t\t\t...editedRecord.meta,\n\t\t\t...allowedMetaChanges,\n\t\t};\n\t}\n\n\t// When remote content changes are detected, recalculate the local user's\n\t// selection using Y.RelativePosition to account for text shifts. The ydoc\n\t// has already been updated with remote content at this point, so converting\n\t// relative positions to absolute gives corrected offsets. Including the\n\t// selection in PostChanges ensures it dispatches atomically with content.\n\tconst selectionHistory = getSelectionHistory( ydoc );\n\tconst shiftedSelection = getShiftedSelection( ydoc, selectionHistory );\n\tif ( shiftedSelection ) {\n\t\tchanges.selection = {\n\t\t\t...shiftedSelection,\n\t\t\tinitialPosition: 0,\n\t\t};\n\t}\n\n\treturn changes;\n}\n\n/**\n * This default sync config can be used for entities that are flat maps of\n * primitive values and do not require custom logic to merge changes.\n */\nexport const defaultSyncConfig: SyncConfig = {\n\tapplyChangesToCRDTDoc: defaultApplyChangesToCRDTDoc,\n\tcreateAwareness: ( ydoc: CRDTDoc ) => new BaseAwareness( ydoc ),\n\tgetChangesFromCRDTDoc: defaultGetChangesFromCRDTDoc,\n};\n\n/**\n * This default collection sync config can be used to sync entity collections\n * (e.g., block comments) where we are not interested in merging changes at the\n * individual record level, but instead want to replace the entire collection\n * when changes are detected.\n */\nexport const defaultCollectionSyncConfig: SyncConfig = {\n\tapplyChangesToCRDTDoc: () => {},\n\tgetChangesFromCRDTDoc: () => ( {} ),\n\tshouldSync: ( _: ObjectType, objectId: ObjectID | null ) =>\n\t\tnull === objectId,\n};\n\n/**\n * Extract the raw string value from a property that may be a string or an object\n * with a `raw` property (`RenderedText`).\n *\n * @param {unknown} value The value to extract from.\n * @return {string|undefined} The raw string value, or undefined if it could not be determined.\n */\nfunction getRawValue( value?: unknown ): string | undefined {\n\t// Value may be a string property or a nested object with a `raw` property.\n\tif ( 'string' === typeof value ) {\n\t\treturn value;\n\t}\n\n\tif (\n\t\tvalue &&\n\t\t'object' === typeof value &&\n\t\t'raw' in value &&\n\t\t'string' === typeof value.raw\n\t) {\n\t\treturn value.raw;\n\t}\n\n\treturn undefined;\n}\n\nfunction haveValuesChanged< ValueType >(\n\tcurrentValue: ValueType | undefined,\n\tnewValue: ValueType | undefined\n): boolean {\n\treturn ! fastDeepEqual( currentValue, newValue );\n}\n\nfunction updateMapValue< T extends YMapRecord, K extends keyof T >(\n\tmap: YMapWrap< T >,\n\tkey: K,\n\tcurrentValue: T[ K ] | undefined,\n\tnewValue: T[ K ] | undefined\n): void {\n\tif ( undefined === newValue ) {\n\t\tmap.delete( key );\n\t\treturn;\n\t}\n\n\tif ( haveValuesChanged< T[ K ] >( currentValue, newValue ) ) {\n\t\tmap.set( key, newValue );\n\t}\n}\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/build-types/actions.d.ts
CHANGED
|
@@ -194,17 +194,6 @@ export function receiveNavigationFallbackId(fallbackId: integer): any;
|
|
|
194
194
|
* @return {Object} Action object.
|
|
195
195
|
*/
|
|
196
196
|
export function receiveDefaultTemplateId(query: any, templateId: string): any;
|
|
197
|
-
/**
|
|
198
|
-
* Returns an action object used to set the sync connection status for an entity or collection.
|
|
199
|
-
*
|
|
200
|
-
* @param {string} kind Kind of the entity.
|
|
201
|
-
* @param {string} name Name of the entity.
|
|
202
|
-
* @param {number|string|null} key The entity key, or null for collections.
|
|
203
|
-
* @param {Object|null} status The connection state object or null on unload.
|
|
204
|
-
*
|
|
205
|
-
* @return {Object} Action object.
|
|
206
|
-
*/
|
|
207
|
-
export function setSyncConnectionStatus(kind: string, name: string, key: number | string | null, status: any | null): any;
|
|
208
197
|
export function deleteEntityRecord(kind: string, name: string, recordId: number | string, query: any | null, { __unstableFetch, throwOnError }?: {
|
|
209
198
|
__unstableFetch?: Function | undefined;
|
|
210
199
|
throwOnError?: boolean | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../src/actions.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../src/actions.js"],"names":[],"mappings":"AAgCA;;;;;;;;;;GAUG;AACH,0CALW,MAAM,SACN,WAAY,OAUtB;AAED;;;;;;;;;GASG;AACH,0DAKC;AAED;;;;;;GAMG;AACH,kDAKC;AAED;;;;;;;;;;;GAWG;AACH,2CATW,MAAM,QACN,MAAM,WACN,WAAY,UACZ,UAAO,oBACN,OAAO,OAAA,UACR,UAAO,SACP,UAAO,OAgCjB;AAED;;;;;;;;;GASG;AACH,4DAKC;AAED;;;;;;;;;GASG;AACH,kFAJW,MAAM,OAWhB;AAED;;;;;;;;;;GAUG;AACH,uEALW,MAAM,0BAchB;AAED;;;;;;;;;;GAUG;AACH,4EALW,MAAM,0BAchB;AAED;;;;;;GAMG;AACH,4CAQC;AAED;;;;;;;;;;;;GAYG;AACH,4DALW,MAAM,yBAkBhB;AAED;;;;;;;;;;;GAWG;AACH,yCALW,MAAM,WACN,GAAC,OAUX;AA+sBD;;;;;;;;GAQG;AACH,+DAJW,OAAO,OAWjB;AAED;;;;;;;;;;;GAWG;AACH,2CALW,MAAM,aACN,OAAO,OAUjB;AAED;;;;;;;;;;;;;;GAcG;AACH;;QAKC;AAED;;;;;;;;;;;GAWG;AACH,yCALW,MAAM,aACN,WAAY,OAUtB;AAED;;;;;;GAMG;AACH,wDAHW,OAAO,OAQjB;AAED;;;;;;;GAOG;AACH,iEAJW,MAAM,OAUhB;AA1yBM,yCAZI,MAAM,QACN,MAAM,YACN,MAAM,GAAC,MAAM,SACb,UAAO,sCAGf;IAAgC,eAAe;IAGf,YAAY;CAE9C,IASQ;;;CAA2B,kCAiFlC;AAeK,uCATI,MAAM,QACN,MAAM,YACN,MAAM,GAAC,MAAM,wBAGrB;IAAgC,UAAU;CAE1C,OAqGD;AAYK,6CANI,MAAM,QACN,MAAM,YACN,MAAM,GAAC,MAAM,OAyCtB;AAMK,yBAEJ;;;CAAoB,UASrB;AAMK,yBAEJ;;;CAAoB,UASrB;AAOK,iDAIL;AAgBK,uCAXI,MAAM,QACN,MAAM,gEAGd;IAA2B,UAAU;IACV,eAAe;IAGf,YAAY;CAEzC,IAYQ;;;;CAAmC,kBAsO1C;AAwBK,sDAHK,CAAC,SAAS,KAAQ,iBAAY,CAuCxC;AAUK,6CALI,MAAM,QACN,MAAM,2BAEN,eAAO,IAIT;;;;CAAmC,kBAqB1C;AAWK,6DANI,MAAM,QACN,MAAM,YACN,MAAM,GAAC,MAAM,sCAMf;;;;CAAmC,kBAwC1C;AA2HK,uCARI,MAAM,QACN,MAAM,aACN,MAAM,GAAC,MAAM,WACb,WAAY,SACZ,UAAO,oBACN,OAAO,OAAA,qBACR,UAAO,IAIT;;;CAA2B,mBAsBlC"}
|
|
@@ -49,10 +49,10 @@ export declare class PostEditorAwareness extends BaseAwarenessState<PostEditorSt
|
|
|
49
49
|
* clientIds (e.g. in "Show Template" mode where blocks are cloned).
|
|
50
50
|
*
|
|
51
51
|
* @param selection - The selection state.
|
|
52
|
-
* @return The text
|
|
52
|
+
* @return The rich-text offset and block client ID, or nulls if not resolvable.
|
|
53
53
|
*/
|
|
54
54
|
convertSelectionStateToAbsolute(selection: SelectionState): {
|
|
55
|
-
|
|
55
|
+
richTextOffset: number | null;
|
|
56
56
|
localClientId: string | null;
|
|
57
57
|
};
|
|
58
58
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"post-editor-awareness.d.ts","sourceRoot":"","sources":["../../src/awareness/post-editor-awareness.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,iBAAiB,CAAC;AAIpC;;GAEG;AACH,OAAO,EAAE,kBAAkB,EAA2B,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"post-editor-awareness.d.ts","sourceRoot":"","sources":["../../src/awareness/post-editor-awareness.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,iBAAiB,CAAC;AAIpC;;GAEG;AACH,OAAO,EAAE,kBAAkB,EAA2B,MAAM,kBAAkB,CAAC;AAe/E,OAAO,KAAK,EAAE,cAAc,EAAoB,MAAM,UAAU,CAAC;AAEjE,OAAO,KAAK,EAEX,WAAW,EACX,eAAe,EAEf,aAAa,EACb,MAAM,SAAS,CAAC;AAEjB,qBAAa,mBAAoB,SAAQ,kBAAkB,CAAE,eAAe,CAAE;IAQ5E,OAAO,CAAC,IAAI;IACZ,OAAO,CAAC,IAAI;IACZ,OAAO,CAAC,MAAM;IATf,SAAS,CAAC,mBAAmB;+BA2KnB,WAAW,WACX,WAAW,KAClB,OAAO;;MA1KR;gBAGD,GAAG,EAAE,CAAC,CAAC,GAAG,EACF,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM;IAKvB,SAAS,CAAC,OAAO,IAAI,IAAI;IAMzB;;OAEG;IACH,OAAO,CAAC,uCAAuC;IAsG/C;;;;;;OAMG;YACW,6BAA6B;IA+B3C;;;;;;OAMG;IACH,OAAO,CAAC,oBAAoB;IAe5B;;;;;;;;;;;;;;;OAeG;IACI,+BAA+B,CAAE,SAAS,EAAE,cAAc,GAAI;QACpE,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;QAC9B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;KAC7B;IA0DD;;;;OAIG;IACH,OAAO,CAAC,OAAO;IAIf;;;;OAIG;IACI,YAAY,IAAI,aAAa;CAiEpC"}
|
|
@@ -23,7 +23,7 @@ export interface BaseState {
|
|
|
23
23
|
* The editor state includes information about the collaborator's current selection.
|
|
24
24
|
*/
|
|
25
25
|
export interface EditorState {
|
|
26
|
-
selection
|
|
26
|
+
selection?: SelectionState;
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
29
29
|
* The post editor state extends the base state with information used to render
|
|
@@ -59,4 +59,9 @@ export type SerializableYItem = Pick<Y.Item, 'id' | 'length' | 'origin' | 'right
|
|
|
59
59
|
right: SerializableYItemRef | null;
|
|
60
60
|
};
|
|
61
61
|
export type EqualityFieldCheck<State, FieldName extends keyof State> = (value1?: State[FieldName], value2?: State[FieldName]) => boolean;
|
|
62
|
+
export interface PostSaveEvent {
|
|
63
|
+
savedAt: number;
|
|
64
|
+
savedByClientId: number;
|
|
65
|
+
postStatus: string | undefined;
|
|
66
|
+
}
|
|
62
67
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/awareness/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,iBAAiB,CAAC;AAEzC;;GAEG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAE5C,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAClC,IAAI,CAAE,MAAM,CAAE,EACd,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,aAAa,CACtC,GAAG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;;;GAIG;AACH,MAAM,WAAW,SAAS;IACzB,gBAAgB,EAAE,gBAAgB,CAAC;CACnC;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC3B,SAAS,EAAE,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/awareness/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,iBAAiB,CAAC;AAEzC;;GAEG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAE5C,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAClC,IAAI,CAAE,MAAM,CAAE,EACd,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,aAAa,CACtC,GAAG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;;;GAIG;AACH,MAAM,WAAW,SAAS;IACzB,gBAAgB,EAAE,gBAAgB,CAAC;CACnC;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC3B,SAAS,CAAC,EAAE,cAAc,CAAC;CAC3B;AAED;;;GAGG;AACH,MAAM,WAAW,eAAgB,SAAQ,SAAS;IACjD,WAAW,CAAC,EAAE,WAAW,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,MAAM,aAAa,CAAE,KAAK,IAAK,KAAK,GAAG;IAC5C,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,OAAO,CAAC;IACrB,IAAI,EAAE,OAAO,CAAC;CACd,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,wBAAwB,GAAG,aAAa,CAAE,eAAe,CAAE,CAAC;AAGxE,MAAM,MAAM,qBAAqB,GAAG,IAAI,CAAE,gBAAgB,EAAE,MAAM,CAAE,GAAG;IACtE,QAAQ,EAAE,gBAAgB,CAAE,IAAI,CAAE,CAAC;CACnC,CAAC;AAEF,MAAM,WAAW,aAAa;IAC7B,GAAG,EAAE,MAAM,CAAE,MAAM,EAAE,OAAO,CAAE,CAAC;IAC/B,OAAO,EAAE,MAAM,CAAE,MAAM,EAAE,KAAK,CAAE,iBAAiB,CAAE,CAAE,CAAC;IACtD,eAAe,EAAE,MAAM,CAAE,MAAM,EAAE,qBAAqB,CAAE,CAAC;CACzD;AAGD,MAAM,MAAM,oBAAoB,GAAG,IAAI,CACtC,CAAC,CAAC,IAAI,EACN,IAAI,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,CACtC,CAAC;AAGF,MAAM,MAAM,iBAAiB,GAAG,IAAI,CACnC,CAAC,CAAC,IAAI,EACJ,IAAI,GACJ,QAAQ,GACR,QAAQ,GACR,aAAa,GACb,QAAQ,GACR,WAAW,GACX,QAAQ,GACR,SAAS,GACT,MAAM,CACR,GAAG;IACH,IAAI,EAAE,oBAAoB,GAAG,IAAI,CAAC;IAClC,KAAK,EAAE,oBAAoB,GAAG,IAAI,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,kBAAkB,CAAE,KAAK,EAAE,SAAS,SAAS,MAAM,KAAK,IAAK,CACxE,MAAM,CAAC,EAAE,KAAK,CAAE,SAAS,CAAE,EAC3B,MAAM,CAAC,EAAE,KAAK,CAAE,SAAS,CAAE,KACvB,OAAO,CAAC;AAEb,MAAM,WAAW,aAAa;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;CAC/B"}
|
|
@@ -14,6 +14,7 @@ export const rootEntitiesConfig: ({
|
|
|
14
14
|
supportsPagination?: undefined;
|
|
15
15
|
transientEdits?: undefined;
|
|
16
16
|
getTitle?: undefined;
|
|
17
|
+
syncConfig?: undefined;
|
|
17
18
|
getRevisionsUrl?: undefined;
|
|
18
19
|
} | {
|
|
19
20
|
label: import("@wordpress/i18n").TranslatableText<"Post Type">;
|
|
@@ -30,6 +31,7 @@ export const rootEntitiesConfig: ({
|
|
|
30
31
|
supportsPagination?: undefined;
|
|
31
32
|
transientEdits?: undefined;
|
|
32
33
|
getTitle?: undefined;
|
|
34
|
+
syncConfig?: undefined;
|
|
33
35
|
getRevisionsUrl?: undefined;
|
|
34
36
|
} | {
|
|
35
37
|
name: string;
|
|
@@ -46,6 +48,7 @@ export const rootEntitiesConfig: ({
|
|
|
46
48
|
key?: undefined;
|
|
47
49
|
transientEdits?: undefined;
|
|
48
50
|
getTitle?: undefined;
|
|
51
|
+
syncConfig?: undefined;
|
|
49
52
|
getRevisionsUrl?: undefined;
|
|
50
53
|
} | {
|
|
51
54
|
name: string;
|
|
@@ -62,6 +65,7 @@ export const rootEntitiesConfig: ({
|
|
|
62
65
|
supportsPagination?: undefined;
|
|
63
66
|
transientEdits?: undefined;
|
|
64
67
|
getTitle?: undefined;
|
|
68
|
+
syncConfig?: undefined;
|
|
65
69
|
getRevisionsUrl?: undefined;
|
|
66
70
|
} | {
|
|
67
71
|
name: string;
|
|
@@ -80,6 +84,7 @@ export const rootEntitiesConfig: ({
|
|
|
80
84
|
rawAttributes?: undefined;
|
|
81
85
|
supportsPagination?: undefined;
|
|
82
86
|
getTitle?: undefined;
|
|
87
|
+
syncConfig?: undefined;
|
|
83
88
|
getRevisionsUrl?: undefined;
|
|
84
89
|
} | {
|
|
85
90
|
name: string;
|
|
@@ -98,6 +103,7 @@ export const rootEntitiesConfig: ({
|
|
|
98
103
|
rawAttributes?: undefined;
|
|
99
104
|
supportsPagination?: undefined;
|
|
100
105
|
getTitle?: undefined;
|
|
106
|
+
syncConfig?: undefined;
|
|
101
107
|
getRevisionsUrl?: undefined;
|
|
102
108
|
} | {
|
|
103
109
|
name: string;
|
|
@@ -114,6 +120,7 @@ export const rootEntitiesConfig: ({
|
|
|
114
120
|
supportsPagination?: undefined;
|
|
115
121
|
transientEdits?: undefined;
|
|
116
122
|
getTitle?: undefined;
|
|
123
|
+
syncConfig?: undefined;
|
|
117
124
|
getRevisionsUrl?: undefined;
|
|
118
125
|
} | {
|
|
119
126
|
label: import("@wordpress/i18n").TranslatableText<"User">;
|
|
@@ -130,6 +137,7 @@ export const rootEntitiesConfig: ({
|
|
|
130
137
|
key?: undefined;
|
|
131
138
|
rawAttributes?: undefined;
|
|
132
139
|
transientEdits?: undefined;
|
|
140
|
+
syncConfig?: undefined;
|
|
133
141
|
getRevisionsUrl?: undefined;
|
|
134
142
|
} | {
|
|
135
143
|
name: string;
|
|
@@ -142,6 +150,7 @@ export const rootEntitiesConfig: ({
|
|
|
142
150
|
plural: string;
|
|
143
151
|
label: import("@wordpress/i18n").TranslatableText<"Comment">;
|
|
144
152
|
supportsPagination: boolean;
|
|
153
|
+
syncConfig: import("@wordpress/sync").SyncConfig;
|
|
145
154
|
key?: undefined;
|
|
146
155
|
rawAttributes?: undefined;
|
|
147
156
|
transientEdits?: undefined;
|
|
@@ -162,6 +171,7 @@ export const rootEntitiesConfig: ({
|
|
|
162
171
|
rawAttributes?: undefined;
|
|
163
172
|
transientEdits?: undefined;
|
|
164
173
|
getTitle?: undefined;
|
|
174
|
+
syncConfig?: undefined;
|
|
165
175
|
getRevisionsUrl?: undefined;
|
|
166
176
|
} | {
|
|
167
177
|
name: string;
|
|
@@ -178,6 +188,7 @@ export const rootEntitiesConfig: ({
|
|
|
178
188
|
key?: undefined;
|
|
179
189
|
transientEdits?: undefined;
|
|
180
190
|
getTitle?: undefined;
|
|
191
|
+
syncConfig?: undefined;
|
|
181
192
|
getRevisionsUrl?: undefined;
|
|
182
193
|
} | {
|
|
183
194
|
name: string;
|
|
@@ -194,6 +205,7 @@ export const rootEntitiesConfig: ({
|
|
|
194
205
|
supportsPagination?: undefined;
|
|
195
206
|
transientEdits?: undefined;
|
|
196
207
|
getTitle?: undefined;
|
|
208
|
+
syncConfig?: undefined;
|
|
197
209
|
getRevisionsUrl?: undefined;
|
|
198
210
|
} | {
|
|
199
211
|
label: import("@wordpress/i18n").TranslatableText<"Global Styles">;
|
|
@@ -211,6 +223,7 @@ export const rootEntitiesConfig: ({
|
|
|
211
223
|
key?: undefined;
|
|
212
224
|
rawAttributes?: undefined;
|
|
213
225
|
transientEdits?: undefined;
|
|
226
|
+
syncConfig?: undefined;
|
|
214
227
|
} | {
|
|
215
228
|
label: import("@wordpress/i18n").TranslatableText<"Themes">;
|
|
216
229
|
name: string;
|
|
@@ -226,6 +239,7 @@ export const rootEntitiesConfig: ({
|
|
|
226
239
|
supportsPagination?: undefined;
|
|
227
240
|
transientEdits?: undefined;
|
|
228
241
|
getTitle?: undefined;
|
|
242
|
+
syncConfig?: undefined;
|
|
229
243
|
getRevisionsUrl?: undefined;
|
|
230
244
|
} | {
|
|
231
245
|
label: import("@wordpress/i18n").TranslatableText<"Plugins">;
|
|
@@ -242,6 +256,7 @@ export const rootEntitiesConfig: ({
|
|
|
242
256
|
supportsPagination?: undefined;
|
|
243
257
|
transientEdits?: undefined;
|
|
244
258
|
getTitle?: undefined;
|
|
259
|
+
syncConfig?: undefined;
|
|
245
260
|
getRevisionsUrl?: undefined;
|
|
246
261
|
} | {
|
|
247
262
|
label: import("@wordpress/i18n").TranslatableText<"Status">;
|
|
@@ -258,6 +273,7 @@ export const rootEntitiesConfig: ({
|
|
|
258
273
|
supportsPagination?: undefined;
|
|
259
274
|
transientEdits?: undefined;
|
|
260
275
|
getTitle?: undefined;
|
|
276
|
+
syncConfig?: undefined;
|
|
261
277
|
getRevisionsUrl?: undefined;
|
|
262
278
|
} | {
|
|
263
279
|
label: import("@wordpress/i18n").TranslatableText<"Registered Templates">;
|
|
@@ -271,6 +287,7 @@ export const rootEntitiesConfig: ({
|
|
|
271
287
|
supportsPagination?: undefined;
|
|
272
288
|
transientEdits?: undefined;
|
|
273
289
|
getTitle?: undefined;
|
|
290
|
+
syncConfig?: undefined;
|
|
274
291
|
getRevisionsUrl?: undefined;
|
|
275
292
|
} | {
|
|
276
293
|
label: import("@wordpress/i18n").TranslatableText<"Font Collections">;
|
|
@@ -287,6 +304,7 @@ export const rootEntitiesConfig: ({
|
|
|
287
304
|
supportsPagination?: undefined;
|
|
288
305
|
transientEdits?: undefined;
|
|
289
306
|
getTitle?: undefined;
|
|
307
|
+
syncConfig?: undefined;
|
|
290
308
|
getRevisionsUrl?: undefined;
|
|
291
309
|
} | {
|
|
292
310
|
label: import("@wordpress/i18n").TranslatableText<"Icons">;
|
|
@@ -303,6 +321,7 @@ export const rootEntitiesConfig: ({
|
|
|
303
321
|
supportsPagination?: undefined;
|
|
304
322
|
transientEdits?: undefined;
|
|
305
323
|
getTitle?: undefined;
|
|
324
|
+
syncConfig?: undefined;
|
|
306
325
|
getRevisionsUrl?: undefined;
|
|
307
326
|
})[];
|
|
308
327
|
export namespace deprecatedEntities {
|
|
@@ -327,7 +346,7 @@ export const additionalEntityConfigLoaders: ({
|
|
|
327
346
|
plural: string;
|
|
328
347
|
loadEntities: typeof loadSiteEntity;
|
|
329
348
|
})[];
|
|
330
|
-
export function prePersistPostType(persistedRecord: any, edits: any, name: string, isTemplate: boolean): any
|
|
349
|
+
export function prePersistPostType(persistedRecord: any, edits: any, name: string, isTemplate: boolean): Promise<any>;
|
|
331
350
|
export function getMethodName(kind: string, name: string, prefix?: string): string;
|
|
332
351
|
/**
|
|
333
352
|
* Returns the list of post type entities.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entities.d.ts","sourceRoot":"","sources":["../src/entities.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"entities.d.ts","sourceRoot":"","sources":["../src/entities.js"],"names":[],"mappings":"AAyBA,iCAAkC,IAAI,CAAC;AAYvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA2ME;;;;;;;;;;;;AAcF;;;;;;;;;;KASE;AAWK,2EAJI,MAAM,cACN,OAAO,GACN,OAAO,KAAU,CA6C5B;AA0NM,oCANI,MAAM,QACN,MAAM,WACN,MAAM,GAEL,MAAM,CAMjB;AA5ND;;;;GAIG;AACH,sDAmIC;AA6BD;;;;GAIG;AACH,gDA0BC"}
|
|
@@ -2,19 +2,24 @@
|
|
|
2
2
|
* Context provider component for providing
|
|
3
3
|
* an entity for a specific entity.
|
|
4
4
|
*
|
|
5
|
-
* @param {Object} props
|
|
6
|
-
* @param {string} props.kind
|
|
7
|
-
* @param {string} props.type
|
|
8
|
-
* @param {number} props.id
|
|
9
|
-
* @param {
|
|
5
|
+
* @param {Object} props The component's props.
|
|
6
|
+
* @param {string} props.kind The entity kind.
|
|
7
|
+
* @param {string} props.type The entity name.
|
|
8
|
+
* @param {number} props.id The entity ID.
|
|
9
|
+
* @param {number} [props.revisionId] Optional revision ID. When set,
|
|
10
|
+
* `useEntityProp` reads from the
|
|
11
|
+
* revision record instead of the
|
|
12
|
+
* current entity.
|
|
13
|
+
* @param {*} props.children The children to wrap.
|
|
10
14
|
*
|
|
11
15
|
* @return {Object} The provided children, wrapped with
|
|
12
16
|
* the entity's context provider.
|
|
13
17
|
*/
|
|
14
|
-
export default function EntityProvider({ kind, type: name, id, children }: {
|
|
18
|
+
export default function EntityProvider({ kind, type: name, id, revisionId, children, }: {
|
|
15
19
|
kind: string;
|
|
16
20
|
type: string;
|
|
17
21
|
id: number;
|
|
22
|
+
revisionId?: number | undefined;
|
|
18
23
|
children: any;
|
|
19
24
|
}): any;
|
|
20
25
|
//# sourceMappingURL=entity-provider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entity-provider.d.ts","sourceRoot":"","sources":["../src/entity-provider.js"],"names":[],"mappings":"AAUA
|
|
1
|
+
{"version":3,"file":"entity-provider.d.ts","sourceRoot":"","sources":["../src/entity-provider.js"],"names":[],"mappings":"AAUA;;;;;;;;;;;;;;;;GAgBG;AACH,wFAZG;IAAsB,IAAI,EAAlB,MAAM;IACQ,IAAI,EAAlB,MAAM;IACQ,EAAE,EAAhB,MAAM;IACS,UAAU;IAIX,QAAQ,EAAtB,GAAC;CAET,OA6BF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-entity-prop.d.ts","sourceRoot":"","sources":["../../src/hooks/use-entity-prop.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-entity-prop.d.ts","sourceRoot":"","sources":["../../src/hooks/use-entity-prop.js"],"names":[],"mappings":"AAcA;;;;;;;;;;;;;;;;GAgBG;AACH,4CAZW,MAAM,QACN,MAAM,QACN,MAAM,QACN,MAAM,GAAC,MAAM,GAEZ,CAAC,GAAC,YAAY,GAAC,CAAC,CA2E3B"}
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import type { PostEditorAwarenessState as ActiveCollaborator, YDocDebugData } from '../awareness/types';
|
|
2
|
-
import type { SelectionState } from '../types';
|
|
3
|
-
interface ResolvedSelection {
|
|
4
|
-
textIndex: number | null;
|
|
5
|
-
localClientId: string | null;
|
|
6
|
-
}
|
|
1
|
+
import type { PostEditorAwarenessState as ActiveCollaborator, PostSaveEvent, YDocDebugData } from '../awareness/types';
|
|
2
|
+
import type { SelectionState, ResolvedSelection } from '../types';
|
|
7
3
|
/**
|
|
8
4
|
* Hook to get the active collaborators for a post editor.
|
|
9
5
|
*
|
|
@@ -36,5 +32,42 @@ export declare function useGetDebugData(postId: number | null, postType: string
|
|
|
36
32
|
* @return {boolean} Whether the current collaborator is disconnected.
|
|
37
33
|
*/
|
|
38
34
|
export declare function useIsDisconnected(postId: number | null, postType: string | null): boolean;
|
|
39
|
-
|
|
35
|
+
/**
|
|
36
|
+
* Hook that fires a callback when a new collaborator joins the post.
|
|
37
|
+
* Handles initial hydration and state diffing internally—consumers
|
|
38
|
+
* only receive "join" events for collaborators that appear after the
|
|
39
|
+
* initial state has loaded.
|
|
40
|
+
*
|
|
41
|
+
* The callback receives the joining collaborator and, when available,
|
|
42
|
+
* the current user's state (useful for comparing `enteredAt` timestamps).
|
|
43
|
+
*
|
|
44
|
+
* @param postId The ID of the post.
|
|
45
|
+
* @param postType The type of the post.
|
|
46
|
+
* @param callback Invoked for each collaborator that joins.
|
|
47
|
+
*/
|
|
48
|
+
export declare function useOnCollaboratorJoin(postId: number | null, postType: string | null, callback: (collaborator: ActiveCollaborator, me?: ActiveCollaborator) => void): void;
|
|
49
|
+
/**
|
|
50
|
+
* Hook that fires a callback when a collaborator leaves the post.
|
|
51
|
+
* A "leave" is detected when a previously-connected collaborator either
|
|
52
|
+
* transitions to `isConnected = false` or disappears from the list
|
|
53
|
+
* entirely while still connected. Already-disconnected collaborators
|
|
54
|
+
* that are later removed from the list are silently ignored.
|
|
55
|
+
*
|
|
56
|
+
* @param postId The ID of the post.
|
|
57
|
+
* @param postType The type of the post.
|
|
58
|
+
* @param callback Invoked for each collaborator that leaves.
|
|
59
|
+
*/
|
|
60
|
+
export declare function useOnCollaboratorLeave(postId: number | null, postType: string | null, callback: (collaborator: ActiveCollaborator) => void): void;
|
|
61
|
+
/**
|
|
62
|
+
* Hook that fires a callback when a remote collaborator saves the post.
|
|
63
|
+
* Only fires for saves by other collaborators (not the current user).
|
|
64
|
+
* Deduplicates by `savedAt` timestamp so the same save event is never
|
|
65
|
+
* reported twice.
|
|
66
|
+
*
|
|
67
|
+
* @param postId The ID of the post.
|
|
68
|
+
* @param postType The type of the post.
|
|
69
|
+
* @param callback Invoked with the save event, the collaborator who saved,
|
|
70
|
+
* and the previous save event (if any) for transition detection.
|
|
71
|
+
*/
|
|
72
|
+
export declare function useOnPostSave(postId: number | null, postType: string | null, callback: (event: PostSaveEvent, saver: ActiveCollaborator, prevEvent: PostSaveEvent | null) => void): void;
|
|
40
73
|
//# sourceMappingURL=use-post-editor-awareness-state.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-post-editor-awareness-state.d.ts","sourceRoot":"","sources":["../../src/hooks/use-post-editor-awareness-state.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-post-editor-awareness-state.d.ts","sourceRoot":"","sources":["../../src/hooks/use-post-editor-awareness-state.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EACX,wBAAwB,IAAI,kBAAkB,EAC9C,aAAa,EACb,aAAa,EACb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAoFlE;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACrC,MAAM,EAAE,MAAM,GAAG,IAAI,EACrB,QAAQ,EAAE,MAAM,GAAG,IAAI,GACrB,kBAAkB,EAAE,CAEtB;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CACnC,MAAM,EAAE,MAAM,GAAG,IAAI,EACrB,QAAQ,EAAE,MAAM,GAAG,IAAI,GACrB,CAAE,SAAS,EAAE,cAAc,KAAM,iBAAiB,CAEpD;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC9B,MAAM,EAAE,MAAM,GAAG,IAAI,EACrB,QAAQ,EAAE,MAAM,GAAG,IAAI,GACrB,aAAa,CAEf;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAChC,MAAM,EAAE,MAAM,GAAG,IAAI,EACrB,QAAQ,EAAE,MAAM,GAAG,IAAI,GACrB,OAAO,CAGT;AAsED;;;;;;;;;;;;GAYG;AACH,wBAAgB,qBAAqB,CACpC,MAAM,EAAE,MAAM,GAAG,IAAI,EACrB,QAAQ,EAAE,MAAM,GAAG,IAAI,EACvB,QAAQ,EAAE,CACT,YAAY,EAAE,kBAAkB,EAChC,EAAE,CAAC,EAAE,kBAAkB,KACnB,IAAI,GACP,IAAI,CAqCN;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,CACrC,MAAM,EAAE,MAAM,GAAG,IAAI,EACrB,QAAQ,EAAE,MAAM,GAAG,IAAI,EACvB,QAAQ,EAAE,CAAE,YAAY,EAAE,kBAAkB,KAAM,IAAI,GACpD,IAAI,CA8BN;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAC5B,MAAM,EAAE,MAAM,GAAG,IAAI,EACrB,QAAQ,EAAE,MAAM,GAAG,IAAI,EACvB,QAAQ,EAAE,CACT,KAAK,EAAE,aAAa,EACpB,KAAK,EAAE,kBAAkB,EACzB,SAAS,EAAE,aAAa,GAAG,IAAI,KAC3B,IAAI,GACP,IAAI,CA6BN"}
|
package/build-types/index.d.ts
CHANGED
|
@@ -27,7 +27,6 @@ export const store: import("@wordpress/data").StoreDescriptor<import("@wordpress
|
|
|
27
27
|
receiveAutosaves(postId: number, autosaves: any[] | any): any;
|
|
28
28
|
receiveNavigationFallbackId(fallbackId: integer): any;
|
|
29
29
|
receiveDefaultTemplateId(query: any, templateId: string): any;
|
|
30
|
-
setSyncConnectionStatus(kind: string, name: string, key: number | string | null, status: any | null): any;
|
|
31
30
|
deleteEntityRecord: (kind: string, name: string, recordId: number | string, query: any | null, { __unstableFetch, throwOnError }?: {
|
|
32
31
|
__unstableFetch?: Function | undefined;
|
|
33
32
|
throwOnError?: boolean | undefined;
|
|
@@ -269,7 +268,6 @@ export const store: import("@wordpress/data").StoreDescriptor<import("@wordpress
|
|
|
269
268
|
is_custom?: boolean;
|
|
270
269
|
ignore_empty?: boolean;
|
|
271
270
|
}): string;
|
|
272
|
-
getSyncConnectionStatus(state: selectors.State): import("@wordpress/sync").ConnectionStatus | undefined;
|
|
273
271
|
isRequestingEmbedPreview: {
|
|
274
272
|
(state: selectors.State, url: string): boolean;
|
|
275
273
|
isRegistrySelector?: boolean;
|
|
@@ -339,7 +337,6 @@ export const store: import("@wordpress/data").StoreDescriptor<import("@wordpress
|
|
|
339
337
|
getWidgets: (state: selectors.State, query?: selectors.GetRecordsHttpQuery) => import("./entity-types").Widget<"edit">[] | null;
|
|
340
338
|
getWidgetTypes: (state: selectors.State, query?: selectors.GetRecordsHttpQuery) => import("./entity-types").WidgetType<"edit">[] | null;
|
|
341
339
|
}>>;
|
|
342
|
-
export { SelectionType } from "./utils/crdt-user-selections";
|
|
343
340
|
export { default as EntityProvider } from "./entity-provider";
|
|
344
341
|
export * from "./entity-provider";
|
|
345
342
|
export * from "./entity-types";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":"AA6HA;;;;GAIG;AACH;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":"AA6HA;;;;GAIG;AACH;;;;;;;;;;;;;;;;;;;;;;4CAay/vB,OAAO;;yBAAryqB,YAAO,EAAC,YAAO,EAAC,yBAAW,EAAC,iBAAQ,EAAC;;;KAA4D,MAAe;;;KAA4B;uBAAi0E,YAAK,EAAC,YAAK,EAAC,yBAAS,EAAC,UAAM,EAAC;;KAAa;6BAA8qG,YAAK,EAAC,YAAK,EAAC,yBAAS;iBAAs4B;;;KAAqB;iBAA4R;;;KAAqB;;uBAAutC,YAAO,EAAC,YAAO,EAAC,WAAS,EAAC;;;;KAA4F,MAAe;;;;KAAoC;0BAAm+N,eAAS;6BAAgtC,YAAK,EAAC,YAAK,EAAC,aAAS,EAAC,yBAAQ,MAAc;;;;KAAoC;6CAAslC,YAAK,EAAC,YAAK,EAAC,yBAAS,EAAC,kBAAY,EAAC,YAAQ,MAAc;;;;KAAoC;uBAAgzJ,YAAK,EAAC,YAAK,EAAC,0BAAU,EAAC,oBAAQ,EAAC,iBAAM,EAAC,6CAAwB,EAAC,gBAAK,MAAc;;;KAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iCAAlkV,sBAAc,EAAC,YAAc,EAAC,YAAc,EAAC,oCAA4B;iCAAu9B,sBAAc,EAAC,YAAc,EAAC,YAAc,EAAC,oCAA4B;;;;;;;;;;;;;;;;;;;;mBAAykqB,sBAAc,EAAC,YAAc,EAAC,YAAc,EAAC,0BAA4B,EAAC,qCAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAbn9pC;;;;;;;;;2BAzHxC,aAAa"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared cache of blocks parsed from an entity's `content` string, keyed by
|
|
3
|
+
* `kind:name:id`. Populated both eagerly by the `getEntityRecord` resolver
|
|
4
|
+
* (when the sync manager parses content for transient edits) and lazily by
|
|
5
|
+
* `useEntityBlockEditor`. The stored `content` string acts as a validator so
|
|
6
|
+
* stale entries are discarded when the underlying record changes.
|
|
7
|
+
*/
|
|
8
|
+
export declare const parsedBlocksCache: Map<any, any>;
|
|
9
|
+
export declare function getCacheKey(kind: any, name: any, id: any): string;
|
|
10
|
+
//# sourceMappingURL=parsed-blocks-cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parsed-blocks-cache.d.ts","sourceRoot":"","sources":["../src/parsed-blocks-cache.js"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,eAAY,CAAC;AAE3C,wBAAgB,WAAW,CAAE,IAAI,KAAA,EAAE,IAAI,KAAA,EAAE,EAAE,KAAA,UAE1C"}
|