@wordpress/core-data 7.51.0 → 7.52.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/build/actions.cjs +54 -1
- package/build/actions.cjs.map +3 -3
- package/build/components/entities-saved-states/entity-record-item.cjs +67 -0
- package/build/components/entities-saved-states/entity-record-item.cjs.map +7 -0
- package/build/components/entities-saved-states/entity-type-list.cjs +135 -0
- package/build/components/entities-saved-states/entity-type-list.cjs.map +7 -0
- package/build/components/entities-saved-states/hooks/use-is-dirty.cjs +97 -0
- package/build/components/entities-saved-states/hooks/use-is-dirty.cjs.map +7 -0
- package/build/components/entities-saved-states/index.cjs +215 -0
- package/build/components/entities-saved-states/index.cjs.map +7 -0
- package/build/entities.cjs +2 -0
- package/build/entities.cjs.map +2 -2
- package/build/private-actions.cjs +85 -0
- package/build/private-actions.cjs.map +3 -3
- package/build/private-apis.cjs +19 -0
- package/build/private-apis.cjs.map +3 -3
- package/build/utils/crdt.cjs +4 -2
- package/build/utils/crdt.cjs.map +2 -2
- package/build/utils/get-template-info.cjs +53 -0
- package/build/utils/get-template-info.cjs.map +7 -0
- package/build/utils/get-template-part-icon.cjs +43 -0
- package/build/utils/get-template-part-icon.cjs.map +7 -0
- package/build-module/actions.mjs +57 -1
- package/build-module/actions.mjs.map +2 -2
- package/build-module/components/entities-saved-states/entity-record-item.mjs +46 -0
- package/build-module/components/entities-saved-states/entity-record-item.mjs.map +7 -0
- package/build-module/components/entities-saved-states/entity-type-list.mjs +104 -0
- package/build-module/components/entities-saved-states/entity-type-list.mjs.map +7 -0
- package/build-module/components/entities-saved-states/hooks/use-is-dirty.mjs +72 -0
- package/build-module/components/entities-saved-states/hooks/use-is-dirty.mjs.map +7 -0
- package/build-module/components/entities-saved-states/index.mjs +187 -0
- package/build-module/components/entities-saved-states/index.mjs.map +7 -0
- package/build-module/entities.mjs +2 -0
- package/build-module/entities.mjs.map +2 -2
- package/build-module/private-actions.mjs +84 -0
- package/build-module/private-actions.mjs.map +2 -2
- package/build-module/private-apis.mjs +12 -0
- package/build-module/private-apis.mjs.map +2 -2
- package/build-module/utils/crdt.mjs +2 -1
- package/build-module/utils/crdt.mjs.map +2 -2
- package/build-module/utils/get-template-info.mjs +28 -0
- package/build-module/utils/get-template-info.mjs.map +7 -0
- package/build-module/utils/get-template-part-icon.mjs +24 -0
- package/build-module/utils/get-template-part-icon.mjs.map +7 -0
- package/build-types/actions.d.ts.map +1 -1
- package/build-types/components/entities-saved-states/entity-record-item.d.ts +6 -0
- package/build-types/components/entities-saved-states/entity-record-item.d.ts.map +1 -0
- package/build-types/components/entities-saved-states/entity-type-list.d.ts +6 -0
- package/build-types/components/entities-saved-states/entity-type-list.d.ts.map +1 -0
- package/build-types/components/entities-saved-states/hooks/use-is-dirty.d.ts +11 -0
- package/build-types/components/entities-saved-states/hooks/use-is-dirty.d.ts.map +1 -0
- package/build-types/components/entities-saved-states/index.d.ts +49 -0
- package/build-types/components/entities-saved-states/index.d.ts.map +1 -0
- package/build-types/entities.d.ts.map +1 -1
- package/build-types/private-actions.d.ts +19 -0
- package/build-types/private-actions.d.ts.map +1 -1
- package/build-types/private-apis.d.ts +9 -0
- package/build-types/private-apis.d.ts.map +1 -1
- package/build-types/utils/crdt.d.ts +8 -0
- package/build-types/utils/crdt.d.ts.map +1 -1
- package/build-types/utils/get-template-info.d.ts +13 -0
- package/build-types/utils/get-template-info.d.ts.map +1 -0
- package/build-types/utils/get-template-part-icon.d.ts +9 -0
- package/build-types/utils/get-template-part-icon.d.ts.map +1 -0
- package/build-types/utils/on-sub-key.d.ts +4 -0
- package/build-types/utils/on-sub-key.d.ts.map +1 -0
- package/package.json +27 -22
- package/src/actions.js +92 -1
- package/src/components/entities-saved-states/entity-record-item.js +60 -0
- package/src/components/entities-saved-states/entity-type-list.js +130 -0
- package/src/components/entities-saved-states/hooks/use-is-dirty.js +101 -0
- package/src/components/entities-saved-states/index.js +242 -0
- package/src/components/entities-saved-states/style.scss +70 -0
- package/src/components/entities-saved-states/test/use-is-dirty.js +88 -0
- package/src/entities.js +2 -0
- package/src/private-actions.js +127 -0
- package/src/private-apis.ts +12 -0
- package/src/style.scss +1 -0
- package/src/test/actions.js +587 -0
- package/src/utils/crdt.ts +1 -1
- package/src/utils/get-template-info.js +52 -0
- package/src/utils/get-template-part-icon.js +30 -0
- package/src/utils/test/get-template-info.js +224 -0
|
@@ -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 */\nimport {\n\t__unstableSerializeAndClean,\n\tparse,\n\ttype Block as WPBlock,\n} from '@wordpress/blocks';\nimport {\n\ttype CRDTDoc,\n\ttype ObjectData,\n\ttype ObjectID,\n\ttype ObjectType,\n\ttype SyncConfig,\n\tY,\n} from '@wordpress/sync';\n\n/**\n * Internal dependencies\n */\nimport { BaseAwareness } from '../awareness/base-awareness';\nimport {\n\ttype Block,\n\tdeserializeBlockAttributes,\n\tmergeCrdtBlocks,\n\ttype MergeCursorPosition,\n\tmergeRichTextUpdate,\n\ttype YBlock,\n\ttype YBlocks,\n} from './crdt-blocks';\nimport { type Post } from '../entity-types/post';\nimport { CRDT_DOC_META_PERSISTENCE_KEY, CRDT_RECORD_MAP_KEY } from '../sync';\nimport type { WPSelection } from '../types';\nimport {\n\tgetSelectionHistory,\n\tgetShiftedSelection,\n\tupdateSelectionHistory,\n} from './crdt-selection';\nimport {\n\tasRichTextOffset,\n\tcreateYMap,\n\tgetRootMap,\n\tisYMap,\n\ttype YMapRecord,\n\ttype YMapWrap,\n} from './crdt-utils';\n\n// A function that derives content from blocks. Two callers produce this:\n// `useEntityBlockEditor` reads blocks from its argument (so the optional arg\n// lets it accept whatever caller is invoked with), and the receiver-side\n// injection in this file captures blocks in a closure and ignores the arg.\ntype ContentFromBlocksFn = ( args?: { blocks: Block[] } ) => string;\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 | ContentFromBlocksFn;\n\texcerpt?: Post[ 'excerpt' ] | string;\n\tselection?: WPSelection;\n\ttitle?: Post[ 'title' ] | string;\n};\n\n// A post record as represented in the CRDT document (Y.Map).\nexport interface YPostRecord extends YMapRecord {\n\tauthor: number;\n\t// Blocks are undefined when they need to be re-parsed from content.\n\tblocks: YBlocks | undefined;\n\tcontent: Y.Text;\n\tcategories: number[];\n\tcomment_status: string;\n\tdate: string | null;\n\texcerpt: Y.Text;\n\tfeatured_media: number;\n\tformat: string;\n\tmeta: YMapWrap< YMapRecord >;\n\tping_status: string;\n\tslug: string;\n\tstatus: string;\n\tsticky: boolean;\n\ttags: number[];\n\ttemplate: string;\n\ttitle: Y.Text;\n}\n\nexport const POST_META_KEY_FOR_CRDT_DOC_PERSISTENCE = '_crdt_document';\n\n// Post meta keys that should *not* be synced.\nconst disallowedPostMetaKeys = new Set< string >( [\n\tPOST_META_KEY_FOR_CRDT_DOC_PERSISTENCE,\n] );\n\n/**\n * Given a set of local changes to a generic entity record, apply those changes\n * to the local Y.Doc.\n *\n * @param {CRDTDoc} ydoc\n * @param {Partial< ObjectData >} changes\n * @return {void}\n */\nfunction defaultApplyChangesToCRDTDoc(\n\tydoc: CRDTDoc,\n\tchanges: ObjectData\n): void {\n\tconst ymap = getRootMap( ydoc, CRDT_RECORD_MAP_KEY );\n\n\tObject.entries( changes ).forEach( ( [ key, newValue ] ) => {\n\t\t// Cannot serialize function values, so cannot sync them.\n\t\tif ( 'function' === typeof newValue ) {\n\t\t\treturn;\n\t\t}\n\n\t\tswitch ( key ) {\n\t\t\t// Add support for additional data types here.\n\n\t\t\tdefault: {\n\t\t\t\tconst currentValue = ymap.get( key );\n\t\t\t\tupdateMapValue( ymap, key, currentValue, newValue );\n\t\t\t}\n\t\t}\n\t} );\n}\n\n/**\n * Given a set of local changes to a post record, apply those changes to the\n * local Y.Doc.\n *\n * @param {CRDTDoc} ydoc\n * @param {PostChanges} changes\n * @param {Set<string>} syncedProperties\n * @return {void}\n */\nexport function applyPostChangesToCRDTDoc(\n\tydoc: CRDTDoc,\n\tchanges: PostChanges,\n\tsyncedProperties: Set< string >\n): void {\n\tconst ymap = getRootMap< YPostRecord >( ydoc, CRDT_RECORD_MAP_KEY );\n\n\tObject.keys( changes ).forEach( ( key ) => {\n\t\tif ( ! syncedProperties.has( key ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst newValue = changes[ key ];\n\n\t\t// Cannot serialize function values, so cannot sync them. `content` is\n\t\t// often passed as a lazy serializer by `useEntityBlockEditor`; the\n\t\t// receiver re-derives it from the synced blocks (see\n\t\t// getPostChangesFromCRDTDoc), so dropping it here is intentional.\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// Block changes from typing are bundled with a 'selection' update.\n\t\t\t\t// Use the resulting cursor position for block merging.\n\t\t\t\tconst newCursorPosition = parseCursorSelection(\n\t\t\t\t\tchanges.selection\n\t\t\t\t);\n\n\t\t\t\t// Blocks are undefined when they need to be re-parsed from content.\n\t\t\t\t// When new content is also part of this change (e.g. the Code\n\t\t\t\t// Editor dispatching `{ content, blocks: undefined }` on every\n\t\t\t\t// keystroke), derive blocks from content so the merge keeps\n\t\t\t\t// stable YBlock identities for unchanged blocks.\n\n\t\t\t\tconst rawContent = getRawValue( changes.content );\n\t\t\t\tif ( ! newValue && typeof rawContent === 'string' ) {\n\t\t\t\t\t// We have no blocks but an updated content string.\n\t\t\t\t\tmergeContentWithoutBlocks(\n\t\t\t\t\t\tymap,\n\t\t\t\t\t\trawContent,\n\t\t\t\t\t\tnewCursorPosition\n\t\t\t\t\t);\n\t\t\t\t\tbreak;\n\t\t\t\t} else if ( ! newValue ) {\n\t\t\t\t\t// We have an update containing empty blocks and content.\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// 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, newCursorPosition );\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\n/**\n * Derive blocks from a raw content string and merge them into the post's\n * blocks Y.Array. Used when a caller dispatches a change with `blocks:\n * undefined` alongside new content, most notably the Code Editor's\n * per-keystroke dispatch.\n *\n * @param ymap The post's root Y.Map.\n * @param rawContent The raw HTML content to parse.\n * @param cursorPosition Cursor position derived from the change's selection,\n * used by mergeCrdtBlocks for rich-text cursor hints.\n */\nfunction mergeContentWithoutBlocks(\n\tymap: YMapWrap< YPostRecord >,\n\trawContent: string,\n\tcursorPosition: MergeCursorPosition\n): void {\n\tlet currentBlocks = ymap.get( 'blocks' );\n\n\tif ( ! ( currentBlocks instanceof Y.Array ) ) {\n\t\tcurrentBlocks = new Y.Array< YBlock >();\n\t\tymap.set( 'blocks', currentBlocks );\n\t}\n\n\tmergeCrdtBlocks(\n\t\tcurrentBlocks,\n\t\tparse( rawContent ) as Block[],\n\t\tcursorPosition,\n\t\t{ preserveClientIds: true }\n\t);\n}\n\n/**\n * Only returns a selection object if it describes a selection within a block, with\n * a cursor inside a RichText field associated with one of that block’s attributes.\n *\n * @param selection Selection object which might represent a selection within a block,\n * within a RichText field associated with a particular attribute of\n * that block, or none at all.\n */\nfunction parseCursorSelection( selection?: WPSelection ): MergeCursorPosition {\n\tconst selectionStart = selection?.selectionStart;\n\n\treturn selectionStart?.clientId &&\n\t\tselectionStart.attributeKey &&\n\t\t'number' === typeof selectionStart.offset &&\n\t\tNumber.isInteger( selectionStart.offset )\n\t\t? {\n\t\t\t\tattributeKey: selectionStart.attributeKey,\n\t\t\t\tclientId: selectionStart.clientId,\n\t\t\t\toffset: asRichTextOffset( selectionStart.offset ),\n\t\t }\n\t\t: null;\n}\n\nfunction defaultGetChangesFromCRDTDoc(\n\tcrdtDoc: CRDTDoc,\n\teditedRecord: ObjectData\n): ObjectData {\n\tconst docRecord = getRootMap( crdtDoc, CRDT_RECORD_MAP_KEY ).toJSON();\n\n\t/*\n\t * Only report properties that differ from the edited record. Reporting\n\t * unchanged properties as edits marks the record dirty: `Y.Map.toJSON()`\n\t * returns fresh object instances, so without this comparison every synced\n\t * update (e.g. from another tab) re-dispatches the entire record as edits.\n\t * See https://github.com/WordPress/gutenberg/issues/79907.\n\t */\n\treturn Object.fromEntries(\n\t\tObject.entries( docRecord ).filter( ( [ key, newValue ] ) =>\n\t\t\thaveValuesChanged( editedRecord?.[ key ], newValue )\n\t\t)\n\t);\n}\n\n/**\n * Given a local Y.Doc that *may* contain changes from remote peers, compare\n * against the local record and determine if there are changes (edits) we want\n * to dispatch.\n *\n * @param {CRDTDoc} ydoc\n * @param {Post} editedRecord\n * @param {Set<string>} syncedProperties\n * @return {Partial<PostChanges>} The changes that should be applied to the local record.\n */\nexport function getPostChangesFromCRDTDoc(\n\tydoc: CRDTDoc,\n\teditedRecord: Post,\n\tsyncedProperties: Set< string >\n): PostChanges {\n\tconst ymap = getRootMap< YPostRecord >( ydoc, CRDT_RECORD_MAP_KEY );\n\n\tlet allowedMetaChanges: Post[ 'meta' ] = {};\n\n\tconst changes = Object.fromEntries(\n\t\tObject.entries( ymap.toJSON() ).filter( ( [ key, newValue ] ) => {\n\t\t\tif ( ! syncedProperties.has( key ) ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tconst currentValue = editedRecord[ key ];\n\n\t\t\tswitch ( key ) {\n\t\t\t\tcase 'blocks': {\n\t\t\t\t\t// When we are passed a persisted CRDT document, make a special\n\t\t\t\t\t// comparison of the content and blocks.\n\t\t\t\t\t//\n\t\t\t\t\t// When other fields (besides `blocks`) are mutated outside the block\n\t\t\t\t\t// editor, the change is caught by an equality check (see other cases\n\t\t\t\t\t// in this `switch` statement). As a transient property, `blocks`\n\t\t\t\t\t// cannot be directly mutated outside the block editor -- only\n\t\t\t\t\t// `content` can.\n\t\t\t\t\t//\n\t\t\t\t\t// Therefore, for this special comparison, we serialize the `blocks`\n\t\t\t\t\t// from the persisted CRDT document and compare that to the content\n\t\t\t\t\t// from the persisted record. If they differ, we know that the content\n\t\t\t\t\t// in the database has changed, and therefore the blocks have changed.\n\t\t\t\t\t//\n\t\t\t\t\t// We cannot directly compare the `blocks` from the CRDT document to\n\t\t\t\t\t// the `blocks` derived from the `content` in the persisted record,\n\t\t\t\t\t// because the latter will have different client IDs.\n\t\t\t\t\tif (\n\t\t\t\t\t\tydoc.meta?.get( CRDT_DOC_META_PERSISTENCE_KEY ) &&\n\t\t\t\t\t\teditedRecord.content\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst blocksJson = ymap.get( 'blocks' )?.toJSON() ?? [];\n\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t__unstableSerializeAndClean( blocksJson ).trim() !==\n\t\t\t\t\t\t\tgetRawValue( editedRecord.content )\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\n\t\t\t\tcase 'date': {\n\t\t\t\t\t// Do not overwrite a \"floating\" date. Borrowing logic from the\n\t\t\t\t\t// isEditedPostDateFloating selector.\n\t\t\t\t\tconst currentDateIsFloating =\n\t\t\t\t\t\tnull === currentValue ||\n\t\t\t\t\t\teditedRecord.modified === currentValue;\n\n\t\t\t\t\tif ( currentDateIsFloating ) {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn haveValuesChanged( currentValue, newValue );\n\t\t\t\t}\n\n\t\t\t\tcase 'meta': {\n\t\t\t\t\tconst currentMeta =\n\t\t\t\t\t\t( currentValue as PostChanges[ 'meta' ] ) ?? {};\n\n\t\t\t\t\tallowedMetaChanges = Object.fromEntries(\n\t\t\t\t\t\tObject.entries( newValue ?? {} ).filter(\n\t\t\t\t\t\t\t( [ metaKey ] ) => {\n\t\t\t\t\t\t\t\tif ( disallowedPostMetaKeys.has( metaKey ) ) {\n\t\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t// Ignore meta keys that are no longer registered\n\t\t\t\t\t\t\t\t// for this post (absent from the REST response).\n\t\t\t\t\t\t\t\t// Without this, orphaned CRDT meta would mark\n\t\t\t\t\t\t\t\t// the post permanently dirty.\n\t\t\t\t\t\t\t\treturn metaKey in currentMeta;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\n\t\t\t\t\t// Merge the allowed meta changes with the current meta values since\n\t\t\t\t\t// not all meta properties are synced.\n\t\t\t\t\tconst mergedValue = {\n\t\t\t\t\t\t...currentMeta,\n\t\t\t\t\t\t...allowedMetaChanges,\n\t\t\t\t\t};\n\n\t\t\t\t\treturn haveValuesChanged( currentValue, mergedValue );\n\t\t\t\t}\n\n\t\t\t\tcase 'status': {\n\t\t\t\t\t// Do not sync an invalid status.\n\t\t\t\t\tif ( 'auto-draft' === newValue ) {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn haveValuesChanged( currentValue, newValue );\n\t\t\t\t}\n\n\t\t\t\tcase 'content':\n\t\t\t\tcase 'excerpt':\n\t\t\t\tcase 'title': {\n\t\t\t\t\treturn haveValuesChanged(\n\t\t\t\t\t\tgetRawValue( currentValue ),\n\t\t\t\t\t\tnewValue\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\t// Add support for additional data types here.\n\n\t\t\t\tdefault: {\n\t\t\t\t\treturn haveValuesChanged( currentValue, newValue );\n\t\t\t\t}\n\t\t\t}\n\t\t} )\n\t);\n\n\t// Blocks extracted from the CRDT document have rich-text attributes as\n\t// plain strings (from Y.Text.toJSON()). Convert them back to RichTextData\n\t// so block edit components receive the same types as locally-created blocks.\n\tif ( changes.blocks ) {\n\t\tchanges.blocks = deserializeBlockAttributes(\n\t\t\tchanges.blocks as Block[]\n\t\t);\n\t}\n\n\t// When blocks changed but content didn't (the sender internally used a lazy\n\t// serializer function), inject a closure that captures the synced blocks\n\t// and serializes them on demand. Mirrors what useEntityBlockEditor does\n\t// locally. A fresh function on every persistent edit marks the entity\n\t// dirty (so the save button reactivates for peers), while serialization\n\t// stays lazy (only runs when getEditedPostContent reads it). The closure\n\t// captures `capturedBlocks` so the right content is returned even if the\n\t// caller later clears `record.blocks` (e.g. the Code Editor re-parsing\n\t// from content).\n\tif ( changes.blocks && ! changes.content ) {\n\t\tconst capturedBlocks = changes.blocks;\n\t\tchanges.content = () =>\n\t\t\t__unstableSerializeAndClean( capturedBlocks as WPBlock[] );\n\t}\n\n\t// Meta changes must be merged with the edited record since not all meta\n\t// properties are synced.\n\tif ( 'object' === typeof changes.meta ) {\n\t\tchanges.meta = {\n\t\t\t...editedRecord.meta,\n\t\t\t...allowedMetaChanges,\n\t\t};\n\t}\n\n\t// When remote content changes are detected, recalculate the local user's\n\t// selection using Y.RelativePosition to account for text shifts. The ydoc\n\t// has already been updated with remote content at this point, so converting\n\t// relative positions to absolute gives corrected offsets. Including the\n\t// selection in PostChanges ensures it dispatches atomically with content.\n\tconst selectionHistory = getSelectionHistory( ydoc );\n\tconst shiftedSelection = getShiftedSelection( ydoc, selectionHistory );\n\tif ( shiftedSelection ) {\n\t\tchanges.selection = {\n\t\t\t...shiftedSelection,\n\t\t\tinitialPosition: 0,\n\t\t};\n\t}\n\n\treturn changes;\n}\n\n/**\n * This default sync config can be used for entities that are flat maps of\n * primitive values and do not require custom logic to merge changes.\n */\nexport const defaultSyncConfig: SyncConfig = {\n\tapplyChangesToCRDTDoc: defaultApplyChangesToCRDTDoc,\n\tcreateAwareness: ( ydoc: CRDTDoc ) => new BaseAwareness( ydoc ),\n\tgetChangesFromCRDTDoc: defaultGetChangesFromCRDTDoc,\n};\n\n/**\n * This default collection sync config can be used to sync entity collections\n * (e.g., block comments) where we are not interested in merging changes at the\n * individual record level, but instead want to replace the entire collection\n * when changes are detected.\n */\nexport const defaultCollectionSyncConfig: SyncConfig = {\n\tapplyChangesToCRDTDoc: () => {},\n\tgetChangesFromCRDTDoc: () => ( {} ),\n\tshouldSync: ( _: ObjectType, objectId: ObjectID | null ) =>\n\t\tnull === objectId,\n};\n\n/**\n * Extract the raw string value from a property that may be a string or an object\n * with a `raw` property (`RenderedText`).\n *\n * @param {unknown} value The value to extract from.\n * @return {string|undefined} The raw string value, or undefined if it could not be determined.\n */\nfunction getRawValue( value?: unknown ): string | undefined {\n\t// Value may be a string property or a nested object with a `raw` property.\n\tif ( 'string' === typeof value ) {\n\t\treturn value;\n\t}\n\n\tif (\n\t\tvalue &&\n\t\t'object' === typeof value &&\n\t\t'raw' in value &&\n\t\t'string' === typeof value.raw\n\t) {\n\t\treturn value.raw;\n\t}\n\n\treturn undefined;\n}\n\nfunction haveValuesChanged< ValueType >(\n\tcurrentValue: ValueType | undefined,\n\tnewValue: ValueType | undefined\n): boolean {\n\treturn ! fastDeepEqual( currentValue, newValue );\n}\n\nfunction updateMapValue< T extends YMapRecord, K extends keyof T >(\n\tmap: YMapWrap< T >,\n\tkey: K,\n\tcurrentValue: T[ K ] | undefined,\n\tnewValue: T[ K ] | undefined\n): void {\n\tif ( undefined === newValue ) {\n\t\tmap.delete( key );\n\t\treturn;\n\t}\n\n\tif ( haveValuesChanged< T[ K ] >( currentValue, newValue ) ) {\n\t\tmap.set( key, newValue );\n\t}\n}\n"],
|
|
5
|
-
"mappings": ";AAGA,OAAO,mBAAmB;AAK1B;AAAA,EACC;AAAA,EACA;AAAA,OAEM;AACP;AAAA,EAMC;AAAA,OACM;AAKP,SAAS,qBAAqB;AAC9B;AAAA,EAEC;AAAA,EACA;AAAA,EAEA;AAAA,OAGM;AAEP,SAAS,+BAA+B,2BAA2B;AAEnE;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAGM;AAuCA,IAAM,yCAAyC;AAGtD,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,IAC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YAAQ,YAAY;AAAA,MACnB,GAAG;AAAA,MACH,iBAAiB;AAAA,IAClB;AAAA,EACD;AAEA,SAAO;AACR;AAMO,IAAM,oBAAgC;AAAA,EAC5C,uBAAuB;AAAA,EACvB,iBAAiB,CAAE,SAAmB,IAAI,cAAe,IAAK;AAAA,EAC9D,uBAAuB;AACxB;AAQO,IAAM,8BAA0C;AAAA,EACtD,uBAAuB,MAAM;AAAA,EAAC;AAAA,EAC9B,uBAAuB,OAAQ,CAAC;AAAA,EAChC,YAAY,CAAE,GAAe,aAC5B,SAAS;AACX;
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport fastDeepEqual from 'fast-deep-equal/es6/index.js';\n\n/**\n * WordPress dependencies\n */\nimport {\n\t__unstableSerializeAndClean,\n\tparse,\n\ttype Block as WPBlock,\n} from '@wordpress/blocks';\nimport {\n\ttype CRDTDoc,\n\ttype ObjectData,\n\ttype ObjectID,\n\ttype ObjectType,\n\ttype SyncConfig,\n\tY,\n} from '@wordpress/sync';\n\n/**\n * Internal dependencies\n */\nimport { BaseAwareness } from '../awareness/base-awareness';\nimport {\n\ttype Block,\n\tdeserializeBlockAttributes,\n\tmergeCrdtBlocks,\n\ttype MergeCursorPosition,\n\tmergeRichTextUpdate,\n\ttype YBlock,\n\ttype YBlocks,\n} from './crdt-blocks';\nimport { type Post } from '../entity-types/post';\nimport { CRDT_DOC_META_PERSISTENCE_KEY, CRDT_RECORD_MAP_KEY } from '../sync';\nimport type { WPSelection } from '../types';\nimport {\n\tgetSelectionHistory,\n\tgetShiftedSelection,\n\tupdateSelectionHistory,\n} from './crdt-selection';\nimport {\n\tasRichTextOffset,\n\tcreateYMap,\n\tgetRootMap,\n\tisYMap,\n\ttype YMapRecord,\n\ttype YMapWrap,\n} from './crdt-utils';\n\n// A function that derives content from blocks. Two callers produce this:\n// `useEntityBlockEditor` reads blocks from its argument (so the optional arg\n// lets it accept whatever caller is invoked with), and the receiver-side\n// injection in this file captures blocks in a closure and ignores the arg.\ntype ContentFromBlocksFn = ( args?: { blocks: Block[] } ) => string;\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 | ContentFromBlocksFn;\n\texcerpt?: Post[ 'excerpt' ] | string;\n\tselection?: WPSelection;\n\ttitle?: Post[ 'title' ] | string;\n};\n\n// A post record as represented in the CRDT document (Y.Map).\nexport interface YPostRecord extends YMapRecord {\n\tauthor: number;\n\t// Blocks are undefined when they need to be re-parsed from content.\n\tblocks: YBlocks | undefined;\n\tcontent: Y.Text;\n\tcategories: number[];\n\tcomment_status: string;\n\tdate: string | null;\n\texcerpt: Y.Text;\n\tfeatured_media: number;\n\tformat: string;\n\tmeta: YMapWrap< YMapRecord >;\n\tping_status: string;\n\tslug: string;\n\tstatus: string;\n\tsticky: boolean;\n\ttags: number[];\n\ttemplate: string;\n\ttitle: Y.Text;\n}\n\nexport const POST_META_KEY_FOR_CRDT_DOC_PERSISTENCE = '_crdt_document';\n\n// Post meta keys that should *not* be synced.\nconst disallowedPostMetaKeys = new Set< string >( [\n\tPOST_META_KEY_FOR_CRDT_DOC_PERSISTENCE,\n] );\n\n/**\n * Given a set of local changes to a generic entity record, apply those changes\n * to the local Y.Doc.\n *\n * @param {CRDTDoc} ydoc\n * @param {Partial< ObjectData >} changes\n * @return {void}\n */\nfunction defaultApplyChangesToCRDTDoc(\n\tydoc: CRDTDoc,\n\tchanges: ObjectData\n): void {\n\tconst ymap = getRootMap( ydoc, CRDT_RECORD_MAP_KEY );\n\n\tObject.entries( changes ).forEach( ( [ key, newValue ] ) => {\n\t\t// Cannot serialize function values, so cannot sync them.\n\t\tif ( 'function' === typeof newValue ) {\n\t\t\treturn;\n\t\t}\n\n\t\tswitch ( key ) {\n\t\t\t// Add support for additional data types here.\n\n\t\t\tdefault: {\n\t\t\t\tconst currentValue = ymap.get( key );\n\t\t\t\tupdateMapValue( ymap, key, currentValue, newValue );\n\t\t\t}\n\t\t}\n\t} );\n}\n\n/**\n * Given a set of local changes to a post record, apply those changes to the\n * local Y.Doc.\n *\n * @param {CRDTDoc} ydoc\n * @param {PostChanges} changes\n * @param {Set<string>} syncedProperties\n * @return {void}\n */\nexport function applyPostChangesToCRDTDoc(\n\tydoc: CRDTDoc,\n\tchanges: PostChanges,\n\tsyncedProperties: Set< string >\n): void {\n\tconst ymap = getRootMap< YPostRecord >( ydoc, CRDT_RECORD_MAP_KEY );\n\n\tObject.keys( changes ).forEach( ( key ) => {\n\t\tif ( ! syncedProperties.has( key ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst newValue = changes[ key ];\n\n\t\t// Cannot serialize function values, so cannot sync them. `content` is\n\t\t// often passed as a lazy serializer by `useEntityBlockEditor`; the\n\t\t// receiver re-derives it from the synced blocks (see\n\t\t// getPostChangesFromCRDTDoc), so dropping it here is intentional.\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// Block changes from typing are bundled with a 'selection' update.\n\t\t\t\t// Use the resulting cursor position for block merging.\n\t\t\t\tconst newCursorPosition = parseCursorSelection(\n\t\t\t\t\tchanges.selection\n\t\t\t\t);\n\n\t\t\t\t// Blocks are undefined when they need to be re-parsed from content.\n\t\t\t\t// When new content is also part of this change (e.g. the Code\n\t\t\t\t// Editor dispatching `{ content, blocks: undefined }` on every\n\t\t\t\t// keystroke), derive blocks from content so the merge keeps\n\t\t\t\t// stable YBlock identities for unchanged blocks.\n\n\t\t\t\tconst rawContent = getRawValue( changes.content );\n\t\t\t\tif ( ! newValue && typeof rawContent === 'string' ) {\n\t\t\t\t\t// We have no blocks but an updated content string.\n\t\t\t\t\tmergeContentWithoutBlocks(\n\t\t\t\t\t\tymap,\n\t\t\t\t\t\trawContent,\n\t\t\t\t\t\tnewCursorPosition\n\t\t\t\t\t);\n\t\t\t\t\tbreak;\n\t\t\t\t} else if ( ! newValue ) {\n\t\t\t\t\t// We have an update containing empty blocks and content.\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// 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, newCursorPosition );\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\n/**\n * Derive blocks from a raw content string and merge them into the post's\n * blocks Y.Array. Used when a caller dispatches a change with `blocks:\n * undefined` alongside new content, most notably the Code Editor's\n * per-keystroke dispatch.\n *\n * @param ymap The post's root Y.Map.\n * @param rawContent The raw HTML content to parse.\n * @param cursorPosition Cursor position derived from the change's selection,\n * used by mergeCrdtBlocks for rich-text cursor hints.\n */\nfunction mergeContentWithoutBlocks(\n\tymap: YMapWrap< YPostRecord >,\n\trawContent: string,\n\tcursorPosition: MergeCursorPosition\n): void {\n\tlet currentBlocks = ymap.get( 'blocks' );\n\n\tif ( ! ( currentBlocks instanceof Y.Array ) ) {\n\t\tcurrentBlocks = new Y.Array< YBlock >();\n\t\tymap.set( 'blocks', currentBlocks );\n\t}\n\n\tmergeCrdtBlocks(\n\t\tcurrentBlocks,\n\t\tparse( rawContent ) as Block[],\n\t\tcursorPosition,\n\t\t{ preserveClientIds: true }\n\t);\n}\n\n/**\n * Only returns a selection object if it describes a selection within a block, with\n * a cursor inside a RichText field associated with one of that block’s attributes.\n *\n * @param selection Selection object which might represent a selection within a block,\n * within a RichText field associated with a particular attribute of\n * that block, or none at all.\n */\nfunction parseCursorSelection( selection?: WPSelection ): MergeCursorPosition {\n\tconst selectionStart = selection?.selectionStart;\n\n\treturn selectionStart?.clientId &&\n\t\tselectionStart.attributeKey &&\n\t\t'number' === typeof selectionStart.offset &&\n\t\tNumber.isInteger( selectionStart.offset )\n\t\t? {\n\t\t\t\tattributeKey: selectionStart.attributeKey,\n\t\t\t\tclientId: selectionStart.clientId,\n\t\t\t\toffset: asRichTextOffset( selectionStart.offset ),\n\t\t }\n\t\t: null;\n}\n\nfunction defaultGetChangesFromCRDTDoc(\n\tcrdtDoc: CRDTDoc,\n\teditedRecord: ObjectData\n): ObjectData {\n\tconst docRecord = getRootMap( crdtDoc, CRDT_RECORD_MAP_KEY ).toJSON();\n\n\t/*\n\t * Only report properties that differ from the edited record. Reporting\n\t * unchanged properties as edits marks the record dirty: `Y.Map.toJSON()`\n\t * returns fresh object instances, so without this comparison every synced\n\t * update (e.g. from another tab) re-dispatches the entire record as edits.\n\t * See https://github.com/WordPress/gutenberg/issues/79907.\n\t */\n\treturn Object.fromEntries(\n\t\tObject.entries( docRecord ).filter( ( [ key, newValue ] ) =>\n\t\t\thaveValuesChanged( editedRecord?.[ key ], newValue )\n\t\t)\n\t);\n}\n\n/**\n * Given a local Y.Doc that *may* contain changes from remote peers, compare\n * against the local record and determine if there are changes (edits) we want\n * to dispatch.\n *\n * @param {CRDTDoc} ydoc\n * @param {Post} editedRecord\n * @param {Set<string>} syncedProperties\n * @return {Partial<PostChanges>} The changes that should be applied to the local record.\n */\nexport function getPostChangesFromCRDTDoc(\n\tydoc: CRDTDoc,\n\teditedRecord: Post,\n\tsyncedProperties: Set< string >\n): PostChanges {\n\tconst ymap = getRootMap< YPostRecord >( ydoc, CRDT_RECORD_MAP_KEY );\n\n\tlet allowedMetaChanges: Post[ 'meta' ] = {};\n\n\tconst changes = Object.fromEntries(\n\t\tObject.entries( ymap.toJSON() ).filter( ( [ key, newValue ] ) => {\n\t\t\tif ( ! syncedProperties.has( key ) ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tconst currentValue = editedRecord[ key ];\n\n\t\t\tswitch ( key ) {\n\t\t\t\tcase 'blocks': {\n\t\t\t\t\t// When we are passed a persisted CRDT document, make a special\n\t\t\t\t\t// comparison of the content and blocks.\n\t\t\t\t\t//\n\t\t\t\t\t// When other fields (besides `blocks`) are mutated outside the block\n\t\t\t\t\t// editor, the change is caught by an equality check (see other cases\n\t\t\t\t\t// in this `switch` statement). As a transient property, `blocks`\n\t\t\t\t\t// cannot be directly mutated outside the block editor -- only\n\t\t\t\t\t// `content` can.\n\t\t\t\t\t//\n\t\t\t\t\t// Therefore, for this special comparison, we serialize the `blocks`\n\t\t\t\t\t// from the persisted CRDT document and compare that to the content\n\t\t\t\t\t// from the persisted record. If they differ, we know that the content\n\t\t\t\t\t// in the database has changed, and therefore the blocks have changed.\n\t\t\t\t\t//\n\t\t\t\t\t// We cannot directly compare the `blocks` from the CRDT document to\n\t\t\t\t\t// the `blocks` derived from the `content` in the persisted record,\n\t\t\t\t\t// because the latter will have different client IDs.\n\t\t\t\t\tif (\n\t\t\t\t\t\tydoc.meta?.get( CRDT_DOC_META_PERSISTENCE_KEY ) &&\n\t\t\t\t\t\teditedRecord.content\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst blocksJson = ymap.get( 'blocks' )?.toJSON() ?? [];\n\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t__unstableSerializeAndClean( blocksJson ).trim() !==\n\t\t\t\t\t\t\tgetRawValue( editedRecord.content )\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\n\t\t\t\tcase 'date': {\n\t\t\t\t\t// Do not overwrite a \"floating\" date. Borrowing logic from the\n\t\t\t\t\t// isEditedPostDateFloating selector.\n\t\t\t\t\tconst currentDateIsFloating =\n\t\t\t\t\t\tnull === currentValue ||\n\t\t\t\t\t\teditedRecord.modified === currentValue;\n\n\t\t\t\t\tif ( currentDateIsFloating ) {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn haveValuesChanged( currentValue, newValue );\n\t\t\t\t}\n\n\t\t\t\tcase 'meta': {\n\t\t\t\t\tconst currentMeta =\n\t\t\t\t\t\t( currentValue as PostChanges[ 'meta' ] ) ?? {};\n\n\t\t\t\t\tallowedMetaChanges = Object.fromEntries(\n\t\t\t\t\t\tObject.entries( newValue ?? {} ).filter(\n\t\t\t\t\t\t\t( [ metaKey ] ) => {\n\t\t\t\t\t\t\t\tif ( disallowedPostMetaKeys.has( metaKey ) ) {\n\t\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t// Ignore meta keys that are no longer registered\n\t\t\t\t\t\t\t\t// for this post (absent from the REST response).\n\t\t\t\t\t\t\t\t// Without this, orphaned CRDT meta would mark\n\t\t\t\t\t\t\t\t// the post permanently dirty.\n\t\t\t\t\t\t\t\treturn metaKey in currentMeta;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\n\t\t\t\t\t// Merge the allowed meta changes with the current meta values since\n\t\t\t\t\t// not all meta properties are synced.\n\t\t\t\t\tconst mergedValue = {\n\t\t\t\t\t\t...currentMeta,\n\t\t\t\t\t\t...allowedMetaChanges,\n\t\t\t\t\t};\n\n\t\t\t\t\treturn haveValuesChanged( currentValue, mergedValue );\n\t\t\t\t}\n\n\t\t\t\tcase 'status': {\n\t\t\t\t\t// Do not sync an invalid status.\n\t\t\t\t\tif ( 'auto-draft' === newValue ) {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn haveValuesChanged( currentValue, newValue );\n\t\t\t\t}\n\n\t\t\t\tcase 'content':\n\t\t\t\tcase 'excerpt':\n\t\t\t\tcase 'title': {\n\t\t\t\t\treturn haveValuesChanged(\n\t\t\t\t\t\tgetRawValue( currentValue ),\n\t\t\t\t\t\tnewValue\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\t// Add support for additional data types here.\n\n\t\t\t\tdefault: {\n\t\t\t\t\treturn haveValuesChanged( currentValue, newValue );\n\t\t\t\t}\n\t\t\t}\n\t\t} )\n\t);\n\n\t// Blocks extracted from the CRDT document have rich-text attributes as\n\t// plain strings (from Y.Text.toJSON()). Convert them back to RichTextData\n\t// so block edit components receive the same types as locally-created blocks.\n\tif ( changes.blocks ) {\n\t\tchanges.blocks = deserializeBlockAttributes(\n\t\t\tchanges.blocks as Block[]\n\t\t);\n\t}\n\n\t// When blocks changed but content didn't (the sender internally used a lazy\n\t// serializer function), inject a closure that captures the synced blocks\n\t// and serializes them on demand. Mirrors what useEntityBlockEditor does\n\t// locally. A fresh function on every persistent edit marks the entity\n\t// dirty (so the save button reactivates for peers), while serialization\n\t// stays lazy (only runs when getEditedPostContent reads it). The closure\n\t// captures `capturedBlocks` so the right content is returned even if the\n\t// caller later clears `record.blocks` (e.g. the Code Editor re-parsing\n\t// from content).\n\tif ( changes.blocks && ! changes.content ) {\n\t\tconst capturedBlocks = changes.blocks;\n\t\tchanges.content = () =>\n\t\t\t__unstableSerializeAndClean( capturedBlocks as WPBlock[] );\n\t}\n\n\t// Meta changes must be merged with the edited record since not all meta\n\t// properties are synced.\n\tif ( 'object' === typeof changes.meta ) {\n\t\tchanges.meta = {\n\t\t\t...editedRecord.meta,\n\t\t\t...allowedMetaChanges,\n\t\t};\n\t}\n\n\t// When remote content changes are detected, recalculate the local user's\n\t// selection using Y.RelativePosition to account for text shifts. The ydoc\n\t// has already been updated with remote content at this point, so converting\n\t// relative positions to absolute gives corrected offsets. Including the\n\t// selection in PostChanges ensures it dispatches atomically with content.\n\tconst selectionHistory = getSelectionHistory( ydoc );\n\tconst shiftedSelection = getShiftedSelection( ydoc, selectionHistory );\n\tif ( shiftedSelection ) {\n\t\tchanges.selection = {\n\t\t\t...shiftedSelection,\n\t\t\tinitialPosition: 0,\n\t\t};\n\t}\n\n\treturn changes;\n}\n\n/**\n * This default sync config can be used for entities that are flat maps of\n * primitive values and do not require custom logic to merge changes.\n */\nexport const defaultSyncConfig: SyncConfig = {\n\tapplyChangesToCRDTDoc: defaultApplyChangesToCRDTDoc,\n\tcreateAwareness: ( ydoc: CRDTDoc ) => new BaseAwareness( ydoc ),\n\tgetChangesFromCRDTDoc: defaultGetChangesFromCRDTDoc,\n};\n\n/**\n * This default collection sync config can be used to sync entity collections\n * (e.g., block comments) where we are not interested in merging changes at the\n * individual record level, but instead want to replace the entire collection\n * when changes are detected.\n */\nexport const defaultCollectionSyncConfig: SyncConfig = {\n\tapplyChangesToCRDTDoc: () => {},\n\tgetChangesFromCRDTDoc: () => ( {} ),\n\tshouldSync: ( _: ObjectType, objectId: ObjectID | null ) =>\n\t\tnull === objectId,\n};\n\n/**\n * Extract the raw string value from a property that may be a string or an object\n * with a `raw` property (`RenderedText`).\n *\n * @param {unknown} value The value to extract from.\n * @return {string|undefined} The raw string value, or undefined if it could not be determined.\n */\nexport function 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;AAK1B;AAAA,EACC;AAAA,EACA;AAAA,OAEM;AACP;AAAA,EAMC;AAAA,OACM;AAKP,SAAS,qBAAqB;AAC9B;AAAA,EAEC;AAAA,EACA;AAAA,EAEA;AAAA,OAGM;AAEP,SAAS,+BAA+B,2BAA2B;AAEnE;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAGM;AAuCA,IAAM,yCAAyC;AAGtD,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,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AAY;AAAA,MACnB,GAAG;AAAA,MACH,iBAAiB;AAAA,IAClB;AAAA,EACD;AAEA,SAAO;AACR;AAMO,IAAM,oBAAgC;AAAA,EAC5C,uBAAuB;AAAA,EACvB,iBAAiB,CAAE,SAAmB,IAAI,cAAe,IAAK;AAAA,EAC9D,uBAAuB;AACxB;AAQO,IAAM,8BAA0C;AAAA,EACtD,uBAAuB,MAAM;AAAA,EAAC;AAAA,EAC9B,uBAAuB,OAAQ,CAAC;AAAA,EAChC,YAAY,CAAE,GAAe,aAC5B,SAAS;AACX;AASO,SAAS,YAAa,OAAsC;AAElE,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;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// packages/core-data/src/utils/get-template-info.js
|
|
2
|
+
import { layout } from "@wordpress/icons";
|
|
3
|
+
import { getTemplatePartIcon } from "./get-template-part-icon.mjs";
|
|
4
|
+
var EMPTY_OBJECT = {};
|
|
5
|
+
var getTemplateInfo = (params) => {
|
|
6
|
+
if (!params) {
|
|
7
|
+
return EMPTY_OBJECT;
|
|
8
|
+
}
|
|
9
|
+
const { templateTypes, templateAreas, template } = params;
|
|
10
|
+
const { description, slug, title, area } = template;
|
|
11
|
+
const { title: defaultTitle, description: defaultDescription } = Object.values(templateTypes).find((type) => type.slug === slug) ?? EMPTY_OBJECT;
|
|
12
|
+
const templateTitle = typeof title === "string" ? title : title?.rendered;
|
|
13
|
+
const templateDescription = typeof description === "string" ? description : description?.raw;
|
|
14
|
+
const templateAreasWithIcon = templateAreas?.map((item) => ({
|
|
15
|
+
...item,
|
|
16
|
+
icon: getTemplatePartIcon(item.icon)
|
|
17
|
+
}));
|
|
18
|
+
const templateIcon = templateAreasWithIcon?.find((item) => area === item.area)?.icon || layout;
|
|
19
|
+
return {
|
|
20
|
+
title: templateTitle && templateTitle !== slug ? templateTitle : defaultTitle || slug,
|
|
21
|
+
description: templateDescription || defaultDescription,
|
|
22
|
+
icon: templateIcon
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export {
|
|
26
|
+
getTemplateInfo
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=get-template-info.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/utils/get-template-info.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { layout } from '@wordpress/icons';\n/**\n * Internal dependencies\n */\nimport { getTemplatePartIcon } from './get-template-part-icon';\nconst EMPTY_OBJECT = {};\n\n/**\n * Helper function to retrieve the corresponding template info for a given template.\n * @param {Object} params\n * @param {Array} params.templateTypes\n * @param {Array} [params.templateAreas]\n * @param {Object} params.template\n */\nexport const getTemplateInfo = ( params ) => {\n\tif ( ! params ) {\n\t\treturn EMPTY_OBJECT;\n\t}\n\n\tconst { templateTypes, templateAreas, template } = params;\n\n\tconst { description, slug, title, area } = template;\n\n\tconst { title: defaultTitle, description: defaultDescription } =\n\t\tObject.values( templateTypes ).find( ( type ) => type.slug === slug ) ??\n\t\tEMPTY_OBJECT;\n\n\tconst templateTitle = typeof title === 'string' ? title : title?.rendered;\n\tconst templateDescription =\n\t\ttypeof description === 'string' ? description : description?.raw;\n\n\tconst templateAreasWithIcon = templateAreas?.map( ( item ) => ( {\n\t\t...item,\n\t\ticon: getTemplatePartIcon( item.icon ),\n\t} ) );\n\n\tconst templateIcon =\n\t\ttemplateAreasWithIcon?.find( ( item ) => area === item.area )?.icon ||\n\t\tlayout;\n\n\treturn {\n\t\ttitle:\n\t\t\ttemplateTitle && templateTitle !== slug\n\t\t\t\t? templateTitle\n\t\t\t\t: defaultTitle || slug,\n\t\tdescription: templateDescription || defaultDescription,\n\t\ticon: templateIcon,\n\t};\n};\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,cAAc;AAIvB,SAAS,2BAA2B;AACpC,IAAM,eAAe,CAAC;AASf,IAAM,kBAAkB,CAAE,WAAY;AAC5C,MAAK,CAAE,QAAS;AACf,WAAO;AAAA,EACR;AAEA,QAAM,EAAE,eAAe,eAAe,SAAS,IAAI;AAEnD,QAAM,EAAE,aAAa,MAAM,OAAO,KAAK,IAAI;AAE3C,QAAM,EAAE,OAAO,cAAc,aAAa,mBAAmB,IAC5D,OAAO,OAAQ,aAAc,EAAE,KAAM,CAAE,SAAU,KAAK,SAAS,IAAK,KACpE;AAED,QAAM,gBAAgB,OAAO,UAAU,WAAW,QAAQ,OAAO;AACjE,QAAM,sBACL,OAAO,gBAAgB,WAAW,cAAc,aAAa;AAE9D,QAAM,wBAAwB,eAAe,IAAK,CAAE,UAAY;AAAA,IAC/D,GAAG;AAAA,IACH,MAAM,oBAAqB,KAAK,IAAK;AAAA,EACtC,EAAI;AAEJ,QAAM,eACL,uBAAuB,KAAM,CAAE,SAAU,SAAS,KAAK,IAAK,GAAG,QAC/D;AAED,SAAO;AAAA,IACN,OACC,iBAAiB,kBAAkB,OAChC,gBACA,gBAAgB;AAAA,IACpB,aAAa,uBAAuB;AAAA,IACpC,MAAM;AAAA,EACP;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// packages/core-data/src/utils/get-template-part-icon.js
|
|
2
|
+
import {
|
|
3
|
+
header as headerIcon,
|
|
4
|
+
footer as footerIcon,
|
|
5
|
+
sidebar as sidebarIcon,
|
|
6
|
+
navigationOverlay as navigationOverlayIcon,
|
|
7
|
+
symbolFilled as symbolFilledIcon
|
|
8
|
+
} from "@wordpress/icons";
|
|
9
|
+
function getTemplatePartIcon(areaOrIconName) {
|
|
10
|
+
if ("header" === areaOrIconName) {
|
|
11
|
+
return headerIcon;
|
|
12
|
+
} else if ("footer" === areaOrIconName) {
|
|
13
|
+
return footerIcon;
|
|
14
|
+
} else if ("sidebar" === areaOrIconName) {
|
|
15
|
+
return sidebarIcon;
|
|
16
|
+
} else if ("navigation-overlay" === areaOrIconName) {
|
|
17
|
+
return navigationOverlayIcon;
|
|
18
|
+
}
|
|
19
|
+
return symbolFilledIcon;
|
|
20
|
+
}
|
|
21
|
+
export {
|
|
22
|
+
getTemplatePartIcon
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=get-template-part-icon.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/utils/get-template-part-icon.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\theader as headerIcon,\n\tfooter as footerIcon,\n\tsidebar as sidebarIcon,\n\tnavigationOverlay as navigationOverlayIcon,\n\tsymbolFilled as symbolFilledIcon,\n} from '@wordpress/icons';\n\n/**\n * Helper function to retrieve the corresponding icon by area name.\n *\n * @param {string} areaOrIconName The area name (e.g., 'header', 'navigation-overlay').\n *\n * @return {Object} The corresponding icon.\n */\nexport function getTemplatePartIcon( areaOrIconName ) {\n\tif ( 'header' === areaOrIconName ) {\n\t\treturn headerIcon;\n\t} else if ( 'footer' === areaOrIconName ) {\n\t\treturn footerIcon;\n\t} else if ( 'sidebar' === areaOrIconName ) {\n\t\treturn sidebarIcon;\n\t} else if ( 'navigation-overlay' === areaOrIconName ) {\n\t\treturn navigationOverlayIcon;\n\t}\n\treturn symbolFilledIcon;\n}\n"],
|
|
5
|
+
"mappings": ";AAGA;AAAA,EACC,UAAU;AAAA,EACV,UAAU;AAAA,EACV,WAAW;AAAA,EACX,qBAAqB;AAAA,EACrB,gBAAgB;AAAA,OACV;AASA,SAAS,oBAAqB,gBAAiB;AACrD,MAAK,aAAa,gBAAiB;AAClC,WAAO;AAAA,EACR,WAAY,aAAa,gBAAiB;AACzC,WAAO;AAAA,EACR,WAAY,cAAc,gBAAiB;AAC1C,WAAO;AAAA,EACR,WAAY,yBAAyB,gBAAiB;AACrD,WAAO;AAAA,EACR;AACA,SAAO;AACR;",
|
|
6
|
+
"names": []
|
|
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":"AA4FA;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAE,OAAO,EAL9B,MAK8B,EAAE,KAAK,EAJrC,WAIqC,OAM/C;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAE,WAAW,KAAA,OAK9C;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAE,QAAQ,OAAA,OAKpC;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CACnC,IAAI,EAVM,MAUN,EACJ,IAAI,EAVM,MAUN,EACJ,OAAO,EAVG,WAUH,EACP,KAAK,GAVK,UAUO,EACjB,eAAe,GAVJ,OAAO,OAUK,EACvB,KAAK,GAVK,UAUO,EACjB,IAAI,GAVM,UAUM,OAsBhB;AAED;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAAE,YAAY,KAAA,OAKhD;AAED;;;;;;;;;GASG;AACH,wBAAgB,0CAA0C,CACzD,qBAAqB,EALX,MAKW,OAMrB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,0CAA0C,CACzD,UAAU,EANA,MAMA,EACV,YAA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H;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,mBAAmB,uBAHpB,CAAC,SAAS,KAAQ,iBAuC5B,CAAC;AAEH;;;;;;;GAOG;AACH,eAAO,MAAM,sBAAsB,SALxB,MAAM,QACN,MAAM,2BAEN,eAAO;;;;kBAyBhB,CAAC;AAEH;;;;;;;;GAQG;AACH,eAAO,MAAM,sCAAsC,SANxC,MAAM,QACN,MAAM,YACN,MAAM,GAAC,MAAM;;;;kBA8CtB,CAAC;AAEH;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,CAAE,oBAAoB,EAJnD,OAImD,OAO7D;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,CAAE,GAAG,EAL/B,MAK+B,EAAE,SAAS,EAJ1C,OAI0C,OAMpD;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,sBAAsB,CAAE,WAAW,yBAAA,OAKlD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAE,MAAM,EAL7B,MAK6B,EAAE,SAAS,EAJxC,WAIwC,OAMlD;AAED;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CAAE,UAAU,EAH5C,OAG4C,OAKtD;AAED;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAE,KAAK,KAAA,EAAE,UAAU,EAJhD,MAIgD,OAM1D;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,gBAAgB,SARlB,MAAM,QACN,MAAM,aACN,MAAM,GAAC,MAAM,WACb,WAAY,SACZ,UAAO,mBACN,OAAO,2BACR,UAAO;;;mBAuBhB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity-record-item.d.ts","sourceRoot":"","sources":["../../../src/components/entities-saved-states/entity-record-item.js"],"names":[],"mappings":"AAcA,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAE,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE;;;;CAAA,+BA6CtE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity-type-list.d.ts","sourceRoot":"","sources":["../../../src/components/entities-saved-states/entity-type-list.js"],"names":[],"mappings":"AA2EA,MAAM,CAAC,OAAO,UAAU,cAAc,CAAE,EACvC,IAAI,EACJ,kBAAkB,EAClB,qBAAqB,GACrB;;;;CAAA,+BAkDA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom hook that determines if any entities are dirty (edited) and provides a way to manage selected/unselected entities.
|
|
3
|
+
*
|
|
4
|
+
* @return {Object} An object containing the following properties:
|
|
5
|
+
* - dirtyEntityRecords: An array of dirty entity records.
|
|
6
|
+
* - isDirty: A boolean indicating if there are any dirty entity records.
|
|
7
|
+
* - setUnselectedEntities: A function to set the unselected entities.
|
|
8
|
+
* - unselectedEntities: An array of unselected entities.
|
|
9
|
+
*/
|
|
10
|
+
export declare const useIsDirty: () => any;
|
|
11
|
+
//# sourceMappingURL=use-is-dirty.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-is-dirty.d.ts","sourceRoot":"","sources":["../../../../src/components/entities-saved-states/hooks/use-is-dirty.js"],"names":[],"mappings":"AAWA;;;;;;;;GAQG;AACH,eAAO,MAAM,UAAU,WAgFtB,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Renders the component for managing saved states of entities.
|
|
3
|
+
*
|
|
4
|
+
* @param {Object} props The component props.
|
|
5
|
+
* @param {Function} props.close The function to close the dialog.
|
|
6
|
+
* @param {boolean=} props.renderDialog Whether to render the component with modal dialog behavior.
|
|
7
|
+
* @param {string} props.variant Changes the layout of the component. When an `inline` value is provided, the action buttons are rendered at the end of the component instead of at the start.
|
|
8
|
+
*
|
|
9
|
+
* @return {React.ReactNode} The rendered component.
|
|
10
|
+
*/
|
|
11
|
+
export default function EntitiesSavedStates({ close, renderDialog, variant, }: {
|
|
12
|
+
close: Function;
|
|
13
|
+
renderDialog?: boolean | undefined;
|
|
14
|
+
variant: string;
|
|
15
|
+
}): React.ReactNode;
|
|
16
|
+
/**
|
|
17
|
+
* Renders a panel for saving entities with dirty records.
|
|
18
|
+
*
|
|
19
|
+
* @param {Object} props The component props.
|
|
20
|
+
* @param {string} props.additionalPrompt Additional prompt to display.
|
|
21
|
+
* @param {Function} props.close Function to close the panel.
|
|
22
|
+
* @param {Function} props.onSave Function to call when saving entities.
|
|
23
|
+
* @param {boolean} props.saveEnabled Flag indicating if save is enabled.
|
|
24
|
+
* @param {string} props.saveLabel Label for the save button.
|
|
25
|
+
* @param {boolean} props.renderDialog Whether to render the component with modal dialog behavior.
|
|
26
|
+
* @param {Array} props.dirtyEntityRecords Array of dirty entity records.
|
|
27
|
+
* @param {boolean} props.isDirty Flag indicating if there are dirty entities.
|
|
28
|
+
* @param {Function} props.setUnselectedEntities Function to set unselected entities.
|
|
29
|
+
* @param {Array} props.unselectedEntities Array of unselected entities.
|
|
30
|
+
* @param {string} props.variant Changes the layout of the component. When an `inline` value is provided, the action buttons are rendered at the end of the component instead of at the start.
|
|
31
|
+
* @param {string} props.successNoticeContent Optional custom success notice content.
|
|
32
|
+
*
|
|
33
|
+
* @return {React.ReactNode} The rendered component.
|
|
34
|
+
*/
|
|
35
|
+
export declare function EntitiesSavedStatesExtensible({ additionalPrompt, close, onSave, saveEnabled: saveEnabledProp, saveLabel, renderDialog, dirtyEntityRecords, isDirty, setUnselectedEntities, unselectedEntities, variant, successNoticeContent, }: {
|
|
36
|
+
additionalPrompt: string;
|
|
37
|
+
close: Function;
|
|
38
|
+
onSave: Function;
|
|
39
|
+
saveEnabled: boolean;
|
|
40
|
+
saveLabel: string;
|
|
41
|
+
renderDialog: boolean;
|
|
42
|
+
dirtyEntityRecords: any[];
|
|
43
|
+
isDirty: boolean;
|
|
44
|
+
setUnselectedEntities: Function;
|
|
45
|
+
unselectedEntities: any[];
|
|
46
|
+
variant: string;
|
|
47
|
+
successNoticeContent: string;
|
|
48
|
+
}): React.ReactNode;
|
|
49
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/entities-saved-states/index.js"],"names":[],"mappings":"AA6BA;;;;;;;;;GASG;AACH,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAE,EAC5C,KAAK,EACL,YAAY,EACZ,OAAO,GACP,EAVE;IAAwB,KAAK,WAC7B;IAAwB,YAAY,AAApC,CACA,EADQ,OAAO,YAAC,CAChB;IAAwB,OAAO,EAAvB,MAAM,CAEd;CAMF,GANW,KAAK,CAAC,SAAS,CAgB1B;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,6BAA6B,CAAE,EAC9C,gBAA4B,EAC5B,KAAK,EACL,MAAkB,EAClB,WAAW,EAAE,eAA2B,EACxC,SAAwB,EACxB,YAAY,EACZ,kBAAkB,EAClB,OAAO,EACP,qBAAqB,EACrB,kBAAkB,EAClB,OAAmB,EACnB,oBAAoB,GACpB,EA5BE;IAAwB,gBAAgB,EAAhC,MAAM,CACd;IAAwB,KAAK,WAC7B;IAAwB,MAAM,WAC9B;IAAwB,WAAW,EAA3B,OAAO,CACf;IAAwB,SAAS,EAAzB,MAAM,CACd;IAAwB,YAAY,EAA5B,OAAO,CACf;IAAwB,kBAAkB,QAC1C;IAAwB,OAAO,EAAvB,OAAO,CACf;IAAwB,qBAAqB,WAC7C;IAAwB,kBAAkB,QAC1C;IAAwB,OAAO,EAAvB,MAAM,CACd;IAAwB,oBAAoB,EAApC,MAAM,CAEd;CAeF,GAfW,KAAK,CAAC,SAAS,CAyK1B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entities.d.ts","sourceRoot":"","sources":["../src/entities.js"],"names":[],"mappings":"AAyBA,eAAO,MAAM,kBAAkB,OAAO,CAAC;AAYvC,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"entities.d.ts","sourceRoot":"","sources":["../src/entities.js"],"names":[],"mappings":"AAyBA,eAAO,MAAM,kBAAkB,OAAO,CAAC;AAYvC,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAsEX,MAAM;;;;;;;;;;;;;;;;;;;QAUN,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAgJzB,CAAC;AAEF,eAAO,MAAM,kBAAkB;IAC9B,IAAI;QACH,KAAK;YACJ,KAAK;YACL,WAAW;gBACV,IAAI;gBACJ,IAAI;;;;CAIP,CAAC;AAEF,eAAO,MAAM,6BAA6B;;;;;;;;;;IASzC,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,2CAJpB,MAAM,cACN,OAAO,KACN,OAAO,KAgDlB,CAAC;AAEF;;;;GAIG;AACH,iBAAe,oBAAoB,iBA2IlC;AA6BD;;;;GAIG;AACH,iBAAe,cAAc,iBA2B5B;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,aAAa,SANf,MAAM,QACN,MAAM,WACN,MAAM,KAEL,MAMX,CAAC"}
|
|
@@ -114,4 +114,23 @@ export declare function __unstableNotifySyncUndoManagerChange(state: {
|
|
|
114
114
|
* @return {Object} Action object.
|
|
115
115
|
*/
|
|
116
116
|
export declare function setSyncConnectionStatus(kind: string, name: string, key: number | string | null, status: any | null): any;
|
|
117
|
+
/**
|
|
118
|
+
* Save entity records marked as dirty.
|
|
119
|
+
*
|
|
120
|
+
* @param {Object} options Options for the action.
|
|
121
|
+
* @param {Function} [options.onSave] Callback when saving happens.
|
|
122
|
+
* @param {object[]} [options.dirtyEntityRecords] Array of dirty entities.
|
|
123
|
+
* @param {object[]} [options.entitiesToSkip] Array of entities to skip saving.
|
|
124
|
+
* @param {Function} [options.close] Callback when the actions is called. It should be consolidated with `onSave`.
|
|
125
|
+
* @param {string} [options.successNoticeContent] Optional custom success notice content. Defaults to 'Site updated.'.
|
|
126
|
+
*/
|
|
127
|
+
export declare const saveDirtyEntities: ({ onSave, dirtyEntityRecords, entitiesToSkip, close, successNoticeContent, }?: {
|
|
128
|
+
onSave?: Function;
|
|
129
|
+
dirtyEntityRecords?: object[];
|
|
130
|
+
entitiesToSkip?: object[];
|
|
131
|
+
close?: Function;
|
|
132
|
+
successNoticeContent?: string;
|
|
133
|
+
}) => ({ registry }: {
|
|
134
|
+
registry: any;
|
|
135
|
+
}) => void;
|
|
117
136
|
//# sourceMappingURL=private-actions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"private-actions.d.ts","sourceRoot":"","sources":["../src/private-actions.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"private-actions.d.ts","sourceRoot":"","sources":["../src/private-actions.js"],"names":[],"mappings":"AAcA;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,CAAE,QAAQ,EALxC,MAKwC,EAAE,kBAAkB,KAAA,OAMtE;AAGE,YAAkB,QAAQ,GAC1B;;;;IAAoB,IAAI,AAAxB,CACA,EADW,MAAM,CACjB;;;;IAAoB,IAAI,AAAxB,CACF,MAAA;CAAA,CAAA;AAGE,YAAkB,KAAK,GACvB;;;;IAAwB,GAAG,AAA3B,CACA,EADW,MAAM,CACjB;;;;IAAwB,SAAS,AAAjC,CACF,EADa,QAA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5
|
import { useActiveCollaborators, useResolvedSelection, useOnCollaboratorJoin, useOnCollaboratorLeave, useOnPostSave } from './hooks/use-post-editor-awareness-state';
|
|
6
|
+
import { getTemplateInfo } from './utils/get-template-info';
|
|
7
|
+
import { getTemplatePartIcon } from './utils/get-template-part-icon';
|
|
8
|
+
import { EntitiesSavedStatesExtensible, default as EntitiesSavedStates } from './components/entities-saved-states';
|
|
9
|
+
import { useIsDirty as useEntitiesSavedStatesIsDirty } from './components/entities-saved-states/hooks/use-is-dirty';
|
|
6
10
|
import { SelectionType, SelectionDirection } from './utils/crdt-user-selections';
|
|
7
11
|
declare const lockedApis: {
|
|
12
|
+
EntitiesSavedStates: typeof EntitiesSavedStates;
|
|
13
|
+
EntitiesSavedStatesExtensible: typeof EntitiesSavedStatesExtensible;
|
|
14
|
+
getTemplateInfo: typeof getTemplateInfo;
|
|
15
|
+
getTemplatePartIcon: typeof getTemplatePartIcon;
|
|
16
|
+
useEntitiesSavedStatesIsDirty: typeof useEntitiesSavedStatesIsDirty;
|
|
8
17
|
useEntityRecordsWithPermissions: typeof useEntityRecordsWithPermissions;
|
|
9
18
|
RECEIVE_INTERMEDIATE_RESULTS: symbol;
|
|
10
19
|
retrySyncConnection: any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"private-apis.d.ts","sourceRoot":"","sources":["../src/private-apis.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,+BAA+B,EAAE,MAAM,4BAA4B,CAAC;AAE7E,OAAO,EACN,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EACrB,sBAAsB,EACtB,aAAa,EACb,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"private-apis.d.ts","sourceRoot":"","sources":["../src/private-apis.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,+BAA+B,EAAE,MAAM,4BAA4B,CAAC;AAE7E,OAAO,EACN,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EACrB,sBAAsB,EACtB,aAAa,EACb,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,EACN,6BAA6B,EAC7B,OAAO,IAAI,mBAAmB,EAC9B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,UAAU,IAAI,6BAA6B,EAAE,MAAM,uDAAuD,CAAC;AAGpH,OAAO,EACN,aAAa,EACb,kBAAkB,EAClB,MAAM,8BAA8B,CAAC;AAEtC,QAAA,MAAM,UAAU;;;;;;;;;;;;;;;;CAgBf,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,OAAO,UAAU,CAAC;AAEpD,eAAO,MAAM,WAAW,IAAK,CAAC"}
|
|
@@ -66,5 +66,13 @@ export declare const defaultSyncConfig: SyncConfig;
|
|
|
66
66
|
* when changes are detected.
|
|
67
67
|
*/
|
|
68
68
|
export declare const defaultCollectionSyncConfig: SyncConfig;
|
|
69
|
+
/**
|
|
70
|
+
* Extract the raw string value from a property that may be a string or an object
|
|
71
|
+
* with a `raw` property (`RenderedText`).
|
|
72
|
+
*
|
|
73
|
+
* @param {unknown} value The value to extract from.
|
|
74
|
+
* @return {string|undefined} The raw string value, or undefined if it could not be determined.
|
|
75
|
+
*/
|
|
76
|
+
export declare function getRawValue(value?: unknown): string | undefined;
|
|
69
77
|
export {};
|
|
70
78
|
//# sourceMappingURL=crdt.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crdt.d.ts","sourceRoot":"","sources":["../../src/utils/crdt.ts"],"names":[],"mappings":"AAaA,OAAO,EACN,KAAK,OAAO,EAIZ,KAAK,UAAU,EACf,CAAC,EACD,MAAM,iBAAiB,CAAC;AAMzB,OAAO,EACN,KAAK,KAAK,EAMV,KAAK,OAAO,EACZ,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,KAAK,IAAI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I/B,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,EAAE,UAKzC,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAE,KAAK,CAAC,EAAE,OAAO,GAAI,MAAM,GAAG,SAAS,CAgBjE"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper function to retrieve the corresponding template info for a given template.
|
|
3
|
+
* @param {Object} params
|
|
4
|
+
* @param {Array} params.templateTypes
|
|
5
|
+
* @param {Array} [params.templateAreas]
|
|
6
|
+
* @param {Object} params.template
|
|
7
|
+
*/
|
|
8
|
+
export declare const getTemplateInfo: (params: {
|
|
9
|
+
templateTypes: any[];
|
|
10
|
+
templateAreas?: any[];
|
|
11
|
+
template: any;
|
|
12
|
+
}) => {};
|
|
13
|
+
//# sourceMappingURL=get-template-info.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-template-info.d.ts","sourceRoot":"","sources":["../../src/utils/get-template-info.js"],"names":[],"mappings":"AAUA;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,WAJzB;IAAuB,aAAa,QACpC;IAAwB,aAAa,AAArC,CACA,QAAA;IAAuB,QAAQ,MACjC;CAAA,OAmCA,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper function to retrieve the corresponding icon by area name.
|
|
3
|
+
*
|
|
4
|
+
* @param {string} areaOrIconName The area name (e.g., 'header', 'navigation-overlay').
|
|
5
|
+
*
|
|
6
|
+
* @return {Object} The corresponding icon.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getTemplatePartIcon(areaOrIconName: string): any;
|
|
9
|
+
//# sourceMappingURL=get-template-part-icon.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-template-part-icon.d.ts","sourceRoot":"","sources":["../../src/utils/get-template-part-icon.js"],"names":[],"mappings":"AAWA;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAE,cAAc,EAJxC,MAIwC,OAWlD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"on-sub-key.d.ts","sourceRoot":"","sources":["../../src/utils/on-sub-key.js"],"names":[],"mappings":"AAUO,yCAJI,MAAM,GAEL,WAAW,CAwBrB;;0BAhCY,OAAO,UAAU,EAAE,WAAW"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/core-data",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.52.0",
|
|
4
4
|
"description": "Access to and manipulation of core WordPress entities.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -48,35 +48,40 @@
|
|
|
48
48
|
"build-module/index.mjs"
|
|
49
49
|
],
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@wordpress/api-fetch": "^7.
|
|
52
|
-
"@wordpress/block-editor": "^16.
|
|
53
|
-
"@wordpress/blocks": "^15.
|
|
54
|
-
"@wordpress/
|
|
55
|
-
"@wordpress/
|
|
56
|
-
"@wordpress/
|
|
57
|
-
"@wordpress/
|
|
58
|
-
"@wordpress/
|
|
59
|
-
"@wordpress/
|
|
60
|
-
"@wordpress/
|
|
61
|
-
"@wordpress/
|
|
62
|
-
"@wordpress/
|
|
63
|
-
"@wordpress/
|
|
64
|
-
"@wordpress/
|
|
65
|
-
"@wordpress/
|
|
66
|
-
"@wordpress/
|
|
51
|
+
"@wordpress/api-fetch": "^7.52.0",
|
|
52
|
+
"@wordpress/block-editor": "^16.1.0",
|
|
53
|
+
"@wordpress/blocks": "^15.25.0",
|
|
54
|
+
"@wordpress/components": "^38.0.0",
|
|
55
|
+
"@wordpress/compose": "^8.5.0",
|
|
56
|
+
"@wordpress/data": "^10.52.0",
|
|
57
|
+
"@wordpress/deprecated": "^4.52.0",
|
|
58
|
+
"@wordpress/element": "^8.4.0",
|
|
59
|
+
"@wordpress/global-styles-engine": "^1.19.0",
|
|
60
|
+
"@wordpress/html-entities": "^4.52.0",
|
|
61
|
+
"@wordpress/i18n": "^6.25.0",
|
|
62
|
+
"@wordpress/icons": "^15.3.0",
|
|
63
|
+
"@wordpress/is-shallow-equal": "^5.52.0",
|
|
64
|
+
"@wordpress/notices": "^5.52.0",
|
|
65
|
+
"@wordpress/private-apis": "^1.52.0",
|
|
66
|
+
"@wordpress/rich-text": "^7.52.0",
|
|
67
|
+
"@wordpress/sync": "^1.52.0",
|
|
68
|
+
"@wordpress/undo-manager": "^1.52.0",
|
|
69
|
+
"@wordpress/url": "^4.52.0",
|
|
70
|
+
"@wordpress/warning": "^3.52.0",
|
|
67
71
|
"change-case": "^4.1.2",
|
|
72
|
+
"clsx": "^2.1.1",
|
|
68
73
|
"equivalent-key-map": "^0.2.2",
|
|
69
74
|
"fast-deep-equal": "^3.1.3",
|
|
70
|
-
"memize": "^2.1.
|
|
75
|
+
"memize": "^2.1.1",
|
|
71
76
|
"uuid": "^14.0.0"
|
|
72
77
|
},
|
|
73
78
|
"devDependencies": {
|
|
74
|
-
"@jest/globals": "^30.
|
|
79
|
+
"@jest/globals": "^30.4.1",
|
|
75
80
|
"@testing-library/dom": "^10.4.1",
|
|
76
81
|
"@testing-library/react": "^16.3.2",
|
|
77
|
-
"@types/jest": "^
|
|
82
|
+
"@types/jest": "^30.0.0",
|
|
78
83
|
"@types/node": "^20.19.39",
|
|
79
|
-
"@wordpress/block-library": "^10.
|
|
84
|
+
"@wordpress/block-library": "^10.3.0",
|
|
80
85
|
"deep-freeze": "^0.0.1"
|
|
81
86
|
},
|
|
82
87
|
"peerDependencies": {
|
|
@@ -92,5 +97,5 @@
|
|
|
92
97
|
"publishConfig": {
|
|
93
98
|
"access": "public"
|
|
94
99
|
},
|
|
95
|
-
"gitHead": "
|
|
100
|
+
"gitHead": "7e8b17a983f9391d3ebc7717af2a1c9ed7efc7ab"
|
|
96
101
|
}
|