@hydranium/core 1.0.0-next.37 → 1.0.0-next.371

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.
Files changed (798) hide show
  1. package/README.md +78 -82
  2. package/lib/browser/host-heads-in-worker.d.ts +77 -0
  3. package/lib/browser/host-heads-in-worker.d.ts.map +1 -0
  4. package/lib/browser/host-heads-in-worker.js +169 -0
  5. package/lib/browser/host-heads-in-worker.js.map +1 -0
  6. package/lib/browser/index.d.ts +12 -0
  7. package/lib/browser/index.d.ts.map +1 -0
  8. package/lib/browser/index.js +17 -0
  9. package/lib/browser/index.js.map +1 -0
  10. package/lib/browser/indexeddb-file-system-store.d.ts +82 -0
  11. package/lib/browser/indexeddb-file-system-store.d.ts.map +1 -0
  12. package/lib/browser/indexeddb-file-system-store.js +181 -0
  13. package/lib/browser/indexeddb-file-system-store.js.map +1 -0
  14. package/lib/browser/start-language-server-in-worker.d.ts +32 -0
  15. package/lib/browser/start-language-server-in-worker.d.ts.map +1 -0
  16. package/lib/browser/start-language-server-in-worker.js +40 -0
  17. package/lib/browser/start-language-server-in-worker.js.map +1 -0
  18. package/lib/documents/ast-document-manager.d.ts +254 -140
  19. package/lib/documents/ast-document-manager.d.ts.map +1 -1
  20. package/lib/documents/ast-document-manager.js +311 -127
  21. package/lib/documents/ast-document-manager.js.map +1 -1
  22. package/lib/documents/client-ids.d.ts +5 -19
  23. package/lib/documents/client-ids.d.ts.map +1 -1
  24. package/lib/documents/client-ids.js +5 -19
  25. package/lib/documents/client-ids.js.map +1 -1
  26. package/lib/documents/client-session-errors.d.ts +15 -0
  27. package/lib/documents/client-session-errors.d.ts.map +1 -0
  28. package/lib/documents/client-session-errors.js +15 -0
  29. package/lib/documents/client-session-errors.js.map +1 -0
  30. package/lib/documents/client-session-registry.d.ts +146 -0
  31. package/lib/documents/client-session-registry.d.ts.map +1 -0
  32. package/lib/documents/client-session-registry.js +207 -0
  33. package/lib/documents/client-session-registry.js.map +1 -0
  34. package/lib/documents/dirty-state-tracker.d.ts +101 -0
  35. package/lib/documents/dirty-state-tracker.d.ts.map +1 -0
  36. package/lib/documents/dirty-state-tracker.js +85 -0
  37. package/lib/documents/dirty-state-tracker.js.map +1 -0
  38. package/lib/documents/document-release-handler.d.ts +204 -0
  39. package/lib/documents/document-release-handler.d.ts.map +1 -0
  40. package/lib/documents/document-release-handler.js +317 -0
  41. package/lib/documents/document-release-handler.js.map +1 -0
  42. package/lib/documents/document-release-scheduler.d.ts +67 -0
  43. package/lib/documents/document-release-scheduler.d.ts.map +1 -0
  44. package/lib/documents/document-release-scheduler.js +80 -0
  45. package/lib/documents/document-release-scheduler.js.map +1 -0
  46. package/lib/documents/file-system-task-queue.d.ts +52 -0
  47. package/lib/documents/file-system-task-queue.d.ts.map +1 -0
  48. package/lib/documents/file-system-task-queue.js +37 -0
  49. package/lib/documents/file-system-task-queue.js.map +1 -0
  50. package/lib/documents/hydranium-text-documents.d.ts +445 -282
  51. package/lib/documents/hydranium-text-documents.d.ts.map +1 -1
  52. package/lib/documents/hydranium-text-documents.js +903 -483
  53. package/lib/documents/hydranium-text-documents.js.map +1 -1
  54. package/lib/documents/index.d.ts +10 -2
  55. package/lib/documents/index.d.ts.map +1 -1
  56. package/lib/documents/index.js +10 -2
  57. package/lib/documents/index.js.map +1 -1
  58. package/lib/documents/language-client-shadow.d.ts +234 -0
  59. package/lib/documents/language-client-shadow.d.ts.map +1 -0
  60. package/lib/documents/language-client-shadow.js +306 -0
  61. package/lib/documents/language-client-shadow.js.map +1 -0
  62. package/lib/documents/model-ledger.d.ts +47 -0
  63. package/lib/documents/model-ledger.d.ts.map +1 -0
  64. package/lib/documents/model-ledger.js +30 -0
  65. package/lib/documents/model-ledger.js.map +1 -0
  66. package/lib/documents/text-ledger.d.ts +64 -0
  67. package/lib/documents/text-ledger.d.ts.map +1 -0
  68. package/lib/documents/text-ledger.js +63 -0
  69. package/lib/documents/text-ledger.js.map +1 -0
  70. package/lib/documents/version-sync-service.d.ts +138 -0
  71. package/lib/documents/version-sync-service.d.ts.map +1 -0
  72. package/lib/documents/version-sync-service.js +173 -0
  73. package/lib/documents/version-sync-service.js.map +1 -0
  74. package/lib/index.d.ts +3 -0
  75. package/lib/index.d.ts.map +1 -1
  76. package/lib/index.js +3 -0
  77. package/lib/index.js.map +1 -1
  78. package/lib/langium/ast-extension/ast-extension-service.d.ts +42 -31
  79. package/lib/langium/ast-extension/ast-extension-service.d.ts.map +1 -1
  80. package/lib/langium/ast-extension/ast-extension-service.js +45 -19
  81. package/lib/langium/ast-extension/ast-extension-service.js.map +1 -1
  82. package/lib/langium/ast-extension/ast-node-builder.d.ts +12 -7
  83. package/lib/langium/ast-extension/ast-node-builder.d.ts.map +1 -1
  84. package/lib/langium/ast-extension/ast-node-builder.js +25 -9
  85. package/lib/langium/ast-extension/ast-node-builder.js.map +1 -1
  86. package/lib/langium/bootstrap.d.ts +49 -36
  87. package/lib/langium/bootstrap.d.ts.map +1 -1
  88. package/lib/langium/bootstrap.js +75 -36
  89. package/lib/langium/bootstrap.js.map +1 -1
  90. package/lib/langium/build-phase-pass/build-phase-pass-service.d.ts +9 -9
  91. package/lib/langium/build-phase-pass/build-phase-pass-service.d.ts.map +1 -1
  92. package/lib/langium/build-phase-pass/build-phase-pass-service.js +25 -16
  93. package/lib/langium/build-phase-pass/build-phase-pass-service.js.map +1 -1
  94. package/lib/langium/build-phase-pass/build-phase-pass.d.ts +20 -8
  95. package/lib/langium/build-phase-pass/build-phase-pass.d.ts.map +1 -1
  96. package/lib/langium/build-phase-pass/build-phase-pass.js +20 -0
  97. package/lib/langium/build-phase-pass/build-phase-pass.js.map +1 -1
  98. package/lib/langium/composite-ast-reflection.d.ts +46 -0
  99. package/lib/langium/composite-ast-reflection.d.ts.map +1 -0
  100. package/lib/langium/composite-ast-reflection.js +97 -0
  101. package/lib/langium/composite-ast-reflection.js.map +1 -0
  102. package/lib/langium/config/configuration-provider.d.ts +81 -0
  103. package/lib/langium/config/configuration-provider.d.ts.map +1 -0
  104. package/lib/langium/config/configuration-provider.js +112 -0
  105. package/lib/langium/config/configuration-provider.js.map +1 -0
  106. package/lib/langium/config/index.d.ts +1 -0
  107. package/lib/langium/config/index.d.ts.map +1 -1
  108. package/lib/langium/config/index.js +1 -0
  109. package/lib/langium/config/index.js.map +1 -1
  110. package/lib/langium/config/settings.js.map +1 -1
  111. package/lib/langium/diagnostics/console-tee.d.ts +27 -0
  112. package/lib/langium/diagnostics/console-tee.d.ts.map +1 -0
  113. package/lib/langium/diagnostics/console-tee.js +141 -0
  114. package/lib/langium/diagnostics/console-tee.js.map +1 -0
  115. package/lib/langium/diagnostics/hydranium-langium-profiler.d.ts +9 -20
  116. package/lib/langium/diagnostics/hydranium-langium-profiler.d.ts.map +1 -1
  117. package/lib/langium/diagnostics/hydranium-langium-profiler.js +15 -24
  118. package/lib/langium/diagnostics/hydranium-langium-profiler.js.map +1 -1
  119. package/lib/langium/diagnostics/log-preamble.js +1 -1
  120. package/lib/langium/diagnostics/log-preamble.js.map +1 -1
  121. package/lib/langium/diagnostics/logger.d.ts +25 -6
  122. package/lib/langium/diagnostics/logger.d.ts.map +1 -1
  123. package/lib/langium/diagnostics/logger.js +49 -17
  124. package/lib/langium/diagnostics/logger.js.map +1 -1
  125. package/lib/langium/diagnostics/lsp-logger.d.ts +25 -0
  126. package/lib/langium/diagnostics/lsp-logger.d.ts.map +1 -1
  127. package/lib/langium/diagnostics/lsp-logger.js +81 -46
  128. package/lib/langium/diagnostics/lsp-logger.js.map +1 -1
  129. package/lib/langium/diagnostics/server-tracer.d.ts.map +1 -1
  130. package/lib/langium/diagnostics/server-tracer.js.map +1 -1
  131. package/lib/langium/document-builder/build-pipeline-integration.d.ts +21 -1
  132. package/lib/langium/document-builder/build-pipeline-integration.d.ts.map +1 -1
  133. package/lib/langium/document-builder/build-pipeline-integration.js +43 -30
  134. package/lib/langium/document-builder/build-pipeline-integration.js.map +1 -1
  135. package/lib/langium/document-builder/build-session.d.ts +6 -5
  136. package/lib/langium/document-builder/build-session.d.ts.map +1 -1
  137. package/lib/langium/document-builder/build-session.js +5 -5
  138. package/lib/langium/document-builder/build-session.js.map +1 -1
  139. package/lib/langium/document-builder/document-builder.d.ts +340 -39
  140. package/lib/langium/document-builder/document-builder.d.ts.map +1 -1
  141. package/lib/langium/document-builder/document-builder.js +550 -81
  142. package/lib/langium/document-builder/document-builder.js.map +1 -1
  143. package/lib/langium/documentation/comment-provider.d.ts.map +1 -1
  144. package/lib/langium/documentation/comment-provider.js.map +1 -1
  145. package/lib/langium/integration-services.d.ts +39 -23
  146. package/lib/langium/integration-services.d.ts.map +1 -1
  147. package/lib/langium/integration-services.js +7 -4
  148. package/lib/langium/integration-services.js.map +1 -1
  149. package/lib/langium/integrity/integrity-rule.d.ts +17 -8
  150. package/lib/langium/integrity/integrity-rule.d.ts.map +1 -1
  151. package/lib/langium/integrity/integrity-rule.js.map +1 -1
  152. package/lib/langium/integrity/integrity-service.d.ts +95 -27
  153. package/lib/langium/integrity/integrity-service.d.ts.map +1 -1
  154. package/lib/langium/integrity/integrity-service.js +303 -63
  155. package/lib/langium/integrity/integrity-service.js.map +1 -1
  156. package/lib/langium/keys/containment.d.ts +3 -2
  157. package/lib/langium/keys/containment.d.ts.map +1 -1
  158. package/lib/langium/keys/containment.js.map +1 -1
  159. package/lib/langium/keys/name-based-key-provider.d.ts +17 -10
  160. package/lib/langium/keys/name-based-key-provider.d.ts.map +1 -1
  161. package/lib/langium/keys/name-based-key-provider.js +24 -12
  162. package/lib/langium/keys/name-based-key-provider.js.map +1 -1
  163. package/lib/langium/keys/positional-key-provider.d.ts.map +1 -1
  164. package/lib/langium/keys/positional-key-provider.js.map +1 -1
  165. package/lib/langium/labeling/label-provider.d.ts.map +1 -1
  166. package/lib/langium/labeling/label-provider.js.map +1 -1
  167. package/lib/langium/language-module.d.ts +30 -5
  168. package/lib/langium/language-module.d.ts.map +1 -1
  169. package/lib/langium/language-module.js +21 -5
  170. package/lib/langium/language-module.js.map +1 -1
  171. package/lib/langium/model-service/client-session.d.ts +383 -0
  172. package/lib/langium/model-service/client-session.d.ts.map +1 -0
  173. package/lib/langium/model-service/client-session.js +455 -0
  174. package/lib/langium/model-service/client-session.js.map +1 -0
  175. package/lib/langium/model-service/index.d.ts +2 -0
  176. package/lib/langium/model-service/index.d.ts.map +1 -1
  177. package/lib/langium/model-service/index.js +2 -0
  178. package/lib/langium/model-service/index.js.map +1 -1
  179. package/lib/langium/model-service/model-events.d.ts +68 -0
  180. package/lib/langium/model-service/model-events.d.ts.map +1 -0
  181. package/lib/langium/model-service/model-events.js +10 -0
  182. package/lib/langium/model-service/model-events.js.map +1 -0
  183. package/lib/langium/model-service/model-service.d.ts +440 -323
  184. package/lib/langium/model-service/model-service.d.ts.map +1 -1
  185. package/lib/langium/model-service/model-service.js +601 -397
  186. package/lib/langium/model-service/model-service.js.map +1 -1
  187. package/lib/langium/module.d.ts +89 -30
  188. package/lib/langium/module.d.ts.map +1 -1
  189. package/lib/langium/module.js +39 -27
  190. package/lib/langium/module.js.map +1 -1
  191. package/lib/langium/naming/name-provider.d.ts +32 -7
  192. package/lib/langium/naming/name-provider.d.ts.map +1 -1
  193. package/lib/langium/naming/name-provider.js +10 -4
  194. package/lib/langium/naming/name-provider.js.map +1 -1
  195. package/lib/langium/naming/name-separator-validation.d.ts.map +1 -1
  196. package/lib/langium/project/abstract-project-manager.d.ts +184 -13
  197. package/lib/langium/project/abstract-project-manager.d.ts.map +1 -1
  198. package/lib/langium/project/abstract-project-manager.js +336 -16
  199. package/lib/langium/project/abstract-project-manager.js.map +1 -1
  200. package/lib/langium/project/project-change-event.d.ts +22 -3
  201. package/lib/langium/project/project-change-event.d.ts.map +1 -1
  202. package/lib/langium/project/project-manager.d.ts +28 -2
  203. package/lib/langium/project/project-manager.d.ts.map +1 -1
  204. package/lib/langium/project/single-project-manager.d.ts +7 -1
  205. package/lib/langium/project/single-project-manager.d.ts.map +1 -1
  206. package/lib/langium/project/single-project-manager.js +12 -0
  207. package/lib/langium/project/single-project-manager.js.map +1 -1
  208. package/lib/langium/residency/cst-residency-service.d.ts +15 -11
  209. package/lib/langium/residency/cst-residency-service.d.ts.map +1 -1
  210. package/lib/langium/residency/cst-residency-service.js +15 -3
  211. package/lib/langium/residency/cst-residency-service.js.map +1 -1
  212. package/lib/langium/scope/ast-node-description-provider.d.ts +46 -10
  213. package/lib/langium/scope/ast-node-description-provider.d.ts.map +1 -1
  214. package/lib/langium/scope/ast-node-description-provider.js +88 -15
  215. package/lib/langium/scope/ast-node-description-provider.js.map +1 -1
  216. package/lib/langium/scope/built-local-symbols.d.ts +12 -0
  217. package/lib/langium/scope/built-local-symbols.d.ts.map +1 -0
  218. package/lib/langium/scope/built-local-symbols.js +11 -0
  219. package/lib/langium/scope/built-local-symbols.js.map +1 -0
  220. package/lib/langium/scope/fallback-scope.d.ts +27 -0
  221. package/lib/langium/scope/fallback-scope.d.ts.map +1 -0
  222. package/lib/langium/scope/fallback-scope.js +35 -0
  223. package/lib/langium/scope/fallback-scope.js.map +1 -0
  224. package/lib/langium/scope/hydranium-scope-computation.d.ts +21 -18
  225. package/lib/langium/scope/hydranium-scope-computation.d.ts.map +1 -1
  226. package/lib/langium/scope/hydranium-scope-computation.js +38 -39
  227. package/lib/langium/scope/hydranium-scope-computation.js.map +1 -1
  228. package/lib/langium/scope/hydranium-scope-provider.d.ts +122 -32
  229. package/lib/langium/scope/hydranium-scope-provider.d.ts.map +1 -1
  230. package/lib/langium/scope/hydranium-scope-provider.js +217 -39
  231. package/lib/langium/scope/hydranium-scope-provider.js.map +1 -1
  232. package/lib/langium/scope/index.d.ts +1 -0
  233. package/lib/langium/scope/index.d.ts.map +1 -1
  234. package/lib/langium/scope/index.js +1 -0
  235. package/lib/langium/scope/index.js.map +1 -1
  236. package/lib/langium/scope/reference-builder.d.ts.map +1 -1
  237. package/lib/langium/scope/reference-builder.js.map +1 -1
  238. package/lib/langium/scope/reference-candidate-provider.d.ts +6 -5
  239. package/lib/langium/scope/reference-candidate-provider.d.ts.map +1 -1
  240. package/lib/langium/scope/reference-candidate-provider.js +3 -2
  241. package/lib/langium/scope/reference-candidate-provider.js.map +1 -1
  242. package/lib/langium/scope/scope-extension-service.d.ts +69 -37
  243. package/lib/langium/scope/scope-extension-service.d.ts.map +1 -1
  244. package/lib/langium/scope/scope-extension-service.js +102 -29
  245. package/lib/langium/scope/scope-extension-service.js.map +1 -1
  246. package/lib/langium/scope/scoped-ast-node-description.d.ts +1 -3
  247. package/lib/langium/scope/scoped-ast-node-description.d.ts.map +1 -1
  248. package/lib/langium/scope/scoped-ast-node-description.js +1 -3
  249. package/lib/langium/scope/scoped-ast-node-description.js.map +1 -1
  250. package/lib/langium/serialization/abstract-serializer.d.ts +38 -27
  251. package/lib/langium/serialization/abstract-serializer.d.ts.map +1 -1
  252. package/lib/langium/serialization/abstract-serializer.js +54 -30
  253. package/lib/langium/serialization/abstract-serializer.js.map +1 -1
  254. package/lib/langium/serialization/json-serializer.d.ts +8 -1
  255. package/lib/langium/serialization/json-serializer.d.ts.map +1 -1
  256. package/lib/langium/serialization/json-serializer.js +13 -3
  257. package/lib/langium/serialization/json-serializer.js.map +1 -1
  258. package/lib/langium/serialization/serializer.d.ts +1 -1
  259. package/lib/langium/serialization/yaml-serializer.d.ts +12 -0
  260. package/lib/langium/serialization/yaml-serializer.d.ts.map +1 -1
  261. package/lib/langium/serialization/yaml-serializer.js +24 -4
  262. package/lib/langium/serialization/yaml-serializer.js.map +1 -1
  263. package/lib/langium/service-registry.d.ts +29 -1
  264. package/lib/langium/service-registry.d.ts.map +1 -1
  265. package/lib/langium/service-registry.js +37 -0
  266. package/lib/langium/service-registry.js.map +1 -1
  267. package/lib/langium/shared-services.d.ts +10 -4
  268. package/lib/langium/shared-services.d.ts.map +1 -1
  269. package/lib/langium/shared-services.js.map +1 -1
  270. package/lib/langium/single-langium-copy.d.ts +22 -0
  271. package/lib/langium/single-langium-copy.d.ts.map +1 -0
  272. package/lib/langium/single-langium-copy.js +36 -0
  273. package/lib/langium/single-langium-copy.js.map +1 -0
  274. package/lib/langium/transfer/transfer-encoder.d.ts +60 -39
  275. package/lib/langium/transfer/transfer-encoder.d.ts.map +1 -1
  276. package/lib/langium/transfer/transfer-encoder.js +35 -24
  277. package/lib/langium/transfer/transfer-encoder.js.map +1 -1
  278. package/lib/langium/trivia/comment-preserver.d.ts +543 -0
  279. package/lib/langium/trivia/comment-preserver.d.ts.map +1 -0
  280. package/lib/langium/trivia/comment-preserver.js +1164 -0
  281. package/lib/langium/trivia/comment-preserver.js.map +1 -0
  282. package/lib/langium/trivia/document-ending-preserver.d.ts +51 -0
  283. package/lib/langium/trivia/document-ending-preserver.d.ts.map +1 -0
  284. package/lib/langium/trivia/document-ending-preserver.js +62 -0
  285. package/lib/langium/trivia/document-ending-preserver.js.map +1 -0
  286. package/lib/langium/trivia/index.d.ts +14 -0
  287. package/lib/langium/trivia/index.d.ts.map +1 -0
  288. package/lib/langium/trivia/index.js +14 -0
  289. package/lib/langium/trivia/index.js.map +1 -0
  290. package/lib/langium/trivia/trivia-contribution.d.ts +37 -0
  291. package/lib/langium/trivia/trivia-contribution.d.ts.map +1 -0
  292. package/lib/langium/trivia/trivia-contribution.js +10 -0
  293. package/lib/langium/trivia/trivia-contribution.js.map +1 -0
  294. package/lib/langium/trivia/trivia-preserver.d.ts +52 -0
  295. package/lib/langium/trivia/trivia-preserver.d.ts.map +1 -0
  296. package/lib/langium/trivia/trivia-preserver.js +10 -0
  297. package/lib/langium/trivia/trivia-preserver.js.map +1 -0
  298. package/lib/langium/trivia/trivia-service.d.ts +70 -0
  299. package/lib/langium/trivia/trivia-service.d.ts.map +1 -0
  300. package/lib/langium/trivia/trivia-service.js +56 -0
  301. package/lib/langium/trivia/trivia-service.js.map +1 -0
  302. package/lib/langium/update-rewrite/normalize-empty-strings.d.ts.map +1 -1
  303. package/lib/langium/update-rewrite/update-rewrite-service.d.ts +1 -1
  304. package/lib/langium/update-rewrite/update-rewrite-service.d.ts.map +1 -1
  305. package/lib/langium/update-rewrite/update-rewrite-service.js.map +1 -1
  306. package/lib/langium/update-rewrite/update-rewrite.d.ts +1 -1
  307. package/lib/langium/validation/document-validator.d.ts +168 -23
  308. package/lib/langium/validation/document-validator.d.ts.map +1 -1
  309. package/lib/langium/validation/document-validator.js +264 -26
  310. package/lib/langium/validation/document-validator.js.map +1 -1
  311. package/lib/langium/validation/validation-contribution-collector.d.ts +9 -1
  312. package/lib/langium/validation/validation-contribution-collector.d.ts.map +1 -1
  313. package/lib/langium/validation/validation-contribution-collector.js +1 -1
  314. package/lib/langium/validation/validation-contribution-collector.js.map +1 -1
  315. package/lib/langium/workspace/ast-node-locator.d.ts +24 -0
  316. package/lib/langium/workspace/ast-node-locator.d.ts.map +1 -0
  317. package/lib/langium/workspace/ast-node-locator.js +32 -0
  318. package/lib/langium/workspace/ast-node-locator.js.map +1 -0
  319. package/lib/langium/workspace/document-uri-policy.d.ts +24 -15
  320. package/lib/langium/workspace/document-uri-policy.d.ts.map +1 -1
  321. package/lib/langium/workspace/document-uri-policy.js +22 -13
  322. package/lib/langium/workspace/document-uri-policy.js.map +1 -1
  323. package/lib/langium/workspace/file-not-found.d.ts +23 -0
  324. package/lib/langium/workspace/file-not-found.d.ts.map +1 -0
  325. package/lib/langium/workspace/file-not-found.js +31 -0
  326. package/lib/langium/workspace/file-not-found.js.map +1 -0
  327. package/lib/langium/workspace/file-system-provider.d.ts +167 -8
  328. package/lib/langium/workspace/file-system-provider.d.ts.map +1 -1
  329. package/lib/langium/workspace/file-system-provider.js +115 -13
  330. package/lib/langium/workspace/file-system-provider.js.map +1 -1
  331. package/lib/langium/workspace/hydranium-langium-document-factory.d.ts +31 -1
  332. package/lib/langium/workspace/hydranium-langium-document-factory.d.ts.map +1 -1
  333. package/lib/langium/workspace/hydranium-langium-document-factory.js +54 -0
  334. package/lib/langium/workspace/hydranium-langium-document-factory.js.map +1 -1
  335. package/lib/langium/workspace/hydranium-workspace-lock.d.ts +43 -1
  336. package/lib/langium/workspace/hydranium-workspace-lock.d.ts.map +1 -1
  337. package/lib/langium/workspace/hydranium-workspace-lock.js +58 -1
  338. package/lib/langium/workspace/hydranium-workspace-lock.js.map +1 -1
  339. package/lib/langium/workspace/hydranium-workspace-manager.d.ts +105 -21
  340. package/lib/langium/workspace/hydranium-workspace-manager.d.ts.map +1 -1
  341. package/lib/langium/workspace/hydranium-workspace-manager.js +186 -31
  342. package/lib/langium/workspace/hydranium-workspace-manager.js.map +1 -1
  343. package/lib/langium/workspace/in-memory-file-system-provider.d.ts +26 -9
  344. package/lib/langium/workspace/in-memory-file-system-provider.d.ts.map +1 -1
  345. package/lib/langium/workspace/in-memory-file-system-provider.js +45 -22
  346. package/lib/langium/workspace/in-memory-file-system-provider.js.map +1 -1
  347. package/lib/langium/workspace/index-manager.d.ts.map +1 -1
  348. package/lib/langium/workspace/index-manager.js.map +1 -1
  349. package/lib/langium/workspace/index.d.ts +2 -0
  350. package/lib/langium/workspace/index.d.ts.map +1 -1
  351. package/lib/langium/workspace/index.js +2 -0
  352. package/lib/langium/workspace/index.js.map +1 -1
  353. package/lib/langium/workspace/initialize-workspace.d.ts +40 -3
  354. package/lib/langium/workspace/initialize-workspace.d.ts.map +1 -1
  355. package/lib/langium/workspace/initialize-workspace.js +68 -3
  356. package/lib/langium/workspace/initialize-workspace.js.map +1 -1
  357. package/lib/langium/workspace/langium-documents.d.ts +7 -0
  358. package/lib/langium/workspace/langium-documents.d.ts.map +1 -1
  359. package/lib/langium/workspace/langium-documents.js +18 -1
  360. package/lib/langium/workspace/langium-documents.js.map +1 -1
  361. package/lib/langium/workspace/persistent-file-system-provider.d.ts +16 -10
  362. package/lib/langium/workspace/persistent-file-system-provider.d.ts.map +1 -1
  363. package/lib/langium/workspace/persistent-file-system-provider.js +25 -13
  364. package/lib/langium/workspace/persistent-file-system-provider.js.map +1 -1
  365. package/lib/{documents → langium/workspace}/self-save-registry.d.ts +7 -9
  366. package/lib/langium/workspace/self-save-registry.d.ts.map +1 -0
  367. package/lib/{documents → langium/workspace}/self-save-registry.js +9 -11
  368. package/lib/langium/workspace/self-save-registry.js.map +1 -0
  369. package/lib/langium/workspace/virtual-document.d.ts +55 -21
  370. package/lib/langium/workspace/virtual-document.d.ts.map +1 -1
  371. package/lib/langium/workspace/virtual-document.js +87 -24
  372. package/lib/langium/workspace/virtual-document.js.map +1 -1
  373. package/lib/langium/workspace/write-lock-scope.d.ts +22 -10
  374. package/lib/langium/workspace/write-lock-scope.d.ts.map +1 -1
  375. package/lib/langium/workspace/write-lock-scope.js +15 -5
  376. package/lib/langium/workspace/write-lock-scope.js.map +1 -1
  377. package/lib/launcher/integrated-server.d.ts +3 -1
  378. package/lib/launcher/integrated-server.d.ts.map +1 -1
  379. package/lib/locale/server-locale.d.ts +6 -6
  380. package/lib/locale/server-locale.d.ts.map +1 -1
  381. package/lib/locale/server-locale.js.map +1 -1
  382. package/lib/lsp/completion/hydranium-completion-provider.d.ts +44 -2
  383. package/lib/lsp/completion/hydranium-completion-provider.d.ts.map +1 -1
  384. package/lib/lsp/completion/hydranium-completion-provider.js +68 -0
  385. package/lib/lsp/completion/hydranium-completion-provider.js.map +1 -1
  386. package/lib/lsp/connection-features.d.ts +23 -0
  387. package/lib/lsp/connection-features.d.ts.map +1 -0
  388. package/lib/lsp/connection-features.js +60 -0
  389. package/lib/lsp/connection-features.js.map +1 -0
  390. package/lib/lsp/diagnostics-connection.d.ts +27 -0
  391. package/lib/lsp/diagnostics-connection.d.ts.map +1 -0
  392. package/lib/lsp/diagnostics-connection.js +53 -0
  393. package/lib/lsp/diagnostics-connection.js.map +1 -0
  394. package/lib/lsp/edit-requests-guard.d.ts +31 -0
  395. package/lib/lsp/edit-requests-guard.d.ts.map +1 -0
  396. package/lib/lsp/edit-requests-guard.js +125 -0
  397. package/lib/lsp/edit-requests-guard.js.map +1 -0
  398. package/lib/lsp/hydranium-document-update-handler.d.ts +126 -82
  399. package/lib/lsp/hydranium-document-update-handler.d.ts.map +1 -1
  400. package/lib/lsp/hydranium-document-update-handler.js +234 -101
  401. package/lib/lsp/hydranium-document-update-handler.js.map +1 -1
  402. package/lib/lsp/index.d.ts +6 -2
  403. package/lib/lsp/index.d.ts.map +1 -1
  404. package/lib/lsp/index.js +6 -2
  405. package/lib/lsp/index.js.map +1 -1
  406. package/lib/lsp/lsp-latency.d.ts +39 -0
  407. package/lib/lsp/lsp-latency.d.ts.map +1 -0
  408. package/lib/lsp/lsp-latency.js +58 -0
  409. package/lib/lsp/lsp-latency.js.map +1 -0
  410. package/lib/lsp/save-text-document.d.ts +31 -0
  411. package/lib/lsp/save-text-document.d.ts.map +1 -0
  412. package/lib/lsp/save-text-document.js +52 -0
  413. package/lib/lsp/save-text-document.js.map +1 -0
  414. package/lib/lsp/semantic-token-provider.d.ts +58 -2
  415. package/lib/lsp/semantic-token-provider.d.ts.map +1 -1
  416. package/lib/lsp/semantic-token-provider.js +98 -9
  417. package/lib/lsp/semantic-token-provider.js.map +1 -1
  418. package/lib/lsp/shared-module.d.ts +4 -8
  419. package/lib/lsp/shared-module.d.ts.map +1 -1
  420. package/lib/lsp/shared-module.js.map +1 -1
  421. package/lib/lsp/start-language-server.d.ts +12 -7
  422. package/lib/lsp/start-language-server.d.ts.map +1 -1
  423. package/lib/lsp/start-language-server.js +21 -7
  424. package/lib/lsp/start-language-server.js.map +1 -1
  425. package/lib/messages/carriers.d.ts +4 -6
  426. package/lib/messages/carriers.d.ts.map +1 -1
  427. package/lib/messages/carriers.js +4 -6
  428. package/lib/messages/carriers.js.map +1 -1
  429. package/lib/messages/index.d.ts +2 -2
  430. package/lib/messages/index.d.ts.map +1 -1
  431. package/lib/messages/index.js +2 -2
  432. package/lib/messages/index.js.map +1 -1
  433. package/lib/messages/renderer.d.ts +10 -4
  434. package/lib/messages/renderer.d.ts.map +1 -1
  435. package/lib/messages/renderer.js +6 -0
  436. package/lib/messages/renderer.js.map +1 -1
  437. package/lib/node/event-loop-monitor.d.ts.map +1 -1
  438. package/lib/node/event-loop-monitor.js +2 -1
  439. package/lib/node/event-loop-monitor.js.map +1 -1
  440. package/lib/node/heap-ceiling.d.ts +61 -0
  441. package/lib/node/heap-ceiling.d.ts.map +1 -0
  442. package/lib/node/heap-ceiling.js +72 -0
  443. package/lib/node/heap-ceiling.js.map +1 -0
  444. package/lib/node/index.d.ts +1 -1
  445. package/lib/node/index.d.ts.map +1 -1
  446. package/lib/node/index.js +5 -1
  447. package/lib/node/index.js.map +1 -1
  448. package/lib/node/latency-from-env.d.ts +1 -1
  449. package/lib/node/latency-from-env.js +1 -1
  450. package/lib/node/lint-grammar.js.map +1 -1
  451. package/lib/node/log-file-sink.d.ts +3 -2
  452. package/lib/node/log-file-sink.d.ts.map +1 -1
  453. package/lib/node/log-file-sink.js +6 -2
  454. package/lib/node/log-file-sink.js.map +1 -1
  455. package/lib/node/log-preamble-node.d.ts +5 -3
  456. package/lib/node/log-preamble-node.d.ts.map +1 -1
  457. package/lib/node/log-preamble-node.js +13 -10
  458. package/lib/node/log-preamble-node.js.map +1 -1
  459. package/lib/node/measure-memory.d.ts.map +1 -1
  460. package/lib/node/measure-memory.js +5 -4
  461. package/lib/node/measure-memory.js.map +1 -1
  462. package/lib/node/memory-monitor.d.ts +2 -2
  463. package/lib/node/memory-monitor.d.ts.map +1 -1
  464. package/lib/node/memory-monitor.js +9 -10
  465. package/lib/node/memory-monitor.js.map +1 -1
  466. package/lib/node/node-file-system-provider.d.ts +67 -9
  467. package/lib/node/node-file-system-provider.d.ts.map +1 -1
  468. package/lib/node/node-file-system-provider.js +198 -53
  469. package/lib/node/node-file-system-provider.js.map +1 -1
  470. package/lib/node/profile-capture.d.ts +12 -4
  471. package/lib/node/profile-capture.d.ts.map +1 -1
  472. package/lib/node/profile-capture.js +8 -6
  473. package/lib/node/profile-capture.js.map +1 -1
  474. package/lib/node/profile-digest.js.map +1 -1
  475. package/lib/node/profiling-run.d.ts +13 -3
  476. package/lib/node/profiling-run.d.ts.map +1 -1
  477. package/lib/node/profiling-run.js +17 -8
  478. package/lib/node/profiling-run.js.map +1 -1
  479. package/lib/node/rename-over-open-readers.d.ts +61 -0
  480. package/lib/node/rename-over-open-readers.d.ts.map +1 -0
  481. package/lib/node/rename-over-open-readers.js +80 -0
  482. package/lib/node/rename-over-open-readers.js.map +1 -0
  483. package/lib/node/server-diagnostics.js +1 -1
  484. package/lib/node/server-diagnostics.js.map +1 -1
  485. package/lib/node/server-state-snapshot.js +4 -4
  486. package/lib/node/server-state-snapshot.js.map +1 -1
  487. package/lib/node/socket-launcher.d.ts +43 -7
  488. package/lib/node/socket-launcher.d.ts.map +1 -1
  489. package/lib/node/socket-launcher.js +42 -7
  490. package/lib/node/socket-launcher.js.map +1 -1
  491. package/lib/node/startup-cpu-profile.d.ts +29 -0
  492. package/lib/node/startup-cpu-profile.d.ts.map +1 -0
  493. package/lib/node/startup-cpu-profile.js +91 -0
  494. package/lib/node/startup-cpu-profile.js.map +1 -0
  495. package/lib/node/stdio-launcher.d.ts +13 -13
  496. package/lib/node/stdio-launcher.d.ts.map +1 -1
  497. package/lib/node/stdio-launcher.js +21 -11
  498. package/lib/node/stdio-launcher.js.map +1 -1
  499. package/lib/node/validate-workspace.d.ts +1 -1
  500. package/lib/node/validate-workspace.d.ts.map +1 -1
  501. package/lib/node/validate-workspace.js +5 -1
  502. package/lib/node/validate-workspace.js.map +1 -1
  503. package/lib/testing/document-uri-policy-conformance.js +1 -1
  504. package/lib/testing/document-uri-policy-conformance.js.map +1 -1
  505. package/lib/testing/fake-description.js.map +1 -1
  506. package/lib/testing/fake-document.d.ts +2 -1
  507. package/lib/testing/fake-document.d.ts.map +1 -1
  508. package/lib/testing/fake-document.js.map +1 -1
  509. package/lib/testing/index.d.ts +1 -1
  510. package/lib/testing/index.d.ts.map +1 -1
  511. package/lib/testing/index.js +2 -1
  512. package/lib/testing/index.js.map +1 -1
  513. package/lib/testing/langium-test-helpers.d.ts.map +1 -1
  514. package/lib/testing/langium-test-helpers.js +1 -0
  515. package/lib/testing/langium-test-helpers.js.map +1 -1
  516. package/lib/testing/make-noop-language-services.js.map +1 -1
  517. package/lib/testing/make-noop-shared-services.js.map +1 -1
  518. package/lib/testing/make-test-services.d.ts +45 -14
  519. package/lib/testing/make-test-services.d.ts.map +1 -1
  520. package/lib/testing/make-test-services.js +23 -7
  521. package/lib/testing/make-test-services.js.map +1 -1
  522. package/lib/testing/make-test-tracer.d.ts +12 -0
  523. package/lib/testing/make-test-tracer.d.ts.map +1 -1
  524. package/lib/testing/make-test-tracer.js +13 -0
  525. package/lib/testing/make-test-tracer.js.map +1 -1
  526. package/lib/testing/node/applied-edit-capture.d.ts +29 -0
  527. package/lib/testing/node/applied-edit-capture.d.ts.map +1 -0
  528. package/lib/testing/node/applied-edit-capture.js +117 -0
  529. package/lib/testing/node/applied-edit-capture.js.map +1 -0
  530. package/lib/testing/node/golden-corpus.js.map +1 -1
  531. package/lib/testing/node/index.d.ts +1 -0
  532. package/lib/testing/node/index.d.ts.map +1 -1
  533. package/lib/testing/node/index.js +1 -0
  534. package/lib/testing/node/index.js.map +1 -1
  535. package/lib/testing/node/lsp-harness.d.ts.map +1 -1
  536. package/lib/testing/node/lsp-harness.js +2 -0
  537. package/lib/testing/node/lsp-harness.js.map +1 -1
  538. package/lib/testing/node/lsp-server-connection.d.ts +21 -6
  539. package/lib/testing/node/lsp-server-connection.d.ts.map +1 -1
  540. package/lib/testing/node/lsp-server-connection.js +49 -106
  541. package/lib/testing/node/lsp-server-connection.js.map +1 -1
  542. package/lib/testing/node/scratch-workspace.d.ts.map +1 -1
  543. package/lib/testing/node/scratch-workspace.js +10 -5
  544. package/lib/testing/node/scratch-workspace.js.map +1 -1
  545. package/lib/testing/node/spawned-server.d.ts +30 -1
  546. package/lib/testing/node/spawned-server.d.ts.map +1 -1
  547. package/lib/testing/node/spawned-server.js +39 -2
  548. package/lib/testing/node/spawned-server.js.map +1 -1
  549. package/lib/testing/node/unhandled-rejections.d.ts +20 -0
  550. package/lib/testing/node/unhandled-rejections.d.ts.map +1 -0
  551. package/lib/testing/node/unhandled-rejections.js +32 -0
  552. package/lib/testing/node/unhandled-rejections.js.map +1 -0
  553. package/lib/testing/playwright/browser-capture-bridge.js.map +1 -1
  554. package/lib/testing/playwright/e2e-profiling.js.map +1 -1
  555. package/lib/testing/playwright/flaky-network-proxy.d.ts +76 -0
  556. package/lib/testing/playwright/flaky-network-proxy.d.ts.map +1 -0
  557. package/lib/testing/playwright/flaky-network-proxy.js +164 -0
  558. package/lib/testing/playwright/flaky-network-proxy.js.map +1 -0
  559. package/lib/testing/playwright/index.d.ts +1 -0
  560. package/lib/testing/playwright/index.d.ts.map +1 -1
  561. package/lib/testing/playwright/index.js +1 -0
  562. package/lib/testing/playwright/index.js.map +1 -1
  563. package/lib/testing/playwright/server-log-capture.d.ts +46 -16
  564. package/lib/testing/playwright/server-log-capture.d.ts.map +1 -1
  565. package/lib/testing/playwright/server-log-capture.js +111 -40
  566. package/lib/testing/playwright/server-log-capture.js.map +1 -1
  567. package/lib/testing/playwright/server-log-fixture.d.ts +16 -0
  568. package/lib/testing/playwright/server-log-fixture.d.ts.map +1 -1
  569. package/lib/testing/playwright/server-log-fixture.js +25 -6
  570. package/lib/testing/playwright/server-log-fixture.js.map +1 -1
  571. package/lib/testing/playwright/server-log-region.d.ts +15 -0
  572. package/lib/testing/playwright/server-log-region.d.ts.map +1 -0
  573. package/lib/testing/playwright/server-log-region.js +30 -0
  574. package/lib/testing/playwright/server-log-region.js.map +1 -0
  575. package/lib/testing/playwright/server-log-rename-reporter.d.ts.map +1 -1
  576. package/lib/testing/playwright/server-log-rename-reporter.js +4 -3
  577. package/lib/testing/playwright/server-log-rename-reporter.js.map +1 -1
  578. package/lib/testing/run-update-pipeline.d.ts +8 -5
  579. package/lib/testing/run-update-pipeline.d.ts.map +1 -1
  580. package/lib/testing/run-update-pipeline.js.map +1 -1
  581. package/lib/testing/stub-ast-document-manager.d.ts +11 -51
  582. package/lib/testing/stub-ast-document-manager.d.ts.map +1 -1
  583. package/lib/testing/stub-ast-document-manager.js +31 -59
  584. package/lib/testing/stub-ast-document-manager.js.map +1 -1
  585. package/lib/testing/stub-document-builder.d.ts +33 -11
  586. package/lib/testing/stub-document-builder.d.ts.map +1 -1
  587. package/lib/testing/stub-document-builder.js +110 -5
  588. package/lib/testing/stub-document-builder.js.map +1 -1
  589. package/lib/testing/stub-hydranium-text-documents.d.ts +33 -10
  590. package/lib/testing/stub-hydranium-text-documents.d.ts.map +1 -1
  591. package/lib/testing/stub-hydranium-text-documents.js +132 -16
  592. package/lib/testing/stub-hydranium-text-documents.js.map +1 -1
  593. package/lib/testing/stub-index-manager.js.map +1 -1
  594. package/lib/testing/stub-langium-documents.d.ts +3 -2
  595. package/lib/testing/stub-langium-documents.d.ts.map +1 -1
  596. package/lib/testing/stub-langium-documents.js.map +1 -1
  597. package/lib/testing/stub-model-service.d.ts +8 -7
  598. package/lib/testing/stub-model-service.d.ts.map +1 -1
  599. package/lib/testing/stub-model-service.js +4 -4
  600. package/lib/testing/stub-model-service.js.map +1 -1
  601. package/lib/testing/stub-project-manager.d.ts.map +1 -1
  602. package/lib/testing/stub-project-manager.js +10 -0
  603. package/lib/testing/stub-project-manager.js.map +1 -1
  604. package/lib/testing/stub-self-save-registry.d.ts +1 -1
  605. package/lib/testing/stub-self-save-registry.d.ts.map +1 -1
  606. package/lib/testing/stub-service-registry.d.ts +1 -1
  607. package/lib/testing/stub-service-registry.js.map +1 -1
  608. package/lib/testing/stub-writable-file-system.d.ts +1 -1
  609. package/lib/testing/stub-writable-file-system.d.ts.map +1 -1
  610. package/lib/testing/stub-writable-file-system.js +2 -1
  611. package/lib/testing/stub-writable-file-system.js.map +1 -1
  612. package/lib/util/connection-liveness.d.ts +22 -6
  613. package/lib/util/connection-liveness.d.ts.map +1 -1
  614. package/lib/util/connection-liveness.js +75 -15
  615. package/lib/util/connection-liveness.js.map +1 -1
  616. package/lib/util/environment.d.ts +7 -0
  617. package/lib/util/environment.d.ts.map +1 -1
  618. package/lib/util/environment.js +15 -1
  619. package/lib/util/environment.js.map +1 -1
  620. package/lib/util/registry.d.ts.map +1 -1
  621. package/package.json +41 -60
  622. package/src/browser/host-heads-in-worker.ts +218 -0
  623. package/src/browser/index.ts +17 -0
  624. package/src/browser/indexeddb-file-system-store.ts +192 -0
  625. package/src/browser/start-language-server-in-worker.ts +56 -0
  626. package/src/documents/ast-document-manager.ts +477 -249
  627. package/src/documents/client-ids.ts +5 -22
  628. package/src/documents/client-session-errors.ts +24 -0
  629. package/src/documents/client-session-registry.ts +262 -0
  630. package/src/documents/dirty-state-tracker.ts +167 -0
  631. package/src/documents/document-release-handler.ts +404 -0
  632. package/src/documents/document-release-scheduler.ts +121 -0
  633. package/src/documents/file-system-task-queue.ts +74 -0
  634. package/src/documents/hydranium-text-documents.ts +1029 -595
  635. package/src/documents/index.ts +10 -2
  636. package/src/documents/language-client-shadow.ts +501 -0
  637. package/src/documents/model-ledger.ts +66 -0
  638. package/src/documents/text-ledger.ts +112 -0
  639. package/src/documents/version-sync-service.ts +275 -0
  640. package/src/index.ts +3 -0
  641. package/src/langium/ast-extension/ast-extension-service.ts +77 -41
  642. package/src/langium/ast-extension/ast-node-builder.ts +35 -13
  643. package/src/langium/bootstrap.ts +79 -43
  644. package/src/langium/build-phase-pass/build-phase-pass-service.ts +29 -19
  645. package/src/langium/build-phase-pass/build-phase-pass.ts +37 -8
  646. package/src/langium/composite-ast-reflection.ts +112 -0
  647. package/src/langium/config/configuration-provider.ts +119 -0
  648. package/src/langium/config/index.ts +1 -0
  649. package/src/langium/diagnostics/console-tee.ts +150 -0
  650. package/src/langium/diagnostics/hydranium-langium-profiler.ts +15 -39
  651. package/src/langium/diagnostics/log-preamble.ts +1 -1
  652. package/src/langium/diagnostics/logger.ts +51 -17
  653. package/src/langium/diagnostics/lsp-logger.ts +83 -45
  654. package/src/langium/document-builder/build-pipeline-integration.ts +57 -32
  655. package/src/langium/document-builder/build-session.ts +4 -3
  656. package/src/langium/document-builder/document-builder.ts +679 -83
  657. package/src/langium/integration-services.ts +58 -27
  658. package/src/langium/integrity/integrity-rule.ts +17 -8
  659. package/src/langium/integrity/integrity-service.ts +332 -69
  660. package/src/langium/keys/containment.ts +3 -2
  661. package/src/langium/keys/name-based-key-provider.ts +24 -12
  662. package/src/langium/language-module.ts +52 -9
  663. package/src/langium/model-service/client-session.ts +726 -0
  664. package/src/langium/model-service/index.ts +2 -0
  665. package/src/langium/model-service/model-events.ts +82 -0
  666. package/src/langium/model-service/model-service.ts +887 -522
  667. package/src/langium/module.ts +132 -56
  668. package/src/langium/naming/name-provider.ts +34 -8
  669. package/src/langium/project/abstract-project-manager.ts +409 -20
  670. package/src/langium/project/project-change-event.ts +25 -3
  671. package/src/langium/project/project-manager.ts +31 -2
  672. package/src/langium/project/single-project-manager.ts +16 -1
  673. package/src/langium/residency/cst-residency-service.ts +30 -14
  674. package/src/langium/scope/ast-node-description-provider.ts +111 -16
  675. package/src/langium/scope/built-local-symbols.ts +13 -0
  676. package/src/langium/scope/fallback-scope.ts +38 -0
  677. package/src/langium/scope/hydranium-scope-computation.ts +45 -44
  678. package/src/langium/scope/hydranium-scope-provider.ts +245 -41
  679. package/src/langium/scope/index.ts +1 -0
  680. package/src/langium/scope/reference-candidate-provider.ts +6 -5
  681. package/src/langium/scope/scope-extension-service.ts +148 -56
  682. package/src/langium/scope/scoped-ast-node-description.ts +1 -3
  683. package/src/langium/serialization/abstract-serializer.ts +57 -41
  684. package/src/langium/serialization/json-serializer.ts +14 -3
  685. package/src/langium/serialization/serializer.ts +1 -1
  686. package/src/langium/serialization/yaml-serializer.ts +26 -4
  687. package/src/langium/service-registry.ts +41 -2
  688. package/src/langium/shared-services.ts +13 -4
  689. package/src/langium/single-langium-copy.ts +42 -0
  690. package/src/langium/transfer/transfer-encoder.ts +76 -50
  691. package/src/langium/trivia/comment-preserver.ts +1409 -0
  692. package/src/langium/trivia/document-ending-preserver.ts +71 -0
  693. package/src/langium/trivia/index.ts +14 -0
  694. package/src/langium/trivia/trivia-contribution.ts +39 -0
  695. package/src/langium/trivia/trivia-preserver.ts +56 -0
  696. package/src/langium/trivia/trivia-service.ts +99 -0
  697. package/src/langium/update-rewrite/update-rewrite-service.ts +1 -1
  698. package/src/langium/update-rewrite/update-rewrite.ts +1 -1
  699. package/src/langium/validation/document-validator.ts +312 -31
  700. package/src/langium/validation/validation-contribution-collector.ts +10 -1
  701. package/src/langium/workspace/ast-node-locator.ts +33 -0
  702. package/src/langium/workspace/document-uri-policy.ts +32 -18
  703. package/src/langium/workspace/file-not-found.ts +35 -0
  704. package/src/langium/workspace/file-system-provider.ts +258 -16
  705. package/src/langium/workspace/hydranium-langium-document-factory.ts +83 -0
  706. package/src/langium/workspace/hydranium-workspace-lock.ts +86 -2
  707. package/src/langium/workspace/hydranium-workspace-manager.ts +214 -35
  708. package/src/langium/workspace/in-memory-file-system-provider.ts +54 -23
  709. package/src/langium/workspace/index.ts +2 -0
  710. package/src/langium/workspace/initialize-workspace.ts +96 -4
  711. package/src/langium/workspace/langium-documents.ts +19 -1
  712. package/src/langium/workspace/persistent-file-system-provider.ts +27 -15
  713. package/src/{documents → langium/workspace}/self-save-registry.ts +12 -14
  714. package/src/langium/workspace/virtual-document.ts +106 -25
  715. package/src/langium/workspace/write-lock-scope.ts +27 -12
  716. package/src/launcher/integrated-server.ts +3 -1
  717. package/src/locale/server-locale.ts +6 -6
  718. package/src/lsp/completion/hydranium-completion-provider.ts +82 -2
  719. package/src/lsp/connection-features.ts +67 -0
  720. package/src/lsp/diagnostics-connection.ts +56 -0
  721. package/src/lsp/edit-requests-guard.ts +152 -0
  722. package/src/lsp/hydranium-document-update-handler.ts +284 -110
  723. package/src/lsp/index.ts +6 -2
  724. package/src/lsp/lsp-latency.ts +62 -0
  725. package/src/lsp/save-text-document.ts +63 -0
  726. package/src/lsp/semantic-token-provider.ts +146 -8
  727. package/src/lsp/shared-module.ts +4 -8
  728. package/src/lsp/start-language-server.ts +21 -7
  729. package/src/messages/carriers.ts +4 -6
  730. package/src/messages/index.ts +11 -2
  731. package/src/messages/renderer.ts +11 -3
  732. package/src/node/event-loop-monitor.ts +2 -1
  733. package/src/node/heap-ceiling.ts +108 -0
  734. package/src/node/index.ts +5 -1
  735. package/src/node/latency-from-env.ts +1 -1
  736. package/src/node/log-file-sink.ts +6 -2
  737. package/src/node/log-preamble-node.ts +20 -10
  738. package/src/node/measure-memory.ts +5 -4
  739. package/src/node/memory-monitor.ts +10 -10
  740. package/src/node/node-file-system-provider.ts +214 -57
  741. package/src/node/profile-capture.ts +16 -15
  742. package/src/node/profiling-run.ts +30 -8
  743. package/src/node/rename-over-open-readers.ts +94 -0
  744. package/src/node/server-diagnostics.ts +1 -1
  745. package/src/node/server-state-snapshot.ts +5 -5
  746. package/src/node/socket-launcher.ts +78 -14
  747. package/src/node/startup-cpu-profile.ts +94 -0
  748. package/src/node/stdio-launcher.ts +29 -19
  749. package/src/node/validate-workspace.ts +8 -2
  750. package/src/testing/document-uri-policy-conformance.ts +1 -1
  751. package/src/testing/fake-document.ts +2 -1
  752. package/src/testing/index.ts +2 -1
  753. package/src/testing/langium-test-helpers.ts +1 -0
  754. package/src/testing/make-test-services.ts +83 -31
  755. package/src/testing/make-test-tracer.ts +26 -0
  756. package/src/testing/node/applied-edit-capture.ts +141 -0
  757. package/src/testing/node/index.ts +1 -0
  758. package/src/testing/node/lsp-harness.ts +2 -0
  759. package/src/testing/node/lsp-server-connection.ts +83 -119
  760. package/src/testing/node/scratch-workspace.ts +10 -5
  761. package/src/testing/node/spawned-server.ts +57 -3
  762. package/src/testing/node/unhandled-rejections.ts +31 -0
  763. package/src/testing/parse-semantic-root.ts +1 -1
  764. package/src/testing/playwright/flaky-network-proxy.ts +240 -0
  765. package/src/testing/playwright/index.ts +1 -0
  766. package/src/testing/playwright/server-log-capture.ts +137 -47
  767. package/src/testing/playwright/server-log-fixture.ts +46 -6
  768. package/src/testing/playwright/server-log-region.ts +32 -0
  769. package/src/testing/playwright/server-log-rename-reporter.ts +4 -3
  770. package/src/testing/run-update-pipeline.ts +8 -5
  771. package/src/testing/stub-ast-document-manager.ts +47 -123
  772. package/src/testing/stub-document-builder.ts +155 -18
  773. package/src/testing/stub-hydranium-text-documents.ts +184 -27
  774. package/src/testing/stub-langium-documents.ts +3 -2
  775. package/src/testing/stub-model-service.ts +9 -8
  776. package/src/testing/stub-project-manager.ts +10 -0
  777. package/src/testing/stub-self-save-registry.ts +1 -1
  778. package/src/testing/stub-service-registry.ts +1 -1
  779. package/src/testing/stub-writable-file-system.ts +3 -2
  780. package/src/util/connection-liveness.ts +81 -15
  781. package/src/util/environment.ts +24 -2
  782. package/lib/documents/language-client-text-shadow.d.ts +0 -101
  783. package/lib/documents/language-client-text-shadow.d.ts.map +0 -1
  784. package/lib/documents/language-client-text-shadow.js +0 -156
  785. package/lib/documents/language-client-text-shadow.js.map +0 -1
  786. package/lib/documents/self-save-registry.d.ts.map +0 -1
  787. package/lib/documents/self-save-registry.js.map +0 -1
  788. package/lib/lsp/instrument-connection.d.ts +0 -36
  789. package/lib/lsp/instrument-connection.d.ts.map +0 -1
  790. package/lib/lsp/instrument-connection.js +0 -62
  791. package/lib/lsp/instrument-connection.js.map +0 -1
  792. package/lib/node/process-memory.d.ts +0 -66
  793. package/lib/node/process-memory.d.ts.map +0 -1
  794. package/lib/node/process-memory.js +0 -252
  795. package/lib/node/process-memory.js.map +0 -1
  796. package/src/documents/language-client-text-shadow.ts +0 -175
  797. package/src/lsp/instrument-connection.ts +0 -66
  798. package/src/node/process-memory.ts +0 -299
