@wordpress/editor
Version:
Enhanced block editor for WordPress posts.
8 lines (7 loc) • 3.19 kB
Source Map (JSON)
{
"version": 3,
"sources": ["../../src/utils/sync-error-messages.ts"],
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { type ConnectionError } from '@wordpress/core-data';\nimport { __ } from '@wordpress/i18n';\n\n// These error codes are defined in the sync package:\n// packages/sync/src/errors.ts\nexport const AUTHENTICATION_FAILED = 'authentication-failed';\nexport const CONNECTION_EXPIRED = 'connection-expired';\nexport const CONNECTION_LIMIT_EXCEEDED = 'connection-limit-exceeded';\nexport const DOCUMENT_SIZE_LIMIT_EXCEEDED = 'document-size-limit-exceeded';\nexport const UNKNOWN_ERROR = 'unknown-error';\n\ninterface ConnectionErrorMessages {\n\tdescription: string;\n\ttitle: string;\n}\n\n/**\n * Default error messages for known error codes.\n */\nconst ERROR_MESSAGES: Record< string, ConnectionErrorMessages > = {\n\t[ AUTHENTICATION_FAILED ]: {\n\t\ttitle: __( 'Unable to connect' ),\n\t\tdescription: __(\n\t\t\t\"Real-time collaboration couldn't verify your permissions. \" +\n\t\t\t\t'Check that you have access to edit this post or contact your site administrator.'\n\t\t),\n\t},\n\t[ CONNECTION_EXPIRED ]: {\n\t\ttitle: __( 'Connection expired' ),\n\t\tdescription: __(\n\t\t\t'Your connection to real-time collaboration has timed out. ' +\n\t\t\t\t'Editing is paused to prevent conflicts with other editors.'\n\t\t),\n\t},\n\t[ CONNECTION_LIMIT_EXCEEDED ]: {\n\t\ttitle: __( 'Too many editors connected' ),\n\t\tdescription: __(\n\t\t\t'Real-time collaboration has reached its connection limit. ' +\n\t\t\t\t'Try again later or contact your site administrator.'\n\t\t),\n\t},\n\t// DOCUMENT_SIZE_LIMIT_EXCEEDED is not included here because it results in\n\t// collaboration being disabled entirely.\n\t[ UNKNOWN_ERROR ]: {\n\t\ttitle: __( 'Connection lost' ),\n\t\tdescription: __(\n\t\t\t'The connection to real-time collaboration was interrupted. ' +\n\t\t\t\t'Editing is paused to prevent conflicts with other editors.'\n\t\t),\n\t},\n};\n\n/**\n * Get user-facing title and description from a sync connection error.\n *\n * Provides default messages based on error.code.\n *\n * @param error - Connection error.\n * @return Object with title, description, and canRetry flag.\n */\nexport function getSyncErrorMessages(\n\terror?: ConnectionError\n): ConnectionErrorMessages {\n\tif ( error?.code && ERROR_MESSAGES[ error?.code ] ) {\n\t\treturn ERROR_MESSAGES[ error.code ];\n\t}\n\n\treturn ERROR_MESSAGES[ UNKNOWN_ERROR ];\n}\n"],
"mappings": ";AAIA,SAAS,UAAU;AAIZ,IAAM,wBAAwB;AAC9B,IAAM,qBAAqB;AAC3B,IAAM,4BAA4B;AAClC,IAAM,+BAA+B;AACrC,IAAM,gBAAgB;AAU7B,IAAM,iBAA4D;AAAA,EACjE,CAAE,qBAAsB,GAAG;AAAA,IAC1B,OAAO,GAAI,mBAAoB;AAAA,IAC/B,aAAa;AAAA,MACZ;AAAA,IAED;AAAA,EACD;AAAA,EACA,CAAE,kBAAmB,GAAG;AAAA,IACvB,OAAO,GAAI,oBAAqB;AAAA,IAChC,aAAa;AAAA,MACZ;AAAA,IAED;AAAA,EACD;AAAA,EACA,CAAE,yBAA0B,GAAG;AAAA,IAC9B,OAAO,GAAI,4BAA6B;AAAA,IACxC,aAAa;AAAA,MACZ;AAAA,IAED;AAAA,EACD;AAAA;AAAA;AAAA,EAGA,CAAE,aAAc,GAAG;AAAA,IAClB,OAAO,GAAI,iBAAkB;AAAA,IAC7B,aAAa;AAAA,MACZ;AAAA,IAED;AAAA,EACD;AACD;AAUO,SAAS,qBACf,OAC0B;AAC1B,MAAK,OAAO,QAAQ,eAAgB,OAAO,IAAK,GAAI;AACnD,WAAO,eAAgB,MAAM,IAAK;AAAA,EACnC;AAEA,SAAO,eAAgB,aAAc;AACtC;",
"names": []
}