rune-langium / visual-editor/src / useModelSourceSync
Function: useModelSourceSync()
ts
function useModelSourceSync(
nodes,
edges,
onModelChanged?,
parseEpoch?,
patches?,
originalSourceByNamespace?,
inversePatches?,
sourceFiles?,
editStore?
): SourceSyncHandle;Defined in: packages/visual-editor/src/hooks/useModelSourceSync.ts:331
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
nodes | TypeGraphNode[] | undefined | - |
edges | TypeGraphEdge[] | undefined | - |
onModelChanged? | (serialized) => void | Promise<void> | undefined | - |
parseEpoch? | number | 0 | The editor store's parseEpoch advances when the graph is rebuilt from source. A pure parse adopts its source baseline without writing it back. Pending user patches made after that parse still publish, even before React adopts the new epoch. Optional/defaulted for controlled callers without an editor store. |
patches? | Patches | [] | The store's accumulated Mutative patches since the last parse. Drives the CST-reuse dirty set: only nodes/subtrees touched by a patch are regenerated; everything else is sliced verbatim from originalSourceByNamespace. |
originalSourceByNamespace? | Map<string, string> | ... | Original source text keyed by namespace name — used as the CST baseline for the reuse serializer. Built by the caller from the current workspace files. Defaults to an empty map so legacy/test callers that don't supply it get an empty output (no write-back). |
inversePatches? | Patches | [] | The store's accumulated Mutative INVERSE patches since the last parse. Used to derive the source byte ranges of genuinely-deleted elements so those ranges are omitted from the assembled output. Defaults to [] so legacy/test callers without deletion support keep the old behavior. |
sourceFiles? | ReadonlyMap<string, SourceSyncFile> | undefined | - |
editStore? | Pick<StoreApi<EditorState>, "subscribe"> | undefined | Capture user edits synchronously before an in-flight parse can consume their patches. |