()
| 300 | } |
| 301 | |
| 302 | const runObserverASyncImpl = (): void => { |
| 303 | try { |
| 304 | const json = yXmlFragmentToProseMirrorRootNode(xmlFragment, schema).toJSON(); |
| 305 | const body = mdManager.serialize(json); |
| 306 | const frontmatter = readCurrentFm(); |
| 307 | const md = prependFrontmatter(frontmatter, body); |
| 308 | |
| 309 | if (canonicalWitnessCoherent && lastSyncedCanonicalMd === md) { |
| 310 | if (settlesSplitBrain(ytext.toString(), md)) { |
| 311 | recordDivergedAttachBaselines(md); |
| 312 | textDirty = true; |
| 313 | recordSplitBrainRederive('identity-gate'); |
| 314 | setActiveSpanAttributes({ 'observer.a.path': 'gated-fragment-unchanged-rederive' }); |
| 315 | } else { |
| 316 | setActiveSpanAttributes({ 'observer.a.path': 'gated-fragment-unchanged' }); |
| 317 | } |
| 318 | return; |
| 319 | } |
| 320 | |
| 321 | const currentText = ytext.toString(); |
| 322 | |
| 323 | const normCurrent = normalizeBridge(currentText); |
| 324 | const normMd = normalizeBridge(md); |
| 325 | if (normCurrent === normMd) { |
| 326 | setActiveSpanAttributes({ 'observer.a.path': 'gated-in-sync' }); |
| 327 | recordSettledBaselines(md); |
| 328 | return; |
| 329 | } |
| 330 | |
| 331 | const preMergeBaseline = lastSyncedYTextBytes; |
| 332 | const ytextInSync = currentText === lastSyncedYTextBytes; |
| 333 | const residualMergeEligible = |
| 334 | ytextInSync && |
| 335 | canonicalWitnessCoherent && |
| 336 | lastSyncedYTextBytes !== lastSyncedCanonicalMd && |
| 337 | normCurrent !== normalizeBridge(lastSyncedCanonicalMd); |
| 338 | setActiveSpanAttributes({ |
| 339 | 'observer.a.path': ytextInSync |
| 340 | ? residualMergeEligible |
| 341 | ? 'residual-merge' |
| 342 | : 'path-a' |
| 343 | : 'path-b', |
| 344 | }); |
| 345 | const pathBState: { mergedText: string | null } = { mergedText: null }; |
| 346 | |
| 347 | const spliceComputeStart = performance.now(); |
| 348 | const mapDrivenSplice = |
| 349 | ytextInSync && residualMergeEligible |
| 350 | ? null |
| 351 | : tryComputeMapDrivenSplice({ |
| 352 | currentText, |
| 353 | lastSyncedXmlMd: lastSyncedYTextBytes, |
| 354 | json, |
| 355 | mdManager, |
| 356 | docName: opts.docName, |
| 357 | }); |
| 358 | if (mapDrivenSplice) { |
| 359 | setActiveSpanAttributes({ |
nothing calls this directly
no test coverage detected