@wordpress/core-data 7.38.1-next.v.0 → 7.39.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.
Files changed (85) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/actions.cjs +17 -6
  3. package/build/actions.cjs.map +2 -2
  4. package/build/awareness/base-awareness.cjs +62 -0
  5. package/build/awareness/base-awareness.cjs.map +7 -0
  6. package/build/awareness/post-editor-awareness.cjs +4 -18
  7. package/build/awareness/post-editor-awareness.cjs.map +3 -3
  8. package/build/entities.cjs +14 -2
  9. package/build/entities.cjs.map +2 -2
  10. package/build/resolvers.cjs +40 -0
  11. package/build/resolvers.cjs.map +2 -2
  12. package/build/types.cjs.map +1 -1
  13. package/build/utils/block-selection-history.cjs +101 -0
  14. package/build/utils/block-selection-history.cjs.map +7 -0
  15. package/build/utils/crdt-selection.cjs +139 -0
  16. package/build/utils/crdt-selection.cjs.map +7 -0
  17. package/build/utils/crdt-user-selections.cjs +2 -2
  18. package/build/utils/crdt-user-selections.cjs.map +2 -2
  19. package/build/utils/crdt-utils.cjs +29 -0
  20. package/build/utils/crdt-utils.cjs.map +3 -3
  21. package/build/utils/crdt.cjs +16 -4
  22. package/build/utils/crdt.cjs.map +2 -2
  23. package/build-module/actions.mjs +17 -6
  24. package/build-module/actions.mjs.map +2 -2
  25. package/build-module/awareness/base-awareness.mjs +35 -0
  26. package/build-module/awareness/base-awareness.mjs.map +7 -0
  27. package/build-module/awareness/post-editor-awareness.mjs +4 -18
  28. package/build-module/awareness/post-editor-awareness.mjs.map +2 -2
  29. package/build-module/entities.mjs +15 -2
  30. package/build-module/entities.mjs.map +2 -2
  31. package/build-module/resolvers.mjs +40 -0
  32. package/build-module/resolvers.mjs.map +2 -2
  33. package/build-module/utils/block-selection-history.mjs +75 -0
  34. package/build-module/utils/block-selection-history.mjs.map +7 -0
  35. package/build-module/utils/crdt-selection.mjs +115 -0
  36. package/build-module/utils/crdt-selection.mjs.map +7 -0
  37. package/build-module/utils/crdt-user-selections.mjs +2 -2
  38. package/build-module/utils/crdt-user-selections.mjs.map +2 -2
  39. package/build-module/utils/crdt-utils.mjs +28 -0
  40. package/build-module/utils/crdt-utils.mjs.map +2 -2
  41. package/build-module/utils/crdt.mjs +18 -3
  42. package/build-module/utils/crdt.mjs.map +2 -2
  43. package/build-types/actions.d.ts.map +1 -1
  44. package/build-types/awareness/base-awareness.d.ts +19 -0
  45. package/build-types/awareness/base-awareness.d.ts.map +1 -0
  46. package/build-types/awareness/post-editor-awareness.d.ts +7 -8
  47. package/build-types/awareness/post-editor-awareness.d.ts.map +1 -1
  48. package/build-types/entities.d.ts.map +1 -1
  49. package/build-types/entity-types/test/attachment.test.d.ts +10 -0
  50. package/build-types/entity-types/test/attachment.test.d.ts.map +1 -0
  51. package/build-types/index.d.ts.map +1 -1
  52. package/build-types/resolvers.d.ts.map +1 -1
  53. package/build-types/types.d.ts +12 -2
  54. package/build-types/types.d.ts.map +1 -1
  55. package/build-types/utils/block-selection-history.d.ts +47 -0
  56. package/build-types/utils/block-selection-history.d.ts.map +1 -0
  57. package/build-types/utils/crdt-selection.d.ts +16 -0
  58. package/build-types/utils/crdt-selection.d.ts.map +1 -0
  59. package/build-types/utils/crdt-user-selections.d.ts.map +1 -1
  60. package/build-types/utils/crdt-utils.d.ts +12 -0
  61. package/build-types/utils/crdt-utils.d.ts.map +1 -1
  62. package/build-types/utils/crdt.d.ts +8 -14
  63. package/build-types/utils/crdt.d.ts.map +1 -1
  64. package/build-types/utils/test/block-selection-history.test.d.ts +2 -0
  65. package/build-types/utils/test/block-selection-history.test.d.ts.map +1 -0
  66. package/build-types/utils/test/crdt-blocks.d.ts +2 -0
  67. package/build-types/utils/test/crdt-blocks.d.ts.map +1 -0
  68. package/build-types/utils/test/crdt.d.ts +2 -0
  69. package/build-types/utils/test/crdt.d.ts.map +1 -0
  70. package/package.json +21 -19
  71. package/src/actions.js +40 -7
  72. package/src/awareness/base-awareness.ts +50 -0
  73. package/src/awareness/post-editor-awareness.ts +4 -24
  74. package/src/entities.js +18 -2
  75. package/src/entity-types/test/attachment.test.ts +4 -4
  76. package/src/resolvers.js +51 -0
  77. package/src/test/actions.js +402 -0
  78. package/src/test/resolvers.js +4 -0
  79. package/src/types.ts +12 -3
  80. package/src/utils/block-selection-history.ts +176 -0
  81. package/src/utils/crdt-selection.ts +205 -0
  82. package/src/utils/crdt-user-selections.ts +7 -3
  83. package/src/utils/crdt-utils.ts +54 -0
  84. package/src/utils/crdt.ts +36 -3
  85. package/src/utils/test/block-selection-history.test.ts +764 -0
@@ -1,5 +1,6 @@
1
1
  // packages/core-data/src/utils/crdt-utils.ts
2
2
  import { Y } from "@wordpress/sync";
3
+ import { CRDT_RECORD_MAP_KEY } from "../sync.mjs";
3
4
  function getRootMap(doc, key) {
4
5
  return doc.getMap(key);
5
6
  }