@@ -6,13 +6,17 @@
6
6
  *
7
7
  * SPDX-License-Identifier: MIT
8
8
  ********************************************************************************/
9
- import { type CanonicalUri, type CloseModelArgs, type MaybeObservableValue, type MaybePromise, ObservableValue, type TransferDiagnostic, type TransferElement, type OpenModelArgs, type Tracer, type TransferSaveArgs, type TransferUpdateArgs } from '@hydranium/protocol';
9
+ import { type CanonicalUri, type MaybeObservableValue, type MaybePromise, ObservableValue, type TransferElement, type TextVersion, type Tracer } from '@hydranium/protocol';
10
10
  import { type AstNode, DocumentState, type LangiumDocument, type URI } from '@hydranium/langium';
11
+ import { type AstDiagnostic } from '../validation/document-validator.js';
11
12
  import { type DocumentUriPolicy } from '../workspace/document-uri-policy.js';
12
- import { type CancellationToken, type Disposable } from 'vscode-languageserver';
13
- import { AstDocument, type AstDocumentSavedEvent, type AstDocumentUpdatedEvent } from '../../documents/ast-document-manager.js';
13
+ import { CancellationToken, Disposable } from 'vscode-languageserver';
14
+ import { AstDocument } from '../../documents/ast-document-manager.js';
14
15
  import { type LogNameOptions } from '../diagnostics/logger.js';
