@voidhash/mimic 0.0.2 → 0.0.4
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/.turbo/turbo-build.log +257 -42
- package/dist/Document.cjs +152 -0
- package/dist/Document.d.cts +67 -0
- package/dist/Document.d.cts.map +1 -0
- package/dist/Document.d.mts +68 -0
- package/dist/Document.d.mts.map +1 -0
- package/dist/Document.mjs +147 -0
- package/dist/Document.mjs.map +1 -0
- package/dist/EffectSchema.cjs +180 -0
- package/dist/EffectSchema.d.cts +84 -0
- package/dist/EffectSchema.d.cts.map +1 -0
- package/dist/EffectSchema.d.mts +84 -0
- package/dist/EffectSchema.d.mts.map +1 -0
- package/dist/EffectSchema.mjs +176 -0
- package/dist/EffectSchema.mjs.map +1 -0
- package/dist/FractionalIndex.cjs +365 -0
- package/dist/FractionalIndex.mjs +364 -0
- package/dist/FractionalIndex.mjs.map +1 -0
- package/dist/Operation.cjs +53 -0
- package/dist/Operation.d.cts +39 -0
- package/dist/Operation.d.cts.map +1 -0
- package/dist/Operation.d.mts +39 -0
- package/dist/Operation.d.mts.map +1 -0
- package/dist/Operation.mjs +46 -0
- package/dist/Operation.mjs.map +1 -0
- package/dist/OperationDefinition.cjs +13 -0
- package/dist/OperationDefinition.d.cts +12 -0
- package/dist/OperationDefinition.d.cts.map +1 -0
- package/dist/OperationDefinition.d.mts +12 -0
- package/dist/OperationDefinition.d.mts.map +1 -0
- package/dist/OperationDefinition.mjs +13 -0
- package/dist/OperationDefinition.mjs.map +1 -0
- package/dist/OperationPath.cjs +148 -0
- package/dist/OperationPath.d.cts +60 -0
- package/dist/OperationPath.d.cts.map +1 -0
- package/dist/OperationPath.d.mts +60 -0
- package/dist/OperationPath.d.mts.map +1 -0
- package/dist/OperationPath.mjs +138 -0
- package/dist/OperationPath.mjs.map +1 -0
- package/dist/{Presence-gWrmGBeu.cjs → Presence.cjs} +4 -39
- package/dist/{Presence-N8u7Eppr.d.mts → Presence.d.cts} +2 -2
- package/dist/Presence.d.cts.map +1 -0
- package/dist/{Presence-DKKP4v5X.d.cts → Presence.d.mts} +2 -2
- package/dist/Presence.d.mts.map +1 -0
- package/dist/{Presence-DdMVKcOv.mjs → Presence.mjs} +3 -28
- package/dist/Presence.mjs.map +1 -0
- package/dist/Primitive.cjs +52 -0
- package/dist/Primitive.d.cts +20 -0
- package/dist/Primitive.d.cts.map +1 -0
- package/dist/Primitive.d.mts +20 -0
- package/dist/Primitive.d.mts.map +1 -0
- package/dist/Primitive.mjs +48 -0
- package/dist/Primitive.mjs.map +1 -0
- package/dist/ProxyEnvironment.cjs +34 -0
- package/dist/ProxyEnvironment.d.cts +31 -0
- package/dist/ProxyEnvironment.d.cts.map +1 -0
- package/dist/ProxyEnvironment.d.mts +31 -0
- package/dist/ProxyEnvironment.d.mts.map +1 -0
- package/dist/ProxyEnvironment.mjs +29 -0
- package/dist/ProxyEnvironment.mjs.map +1 -0
- package/dist/Transaction.cjs +66 -0
- package/dist/Transaction.d.cts +56 -0
- package/dist/Transaction.d.cts.map +1 -0
- package/dist/Transaction.d.mts +56 -0
- package/dist/Transaction.d.mts.map +1 -0
- package/dist/Transaction.mjs +58 -0
- package/dist/Transaction.mjs.map +1 -0
- package/dist/Transform.cjs +11 -0
- package/dist/Transform.d.cts +21 -0
- package/dist/Transform.d.cts.map +1 -0
- package/dist/Transform.d.mts +21 -0
- package/dist/Transform.d.mts.map +1 -0
- package/dist/Transform.mjs +6 -0
- package/dist/Transform.mjs.map +1 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/defineProperty.cjs +14 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/defineProperty.mjs +14 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/objectSpread2.cjs +27 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/objectSpread2.mjs +27 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/toPrimitive.cjs +16 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/toPrimitive.mjs +16 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/toPropertyKey.cjs +11 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/toPropertyKey.mjs +11 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/typeof.cjs +18 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/typeof.mjs +12 -0
- package/dist/_virtual/rolldown_runtime.cjs +43 -0
- package/dist/{chunk-CLMFDpHK.mjs → _virtual/rolldown_runtime.mjs} +1 -1
- package/dist/client/ClientDocument.cjs +590 -0
- package/dist/client/ClientDocument.d.cts +161 -0
- package/dist/client/ClientDocument.d.cts.map +1 -0
- package/dist/client/ClientDocument.d.mts +162 -0
- package/dist/client/ClientDocument.d.mts.map +1 -0
- package/dist/client/ClientDocument.mjs +586 -0
- package/dist/client/ClientDocument.mjs.map +1 -0
- package/dist/client/Rebase.cjs +204 -0
- package/dist/client/Rebase.d.cts +87 -0
- package/dist/client/Rebase.d.cts.map +1 -0
- package/dist/client/Rebase.d.mts +88 -0
- package/dist/client/Rebase.d.mts.map +1 -0
- package/dist/client/Rebase.mjs +198 -0
- package/dist/client/Rebase.mjs.map +1 -0
- package/dist/client/StateMonitor.cjs +133 -0
- package/dist/client/StateMonitor.d.cts +122 -0
- package/dist/client/StateMonitor.d.cts.map +1 -0
- package/dist/client/StateMonitor.d.mts +122 -0
- package/dist/client/StateMonitor.d.mts.map +1 -0
- package/dist/client/StateMonitor.mjs +129 -0
- package/dist/client/StateMonitor.mjs.map +1 -0
- package/dist/client/Transport.cjs +11 -0
- package/dist/client/Transport.d.cts +237 -0
- package/dist/client/Transport.d.cts.map +1 -0
- package/dist/client/Transport.d.mts +237 -0
- package/dist/client/Transport.d.mts.map +1 -0
- package/dist/client/Transport.mjs +6 -0
- package/dist/client/Transport.mjs.map +1 -0
- package/dist/client/WebSocketTransport.cjs +396 -0
- package/dist/client/WebSocketTransport.d.cts +29 -0
- package/dist/client/WebSocketTransport.d.cts.map +1 -0
- package/dist/client/WebSocketTransport.d.mts +29 -0
- package/dist/client/WebSocketTransport.d.mts.map +1 -0
- package/dist/client/WebSocketTransport.mjs +392 -0
- package/dist/client/WebSocketTransport.mjs.map +1 -0
- package/dist/client/errors.cjs +135 -0
- package/dist/client/errors.d.cts +87 -0
- package/dist/client/errors.d.cts.map +1 -0
- package/dist/client/errors.d.mts +87 -0
- package/dist/client/errors.d.mts.map +1 -0
- package/dist/client/errors.mjs +127 -0
- package/dist/client/errors.mjs.map +1 -0
- package/dist/client/index.cjs +22 -1424
- package/dist/client/index.d.cts +8 -692
- package/dist/client/index.d.mts +8 -692
- package/dist/client/index.mjs +9 -1413
- package/dist/index.cjs +20 -2973
- package/dist/index.d.cts +12 -419
- package/dist/index.d.mts +12 -419
- package/dist/index.mjs +13 -2968
- package/dist/primitives/Array.cjs +302 -0
- package/dist/primitives/Array.d.cts +95 -0
- package/dist/primitives/Array.d.cts.map +1 -0
- package/dist/primitives/Array.d.mts +95 -0
- package/dist/primitives/Array.d.mts.map +1 -0
- package/dist/primitives/Array.mjs +301 -0
- package/dist/primitives/Array.mjs.map +1 -0
- package/dist/primitives/Boolean.cjs +95 -0
- package/dist/primitives/Boolean.d.cts +44 -0
- package/dist/primitives/Boolean.d.cts.map +1 -0
- package/dist/primitives/Boolean.d.mts +44 -0
- package/dist/primitives/Boolean.d.mts.map +1 -0
- package/dist/primitives/Boolean.mjs +94 -0
- package/dist/primitives/Boolean.mjs.map +1 -0
- package/dist/primitives/Either.cjs +200 -0
- package/dist/primitives/Either.d.cts +113 -0
- package/dist/primitives/Either.d.cts.map +1 -0
- package/dist/primitives/Either.d.mts +113 -0
- package/dist/primitives/Either.d.mts.map +1 -0
- package/dist/primitives/Either.mjs +199 -0
- package/dist/primitives/Either.mjs.map +1 -0
- package/dist/primitives/Lazy.cjs +46 -0
- package/dist/primitives/Lazy.d.cts +46 -0
- package/dist/primitives/Lazy.d.cts.map +1 -0
- package/dist/primitives/Lazy.d.mts +46 -0
- package/dist/primitives/Lazy.d.mts.map +1 -0
- package/dist/primitives/Lazy.mjs +46 -0
- package/dist/primitives/Lazy.mjs.map +1 -0
- package/dist/primitives/Literal.cjs +91 -0
- package/dist/primitives/Literal.d.cts +46 -0
- package/dist/primitives/Literal.d.cts.map +1 -0
- package/dist/primitives/Literal.d.mts +46 -0
- package/dist/primitives/Literal.d.mts.map +1 -0
- package/dist/primitives/Literal.mjs +90 -0
- package/dist/primitives/Literal.mjs.map +1 -0
- package/dist/primitives/Number.cjs +115 -0
- package/dist/primitives/Number.d.cts +54 -0
- package/dist/primitives/Number.d.cts.map +1 -0
- package/dist/primitives/Number.d.mts +54 -0
- package/dist/primitives/Number.d.mts.map +1 -0
- package/dist/primitives/Number.mjs +114 -0
- package/dist/primitives/Number.mjs.map +1 -0
- package/dist/primitives/String.cjs +127 -0
- package/dist/primitives/String.d.cts +56 -0
- package/dist/primitives/String.d.cts.map +1 -0
- package/dist/primitives/String.d.mts +56 -0
- package/dist/primitives/String.d.mts.map +1 -0
- package/dist/primitives/String.mjs +126 -0
- package/dist/primitives/String.mjs.map +1 -0
- package/dist/primitives/Struct.cjs +207 -0
- package/dist/primitives/Struct.d.cts +96 -0
- package/dist/primitives/Struct.d.cts.map +1 -0
- package/dist/primitives/Struct.d.mts +97 -0
- package/dist/primitives/Struct.d.mts.map +1 -0
- package/dist/primitives/Struct.mjs +206 -0
- package/dist/primitives/Struct.mjs.map +1 -0
- package/dist/primitives/Tree.cjs +575 -0
- package/dist/primitives/Tree.d.cts +185 -0
- package/dist/primitives/Tree.d.cts.map +1 -0
- package/dist/primitives/Tree.d.mts +185 -0
- package/dist/primitives/Tree.d.mts.map +1 -0
- package/dist/primitives/Tree.mjs +574 -0
- package/dist/primitives/Tree.mjs.map +1 -0
- package/dist/primitives/TreeNode.cjs +73 -0
- package/dist/primitives/TreeNode.d.cts +92 -0
- package/dist/primitives/TreeNode.d.cts.map +1 -0
- package/dist/primitives/TreeNode.d.mts +93 -0
- package/dist/primitives/TreeNode.d.mts.map +1 -0
- package/dist/primitives/TreeNode.mjs +72 -0
- package/dist/primitives/TreeNode.mjs.map +1 -0
- package/dist/primitives/Union.cjs +170 -0
- package/dist/primitives/Union.d.cts +81 -0
- package/dist/primitives/Union.d.cts.map +1 -0
- package/dist/primitives/Union.d.mts +81 -0
- package/dist/primitives/Union.d.mts.map +1 -0
- package/dist/primitives/Union.mjs +169 -0
- package/dist/primitives/Union.mjs.map +1 -0
- package/dist/primitives/shared.cjs +60 -0
- package/dist/primitives/shared.d.cts +147 -0
- package/dist/primitives/shared.d.cts.map +1 -0
- package/dist/primitives/shared.d.mts +147 -0
- package/dist/primitives/shared.d.mts.map +1 -0
- package/dist/primitives/shared.mjs +58 -0
- package/dist/primitives/shared.mjs.map +1 -0
- package/dist/server/ServerDocument.cjs +110 -0
- package/dist/server/ServerDocument.d.cts +98 -0
- package/dist/server/ServerDocument.d.cts.map +1 -0
- package/dist/server/ServerDocument.d.mts +99 -0
- package/dist/server/ServerDocument.d.mts.map +1 -0
- package/dist/server/ServerDocument.mjs +106 -0
- package/dist/server/ServerDocument.mjs.map +1 -0
- package/dist/server/errors.cjs +85 -0
- package/dist/server/errors.d.cts +53 -0
- package/dist/server/errors.d.cts.map +1 -0
- package/dist/server/errors.d.mts +53 -0
- package/dist/server/errors.d.mts.map +1 -0
- package/dist/server/errors.mjs +81 -0
- package/dist/server/errors.mjs.map +1 -0
- package/dist/server/index.cjs +9 -185
- package/dist/server/index.d.cts +3 -148
- package/dist/server/index.d.mts +3 -148
- package/dist/server/index.mjs +3 -181
- package/dist/types/index.cjs +16 -0
- package/dist/types/index.d.cts +16 -0
- package/dist/types/index.d.cts.map +1 -0
- package/dist/types/index.d.mts +16 -0
- package/dist/types/index.d.mts.map +1 -0
- package/dist/types/index.mjs +12 -0
- package/dist/types/index.mjs.map +1 -0
- package/dist/utils/tree-helpers.cjs +443 -0
- package/dist/utils/tree-helpers.d.cts +280 -0
- package/dist/utils/tree-helpers.d.cts.map +1 -0
- package/dist/utils/tree-helpers.d.mts +280 -0
- package/dist/utils/tree-helpers.d.mts.map +1 -0
- package/dist/utils/tree-helpers.mjs +439 -0
- package/dist/utils/tree-helpers.mjs.map +1 -0
- package/package.json +2 -2
- package/tsdown.config.ts +1 -1
- package/dist/Document-ChuFrTk1.cjs +0 -571
- package/dist/Document-CwiAFTIq.mjs +0 -438
- package/dist/Document-CwiAFTIq.mjs.map +0 -1
- package/dist/Presence-DKKP4v5X.d.cts.map +0 -1
- package/dist/Presence-DdMVKcOv.mjs.map +0 -1
- package/dist/Presence-N8u7Eppr.d.mts.map +0 -1
- package/dist/Primitive-DqQFc3Gu.d.mts +0 -1180
- package/dist/Primitive-DqQFc3Gu.d.mts.map +0 -1
- package/dist/Primitive-awpEjnKL.d.cts +0 -1180
- package/dist/Primitive-awpEjnKL.d.cts.map +0 -1
- package/dist/client/index.d.cts.map +0 -1
- package/dist/client/index.d.mts.map +0 -1
- package/dist/client/index.mjs.map +0 -1
- package/dist/index.d.cts.map +0 -1
- package/dist/index.d.mts.map +0 -1
- package/dist/index.mjs.map +0 -1
- package/dist/server/index.d.cts.map +0 -1
- package/dist/server/index.d.mts.map +0 -1
- package/dist/server/index.mjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClientDocument.mjs","names":["_serverState: Primitive.InferState<TSchema> | undefined","_pending: PendingTransaction[]","_serverTransactionHistory: Transaction.Transaction[]","Document.make","_unsubscribe: (() => void) | null","_initState: InitState","_initTimeoutHandle: ReturnType<typeof setTimeout> | null","_initResolver: (() => void) | null","_initRejecter: ((error: Error) => void) | null","_presenceSelfId: string | undefined","_presenceSelfData: unknown","pending: PendingTransaction","Rebase.transformTransactionWithPrimitive","Rebase.rebaseAfterRejectionWithPrimitive","Transaction.isEmpty","Presence.validate"],"sources":["../../src/client/ClientDocument.ts"],"sourcesContent":["import * as Document from \"../Document\";\nimport * as Transaction from \"../Transaction\";\nimport * as Presence from \"../Presence\";\nimport type * as Primitive from \"../Primitive\";\nimport type * as Transport from \"./Transport\";\nimport * as Rebase from \"./Rebase\";\nimport {\n TransactionRejectedError,\n NotConnectedError,\n InvalidStateError,\n} from \"./errors\";\n\n// =============================================================================\n// Client Document Types\n// =============================================================================\n\n/**\n * Pending transaction with metadata for tracking.\n */\ninterface PendingTransaction {\n /** The transaction */\n readonly transaction: Transaction.Transaction;\n /** Original transaction before any rebasing */\n readonly original: Transaction.Transaction;\n /** Timestamp when the transaction was sent */\n readonly sentAt: number;\n}\n\n/**\n * Initialization state for the client document.\n * Handles the race condition during startup where transactions\n * may arrive while fetching the initial snapshot.\n */\ntype InitState =\n | { readonly type: \"uninitialized\" }\n | { readonly type: \"initializing\"; readonly bufferedMessages: Transport.ServerMessage[] }\n | { readonly type: \"ready\" };\n\n// =============================================================================\n// Presence Types\n// =============================================================================\n\n/**\n * Listener for presence changes.\n */\nexport interface PresenceListener<_TData> {\n /** Called when any presence changes (self or others) */\n readonly onPresenceChange?: () => void;\n}\n\n/**\n * Presence API exposed on the ClientDocument.\n */\nexport interface ClientPresence<TData> {\n /**\n * Returns this client's connection ID (set after receiving presence_snapshot).\n * Returns undefined before the snapshot is received.\n */\n readonly selfId: () => string | undefined;\n\n /**\n * Returns this client's current presence data.\n * Returns undefined if not set.\n */\n readonly self: () => TData | undefined;\n\n /**\n * Returns a map of other clients' presence data.\n * Keys are connection IDs.\n */\n readonly others: () => ReadonlyMap<string, Presence.PresenceEntry<TData>>;\n\n /**\n * Returns all presence entries including self.\n */\n readonly all: () => ReadonlyMap<string, Presence.PresenceEntry<TData>>;\n\n /**\n * Sets this client's presence data.\n * Validates against the presence schema before sending.\n * @throws ParseError if validation fails\n */\n readonly set: (data: TData) => void;\n\n /**\n * Clears this client's presence data.\n */\n readonly clear: () => void;\n\n /**\n * Subscribes to presence changes.\n * @returns Unsubscribe function\n */\n readonly subscribe: (listener: PresenceListener<TData>) => () => void;\n}\n\n/**\n * Options for creating a ClientDocument.\n */\nexport interface ClientDocumentOptions<\n TSchema extends Primitive.AnyPrimitive,\n TPresence extends Presence.AnyPresence | undefined = undefined\n> {\n /** The schema defining the document structure */\n readonly schema: TSchema;\n /** Transport for server communication */\n readonly transport: Transport.Transport;\n /** Initial state (optional, will sync from server if not provided) */\n readonly initialState?: Primitive.InferState<TSchema>;\n /** Initial server version (optional) */\n readonly initialVersion?: number;\n /** Called when server rejects a transaction */\n readonly onRejection?: (\n transaction: Transaction.Transaction,\n reason: string\n ) => void;\n /** Called when optimistic state changes */\n readonly onStateChange?: (state: Primitive.InferState<TSchema> | undefined) => void;\n /** Called when connection status changes */\n readonly onConnectionChange?: (connected: boolean) => void;\n /** Called when client is fully initialized and ready */\n readonly onReady?: () => void;\n /** Timeout in ms for pending transactions (default: 30000) */\n readonly transactionTimeout?: number;\n /** Timeout in ms for initialization (default: 10000) */\n readonly initTimeout?: number;\n /** Enable debug logging for all activity (default: false) */\n readonly debug?: boolean;\n /**\n * Optional presence schema for ephemeral per-user data.\n * When provided, enables the presence API on the ClientDocument.\n */\n readonly presence?: TPresence;\n /** Initial presence data, that will be set on the ClientDocument when it is created */\n readonly initialPresence?: TPresence extends Presence.AnyPresence ? Presence.Infer<TPresence> : undefined;\n}\n\n/**\n * Listener callbacks for subscribing to ClientDocument events.\n */\nexport interface ClientDocumentListener<TSchema extends Primitive.AnyPrimitive> {\n /** Called when optimistic state changes */\n readonly onStateChange?: (state: Primitive.InferState<TSchema> | undefined) => void;\n /** Called when connection status changes */\n readonly onConnectionChange?: (connected: boolean) => void;\n /** Called when client is fully initialized and ready */\n readonly onReady?: () => void;\n}\n\n/**\n * A ClientDocument provides optimistic updates with server synchronization.\n */\nexport interface ClientDocument<\n TSchema extends Primitive.AnyPrimitive,\n TPresence extends Presence.AnyPresence | undefined = undefined\n> {\n /** The schema defining this document's structure */\n readonly schema: TSchema;\n\n /** Root proxy for accessing and modifying document data (optimistic) */\n readonly root: Primitive.InferProxy<TSchema>;\n\n /** Returns the current optimistic state (server + pending) */\n get(): Primitive.InferState<TSchema> | undefined;\n\n /** Returns the confirmed server state */\n getServerState(): Primitive.InferState<TSchema> | undefined;\n\n /** Returns the current server version */\n getServerVersion(): number;\n\n /** Returns pending transactions count */\n getPendingCount(): number;\n\n /** Returns whether there are pending transactions */\n hasPendingChanges(): boolean;\n\n /**\n * Runs a function within a transaction.\n * Changes are applied optimistically and sent to the server.\n */\n transaction<R>(fn: (root: Primitive.InferProxy<TSchema>) => R): R;\n\n /**\n * Connects to the server and starts syncing.\n */\n connect(): Promise<void>;\n\n /**\n * Disconnects from the server.\n */\n disconnect(): void;\n\n /**\n * Returns whether currently connected to the server.\n */\n isConnected(): boolean;\n\n /**\n * Forces a full resync from the server.\n */\n resync(): void;\n\n /**\n * Returns whether the client is fully initialized and ready.\n */\n isReady(): boolean;\n\n /**\n * Subscribes to document events (state changes, connection changes, ready).\n * @returns Unsubscribe function\n */\n subscribe(listener: ClientDocumentListener<TSchema>): () => void;\n\n /**\n * Presence API for ephemeral per-user data.\n * Only available when presence schema is provided in options.\n */\n readonly presence: TPresence extends Presence.AnyPresence\n ? ClientPresence<Presence.Infer<TPresence>>\n : undefined;\n}\n\n// =============================================================================\n// Client Document Implementation\n// =============================================================================\n\n/**\n * Creates a new ClientDocument for the given schema.\n */\nexport const make = <\n TSchema extends Primitive.AnyPrimitive,\n TPresence extends Presence.AnyPresence | undefined = undefined\n>(\n options: ClientDocumentOptions<TSchema, TPresence>\n): ClientDocument<TSchema, TPresence> => {\n const {\n schema,\n transport,\n initialState,\n initialVersion = 0,\n onRejection,\n onStateChange,\n onConnectionChange,\n onReady,\n transactionTimeout = 30000,\n initTimeout = 10000,\n debug = false,\n presence: presenceSchema,\n initialPresence,\n } = options;\n\n // ==========================================================================\n // Internal State\n // ==========================================================================\n\n // Server-confirmed state\n let _serverState: Primitive.InferState<TSchema> | undefined = initialState;\n let _serverVersion = initialVersion;\n\n // Pending transactions queue\n let _pending: PendingTransaction[] = [];\n\n // Server transactions received (for rebase after rejection)\n let _serverTransactionHistory: Transaction.Transaction[] = [];\n const MAX_HISTORY_SIZE = 100;\n\n // The underlying document for optimistic state\n let _optimisticDoc = Document.make(schema, { initial: _serverState });\n\n // Subscription cleanup\n let _unsubscribe: (() => void) | null = null;\n\n // Timeout handles for pending transactions\n const _timeoutHandles = new Map<string, ReturnType<typeof setTimeout>>();\n\n // Initialization state - handles buffering during startup\n let _initState: InitState = initialState !== undefined\n ? { type: \"ready\" }\n : { type: \"uninitialized\" };\n\n // Init timeout handle\n let _initTimeoutHandle: ReturnType<typeof setTimeout> | null = null;\n\n // Promise resolver for connect() to wait for ready state\n let _initResolver: (() => void) | null = null;\n let _initRejecter: ((error: Error) => void) | null = null;\n\n // Subscribers for events (added after creation via subscribe())\n const _subscribers = new Set<ClientDocumentListener<TSchema>>();\n\n // ==========================================================================\n // Presence State (only used when presenceSchema is provided)\n // ==========================================================================\n\n // This client's connection ID (received from presence_snapshot)\n let _presenceSelfId: string | undefined = undefined;\n\n // This client's current presence data\n let _presenceSelfData: unknown = undefined;\n\n // Other clients' presence entries (connectionId -> entry)\n const _presenceOthers = new Map<string, Presence.PresenceEntry<unknown>>();\n\n // Presence change subscribers\n const _presenceSubscribers = new Set<PresenceListener<unknown>>();\n\n // ==========================================================================\n // Debug Logging\n // ==========================================================================\n\n /**\n * Debug logging helper that only logs when debug is enabled.\n */\n const debugLog = (...args: unknown[]): void => {\n if (debug) {\n console.log(\"[ClientDocument]\", ...args);\n }\n };\n\n // ==========================================================================\n // Notification Helpers\n // ==========================================================================\n\n /**\n * Notifies all listeners of a state change.\n */\n const notifyStateChange = (state: Primitive.InferState<TSchema> | undefined): void => {\n debugLog(\"notifyStateChange\", {\n state,\n subscriberCount: _subscribers.size,\n hasOnStateChange: !!onStateChange,\n });\n onStateChange?.(state);\n for (const listener of _subscribers) {\n listener.onStateChange?.(state);\n }\n };\n\n /**\n * Notifies all listeners of a connection change.\n */\n const notifyConnectionChange = (connected: boolean): void => {\n debugLog(\"notifyConnectionChange\", {\n connected,\n subscriberCount: _subscribers.size,\n hasOnConnectionChange: !!onConnectionChange,\n });\n onConnectionChange?.(connected);\n for (const listener of _subscribers) {\n listener.onConnectionChange?.(connected);\n }\n };\n\n /**\n * Notifies all listeners when ready.\n */\n const notifyReady = (): void => {\n debugLog(\"notifyReady\", {\n subscriberCount: _subscribers.size,\n hasOnReady: !!onReady,\n });\n onReady?.();\n for (const listener of _subscribers) {\n listener.onReady?.();\n }\n };\n\n /**\n * Notifies all presence listeners of a change.\n */\n const notifyPresenceChange = (): void => {\n debugLog(\"notifyPresenceChange\", {\n subscriberCount: _presenceSubscribers.size,\n });\n for (const listener of _presenceSubscribers) {\n try {\n listener.onPresenceChange?.();\n } catch {\n // Ignore listener errors\n }\n }\n };\n\n // ==========================================================================\n // Presence Handlers\n // ==========================================================================\n\n /**\n * Handles incoming presence snapshot from server.\n */\n const handlePresenceSnapshot = (message: Transport.PresenceSnapshotMessage): void => {\n if (!presenceSchema) return;\n\n debugLog(\"handlePresenceSnapshot\", {\n selfId: message.selfId,\n presenceCount: Object.keys(message.presences).length,\n });\n\n _presenceSelfId = message.selfId;\n _presenceOthers.clear();\n\n // Populate others from snapshot (exclude self)\n for (const [id, entry] of Object.entries(message.presences)) {\n if (id !== message.selfId) {\n _presenceOthers.set(id, entry);\n }\n }\n\n notifyPresenceChange();\n };\n\n /**\n * Handles incoming presence update from server (another user).\n */\n const handlePresenceUpdate = (message: Transport.PresenceUpdateMessage): void => {\n if (!presenceSchema) return;\n\n debugLog(\"handlePresenceUpdate\", {\n id: message.id,\n userId: message.userId,\n });\n\n _presenceOthers.set(message.id, {\n data: message.data,\n userId: message.userId,\n });\n\n notifyPresenceChange();\n };\n\n /**\n * Handles incoming presence remove from server (user disconnected).\n */\n const handlePresenceRemove = (message: Transport.PresenceRemoveMessage): void => {\n if (!presenceSchema) return;\n\n debugLog(\"handlePresenceRemove\", {\n id: message.id,\n });\n\n _presenceOthers.delete(message.id);\n notifyPresenceChange();\n };\n\n /**\n * Clears all presence state (on disconnect).\n */\n const clearPresenceState = (): void => {\n _presenceSelfId = undefined;\n _presenceSelfData = undefined;\n _presenceOthers.clear();\n notifyPresenceChange();\n };\n\n // ==========================================================================\n // Helper Functions\n // ==========================================================================\n\n /**\n * Recomputes the optimistic document from server state + pending transactions.\n */\n const recomputeOptimisticState = (): void => {\n debugLog(\"recomputeOptimisticState\", {\n serverVersion: _serverVersion,\n pendingCount: _pending.length,\n serverState: _serverState,\n });\n\n // Create fresh document from server state\n _optimisticDoc = Document.make(schema, { initial: _serverState });\n\n // Apply all pending transactions\n for (const pending of _pending) {\n _optimisticDoc.apply(pending.transaction.ops);\n }\n\n const newState = _optimisticDoc.get();\n debugLog(\"recomputeOptimisticState: new optimistic state\", newState);\n\n // Notify state change\n notifyStateChange(newState);\n };\n\n /**\n * Adds a transaction to pending queue and sends to server.\n */\n const submitTransaction = (tx: Transaction.Transaction): void => {\n if (!transport.isConnected()) {\n throw new NotConnectedError();\n }\n\n debugLog(\"submitTransaction\", {\n txId: tx.id,\n ops: tx.ops,\n pendingCount: _pending.length + 1,\n });\n\n const pending: PendingTransaction = {\n transaction: tx,\n original: tx,\n sentAt: Date.now(),\n };\n\n _pending.push(pending);\n\n // Set timeout for this transaction\n const timeoutHandle = setTimeout(() => {\n handleTransactionTimeout(tx.id);\n }, transactionTimeout);\n _timeoutHandles.set(tx.id, timeoutHandle);\n\n // Send to server\n transport.send(tx);\n debugLog(\"submitTransaction: sent to server\", { txId: tx.id });\n };\n\n /**\n * Handles a transaction timeout.\n */\n const handleTransactionTimeout = (txId: string): void => {\n debugLog(\"handleTransactionTimeout\", { txId });\n const index = _pending.findIndex((p) => p.transaction.id === txId);\n if (index === -1) {\n debugLog(\"handleTransactionTimeout: transaction not found (already confirmed/rejected)\", { txId });\n return; // Already confirmed or rejected\n }\n\n // Remove from pending\n const [removed] = _pending.splice(index, 1);\n _timeoutHandles.delete(txId);\n\n debugLog(\"handleTransactionTimeout: removed from pending\", {\n txId,\n remainingPending: _pending.length,\n });\n\n // Recompute state\n recomputeOptimisticState();\n\n // Notify as rejection\n onRejection?.(removed!.transaction, \"Transaction timed out\");\n };\n\n /**\n * Handles an incoming server transaction.\n */\n const handleServerTransaction = (\n serverTx: Transaction.Transaction,\n version: number\n ): void => {\n debugLog(\"handleServerTransaction\", {\n txId: serverTx.id,\n version,\n ops: serverTx.ops,\n currentServerVersion: _serverVersion,\n pendingCount: _pending.length,\n });\n\n // Update server version\n _serverVersion = version;\n\n // Check if this is one of our pending transactions (ACK)\n const pendingIndex = _pending.findIndex(\n (p) => p.transaction.id === serverTx.id\n );\n\n if (pendingIndex !== -1) {\n // This is our transaction - confirmed!\n debugLog(\"handleServerTransaction: transaction confirmed (ACK)\", {\n txId: serverTx.id,\n pendingIndex,\n });\n\n const confirmed = _pending[pendingIndex]!;\n\n // Clear timeout\n const timeoutHandle = _timeoutHandles.get(serverTx.id);\n if (timeoutHandle) {\n clearTimeout(timeoutHandle);\n _timeoutHandles.delete(serverTx.id);\n }\n\n // Remove from pending\n _pending.splice(pendingIndex, 1);\n\n // Apply to server state\n const tempDoc = Document.make(schema, { initial: _serverState });\n tempDoc.apply(serverTx.ops);\n _serverState = tempDoc.get();\n\n debugLog(\"handleServerTransaction: updated server state\", {\n txId: serverTx.id,\n newServerState: _serverState,\n remainingPending: _pending.length,\n });\n\n // Recompute optimistic state (pending txs already applied, just need to update base)\n recomputeOptimisticState();\n } else {\n // This is someone else's transaction - need to rebase\n debugLog(\"handleServerTransaction: remote transaction, rebasing pending\", {\n txId: serverTx.id,\n pendingCount: _pending.length,\n });\n\n // Apply to server state\n const tempDoc = Document.make(schema, { initial: _serverState });\n tempDoc.apply(serverTx.ops);\n _serverState = tempDoc.get();\n\n // Add to history for potential rebase after rejection\n _serverTransactionHistory.push(serverTx);\n if (_serverTransactionHistory.length > MAX_HISTORY_SIZE) {\n _serverTransactionHistory.shift();\n }\n\n // Rebase all pending transactions using primitive-based transformation\n const rebasedPending = _pending.map((p) => ({\n ...p,\n transaction: Rebase.transformTransactionWithPrimitive(p.transaction, serverTx, schema),\n }));\n\n debugLog(\"handleServerTransaction: rebased pending transactions\", {\n txId: serverTx.id,\n rebasedCount: rebasedPending.length,\n originalPendingIds: _pending.map((p) => p.transaction.id),\n rebasedPendingIds: rebasedPending.map((p) => p.transaction.id),\n });\n\n _pending = rebasedPending;\n\n // Recompute optimistic state\n recomputeOptimisticState();\n }\n };\n\n /**\n * Handles a transaction rejection from the server.\n */\n const handleRejection = (txId: string, reason: string): void => {\n debugLog(\"handleRejection\", {\n txId,\n reason,\n pendingCount: _pending.length,\n });\n\n const index = _pending.findIndex((p) => p.transaction.id === txId);\n if (index === -1) {\n debugLog(\"handleRejection: transaction not found (already removed)\", { txId });\n return; // Already removed\n }\n\n const rejected = _pending[index]!;\n\n // Clear timeout\n const timeoutHandle = _timeoutHandles.get(txId);\n if (timeoutHandle) {\n clearTimeout(timeoutHandle);\n _timeoutHandles.delete(txId);\n }\n\n // Remove rejected transaction\n _pending.splice(index, 1);\n\n debugLog(\"handleRejection: removed rejected transaction, rebasing remaining\", {\n txId,\n remainingPending: _pending.length,\n serverHistorySize: _serverTransactionHistory.length,\n });\n\n // Re-transform remaining pending transactions without the rejected one\n // We need to replay from their original state\n const remainingOriginals = _pending.map((p) => p.original);\n const retransformed = Rebase.rebaseAfterRejectionWithPrimitive(\n [...remainingOriginals, rejected.original],\n txId,\n _serverTransactionHistory,\n schema\n );\n\n // Update pending with retransformed versions\n _pending = _pending.map((p, i) => ({\n ...p,\n transaction: retransformed[i] ?? p.transaction,\n }));\n\n debugLog(\"handleRejection: rebased remaining transactions\", {\n txId,\n rebasedCount: _pending.length,\n });\n\n // Recompute optimistic state\n recomputeOptimisticState();\n\n // Notify rejection\n onRejection?.(rejected.original, reason);\n };\n\n /**\n * Handles a snapshot from the server.\n * @param isInitialSnapshot - If true, this is the initial sync snapshot\n */\n const handleSnapshot = (state: unknown, version: number, isInitialSnapshot: boolean = false): void => {\n debugLog(\"handleSnapshot\", {\n isInitialSnapshot,\n version,\n currentServerVersion: _serverVersion,\n pendingCount: _pending.length,\n state,\n });\n\n if (!isInitialSnapshot) {\n debugLog(\"handleSnapshot: non-initial snapshot, clearing pending transactions\", {\n clearedPendingCount: _pending.length,\n });\n\n // For non-initial snapshots, clear all pending (they're now invalid)\n for (const handle of _timeoutHandles.values()) {\n clearTimeout(handle);\n }\n _timeoutHandles.clear();\n\n // Notify rejections for all pending\n for (const pending of _pending) {\n onRejection?.(pending.original, \"State reset due to resync\");\n }\n\n _pending = [];\n }\n\n _serverTransactionHistory = [];\n _serverState = state as Primitive.InferState<TSchema>;\n _serverVersion = version;\n\n debugLog(\"handleSnapshot: updated server state\", {\n newVersion: _serverVersion,\n newState: _serverState,\n });\n\n // Recompute optimistic state (now equals server state)\n recomputeOptimisticState();\n };\n\n /**\n * Processes buffered messages after receiving the initial snapshot.\n * Filters out transactions already included in the snapshot (version <= snapshotVersion)\n * and applies newer transactions in order.\n */\n const processBufferedMessages = (\n bufferedMessages: Transport.ServerMessage[],\n snapshotVersion: number\n ): void => {\n debugLog(\"processBufferedMessages\", {\n bufferedCount: bufferedMessages.length,\n snapshotVersion,\n });\n\n // Sort transactions by version to ensure correct order\n const sortedMessages = [...bufferedMessages].sort((a, b) => {\n if (a.type === \"transaction\" && b.type === \"transaction\") {\n return a.version - b.version;\n }\n return 0;\n });\n\n // Process each buffered message\n for (const message of sortedMessages) {\n switch (message.type) {\n case \"transaction\":\n // Only apply transactions with version > snapshot version\n if (message.version > snapshotVersion) {\n debugLog(\"processBufferedMessages: applying buffered transaction\", {\n txId: message.transaction.id,\n version: message.version,\n snapshotVersion,\n });\n handleServerTransaction(message.transaction, message.version);\n } else {\n debugLog(\"processBufferedMessages: skipping buffered transaction (already in snapshot)\", {\n txId: message.transaction.id,\n version: message.version,\n snapshotVersion,\n });\n }\n break;\n case \"error\":\n // Errors are still relevant - pass through\n debugLog(\"processBufferedMessages: processing buffered error\", {\n txId: message.transactionId,\n reason: message.reason,\n });\n handleRejection(message.transactionId, message.reason);\n break;\n // Ignore additional snapshots in buffer - we already have one\n }\n }\n };\n\n /**\n * Completes initialization and transitions to ready state.\n */\n const completeInitialization = (): void => {\n debugLog(\"completeInitialization\");\n\n // Clear init timeout\n if (_initTimeoutHandle !== null) {\n clearTimeout(_initTimeoutHandle);\n _initTimeoutHandle = null;\n }\n\n _initState = { type: \"ready\" };\n\n // Resolve the connect promise\n if (_initResolver) {\n _initResolver();\n _initResolver = null;\n _initRejecter = null;\n }\n\n debugLog(\"completeInitialization: ready\", {\n serverVersion: _serverVersion,\n serverState: _serverState,\n });\n\n // Notify ready\n notifyReady();\n };\n\n /**\n * Handles initialization timeout.\n */\n const handleInitTimeout = (): void => {\n debugLog(\"handleInitTimeout: initialization timed out\");\n _initTimeoutHandle = null;\n\n // Reject the connect promise\n if (_initRejecter) {\n const error = new Error(\"Initialization timed out waiting for snapshot\");\n _initRejecter(error);\n _initResolver = null;\n _initRejecter = null;\n }\n\n // Reset to uninitialized state\n _initState = { type: \"uninitialized\" };\n };\n\n /**\n * Handles incoming server messages.\n * During initialization, messages are buffered until the snapshot arrives.\n * Presence messages are always processed immediately (not buffered).\n */\n const handleServerMessage = (message: Transport.ServerMessage): void => {\n debugLog(\"handleServerMessage\", {\n messageType: message.type,\n initState: _initState.type,\n });\n\n // Presence messages are always handled immediately (not buffered)\n // This allows presence to work even during document initialization\n if (message.type === \"presence_snapshot\") {\n handlePresenceSnapshot(message);\n return;\n }\n if (message.type === \"presence_update\") {\n handlePresenceUpdate(message);\n return;\n }\n if (message.type === \"presence_remove\") {\n handlePresenceRemove(message);\n return;\n }\n\n // Handle based on initialization state\n if (_initState.type === \"initializing\") {\n if (message.type === \"snapshot\") {\n debugLog(\"handleServerMessage: received snapshot during initialization\", {\n version: message.version,\n bufferedCount: _initState.bufferedMessages.length,\n });\n // Snapshot received - apply it and process buffered messages\n const buffered = _initState.bufferedMessages;\n handleSnapshot(message.state, message.version, true);\n processBufferedMessages(buffered, message.version);\n completeInitialization();\n } else {\n debugLog(\"handleServerMessage: buffering message during initialization\", {\n messageType: message.type,\n bufferedCount: _initState.bufferedMessages.length + 1,\n });\n // Buffer other messages during initialization\n _initState.bufferedMessages.push(message);\n }\n return;\n }\n\n // Normal message handling when ready (or uninitialized with initial state)\n switch (message.type) {\n case \"transaction\":\n handleServerTransaction(message.transaction, message.version);\n break;\n case \"snapshot\":\n handleSnapshot(message.state, message.version, false);\n break;\n case \"error\":\n handleRejection(message.transactionId, message.reason);\n break;\n }\n };\n\n // ==========================================================================\n // Public API\n // ==========================================================================\n\n const clientDocument = {\n schema,\n\n get root() {\n return _optimisticDoc.root;\n },\n\n get: () => _optimisticDoc.get(),\n\n getServerState: () => _serverState,\n\n getServerVersion: () => _serverVersion,\n\n getPendingCount: () => _pending.length,\n\n hasPendingChanges: () => _pending.length > 0,\n\n transaction: <R,>(fn: (root: Primitive.InferProxy<TSchema>) => R): R => {\n debugLog(\"transaction: starting\", {\n isConnected: transport.isConnected(),\n isReady: _initState.type === \"ready\",\n pendingCount: _pending.length,\n });\n\n if (!transport.isConnected()) {\n throw new NotConnectedError();\n }\n\n if (_initState.type !== \"ready\") {\n throw new InvalidStateError(\"Client is not ready. Wait for initialization to complete.\");\n }\n\n // Run the transaction on the optimistic document\n const result = _optimisticDoc.transaction(fn);\n\n // Flush and get the transaction\n const tx = _optimisticDoc.flush();\n\n // If there are operations, submit to server\n if (!Transaction.isEmpty(tx)) {\n debugLog(\"transaction: flushed, submitting\", {\n txId: tx.id,\n opsCount: tx.ops.length,\n });\n submitTransaction(tx);\n } else {\n debugLog(\"transaction: flushed, empty transaction (no ops)\");\n }\n\n // Notify state change\n notifyStateChange(_optimisticDoc.get());\n\n return result;\n },\n\n connect: async (): Promise<void> => {\n debugLog(\"connect: starting\");\n // Subscribe to server messages\n _unsubscribe = transport.subscribe(handleServerMessage);\n\n // Connect transport\n await transport.connect();\n debugLog(\"connect: transport connected\");\n\n notifyConnectionChange(true);\n\n // Set initial presence if provided\n if (presenceSchema && initialPresence !== undefined) {\n debugLog(\"connect: setting initial presence\", { initialPresence });\n const validated = Presence.validate(presenceSchema, initialPresence);\n _presenceSelfData = validated;\n transport.sendPresenceSet(validated);\n notifyPresenceChange();\n }\n\n // If we already have initial state, we're ready immediately\n if (_initState.type === \"ready\") {\n debugLog(\"connect: already ready (has initial state)\");\n notifyReady();\n return;\n }\n\n // Enter initializing state - buffer messages until snapshot arrives\n _initState = { type: \"initializing\", bufferedMessages: [] };\n debugLog(\"connect: entering initializing state\", {\n initTimeout,\n });\n\n // Set up initialization timeout\n _initTimeoutHandle = setTimeout(handleInitTimeout, initTimeout);\n\n // Create a promise that resolves when we're ready\n const readyPromise = new Promise<void>((resolve, reject) => {\n _initResolver = resolve;\n _initRejecter = reject;\n });\n\n // Request initial snapshot\n debugLog(\"connect: requesting initial snapshot\");\n \n transport.requestSnapshot();\n\n\n // Wait for initialization to complete\n await readyPromise;\n debugLog(\"connect: completed\");\n },\n\n disconnect: (): void => {\n debugLog(\"disconnect: starting\", {\n pendingCount: _pending.length,\n initState: _initState.type,\n });\n\n // Clear all timeouts\n for (const handle of _timeoutHandles.values()) {\n clearTimeout(handle);\n }\n _timeoutHandles.clear();\n\n // Clear init timeout\n if (_initTimeoutHandle !== null) {\n clearTimeout(_initTimeoutHandle);\n _initTimeoutHandle = null;\n }\n\n // Reject any pending init promise\n if (_initRejecter) {\n _initRejecter(new Error(\"Disconnected during initialization\"));\n _initResolver = null;\n _initRejecter = null;\n }\n\n // Reset init state\n if (_initState.type === \"initializing\") {\n _initState = { type: \"uninitialized\" };\n }\n\n // Clear presence state\n clearPresenceState();\n\n // Unsubscribe\n if (_unsubscribe) {\n _unsubscribe();\n _unsubscribe = null;\n }\n\n // Disconnect transport\n transport.disconnect();\n\n notifyConnectionChange(false);\n debugLog(\"disconnect: completed\");\n },\n\n isConnected: () => transport.isConnected(),\n\n isReady: () => _initState.type === \"ready\",\n\n resync: (): void => {\n debugLog(\"resync: requesting snapshot\", {\n currentVersion: _serverVersion,\n pendingCount: _pending.length,\n });\n if (!transport.isConnected()) {\n throw new NotConnectedError();\n }\n transport.requestSnapshot();\n },\n\n subscribe: (listener: ClientDocumentListener<TSchema>): (() => void) => {\n _subscribers.add(listener);\n return () => {\n _subscribers.delete(listener);\n };\n },\n\n // =========================================================================\n // Presence API\n // =========================================================================\n\n presence: (presenceSchema\n ? {\n selfId: () => _presenceSelfId,\n\n self: () => _presenceSelfData as Presence.Infer<NonNullable<TPresence>> | undefined,\n\n others: () => _presenceOthers as ReadonlyMap<string, Presence.PresenceEntry<Presence.Infer<NonNullable<TPresence>>>>,\n\n all: () => {\n const all = new Map<string, Presence.PresenceEntry<unknown>>();\n // Add others\n for (const [id, entry] of _presenceOthers) {\n all.set(id, entry);\n }\n // Add self if we have data\n if (_presenceSelfId !== undefined && _presenceSelfData !== undefined) {\n all.set(_presenceSelfId, { data: _presenceSelfData });\n }\n return all as ReadonlyMap<string, Presence.PresenceEntry<Presence.Infer<NonNullable<TPresence>>>>;\n },\n\n set: (data: Presence.Infer<NonNullable<TPresence>>) => {\n if (!presenceSchema) return;\n\n // Validate against schema (throws if invalid)\n const validated = Presence.validate(presenceSchema, data);\n\n debugLog(\"presence.set\", { data: validated });\n\n // Update local state\n _presenceSelfData = validated;\n\n // Send to server\n transport.sendPresenceSet(validated);\n\n // Notify listeners\n notifyPresenceChange();\n },\n\n clear: () => {\n if (!presenceSchema) return;\n\n debugLog(\"presence.clear\");\n\n // Clear local state\n _presenceSelfData = undefined;\n\n // Send to server\n transport.sendPresenceClear();\n\n // Notify listeners\n notifyPresenceChange();\n },\n\n subscribe: (listener: PresenceListener<Presence.Infer<NonNullable<TPresence>>>) => {\n _presenceSubscribers.add(listener as PresenceListener<unknown>);\n return () => {\n _presenceSubscribers.delete(listener as PresenceListener<unknown>);\n };\n },\n }\n : undefined) as TPresence extends Presence.AnyPresence\n ? ClientPresence<Presence.Infer<TPresence>>\n : undefined,\n } as ClientDocument<TSchema, TPresence>;\n\n return clientDocument;\n};\n"],"mappings":";;;;;;;;;;;;;AAsOA,MAAa,QAIX,YACuC;CACvC,MAAM,EACJ,QACA,WACA,cACA,iBAAiB,GACjB,aACA,eACA,oBACA,SACA,qBAAqB,KACrB,cAAc,KACd,QAAQ,OACR,UAAU,gBACV,oBACE;CAOJ,IAAIA,eAA0D;CAC9D,IAAI,iBAAiB;CAGrB,IAAIC,WAAiC,EAAE;CAGvC,IAAIC,4BAAuD,EAAE;CAC7D,MAAM,mBAAmB;CAGzB,IAAI,iBAAiBC,OAAc,QAAQ,EAAE,SAAS,cAAc,CAAC;CAGrE,IAAIC,eAAoC;CAGxC,MAAM,kCAAkB,IAAI,KAA4C;CAGxE,IAAIC,aAAwB,iBAAiB,SACzC,EAAE,MAAM,SAAS,GACjB,EAAE,MAAM,iBAAiB;CAG7B,IAAIC,qBAA2D;CAG/D,IAAIC,gBAAqC;CACzC,IAAIC,gBAAiD;CAGrD,MAAM,+BAAe,IAAI,KAAsC;CAO/D,IAAIC,kBAAsC;CAG1C,IAAIC,oBAA6B;CAGjC,MAAM,kCAAkB,IAAI,KAA8C;CAG1E,MAAM,uCAAuB,IAAI,KAAgC;;;;CASjE,MAAM,YAAY,GAAG,SAA0B;AAC7C,MAAI,MACF,SAAQ,IAAI,oBAAoB,GAAG,KAAK;;;;;CAW5C,MAAM,qBAAqB,UAA2D;AACpF,WAAS,qBAAqB;GAC5B;GACA,iBAAiB,aAAa;GAC9B,kBAAkB,CAAC,CAAC;GACrB,CAAC;AACF,sEAAgB,MAAM;AACtB,OAAK,MAAM,YAAY,cAAc;;AACnC,qCAAS,oGAAgB,MAAM;;;;;;CAOnC,MAAM,0BAA0B,cAA6B;AAC3D,WAAS,0BAA0B;GACjC;GACA,iBAAiB,aAAa;GAC9B,uBAAuB,CAAC,CAAC;GAC1B,CAAC;AACF,qFAAqB,UAAU;AAC/B,OAA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|
|
2
|
+
const require_OperationPath = require('../OperationPath.cjs');
|
|
3
|
+
|
|
4
|
+
//#region src/client/Rebase.ts
|
|
5
|
+
var Rebase_exports = /* @__PURE__ */ require_rolldown_runtime.__export({
|
|
6
|
+
rebaseAfterRejection: () => rebaseAfterRejection,
|
|
7
|
+
rebaseAfterRejectionWithPrimitive: () => rebaseAfterRejectionWithPrimitive,
|
|
8
|
+
rebasePendingTransactions: () => rebasePendingTransactions,
|
|
9
|
+
rebasePendingTransactionsWithPrimitive: () => rebasePendingTransactionsWithPrimitive,
|
|
10
|
+
transformOperation: () => transformOperation,
|
|
11
|
+
transformOperationWithPrimitive: () => transformOperationWithPrimitive,
|
|
12
|
+
transformTransaction: () => transformTransaction,
|
|
13
|
+
transformTransactionWithPrimitive: () => transformTransactionWithPrimitive
|
|
14
|
+
});
|
|
15
|
+
/**
|
|
16
|
+
* Transforms a client operation against a server operation using a primitive.
|
|
17
|
+
*
|
|
18
|
+
* This delegates to the primitive's transformOperation method, which handles
|
|
19
|
+
* type-specific conflict resolution.
|
|
20
|
+
*
|
|
21
|
+
* @param clientOp - The client's operation to transform
|
|
22
|
+
* @param serverOp - The server's operation that has already been applied
|
|
23
|
+
* @param primitive - The root primitive to use for transformation
|
|
24
|
+
* @returns TransformResult indicating how the client operation should be handled
|
|
25
|
+
*/
|
|
26
|
+
const transformOperationWithPrimitive = (clientOp, serverOp, primitive) => {
|
|
27
|
+
return primitive._internal.transformOperation(clientOp, serverOp);
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Transforms a client operation against a server operation.
|
|
31
|
+
*
|
|
32
|
+
* This is a standalone implementation for cases where the primitive is not available.
|
|
33
|
+
* For schema-aware transformation, use transformOperationWithPrimitive instead.
|
|
34
|
+
*
|
|
35
|
+
* The key principle: client ops "shadow" server ops for the same path,
|
|
36
|
+
* meaning if both touch the same field, the client's intention wins
|
|
37
|
+
* (since it was made with knowledge of the server state at that time).
|
|
38
|
+
*/
|
|
39
|
+
const transformOperation = (clientOp, serverOp) => {
|
|
40
|
+
const clientPath = clientOp.path;
|
|
41
|
+
const serverPath = serverOp.path;
|
|
42
|
+
if (!require_OperationPath.pathsOverlap(clientPath, serverPath)) return {
|
|
43
|
+
type: "transformed",
|
|
44
|
+
operation: clientOp
|
|
45
|
+
};
|
|
46
|
+
if (serverOp.kind === "array.remove") {
|
|
47
|
+
const removedId = serverOp.payload.id;
|
|
48
|
+
const clientTokens = clientPath.toTokens().filter((t) => t !== "");
|
|
49
|
+
const serverTokens = serverPath.toTokens().filter((t) => t !== "");
|
|
50
|
+
if (clientTokens.length > serverTokens.length) {
|
|
51
|
+
if (clientTokens[serverTokens.length] === removedId) return { type: "noop" };
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (serverOp.kind === "array.insert" && clientOp.kind === "array.insert") return {
|
|
55
|
+
type: "transformed",
|
|
56
|
+
operation: clientOp
|
|
57
|
+
};
|
|
58
|
+
if (serverOp.kind === "array.move" && clientOp.kind === "array.move") {
|
|
59
|
+
if (serverOp.payload.id === clientOp.payload.id) return {
|
|
60
|
+
type: "transformed",
|
|
61
|
+
operation: clientOp
|
|
62
|
+
};
|
|
63
|
+
return {
|
|
64
|
+
type: "transformed",
|
|
65
|
+
operation: clientOp
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
if (require_OperationPath.pathsEqual(clientPath, serverPath)) return {
|
|
69
|
+
type: "transformed",
|
|
70
|
+
operation: clientOp
|
|
71
|
+
};
|
|
72
|
+
if (require_OperationPath.isPrefix(serverPath, clientPath)) {
|
|
73
|
+
const serverKind = serverOp.kind;
|
|
74
|
+
if (serverKind === "struct.set" || serverKind === "array.set" || serverKind === "union.set") return {
|
|
75
|
+
type: "transformed",
|
|
76
|
+
operation: clientOp
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
return {
|
|
80
|
+
type: "transformed",
|
|
81
|
+
operation: clientOp
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Transforms all operations in a client transaction against a server transaction.
|
|
86
|
+
* Uses the primitive's transformOperation for schema-aware transformation.
|
|
87
|
+
*/
|
|
88
|
+
const transformTransactionWithPrimitive = (clientTx, serverTx, primitive) => {
|
|
89
|
+
const transformedOps = [];
|
|
90
|
+
for (const clientOp of clientTx.ops) {
|
|
91
|
+
let currentOp = clientOp;
|
|
92
|
+
for (const serverOp of serverTx.ops) {
|
|
93
|
+
if (currentOp === null) break;
|
|
94
|
+
const result = transformOperationWithPrimitive(currentOp, serverOp, primitive);
|
|
95
|
+
switch (result.type) {
|
|
96
|
+
case "transformed":
|
|
97
|
+
currentOp = result.operation;
|
|
98
|
+
break;
|
|
99
|
+
case "noop":
|
|
100
|
+
currentOp = null;
|
|
101
|
+
break;
|
|
102
|
+
case "conflict": break;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
if (currentOp !== null) transformedOps.push(currentOp);
|
|
106
|
+
}
|
|
107
|
+
return {
|
|
108
|
+
id: clientTx.id,
|
|
109
|
+
ops: transformedOps,
|
|
110
|
+
timestamp: clientTx.timestamp
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
/**
|
|
114
|
+
* Transforms all operations in a client transaction against a server transaction.
|
|
115
|
+
* This is a standalone version that doesn't require a primitive.
|
|
116
|
+
*/
|
|
117
|
+
const transformTransaction = (clientTx, serverTx) => {
|
|
118
|
+
const transformedOps = [];
|
|
119
|
+
for (const clientOp of clientTx.ops) {
|
|
120
|
+
let currentOp = clientOp;
|
|
121
|
+
for (const serverOp of serverTx.ops) {
|
|
122
|
+
if (currentOp === null) break;
|
|
123
|
+
const result = transformOperation(currentOp, serverOp);
|
|
124
|
+
switch (result.type) {
|
|
125
|
+
case "transformed":
|
|
126
|
+
currentOp = result.operation;
|
|
127
|
+
break;
|
|
128
|
+
case "noop":
|
|
129
|
+
currentOp = null;
|
|
130
|
+
break;
|
|
131
|
+
case "conflict": break;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
if (currentOp !== null) transformedOps.push(currentOp);
|
|
135
|
+
}
|
|
136
|
+
return {
|
|
137
|
+
id: clientTx.id,
|
|
138
|
+
ops: transformedOps,
|
|
139
|
+
timestamp: clientTx.timestamp
|
|
140
|
+
};
|
|
141
|
+
};
|
|
142
|
+
/**
|
|
143
|
+
* Rebases a list of pending transactions against a server transaction using a primitive.
|
|
144
|
+
*
|
|
145
|
+
* This is called when a server transaction arrives that is NOT one of our pending
|
|
146
|
+
* transactions. We need to transform all pending transactions to work correctly
|
|
147
|
+
* on top of the new server state.
|
|
148
|
+
*/
|
|
149
|
+
const rebasePendingTransactionsWithPrimitive = (pendingTxs, serverTx, primitive) => {
|
|
150
|
+
return pendingTxs.map((pendingTx) => transformTransactionWithPrimitive(pendingTx, serverTx, primitive));
|
|
151
|
+
};
|
|
152
|
+
/**
|
|
153
|
+
* Rebases a list of pending transactions against a server transaction.
|
|
154
|
+
*
|
|
155
|
+
* This is called when a server transaction arrives that is NOT one of our pending
|
|
156
|
+
* transactions. We need to transform all pending transactions to work correctly
|
|
157
|
+
* on top of the new server state.
|
|
158
|
+
*/
|
|
159
|
+
const rebasePendingTransactions = (pendingTxs, serverTx) => {
|
|
160
|
+
return pendingTxs.map((pendingTx) => transformTransaction(pendingTx, serverTx));
|
|
161
|
+
};
|
|
162
|
+
/**
|
|
163
|
+
* Rebases pending transactions after a rejection using a primitive.
|
|
164
|
+
*
|
|
165
|
+
* When a transaction is rejected, we need to re-transform remaining pending
|
|
166
|
+
* transactions as if the rejected transaction never happened. This is done by
|
|
167
|
+
* rebuilding from the original operations against the current server state.
|
|
168
|
+
*
|
|
169
|
+
* @param originalPendingTxs - The original pending transactions before any rebasing
|
|
170
|
+
* @param rejectedTxId - ID of the rejected transaction
|
|
171
|
+
* @param serverTxsSinceOriginal - Server transactions that have arrived since original
|
|
172
|
+
* @param primitive - The root primitive to use for transformation
|
|
173
|
+
*/
|
|
174
|
+
const rebaseAfterRejectionWithPrimitive = (originalPendingTxs, rejectedTxId, serverTxsSinceOriginal, primitive) => {
|
|
175
|
+
let result = [...originalPendingTxs.filter((tx) => tx.id !== rejectedTxId)];
|
|
176
|
+
for (const serverTx of serverTxsSinceOriginal) result = rebasePendingTransactionsWithPrimitive(result, serverTx, primitive);
|
|
177
|
+
return result;
|
|
178
|
+
};
|
|
179
|
+
/**
|
|
180
|
+
* Rebases pending transactions after a rejection.
|
|
181
|
+
*
|
|
182
|
+
* When a transaction is rejected, we need to re-transform remaining pending
|
|
183
|
+
* transactions as if the rejected transaction never happened. This is done by
|
|
184
|
+
* rebuilding from the original operations against the current server state.
|
|
185
|
+
*
|
|
186
|
+
* @param originalPendingTxs - The original pending transactions before any rebasing
|
|
187
|
+
* @param rejectedTxId - ID of the rejected transaction
|
|
188
|
+
* @param serverTxsSinceOriginal - Server transactions that have arrived since original
|
|
189
|
+
*/
|
|
190
|
+
const rebaseAfterRejection = (originalPendingTxs, rejectedTxId, serverTxsSinceOriginal) => {
|
|
191
|
+
let result = [...originalPendingTxs.filter((tx) => tx.id !== rejectedTxId)];
|
|
192
|
+
for (const serverTx of serverTxsSinceOriginal) result = rebasePendingTransactions(result, serverTx);
|
|
193
|
+
return result;
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
//#endregion
|
|
197
|
+
Object.defineProperty(exports, 'Rebase_exports', {
|
|
198
|
+
enumerable: true,
|
|
199
|
+
get: function () {
|
|
200
|
+
return Rebase_exports;
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
exports.rebaseAfterRejectionWithPrimitive = rebaseAfterRejectionWithPrimitive;
|
|
204
|
+
exports.transformTransactionWithPrimitive = transformTransactionWithPrimitive;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { Operation } from "../Operation.cjs";
|
|
2
|
+
import { Transaction } from "../Transaction.cjs";
|
|
3
|
+
import { TransformResult as TransformResult$1 } from "../Transform.cjs";
|
|
4
|
+
import { AnyPrimitive } from "../primitives/shared.cjs";
|
|
5
|
+
|
|
6
|
+
//#region src/client/Rebase.d.ts
|
|
7
|
+
declare namespace Rebase_d_exports {
|
|
8
|
+
export { TransformResult, rebaseAfterRejection, rebaseAfterRejectionWithPrimitive, rebasePendingTransactions, rebasePendingTransactionsWithPrimitive, transformOperation, transformOperationWithPrimitive, transformTransaction, transformTransactionWithPrimitive };
|
|
9
|
+
}
|
|
10
|
+
type TransformResult = TransformResult$1;
|
|
11
|
+
/**
|
|
12
|
+
* Transforms a client operation against a server operation using a primitive.
|
|
13
|
+
*
|
|
14
|
+
* This delegates to the primitive's transformOperation method, which handles
|
|
15
|
+
* type-specific conflict resolution.
|
|
16
|
+
*
|
|
17
|
+
* @param clientOp - The client's operation to transform
|
|
18
|
+
* @param serverOp - The server's operation that has already been applied
|
|
19
|
+
* @param primitive - The root primitive to use for transformation
|
|
20
|
+
* @returns TransformResult indicating how the client operation should be handled
|
|
21
|
+
*/
|
|
22
|
+
declare const transformOperationWithPrimitive: (clientOp: Operation<any, any, any>, serverOp: Operation<any, any, any>, primitive: AnyPrimitive) => TransformResult;
|
|
23
|
+
/**
|
|
24
|
+
* Transforms a client operation against a server operation.
|
|
25
|
+
*
|
|
26
|
+
* This is a standalone implementation for cases where the primitive is not available.
|
|
27
|
+
* For schema-aware transformation, use transformOperationWithPrimitive instead.
|
|
28
|
+
*
|
|
29
|
+
* The key principle: client ops "shadow" server ops for the same path,
|
|
30
|
+
* meaning if both touch the same field, the client's intention wins
|
|
31
|
+
* (since it was made with knowledge of the server state at that time).
|
|
32
|
+
*/
|
|
33
|
+
declare const transformOperation: (clientOp: Operation<any, any, any>, serverOp: Operation<any, any, any>) => TransformResult;
|
|
34
|
+
/**
|
|
35
|
+
* Transforms all operations in a client transaction against a server transaction.
|
|
36
|
+
* Uses the primitive's transformOperation for schema-aware transformation.
|
|
37
|
+
*/
|
|
38
|
+
declare const transformTransactionWithPrimitive: (clientTx: Transaction, serverTx: Transaction, primitive: AnyPrimitive) => Transaction;
|
|
39
|
+
/**
|
|
40
|
+
* Transforms all operations in a client transaction against a server transaction.
|
|
41
|
+
* This is a standalone version that doesn't require a primitive.
|
|
42
|
+
*/
|
|
43
|
+
declare const transformTransaction: (clientTx: Transaction, serverTx: Transaction) => Transaction;
|
|
44
|
+
/**
|
|
45
|
+
* Rebases a list of pending transactions against a server transaction using a primitive.
|
|
46
|
+
*
|
|
47
|
+
* This is called when a server transaction arrives that is NOT one of our pending
|
|
48
|
+
* transactions. We need to transform all pending transactions to work correctly
|
|
49
|
+
* on top of the new server state.
|
|
50
|
+
*/
|
|
51
|
+
declare const rebasePendingTransactionsWithPrimitive: (pendingTxs: ReadonlyArray<Transaction>, serverTx: Transaction, primitive: AnyPrimitive) => Transaction[];
|
|
52
|
+
/**
|
|
53
|
+
* Rebases a list of pending transactions against a server transaction.
|
|
54
|
+
*
|
|
55
|
+
* This is called when a server transaction arrives that is NOT one of our pending
|
|
56
|
+
* transactions. We need to transform all pending transactions to work correctly
|
|
57
|
+
* on top of the new server state.
|
|
58
|
+
*/
|
|
59
|
+
declare const rebasePendingTransactions: (pendingTxs: ReadonlyArray<Transaction>, serverTx: Transaction) => Transaction[];
|
|
60
|
+
/**
|
|
61
|
+
* Rebases pending transactions after a rejection using a primitive.
|
|
62
|
+
*
|
|
63
|
+
* When a transaction is rejected, we need to re-transform remaining pending
|
|
64
|
+
* transactions as if the rejected transaction never happened. This is done by
|
|
65
|
+
* rebuilding from the original operations against the current server state.
|
|
66
|
+
*
|
|
67
|
+
* @param originalPendingTxs - The original pending transactions before any rebasing
|
|
68
|
+
* @param rejectedTxId - ID of the rejected transaction
|
|
69
|
+
* @param serverTxsSinceOriginal - Server transactions that have arrived since original
|
|
70
|
+
* @param primitive - The root primitive to use for transformation
|
|
71
|
+
*/
|
|
72
|
+
declare const rebaseAfterRejectionWithPrimitive: (originalPendingTxs: ReadonlyArray<Transaction>, rejectedTxId: string, serverTxsSinceOriginal: ReadonlyArray<Transaction>, primitive: AnyPrimitive) => Transaction[];
|
|
73
|
+
/**
|
|
74
|
+
* Rebases pending transactions after a rejection.
|
|
75
|
+
*
|
|
76
|
+
* When a transaction is rejected, we need to re-transform remaining pending
|
|
77
|
+
* transactions as if the rejected transaction never happened. This is done by
|
|
78
|
+
* rebuilding from the original operations against the current server state.
|
|
79
|
+
*
|
|
80
|
+
* @param originalPendingTxs - The original pending transactions before any rebasing
|
|
81
|
+
* @param rejectedTxId - ID of the rejected transaction
|
|
82
|
+
* @param serverTxsSinceOriginal - Server transactions that have arrived since original
|
|
83
|
+
*/
|
|
84
|
+
declare const rebaseAfterRejection: (originalPendingTxs: ReadonlyArray<Transaction>, rejectedTxId: string, serverTxsSinceOriginal: ReadonlyArray<Transaction>) => Transaction[];
|
|
85
|
+
//#endregion
|
|
86
|
+
export { Rebase_d_exports };
|
|
87
|
+
//# sourceMappingURL=Rebase.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Rebase.d.cts","names":[],"sources":["../../src/client/Rebase.ts"],"sourcesContent":[],"mappings":";;;;;;;;;KAUY,eAAA,GAAkB;;;;;;;;;;;;cAiBjB,4CACD,oCACA,qCACC,iBACV;;AArBH;AAiBA;;;;;;AAkBA;;AAEY,cAFC,kBAED,EAAA,CAAA,QAAA,EADA,SACA,CAAA,GAAA,EAAA,GAAA,EAAA,GAAA,CAAA,EAAA,QAAA,EAAA,SAAA,CAAA,GAAA,EAAA,GAAA,EAAA,GAAA,CAAA,EAAA,GACT,eADS;;;AA6EZ;;AAEY,cAFC,iCAED,EAAA,CAAA,QAAA,EADA,WACA,EAAA,QAAA,EAAA,WAAA,EAAA,SAAA,EACC,YADD,EAAA,GAET,WAFS;;;;AA6CZ;AACY,cADC,oBACD,EAAA,CAAA,QAAA,EAAA,WAAA,EAAA,QAAA,EACA,WADA,EAAA,GAET,WAFS;;;;AAgDZ;;;;AAGa,cAHA,sCAGA,EAAA,CAAA,UAAA,EAFC,aAED,CAFe,WAEf,CAAA,EAAA,QAAA,EADD,WACC,EAAA,SAAA,EAAA,YAAA,EAAA,GACV,WADU,EAAA;;;AAcb;;;;;AAG0B,cAHb,yBAGa,EAAA,CAAA,UAAA,EAFZ,aAEY,CAFE,WAEF,CAAA,EAAA,QAAA,EADd,WACc,EAAA,GAAvB,WAAuB,EAAA;AAkB1B;;;;;;;;AAgCA;;;;AAG0B,cAnCb,iCAmCa,EAAA,CAAA,kBAAA,EAlCJ,aAkCI,CAlCU,WAkCV,CAAA,EAAA,YAAA,EAAA,MAAA,EAAA,sBAAA,EAhCA,aAgCA,CAhCc,WAgCd,CAAA,EAAA,SAAA,EA/Bb,YA+Ba,EAAA,GA9BvB,WA8BuB,EAAA;;;;;;;;;;;;cAHb,2CACS,cAAc,4DAEV,cAAc,iBACrC"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { Operation } from "../Operation.mjs";
|
|
2
|
+
import { Transaction } from "../Transaction.mjs";
|
|
3
|
+
import { TransformResult as TransformResult$1 } from "../Transform.mjs";
|
|
4
|
+
import { AnyPrimitive } from "../primitives/shared.mjs";
|
|
5
|
+
import "../Primitive.mjs";
|
|
6
|
+
|
|
7
|
+
//#region src/client/Rebase.d.ts
|
|
8
|
+
declare namespace Rebase_d_exports {
|
|
9
|
+
export { TransformResult, rebaseAfterRejection, rebaseAfterRejectionWithPrimitive, rebasePendingTransactions, rebasePendingTransactionsWithPrimitive, transformOperation, transformOperationWithPrimitive, transformTransaction, transformTransactionWithPrimitive };
|
|
10
|
+
}
|
|
11
|
+
type TransformResult = TransformResult$1;
|
|
12
|
+
/**
|
|
13
|
+
* Transforms a client operation against a server operation using a primitive.
|
|
14
|
+
*
|
|
15
|
+
* This delegates to the primitive's transformOperation method, which handles
|
|
16
|
+
* type-specific conflict resolution.
|
|
17
|
+
*
|
|
18
|
+
* @param clientOp - The client's operation to transform
|
|
19
|
+
* @param serverOp - The server's operation that has already been applied
|
|
20
|
+
* @param primitive - The root primitive to use for transformation
|
|
21
|
+
* @returns TransformResult indicating how the client operation should be handled
|
|
22
|
+
*/
|
|
23
|
+
declare const transformOperationWithPrimitive: (clientOp: Operation<any, any, any>, serverOp: Operation<any, any, any>, primitive: AnyPrimitive) => TransformResult;
|
|
24
|
+
/**
|
|
25
|
+
* Transforms a client operation against a server operation.
|
|
26
|
+
*
|
|
27
|
+
* This is a standalone implementation for cases where the primitive is not available.
|
|
28
|
+
* For schema-aware transformation, use transformOperationWithPrimitive instead.
|
|
29
|
+
*
|
|
30
|
+
* The key principle: client ops "shadow" server ops for the same path,
|
|
31
|
+
* meaning if both touch the same field, the client's intention wins
|
|
32
|
+
* (since it was made with knowledge of the server state at that time).
|
|
33
|
+
*/
|
|
34
|
+
declare const transformOperation: (clientOp: Operation<any, any, any>, serverOp: Operation<any, any, any>) => TransformResult;
|
|
35
|
+
/**
|
|
36
|
+
* Transforms all operations in a client transaction against a server transaction.
|
|
37
|
+
* Uses the primitive's transformOperation for schema-aware transformation.
|
|
38
|
+
*/
|
|
39
|
+
declare const transformTransactionWithPrimitive: (clientTx: Transaction, serverTx: Transaction, primitive: AnyPrimitive) => Transaction;
|
|
40
|
+
/**
|
|
41
|
+
* Transforms all operations in a client transaction against a server transaction.
|
|
42
|
+
* This is a standalone version that doesn't require a primitive.
|
|
43
|
+
*/
|
|
44
|
+
declare const transformTransaction: (clientTx: Transaction, serverTx: Transaction) => Transaction;
|
|
45
|
+
/**
|
|
46
|
+
* Rebases a list of pending transactions against a server transaction using a primitive.
|
|
47
|
+
*
|
|
48
|
+
* This is called when a server transaction arrives that is NOT one of our pending
|
|
49
|
+
* transactions. We need to transform all pending transactions to work correctly
|
|
50
|
+
* on top of the new server state.
|
|
51
|
+
*/
|
|
52
|
+
declare const rebasePendingTransactionsWithPrimitive: (pendingTxs: ReadonlyArray<Transaction>, serverTx: Transaction, primitive: AnyPrimitive) => Transaction[];
|
|
53
|
+
/**
|
|
54
|
+
* Rebases a list of pending transactions against a server transaction.
|
|
55
|
+
*
|
|
56
|
+
* This is called when a server transaction arrives that is NOT one of our pending
|
|
57
|
+
* transactions. We need to transform all pending transactions to work correctly
|
|
58
|
+
* on top of the new server state.
|
|
59
|
+
*/
|
|
60
|
+
declare const rebasePendingTransactions: (pendingTxs: ReadonlyArray<Transaction>, serverTx: Transaction) => Transaction[];
|
|
61
|
+
/**
|
|
62
|
+
* Rebases pending transactions after a rejection using a primitive.
|
|
63
|
+
*
|
|
64
|
+
* When a transaction is rejected, we need to re-transform remaining pending
|
|
65
|
+
* transactions as if the rejected transaction never happened. This is done by
|
|
66
|
+
* rebuilding from the original operations against the current server state.
|
|
67
|
+
*
|
|
68
|
+
* @param originalPendingTxs - The original pending transactions before any rebasing
|
|
69
|
+
* @param rejectedTxId - ID of the rejected transaction
|
|
70
|
+
* @param serverTxsSinceOriginal - Server transactions that have arrived since original
|
|
71
|
+
* @param primitive - The root primitive to use for transformation
|
|
72
|
+
*/
|
|
73
|
+
declare const rebaseAfterRejectionWithPrimitive: (originalPendingTxs: ReadonlyArray<Transaction>, rejectedTxId: string, serverTxsSinceOriginal: ReadonlyArray<Transaction>, primitive: AnyPrimitive) => Transaction[];
|
|
74
|
+
/**
|
|
75
|
+
* Rebases pending transactions after a rejection.
|
|
76
|
+
*
|
|
77
|
+
* When a transaction is rejected, we need to re-transform remaining pending
|
|
78
|
+
* transactions as if the rejected transaction never happened. This is done by
|
|
79
|
+
* rebuilding from the original operations against the current server state.
|
|
80
|
+
*
|
|
81
|
+
* @param originalPendingTxs - The original pending transactions before any rebasing
|
|
82
|
+
* @param rejectedTxId - ID of the rejected transaction
|
|
83
|
+
* @param serverTxsSinceOriginal - Server transactions that have arrived since original
|
|
84
|
+
*/
|
|
85
|
+
declare const rebaseAfterRejection: (originalPendingTxs: ReadonlyArray<Transaction>, rejectedTxId: string, serverTxsSinceOriginal: ReadonlyArray<Transaction>) => Transaction[];
|
|
86
|
+
//#endregion
|
|
87
|
+
export { Rebase_d_exports };
|
|
88
|
+
//# sourceMappingURL=Rebase.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Rebase.d.mts","names":[],"sources":["../../src/client/Rebase.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;KAUY,eAAA,GAAkB;;;;;;;;;;;;cAiBjB,4CACD,oCACA,qCACC,iBACV;;;AArBH;AAiBA;;;;;;AAkBA;AACY,cADC,kBACD,EAAA,CAAA,QAAA,EAAA,SAAA,CAAA,GAAA,EAAA,GAAA,EAAA,GAAA,CAAA,EAAA,QAAA,EACA,SADA,CAAA,GAAA,EAAA,GAAA,EAAA,GAAA,CAAA,EAAA,GAET,eAFS;;;;AA8EZ;AACY,cADC,iCACD,EAAA,CAAA,QAAA,EAAA,WAAA,EAAA,QAAA,EACA,WADA,EAAA,SAAA,EAEC,YAFD,EAAA,GAGT,WAHS;;;;;AA8CC,cAAA,oBAwCZ,EAAA,CAAA,QAAA,EAvCW,WAuCX,EAAA,QAAA,EAtCW,WAsCX,EAAA,GArCE,WAqCF;;;;;AASD;;;AAEY,cAFC,sCAED,EAAA,CAAA,UAAA,EADE,aACF,CADgB,WAChB,CAAA,EAAA,QAAA,EAAA,WAAA,EAAA,SAAA,EACC,YADD,EAAA,GAET,WAFS,EAAA;;;;AAeZ;;;;AAGG,cAHU,yBAGV,EAAA,CAAA,UAAA,EAFW,aAEX,CAFyB,WAEzB,CAAA,EAAA,QAAA,EADS,WACT,EAAA,GAAA,WAAA,EAAA;;AAkBH;;;;;;;;AAgCA;;;AAGwC,cAnC3B,iCAmC2B,EAAA,CAAA,kBAAA,EAlClB,aAkCkB,CAlCJ,WAkCI,CAAA,EAAA,YAAA,EAAA,MAAA,EAAA,sBAAA,EAhCd,aAgCc,CAhCA,WAgCA,CAAA,EAAA,SAAA,EA/B3B,YA+B2B,EAAA,GA9BrC,WA8BqC,EAAA;;;;;;;;;;;;cAH3B,2CACS,cAAc,4DAEV,cAAc,iBACrC"}
|