@@ -9,8 +10,35 @@ function createYMap(partial = {}) {
9
10
  function isYMap(value) {
10
11
  return value instanceof Y.Map;
11
12
  }
13
+ function findBlockByClientIdInDoc(blockId, ydoc) {
14
+ const ymap = getRootMap(ydoc, CRDT_RECORD_MAP_KEY);
15
+ const blocks = ymap.get("blocks");
16
+ if (!(blocks instanceof Y.Array)) {
17
+ return null;
18
+ }
19
+ return findBlockByClientIdInBlocks(blockId, blocks);
20
+ }
21
+ function findBlockByClientIdInBlocks(blockId, blocks) {
22
+ for (const block of blocks) {
23
+ if (block.get("clientId") === blockId) {
24
+ return block;
25
+ }
26
+ const innerBlocks = block.get("innerBlocks");
27
+ if (innerBlocks && innerBlocks.length > 0) {
28
+ const innerBlock = findBlockByClientIdInBlocks(
29
+ blockId,
30
+ innerBlocks
31
+ );
32
+ if (innerBlock) {
33
+ return innerBlock;
34
+ }
35
+ }
36
+ }
37
+ return null;
38
+ }
12
39
  export {
13
40
  createYMap,
41
+ findBlockByClientIdInDoc,
14
42
  getRootMap,
15
43
  isYMap
16
44
  };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/utils/crdt-utils.ts"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { Y } from '@wordpress/sync';\n\n/**\n * A YMapRecord represents the shape of the data stored in a Y.Map.\n */\nexport type YMapRecord = Record< string, unknown >;\n\n/**\n * A wrapper around Y.Map to provide type safety. The generic type accepted by\n * Y.Map represents the union of possible values of the map, which are varied in\n * many cases. This type is accurate, but its non-specificity requires aggressive\n * type narrowing or type casting / destruction with `as`.\n *\n * This type provides type enhancements so that the correct value type can be\n * inferred based on the provided key. It is just a type wrap / overlay, and\n * does not change the runtime behavior of Y.Map.\n *\n * This interface cannot extend Y.Map directly due to the limitations of\n * TypeScript's structural typing. One negative consequence of this is that\n * `instanceof` checks against Y.Map continue to work at runtime but will blur\n * the type at compile time. To navigate this, use the `isYMap` function below.\n */\nexport interface YMapWrap< T extends YMapRecord > extends Y.AbstractType< T > {\n\tdelete: < K extends keyof T >( key: K ) => void;\n\tforEach: (\n\t\tcallback: (\n\t\t\tvalue: T[ keyof T ],\n\t\t\tkey: keyof T,\n\t\t\tmap: YMapWrap< T >\n\t\t) => void\n\t) => void;\n\thas: < K extends keyof T >( key: K ) => boolean;\n\tget: < K extends keyof T >( key: K ) => T[ K ] | undefined;\n\tset: < K extends keyof T >( key: K, value: T[ K ] ) => void;\n\ttoJSON: () => T;\n\t// add types for other Y.Map methods as needed\n}\n\n/**\n * Get or create a root-level Map for the given Y.Doc. Use this instead of\n * doc.getMap() for additional type safety.\n *\n * @param doc Y.Doc\n * @param key Map key\n */\nexport function getRootMap< T extends YMapRecord >(\n\tdoc: Y.Doc,\n\tkey: string\n): YMapWrap< T > {\n\treturn doc.getMap< T >( key ) as unknown as YMapWrap< T >;\n}\n\n/**\n * Create a new Y.Map (provided with YMapWrap type), optionally initialized with\n * data. Use this instead of `new Y.Map()` for additional type safety.\n *\n * @param partial Partial data to initialize the map with.\n */\nexport function createYMap< T extends YMapRecord >(\n\tpartial: Partial< T > = {}\n): YMapWrap< T > {\n\treturn new Y.Map( Object.entries( partial ) ) as unknown as YMapWrap< T >;\n}\n\n/**\n * Type guard to check if a value is a Y.Map without losing type information.\n *\n * @param value Value to check.\n */\nexport function isYMap< T extends YMapRecord >(\n\tvalue: YMapWrap< T > | undefined\n): value is YMapWrap< T > {\n\treturn value instanceof Y.Map;\n}\n"],