16
+ import { type OpenOptions } from '../../documents/client-session-registry.js';
15
17
  import { type ServerSharedServices } from '../module.js';
18
+ import { type ClientSession } from './client-session.js';
19
+ import { type ModelDeletedEvent, type ModelDirtyChangedEvent, type ModelEventFilter, type ModelPhaseFilter, type ModelReleasedEvent, type ModelSavedEvent, type ModelsBuiltEvent, type ModelUpdatedEvent } from './model-events.js';
16
20
  /**
17
21
  * The undo-stack entry for a server-authored write pushed to the editor.
18
22
  *
@@ -35,74 +39,77 @@ export declare const MODEL_UPDATE_EDIT: import("@hydranium/protocol").MessageDef
35
39
  */
36
40
  export interface ModelServiceOptions extends LogNameOptions {
37
41
  /**
38
- * When set, {@link ModelService.update} logs a `warn` line if its
39
- * end-to-end wait (serialise + content-change apply + rebuild +
40
- * settled-phase wait) exceeds this many milliseconds. Default
41
- * `undefined` (no warn line ever emitted; the underlying
42
- * `Logger.time` debug timing log is unchanged either way).
43
- *
44
- * Pure observability — does NOT abort the update, does NOT change
45
- * resolution semantics. Adopters wanting a hard timeout that throws
46
- * instead override {@link ModelService.update} on their subclass and
47
- * race the parent call against their own deadline.
48
- *
49
- * Recommended starting threshold: 2-5 seconds for interactive paths
50
- * (form save, diagram edit). Workspaces with very large documents
51
- * or slow validation may legitimately exceed 5s on the cold path —
52
- * tune per workspace.
53
- *
54
- * Accepts a {@link MaybeObservableValue} so the threshold can be a
55
- * fixed constant or bound to a user setting via `Settings.number`
56
- * and retuned live. Leaving it unset disables the warn line entirely
57
- * (and skips the per-update stopwatch).
58
- */
59
- readonly slowUpdateWarnMs?: MaybeObservableValue<number>;
60
- /**
61
- * Serialise the facade's own build under the workspace WRITE lock, the way
62
- * Langium's `DefaultDocumentUpdateHandler` dispatches its build. Default
63
- * `true`.
64
- *
65
- * **Why it defaults on.** Unlocked, the facade's build races the LSP bridge's
66
- * build of the same URI — both are legitimate (the bridge exists only under a
67
- * `Connection`, so the facade stands in for it headless), but nothing
68
- * serialises them, so both run a full validation pass and Langium appends the
69
- * second onto the first. Every diagnostic is then duplicated, and the
70
- * duplication compounds per rebuild. Serialised, Langium elides the second
71
- * build entirely, so the redundant work goes too.
72
- *
73
- * **What `false` costs.** The facade's build is then unserialised and can run
74
- * concurrently with the bridge's build of the same URI, so the affected
75
- * documents are validated twice per write — double the validation work.
76
- * Reported diagnostics stay correct even then, because
77
- * `HydraniumDocumentBuilder.dedupeDiagnostics` collapses the byte-identical
78
- * duplicates a repeated pass produces before any listener sees them; what this
79
- * option removes is the wasted pass, not just its visible symptom.
80
- *
81
- * **What `false` buys.** `WorkspaceLock` is not reentrant. A caller that
82
- * reaches `update` / `save` / `rebuild` while already holding the write lock —
83
- * an integrity rule or build-phase pass that writes through this facade —
84
- * deadlocks: acquiring the lock cancels the running holder, and the new
85
- * acquisition then waits for that holder to release while the holder waits
86
- * for this call. On `true` that shape is DETECTED and rejected with
87
- * {@link ReentrantWriteLockError} rather than hanging, wherever a host
88
- * installs a write-lock scope tracker (`@hydranium/core/node` does at entry
89
- * load; see {@link isInsideWriteLock}). Setting `false` is the escape hatch
90
- * for an adopter whose reentrant shape is unavoidable — nothing acquires the
91
- * lock then, so there is nothing to be reentrant about; prefer it over
92
- * unserialised builds only in that case.
42
+ * Let the facade's build run without the workspace write lock when its
43
+ * caller already holds it: an integrity rule or build-phase pass that
44
+ * writes back through a session's `update` / `save`, or calls `rebuild`.
45
+ * Default `false`.
46
+ *
47
+ * `WorkspaceLock` is not reentrant. Taking it from inside a holder cancels
48
+ * that holder and then waits for it to end, while the holder waits for this
49
+ * call, so neither completes. On `false` that call fails with
50
+ * {@link ReentrantWriteLockError} instead, wherever a host installs a
51
+ * write-lock scope tracker (`@hydranium/core/node` does at entry load); on
52
+ * `true` its build takes no lock. The wait after that build can still hang,
53
+ * because a document no build will carry is re-queued through the lock, and
54
+ * the re-queue waits for the holder to end.
55
+ *
56
+ * A session's delete is refused that way on either value, since its builds
57
+ * always take the lock.
58
+ *
59
+ * Every other facade build takes the lock on either value. Unlocked, it can
60
+ * overlap another build of the same document: both run a full validation
61
+ * pass that Langium appends, and a caller can be handed a version that an
62
+ * integrity repair still running in the other build then moves past. Without
63
+ * a tracker the two cases cannot be told apart (see
64
+ * {@link isWriteLockScopeInstalled}), so `true` builds without the lock every
65
+ * time and accepts both.
93
66
  *
94
67
  * Accepts a {@link MaybeObservableValue} so it can be bound to a setting and
95
68
  * flipped without a restart.
96
69
  */
97
- readonly serializeBuilds?: MaybeObservableValue<boolean>;
70
+ readonly allowReentrantBuilds?: MaybeObservableValue<boolean>;
71
+ /**
72
+ * Let a structured write keep the text the document's root was parsed from
73
+ * when that text serializes to the same text as the written model, so an
74
+ * update that changes nothing in the model leaves hand formatting alone.
75
+ * Default `false`: every structured write applies the canonical text.
76
+ *
77
+ * Costs a parse, an encode and a serialization per write whose text
78
+ * differs; remembering the text last written instead would not cover a
79
+ * file formatted outside the framework. Text with lexer or parser errors is
80
+ * replaced as usual.
81
+ *
82
+ * Accepts a {@link MaybeObservableValue} so it can be bound to a setting.
83
+ */
84
+ readonly keepUnchangedText?: MaybeObservableValue<boolean>;
85
+ }
86
+ /** One {@link ModelService.onModelUpdated} subscription; `uri` is canonical, absent for every document. */
87
+ export interface ModelUpdateSubscriber<TAst extends AstNode, TDiagnostic extends AstDiagnostic = AstDiagnostic> {
88
+ readonly uri?: CanonicalUri;
89
+ readonly listener: (event: ModelUpdatedEvent<TAst, TDiagnostic>) => void;
90
+ }
91
+ /** Options for a {@link DefaultModelService} wait on one document. */
92
+ export interface SyncedWaitOptions {
93
+ /**
94
+ * Build a root parsed from text older than the store's at the call, and
95
+ * reject once that build, or one the builder re-queues, is given up. Without
96
+ * it, such a root is left to other builds, and a wait they never end stays
97
+ * pending until its token is cancelled.
98
+ */
99
+ readonly sync?: boolean;
98
100
  }
