@wordpress/core-data 7.41.0 → 7.41.2-next.v.202603161435.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/README.md +19 -0
- package/build/actions.cjs +25 -31
- package/build/actions.cjs.map +2 -2
- package/build/awareness/post-editor-awareness.cjs +34 -1
- package/build/awareness/post-editor-awareness.cjs.map +2 -2
- package/build/awareness/types.cjs.map +1 -1
- package/build/entities.cjs +3 -2
- 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 +83 -2
- package/build/hooks/use-post-editor-awareness-state.cjs.map +2 -2
- package/build/index.cjs +3 -0
- package/build/index.cjs.map +2 -2
- package/build/private-actions.cjs +1 -1
- package/build/private-actions.cjs.map +2 -2
- package/build/private-apis.cjs +3 -1
- package/build/private-apis.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/queried-data/selectors.cjs +7 -4
- package/build/queried-data/selectors.cjs.map +2 -2
- package/build/reducer.cjs +2 -1
- package/build/reducer.cjs.map +2 -2
- package/build/resolvers.cjs +114 -76
- package/build/resolvers.cjs.map +2 -2
- package/build/selectors.cjs +29 -0
- package/build/selectors.cjs.map +2 -2
- package/build/sync.cjs +3 -0
- package/build/sync.cjs.map +2 -2
- package/build/types.cjs +16 -0
- package/build/types.cjs.map +3 -3
- package/build/utils/crdt-blocks.cjs +22 -26
- package/build/utils/crdt-blocks.cjs.map +2 -2
- package/build/utils/crdt-user-selections.cjs +8 -5
- package/build/utils/crdt-user-selections.cjs.map +2 -2
- package/build/utils/crdt.cjs +1 -3
- package/build/utils/crdt.cjs.map +2 -2
- package/build/utils/index.cjs +3 -0
- package/build/utils/index.cjs.map +2 -2
- package/build/utils/normalize-query-for-resolution.cjs +35 -0
- package/build/utils/normalize-query-for-resolution.cjs.map +7 -0
- package/build/utils/user-permissions.cjs +1 -4
- package/build/utils/user-permissions.cjs.map +2 -2
- package/build-module/actions.mjs +30 -32
- package/build-module/actions.mjs.map +2 -2
- package/build-module/awareness/post-editor-awareness.mjs +34 -1
- package/build-module/awareness/post-editor-awareness.mjs.map +2 -2
- package/build-module/entities.mjs +3 -2
- 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 +80 -1
- package/build-module/hooks/use-post-editor-awareness-state.mjs.map +2 -2
- package/build-module/index.mjs +2 -0
- package/build-module/index.mjs.map +2 -2
- package/build-module/private-actions.mjs +1 -1
- package/build-module/private-actions.mjs.map +2 -2
- package/build-module/private-apis.mjs +6 -2
- package/build-module/private-apis.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/queried-data/selectors.mjs +7 -4
- package/build-module/queried-data/selectors.mjs.map +2 -2
- package/build-module/reducer.mjs +2 -1
- package/build-module/reducer.mjs.map +2 -2
- package/build-module/resolvers.mjs +116 -77
- package/build-module/resolvers.mjs.map +2 -2
- package/build-module/selectors.mjs +28 -0
- package/build-module/selectors.mjs.map +2 -2
- package/build-module/sync.mjs +2 -0
- package/build-module/sync.mjs.map +2 -2
- package/build-module/types.mjs +9 -0
- package/build-module/types.mjs.map +4 -4
- package/build-module/utils/crdt-blocks.mjs +22 -26
- package/build-module/utils/crdt-blocks.mjs.map +2 -2
- package/build-module/utils/crdt-user-selections.mjs +8 -5
- package/build-module/utils/crdt-user-selections.mjs.map +2 -2
- package/build-module/utils/crdt.mjs +1 -3
- package/build-module/utils/crdt.mjs.map +2 -2
- package/build-module/utils/index.mjs +2 -0
- package/build-module/utils/index.mjs.map +2 -2
- package/build-module/utils/normalize-query-for-resolution.mjs +14 -0
- package/build-module/utils/normalize-query-for-resolution.mjs.map +7 -0
- package/build-module/utils/user-permissions.mjs +1 -4
- package/build-module/utils/user-permissions.mjs.map +2 -2
- package/build-types/actions.d.ts.map +1 -1
- package/build-types/awareness/post-editor-awareness.d.ts.map +1 -1
- package/build-types/awareness/types.d.ts +1 -1
- package/build-types/awareness/types.d.ts.map +1 -1
- package/build-types/entities.d.ts +1 -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 +34 -10
- package/build-types/hooks/use-post-editor-awareness-state.d.ts.map +1 -1
- package/build-types/index.d.ts +2 -0
- package/build-types/index.d.ts.map +1 -1
- package/build-types/private-apis.d.ts.map +1 -1
- package/build-types/queried-data/reducer.d.ts.map +1 -1
- package/build-types/queried-data/selectors.d.ts.map +1 -1
- package/build-types/reducer.d.ts.map +1 -1
- package/build-types/resolvers.d.ts +2 -1
- package/build-types/resolvers.d.ts.map +1 -1
- package/build-types/selectors.d.ts +17 -0
- 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 +15 -0
- package/build-types/types.d.ts.map +1 -1
- package/build-types/utils/crdt-blocks.d.ts.map +1 -1
- package/build-types/utils/crdt-user-selections.d.ts +10 -5
- package/build-types/utils/crdt-user-selections.d.ts.map +1 -1
- package/build-types/utils/crdt.d.ts.map +1 -1
- package/build-types/utils/index.d.ts +1 -0
- 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/user-permissions.d.ts.map +1 -1
- package/package.json +18 -18
- package/src/actions.js +49 -50
- package/src/awareness/post-editor-awareness.ts +93 -1
- package/src/awareness/test/post-editor-awareness.ts +35 -0
- package/src/awareness/types.ts +1 -1
- package/src/entities.js +2 -1
- package/src/entity-provider.js +24 -11
- package/src/hooks/test/use-post-editor-awareness-state.ts +443 -0
- package/src/hooks/use-entity-prop.js +43 -3
- package/src/hooks/use-post-editor-awareness-state.ts +159 -7
- package/src/index.js +1 -0
- package/src/private-actions.js +1 -1
- package/src/private-apis.js +6 -2
- package/src/queried-data/actions.js +1 -1
- package/src/queried-data/reducer.js +26 -14
- package/src/queried-data/selectors.js +12 -5
- package/src/queried-data/test/selectors.js +25 -0
- package/src/reducer.js +4 -1
- package/src/resolvers.js +141 -91
- package/src/selectors.ts +56 -0
- package/src/sync.ts +2 -0
- package/src/test/private-actions.js +1 -1
- package/src/test/resolvers.js +88 -14
- package/src/test/selectors.js +150 -0
- package/src/test/store.js +182 -0
- package/src/types.ts +19 -0
- package/src/utils/crdt-blocks.ts +47 -54
- package/src/utils/crdt-user-selections.ts +28 -16
- package/src/utils/crdt.ts +2 -7
- package/src/utils/index.js +1 -0
- package/src/utils/normalize-query-for-resolution.js +23 -0
- package/src/utils/test/crdt-blocks.ts +42 -24
- package/src/utils/user-permissions.js +4 -5
|
@@ -12,7 +12,8 @@ var SelectionType = /* @__PURE__ */ ((SelectionType2) => {
|
|
|
12
12
|
SelectionType2["WholeBlock"] = "whole-block";
|
|
13
13
|
return SelectionType2;
|
|
14
14
|
})(SelectionType || {});
|
|
15
|
-
function getSelectionState(selectionStart, selectionEnd, yDoc) {
|
|
15
|
+
function getSelectionState(selectionStart, selectionEnd, yDoc, options) {
|
|
16
|
+
const { selectionDirection } = options ?? {};
|
|
16
17
|
const ymap = getRootMap(yDoc, CRDT_RECORD_MAP_KEY);
|
|
17
18
|
const yBlocks = ymap.get("blocks");
|
|
18
19
|
const isSelectionEmpty = Object.keys(selectionStart).length === 0;
|
|
@@ -56,7 +57,8 @@ function getSelectionState(selectionStart, selectionEnd, yDoc) {
|
|
|
56
57
|
return {
|
|
57
58
|
type: "selection-in-one-block" /* SelectionInOneBlock */,
|
|
58
59
|
cursorStartPosition: cursorStartPosition2,
|
|
59
|
-
cursorEndPosition: cursorEndPosition2
|
|
60
|
+
cursorEndPosition: cursorEndPosition2,
|
|
61
|
+
selectionDirection
|
|
60
62
|
};
|
|
61
63
|
}
|
|
62
64
|
const cursorStartPosition = getCursorPosition(selectionStart, yBlocks);
|
|
@@ -67,7 +69,8 @@ function getSelectionState(selectionStart, selectionEnd, yDoc) {
|
|
|
67
69
|
return {
|
|
68
70
|
type: "selection-in-multiple-blocks" /* SelectionInMultipleBlocks */,
|
|
69
71
|
cursorStartPosition,
|
|
70
|
-
cursorEndPosition
|
|
72
|
+
cursorEndPosition,
|
|
73
|
+
selectionDirection
|
|
71
74
|
};
|
|
72
75
|
}
|
|
73
76
|
function getCursorPosition(selection, blocks) {
|
|
@@ -165,7 +168,7 @@ function areSelectionsStatesEqual(selection1, selection2) {
|
|
|
165
168
|
) && areCursorPositionsEqual(
|
|
166
169
|
selection1.cursorEndPosition,
|
|
167
170
|
selection2.cursorEndPosition
|
|
168
|
-
);
|
|
171
|
+
) && selection1.selectionDirection === selection2.selectionDirection;
|
|
169
172
|
case "selection-in-multiple-blocks" /* SelectionInMultipleBlocks */:
|
|
170
173
|
return areCursorPositionsEqual(
|
|
171
174
|
selection1.cursorStartPosition,
|
|
@@ -173,7 +176,7 @@ function areSelectionsStatesEqual(selection1, selection2) {
|
|
|
173
176
|
) && areCursorPositionsEqual(
|
|
174
177
|
selection1.cursorEndPosition,
|
|
175
178
|
selection2.cursorEndPosition
|
|
176
|
-
);
|
|
179
|
+
) && selection1.selectionDirection === selection2.selectionDirection;
|
|
177
180
|
case "whole-block" /* WholeBlock */:
|
|
178
181
|
return Y.compareRelativePositions(
|
|
179
182
|
selection1.blockPosition,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/crdt-user-selections.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { select } from '@wordpress/data';\nimport { Y } from '@wordpress/sync';\n// @ts-ignore No exported types for block editor store selectors.\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { CRDT_RECORD_MAP_KEY } from '../sync';\nimport type { YPostRecord } from './crdt';\nimport type { YBlock, YBlocks } from './crdt-blocks';\nimport { getRootMap } from './crdt-utils';\nimport type {\n\tAbsoluteBlockIndexPath,\n\tWPBlockSelection,\n\tSelectionState,\n\tSelectionNone,\n\tSelectionCursor,\n\tSelectionInOneBlock,\n\tSelectionInMultipleBlocks,\n\tSelectionWholeBlock,\n\tCursorPosition,\n} from '../types';\n\n/**\n * The type of selection.\n */\nexport enum SelectionType {\n\tNone = 'none',\n\tCursor = 'cursor',\n\tSelectionInOneBlock = 'selection-in-one-block',\n\tSelectionInMultipleBlocks = 'selection-in-multiple-blocks',\n\tWholeBlock = 'whole-block',\n}\n\n/**\n * Converts WordPress block editor selection to a SelectionState.\n *\n * Uses getBlockPathForLocalClientId to locate blocks in the Yjs document by\n * their tree position (index path) rather than clientId, since clientIds may\n * differ between the block-editor store and the Yjs document (e.g. in \"Show\n * Template\" mode).\n *\n * @param selectionStart - The start position of the selection\n * @param selectionEnd - The end position of the selection\n * @param yDoc - The Yjs document\n * @return The SelectionState\n */\nexport function getSelectionState(\n\tselectionStart: WPBlockSelection,\n\tselectionEnd: WPBlockSelection,\n\tyDoc: Y.Doc\n): SelectionState {\n\tconst ymap = getRootMap< YPostRecord >( yDoc, CRDT_RECORD_MAP_KEY );\n\tconst yBlocks = ymap.get( 'blocks' );\n\n\tconst isSelectionEmpty = Object.keys( selectionStart ).length === 0;\n\tconst noSelection: SelectionNone = {\n\t\ttype: SelectionType.None,\n\t};\n\n\tif ( isSelectionEmpty || ! yBlocks ) {\n\t\t// Case 1: No selection, or no blocks in the document.\n\t\treturn noSelection;\n\t}\n\n\t// When the page initially loads, selectionStart can contain an empty object `{}`.\n\tconst isSelectionInOneBlock =\n\t\tselectionStart.clientId === selectionEnd.clientId;\n\tconst isCursorOnly =\n\t\tisSelectionInOneBlock && selectionStart.offset === selectionEnd.offset;\n\tconst isSelectionAWholeBlock =\n\t\tisSelectionInOneBlock &&\n\t\tselectionStart.offset === undefined &&\n\t\tselectionEnd.offset === undefined;\n\n\tif ( isSelectionAWholeBlock ) {\n\t\t// Case 2: A whole block is selected.\n\t\tconst path = getBlockPathForLocalClientId( selectionStart.clientId );\n\t\tconst blockPosition = path\n\t\t\t? createRelativePositionForBlockPath( path, yBlocks )\n\t\t\t: null;\n\n\t\tif ( ! blockPosition ) {\n\t\t\treturn noSelection;\n\t\t}\n\n\t\treturn {\n\t\t\ttype: SelectionType.WholeBlock,\n\t\t\tblockPosition,\n\t\t};\n\t} else if ( isCursorOnly ) {\n\t\t// Case 3: Cursor only, no text selected\n\t\tconst cursorPosition = getCursorPosition( selectionStart, yBlocks );\n\n\t\tif ( ! cursorPosition ) {\n\t\t\t// If we can't find the cursor position in block text, treat it as a non-selection.\n\t\t\treturn noSelection;\n\t\t}\n\n\t\treturn {\n\t\t\ttype: SelectionType.Cursor,\n\t\t\tcursorPosition,\n\t\t};\n\t} else if ( isSelectionInOneBlock ) {\n\t\t// Case 4: Selection in a single block\n\t\tconst cursorStartPosition = getCursorPosition(\n\t\t\tselectionStart,\n\t\t\tyBlocks\n\t\t);\n\t\tconst cursorEndPosition = getCursorPosition( selectionEnd, yBlocks );\n\n\t\tif ( ! cursorStartPosition || ! cursorEndPosition ) {\n\t\t\t// If we can't find the cursor positions in block text, treat it as a non-selection.\n\t\t\treturn noSelection;\n\t\t}\n\n\t\treturn {\n\t\t\ttype: SelectionType.SelectionInOneBlock,\n\t\t\tcursorStartPosition,\n\t\t\tcursorEndPosition,\n\t\t};\n\t}\n\n\t// Case 5: Selection in multiple blocks\n\tconst cursorStartPosition = getCursorPosition( selectionStart, yBlocks );\n\tconst cursorEndPosition = getCursorPosition( selectionEnd, yBlocks );\n\tif ( ! cursorStartPosition || ! cursorEndPosition ) {\n\t\t// If we can't find the cursor positions in block text, treat it as a non-selection.\n\t\treturn noSelection;\n\t}\n\n\treturn {\n\t\ttype: SelectionType.SelectionInMultipleBlocks,\n\t\tcursorStartPosition,\n\t\tcursorEndPosition,\n\t};\n}\n\n/**\n * Get the cursor position from a selection.\n *\n * @param selection - The selection.\n * @param blocks - The blocks to search through.\n * @return The cursor position, or null if not found.\n */\nfunction getCursorPosition(\n\tselection: WPBlockSelection,\n\tblocks: YBlocks\n): CursorPosition | null {\n\tconst path = getBlockPathForLocalClientId( selection.clientId );\n\tconst block = path ? findBlockByPath( path, blocks ) : null;\n\tif (\n\t\t! block ||\n\t\t! selection.attributeKey ||\n\t\tundefined === selection.offset\n\t) {\n\t\treturn null;\n\t}\n\n\tconst attributes = block.get( 'attributes' );\n\tconst currentYText = attributes?.get( selection.attributeKey );\n\n\t// If the attribute is not a Y.Text, return null.\n\tif ( ! ( currentYText instanceof Y.Text ) ) {\n\t\treturn null;\n\t}\n\n\tconst relativePosition = Y.createRelativePositionFromTypeIndex(\n\t\tcurrentYText,\n\t\tselection.offset\n\t);\n\n\treturn {\n\t\trelativePosition,\n\t\tabsoluteOffset: selection.offset,\n\t};\n}\n\n/**\n * Resolves a local block-editor clientId to its index path relative to the\n * post content blocks. This allows finding the corresponding block in the Yjs\n * document even when clientIds differ (e.g. in \"Show Template\" mode where\n * blocks are cloned).\n *\n * In template mode, the block tree includes template parts and wrapper blocks\n * around a core/post-content block. The Yjs document only contains the post\n * content blocks, so we stop the upward walk when the parent is\n * core/post-content (its inner blocks correspond to the Yjs root blocks).\n *\n * @param clientId - The local block-editor clientId to resolve.\n * @return The index path from root, or null if not resolvable.\n */\nexport function getBlockPathForLocalClientId(\n\tclientId: string\n): AbsoluteBlockIndexPath | null {\n\tconst { getBlockIndex, getBlockRootClientId, getBlockName } =\n\t\tselect( blockEditorStore );\n\n\tconst path: AbsoluteBlockIndexPath = [];\n\tlet current: string | null = clientId;\n\twhile ( current ) {\n\t\tconst index = getBlockIndex( current );\n\t\tif ( index === -1 ) {\n\t\t\treturn null;\n\t\t}\n\t\tpath.unshift( index );\n\t\tconst parent = getBlockRootClientId( current );\n\t\tif ( ! parent ) {\n\t\t\tbreak;\n\t\t}\n\t\t// If the parent is core/post-content, stop here \u2014 the Yjs doc\n\t\t// root blocks correspond to post-content's inner blocks.\n\t\tconst parentName = getBlockName( parent );\n\t\tif ( parentName === 'core/post-content' ) {\n\t\t\tbreak;\n\t\t}\n\t\tcurrent = parent;\n\t}\n\treturn path.length > 0 ? path : null;\n}\n\n/**\n * Find a block by navigating a tree index path in the Yjs block hierarchy.\n *\n * @param path - The index path, e.g. [0, 1] for blocks[0].innerBlocks[1].\n * @param blocks - The root-level Yjs blocks array.\n * @return The block Y.Map if found, null otherwise.\n */\nfunction findBlockByPath(\n\tpath: AbsoluteBlockIndexPath,\n\tblocks: YBlocks\n): YBlock | null {\n\tlet currentBlocks = blocks;\n\tfor ( let i = 0; i < path.length; i++ ) {\n\t\tif ( path[ i ] >= currentBlocks.length ) {\n\t\t\treturn null;\n\t\t}\n\t\tconst block = currentBlocks.get( path[ i ] );\n\t\tif ( ! block ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( i === path.length - 1 ) {\n\t\t\treturn block;\n\t\t}\n\t\tcurrentBlocks =\n\t\t\tblock.get( 'innerBlocks' ) ?? ( new Y.Array() as YBlocks );\n\t}\n\treturn null;\n}\n\n/**\n * Create a Y.RelativePosition for a block by navigating a tree index path.\n *\n * @param path - The index path, e.g. [0, 1] for blocks[0].innerBlocks[1].\n * @param blocks - The root-level Yjs blocks array.\n * @return A Y.RelativePosition for the block, or null if the path is invalid.\n */\nfunction createRelativePositionForBlockPath(\n\tpath: AbsoluteBlockIndexPath,\n\tblocks: YBlocks\n): Y.RelativePosition | null {\n\tlet currentBlocks = blocks;\n\tfor ( let i = 0; i < path.length; i++ ) {\n\t\tif ( path[ i ] >= currentBlocks.length ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( i === path.length - 1 ) {\n\t\t\treturn Y.createRelativePositionFromTypeIndex(\n\t\t\t\tcurrentBlocks,\n\t\t\t\tpath[ i ]\n\t\t\t);\n\t\t}\n\t\tconst block = currentBlocks.get( path[ i ] );\n\t\tcurrentBlocks =\n\t\t\tblock?.get( 'innerBlocks' ) ?? ( new Y.Array() as YBlocks );\n\t}\n\treturn null;\n}\n\n/**\n * Check if two selection states are equal.\n *\n * @param selection1 - The first selection state.\n * @param selection2 - The second selection state.\n * @return True if the selection states are equal, false otherwise.\n */\nexport function areSelectionsStatesEqual(\n\tselection1: SelectionState,\n\tselection2: SelectionState\n): boolean {\n\tif ( selection1.type !== selection2.type ) {\n\t\treturn false;\n\t}\n\n\tswitch ( selection1.type ) {\n\t\tcase SelectionType.None:\n\t\t\treturn true;\n\n\t\tcase SelectionType.Cursor:\n\t\t\treturn areCursorPositionsEqual(\n\t\t\t\tselection1.cursorPosition,\n\t\t\t\t( selection2 as SelectionCursor ).cursorPosition\n\t\t\t);\n\n\t\tcase SelectionType.SelectionInOneBlock:\n\t\t\treturn (\n\t\t\t\tareCursorPositionsEqual(\n\t\t\t\t\tselection1.cursorStartPosition,\n\t\t\t\t\t( selection2 as SelectionInOneBlock ).cursorStartPosition\n\t\t\t\t) &&\n\t\t\t\tareCursorPositionsEqual(\n\t\t\t\t\tselection1.cursorEndPosition,\n\t\t\t\t\t( selection2 as SelectionInOneBlock ).cursorEndPosition\n\t\t\t\t)\n\t\t\t);\n\n\t\tcase SelectionType.SelectionInMultipleBlocks:\n\t\t\treturn (\n\t\t\t\tareCursorPositionsEqual(\n\t\t\t\t\tselection1.cursorStartPosition,\n\t\t\t\t\t( selection2 as SelectionInMultipleBlocks )\n\t\t\t\t\t\t.cursorStartPosition\n\t\t\t\t) &&\n\t\t\t\tareCursorPositionsEqual(\n\t\t\t\t\tselection1.cursorEndPosition,\n\t\t\t\t\t( selection2 as SelectionInMultipleBlocks )\n\t\t\t\t\t\t.cursorEndPosition\n\t\t\t\t)\n\t\t\t);\n\t\tcase SelectionType.WholeBlock:\n\t\t\treturn Y.compareRelativePositions(\n\t\t\t\tselection1.blockPosition,\n\t\t\t\t( selection2 as SelectionWholeBlock ).blockPosition\n\t\t\t);\n\n\t\tdefault:\n\t\t\treturn false;\n\t}\n}\n\n/**\n * Check if two cursor positions are equal.\n *\n * @param cursorPosition1 - The first cursor position.\n * @param cursorPosition2 - The second cursor position.\n * @return True if the cursor positions are equal, false otherwise.\n */\nfunction areCursorPositionsEqual(\n\tcursorPosition1: CursorPosition,\n\tcursorPosition2: CursorPosition\n): boolean {\n\tconst isRelativePositionEqual = Y.compareRelativePositions(\n\t\tcursorPosition1.relativePosition,\n\t\tcursorPosition2.relativePosition\n\t);\n\n\t// Ensure a change in calculated absolute offset results in a treating the cursor as modified.\n\t// This is necessary because Y.Text relative positions can remain the same after text changes.\n\tconst isAbsoluteOffsetEqual =\n\t\tcursorPosition1.absoluteOffset === cursorPosition2.absoluteOffset;\n\n\treturn isRelativePositionEqual && isAbsoluteOffsetEqual;\n}\n"],
|
|
5
|
-
"mappings": ";AAGA,SAAS,cAAc;AACvB,SAAS,SAAS;AAElB,SAAS,SAAS,wBAAwB;AAK1C,SAAS,2BAA2B;AAGpC,SAAS,kBAAkB;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { select } from '@wordpress/data';\nimport { Y } from '@wordpress/sync';\n// @ts-ignore No exported types for block editor store selectors.\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { CRDT_RECORD_MAP_KEY } from '../sync';\nimport type { YPostRecord } from './crdt';\nimport type { YBlock, YBlocks } from './crdt-blocks';\nimport { getRootMap } from './crdt-utils';\nimport type { SelectionDirection } from '../types';\nimport {\n\ttype AbsoluteBlockIndexPath,\n\ttype WPBlockSelection,\n\ttype SelectionState,\n\ttype SelectionNone,\n\ttype SelectionCursor,\n\ttype SelectionInOneBlock,\n\ttype SelectionInMultipleBlocks,\n\ttype SelectionWholeBlock,\n\ttype CursorPosition,\n} from '../types';\n\n/**\n * The type of selection.\n */\nexport enum SelectionType {\n\tNone = 'none',\n\tCursor = 'cursor',\n\tSelectionInOneBlock = 'selection-in-one-block',\n\tSelectionInMultipleBlocks = 'selection-in-multiple-blocks',\n\tWholeBlock = 'whole-block',\n}\n\n/**\n * Converts WordPress block editor selection to a SelectionState.\n *\n * Uses getBlockPathForLocalClientId to locate blocks in the Yjs document by\n * their tree position (index path) rather than clientId, since clientIds may\n * differ between the block-editor store and the Yjs document (e.g. in \"Show\n * Template\" mode).\n *\n * @param selectionStart - The start position of the selection\n * @param selectionEnd - The end position of the selection\n * @param yDoc - The Yjs document\n * @param options - Optional parameters\n * @param options.selectionDirection - The direction of the selection (forward or backward)\n * @return The SelectionState\n */\nexport function getSelectionState(\n\tselectionStart: WPBlockSelection,\n\tselectionEnd: WPBlockSelection,\n\tyDoc: Y.Doc,\n\toptions?: { selectionDirection?: SelectionDirection }\n): SelectionState {\n\tconst { selectionDirection } = options ?? {};\n\tconst ymap = getRootMap< YPostRecord >( yDoc, CRDT_RECORD_MAP_KEY );\n\tconst yBlocks = ymap.get( 'blocks' );\n\n\tconst isSelectionEmpty = Object.keys( selectionStart ).length === 0;\n\tconst noSelection: SelectionNone = {\n\t\ttype: SelectionType.None,\n\t};\n\n\tif ( isSelectionEmpty || ! yBlocks ) {\n\t\t// Case 1: No selection, or no blocks in the document.\n\t\treturn noSelection;\n\t}\n\n\t// When the page initially loads, selectionStart can contain an empty object `{}`.\n\tconst isSelectionInOneBlock =\n\t\tselectionStart.clientId === selectionEnd.clientId;\n\tconst isCursorOnly =\n\t\tisSelectionInOneBlock && selectionStart.offset === selectionEnd.offset;\n\tconst isSelectionAWholeBlock =\n\t\tisSelectionInOneBlock &&\n\t\tselectionStart.offset === undefined &&\n\t\tselectionEnd.offset === undefined;\n\n\tif ( isSelectionAWholeBlock ) {\n\t\t// Case 2: A whole block is selected.\n\t\tconst path = getBlockPathForLocalClientId( selectionStart.clientId );\n\t\tconst blockPosition = path\n\t\t\t? createRelativePositionForBlockPath( path, yBlocks )\n\t\t\t: null;\n\n\t\tif ( ! blockPosition ) {\n\t\t\treturn noSelection;\n\t\t}\n\n\t\treturn {\n\t\t\ttype: SelectionType.WholeBlock,\n\t\t\tblockPosition,\n\t\t};\n\t} else if ( isCursorOnly ) {\n\t\t// Case 3: Cursor only, no text selected\n\t\tconst cursorPosition = getCursorPosition( selectionStart, yBlocks );\n\n\t\tif ( ! cursorPosition ) {\n\t\t\t// If we can't find the cursor position in block text, treat it as a non-selection.\n\t\t\treturn noSelection;\n\t\t}\n\n\t\treturn {\n\t\t\ttype: SelectionType.Cursor,\n\t\t\tcursorPosition,\n\t\t};\n\t} else if ( isSelectionInOneBlock ) {\n\t\t// Case 4: Selection in a single block\n\t\tconst cursorStartPosition = getCursorPosition(\n\t\t\tselectionStart,\n\t\t\tyBlocks\n\t\t);\n\t\tconst cursorEndPosition = getCursorPosition( selectionEnd, yBlocks );\n\n\t\tif ( ! cursorStartPosition || ! cursorEndPosition ) {\n\t\t\t// If we can't find the cursor positions in block text, treat it as a non-selection.\n\t\t\treturn noSelection;\n\t\t}\n\n\t\treturn {\n\t\t\ttype: SelectionType.SelectionInOneBlock,\n\t\t\tcursorStartPosition,\n\t\t\tcursorEndPosition,\n\t\t\tselectionDirection,\n\t\t};\n\t}\n\n\t// Case 5: Selection in multiple blocks\n\tconst cursorStartPosition = getCursorPosition( selectionStart, yBlocks );\n\tconst cursorEndPosition = getCursorPosition( selectionEnd, yBlocks );\n\tif ( ! cursorStartPosition || ! cursorEndPosition ) {\n\t\t// If we can't find the cursor positions in block text, treat it as a non-selection.\n\t\treturn noSelection;\n\t}\n\n\treturn {\n\t\ttype: SelectionType.SelectionInMultipleBlocks,\n\t\tcursorStartPosition,\n\t\tcursorEndPosition,\n\t\tselectionDirection,\n\t};\n}\n\n/**\n * Get the cursor position from a selection.\n *\n * @param selection - The selection.\n * @param blocks - The blocks to search through.\n * @return The cursor position, or null if not found.\n */\nfunction getCursorPosition(\n\tselection: WPBlockSelection,\n\tblocks: YBlocks\n): CursorPosition | null {\n\tconst path = getBlockPathForLocalClientId( selection.clientId );\n\tconst block = path ? findBlockByPath( path, blocks ) : null;\n\tif (\n\t\t! block ||\n\t\t! selection.attributeKey ||\n\t\tundefined === selection.offset\n\t) {\n\t\treturn null;\n\t}\n\n\tconst attributes = block.get( 'attributes' );\n\tconst currentYText = attributes?.get( selection.attributeKey );\n\n\t// If the attribute is not a Y.Text, return null.\n\tif ( ! ( currentYText instanceof Y.Text ) ) {\n\t\treturn null;\n\t}\n\n\tconst relativePosition = Y.createRelativePositionFromTypeIndex(\n\t\tcurrentYText,\n\t\tselection.offset\n\t);\n\n\treturn {\n\t\trelativePosition,\n\t\tabsoluteOffset: selection.offset,\n\t};\n}\n\n/**\n * Resolves a local block-editor clientId to its index path relative to the\n * post content blocks. This allows finding the corresponding block in the Yjs\n * document even when clientIds differ (e.g. in \"Show Template\" mode where\n * blocks are cloned).\n *\n * In template mode, the block tree includes template parts and wrapper blocks\n * around a core/post-content block. The Yjs document only contains the post\n * content blocks, so we stop the upward walk when the parent is\n * core/post-content (its inner blocks correspond to the Yjs root blocks).\n *\n * @param clientId - The local block-editor clientId to resolve.\n * @return The index path from root, or null if not resolvable.\n */\nexport function getBlockPathForLocalClientId(\n\tclientId: string\n): AbsoluteBlockIndexPath | null {\n\tconst { getBlockIndex, getBlockRootClientId, getBlockName } =\n\t\tselect( blockEditorStore );\n\n\tconst path: AbsoluteBlockIndexPath = [];\n\tlet current: string | null = clientId;\n\twhile ( current ) {\n\t\tconst index = getBlockIndex( current );\n\t\tif ( index === -1 ) {\n\t\t\treturn null;\n\t\t}\n\t\tpath.unshift( index );\n\t\tconst parent = getBlockRootClientId( current );\n\t\tif ( ! parent ) {\n\t\t\tbreak;\n\t\t}\n\t\t// If the parent is core/post-content, stop here \u2014 the Yjs doc\n\t\t// root blocks correspond to post-content's inner blocks.\n\t\tconst parentName = getBlockName( parent );\n\t\tif ( parentName === 'core/post-content' ) {\n\t\t\tbreak;\n\t\t}\n\t\tcurrent = parent;\n\t}\n\treturn path.length > 0 ? path : null;\n}\n\n/**\n * Find a block by navigating a tree index path in the Yjs block hierarchy.\n *\n * @param path - The index path, e.g. [0, 1] for blocks[0].innerBlocks[1].\n * @param blocks - The root-level Yjs blocks array.\n * @return The block Y.Map if found, null otherwise.\n */\nfunction findBlockByPath(\n\tpath: AbsoluteBlockIndexPath,\n\tblocks: YBlocks\n): YBlock | null {\n\tlet currentBlocks = blocks;\n\tfor ( let i = 0; i < path.length; i++ ) {\n\t\tif ( path[ i ] >= currentBlocks.length ) {\n\t\t\treturn null;\n\t\t}\n\t\tconst block = currentBlocks.get( path[ i ] );\n\t\tif ( ! block ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( i === path.length - 1 ) {\n\t\t\treturn block;\n\t\t}\n\t\tcurrentBlocks =\n\t\t\tblock.get( 'innerBlocks' ) ?? ( new Y.Array() as YBlocks );\n\t}\n\treturn null;\n}\n\n/**\n * Create a Y.RelativePosition for a block by navigating a tree index path.\n *\n * @param path - The index path, e.g. [0, 1] for blocks[0].innerBlocks[1].\n * @param blocks - The root-level Yjs blocks array.\n * @return A Y.RelativePosition for the block, or null if the path is invalid.\n */\nfunction createRelativePositionForBlockPath(\n\tpath: AbsoluteBlockIndexPath,\n\tblocks: YBlocks\n): Y.RelativePosition | null {\n\tlet currentBlocks = blocks;\n\tfor ( let i = 0; i < path.length; i++ ) {\n\t\tif ( path[ i ] >= currentBlocks.length ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( i === path.length - 1 ) {\n\t\t\treturn Y.createRelativePositionFromTypeIndex(\n\t\t\t\tcurrentBlocks,\n\t\t\t\tpath[ i ]\n\t\t\t);\n\t\t}\n\t\tconst block = currentBlocks.get( path[ i ] );\n\t\tcurrentBlocks =\n\t\t\tblock?.get( 'innerBlocks' ) ?? ( new Y.Array() as YBlocks );\n\t}\n\treturn null;\n}\n\n/**\n * Check if two selection states are equal.\n *\n * @param selection1 - The first selection state.\n * @param selection2 - The second selection state.\n * @return True if the selection states are equal, false otherwise.\n */\nexport function areSelectionsStatesEqual(\n\tselection1: SelectionState,\n\tselection2: SelectionState\n): boolean {\n\tif ( selection1.type !== selection2.type ) {\n\t\treturn false;\n\t}\n\n\tswitch ( selection1.type ) {\n\t\tcase SelectionType.None:\n\t\t\treturn true;\n\n\t\tcase SelectionType.Cursor:\n\t\t\treturn areCursorPositionsEqual(\n\t\t\t\tselection1.cursorPosition,\n\t\t\t\t( selection2 as SelectionCursor ).cursorPosition\n\t\t\t);\n\n\t\tcase SelectionType.SelectionInOneBlock:\n\t\t\treturn (\n\t\t\t\tareCursorPositionsEqual(\n\t\t\t\t\tselection1.cursorStartPosition,\n\t\t\t\t\t( selection2 as SelectionInOneBlock ).cursorStartPosition\n\t\t\t\t) &&\n\t\t\t\tareCursorPositionsEqual(\n\t\t\t\t\tselection1.cursorEndPosition,\n\t\t\t\t\t( selection2 as SelectionInOneBlock ).cursorEndPosition\n\t\t\t\t) &&\n\t\t\t\tselection1.selectionDirection ===\n\t\t\t\t\t( selection2 as SelectionInOneBlock ).selectionDirection\n\t\t\t);\n\n\t\tcase SelectionType.SelectionInMultipleBlocks:\n\t\t\treturn (\n\t\t\t\tareCursorPositionsEqual(\n\t\t\t\t\tselection1.cursorStartPosition,\n\t\t\t\t\t( selection2 as SelectionInMultipleBlocks )\n\t\t\t\t\t\t.cursorStartPosition\n\t\t\t\t) &&\n\t\t\t\tareCursorPositionsEqual(\n\t\t\t\t\tselection1.cursorEndPosition,\n\t\t\t\t\t( selection2 as SelectionInMultipleBlocks )\n\t\t\t\t\t\t.cursorEndPosition\n\t\t\t\t) &&\n\t\t\t\tselection1.selectionDirection ===\n\t\t\t\t\t( selection2 as SelectionInMultipleBlocks )\n\t\t\t\t\t\t.selectionDirection\n\t\t\t);\n\t\tcase SelectionType.WholeBlock:\n\t\t\treturn Y.compareRelativePositions(\n\t\t\t\tselection1.blockPosition,\n\t\t\t\t( selection2 as SelectionWholeBlock ).blockPosition\n\t\t\t);\n\n\t\tdefault:\n\t\t\treturn false;\n\t}\n}\n\n/**\n * Check if two cursor positions are equal.\n *\n * @param cursorPosition1 - The first cursor position.\n * @param cursorPosition2 - The second cursor position.\n * @return True if the cursor positions are equal, false otherwise.\n */\nfunction areCursorPositionsEqual(\n\tcursorPosition1: CursorPosition,\n\tcursorPosition2: CursorPosition\n): boolean {\n\tconst isRelativePositionEqual = Y.compareRelativePositions(\n\t\tcursorPosition1.relativePosition,\n\t\tcursorPosition2.relativePosition\n\t);\n\n\t// Ensure a change in calculated absolute offset results in a treating the cursor as modified.\n\t// This is necessary because Y.Text relative positions can remain the same after text changes.\n\tconst isAbsoluteOffsetEqual =\n\t\tcursorPosition1.absoluteOffset === cursorPosition2.absoluteOffset;\n\n\treturn isRelativePositionEqual && isAbsoluteOffsetEqual;\n}\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,cAAc;AACvB,SAAS,SAAS;AAElB,SAAS,SAAS,wBAAwB;AAK1C,SAAS,2BAA2B;AAGpC,SAAS,kBAAkB;AAiBpB,IAAK,gBAAL,kBAAKA,mBAAL;AACN,EAAAA,eAAA,UAAO;AACP,EAAAA,eAAA,YAAS;AACT,EAAAA,eAAA,yBAAsB;AACtB,EAAAA,eAAA,+BAA4B;AAC5B,EAAAA,eAAA,gBAAa;AALF,SAAAA;AAAA,GAAA;AAuBL,SAAS,kBACf,gBACA,cACA,MACA,SACiB;AACjB,QAAM,EAAE,mBAAmB,IAAI,WAAW,CAAC;AAC3C,QAAM,OAAO,WAA2B,MAAM,mBAAoB;AAClE,QAAM,UAAU,KAAK,I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A,QAAM,wBACL,gBAAgB,mBAAmB,gBAAgB;AAEpD,SAAO,2BAA2B;AACnC;",
|
|
6
6
|
"names": ["SelectionType", "cursorStartPosition", "cursorEndPosition"]
|
|
7
7
|
}
|
|
@@ -166,9 +166,7 @@ function getPostChangesFromCRDTDoc(ydoc, editedRecord, _postType) {
|
|
|
166
166
|
return true;
|
|
167
167
|
}
|
|
168
168
|
case "date": {
|
|
169
|
-
const currentDateIsFloating =
|
|
170
|
-
ymap.get("status")
|
|
171
|
-
) && (null === currentValue || editedRecord.modified === currentValue);
|
|
169
|
+
const currentDateIsFloating = null === currentValue || editedRecord.modified === currentValue;
|
|
172
170
|
if (currentDateIsFloating) {
|
|
173
171
|
return false;
|
|
174
172
|
}
|
|
@@ -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,EAIC;AAAA,OACM;AAKP,SAAS,qBAAqB;AAC9B;AAAA,EACC;AAAA,EACA;AAAA,OAIM;AAGP,SAAS,+BAA+B,2BAA2B;AAEnE;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OAGM;AAiCA,IAAM,yCAAyC;AAGtD,IAAM,wBAAwB,oBAAI,IAAe;AAAA,EAChD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,CAAE;AAGF,IAAM,yBAAyB,oBAAI,IAAe;AAAA,EACjD;AACD,CAAE;AAUF,SAAS,6BACR,MACA,SACO;AACP,QAAM,OAAO,WAAY,MAAM,mBAAoB;AAEnD,SAAO,QAAS,OAAQ,EAAE,QAAS,CAAE,CAAE,KAAK,QAAS,MAAO;AAE3D,QAAK,eAAe,OAAO,UAAW;AACrC;AAAA,IACD;AAEA,YAAS,KAAM;AAAA;AAAA,MAGd,SAAS;AACR,cAAM,e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M,IAAK,6BAA8B,KAC9C,aAAa,SACZ;AACD,kBAAM,aAAa,KAAK,IAAK,QAAS,GAAG,OAAO,KAAK,CAAC;AAEtD,mBACC,4BAA6B,UAAW,EAAE,KAAK,MAC/C,YAAa,aAAa,OAAQ;AAAA,UAEpC;
|
|
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\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\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,EAIC;AAAA,OACM;AAKP,SAAS,qBAAqB;AAC9B;AAAA,EACC;AAAA,EACA;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I,OAAQ,GAAI;AAChB;AAAA,EACD;AAEA,MAAK,kBAA6B,cAAc,QAAS,GAAI;AAC5D,QAAI,IAAK,KAAK,QAAS;AAAA,EACxB;AACD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
ALLOWED_RESOURCE_ACTIONS
|
|
17
17
|
} from "./user-permissions.mjs";
|
|
18
18
|
import { RECEIVE_INTERMEDIATE_RESULTS } from "./receive-intermediate-results.mjs";
|
|
19
|
+
import { default as default13 } from "./normalize-query-for-resolution.mjs";
|
|
19
20
|
export {
|
|
20
21
|
ALLOWED_RESOURCE_ACTIONS,
|
|
21
22
|
RECEIVE_INTERMEDIATE_RESULTS,
|
|
@@ -28,6 +29,7 @@ export {
|
|
|
28
29
|
default4 as ifMatchingAction,
|
|
29
30
|
default12 as isNumericID,
|
|
30
31
|
default9 as isRawAttribute,
|
|
32
|
+
default13 as normalizeQueryForResolution,
|
|
31
33
|
default6 as onSubKey,
|
|
32
34
|
default7 as replaceAction,
|
|
33
35
|
default10 as setNestedValue,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/index.js"],
|
|
4
|
-
"sourcesContent": ["export { default as conservativeMapItem } from './conservative-map-item';\nexport { default as getNormalizedCommaSeparable } from './get-normalized-comma-separable';\nexport { default as ifMatchingAction } from './if-matching-action';\nexport { default as forwardResolver } from './forward-resolver';\nexport { default as onSubKey } from './on-sub-key';\nexport { default as replaceAction } from './replace-action';\nexport { default as withWeakMapCache } from './with-weak-map-cache';\nexport { default as isRawAttribute } from './is-raw-attribute';\nexport { default as setNestedValue } from './set-nested-value';\nexport { default as getNestedValue } from './get-nested-value';\nexport { default as isNumericID } from './is-numeric-id';\nexport {\n\tgetUserPermissionCacheKey,\n\tgetUserPermissionsFromAllowHeader,\n\tALLOWED_RESOURCE_ACTIONS,\n} from './user-permissions';\nexport { RECEIVE_INTERMEDIATE_RESULTS } from './receive-intermediate-results';\n"],
|
|
5
|
-
"mappings": ";AAAA,SAAoB,WAAXA,gBAAsC;AAC/C,SAAoB,WAAXA,gBAA8C;AACvD,SAAoB,WAAXA,gBAAmC;AAC5C,SAAoB,WAAXA,gBAAkC;AAC3C,SAAoB,WAAXA,gBAA2B;AACpC,SAAoB,WAAXA,gBAAgC;AACzC,SAAoB,WAAXA,gBAAmC;AAC5C,SAAoB,WAAXA,gBAAiC;AAC1C,SAAoB,WAAXA,iBAAiC;AAC1C,SAAoB,WAAXA,iBAAiC;AAC1C,SAAoB,WAAXA,iBAA8B;AACvC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,oCAAoC;",
|
|
4
|
+
"sourcesContent": ["export { default as conservativeMapItem } from './conservative-map-item';\nexport { default as getNormalizedCommaSeparable } from './get-normalized-comma-separable';\nexport { default as ifMatchingAction } from './if-matching-action';\nexport { default as forwardResolver } from './forward-resolver';\nexport { default as onSubKey } from './on-sub-key';\nexport { default as replaceAction } from './replace-action';\nexport { default as withWeakMapCache } from './with-weak-map-cache';\nexport { default as isRawAttribute } from './is-raw-attribute';\nexport { default as setNestedValue } from './set-nested-value';\nexport { default as getNestedValue } from './get-nested-value';\nexport { default as isNumericID } from './is-numeric-id';\nexport {\n\tgetUserPermissionCacheKey,\n\tgetUserPermissionsFromAllowHeader,\n\tALLOWED_RESOURCE_ACTIONS,\n} from './user-permissions';\nexport { RECEIVE_INTERMEDIATE_RESULTS } from './receive-intermediate-results';\nexport { default as normalizeQueryForResolution } from './normalize-query-for-resolution';\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAoB,WAAXA,gBAAsC;AAC/C,SAAoB,WAAXA,gBAA8C;AACvD,SAAoB,WAAXA,gBAAmC;AAC5C,SAAoB,WAAXA,gBAAkC;AAC3C,SAAoB,WAAXA,gBAA2B;AACpC,SAAoB,WAAXA,gBAAgC;AACzC,SAAoB,WAAXA,gBAAmC;AAC5C,SAAoB,WAAXA,gBAAiC;AAC1C,SAAoB,WAAXA,iBAAiC;AAC1C,SAAoB,WAAXA,iBAAiC;AAC1C,SAAoB,WAAXA,iBAA8B;AACvC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,oCAAoC;AAC7C,SAAoB,WAAXA,iBAA8C;",
|
|
6
6
|
"names": ["default"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// packages/core-data/src/utils/normalize-query-for-resolution.js
|
|
2
|
+
function normalizeQueryForResolution(query) {
|
|
3
|
+
if (!query) {
|
|
4
|
+
return void 0;
|
|
5
|
+
}
|
|
6
|
+
const entries = Object.entries(query).filter(
|
|
7
|
+
([k, v]) => (k === "context" || k === "_fields") && v !== void 0 && v !== null
|
|
8
|
+
);
|
|
9
|
+
return entries.length > 0 ? Object.fromEntries(entries) : void 0;
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
normalizeQueryForResolution as default
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=normalize-query-for-resolution.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/utils/normalize-query-for-resolution.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * Returns a copy of `query` filtered to only the keys that affect resolution\n * identity (`context` and `_fields`), or `undefined` when none are present.\n * This mirrors the normalisation that the data store applies when keying\n * resolved records, so that `finishResolutions` receives args that match the\n * keys used by callers who omit pagination params.\n *\n * @param {Object} query The raw query object.\n * @return {Object|undefined} Normalised query or undefined.\n */\nexport default function normalizeQueryForResolution( query ) {\n\tif ( ! query ) {\n\t\treturn undefined;\n\t}\n\n\tconst entries = Object.entries( query ).filter(\n\t\t( [ k, v ] ) =>\n\t\t\t( k === 'context' || k === '_fields' ) &&\n\t\t\tv !== undefined &&\n\t\t\tv !== null\n\t);\n\treturn entries.length > 0 ? Object.fromEntries( entries ) : undefined;\n}\n"],
|
|
5
|
+
"mappings": ";AAUe,SAAR,4BAA8C,OAAQ;AAC5D,MAAK,CAAE,OAAQ;AACd,WAAO;AAAA,EACR;AAEA,QAAM,UAAU,OAAO,QAAS,KAAM,EAAE;AAAA,IACvC,CAAE,CAAE,GAAG,CAAE,OACN,MAAM,aAAa,MAAM,cAC3B,MAAM,UACN,MAAM;AAAA,EACR;AACA,SAAO,QAAQ,SAAS,IAAI,OAAO,YAAa,OAAQ,IAAI;AAC7D;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -7,9 +7,6 @@ var ALLOWED_RESOURCE_ACTIONS = [
|
|
|
7
7
|
];
|
|
8
8
|
function getUserPermissionsFromAllowHeader(allowedMethods) {
|
|
9
9
|
const permissions = {};
|
|
10
|
-
if (!allowedMethods) {
|
|
11
|
-
return permissions;
|
|
12
|
-
}
|
|
13
10
|
const methods = {
|
|
14
11
|
create: "POST",
|
|
15
12
|
read: "GET",
|
|
@@ -17,7 +14,7 @@ function getUserPermissionsFromAllowHeader(allowedMethods) {
|
|
|
17
14
|
delete: "DELETE"
|
|
18
15
|
};
|
|
19
16
|
for (const [actionName, methodName] of Object.entries(methods)) {
|
|
20
|
-
permissions[actionName] = allowedMethods.includes(methodName);
|
|
17
|
+
permissions[actionName] = allowedMethods ? allowedMethods.includes(methodName) : false;
|
|
21
18
|
}
|
|
22
19
|
return permissions;
|
|
23
20
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/user-permissions.js"],
|
|
4
|
-
"sourcesContent": ["export const ALLOWED_RESOURCE_ACTIONS = [\n\t'create',\n\t'read',\n\t'update',\n\t'delete',\n];\n\nexport function getUserPermissionsFromAllowHeader( allowedMethods ) {\n\tconst permissions = {};\n\
|
|
5
|
-
"mappings": ";AAAO,IAAM,2BAA2B;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;AAEO,SAAS,kCAAmC,gBAAiB;AACnE,QAAM,cAAc,CAAC;AACrB,
|
|
4
|
+
"sourcesContent": ["export const ALLOWED_RESOURCE_ACTIONS = [\n\t'create',\n\t'read',\n\t'update',\n\t'delete',\n];\n\nexport function getUserPermissionsFromAllowHeader( allowedMethods ) {\n\tconst permissions = {};\n\tconst methods = {\n\t\tcreate: 'POST',\n\t\tread: 'GET',\n\t\tupdate: 'PUT',\n\t\tdelete: 'DELETE',\n\t};\n\n\tfor ( const [ actionName, methodName ] of Object.entries( methods ) ) {\n\t\tpermissions[ actionName ] = allowedMethods\n\t\t\t? allowedMethods.includes( methodName )\n\t\t\t: false;\n\t}\n\n\treturn permissions;\n}\n\nexport function getUserPermissionCacheKey( action, resource, id ) {\n\tconst key = (\n\t\ttypeof resource === 'object'\n\t\t\t? [ action, resource.kind, resource.name, resource.id ]\n\t\t\t: [ action, resource, id ]\n\t)\n\t\t.filter( Boolean )\n\t\t.join( '/' );\n\n\treturn key;\n}\n"],
|
|
5
|
+
"mappings": ";AAAO,IAAM,2BAA2B;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;AAEO,SAAS,kCAAmC,gBAAiB;AACnE,QAAM,cAAc,CAAC;AACrB,QAAM,UAAU;AAAA,IACf,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,QAAQ;AAAA,EACT;AAEA,aAAY,CAAE,YAAY,UAAW,KAAK,OAAO,QAAS,OAAQ,GAAI;AACrE,gBAAa,UAAW,IAAI,iBACzB,eAAe,SAAU,UAAW,IACpC;AAAA,EACJ;AAEA,SAAO;AACR;AAEO,SAAS,0BAA2B,QAAQ,UAAU,IAAK;AACjE,QAAM,OACL,OAAO,aAAa,WACjB,CAAE,QAAQ,SAAS,MAAM,SAAS,MAAM,SAAS,EAAG,IACpD,CAAE,QAAQ,UAAU,EAAG,GAEzB,OAAQ,OAAQ,EAChB,KAAM,GAAI;AAEZ,SAAO;AACR;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -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;AAmsBD;;;;;;;;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;AAoCD;;;;;;;;;GASG;AACH,8CAPW,MAAM,QACN,MAAM,OACN,MAAM,GAAC,MAAM,GAAC,IAAI,UAClB,MAAO,IAAI,OAqBrB;AA71BM,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,kBA0N1C;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,mBAmBlC"}
|
|
@@ -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;AAc/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,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;QACzB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;KAC7B;IAoDD;;;;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
|
|
@@ -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,EA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@ -283,8 +283,8 @@ export const rootEntitiesConfig: ({
|
|
|
283
283
|
};
|
|
284
284
|
plural: string;
|
|
285
285
|
key: string;
|
|
286
|
+
supportsPagination: boolean;
|
|
286
287
|
rawAttributes?: undefined;
|
|
287
|
-
supportsPagination?: undefined;
|
|
288
288
|
transientEdits?: undefined;
|
|
289
289
|
getTitle?: undefined;
|
|
290
290
|
getRevisionsUrl?: undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entities.d.ts","sourceRoot":"","sources":["../src/entities.js"],"names":[],"mappings":"AAwBA,iCAAkC,IAAI,CAAC;AAYvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"entities.d.ts","sourceRoot":"","sources":["../src/entities.js"],"names":[],"mappings":"AAwBA,iCAAkC,IAAI,CAAC;AAYvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAkNI;;;;;;;;;;;;AAcJ;;;;;;;;;;KASE;AAWK,2EAJI,MAAM,cACN,OAAO,GACN,OAAO,KAAU,CA6C5B;AA2LM,oCANI,MAAM,QACN,MAAM,WACN,MAAM,GAEL,MAAM,CAMjB;AA7LD;;;;GAIG;AACH,sDAoGC;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
1
|
import type { PostEditorAwarenessState as ActiveCollaborator, PostSaveEvent, YDocDebugData } from '../awareness/types';
|
|
2
|
-
import type { SelectionState } from '../types';
|
|
3
|
-
interface ResolvedSelection {
|
|
4
|
-
textIndex: number | null;
|
|
5
|
-
localClientId: string | null;
|
|
6
|
-
}
|
|
2
|
+
import type { SelectionState, ResolvedSelection } from '../types';
|
|
7
3
|
/**
|
|
8
4
|
* Hook to get the active collaborators for a post editor.
|
|
9
5
|
*
|
|
@@ -37,13 +33,41 @@ export declare function useGetDebugData(postId: number | null, postType: string
|
|
|
37
33
|
*/
|
|
38
34
|
export declare function useIsDisconnected(postId: number | null, postType: string | null): boolean;
|
|
39
35
|
/**
|
|
40
|
-
* Hook that
|
|
41
|
-
*
|
|
42
|
-
*
|
|
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.
|
|
43
66
|
*
|
|
44
67
|
* @param postId The ID of the post.
|
|
45
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.
|
|
46
71
|
*/
|
|
47
|
-
export declare function
|
|
48
|
-
export {};
|
|
72
|
+
export declare function useOnPostSave(postId: number | null, postType: string | null, callback: (event: PostSaveEvent, saver: ActiveCollaborator, prevEvent: PostSaveEvent | null) => void): void;
|
|
49
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
|
@@ -269,6 +269,7 @@ export const store: import("@wordpress/data").StoreDescriptor<import("@wordpress
|
|
|
269
269
|
is_custom?: boolean;
|
|
270
270
|
ignore_empty?: boolean;
|
|
271
271
|
}): string;
|
|
272
|
+
hasRevision(state: selectors.State, kind: string, name: string, recordKey: string | number, revisionKey: string | number, query?: selectors.GetRecordsHttpQuery): boolean;
|
|
272
273
|
getSyncConnectionStatus(state: selectors.State): import("@wordpress/sync").ConnectionStatus | undefined;
|
|
273
274
|
isRequestingEmbedPreview: {
|
|
274
275
|
(state: selectors.State, url: string): boolean;
|
|
@@ -340,6 +341,7 @@ export const store: import("@wordpress/data").StoreDescriptor<import("@wordpress
|
|
|
340
341
|
getWidgetTypes: (state: selectors.State, query?: selectors.GetRecordsHttpQuery) => import("./entity-types").WidgetType<"edit">[] | null;
|
|
341
342
|
}>>;
|
|
342
343
|
export { SelectionType } from "./utils/crdt-user-selections";
|
|
344
|
+
export { SelectionDirection } from "./types";
|
|
343
345
|
export { default as EntityProvider } from "./entity-provider";
|
|
344
346
|
export * from "./entity-provider";
|
|
345
347
|
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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version":3,"file":"private-apis.d.ts","sourceRoot":"","sources":["../src/private-apis.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"private-apis.d.ts","sourceRoot":"","sources":["../src/private-apis.js"],"names":[],"mappings":"AAeA,6BAA8B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reducer.d.ts","sourceRoot":"","sources":["../../src/queried-data/reducer.js"],"names":[],"mappings":"AA4BA;;;;;;;;;;GAUG;AACH,0CAPY,KAAK,CAAC,MAAM,CAAC,OAAA,eACd,MAAM,EAAE,QACR,MAAM,WACN,MAAM,GAEL,MAAM,EAAE,CA+BnB;AAyBD;;;;;;;;GAQG;AACH,
|
|
1
|
+
{"version":3,"file":"reducer.d.ts","sourceRoot":"","sources":["../../src/queried-data/reducer.js"],"names":[],"mappings":"AA4BA;;;;;;;;;;GAUG;AACH,0CAPY,KAAK,CAAC,MAAM,CAAC,OAAA,eACd,MAAM,EAAE,QACR,MAAM,WACN,MAAM,GAEL,MAAM,EAAE,CA+BnB;AAyBD;;;;;;;;GAQG;AACH,oDAiCC;AAED;;;;;;;;;;;GAWG;AACH;;;;;;;;EA8CC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selectors.d.ts","sourceRoot":"","sources":["../../src/queried-data/selectors.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"selectors.d.ts","sourceRoot":"","sources":["../../src/queried-data/selectors.js"],"names":[],"mappings":"AAsIA,kEAIC;AAED,kEAIC;AAxCD;;;;;;;;;;;;GAYG;AACH,qGAeI"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reducer.d.ts","sourceRoot":"","sources":["../src/reducer.js"],"names":[],"mappings":"AAmBA,2DAA2D;AAE3D;;;;;;;GAOG;AACH,oDAuBC;AAED;;;;;;;GAOG;AACH,0DAOC;AAED;;;;;;;GAOG;AACH,oCALW,MAAM,GAAC,SAAS,gBAGf,MAAM,GAAC,SAAS,CAS3B;A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,EAAE,MAAM,CAAC,4BAGrB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAYjC;AAED;;;;;;;GAOG;AACH,iEASC;AAED;;;;;;;GAOG;AACH,6DAMC;AAED;;;;;;;GAOG;AACH,2DAMC;AAED;;;;;;;;GAQG;AACH,qEAgBC;AAED;;;;;;;;;;;GAWG;AACH,8CALW,OAAO,4BAGN,OAAO,CAQlB;AA1UM,uDAwEN;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0BAjba,OAAO,SAAS,EAAE,WAAW"}
|
|
@@ -113,7 +113,8 @@ export function getRevisions(kind: string, name: string, recordKey: number | str
|
|
|
113
113
|
export namespace getRevisions {
|
|
114
114
|
function shouldInvalidate(action: any, kind: any, name: any, recordKey: any): boolean;
|
|
115
115
|
}
|
|
116
|
-
export function getRevision(kind: string, name: string, recordKey: number | string, revisionKey: number | string, query: any | undefined): ({ dispatch, resolveSelect }: {
|
|
116
|
+
export function getRevision(kind: string, name: string, recordKey: number | string, revisionKey: number | string, query: any | undefined): ({ select, dispatch, resolveSelect }: {
|
|
117
|
+
select: any;
|
|
117
118
|
dispatch: any;
|
|
118
119
|
resolveSelect: any;
|
|
119
120
|
}) => Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolvers.d.ts","sourceRoot":"","sources":["../src/resolvers.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"resolvers.d.ts","sourceRoot":"","sources":["../src/resolvers.js"],"names":[],"mappings":"AAqCO,kCAHI,MAAO,SAAS,IAKlB;;CAAY,mBAOnB;AAKK,mCAEE;;CAAY,mBAGnB;AAYK,sCAPI,MAAM,QACN,MAAM,OACN,MAAM,GAAC,MAAM,qBACb,MAAO,SAAS,IAMlB;;;;;CAA6C,mBAoOpD;;IAIF,kEAcC;;AAED;;GAEG;AACH,0CAAuE;AAEvE;;GAEG;AACH,6CAA0E;AAUnE,uCALI,MAAM,QACN,MAAM,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