5
- "mappings": ";AAGA,SAAS,SAAS;AA6CX,SAAS,WACf,KACA,KACgB;AAChB,SAAO,IAAI,OAAa,GAAI;AAC7B;AAQO,SAAS,WACf,UAAwB,CAAC,GACT;AAChB,SAAO,IAAI,EAAE,IAAK,OAAO,QAAS,OAAQ,CAAE;AAC7C;AAOO,SAAS,OACf,OACyB;AACzB,SAAO,iBAAiB,EAAE;AAC3B;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { Y } from '@wordpress/sync';\n\n/**\n * Internal dependencies\n */\nimport type { YBlock, YBlocks } from './crdt-blocks';\nimport type { YPostRecord } from './crdt';\nimport { CRDT_RECORD_MAP_KEY } from '../sync';\n\n/**\n * A YMapRecord represents the shape of the data stored in a Y.Map.\n */\nexport type YMapRecord = Record< string, unknown >;\n\n/**\n * A wrapper around Y.Map to provide type safety. The generic type accepted by\n * Y.Map represents the union of possible values of the map, which are varied in\n * many cases. This type is accurate, but its non-specificity requires aggressive\n * type narrowing or type casting / destruction with `as`.\n *\n * This type provides type enhancements so that the correct value type can be\n * inferred based on the provided key. It is just a type wrap / overlay, and\n * does not change the runtime behavior of Y.Map.\n *\n * This interface cannot extend Y.Map directly due to the limitations of\n * TypeScript's structural typing. One negative consequence of this is that\n * `instanceof` checks against Y.Map continue to work at runtime but will blur\n * the type at compile time. To navigate this, use the `isYMap` function below.\n */\nexport interface YMapWrap< T extends YMapRecord > extends Y.AbstractType< T > {\n\tdelete: < K extends keyof T >( key: K ) => void;\n\tforEach: (\n\t\tcallback: (\n\t\t\tvalue: T[ keyof T ],\n\t\t\tkey: keyof T,\n\t\t\tmap: YMapWrap< T >\n\t\t) => void\n\t) => void;\n\thas: < K extends keyof T >( key: K ) => boolean;\n\tget: < K extends keyof T >( key: K ) => T[ K ] | undefined;\n\tset: < K extends keyof T >( key: K, value: T[ K ] ) => void;\n\ttoJSON: () => T;\n\t// add types for other Y.Map methods as needed\n}\n\n/**\n * Get or create a root-level Map for the given Y.Doc. Use this instead of\n * doc.getMap() for additional type safety.\n *\n * @param doc Y.Doc\n * @param key Map key\n */\nexport function getRootMap< T extends YMapRecord >(\n\tdoc: Y.Doc,\n\tkey: string\n): YMapWrap< T > {\n\treturn doc.getMap< T >( key ) as unknown as YMapWrap< T >;\n}\n\n/**\n * Create a new Y.Map (provided with YMapWrap type), optionally initialized with\n * data. Use this instead of `new Y.Map()` for additional type safety.\n *\n * @param partial Partial data to initialize the map with.\n */\nexport function createYMap< T extends YMapRecord >(\n\tpartial: Partial< T > = {}\n): YMapWrap< T > {\n\treturn new Y.Map( Object.entries( partial ) ) as unknown as YMapWrap< T >;\n}\n\n/**\n * Type guard to check if a value is a Y.Map without losing type information.\n *\n * @param value Value to check.\n */\nexport function isYMap< T extends YMapRecord >(\n\tvalue: YMapWrap< T > | undefined\n): value is YMapWrap< T > {\n\treturn value instanceof Y.Map;\n}\n\n/**\n * Given a block ID and a Y.Doc, find the block in the document.\n *\n * @param blockId The block ID to find\n * @param ydoc The Y.Doc to find the block in\n * @return The block, or null if the block is not found\n */\nexport function findBlockByClientIdInDoc(\n\tblockId: string,\n\tydoc: Y.Doc\n): YBlock | null {\n\tconst ymap = getRootMap< YPostRecord >( ydoc, CRDT_RECORD_MAP_KEY );\n\tconst blocks = ymap.get( 'blocks' );\n\n\tif ( ! ( blocks instanceof Y.Array ) ) {\n\t\treturn null;\n\t}\n\n\treturn findBlockByClientIdInBlocks( blockId, blocks );\n}\n\nfunction findBlockByClientIdInBlocks(\n\tblockId: string,\n\tblocks: YBlocks\n): YBlock | null {\n\tfor ( const block of blocks ) {\n\t\tif ( block.get( 'clientId' ) === blockId ) {\n\t\t\treturn block;\n\t\t}\n\n\t\tconst innerBlocks = block.get( 'innerBlocks' );\n\n\t\tif ( innerBlocks && innerBlocks.length > 0 ) {\n\t\t\tconst innerBlock = findBlockByClientIdInBlocks(\n\t\t\t\tblockId,\n\t\t\t\tinnerBlocks\n\t\t\t);\n\n\t\t\tif ( innerBlock ) {\n\t\t\t\treturn innerBlock;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn null;\n}\n"],
5
+ "mappings": ";AAGA,SAAS,SAAS;AAOlB,SAAS,2BAA2B;AA6C7B,SAAS,WACf,KACA,KACgB;AAChB,SAAO,IAAI,OAAa,GAAI;AAC7B;AAQO,SAAS,WACf,UAAwB,CAAC,GACT;AAChB,SAAO,IAAI,EAAE,IAAK,OAAO,QAAS,OAAQ,CAAE;AAC7C;AAOO,SAAS,OACf,OACyB;AACzB,SAAO,iBAAiB,EAAE;AAC3B;AASO,SAAS,yBACf,SACA,MACgB;AAChB,QAAM,OAAO,WAA2B,MAAM,mBAAoB;AAClE,QAAM,SAAS,KAAK,IAAK,QAAS;AAElC,MAAK,EAAI,kBAAkB,EAAE,QAAU;AACtC,WAAO;AAAA,EACR;AAEA,SAAO,4BAA6B,SAAS,MAAO;AACrD;AAEA,SAAS,4BACR,SACA,QACgB;AAChB,aAAY,SAAS,QAAS;AAC7B,QAAK,MAAM,IAAK,UAAW,MAAM,SAAU;AAC1C,aAAO;AAAA,IACR;AAEA,UAAM,cAAc,MAAM,IAAK,aAAc;AAE7C,QAAK,eAAe,YAAY,SAAS,GAAI;AAC5C,YAAM,aAAa;AAAA,QAClB;AAAA,QACA;AAAA,MACD;AAEA,UAAK,YAAa;AACjB,eAAO;AAAA,MACR;AAAA,IACD;AAAA,EACD;AAEA,SAAO;AACR;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,10 @@
1
1
  // packages/core-data/src/utils/crdt.ts
2
2
  import fastDeepEqual from "fast-deep-equal/es6/index.js";
3
3
  import { __unstableSerializeAndClean } from "@wordpress/blocks";
4
- import { Y } from "@wordpress/sync";
4
+ import {
5
+ Y
6
+ } from "@wordpress/sync";
7
+ import { BaseAwareness } from "../awareness/base-awareness.mjs";
5
8
  import {
6
9
  mergeCrdtBlocks
7
10
  } from "./crdt-blocks.mjs";
@@ -10,6 +13,7 @@ import {
10
13
  CRDT_RECORD_MAP_KEY,
11
14
  WORDPRESS_META_KEY_FOR_CRDT_DOC_PERSISTENCE
12
15
  } from "../sync.mjs";
16
+ import { updateSelectionHistory } from "./crdt-selection.mjs";
13
17
  import {
14
18
  createYMap,
15
19
  getRootMap,
@@ -18,6 +22,7 @@ import {
18
22
  var allowedPostProperties = /* @__PURE__ */ new Set([
19
23
  "author",
20
24
  "blocks",
25
+ "categories",
21
26
  "comment_status",
22
27
  "date",
23
28
  "excerpt",
@@ -126,6 +131,12 @@ function applyPostChangesToCRDTDoc(ydoc, changes, _postType) {
126
131
  }
127
132
  }
128
133
  });
134
+ if (changes.selection) {
135
+ const selection = changes.selection;
136
+ setTimeout(() => {
137
+ updateSelectionHistory(ydoc, selection);
138
+ }, 0);
139
+ }
129
140
  }