99
101
  /**
102
+ * The seam every non-LSP head talks to: the data server, the GLSP head and an
103
+ * adopter's own services reach documents through this slot rather than through
104
+ * the workspace stores.
105
+ *
100
106
  * In-process facade over the framework's document plumbing
101
107
  * (`HydraniumTextDocuments`, `LangiumDocuments`,
102
- * `DocumentBuilder`, `WritableFileSystemProvider`). Owns the
103
- * `open / request / update / save / ready` lifecycle that protocol heads
104
- * (LSP, data-server, GLSP) delegate to so coordinating those primitives
105
- * doesn't have to be re-implemented per-head.
108
+ * `DocumentBuilder`, `WritableFileSystemProvider`). Owns the document
109
+ * lifecycle the data-server and GLSP heads delegate to — client sessions that
110
+ * open, update, save and close documents, the phase reads, and `ready` — so
111
+ * coordinating those primitives doesn't have to be re-implemented per head.
112
+ * Every open and write goes through a session from {@link createSession}.
106
113
  *
107
114
  * "Model" here means the parsed AST — distinct from the wire-shape
108
115
  * `TransferDocument` in `@hydranium/protocol`.
@@ -112,9 +119,9 @@ export interface ModelServiceOptions extends LogNameOptions {
112
119
  * Multiple in-process consumers want the same workspace-level
113
120
  * operations:
114
121
  * - The data-server head turns these into typed RPC methods.
115
- * - The GLSP head uses the same lifecycle for diagram-driven edits;
116
- * GModel operation handlers route through `update` for AST mutation,
117
- * `waitForDocumentState` for indexed-phase waits before reads, etc.
122
+ * - The GLSP head uses the same lifecycle for diagram-driven edits: GModel
123
+ * operation handlers write through the diagram's session and wait on phases
124
+ * before reading.
118
125
  * - Server-internal callers (integrity service, ad-hoc bridges, tests)
119
126
  * want the same operations without the wire serialisation step.
120
127
  *
@@ -127,15 +134,16 @@ export interface ModelServiceOptions extends LogNameOptions {
127
134
  *
128
135
  * **Read-latest supersession**
129
136
  *
130
- * The default `update` and `save` flows use Langium's per-URI
131
- * `DocumentBuilder.waitUntil` to wait for the integrity-settled landmark
132
- * ({@link IntegrityService.SettledState}), then read the post-build state. Concurrent
133
- * in-process callers on the same URI all see the latest post-build
134
- * snapshot — none deadlock waiting for a specific version's settled
135
- * event. Adopters wanting strict version-matched semantics (resolve
136
- * with vN's snapshot specifically, log "vN superseded by vM at vN+1")
137
- * override {@link update} to attach a phase-listener with explicit
138
- * version checks; the framework default doesn't need it for safety.
137
+ * A session's default `update` and `save` use Langium's per-URI
138
+ * `DocumentBuilder.waitUntil` to wait for `Validated` (the integrity-settled
139
+ * landmark {@link IntegrityService.SettledState} when rebuilds do not
140
+ * validate), then read the post-build state. Concurrent in-process callers
141
+ * on the same URI all see the latest post-build snapshot — none deadlock
142
+ * waiting for a specific version's settled event. Adopters wanting strict
143
+ * version-matched semantics (resolve with vN's snapshot specifically, log
144
+ * "vN superseded by vM at vN+1") override
145
+ * `DefaultClientSession.updateDocument` to attach a phase-listener with
146
+ * explicit version checks; the framework default doesn't need it for safety.
139
147
  *
140
148
  * **Returns AST snapshots, not wire envelopes**
141
149
  *
@@ -148,32 +156,26 @@ export interface ModelServiceOptions extends LogNameOptions {
148
156
  * the injected `TransferEncoder` — symmetric with the
149
157
  * `getModelDocument` envelope path.
150
158
  *
151
- * **Subscriptions** ({@link onModelUpdated} / {@link onModelSaved} /
152
- * {@link onClientClosed}) are thin pass-throughs over
153
- * `DocumentBuilder.onDocumentPhase` and
154
- * `HydraniumTextDocuments.onDidSave` / `onDidClose`. Filtering
155
- * by URI happens here so consumers can subscribe per-document without
156
- * implementing the URI gate at each callsite.
159
+ * **Subscriptions** (`on*`) are how a head follows documents; it subscribes
160
+ * here rather than to the builder or the text store. Each takes a filter, and
161
+ * one without a `uri` hears every document.
157
162
  *
158
- * **Generic parameters.**
159
- * - `TAst` — the AST root type each consumer expects on the returned
160
- * {@link AstDocument}. Constrained to {@link AstNode}.
161
- * - `TDiagnostic` — wire diagnostic shape used by the injected
162
- * `TransferEncoder`. Defaults to {@link TransferDiagnostic}.
163
- * - `TTransfer` — transfer-model root accepted by `update` / `save`
164
- * args. Constrained to {@link TransferElement}. Defaults to the
165
- * structural base.
166
- */
167
- /**
168
- * The seam every non-LSP head talks to: the data server, the GLSP head and an
169
- * adopter's own services reach documents through this slot rather than through
170
- * the workspace stores.
163
+ * **Two families.** `waitFor*` only waits: it rejects for a URI with no
164
+ * document, and for a root behind the store's text it waits for whatever
165
+ * builds it next, so it never ends if nothing does. `ensureDocumentState` and
166
+ * the phase shorthands over it build a missing document, and build a root
167
+ * behind its text, rejecting when that build fails twice. Both re-queue a
168
+ * document the builder's last build left short of the state.
169
+ *
170
+ * Both resolve at the state with a root parsed from text no older than the
171
+ * store's version at the call; inside the write lock, at the state alone, since
172
+ * the build that would sync the document to that version cannot start until
173
+ * it is released.
171
174
  *
172
- * **Two families, and the distinction matters more than the names suggest.**
173
- * `waitFor*` is a pure wait — it never triggers a build, so a caller waiting on
174
- * a document no build has touched waits until something else builds it.
175
- * `ensureDocumentState` and the phase shorthands over it *dispatch*: warm
176
- * documents are awaited, cold ones are built.
175
+ * Do not await one inside a build phase listener: a browser host installs no
176
+ * write-lock scope, so the wait cannot tell it is inside a build and waits for
177
+ * one that cannot start. Nor inside a `WorkspaceLock.read`: the lock starts no
178
+ * write, the build included, while a read runs.
177
179
  *
178
180
  * **Diagnostics are typed `never` below `Validated`.** Validation is the last
179
181
  * phase, so at any earlier landmark the array either is not yet computed or
@@ -189,10 +191,23 @@ export interface ModelServiceOptions extends LogNameOptions {
189
191
  * The waits resolve at or ABOVE their target, so an already-validated document
190
192
  * does carry usable diagnostics and the `never` over-forbids there. That
191
193
  * direction is the safe one: the alternative permits stale reads silently. A
192
- * member taking a phase as a PARAMETER cannot judge statically and so returns
193
- * `TDiagnostic`, leaving the choice to the caller.
194
+ * member taking a phase as a PARAMETER returns `TDiagnostic`, and leaves them
195
+ * absent for a phase below `Validated`.
196
+ *
197
+ * **Generic parameters.**
198
+ * - `TAst` — the AST root type each consumer expects on the returned
199
+ * {@link AstDocument}. Constrained to {@link AstNode}.
200
+ * - `TDiagnostic` — the AST-layer diagnostic: whatever the build left on
201
+ * `LangiumDocument.diagnostics`, carried through on the returned
202
+ * {@link AstDocument}. Defaults to {@link AstDiagnostic}.
203
+ * **Not the `TransferEncoder`'s parameter of the same name**, which is
204
+ * that encoder's OUTPUT and so names the wire shape. This one names its
205
+ * input, and an adopter binds the two to different types.
206
+ * - `TTransfer` — transfer-model root a session's `update` / `save` accept
207
+ * args. Constrained to {@link TransferElement}. Defaults to the
208
+ * structural base.
194
209
  */
