{
  "version": 3,
  "sources": ["../src/types.ts"],
  "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport type { UndoManager as WPUndoManager } from '@wordpress/undo-manager';\n\n/**\n * External dependencies\n */\nimport type * as Y from 'yjs';\nimport type { Awareness } from 'y-protocols/awareness';\n\n/**\n * Internal dependencies\n */\nimport type { ConnectionError } from './errors';\n\n/* globalThis */\ndeclare global {\n\tinterface Window {\n\t\t_wpCollaborationEnabled?: string;\n\t}\n}\n\nexport type CRDTDoc = Y.Doc;\nexport type AwarenessID = string;\nexport type EntityID = string;\nexport type ObjectID = string;\nexport type ObjectType = string;\n\n// An origin is a value passed by the transactor to identify the source of a\n// change. It can be any value, and is not used internally by Yjs. Origins are\n// preserved locally, while a remote change will have the provider instance as\n// its origin.\nexport type Origin = any;\n\n// Object data represents any entity record. There are not any expectations that\n// can hold on its shape, beyond a record with string keys and unknown values.\nexport type ObjectData = Record< string, unknown >;\n\n/**\n * Event map for provider events.\n * Add new event types here as needed.\n */\nexport interface ProviderEventMap {\n\tstatus: ConnectionStatus;\n}\n\n/**\n * Generic event listener type for providers.\n * Providers should call registered callbacks when events occur like connection status changes.\n * Providers are responsible for cleaning up listeners in their destroy() method.\n */\nexport type ProviderOn = < K extends keyof ProviderEventMap >(\n\tevent: K,\n\tcallback: ( data: ProviderEventMap[ K ] ) => void\n) => void;\n\nexport interface ProviderCreatorResult {\n\tdestroy: () => void;\n\ton: ProviderOn;\n}\n\n/**\n * Current connection status of a sync provider.\n */\nexport interface ConnectionStatusConnected {\n\tstatus: 'connected';\n}\n\nexport interface ConnectionStatusConnecting {\n\tstatus: 'connecting';\n}\n\nexport interface ConnectionStatusDisconnected {\n\tstatus: 'disconnected';\n\n\t/** Optional error information. */\n\terror?: ConnectionError;\n\n\t/** Whether the error condition is retryable via user action. */\n\tcanManuallyRetry?: boolean;\n\n\t/** Number of consecutive poll failures since the last successful connection. */\n\tconsecutiveFailures?: number;\n\n\t/** Whether the background retry schedule has been exhausted without a successful connection. */\n\tbackgroundRetriesFailed?: boolean;\n\n\t/** Milliseconds until the next automatic retry attempt (triggered by the provider). */\n\twillAutoRetryInMs?: number;\n}\n\nexport type ConnectionStatus =\n\t| ConnectionStatusConnected\n\t| ConnectionStatusConnecting\n\t| ConnectionStatusDisconnected;\n\nexport type OnStatusChangeCallback = (\n\tstatus: ConnectionStatus | null\n) => void;\n\n/**\n * Options passed to a provider creator function when initializing a sync provider.\n */\nexport interface ProviderCreatorOptions {\n\tobjectType: ObjectType;\n\tobjectId: ObjectID | null;\n\tydoc: Y.Doc;\n\tawareness?: Awareness;\n}\n\nexport type ProviderCreator = (\n\toptions: ProviderCreatorOptions\n) => Promise< ProviderCreatorResult >;\n\nexport interface CollectionHandlers {\n\tonStatusChange: OnStatusChangeCallback;\n\trefetchRecords: () => Promise< void >;\n}\n\nexport interface SyncManagerUpdateOptions {\n\tisSave?: boolean;\n\tisNewUndoLevel?: boolean;\n}\n\nexport interface RecordHandlers {\n\taddUndoMeta: ( ydoc: Y.Doc, meta: Map< string, any > ) => void;\n\teditRecord: (\n\t\tdata: Partial< ObjectData >,\n\t\toptions?: { undoIgnore?: boolean }\n\t) => void;\n\tgetEditedRecord: () => Promise< ObjectData >;\n\tonStatusChange: OnStatusChangeCallback;\n\tpersistCRDTDoc: () => void;\n\trefetchRecord: () => Promise< void >;\n\trestoreUndoMeta: ( ydoc: Y.Doc, meta: Map< string, any > ) => void;\n}\n\nexport interface SyncConfig {\n\tapplyChangesToCRDTDoc: (\n\t\tydoc: Y.Doc,\n\t\tchanges: Partial< ObjectData >\n\t) => void;\n\tcreateAwareness?: (\n\t\tydoc: Y.Doc,\n\t\tobjectId?: ObjectID\n\t) => Awareness | undefined;\n\tgetChangesFromCRDTDoc: (\n\t\tydoc: Y.Doc,\n\t\teditedRecord: ObjectData\n\t) => ObjectData;\n\tgetPersistedCRDTDoc?: ( record: ObjectData ) => string | null;\n\tshouldSync?: (\n\t\tobjectType: ObjectType,\n\t\tobjectId: ObjectID | null\n\t) => boolean;\n}\n\nexport interface SyncManager {\n\tcreatePersistedCRDTDoc: (\n\t\tobjectType: ObjectType,\n\t\tobjectId: ObjectID\n\t) => Promise< string | null >;\n\tgetAwareness: < State extends Awareness >(\n\t\tobjectType: ObjectType,\n\t\tobjectId: ObjectID\n\t) => State | undefined;\n\tload: (\n\t\tsyncConfig: SyncConfig,\n\t\tobjectType: ObjectType,\n\t\tobjectId: ObjectID,\n\t\trecord: ObjectData,\n\t\thandlers: RecordHandlers\n\t) => Promise< void >;\n\tloadCollection: (\n\t\tsyncConfig: SyncConfig,\n\t\tobjectType: ObjectType,\n\t\thandlers: CollectionHandlers\n\t) => Promise< void >;\n\t// undoManager is undefined until the first entity is loaded.\n\tundoManager: SyncUndoManager | undefined;\n\tunload: ( objectType: ObjectType, objectId: ObjectID ) => void;\n\tupdate: (\n\t\tobjectType: ObjectType,\n\t\tobjectId: ObjectID | null,\n\t\tchanges: Partial< ObjectData >,\n\t\torigin: string,\n\t\toptions?: SyncManagerUpdateOptions\n\t) => void;\n}\n\nexport interface SyncUndoManager extends WPUndoManager< ObjectData > {\n\taddToScope: (\n\t\tymap: Y.Map< any >,\n\t\thandlers: Pick< RecordHandlers, 'addUndoMeta' | 'restoreUndoMeta' >\n\t) => void;\n\tstopCapturing: () => void;\n}\n"],
  "mappings": ";;;;;;;;;;;;;;;;AAAA;AAAA;",
  "names": []
}