130
141
  function defaultGetChangesFromCRDTDoc(crdtDoc) {
131
142
  return getRootMap(crdtDoc, CRDT_RECORD_MAP_KEY).toJSON();
@@ -198,6 +209,11 @@ function getPostChangesFromCRDTDoc(ydoc, editedRecord, _postType) {
198
209
  }
199
210
  return changes;
200
211
  }
212
+ var defaultSyncConfig = {
213
+ applyChangesToCRDTDoc: defaultApplyChangesToCRDTDoc,
214
+ createAwareness: (ydoc) => new BaseAwareness(ydoc),
215
+ getChangesFromCRDTDoc: defaultGetChangesFromCRDTDoc
216
+ };
201
217
  function getRawValue(value) {
202
218
  if ("string" === typeof value) {
203
219
  return value;
@@ -221,8 +237,7 @@ function updateMapValue(map, key, currentValue, newValue) {
221
237
  }
222
238
  export {
223
239
  applyPostChangesToCRDTDoc,
224
- defaultApplyChangesToCRDTDoc,
225
- defaultGetChangesFromCRDTDoc,
240
+ defaultSyncConfig,
226
241
  getPostChangesFromCRDTDoc
227
242
  };
228
243
  //# sourceMappingURL=crdt.mjs.map
@@ -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 { type CRDTDoc, type ObjectData, Y } from '@wordpress/sync';\n\n/**\n * Internal dependencies\n */\nimport {\n\tmergeCrdtBlocks,\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 {\n\tCRDT_DOC_META_PERSISTENCE_KEY,\n\tCRDT_RECORD_MAP_KEY,\n\tWORDPRESS_META_KEY_FOR_CRDT_DOC_PERSISTENCE,\n} from '../sync';\nimport type { WPSelection } from '../types';\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\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\tblocks: YBlocks;\n\tcomment_status: string;\n\tdate: string | null;\n\texcerpt: string;\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: string;\n}\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'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\tWORDPRESS_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 */\nexport function 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\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[] from local changes.\n\t\t\t\tconst newBlocks = ( newValue as PostChanges[ 'blocks' ] ) ?? [];\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, newBlocks, cursorPosition );\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase 'excerpt': {\n\t\t\t\tconst currentValue = ymap.get( 'excerpt' );\n\t\t\t\tconst rawNewValue = getRawValue( newValue );\n\n\t\t\t\tupdateMapValue( ymap, key, currentValue, rawNewValue );\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\tcase 'title': {\n\t\t\t\tconst currentValue = ymap.get( key );\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\tlet rawNewValue = getRawValue( newValue );\n\t\t\t\tif ( ! currentValue && 'Auto Draft' === rawNewValue ) {\n\t\t\t\t\trawNewValue = '';\n\t\t\t\t}\n\n\t\t\t\tupdateMapValue( ymap, key, currentValue, rawNewValue );\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\nexport function 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 blocks = ymap.get( 'blocks' ) as YBlocks;\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t__unstableSerializeAndClean(\n\t\t\t\t\t\t\t\tblocks.toJSON()\n\t\t\t\t\t\t\t).trim() !== editedRecord.content.raw.trim()\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 '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\treturn changes;\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,SAAwC,SAAS;AAKjD;AAAA,EACC;AAAA,OAIM;AAGP;AAAA,EACC;AAAA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K;AAAA,QACL,KAAK,SAAS;AACb,iBAAO;AAAA,YACN,YAAa,YAAa;AAAA,YAC1B;AAAA,UACD;AAAA,QACD;AAAA;AAAA,QAIA,SAAS;AACR,iBAAO,kBAAmB,cAAc,QAAS;AAAA,QAClD;AAAA,MACD;AAAA,IACD,CAAE;AAAA,EACH;AAIA,MAAK,aAAa,OAAO,QAAQ,MAAO;AACvC,YAAQ,OAAO;AAAA,MACd,GAAG,aAAa;AAAA,MAChB,GAAG;AAAA,IACJ;AAAA,EACD;AAEA,SAAO;AACR;AASA,SAAS,YAAa,OAAsC;AAE3D,MAAK,aAAa,OAAO,OAAQ;AAChC,WAAO;AAAA,EACR;AAEA,MACC,SACA,aAAa,OAAO,SACpB,SAAS,SACT,aAAa,OAAO,MAAM,KACzB;AACD,WAAO,MAAM;AAAA,EACd;AAEA,SAAO;AACR;AAEA,SAAS,kBACR,cACA,UACU;AACV,SAAO,CAAE,cAAe,cAAc,QAAS;AAChD;AAEA,SAAS,eACR,KACA,KACA,cACA,UACO;AACP,MAAK,WAAc,UAAW;AAC7B,QAAI,OAAQ,GAAI;AAChB;AAAA,EACD;AAEA,MAAK,kBAA6B,cAAc,QAAS,GAAI;AAC5D,QAAI,IAAK,KAAK,QAAS;AAAA,EACxB;AACD;",
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 { type BaseState } from '../awareness/types';\nimport {\n\tmergeCrdtBlocks,\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 {\n\tCRDT_DOC_META_PERSISTENCE_KEY,\n\tCRDT_RECORD_MAP_KEY,\n\tWORDPRESS_META_KEY_FOR_CRDT_DOC_PERSISTENCE,\n} from '../sync';\nimport type { WPSelection } from '../types';\nimport { updateSelectionHistory } 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\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\tblocks: YBlocks;\n\tcategories: number[];\n\tcomment_status: string;\n\tdate: string | null;\n\texcerpt: string;\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: string;\n}\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'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\tWORDPRESS_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\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[] from local changes.\n\t\t\t\tconst newBlocks = ( newValue as PostChanges[ 'blocks' ] ) ?? [];\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, newBlocks, cursorPosition );\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase 'excerpt': {\n\t\t\t\tconst currentValue = ymap.get( 'excerpt' );\n\t\t\t\tconst rawNewValue = getRawValue( newValue );\n\n\t\t\t\tupdateMapValue( ymap, key, currentValue, rawNewValue );\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\tcase 'title': {\n\t\t\t\tconst currentValue = ymap.get( key );\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\tlet rawNewValue = getRawValue( newValue );\n\t\t\t\tif ( ! currentValue && 'Auto Draft' === rawNewValue ) {\n\t\t\t\t\trawNewValue = '';\n\t\t\t\t}\n\n\t\t\t\tupdateMapValue( ymap, key, currentValue, rawNewValue );\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 blocks = ymap.get( 'blocks' ) as YBlocks;\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t__unstableSerializeAndClean(\n\t\t\t\t\t\t\t\tblocks.toJSON()\n\t\t\t\t\t\t\t).trim() !== editedRecord.content.raw.trim()\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 '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\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< BaseState > = {\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": ";A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
  }
@@ -1 +1 @@
1
- {"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../src/actions.js"],"names":[],"mappings":"AAwBA;;;;;;;;;;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,OAmCjB;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;AA0nBD;;;;;;;;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;AArtBM,yCAZI,MAAM,QACN,MAAM,YACN,MAAM,GAAC,MAAM,SACb,UAAO,sCAGf;IAAgC,eAAe;IAGf,YAAY;CAE9C,IASQ;;;CAA2B,kCA0ElC;AAeK,uCATI,MAAM,QACN,MAAM,YACN,MAAM,GAAC,MAAM,wBAGrB;IAAgC,UAAU;CAE1C,OAwED;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"}
1
+ {"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../src/actions.js"],"names":[],"mappings":"AAwBA;;;;;;;;;;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,OAmCjB;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;AA2pBD;;;;;;;;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;AAtvBM,yCAZI,MAAM,QACN,MAAM,YACN,MAAM,GAAC,MAAM,SACb,UAAO,sCAGf;IAAgC,eAAe;IAGf,YAAY;CAE9C,IASQ;;;CAA2B,kCAmFlC;AAeK,uCATI,MAAM,QACN,MAAM,YACN,MAAM,GAAC,MAAM,wBAGrB;IAAgC,UAAU;CAE1C,OAgGD;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"}
@@ -0,0 +1,19 @@
1
+ import { AwarenessState } from '@wordpress/sync';
2
+ import { areUserInfosEqual } from './utils';
3
+ import type { BaseState } from './types';
4
+ export declare abstract class BaseAwarenessState<State extends BaseState> extends AwarenessState<State> {
5
+ setUp(): void;
6
+ /**
7
+ * Set the current user info in the local state.
8
+ */
9
+ private setCurrentUserInfo;
10
+ }
11
+ export declare const baseEqualityFieldChecks: {
12
+ userInfo: typeof areUserInfosEqual;
13
+ };
14
+ export declare class BaseAwareness extends BaseAwarenessState<BaseState> {
15
+ protected equalityFieldChecks: {
16
+ userInfo: typeof areUserInfosEqual;
17
+ };
18
+ }
19
+ //# sourceMappingURL=base-awareness.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-awareness.d.ts","sourceRoot":"","sources":["../../src/awareness/base-awareness.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAMjD,OAAO,EAAoB,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC,8BAAsB,kBAAkB,CACvC,KAAK,SAAS,SAAS,CACtB,SAAQ,cAAc,CAAE,KAAK,CAAE;IACzB,KAAK,IAAI,IAAI;IAMpB;;OAEG;IACH,OAAO,CAAC,kBAAkB;CAe1B;AAED,eAAO,MAAM,uBAAuB;;CAEnC,CAAC;AAEF,qBAAa,aAAc,SAAQ,kBAAkB,CAAE,SAAS,CAAE;IACjE,SAAS,CAAC,mBAAmB;;MAA2B;CACxD"}
@@ -1,20 +1,19 @@
1
- import { AwarenessState, type Y } from '@wordpress/sync';
2
- import { areUserInfosEqual } from './utils';
1
+ import type { Y } from '@wordpress/sync';
2
+ /**
3
+ * Internal dependencies
4
+ */
5
+ import { BaseAwarenessState } from './base-awareness';
3
6
  import type { EditorState, PostEditorState } from './types';
