@hydranium/core 1.0.0-next.19 → 1.0.0-next.193

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