195
- export interface ModelService<TAst extends AstNode, TDiagnostic = TransferDiagnostic, TTransfer extends TransferElement = TransferElement> {
210
+ export interface ModelService<TAst extends AstNode, TDiagnostic extends AstDiagnostic = AstDiagnostic, TTransfer extends TransferElement = TransferElement> {
196
211
  /**
197
212
  * Resolves once the workspace has been initialised and its first build has
198
213
  * completed — the gate every read should wait behind, since a document
@@ -208,24 +223,116 @@ export interface ModelService<TAst extends AstNode, TDiagnostic = TransferDiagno
208
223
  waitForBuilderState(state: DocumentState, cancelToken?: CancellationToken): Promise<void>;
209
224
  ensureDocumentState(uri: string, state?: DocumentState, cancelToken?: CancellationToken): Promise<AstDocument<TAst, TDiagnostic>>;
210
225
  rebuild(uri: string, state?: DocumentState, cancelToken?: CancellationToken): Promise<AstDocument<TAst, TDiagnostic>>;
226
+ /**
227
+ * Throw where {@link rebuild} would reject as reentrant. A write calls it
228
+ * before applying its text: a text applied and then refused stays applied
229
+ * with no build to follow it.
230
+ */
231
+ assertCanBuild(uri: string): void;
211
232
  parsed(uri: string, cancelToken?: CancellationToken): Promise<AstDocument<TAst, never>>;
212
233
  linked(uri: string, cancelToken?: CancellationToken): Promise<AstDocument<TAst, never>>;
213
234
  settled(uri: string, cancelToken?: CancellationToken): Promise<AstDocument<TAst, never>>;
214
235
  indexed(uri: string, cancelToken?: CancellationToken): Promise<AstDocument<TAst, never>>;
215
236
  validated(uri: string, cancelToken?: CancellationToken): Promise<AstDocument<TAst, TDiagnostic>>;
216
- update(args: TransferUpdateArgs<TTransfer>, cancelToken?: CancellationToken): Promise<AstDocument<TAst, TDiagnostic>>;
217
- save(args: TransferSaveArgs<TTransfer>, cancelToken?: CancellationToken): Promise<AstDocument<TAst, TDiagnostic>>;
218
- open(args: OpenModelArgs): Promise<Disposable>;
219
- close(args: CloseModelArgs): Promise<void>;
220
237
  isOpen(uri: string): boolean;
238
+ /**
239
+ * The version the document at `uri` was opened at, which a client's write
240
+ * or an integrity repair steps past; `undefined` while it is not open.
241
+ */
242
+ openedVersion(uri: string): TextVersion | undefined;
243
+ snapshot(uri: string): AstDocument<TAst, TDiagnostic> | undefined;
244
+ /**
245
+ * The text a session's write of `model` to `uri` applies: a textual model
246
+ * as given, a structured one rewritten and serialised. Also the text to
247
+ * create a document with: for a `uri` with no text the trivia preservers
248
+ * still run, so it gets their defaults, such as
249
+ * `DocumentEndingPreserver.DEFAULT_ENDING`. With
250
+ * {@link ModelServiceOptions.keepUnchangedText} set, a model equal to the
251
+ * document's gives the text its root was parsed from instead.
252
+ */
253
+ modelToText(uri: string, model: TTransfer | string, cancelToken?: CancellationToken): Promise<string>;
221
254
  getDocument(uri: string): LangiumDocument | undefined;
222
- onModelUpdated(uri: string, listener: (event: AstDocumentUpdatedEvent<TAst, TDiagnostic>) => void): Disposable;
223
- onModelSaved(uri: string, listener: (event: AstDocumentSavedEvent<TAst, TDiagnostic>) => void): Disposable;
224
- onClientClosed(uri: string, clientId: string, listener: () => void): Disposable;
255
+ /**
256
+ * Resolve once the document's build has settled and the language client
257
+ * has answered the push of its text, applied or refused and logged, so a
258
+ * save answering after it does not race that push. Does not wait again for
259
+ * a push an earlier settle timed out on and the client has not answered
260
+ * since. Never rejects: past its bound it warns and resolves, and a failed
261
+ * wait is logged and resolves.
262
+ */
263
+ settleLanguageClient(uri: string, cancelToken?: CancellationToken): Promise<void>;
264
+ /**
265
+ * Whether a push of the document's text into the language client awaits the
266
+ * client's answer. A push a settle already timed out on does not count: that
267
+ * settle has warned about it.
268
+ */
269
+ isLanguageClientPushPending(uri: string): boolean;
270
+ /**
271
+ * Fires as a document reaches the filter's phase, `Validated` by default.
272
+ * Listeners run inside the build, so one that throws is logged and the
273
+ * others still run.
274
+ */
275
+ onModelUpdated(listener: (event: ModelUpdatedEvent<TAst, TDiagnostic>) => void, filter?: ModelPhaseFilter): Disposable;
276
+ /**
277
+ * Fires once per build that reaches the phase, with every document it
278
+ * carried there. A listener that throws is logged, as for {@link onModelUpdated}.
279
+ */
280
+ onModelsBuilt(listener: (event: ModelsBuiltEvent) => void, filter?: Pick<ModelPhaseFilter, 'phase'>): Disposable;
281
+ /**
282
+ * Fires for every save, whichever client made it, as the store announces
283
+ * it. A document saved before its first build arrives as an empty envelope
284
+ * at `UNRECORDED_VERSION`, whose `root` is `undefined` despite its type.
285
+ */
286
+ onModelSaved(listener: (event: ModelSavedEvent<TAst, TDiagnostic>) => void, filter?: ModelEventFilter): Disposable;
287
+ /**
288
+ * Fires for every document a build removes, with the session whose
289
+ * `delete` removed it, as `AstDocumentManager.attributeDeletion` names it.
290
+ */
291
+ onModelDeleted(listener: (event: ModelDeletedEvent) => void, filter?: ModelEventFilter): Disposable;
292
+ /** Fires when a document's text starts or stops differing from its file. */
293
+ onDirtyChanged(listener: (event: ModelDirtyChangedEvent) => void, filter?: ModelEventFilter): Disposable;
294
+ /**
295
+ * Fires when the store releases a document no client has open any more.
296
+ * What the build keeps for it is up to the
297
+ * `DocumentReleaseHandler` slot; the default reverts it to disk, and that
298
+ * rebuild follows as an {@link onModelUpdated} event, unless a client opens
299
+ * the document first or its file is deleted.
300
+ */
301
+ onModelReleased(listener: (event: ModelReleasedEvent) => void, filter?: ModelEventFilter): Disposable;
302
+ /** Fires when `filter.clientId` closes `filter.uri`, its session ending included. */
303
+ onClientClosed(listener: () => void, filter: {
304
+ readonly uri: string;
305
+ readonly clientId: string;
306
+ }): Disposable;
307
+ /**
308
+ * Start a client session, the only way to open and write documents through
309
+ * this service. Pass a `label` naming the participant; without one it is
310
+ * `session`. The id defaults to `label#` plus a random UUID; a fixed
311
+ * `clientId` is taken as given. Throws `ReservedClientIdError` when the id
312
+ * is reserved by the framework, and `DuplicateClientIdError` when it is
313
+ * held by another live session or has documents open under it as a client
314
+ * that is not a session.
315
+ *
316
+ * A `resumeToken` matching the one the live session under `clientId` was
317
+ * started with ends that session as lost first, so the documents it was
318
+ * last to hold keep their unsaved text for the new one. The token guards
319
+ * against taking over a session by accident, not against a peer: anyone who
320
+ * knows it can end the session.
321
+ *
322
+ * `TOpenOptions` types the options the session's `open` takes and its
323
+ * `openOptions` returns. The narrowing is an unchecked cast, and it holds
324
+ * only for the caller that started the session: a holder reached through
325
+ * {@link getSession} sees plain `OpenOptions`.
326
+ */
327
+ createSession<TOpenOptions extends OpenOptions = OpenOptions>(label?: string, clientId?: string, options?: {
328
+ readonly resumeToken?: string;
329
+ }): ClientSession<TAst, TDiagnostic, TTransfer, TOpenOptions>;
330
+ /** The live session started under `clientId`, or `undefined` once it has ended or was never started. */
331
+ getSession(clientId: string): ClientSession<TAst, TDiagnostic, TTransfer> | undefined;
225
332
  }
226
- export declare class DefaultModelService<TAst extends AstNode, TDiagnostic = TransferDiagnostic,
333
+ export declare class DefaultModelService<TAst extends AstNode, TDiagnostic extends AstDiagnostic = AstDiagnostic,
227
334
  /**
228
- * Structured payload accepted by `update` / `save`. Constrained to
335
+ * Structured payload a session's `update` / `save` accept. Constrained to
229
336
  * {@link TransferElement} — the minimal `{ readonly $type: string }`
230
337
  * shape. Both transfer-model overlay roots (which extend
231
338
  * `TransferElement` explicitly) and AST root types (which have
@@ -245,14 +352,10 @@ TTransfer extends TransferElement = TransferElement> implements ModelService<TAs
245
352
  * (see {@link DocumentUriPolicy}).
246
353
  */
247
354
  protected readonly uriPolicy: DocumentUriPolicy;
248
- /**
249
- * Live slow-update-warn threshold cell, or `undefined` when the option
250
- * was not supplied (warn line + stopwatch disabled). Reads `.value` per
251
- * update so a setting-bound threshold retunes without reconstruction.
252
- */
253
- protected readonly slowUpdateWarn?: ObservableValue<number>;
254
- /** See {@link ModelServiceOptions.serializeBuilds}. Defaults to `true`. */
255
- protected readonly serializeBuilds: ObservableValue<boolean>;
355
+ /** See {@link ModelServiceOptions.allowReentrantBuilds}. Defaults to `false`. */
356
+ protected readonly allowReentrantBuilds: ObservableValue<boolean>;
357
+ /** See {@link ModelServiceOptions.keepUnchangedText}. Defaults to `false`. */
358
+ protected readonly keepUnchangedText: ObservableValue<boolean>;
256
359
  /**
257
360
  * Per-URI applyEdit coalescing: at most one in-flight `applyEditToLanguageClient`
258
361
  * RPC per URI, newest text wins. A newer settle while the current RPC is in
@@ -261,6 +364,29 @@ TTransfer extends TransferElement = TransferElement> implements ModelService<TAs
261
364
  */
262
365
  protected readonly syncChains: Map<string, Promise<void>>;
263
366
  protected readonly pendingSync: Map<string, string>;
367
+ /**
368
+ * The sync chains a settle timed out on, until the client answers their
369
+ * push. A later settle does not wait on one meanwhile: GLSP runs a diagram's
370
+ * saves one at a time, so each would add the full bound and a queued save
371
+ * outlast its client's timeout.
372
+ */
373
+ protected readonly timedOutSyncChains: WeakSet<Promise<void>>;
374
+ /** The live sessions this service started, by client id, for {@link getSession}. */
375
+ protected readonly sessions: Map<string, ClientSession<TAst, TDiagnostic, TTransfer, object>>;
376
+ /**
377
+ * Drops an ended session from {@link sessions}. Subscribed by the first
378
+ * {@link createSession} rather than at construction, so a services tree with
379
+ * no text store, or one that knows nothing of sessions, still constructs
380
+ * this service.
381
+ */
382
+ protected sessionCloseListener?: Disposable;
383
+ /** The token each live session was started with, by client id, for a takeover by {@link createSession}. */
384
+ protected readonly resumeTokens: Map<string, string>;
385
+ /**
386
+ * The {@link onModelUpdated} subscribers, by phase. One builder listener per
387
+ * phase serves them all, kept for the life of the service.
388
+ */
389
+ protected readonly updateSubscribers: Map<DocumentState, Set<ModelUpdateSubscriber<TAst, TDiagnostic>>>;
264
390
  /**
265
391
  * Workspace-level readiness gate. Resolves when the framework has
266
392
  * finished its first workspace build cycle and the `ModelService`
@@ -296,10 +422,12 @@ TTransfer extends TransferElement = TransferElement> implements ModelService<TAs
296
422
  readonly ready: Promise<void>;
297
423
  constructor(services: ServerSharedServices, options?: ModelServiceOptions);
298
424
  /**
299
- * Wait for the document at `uri` to reach `state`. Pure wait — does
300
- * not trigger a build. If `uri` is not yet in the document registry
301
- * the call will hang until something else drives it through the
302
- * pipeline; for the cold-start case use {@link rebuild} instead.
425
+ * Wait for the document at `uri` to reach `state` with a root no older than
426
+ * the store's text at the call. Rejects if `uri` is not in the document
427
+ * registry. A root behind its text is not built: the wait lasts until
428
+ * something else builds it, so use {@link ensureDocumentState} where
429
+ * nothing may. Builds that keep failing leave the wait pending, to its
430
+ * cancellation token.
303
431
  *
304
432
  * Wrapped in a debug-level timing log via {@link Tracer.time} so
305
433
  * slow per-URI waits surface in build telemetry; the URI is
@@ -310,8 +438,7 @@ TTransfer extends TransferElement = TransferElement> implements ModelService<TAs
310
438
  * Wait for the document at `uri` to reach the integrity-settled landmark
311
439
  * ({@link IntegrityService.SettledState}) — the earliest phase at which the
312
440
  * AST + serialised text are stable post-integrity. Convenience wrapper over
313
- * {@link waitForDocumentState} for the common "wait until content is stable"
314
- * case (e.g. settling a save). Pure wait — does not trigger a build.
441
+ * {@link waitForDocumentState}, and like it builds nothing behind its text.
315
442
  */
316
443
  waitForDocumentSettled(uri: string, cancelToken?: CancellationToken): Promise<AstDocument<TAst, never>>;
317
444
  /**
@@ -323,8 +450,31 @@ TTransfer extends TransferElement = TransferElement> implements ModelService<TAs
323
450
  * the identity once instead of re-running the (filesystem-touching) `realpath`
324
451
  * at every wait. The `CanonicalUri` parameter type enforces that — a raw
325
452
  * `string` cannot be passed without minting through the URI policy.
453
+ *
454
+ * With `options.sync`, a root behind the store's text is built, as in
455
+ * {@link ensureDocumentState}; without it, the root is left to other builds,
456
+ * as in {@link waitForDocumentState}. Below `Validated` the envelope has no
457
+ * diagnostics: see {@link withoutDiagnostics}.
458
+ */
459
+ protected waitForDocumentStateCanonical(uri: CanonicalUri, state: DocumentState, cancelToken?: CancellationToken, options?: SyncedWaitOptions): Promise<AstDocument<TAst, TDiagnostic>>;
460
+ /**
461
+ * Wait for `state` with a root parsed from text at `textVersion` or later. A
462
+ * root no factory recorded counts as synced, since no build records it.
463
+ * With `options.sync`, a root still behind is built through
464
+ * `VersionSyncService.syncTo`, and the wait rejects once that build, or one
465
+ * the builder re-queues to reach `state`, is given up. Without it, the wait
466
+ * lasts until another build parses the text, and stays pending when the
467
+ * builder gives up re-queuing the document.
468
+ */
469
+ protected waitUntilSynced(uri: URI, state: DocumentState, textVersion: TextVersion | undefined, cancelToken?: CancellationToken, options?: SyncedWaitOptions): Promise<void>;
470
+ /**
471
+ * Resolves once a parse of `uri` has been recorded or a build has deleted
472
+ * it, rejecting with `OperationCancelled` when `cancelToken` is cancelled
473
+ * first, and with an error when `build`, the build requested for it, is
474
+ * given up. A `Parsed` phase listener cannot serve: a cancel right after the
475
+ * parse skips it, and the resumed build does not parse again.
326
476
  */
327
- protected waitForDocumentStateCanonical(uri: CanonicalUri, state: DocumentState, cancelToken?: CancellationToken): Promise<AstDocument<TAst, TDiagnostic>>;
477
+ protected nextParseOrDeletion(uri: URI, cancelToken?: CancellationToken, build?: Promise<void>): Promise<void>;
328
478
  /**
329
479
  * Wait for the document builder to reach `state` across its currently-
330
480
  * queued documents. Pure wait — does not trigger a build. Used by
@@ -339,31 +489,35 @@ TTransfer extends TransferElement = TransferElement> implements ModelService<TAs
339
489
  * Force a fresh build of the document at `uri` and wait for it to
340
490
  * reach `state` (or the integrity-settled landmark
341
491
  * {@link IntegrityService.SettledState} if omitted).
342
- * Always triggers `DocumentBuilder.update([uri], [])` regardless of
343
- * whether the document is already in the registry — call this when
344
- * you want to re-process from scratch.
492
+ * Always builds the document, whether or not it is already in the
493
+ * registry, in a build of its own or in one already scheduled that carries
494
+ * it — call this when you want to re-process from scratch.
345
495
  *
346
- * The facade is responsible for firing `DocumentBuilder.update`
347
- * directly because Langium's `DefaultDocumentUpdateHandler.didChangeContent`
496
+ * The facade is responsible for requesting the build itself because Langium's `DefaultDocumentUpdateHandler.didChangeContent`
348
497
  * (the standard text-document → builder bridge) only runs under an
349
498
  * LSP `Connection`. Running headless the bridge never fires; the
350
499
  * facade stands in for it on its own update path.
351
500
  *
352
501
  * Coexistence with an LSP head running on the same `DocumentBuilder` is
353
- * fine, but not because the builder merges the two: Langium does NOT
354
- * coalesce concurrent builds of the same URI. The LSP head fires `update`
355
- * from the LSP-driven event and the facade fires it from its own RPC-driven
356
- * event — both legitimate — so this method takes the workspace WRITE lock,
357
- * the same one Langium's own text-change bridge builds under, to serialise
358
- * them. Two unserialised builds of one URI each run a full validation pass
359
- * and Langium appends the second set onto the first, duplicating every
360
- * diagnostic. Opt out via
361
- * {@link ModelServiceOptions.serializeBuilds} — see there for the
362
- * non-reentrancy hazard that is the reason the opt-out exists.
363
- *
364
- * Returns an empty `{ root, diagnostics }` envelope when the document
365
- * cannot be loaded; adopters that want to throw override this method
366
- * on their subclass.
502
+ * fine: the LSP head builds from the LSP-driven event and the facade from
503
+ * its own RPC-driven event — both legitimate — and both go through
504
+ * `HydraniumDocumentBuilder.scheduleUpdate`, which serialises them under
505
+ * the workspace WRITE lock and lets the second share the first's build
506
+ * where that build carries it. Langium alone does not coalesce concurrent
507
+ * builds of one URI: two unserialised builds each run a full validation
508
+ * pass and Langium appends the second set onto the first, duplicating every
509
+ * diagnostic. A caller that already holds the lock builds without it only
510
+ * under {@link ModelServiceOptions.allowReentrantBuilds} — see there for the
511
+ * non-reentrancy hazard.
512
+ *
513
+ * An override calls the base before it awaits. Under an LSP connection the
514
+ * store's change event has already asked the update handler to build a
515
+ * session's write; an override whose await outlasts that build makes the
516
+ * base's request start a build of its own, so the write is built and
517
+ * delivered twice.
518
+ *
519
+ * Rejects when the build leaves no document for `uri`, as for a URI with
520
+ * neither a file nor text: the wait after it has nothing to wait on.
367
521
  *
368
522
  * Consumers wanting "give me this doc at state X, building only if
369
523
  * needed" — use the per-state methods ({@link parsed} / {@link linked}
@@ -372,22 +526,20 @@ TTransfer extends TransferElement = TransferElement> implements ModelService<TAs
372
526
  rebuild(uri: string, state?: DocumentState, cancelToken?: CancellationToken): Promise<AstDocument<TAst, TDiagnostic>>;
373
527
  /**
374
528
  * Internal build core operating on an already-{@link CanonicalUri canonical}
375
- * URI — the build counterpart to {@link waitForDocumentStateCanonical}. Drives
376
- * `DocumentBuilder.update` then waits via the canonical wait core, so the
529
+ * URI — the build counterpart to {@link waitForDocumentStateCanonical}.
530
+ * Requests the build, then waits via the canonical wait core, so the
377
531
  * identity is resolved once at the public door and neither sink re-runs the
378
532
  * `realpath`. (`DocumentBuilder.update` still resolves each URI internally for
379
533
  * directory flattening — that is the build's own existence-aware resolution,
380
534
  * not a redundant identity canonicalisation.)
381
535
  */
382
536
  protected rebuildCanonical(uri: CanonicalUri, state?: DocumentState, cancelToken?: CancellationToken): Promise<AstDocument<TAst, TDiagnostic>>;
537
+ assertCanBuild(uri: string): void;
383
538
  /**
384
539
  * Per-state typed convenience methods. Each ensures the document at
385
540
  * `uri` reaches the named phase and returns the AST envelope with
386
- * the narrowest accurate diagnostics type for that phase. Smart
387
- * dispatch internally: warm path (URI already in the document
388
- * registry) just waits via {@link waitForDocumentState}; cold path
389
- * triggers a build via {@link rebuild}. Consumers do not need to
390
- * know which path was taken.
541
+ * the narrowest accurate diagnostics type for that phase, building as
542
+ * {@link ensureDocumentState} does.
391
543
  *
392
544
  * Phase invariants encoded in the return type:
393
545
  * - `parsed` / `linked` / `settled` / `indexed` return
@@ -396,16 +548,13 @@ TTransfer extends TransferElement = TransferElement> implements ModelService<TAs
396
548
  * - `validated` returns `AstDocument<TAst, TDiagnostic>` — diagnostics
397
549
  * are populated.
398
550
  *
399
- * **The `never` is a claim about the PHASE, not a guarantee about the
400
- * instance, and the gap is reachable rather than theoretical.** The wait
401
- * underneath resolves at or ABOVE the requested state, so a document
402
- * something else already carried past `Validated` comes back from
403
- * `settled()` with a populated diagnostics array typed `never`. Nothing
404
- * strips it — the envelope copies the live document's array verbatim — and
405
- * any host that validates its workspace before a consumer asks produces
406
- * exactly that. So read an empty array as "none were computed, or there are
407
- * none", never as "this document is clean", and call {@link validated} when
408
- * the answer has to mean the second.
551
+ * **The `never` is enforced, not merely declared.** The wait underneath
552
+ * resolves at or ABOVE the requested state, so a document something else
553
+ * already carried past `Validated` would otherwise come back from
554
+ * `settled()` carrying a full diagnostics array typed `never`; these four
555
+ * strip it. An empty array here therefore means "this read does not report
556
+ * diagnostics", never "this document is clean" — call {@link validated}
557
+ * when the answer has to mean the second.
409
558
  *
410
559
  * `settled` is the integrity-overlay name for "all integrity rules
411
560
  * have fired"; it maps to {@link IntegrityService.SettledState} (which
@@ -421,18 +570,13 @@ TTransfer extends TransferElement = TransferElement> implements ModelService<TAs
421
570
  /**
422
571
  * Ensure the document at `uri` reaches `state` (or the integrity-settled
423
572
  * landmark {@link IntegrityService.SettledState} if omitted) and return its
424
- * AST envelope. Smart
425
- * dispatch: warm path (URI already in `LangiumDocuments`) just waits
426
- * via {@link waitForDocumentState}; cold path forces a build via
427
- * {@link rebuild}.
428
- *
429
- * Pairs with {@link rebuild} — same default phase, but `rebuild`
430
- * always builds while this skips the build for an already-loaded
431
- * document. Also pairs with {@link waitForDocumentState} — the verb
432
- * difference (`ensure` vs `waitFor`) signals the side-effect
433
- * difference. The per-state convenience methods (`parsed` / `linked`
434
- * / `settled` / `indexed` / `validated`) all delegate here with an
435
- * explicit phase.
573
+ * AST envelope, with a root no older than the store's text at the call.
574
+ * A document not in `LangiumDocuments` is built via {@link rebuild}; a
575
+ * loaded one whose root is behind its text is built through
576
+ * `VersionSyncService.syncTo`. Until `state` is reached, the call rejects
577
+ * once that build, or one the builder re-queues, has failed twice, or the
578
+ * builder stops re-queuing the document. A loaded, current document is only
579
+ * awaited.
436
580
  */
437
581
  ensureDocumentState(uri: string, state?: DocumentState, cancelToken?: CancellationToken): Promise<AstDocument<TAst, TDiagnostic>>;
438
582
  /**
@@ -447,80 +591,49 @@ TTransfer extends TransferElement = TransferElement> implements ModelService<TAs
447
591
  */
448
592
  protected ensureDocumentStateCanonical(uri: CanonicalUri, state?: DocumentState, cancelToken?: CancellationToken): Promise<AstDocument<TAst, TDiagnostic>>;
449
593
  /**
450
- * Apply an update for `uri`. The structured-or-textual `model` payload
451
- * is serialised (via {@link serialize} after {@link rewriteModel} when
452
- * structured), pushed into the multi-client text-document store with
453
- * a fresh version, drives a build to the target phase, and returns
454
- * the post-build AST snapshot.
455
- *
456
- * **Read-latest supersession**: concurrent callers on the same URI
457
- * all see the same post-build state once `waitUntil` resolves; none
458
- * deadlock waiting for a specific version's settled event. The
459
- * framework emits a post-resolution `debug` log line distinguishing
460
- * "vN ready" from "vN ready at vM (superseded)" so callers can
461
- * observe when their write was overtaken by a newer one before
462
- * settling — purely observability, doesn't change resolution
463
- * semantics. Adopters wanting version-matched resolution (resolve
464
- * with vN's specific settled snapshot, intermediate-phase
465
- * observability, slow-warn / hard-timeout behaviour) override this
466
- * method.
467
- */
468
- update(args: TransferUpdateArgs<TTransfer>, cancelToken?: CancellationToken): Promise<AstDocument<TAst, TDiagnostic>>;
469
- /**
470
- * Persist `uri` to disk. Same content-change + settled-phase flow as
471
- * {@link update}, then writes via the
472
- * `WritableFileSystemProvider` and notifies the multi-client
473
- * text-document store of the save (so any open LSP-side editor sees
474
- * the `onDidSave` event regardless of who originated the persist).
475
- *
476
- * Returns the post-save AST snapshot.
477
- */
478
- save(args: TransferSaveArgs<TTransfer>, cancelToken?: CancellationToken): Promise<AstDocument<TAst, TDiagnostic>>;
479
- /**
480
- * Wait for the document at `uri` to reach the integrity-settled landmark and
594
+ * Wait for the document at `uri` to reach the integrity-settled landmark,
595
+ * building a root behind its text as {@link ensureDocumentState} does, and
481
596
  * drain any in-flight write-path applyEdit sync chain (see {@link syncChains})
482
- * so every language client reflects the latest content before a save returns.
483
- * No-op tail for headless adopters — `syncChains` is empty without an LSP
484
- * client. Bounded by {@link SAVE_SETTLE_TIMEOUT_MS} so a hung build, or an
485
- * applyEdit reverse-RPC deadlock, can't freeze the caller; on timeout it logs
486
- * a warning and returns rather than throwing.
487
- *
488
- * Adopters with a save flow that must converge editor + disk before returning
489
- * (e.g. a dual form/code editor that would otherwise show a content-conflict
490
- * dialog on rapid save) call this after their `save`.
491
- */
492
- protected settleSave(uri: string, cancelToken?: CancellationToken): Promise<void>;
493
- /**
494
- * Open the document at `args.uri` on behalf of `args.clientId`.
495
- * Multi-client: each (uri, clientId) pair is tracked as one
496
- * registration; the underlying document stays open until the last
497
- * client closes it. If `args.text` is omitted the document content
498
- * is read from the `FileSystemProvider`.
499
- *
500
- * Returns a {@link Disposable} that closes the registration when
501
- * disposed — useful for `using` blocks and shutdown cleanup.
502
- *
503
- * Delegates to the framework-bound
504
- * `services.workspace.AstDocumentManager`. Adopter subclasses with
505
- * extra open-time behaviour (logging, sync-chain bootstrapping)
506
- * override on their `ModelService` subclass and call `super.open`.
507
- *
508
- * The open path does not thread cancellation: `AstDocumentManager.open`
509
- * and the filesystem read behind it take no token, so a cancelled caller
510
- * still completes the open.
511
- */
512
- open(args: OpenModelArgs): Promise<Disposable>;
513
- /**
514
- * Close the document at `args.uri` for `args.clientId`. Counterpart
515
- * to {@link open}; the underlying document stays open until every
516
- * registered client has closed.
517
- */
518
- close(args: CloseModelArgs): Promise<void>;
597
+ * so the language client has answered the push of the latest content before
598
+ * this returns; a push it refused twice is logged, not retried. No-op tail
599
+ * for headless adopters — `syncChains` is empty without an LSP client.
600
+ * Bounded at 10 s so a hung build, or an applyEdit reverse-RPC deadlock,
601
+ * can't freeze the caller; it returns rather than throwing, warning on
602
+ * timeout. A failed wait is logged at `error`, at `debug` when cancelled and
603
+ * at `warn` when the document is gone.
604
+ *
605
+ * The framework's save handlers call this after their persist, the data
606
+ * head's updates after their write and the GLSP head's settle request for
607
+ * each document a save writes; an adopter's own save path that answers a
608
+ * client calls it after its `save` too.
609
+ */
610
+ settleLanguageClient(uri: string, cancelToken?: CancellationToken): Promise<void>;
611
+ isLanguageClientPushPending(uri: string): boolean;
519
612
  /**
520
613
  * True when the document at `uri` is currently open for at least one
521
614
  * client. Pure read; no side effects.
522
615
  */
523
616
  isOpen(uri: string): boolean;
617
+ openedVersion(uri: string): TextVersion | undefined;
618
+ /**
619
+ * Snapshot of `uri` as it stands RIGHT NOW — the synchronous sibling of the
620
+ * phase reads, which all wait. `undefined` when no document is registered,
621
+ * or only the builder's placeholder for one its build has not parsed yet:
622
+ * that root is no parse of any text, and its version gates no write.
623
+ *
624
+ * **This is what a writer wants, and {@link getDocument} is not.** The
625
+ * envelope's `version` is copied by value at projection time, so it cannot
626
+ * move afterwards; a version read off the live document at write time is
627
+ * whatever the server is at *now*, which is the number an optimistic gate is
628
+ * about to compare it against.
629
+ *
630
+ * Diagnostics only from a document that has reached `Validated`, and absent
631
+ * otherwise. Unlike the phase reads this one names no phase, so
632
+ * the state it finds is the only thing that can say whether the array
633
+ * describes the content being handed back or whatever an earlier build left.
634
+ * A caller that needs them unconditionally waits, via {@link validated}.
635
+ */
636
+ snapshot(uri: string): AstDocument<TAst, TDiagnostic> | undefined;
524
637
  /**
525
638
  * The built {@link LangiumDocument} for `uri`, looked up by canonical identity —
526
639
  * the synchronous, phase-agnostic sibling of {@link ensureDocumentState} /
@@ -529,24 +642,49 @@ TTransfer extends TransferElement = TransferElement> implements ModelService<TAs
529
642
  * into `LangiumDocuments` directly: a symlinked / `..` / case-divergent URI
530
643
  * still resolves to the one document the build keys by its real path. Returns
531
644
  * `undefined` if no document is registered for `uri`.
645
+ *
646
+ * **Live, so do not take a base version off it.** `textDocument` is the
647
+ * store's own object rather than a copy, so `.version` read here answers for
648
+ * the moment of the READ, not the moment of the earlier content — pass it to
649
+ * a write and the server compares its current version against itself, the
650
+ * gate passes unconditionally, and a concurrent edit is overwritten with
651
+ * nothing logged. Use {@link snapshot} for that, or a phase read.
532
652
  */
533
653
  getDocument(uri: string): LangiumDocument | undefined;
654
+ createSession<TOpenOptions extends OpenOptions = OpenOptions>(label?: string, clientId?: string, options?: {
655
+ readonly resumeToken?: string;
656
+ }): ClientSession<TAst, TDiagnostic, TTransfer, TOpenOptions>;
657
+ getSession(clientId: string): ClientSession<TAst, TDiagnostic, TTransfer> | undefined;
658
+ /**
659
+ * Convert a structured-or-textual `model` payload to its textual form.
660
+ *
661
+ * Textual payloads (LSP / pre-serialised callers) pass through untouched.
662
+ * Structured payloads run the per-language `UpdateRewriteService` chain
663
+ * (transfer-model transforms; diff-aware rewrites see the previous AST root),
664
+ * then serialise. The chain is the single transfer-model-transform seam — a
665
+ * unary normalisation is just a rewrite that ignores `previous`, as
666
+ * `NormalizeEmptyStringsContribution` does. The chain is empty by
667
+ * default, so this is a no-op for adopters that register none.
668
+ *
669
+ * The serialised text then takes the trivia of the text it replaces, or of
670
+ * an empty one when `uri` has none, so a created document gets the
671
+ * preservers' defaults rather than the serializer's bare output. Under
672
+ * {@link ModelServiceOptions.keepUnchangedText} the document's own text is
673
+ * returned when it parses to a model that serializes to the same text.
674
+ */
675
+ modelToText(uri: string, model: TTransfer | string, cancelToken?: CancellationToken): Promise<string>;
534
676
  /**
535
677
  * Mirror a server-side change of `document` back to the LSP textual language
536
678
  * client, run per document as it reaches the post-integrity settled phase.
537
679
  * The single framework caller of
538
- * `HydraniumTextDocuments.applyEditToLanguageClient` and
539
- * `HydraniumTextDocuments.stagePendingContent`.
680
+ * `HydraniumTextDocuments.applyEditToLanguageClient`.
540
681
  *
541
- * Routes to one of two mechanisms by language-client registration, because
542
- * an open and a closed document answer different questions:
543
- *
544
- * - **Open in the language client** → {@link syncOpenDocument}: mirror the
545
- * settled text via a coalesced `applyEditToLanguageClient`, routed purely by
546
- * **content**.
547
- * - **Closed in the language client** → {@link stageClosedDocument}: stage the
548
- * text for the eventual first `didOpen`, gated by **provenance**
549
- * ({@link isNonLanguageClientEdit}).
682
+ * Only a document open in the language client is mirrored, through
683
+ * {@link syncOpenDocument}, routed purely by **content**. A document open
684
+ * only in another client needs nothing: a language client opening it joins
685
+ * the existing entry and is refreshed from the store. A session writes only
686
+ * what it has open, so no session edit of a closed document waits here for
687
+ * the language client's next open.
550
688
  *
551
689
  * The decision is **re-derived from the current settled state every time** (it
552
690
  * is not a one-shot enrolment), which is what makes it self-healing: a doc
@@ -567,35 +705,6 @@ TTransfer extends TransferElement = TransferElement> implements ModelService<TAs
567
705
  * author-based skip is needed.
568
706
  */
569
707
  protected syncOpenDocument(uri: string, text: string): void;
570
- /**
571
- * Stage the settled text of a document closed in the language client so the
572
- * eventual first `didOpen` sees this in-memory text instead of stale disk —
573
- * but only for a {@link isNonLanguageClientEdit genuine non-language-client edit}.
574
- * A document rebuilt by an internal build is skipped, leaving disk authoritative
575
- * on the next open.
576
- */
577
- protected stageClosedDocument(document: LangiumDocument): void;
578
- /**
579
- * Whether `document`'s settled state is a genuine edit by a client *other than
580
- * the language client* — a write a form / GLSP / integrity client actually made.
581
- * Excludes two non-edits: the **language client** itself (the LSP/Monaco text
582
- * client — it already holds its own edits, and the staging here exists to feed
583
- * it) and an **internal build** (workspace startup, a cascade relink, a
584
- * `didClose`-reload). This is the gate for {@link stageClosedDocument}: staging
585
- * an internal build would
586
- * (a) pre-stage every file on boot and (b) re-stage discarded content after
587
- * close (e.g. a disposing GLSP session's debounced submit firing after close),
588
- * which then shadows clean disk on the next open.
589
- *
590
- * The signal is "a known client other than the language client authored this
591
- * version **and** the URI was in the last build's changed set
592
- * (`isTriggeringEdit`)". A framework-internal rebuild reports no author
593
- * (`getAuthor` → `undefined`), so it fails `hasKnownAuthor` without comparing
594
- * against a sentinel. This is NOT redundant with content/registration — it
595
- * distinguishes "client edited" from "framework rebuilt", which neither the
596
- * shadow nor `isTriggeringEdit` alone can.
597
- */
598
- protected isNonLanguageClientEdit(document: LangiumDocument): boolean;
599
708
  /**
600
709
  * Enqueue a sync to the language client. The pending slot per URI holds only
601
710
  * the latest text: if a newer settle fires while the current RPC is in
@@ -615,32 +724,25 @@ TTransfer extends TransferElement = TransferElement> implements ModelService<TAs
615
724
  */
616
725
  protected editLabel(): string;
617
726
  protected drainSyncQueue(uri: string): Promise<void>;
618
- /**
619
- * Subscribe to AST-snapshot updates for `uri`. Fires after each
620
- * rebuild that reaches the target phase. Delegates to the
621
- * `HydraniumTextDocuments` — single listener registration shared with
622
- * any direct `HydraniumTextDocuments.onUpdate` subscriber, so the same
623
- * underlying `DocumentBuilder.onDocumentPhase` listener serves both
624
- * call paths. `sourceClientId` is resolved from the multi-client
625
- * author history; reason discrimination follows the manager's own
626
- * `lastUpdate` snapshot (see `AstDocumentManager.onUpdate`).
627
- */
628
- onModelUpdated(uri: string, listener: (event: AstDocumentUpdatedEvent<TAst, TDiagnostic>) => void): Disposable;
629
- /**
630
- * Subscribe to save events for `uri`. Fires on every persist through
631
- * the multi-client text-document store — including saves originated
632
- * by other heads (LSP editor `Ctrl+S`, the data-server `save`, etc.)
633
- * so subscribers see one consistent stream regardless of who wrote
634
- * the file. Delegates to the manager — single listener registration
635
- * shared with any direct `HydraniumTextDocuments.onSave` subscriber.
636
- */
637
- onModelSaved(uri: string, listener: (event: AstDocumentSavedEvent<TAst, TDiagnostic>) => void): Disposable;
638
- /**
639
- * Subscribe to the `(uri, clientId)` close event. Delegates to the
640
- * manager so the listener registry is shared with any direct
641
- * `HydraniumTextDocuments.onClientClosed` subscriber.
642
- */
643
- onClientClosed(uri: string, clientId: string, listener: () => void): Disposable;
727
+ onModelUpdated(listener: (event: ModelUpdatedEvent<TAst, TDiagnostic>) => void, filter?: ModelPhaseFilter): Disposable;
728
+ onModelsBuilt(listener: (event: ModelsBuiltEvent) => void, filter?: Pick<ModelPhaseFilter, 'phase'>): Disposable;
729
+ onModelSaved(listener: (event: ModelSavedEvent<TAst, TDiagnostic>) => void, filter?: ModelEventFilter): Disposable;
730
+ onModelDeleted(listener: (event: ModelDeletedEvent) => void, filter?: ModelEventFilter): Disposable;
731
+ onDirtyChanged(listener: (event: ModelDirtyChangedEvent) => void, filter?: ModelEventFilter): Disposable;
732
+ onModelReleased(listener: (event: ModelReleasedEvent) => void, filter?: ModelEventFilter): Disposable;
733
+ onClientClosed(listener: () => void, filter: {
734
+ readonly uri: string;
735
+ readonly clientId: string;
736
+ }): Disposable;
737
+ protected filterUri(filter: ModelEventFilter): CanonicalUri | undefined;
738
+ protected matches(target: CanonicalUri | undefined, uri: CanonicalUri): boolean;
739
+ /**
740
+ * Hand every subscriber of `phase` for `document` one event, built once, so
741
+ * all of them see the same attribution. Built inside the build's listener
742
+ * and handed out without an await: after one, another build can have reset
743
+ * the document.
744
+ */
745
+ protected deliverUpdate(phase: DocumentState, subscribers: ReadonlySet<ModelUpdateSubscriber<TAst, TDiagnostic>>, document: LangiumDocument, cancelToken: CancellationToken): void;
644
746
  /**
645
747
  * Serialise a transfer-model root via the language-specific
646
748
  * `Serializer` bound at `services.serializer.Serializer`,
@@ -652,28 +754,25 @@ TTransfer extends TransferElement = TransferElement> implements ModelService<TAs
652
754
  * Adopters whose serializer call shape differs (custom service
653
755
  * names, generator-driven YAML pretty printers, etc.) override this
654
756
  * method. Routes through `Serializer.serializeTransfer` because
655
- * `ModelService.update` / `ModelService.save` always receive a
757
+ * a session's `update` / `save` always receive a
656
758
  * transfer-model shape (cross-references as plain strings) from
657
759
  * adopter callers — the AST-shape entry point is `serializeAst`.
658
760
  *
659
761
  * Returns {@link MaybePromise} so adopter `Serializer` overrides can be
660
762
  * async (remote schema lookup, external canonical-value resolution); the
661
- * single caller ({@link modelToText} → {@link update}) is already `async`,
763
+ * single caller ({@link modelToText}) is already `async`,
662
764
  * so a naive `await` covers both branches without extra ceremony.
663
765
  */
664
766
  protected serialize(uri: string, root: TTransfer): MaybePromise<string>;
665
767
  /**
666
- * Convert a structured-or-textual `model` payload to its textual form.
667
- *
668
- * Textual payloads (LSP / pre-serialised callers) pass through untouched.
669
- * Structured payloads run the per-language `UpdateRewriteService` chain
670
- * (transfer-model transforms; diff-aware rewrites see the previous AST root),
671
- * then serialise. The chain is the single transfer-model-transform seam — a
672
- * unary normalisation is just a rewrite that ignores `previous`, as
673
- * `NormalizeEmptyStringsContribution` does. The chain is empty by
674
- * default, so this is a no-op for adopters that register none.
768
+ * The text a write into a document not yet built should take its trivia
769
+ * from: the store's, which a write always has, since it writes only a
770
+ * document its client has open. `undefined` when the store holds no text
771
+ * for `uri`: a document not yet created, or a file on disk that the
772
+ * workspace has not read and no client has open. The preservers then run
773
+ * over empty text, as for a created document; no answer skips them.
675
774
  */
676
- protected modelToText(uri: string, model: TTransfer | string, cancelToken?: CancellationToken): Promise<string>;
775
+ protected textToTakeTriviaFrom(uri: string, _target: URI): Promise<string | undefined>;
677
776
  /**
678
777
  * Run the per-language transfer-model rewrite chain. Resolves the
679
778
  * `UpdateRewriteService` per-URI (like {@link serialize}) and threads
@@ -684,11 +783,29 @@ TTransfer extends TransferElement = TransferElement> implements ModelService<TAs
684
783
  protected rewriteModel(uri: string, model: TTransfer, cancelToken?: CancellationToken): Promise<TTransfer>;
685
784
  /**
686
785
  * Build an {@link AstDocument} envelope from the current
687
- * {@link LangiumDocument} state via the shared {@link AstDocument.from}
688
- * projection. Returns an empty envelope (built via
786
+ * {@link LangiumDocument} state via `AstDocumentManager.toAstDocument`,
787
+ * the projection events use too. Returns an empty envelope (built via
689
788
  * {@link AstDocument.create}) when the document is absent from the
690
- * registry — adopters that prefer to throw override on their subclass.
789
+ * registry — adopters that prefer to throw override on their subclass. Its
790
+ * version is {@link UNRECORDED_VERSION}, so a write based on it conflicts.
691
791
  */
692
792
  protected toAstDocument(uri: URI): AstDocument<TAst, TDiagnostic>;
793
+ /**
794
+ * The same envelope with no diagnostics, for a read that names a phase below
795
+ * `Validated`. Absent rather than `[]`, which says the document was validated
796
+ * and found clean.
797
+ *
798
+ * Langium fills `LangiumDocument.diagnostics` from inside `validateDocument`
799
+ * and from nowhere else, so below that phase the array holds whatever an
800
+ * EARLIER build left — a verdict about text the document may no longer have.
801
+ * The wait underneath resolves at or above the phase asked for, so a document
802
+ * something else carried past `Validated` would otherwise hand a full array
803
+ * back from `parsed()`.
804
+ *
805
+ * A copy rather than a clear: the envelope is freshly built here, but
806
+ * {@link toAstDocument} is overridable and an adopter's version may return
807
+ * one it also keeps.
808
+ */
809
+ protected withoutDiagnostics(document: AstDocument<TAst, TDiagnostic>): AstDocument<TAst, never>;
693
810
  }
694
811
  //# sourceMappingURL=model-service.d.ts.map