4
- export declare class PostEditorAwareness extends AwarenessState<PostEditorState> {
7
+ export declare class PostEditorAwareness extends BaseAwarenessState<PostEditorState> {
5
8
  private kind;
6
9
  private name;
7
10
  private postId;
8
11
  protected equalityFieldChecks: {
9
12
  editorState: (state1?: EditorState, state2?: EditorState) => boolean;
10
- userInfo: typeof areUserInfosEqual;
13
+ userInfo: typeof import("./utils").areUserInfosEqual;
11
14
  };
12
15
  constructor(doc: Y.Doc, kind: string, name: string, postId: number);
13
16
  setUp(): void;
14
- /**
15
- * Set the current user info in the local state.
16
- */
17
- private setCurrentUserInfo;
18
17
  /**
19
18
  * Subscribe to user selection changes and update the selection state.
20
19
  */
@@ -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,KAAK,CAAC,EAAE,MAAM,iBAAiB,CAAC;AAYzD,OAAO,EAAoB,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAO9D,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE5D,qBAAa,mBAAoB,SAAQ,cAAc,CAAE,eAAe,CAAE;IAQxE,OAAO,CAAC,IAAI;IACZ,OAAO,CAAC,IAAI;IACZ,OAAO,CAAC,MAAM;IATf,SAAS,CAAC,mBAAmB;+BAuJnB,WAAW,WACX,WAAW,KAClB,OAAO;;MAtJR;gBAGD,GAAG,EAAE,CAAC,CAAC,GAAG,EACF,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM;IAKhB,KAAK,IAAI,IAAI;IAOpB;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAgB1B;;OAEG;IACH,OAAO,CAAC,+BAA+B;IA8DvC;;;;;;OAMG;YACW,6BAA6B;IA+B3C;;;;;;OAMG;IACH,OAAO,CAAC,oBAAoB;CAU5B"}
1
+ {"version":3,"file":"post-editor-awareness.d.ts","sourceRoot":"","sources":["../../src/awareness/post-editor-awareness.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,iBAAiB,CAAC;AAIzC;;GAEG;AACH,OAAO,EAAE,kBAAkB,EAA2B,MAAM,kBAAkB,CAAC;AAY/E,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE5D,qBAAa,mBAAoB,SAAQ,kBAAkB,CAAE,eAAe,CAAE;IAQ5E,OAAO,CAAC,IAAI;IACZ,OAAO,CAAC,IAAI;IACZ,OAAO,CAAC,MAAM;IATf,SAAS,CAAC,mBAAmB;+BAmInB,WAAW,WACX,WAAW,KAClB,OAAO;;MAlIR;gBAGD,GAAG,EAAE,CAAC,CAAC,GAAG,EACF,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM;IAKhB,KAAK,IAAI,IAAI;IAMpB;;OAEG;IACH,OAAO,CAAC,+BAA+B;IA8DvC;;;;;;OAMG;YACW,6BAA6B;IA+B3C;;;;;;OAMG;IACH,OAAO,CAAC,oBAAoB;CAU5B"}
@@ -1 +1 @@
1
- {"version":3,"file":"entities.d.ts","sourceRoot":"","sources":["../src/entities.js"],"names":[],"mappings":"AAsBA,iCAAkC,IAAI,CAAC;AAYvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA2LE;;;;;;;;;;;;AAcF;;;;;;;;;;KASE;AAWK,2EAJI,MAAM,cACN,OAAO,OA0CjB;AAwLM,oCANI,MAAM,QACN,MAAM,WACN,MAAM,GAEL,MAAM,CAMjB;AA1LD;;;;GAIG;AACH,sDAqGC;AAyBD;;;;GAIG;AACH,gDA0BC"}
1
+ {"version":3,"file":"entities.d.ts","sourceRoot":"","sources":["../src/entities.js"],"names":[],"mappings":"AAuBA,iCAAkC,IAAI,CAAC;AAYvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAoMI;;;;;;;;;;;;AAcJ;;;;;;;;;;KASE;AAWK,2EAJI,MAAM,cACN,OAAO,OA0CjB;AA8LM,oCANI,MAAM,QACN,MAAM,WACN,MAAM,GAEL,MAAM,CAMjB;AAhMD;;;;GAIG;AACH,sDAqGC;AA+BD;;;;GAIG;AACH,gDA0BC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Tests for the Attachment type against real REST API responses.
3
+ *
4
+ * These tests validate the Attachment type definition by comparing it with
5
+ * real JSON responses from the WordPress REST API's media endpoint. The fixtures
6
+ * are from the REST API's edit context, which includes edit-only fields like
7
+ * permalink_template, generated_slug, and missing_image_sizes.
8
+ */
9
+ export {};
10
+ //# sourceMappingURL=attachment.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attachment.test.d.ts","sourceRoot":"","sources":["../../../src/entity-types/test/attachment.test.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":"AA6HA;;;;GAIG;AACH;;;;;;;;;;;;;;;;;;;;;;4CAWg+qB,OAAO;;yBAA5ylB,YAAO,EAAC,YAAO,EAAC,yBAAW,EAAC,iBAAQ,EAAC;;;KAA4D,MAAe;;;KAA4B;uBAA8oE,YAAK,EAAC,YAAK,EAAC,yBAAS,EAAC,UAAM,EAAC;;KAAa;iBAAyzD;;;KAAqB;iBAA4R;;;KAAqB;;uBAAutC,YAAO,EAAC,YAAO,EAAC,WAAS,EAAC;;;;KAA4F,MAAe;;;;KAAoC;0BAA66N,eAAS;6BAAgtC,YAAK,EAAC,YAAK,EAAC,aAAS,EAAC,yBAAQ,MAAc;;;;KAAoC;6CAAslC,YAAK,EAAC,YAAK,EAAC,yBAAS,EAAC,k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-1,10 +1,20 @@
1
1
  export interface AnyFunction {
2
2
  (...args: any[]): any;
3
3
  }
4
+ /**
5
+ * Avoid a circular dependency with @wordpress/editor
6
+ *
7
+ * Additionaly, this type marks `attributeKey` and `offset` as possibly
8
+ * `undefined`, which can happen in two known scenarios:
9
+ *
10
+ * 1. If a user has an entire block highlighted (e.g., a `core/image` block).
11
+ * 2. If there's an intermediate selection state while inserting a block, those
12
+ * properties will be temporarily`undefined`.
13
+ */
4
14
  export interface WPBlockSelection {
5
15
  clientId: string;
6
- attributeKey: string;
7
- offset: number;
16
+ attributeKey?: string;
17
+ offset?: number;
8
18
  }
9
19
  export interface WPSelection {
10
20
  selectionEnd: WPBlockSelection;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC3B,CAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAI,GAAG,CAAC;CACxB;AAGD,MAAM,WAAW,gBAAgB;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,WAAW;IAC3B,YAAY,EAAE,gBAAgB,CAAC;IAC/B,cAAc,EAAE,gBAAgB,CAAC;CACjC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC3B,CAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAI,GAAG,CAAC;CACxB;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,gBAAgB;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,WAAW;IAC3B,YAAY,EAAE,gBAAgB,CAAC;IAC/B,cAAc,EAAE,gBAAgB,CAAC;CACjC"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ /**
5
+ * WordPress dependencies
6
+ */
7
+ import { Y } from '@wordpress/sync';
8
+ import type { WPSelection } from '../types';
9
+ export declare enum YSelectionType {
10
+ RelativeSelection = "RelativeSelection",
11
+ BlockSelection = "BlockSelection"
12
+ }
13
+ export interface YRelativeSelection {
14
+ type: YSelectionType.RelativeSelection;
15
+ attributeKey: string;
16
+ relativePosition: Y.RelativePosition;
17
+ clientId: string;
18
+ offset: number;
19
+ }
20
+ export interface YBlockSelection {
21
+ type: YSelectionType.BlockSelection;
22
+ clientId: string;
23
+ }
24
+ export type YSelection = YRelativeSelection | YBlockSelection;
25
+ export type YFullSelection = {
26
+ start: YSelection;
27
+ end: YSelection;
28
+ };
29
+ export interface YSelectionHistory {
30
+ selection: YFullSelection;
31
+ backupSelections?: YFullSelection[];
32
+ }
33
+ export interface BlockSelectionHistory {
34
+ getSelectionHistory: () => YFullSelection[];
35
+ updateSelection: (newSelection: WPSelection) => void;
36
+ }
37
+ /**
38
+ * This function is used to track recent block selections to help in restoring
39
+ * a user's selection after an undo or redo operation.
40
+ *
41
+ * Maintains a history array for previous selections, which can be used for
42
+ * backup restoration locations.
43
+ * @param ydoc
44
+ * @param historySize
45
+ */
46
+ export declare function createBlockSelectionHistory(ydoc: Y.Doc, historySize?: number): BlockSelectionHistory;
47
+ //# sourceMappingURL=block-selection-history.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"block-selection-history.d.ts","sourceRoot":"","sources":["../../src/utils/block-selection-history.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;GAEG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,iBAAiB,CAAC;AAMpC,OAAO,KAAK,EAAoB,WAAW,EAAE,MAAM,UAAU,CAAC;AAK9D,oBAAY,cAAc;IACzB,iBAAiB,sBAAsB;IACvC,cAAc,mBAAmB;CACjC;AAED,MAAM,WAAW,kBAAkB;IAClC,IAAI,EAAE,cAAc,CAAC,iBAAiB,CAAC;IACvC,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,CAAC,CAAC,gBAAgB,CAAC;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,eAAe;IAC/B,IAAI,EAAE,cAAc,CAAC,cAAc,CAAC;IACpC,QAAQ,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,MAAM,UAAU,GAAG,kBAAkB,GAAG,eAAe,CAAC;AAE9D,MAAM,MAAM,cAAc,GAAG;IAC5B,KAAK,EAAE,UAAU,CAAC;IAClB,GAAG,EAAE,UAAU,CAAC;CAChB,CAAC;AAEF,MAAM,WAAW,iBAAiB;IACjC,SAAS,EAAE,cAAc,CAAC;IAC1B,gBAAgB,CAAC,EAAE,cAAc,EAAE,CAAC;CACpC;AAED,MAAM,WAAW,qBAAqB;IACrC,mBAAmB,EAAE,MAAM,cAAc,EAAE,CAAC;IAC5C,eAAe,EAAE,CAAE,YAAY,EAAE,WAAW,KAAM,IAAI,CAAC;CACvD;AAED;;;;;;;;GAQG;AACH,wBAAgB,2BAA2B,CAC1C,IAAI,EAAE,CAAC,CAAC,GAAG,EACX,WAAW,GAAE,MAAuC,GAClD,qBAAqB,CAgEvB"}
@@ -0,0 +1,16 @@
1
+ import { type CRDTDoc, Y } from '@wordpress/sync';
2
+ /**
3
+ * Internal dependencies
4
+ */
5
+ import { type YFullSelection } from './block-selection-history';
6
+ import type { WPSelection } from '../types';
7
+ export declare function getSelectionHistory(ydoc: CRDTDoc): YFullSelection[];
8
+ export declare function updateSelectionHistory(ydoc: CRDTDoc, wpSelection: WPSelection): void;
9
+ /**
10
+ * Restore the selection to the most recent selection in history that is
11
+ * available in the document.
12
+ * @param selectionHistory The selection history to restore
13
+ * @param ydoc The Y.Doc where blocks are stored
14
+ */
15
+ export declare function restoreSelection(selectionHistory: YFullSelection[], ydoc: Y.Doc): void;
16
+ //# sourceMappingURL=crdt-selection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crdt-selection.d.ts","sourceRoot":"","sources":["../../src/utils/crdt-selection.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,KAAK,OAAO,EAAE,CAAC,EAAE,MAAM,iBAAiB,CAAC;AAElD;;GAEG;AACH,OAAO,EAIN,KAAK,cAAc,EAEnB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,KAAK,EAAoB,WAAW,EAAE,MAAM,UAAU,CAAC;AAsB9D,wBAAgB,mBAAmB,CAAE,IAAI,EAAE,OAAO,GAAI,cAAc,EAAE,CAErE;AAED,wBAAgB,sBAAsB,CACrC,IAAI,EAAE,OAAO,EACb,WAAW,EAAE,WAAW,GACtB,IAAI,CAEN;AAkFD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC/B,gBAAgB,EAAE,cAAc,EAAE,EAClC,IAAI,EAAE,CAAC,CAAC,GAAG,GACT,IAAI,CA6DN"}
@@ -1 +1 @@
1
- {"version":3,"file":"crdt-user-selections.d.ts","sourceRoot":"","sources":["../../src/utils/crdt-user-selections.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,CAAC,EAAuB,MAAM,iBAAiB,CAAC;AAQzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAEjD;;GAEG;AACH,oBAAY,aAAa;IACxB,IAAI,SAAS;IACb,MAAM,WAAW;IACjB,mBAAmB,2BAA2B;IAC9C,yBAAyB,iCAAiC;IAC1D,UAAU,gBAAgB;CAC1B;AAED;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC5B,gBAAgB,EAAE,CAAC,CAAC,gBAAgB,CAAC;IAYrC,cAAc,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAE3B,IAAI,EAAE,aAAa,CAAC,IAAI,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAE7B,IAAI,EAAE,a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kED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACvC,UAAU,EAAE,cAAc,EAC1B,UAAU,EAAE,cAAc,GACxB,OAAO,CA2DT"}
@@ -2,6 +2,10 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { Y } from '@wordpress/sync';
5
+ /**
6
+ * Internal dependencies
7
+ */
8
+ import type { YBlock } from './crdt-blocks';
5
9
  /**
6
10
  * A YMapRecord represents the shape of the data stored in a Y.Map.
7
11
  */
@@ -50,4 +54,12 @@ export declare function createYMap<T extends YMapRecord>(partial?: Partial<T>):
50
54
  * @param value Value to check.
51
55
  */
52
56
  export declare function isYMap<T extends YMapRecord>(value: YMapWrap<T> | undefined): value is YMapWrap<T>;
57
+ /**
58
+ * Given a block ID and a Y.Doc, find the block in the document.
59
+ *
60
+ * @param blockId The block ID to find
61
+ * @param ydoc The Y.Doc to find the block in
62
+ * @return The block, or null if the block is not found
63
+ */
64
+ export declare function findBlockByClientIdInDoc(blockId: string, ydoc: Y.Doc): YBlock | null;
53
65
  //# sourceMappingURL=crdt-utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"crdt-utils.d.ts","sourceRoot":"","sources":["../../src/utils/crdt-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,iBAAiB,CAAC;AAEpC;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAE,MAAM,EAAE,OAAO,CAAE,CAAC;AAEnD;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,QAAQ,CAAE,CAAC,SAAS,UAAU,CAAG,SAAQ,CAAC,CAAC,YAAY,CAAE,CAAC,CAAE;IAC5E,MAAM,EAAE,CAAE,CAAC,SAAS,MAAM,CAAC,EAAI,GAAG,EAAE,CAAC,KAAM,IAAI,CAAC;IAChD,OAAO,EAAE,CACR,QAAQ,EAAE,CACT,KAAK,EAAE,CAAC,CAAE,MAAM,CAAC,CAAE,EACnB,GAAG,EAAE,MA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C,CAAE,CAExB;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACvC,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,CAAC,CAAC,GAAG,GACT,MAAM,GAAG,IAAI,CASf"}
@@ -1,7 +1,5 @@
1
- import { type CRDTDoc, type ObjectData } from '@wordpress/sync';
2
- /**
3
- * Internal dependencies
4
- */
1
+ import { type CRDTDoc, type SyncConfig } from '@wordpress/sync';
2
+ import { type BaseState } from '../awareness/types';
5
3
  import { type Block, type YBlocks } from './crdt-blocks';
6
4
  import { type Post } from '../entity-types/post';
7
5
  import { type Type } from '../entity-types';
@@ -16,6 +14,7 @@ export type PostChanges = Partial<Post> & {
16
14
  export interface YPostRecord extends YMapRecord {
17
15
  author: number;
18
16
  blocks: YBlocks;
17
+ categories: number[];
19
18
  comment_status: string;
20
19
  date: string | null;
21
20
  excerpt: string;
@@ -30,15 +29,6 @@ export interface YPostRecord extends YMapRecord {
30
29
  template: string;
31
30
  title: string;
32
31
  }
33
- /**
34
- * Given a set of local changes to a generic entity record, apply those changes
35
- * to the local Y.Doc.
36
- *
37
- * @param {CRDTDoc} ydoc
38
- * @param {Partial< ObjectData >} changes
39
- * @return {void}
40
- */
41
- export declare function defaultApplyChangesToCRDTDoc(ydoc: CRDTDoc, changes: ObjectData): void;
42
32
  /**
43
33
  * Given a set of local changes to a post record, apply those changes to the
44
34
  * local Y.Doc.
@@ -49,7 +39,6 @@ export declare function defaultApplyChangesToCRDTDoc(ydoc: CRDTDoc, changes: Obj
49
39
  * @return {void}
50
40
  */
51
41
  export declare function applyPostChangesToCRDTDoc(ydoc: CRDTDoc, changes: PostChanges, _postType: Type): void;
52
- export declare function defaultGetChangesFromCRDTDoc(crdtDoc: CRDTDoc): ObjectData;
53
42
  /**
54
43
  * Given a local Y.Doc that *may* contain changes from remote peers, compare
55
44
  * against the local record and determine if there are changes (edits) we want
@@ -61,4 +50,9 @@ export declare function defaultGetChangesFromCRDTDoc(crdtDoc: CRDTDoc): ObjectDa
61
50
  * @return {Partial<PostChanges>} The changes that should be applied to the local record.
62
51
  */
63
52
  export declare function getPostChangesFromCRDTDoc(ydoc: CRDTDoc, editedRecord: Post, _postType: Type): PostChanges;
53
+ /**
54
+ * This default sync config can be used for entities that are flat maps of
55
+ * primitive values and do not require custom logic to merge changes.
56
+ */
57
+ export declare const defaultSyncConfig: SyncConfig<BaseState>;
64
58
  //# sourceMappingURL=crdt.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"crdt.d.ts","sourceRoot":"","sources":["../../src/utils/crdt.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,UAAU,EAAK,MAAM,iBAAiB,CAAC;AAEnE;;GAEG;AACH,OAAO,EAEN,KAAK,KAAK,EAEV,KAAK,OAAO,EACZ,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAM5C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAIN,KAAK,UAAU,EACf,KAAK,QAAQ,EACb,MAAM,cAAc,CAAC;AAGtB,MAAM,MAAM,WAAW,GAAG,OAAO,CAAE,IAAI,CAAE,GAAG;IAC3C,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC;IACjB,OAAO,CAAC,EAAE,IAAI,CAAE,SAAS,CAAE,GAAG,MAAM,CAAC;IACrC,SAAS,CAAC,EAAE,WAAW,CAAC;IACxB,KAAK,CAAC,EAAE,IAAI,CAAE,OAAO,CAAE,GAAG,MAAM,CAAC;CACjC,CAAC;AAGF,MAAM,WAAW,WAAY,SAAQ,UAAU;IAC9C,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,OAAO,CAAC;IAChB,cAAc,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,OAAO,EAAE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AE,SAAS,CAIpD,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=block-selection-history.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"block-selection-history.test.d.ts","sourceRoot":"","sources":["../../../src/utils/test/block-selection-history.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=crdt-blocks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crdt-blocks.d.ts","sourceRoot":"","sources":["../../../src/utils/test/crdt-blocks.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=crdt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crdt.d.ts","sourceRoot":"","sources":["../../../src/utils/test/crdt.ts"],"names":[],"mappings":""}