logo
  • Docs
  • API Reference
    Overview
    Functions
    acceptChangeProposal
    applyChangeSet
    attachConversation
    attachLabel
    commitIsAncestorOf
    commitIsDescendantOf
    createAccount
    createChangeProposal
    createChangeSet
    createCheckpoint
    createConversation
    createConversationMessage
    createHooks
    createLabel
    createLog
    createLspInMemoryEnvironment
    createQuerySync
    createServerProtocolHandler
    createVersion
    createVersionFromCommit
    detachConversation
    detachLabel
    ebEntity
    getTimestamp
    humanId
    mergeVersion
    nanoId
    newLixFile
    nextSequenceNumber
    normalizeDirectoryPath
    normalizeFilePath
    normalizePathSegment
    openLix
    random
    rejectChangeProposal
    selectCommitDiff
    selectVersionDiff
    selectWorkingDiff
    switchAccount
    switchVersion
    transition
    uuidV7
    uuidV7Sync
    validateLixSchema
    validateLixSchemaDefinition
    withWriterKey
    Type Aliases
    Account
    ActiveAccount
    Change
    ChangeAuthor
    DetectedChange
    EntityStateByVersionView
    EntityStateHistoryView
    EntityStateView
    EnvironmentActorHandle
    FromLixSchemaDefinition
    JSONType
    Lix
    LixActiveVersion
    LixChangeProposal
    LixChangeSet
    LixChangeSetElement
    LixCommit
    LixCommitEdge
    LixConversation
    LixConversationMessage
    LixDatabaseSchema
    LixDirectoryDescriptor
    LixEntity
    LixEntityCanonical
    LixEntityConversation
    LixEntityLabel
    LixFile
    LixFileDescriptor
    LixGenerated
    LixHooks
    LixInsertable
    LixKeyValue
    LixLabel
    LixLog
    LixPlugin
    LixSchemaDefinition
    LixSelectable
    LixServerProtocolHandlerContext
    LixUpdateable
    LixVersion
    LixVersionDescriptor
    LixVersionTip
    NewChange
    NewState
    NewStateByVersion
    NewStateByVersionRow
    NewStateRow
    QuerySync
    RenderDiffArgs
    SpawnActorOptions
    State
    StateByVersion
    StateByVersionRow
    StateByVersionRowUpdate
    StateByVersionUpdate
    StateByVersionView
    StateCommitChange
    StateHistory
    StateRow
    StateRowUpdate
    StateUpdate
    StateView
    StateWithTombstonesRow
    StateWithTombstonesView
    StoredSchema
    ToKysely
    Variables
    JSONTypeSchema
    LixAccountSchema
    LixActiveAccountSchema
    LixActiveVersionSchema
    LixChangeAuthorSchema
    LixChangeProposalSchema
    LixChangeSetElementSchema
    LixChangeSetSchema
    LixCommitEdgeSchema
    LixCommitSchema
    LixConversationMessageSchema
    LixConversationSchema
    LixDirectoryDescriptorSchema
    LixFileDescriptorSchema
    LixKeyValueSchema
    LixLabelSchema
    LixLogSchema
    LixSchemaDefinition
    LixStoredSchemaSchema
    LixVersionDescriptorSchema
    LixVersionTipSchema
    mockJsonPlugin
    Classes
    InMemoryEnvironment
    LixObservable
    OpfsSahEnvironment
    Interfaces
    LixEnvironment
    Previous pageLixLogNext pageLixSchemaDefinition

    #Type Alias: LixPlugin

    LixPlugin = { applyChanges?: ({ file, changes, }: { changes: Change[]; file: Omit<LixFile, "data"> & { data?: Uint8Array; }; }) => { fileData: Uint8Array; }; detectChanges?: ({ before, after, querySync, }: { after: Omit<LixFile, "data"> & { data: Uint8Array; }; before?: Omit<LixFile, "data"> & { data?: Uint8Array; }; querySync: QuerySync; }) => DetectedChange[]; detectChangesGlob?: string; key: string; renderDiff?: (args: RenderDiffArgs) => Promise<string>; }

    #Properties

    #applyChanges()?

    optional applyChanges: ({ file, changes, }: { changes: Change[]; file: Omit<LixFile, "data"> & { data?: Uint8Array; }; }) => { fileData: Uint8Array; }

    #Parameters

    ParameterTypeDescription
    { file, changes, }{ changes: Change[]; file: Omit<LixFile, "data"> & { data?: Uint8Array; }; }-
    { file, changes, }.changesChange[]-
    { file, changes, }.fileOmit<LixFile, "data"> & { data?: Uint8Array; }The file to which the changes should be applied. The file.data might be undefined if the file does not exist at the time of applying the changes. This can happen when merging a version that created a new file that did not exist in the target version. Or, a file has been deleted and should be restored at a later point.

    #Returns

    { fileData: Uint8Array; }

    #fileData

    fileData: Uint8Array


    #detectChanges()?

    optional detectChanges: ({ before, after, querySync, }: { after: Omit<LixFile, "data"> & { data: Uint8Array; }; before?: Omit<LixFile, "data"> & { data?: Uint8Array; }; querySync: QuerySync; }) => DetectedChange[]

    Detects changes between the before and after file update(s).

    Before is undefined if the file did not exist before ( the file was created).

    After is always defined. Either the file was updated, or deleted. If the file is deleted, lix own change control will handle the deletion. Hence, after is always be defined.

    #Parameters

    ParameterTypeDescription
    { before, after, querySync, }{ after: Omit<LixFile, "data"> & { data: Uint8Array; }; before?: Omit<LixFile, "data"> & { data?: Uint8Array; }; querySync: QuerySync; }-
    { before, after, querySync, }.afterOmit<LixFile, "data"> & { data: Uint8Array; }-
    { before, after, querySync, }.before?Omit<LixFile, "data"> & { data?: Uint8Array; }-
    { before, after, querySync, }.querySyncQuerySyncBuild synchronous SQL queries. Detecting changes can require reading current state to preserve stable entity ids, compare snapshots, or infer ordering without reparsing files. Why is a sync possible and allowed? The engine can run in a separate thread/process. SQLite executes queries synchronously and the engine cannot await async calls to the host thread during detectChanges(). querySync provides a Kysely builder whose .execute() runs synchronously inside the engine. Example detectChanges: ({ after, querySync }) => { const rows = querySync('state') .where('file_id', '=', after.id) .where('plugin_key', '=', 'plugin_md') .select(['entity_id', 'schema_key', 'snapshot_content']) .execute() const latestById = new Map(rows.map(r => [r.entity_id, r])) // ...use latestById to assign/reuse ids in emitted changes... return [] }

    #Returns

    DetectedChange[]


    #detectChangesGlob?

    optional detectChangesGlob: string

    The glob pattern that should invoke detectChanges().

    #Example

    `**/*.json` for all JSON files
      `**/*.inlang` for all inlang files

    #key

    key: string


    #renderDiff()?

    optional renderDiff: (args: RenderDiffArgs) => Promise<string>

    Render the diff for this plugin as HTML.

    Hosts can insert the returned markup directly or scope it inside a ShadowRoot. The HTML should rely on CSS custom properties (e.g. --lix-diff-*) instead of hardcoded colors so environments can theme it.

    #Example

    const html = await plugin.renderDiff?.({ diffs })
    container.innerHTML = html ?? ""

    #Parameters

    ParameterType
    argsRenderDiffArgs

    #Returns

    Promise<string>