@mrclrchtr/supi-code-intelligence 12.0.0 → 14.0.0

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 (307) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/README.md +7 -5
  3. package/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  4. package/node_modules/@mrclrchtr/supi-code-runtime/src/query-result.ts +10 -0
  5. package/node_modules/@mrclrchtr/supi-core/package.json +3 -1
  6. package/node_modules/@mrclrchtr/supi-core/src/api.ts +4 -0
  7. package/node_modules/@mrclrchtr/supi-core/src/context/context-tag.ts +1 -1
  8. package/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +78 -13
  9. package/node_modules/@mrclrchtr/supi-core/src/footer-registry.ts +41 -9
  10. package/node_modules/@mrclrchtr/supi-core/src/retired-packages.ts +152 -0
  11. package/node_modules/@mrclrchtr/supi-core/src/session.ts +3 -0
  12. package/node_modules/@mrclrchtr/supi-core/src/shell-hints.ts +46 -0
  13. package/node_modules/@mrclrchtr/supi-core/src/side-run.ts +46 -0
  14. package/node_modules/@mrclrchtr/supi-core/src/spill.ts +93 -0
  15. package/node_modules/@mrclrchtr/supi-lsp/README.md +6 -2
  16. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  17. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/query-result.ts +10 -0
  18. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/package.json +3 -1
  19. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/api.ts +4 -0
  20. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/context/context-tag.ts +1 -1
  21. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +78 -13
  22. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/footer-registry.ts +41 -9
  23. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/retired-packages.ts +152 -0
  24. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/session.ts +3 -0
  25. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/shell-hints.ts +46 -0
  26. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/side-run.ts +46 -0
  27. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/spill.ts +93 -0
  28. package/node_modules/@mrclrchtr/supi-lsp/package.json +8 -8
  29. package/node_modules/@mrclrchtr/supi-lsp/src/api.ts +1 -0
  30. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-cache.ts +102 -47
  31. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-host.ts +8 -0
  32. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-refresh.ts +20 -1
  33. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-request.ts +4 -1
  34. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-timing.ts +14 -1
  35. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-typescript.ts +8 -1
  36. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostics.ts +50 -4
  37. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-disk-stamp.ts +60 -0
  38. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-document-state.ts +3 -0
  39. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-document-sync.ts +21 -1
  40. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-file-state.ts +17 -3
  41. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-input-admission.ts +7 -1
  42. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-semantic-input-barrier.ts +53 -4
  43. package/node_modules/@mrclrchtr/supi-lsp/src/client/client.ts +12 -3
  44. package/node_modules/@mrclrchtr/supi-lsp/src/client/transport.ts +24 -8
  45. package/node_modules/@mrclrchtr/supi-lsp/src/config/server-config.ts +5 -0
  46. package/node_modules/@mrclrchtr/supi-lsp/src/config/tsconfig-extends.ts +2 -1
  47. package/node_modules/@mrclrchtr/supi-lsp/src/config/tsconfig-path.ts +2 -2
  48. package/node_modules/@mrclrchtr/supi-lsp/src/config/tsconfig-scope.ts +17 -5
  49. package/node_modules/@mrclrchtr/supi-lsp/src/config/typescript-module.ts +17 -0
  50. package/node_modules/@mrclrchtr/supi-lsp/src/debug-telemetry.ts +64 -0
  51. package/node_modules/@mrclrchtr/supi-lsp/src/diagnostics/evidence.ts +42 -0
  52. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-client-state.ts +2 -17
  53. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-project-info.ts +3 -0
  54. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-removal-ledger.ts +52 -0
  55. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-typescript-coverage.ts +27 -2
  56. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-workspace-symbol.ts +16 -112
  57. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager.ts +561 -103
  58. package/node_modules/@mrclrchtr/supi-lsp/src/manager/typescript-file-local.ts +6 -1
  59. package/node_modules/@mrclrchtr/supi-lsp/src/manager/workspace-symbol-collection.ts +163 -0
  60. package/node_modules/@mrclrchtr/supi-lsp/src/manager/workspace-symbol-row-limit.ts +72 -0
  61. package/node_modules/@mrclrchtr/supi-lsp/src/provider/lsp-semantic-provider.ts +6 -1
  62. package/node_modules/@mrclrchtr/supi-lsp/src/provider/semantic-symbol-mapper.ts +13 -3
  63. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-controller.ts +11 -0
  64. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-diagnostic-surface.ts +11 -0
  65. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-diagnostics.ts +1 -0
  66. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-registry.ts +53 -9
  67. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-transition-debug.ts +11 -1
  68. package/node_modules/@mrclrchtr/supi-lsp/src/session/workspace-lsp-runtime.ts +2 -0
  69. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  70. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/query-result.ts +10 -0
  71. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/package.json +3 -1
  72. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/api.ts +4 -0
  73. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/context/context-tag.ts +1 -1
  74. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +78 -13
  75. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/footer-registry.ts +41 -9
  76. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/retired-packages.ts +152 -0
  77. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/session.ts +3 -0
  78. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/shell-hints.ts +46 -0
  79. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/side-run.ts +46 -0
  80. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/spill.ts +93 -0
  81. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.cjs +50 -75
  82. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.cjs.map +2 -2
  83. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.js +50 -75
  84. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.js.map +2 -2
  85. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.wasm +0 -0
  86. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.wasm.map +6 -6
  87. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/package.json +1 -1
  88. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.cjs +50 -75
  89. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.cjs.map +2 -2
  90. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.d.cts +7 -7
  91. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.d.cts.map +1 -1
  92. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.d.ts +7 -7
  93. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.d.ts.map +1 -1
  94. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.js +50 -75
  95. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.js.map +2 -2
  96. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.wasm +0 -0
  97. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.wasm.map +5 -5
  98. package/node_modules/@mrclrchtr/supi-tree-sitter/package.json +5 -5
  99. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/kotlin/tree-sitter-kotlin.wasm.json +1 -1
  100. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/latex/tree-sitter-latex.wasm.json +1 -1
  101. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/sql/tree-sitter-sql.wasm +0 -0
  102. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/sql/tree-sitter-sql.wasm.json +3 -3
  103. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/tsx/tree-sitter-tsx.wasm.json +1 -1
  104. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/typescript/tree-sitter-typescript.wasm.json +1 -1
  105. package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/structural-worker-client.ts +1 -1
  106. package/node_modules/fast-xml-parser/CHANGELOG.md +886 -0
  107. package/node_modules/fast-xml-parser/LICENSE +21 -0
  108. package/node_modules/fast-xml-parser/README.md +204 -0
  109. package/node_modules/fast-xml-parser/lib/fxbuilder.min.js +2 -0
  110. package/node_modules/fast-xml-parser/lib/fxbuilder.min.js.map +1 -0
  111. package/node_modules/fast-xml-parser/lib/fxp.cjs +1 -0
  112. package/node_modules/fast-xml-parser/lib/fxp.d.cts +774 -0
  113. package/node_modules/fast-xml-parser/lib/fxp.min.js +2 -0
  114. package/node_modules/fast-xml-parser/lib/fxp.min.js.map +1 -0
  115. package/node_modules/fast-xml-parser/lib/fxparser.min.js +2 -0
  116. package/node_modules/fast-xml-parser/lib/fxparser.min.js.map +1 -0
  117. package/node_modules/fast-xml-parser/lib/fxvalidator.min.js +2 -0
  118. package/node_modules/fast-xml-parser/lib/fxvalidator.min.js.map +1 -0
  119. package/node_modules/fast-xml-parser/node_modules/@nodable/entities/README.md +92 -0
  120. package/node_modules/fast-xml-parser/node_modules/@nodable/entities/package.json +57 -0
  121. package/node_modules/fast-xml-parser/node_modules/@nodable/entities/src/EntityDecoder.js +644 -0
  122. package/node_modules/fast-xml-parser/node_modules/@nodable/entities/src/EntityEncoder.js +239 -0
  123. package/node_modules/fast-xml-parser/node_modules/@nodable/entities/src/all-entities.js +53 -0
  124. package/node_modules/fast-xml-parser/node_modules/@nodable/entities/src/entities.js +1139 -0
  125. package/node_modules/fast-xml-parser/node_modules/@nodable/entities/src/entityTries.js +60 -0
  126. package/node_modules/fast-xml-parser/node_modules/@nodable/entities/src/index.d.ts +358 -0
  127. package/node_modules/fast-xml-parser/node_modules/@nodable/entities/src/index.js +29 -0
  128. package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/CHANGELOG.md +52 -0
  129. package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/LICENSE +21 -0
  130. package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/README.md +77 -0
  131. package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/lib/fxb.cjs +1 -0
  132. package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/lib/fxb.d.cts +270 -0
  133. package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/lib/fxb.min.js +2 -0
  134. package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/lib/fxb.min.js.map +1 -0
  135. package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/package.json +77 -0
  136. package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/src/fxb.d.ts +270 -0
  137. package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/src/fxb.js +609 -0
  138. package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/src/ignoreAttributes.js +18 -0
  139. package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/src/orderedJs2Xml.js +360 -0
  140. package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/src/prettifyJs2Xml.js +0 -0
  141. package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/src/util.js +23 -0
  142. package/node_modules/fast-xml-parser/node_modules/is-unsafe/LICENSE +21 -0
  143. package/node_modules/fast-xml-parser/node_modules/is-unsafe/README.md +632 -0
  144. package/node_modules/fast-xml-parser/node_modules/is-unsafe/package.json +56 -0
  145. package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/contexts/html.js +102 -0
  146. package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/contexts/log.js +98 -0
  147. package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/contexts/nosql.js +114 -0
  148. package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/contexts/redos.js +60 -0
  149. package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/contexts/shell.js +105 -0
  150. package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/contexts/sql-strict.js +47 -0
  151. package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/contexts/sql.js +95 -0
  152. package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/contexts/svg.js +81 -0
  153. package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/contexts/xml.js +79 -0
  154. package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/index.cjs +27 -0
  155. package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/index.d.ts +103 -0
  156. package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/index.js +292 -0
  157. package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/util/decode-entities.js +48 -0
  158. package/node_modules/fast-xml-parser/node_modules/path-expression-matcher/LICENSE +21 -0
  159. package/node_modules/fast-xml-parser/node_modules/path-expression-matcher/README.md +947 -0
  160. package/node_modules/fast-xml-parser/node_modules/path-expression-matcher/lib/pem.cjs +1 -0
  161. package/node_modules/fast-xml-parser/node_modules/path-expression-matcher/lib/pem.d.cts +725 -0
  162. package/node_modules/fast-xml-parser/node_modules/path-expression-matcher/lib/pem.min.js +2 -0
  163. package/node_modules/fast-xml-parser/node_modules/path-expression-matcher/lib/pem.min.js.map +1 -0
  164. package/node_modules/fast-xml-parser/node_modules/path-expression-matcher/package.json +79 -0
  165. package/node_modules/fast-xml-parser/node_modules/path-expression-matcher/src/Expression.js +232 -0
  166. package/node_modules/fast-xml-parser/node_modules/path-expression-matcher/src/ExpressionSet.js +225 -0
  167. package/node_modules/fast-xml-parser/node_modules/path-expression-matcher/src/Matcher.js +663 -0
  168. package/node_modules/fast-xml-parser/node_modules/path-expression-matcher/src/index.d.ts +589 -0
  169. package/node_modules/fast-xml-parser/node_modules/path-expression-matcher/src/index.js +30 -0
  170. package/node_modules/fast-xml-parser/node_modules/strnum/CHANGELOG.md +63 -0
  171. package/node_modules/fast-xml-parser/node_modules/strnum/LICENSE +21 -0
  172. package/node_modules/fast-xml-parser/node_modules/strnum/README.md +113 -0
  173. package/node_modules/fast-xml-parser/node_modules/strnum/node_modules/anynum/LICENSE +21 -0
  174. package/node_modules/fast-xml-parser/node_modules/strnum/node_modules/anynum/README.md +142 -0
  175. package/node_modules/fast-xml-parser/node_modules/strnum/node_modules/anynum/anynum.js +135 -0
  176. package/node_modules/fast-xml-parser/node_modules/strnum/node_modules/anynum/digitTable.js +116 -0
  177. package/node_modules/fast-xml-parser/node_modules/strnum/node_modules/anynum/package.json +42 -0
  178. package/node_modules/fast-xml-parser/node_modules/strnum/package.json +36 -0
  179. package/node_modules/fast-xml-parser/node_modules/strnum/strnum.js +176 -0
  180. package/node_modules/fast-xml-parser/node_modules/xml-naming/LICENSE +21 -0
  181. package/node_modules/fast-xml-parser/node_modules/xml-naming/README.md +287 -0
  182. package/node_modules/fast-xml-parser/node_modules/xml-naming/package.json +56 -0
  183. package/node_modules/fast-xml-parser/node_modules/xml-naming/src/index.d.ts +108 -0
  184. package/node_modules/fast-xml-parser/node_modules/xml-naming/src/index.js +382 -0
  185. package/node_modules/fast-xml-parser/package.json +93 -0
  186. package/node_modules/fast-xml-parser/src/cli/cli.js +97 -0
  187. package/node_modules/fast-xml-parser/src/cli/man.js +17 -0
  188. package/node_modules/fast-xml-parser/src/cli/read.js +43 -0
  189. package/node_modules/fast-xml-parser/src/fxp.d.ts +754 -0
  190. package/node_modules/fast-xml-parser/src/fxp.js +14 -0
  191. package/node_modules/fast-xml-parser/src/ignoreAttributes.js +18 -0
  192. package/node_modules/fast-xml-parser/src/util.js +61 -0
  193. package/node_modules/fast-xml-parser/src/v6/CharsSymbol.js +16 -0
  194. package/node_modules/fast-xml-parser/src/v6/EntitiesParser.js +106 -0
  195. package/node_modules/fast-xml-parser/src/v6/OptionsBuilder.js +61 -0
  196. package/node_modules/fast-xml-parser/src/v6/OutputBuilders/BaseOutputBuilder.js +69 -0
  197. package/node_modules/fast-xml-parser/src/v6/OutputBuilders/JsArrBuilder.js +103 -0
  198. package/node_modules/fast-xml-parser/src/v6/OutputBuilders/JsMinArrBuilder.js +100 -0
  199. package/node_modules/fast-xml-parser/src/v6/OutputBuilders/JsObjBuilder.js +154 -0
  200. package/node_modules/fast-xml-parser/src/v6/OutputBuilders/ParserOptionsBuilder.js +94 -0
  201. package/node_modules/fast-xml-parser/src/v6/Report.js +0 -0
  202. package/node_modules/fast-xml-parser/src/v6/TagPath.js +81 -0
  203. package/node_modules/fast-xml-parser/src/v6/TagPathMatcher.js +13 -0
  204. package/node_modules/fast-xml-parser/src/v6/XMLParser.js +83 -0
  205. package/node_modules/fast-xml-parser/src/v6/Xml2JsParser.js +235 -0
  206. package/node_modules/fast-xml-parser/src/v6/XmlPartReader.js +210 -0
  207. package/node_modules/fast-xml-parser/src/v6/XmlSpecialTagsReader.js +111 -0
  208. package/node_modules/fast-xml-parser/src/v6/inputSource/BufferSource.js +116 -0
  209. package/node_modules/fast-xml-parser/src/v6/inputSource/StringSource.js +121 -0
  210. package/node_modules/fast-xml-parser/src/v6/valueParsers/EntitiesParser.js +105 -0
  211. package/node_modules/fast-xml-parser/src/v6/valueParsers/booleanParser.js +22 -0
  212. package/node_modules/fast-xml-parser/src/v6/valueParsers/booleanParserExt.js +19 -0
  213. package/node_modules/fast-xml-parser/src/v6/valueParsers/currency.js +38 -0
  214. package/node_modules/fast-xml-parser/src/v6/valueParsers/join.js +13 -0
  215. package/node_modules/fast-xml-parser/src/v6/valueParsers/number.js +14 -0
  216. package/node_modules/fast-xml-parser/src/v6/valueParsers/trim.js +6 -0
  217. package/node_modules/fast-xml-parser/src/validator.js +518 -0
  218. package/node_modules/fast-xml-parser/src/xmlbuilder/json2xml.js +6 -0
  219. package/node_modules/fast-xml-parser/src/xmlparser/DocTypeReader.js +426 -0
  220. package/node_modules/fast-xml-parser/src/xmlparser/OptionsBuilder.js +164 -0
  221. package/node_modules/fast-xml-parser/src/xmlparser/OrderedObjParser.js +907 -0
  222. package/node_modules/fast-xml-parser/src/xmlparser/XMLParser.js +77 -0
  223. package/node_modules/fast-xml-parser/src/xmlparser/node2json.js +177 -0
  224. package/node_modules/fast-xml-parser/src/xmlparser/xmlNode.js +54 -0
  225. package/package.json +10 -8
  226. package/src/analysis/evidence.ts +331 -73
  227. package/src/analysis/health/diagnostics.ts +66 -18
  228. package/src/analysis/health/evidence-reason.ts +44 -0
  229. package/src/analysis/health/server-status.ts +32 -9
  230. package/src/analysis/health/signals.ts +1 -0
  231. package/src/analysis/instruction-files.ts +11 -7
  232. package/src/analysis/search/exclusions.ts +18 -4
  233. package/src/analysis/search/pattern.ts +3 -3
  234. package/src/analysis/target/anchored.ts +3 -6
  235. package/src/analysis/target/file-outline-omissions.ts +17 -2
  236. package/src/analysis/target/symbol-selection.ts +100 -0
  237. package/src/analysis/target/symbol.ts +83 -49
  238. package/src/analysis/target/types.ts +12 -10
  239. package/src/analysis/workspace/cmake-parser.ts +207 -0
  240. package/src/analysis/workspace/cmake.ts +141 -0
  241. package/src/analysis/workspace/maven.ts +310 -0
  242. package/src/analysis/workspace/membership.ts +100 -26
  243. package/src/analysis/workspace/metadata.ts +6 -1
  244. package/src/analysis/workspace/observe.ts +6 -0
  245. package/src/analysis/workspace/types.ts +11 -3
  246. package/src/app/app.ts +37 -21
  247. package/src/diagnostics/coverage.ts +49 -0
  248. package/src/diagnostics/evidence.ts +10 -2
  249. package/src/extension.ts +1 -2
  250. package/src/headless.ts +4 -2
  251. package/src/session/health-types.ts +2 -0
  252. package/src/session/health-workflow.ts +6 -0
  253. package/src/session/input/common.ts +1 -1
  254. package/src/session/orientation/collect.ts +42 -7
  255. package/src/session/orientation/context-facts.ts +3 -3
  256. package/src/session/orientation/context-sections.ts +13 -15
  257. package/src/session/orientation/facts.ts +5 -8
  258. package/src/session/orientation-types.ts +5 -0
  259. package/src/session/orientation-workflow.ts +12 -17
  260. package/src/session/target-workflow.ts +38 -25
  261. package/src/tool/code_find/render.ts +10 -11
  262. package/src/tool/code_find/result.ts +11 -8
  263. package/src/tool/code_graph/display.ts +5 -6
  264. package/src/tool/code_graph/format.ts +8 -24
  265. package/src/tool/code_graph/result.ts +16 -75
  266. package/src/tool/code_graph/section.ts +21 -33
  267. package/src/tool/code_graph/structured.ts +3 -0
  268. package/src/tool/code_graph/tui.ts +10 -5
  269. package/src/tool/code_health/diagnostic-tui.ts +49 -0
  270. package/src/tool/code_health/guidance.ts +27 -0
  271. package/src/tool/code_health/markdown.ts +63 -9
  272. package/src/tool/code_health/result.ts +20 -9
  273. package/src/tool/code_health/structured-schema.ts +15 -0
  274. package/src/tool/code_health/structured.ts +9 -1
  275. package/src/tool/code_health/tui.ts +33 -40
  276. package/src/tool/code_inspect/result.ts +23 -18
  277. package/src/tool/code_inspect/structured.ts +2 -19
  278. package/src/tool/code_orientation/markdown.ts +6 -1
  279. package/src/tool/code_orientation/result.ts +53 -100
  280. package/src/tool/code_orientation/structured-schema.ts +16 -12
  281. package/src/tool/code_orientation/structured-workspace.ts +13 -7
  282. package/src/tool/code_orientation/structured.ts +31 -39
  283. package/src/tool/code_orientation/workspace-format.ts +4 -10
  284. package/src/tool/code_orientation/workspace-instructions.ts +4 -5
  285. package/src/tool/code_orientation/workspace-observations.ts +2 -2
  286. package/src/tool/code_orientation/workspace-output.ts +16 -7
  287. package/src/tool/code_orientation/workspace-projects.ts +7 -10
  288. package/src/tool/code_orientation/workspace-sections.ts +13 -19
  289. package/src/tool/code_resolve/markdown.ts +4 -46
  290. package/src/tool/code_resolve/result.ts +45 -73
  291. package/src/tool/code_resolve/structured.ts +6 -1
  292. package/src/tool/infra/truncate.ts +2 -16
  293. package/src/tool/result/candidate-selection.ts +157 -0
  294. package/src/tool/result/display.ts +41 -45
  295. package/src/tool/result/errors.ts +1 -0
  296. package/src/tool/result/model-budget.ts +26 -1
  297. package/src/tool/result/refactor.ts +11 -8
  298. package/src/tool/result/structured.ts +2 -1
  299. package/src/tool/result/types.ts +9 -8
  300. package/src/tool/schemas.ts +15 -20
  301. package/src/ui/footer.ts +147 -44
  302. package/src/ui/status-overlay.ts +13 -8
  303. package/src/ui/status-presentation.ts +4 -7
  304. package/src/ui/tui/candidate-selection.ts +40 -95
  305. package/src/ui/tui/common.ts +16 -70
  306. package/src/ui/tui/display.ts +6 -24
  307. package/src/tool/result/candidate-row.ts +0 -49
@@ -0,0 +1,176 @@
1
+ const hexRegex = /^[-+]?0x[a-fA-F0-9]+$/;
2
+ const binRegex = /^0b[01]+$/;
3
+ const octRegex = /^0o[0-7]+$/;
4
+ const numRegex = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/;
5
+
6
+ import anynum from "anynum";
7
+
8
+ const consider = {
9
+ hex: true,
10
+ binary: false,
11
+ octal: false,
12
+ leadingZeros: true,
13
+ decimalPoint: "\.",
14
+ eNotation: true,
15
+ //skipLike: /regex/,
16
+ infinity: "original", // "null", "infinity" (Infinity type), "string" ("Infinity" (the string literal))
17
+ unicode: false,
18
+ };
19
+
20
+ export default function toNumber(str, options = {}) {
21
+ options = Object.assign({}, consider, options);
22
+ if (!str || typeof str !== "string") return str;
23
+
24
+ let trimmedStr = str.trim();
25
+
26
+ if (trimmedStr.length === 0) return str;
27
+ else if (options.skipLike !== undefined && options.skipLike.test(trimmedStr)) return str;
28
+ else if (trimmedStr === "0") return 0;
29
+
30
+ if (options.unicode) {
31
+ trimmedStr = anynum(trimmedStr);
32
+ if (trimmedStr === "0") return 0; // re-check after normalization
33
+ }
34
+ if (options.hex && hexRegex.test(trimmedStr)) {
35
+ return parse_int(trimmedStr, 16);
36
+ } else if (options.binary && binRegex.test(trimmedStr)) {
37
+ return parse_int(trimmedStr, 2);
38
+ } else if (options.octal && octRegex.test(trimmedStr)) {
39
+ return parse_int(trimmedStr, 8);
40
+ } else if (!isFinite(trimmedStr)) { //Infinity or not a number
41
+ const num = Number(trimmedStr);
42
+ if (Number.isNaN(num)) return str; //not a number: always the original string
43
+ return handleInfinity(str, num, options); //only +/-Infinity reaches here
44
+ } else if (trimmedStr.includes('e') || trimmedStr.includes('E')) { //eNotation
45
+ return resolveEnotation(str, trimmedStr, options);
46
+ } else {
47
+ //separate negative sign, leading zeros, and rest number
48
+ const match = numRegex.exec(trimmedStr);
49
+ // +00.123 => [ , '+', '00', '.123', ..
50
+ if (match) {
51
+ const sign = match[1] || "";
52
+ const leadingZeros = match[2];
53
+ let numTrimmedByZeros = trimZeros(match[3]); //complete num without leading zeros
54
+ const decimalAdjacentToLeadingZeros = sign ? // 0., -00., 000.
55
+ trimmedStr[leadingZeros.length + 1] === "."
56
+ : trimmedStr[leadingZeros.length] === ".";
57
+
58
+ //trim ending zeros for floating number
59
+ if (!options.leadingZeros //leading zeros are not allowed
60
+ && (leadingZeros.length > 1
61
+ || (leadingZeros.length === 1 && !decimalAdjacentToLeadingZeros))) {
62
+ // 00, 00.3, +03.24, 03, 03.24
63
+ return str;
64
+ }
65
+ else {//no leading zeros or leading zeros are allowed
66
+ const num = Number(trimmedStr);
67
+ const parsedStr = String(num);
68
+
69
+ if (num === 0) return num;
70
+ if (parsedStr.search(/[eE]/) !== -1) { //given number is long and parsed to eNotation
71
+ if (options.eNotation) return num;
72
+ else return str;
73
+ } else if (trimmedStr.indexOf(".") !== -1) { //floating number
74
+ if (parsedStr === "0") return num; //0.0
75
+ else if (parsedStr === numTrimmedByZeros) return num; //0.456. 0.79000
76
+ else if (parsedStr === `${sign}${numTrimmedByZeros}`) return num;
77
+ else return str;
78
+ }
79
+
80
+ let n = leadingZeros ? numTrimmedByZeros : trimmedStr;
81
+ if (leadingZeros) {
82
+ // -009 => -9
83
+ return (n === parsedStr) || (sign + n === parsedStr) ? num : str
84
+ } else {
85
+ // +9
86
+ return (n === parsedStr) || (n === sign + parsedStr) ? num : str
87
+ }
88
+ }
89
+ } else { //non-numeric string
90
+ return str;
91
+ }
92
+ }
93
+ }
94
+
95
+ const eNotationRegx = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/;
96
+ function resolveEnotation(str, trimmedStr, options) {
97
+ if (!options.eNotation) return str;
98
+ const notation = trimmedStr.match(eNotationRegx);
99
+ if (notation) {
100
+ let sign = notation[1] || "";
101
+ const eChar = notation[3].indexOf("e") === -1 ? "E" : "e";
102
+ const leadingZeros = notation[2];
103
+ const eAdjacentToLeadingZeros = sign ? // 0E.
104
+ trimmedStr[leadingZeros.length + 1] === eChar
105
+ : trimmedStr[leadingZeros.length] === eChar;
106
+
107
+ if (leadingZeros.length > 1 && eAdjacentToLeadingZeros) return str;
108
+ else if (leadingZeros.length === 1
109
+ && (notation[3].startsWith(`.${eChar}`) || notation[3][0] === eChar)) {
110
+ return Number(trimmedStr);
111
+ } else if (leadingZeros.length > 0) {
112
+ // Has leading zeros — only accept if leadingZeros option allows it
113
+ if (options.leadingZeros && !eAdjacentToLeadingZeros) {
114
+ return Number(trimmedStr); // Number() accepts leading zeros; stripping can leave a mantissa-less ".e0"
115
+ } else return str;
116
+ } else {
117
+ // No leading zeros — always valid e-notation, parse it
118
+ return Number(trimmedStr);
119
+ }
120
+ } else {
121
+ return str;
122
+ }
123
+ }
124
+
125
+ /**
126
+ *
127
+ * @param {string} numStr without leading zeros
128
+ * @returns
129
+ */
130
+ function trimZeros(numStr) {
131
+ if (numStr && numStr.indexOf(".") !== -1) {//float
132
+ //remove ending zeros without the O(n^2) backtracking that /0+$/ hits
133
+ //when the string doesn't end in 0 but has a long internal zero-run
134
+ let end = numStr.length;
135
+ while (end > 0 && numStr.charCodeAt(end - 1) === 48 /* '0' */) end--;
136
+ numStr = numStr.slice(0, end);
137
+ if (numStr === ".") numStr = "0";
138
+ else if (numStr[0] === ".") numStr = "0" + numStr;
139
+ else if (numStr[numStr.length - 1] === ".") numStr = numStr.substring(0, numStr.length - 1);
140
+ return numStr;
141
+ }
142
+ return numStr;
143
+ }
144
+
145
+ function parse_int(numStr, base) {
146
+ const str = numStr.trim();
147
+ if (base === 2 || base === 8) numStr = str.substring(2);
148
+
149
+ if (parseInt) return parseInt(numStr, base);
150
+ else if (Number.parseInt) return Number.parseInt(numStr, base);
151
+ else if (window && window.parseInt) return window.parseInt(numStr, base);
152
+ else throw new Error("parseInt, Number.parseInt, window.parseInt are not supported");
153
+ }
154
+
155
+ /**
156
+ * Handle infinite values based on user option
157
+ * @param {string} str - original input string
158
+ * @param {number} num - parsed number (Infinity or -Infinity)
159
+ * @param {object} options - user options
160
+ * @returns {string|number|null} based on infinity option
161
+ */
162
+ function handleInfinity(str, num, options) {
163
+ const isPositive = num === Infinity;
164
+
165
+ switch (options.infinity.toLowerCase()) {
166
+ case "null":
167
+ return null;
168
+ case "infinity":
169
+ return num; // Return Infinity or -Infinity
170
+ case "string":
171
+ return isPositive ? "Infinity" : "-Infinity";
172
+ case "original":
173
+ default:
174
+ return str; // Return original string like "1e1000"
175
+ }
176
+ }
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Natural Intelligence
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,287 @@
1
+ # xml-naming
2
+ [![xml-naming downloads](https://img.shields.io/npm/dw/xml-naming.svg)](https://npm-compare.com/xml-naming)
3
+ [![xml-naming version](https://img.shields.io/npm/v/xml-naming.svg)](https://www.npmjs.com/package/xml-naming)
4
+ [![xml-naming license](https://img.shields.io/npm/l/xml-naming.svg)](https://github.com/NaturalIntelligence/xml-naming)
5
+
6
+ Validates XML name productions as defined in the [XML 1.0](https://www.w3.org/TR/xml/) and [XML 1.1](https://www.w3.org/TR/xml11/) specifications.
7
+
8
+ Covers all five productions:
9
+
10
+ | Production | Description | Colon | Digit/hyphen start |
11
+ |---|---|---|---|
12
+ | `Name` | General XML name | ✅ | ❌ |
13
+ | `NCName` | Non-Colonized name | ❌ | ❌ |
14
+ | `QName` | Namespace-qualified name (`prefix:local`) | ✅ (one only) | ❌ |
15
+ | `NMToken` | Name token (relaxed start) | ✅ | ✅ |
16
+ | `NMTokens` | Whitespace-separated NMToken list | ✅ | ✅ |
17
+
18
+ Used internally by [fast-xml-parser](https://github.com/NaturalIntelligence/fast-xml-parser), [fast-xml-validator](https://github.com/NaturalIntelligence/fast-xml-validator), [@nodable\flexible-xml-parser](https://github.com/nodable/flexible-xml-parser) and [fast-svg-parser](https://github.com/amitguptagwl/fast-svg-parser).
19
+
20
+ ---
21
+
22
+ ## Install
23
+
24
+ ```bash
25
+ npm install xml-naming
26
+ ```
27
+
28
+ ---
29
+
30
+ ## Usage
31
+
32
+ ### Boolean validators
33
+
34
+ ```js
35
+ import { name, ncName, qName, nmToken, nmTokens } from 'xml-naming';
36
+
37
+ // Name — colon allowed anywhere, used for DOCTYPE entity names
38
+ name('foo') // true
39
+ name('a:b:c') // true ← multiple colons fine for Name
40
+ name('1foo') // false ← digit start invalid
41
+
42
+ // NCName — no colon, used for SVG id attributes, namespace prefixes
43
+ ncName('my-id') // true
44
+ ncName('xlink:href') // false ← colon not allowed
45
+
46
+ // QName — exactly one colon as prefix separator, used for element/attribute names
47
+ qName('svg:circle') // true
48
+ qName('foo') // true ← unprefixed QName is valid
49
+ qName('a:b:c') // false ← only one colon allowed
50
+ qName(':foo') // false ← cannot start with colon
51
+
52
+ // NMToken — any NameChar at start, used for DTD NMTOKEN attributes
53
+ nmToken('123') // true ← digit start is fine
54
+ nmToken('-bar') // true
55
+ nmToken('foo bar') // false ← space not allowed
56
+
57
+ // NMTokens — whitespace-separated NMToken list
58
+ nmTokens('tok1 tok2 -foo 123') // true
59
+ ```
60
+
61
+ ### XML version option
62
+
63
+ All validators accept an optional `{ xmlVersion }` option:
64
+
65
+ ```js
66
+ import { name } from 'xml-naming';
67
+
68
+ name('\u0085', { xmlVersion: '1.0' }) // false — NEL (Next Line), not in 1.0 ranges
69
+ name('\u0085', { xmlVersion: '1.1' }) // true — explicitly allowed in 1.1
70
+
71
+ name('\uD800\uDC00', { xmlVersion: '1.0' }) // false
72
+ name('\uD800\uDC00', { xmlVersion: '1.1' }) // true
73
+ ```
74
+
75
+ ---
76
+
77
+ ### ASCII-only fast path
78
+
79
+ All validators, `validate`, `validateAll`, and `sanitize` also accept `{ asciiOnly: true }`.
80
+ When set, matching is restricted to the ASCII subset of the NameStartChar/NameChar
81
+ productions and skips unicode-aware regex matching entirely — no `\u00C0-\uFFFD`-style
82
+ ranges, and (for XML 1.1) no `/u` regex flag. Unicode-aware regexes are measurably slower
83
+ than plain ASCII matching in JS engines, so this is a real performance win when you know
84
+ your input is ASCII-only, which is the common case for HTML/SVG ids and most XML tags.
85
+
86
+ **This is opt-in and defaults to `false`** for backward compatibility: turning it on
87
+ changes behavior, since it rejects legitimate non-ASCII XML names that would otherwise be
88
+ valid. Only enable it when you control the input and know it's ASCII (e.g. internal
89
+ identifiers, machine-generated names), not for validating arbitrary user- or
90
+ externally-supplied XML/SVG content.
91
+
92
+ ```js
93
+ import { name, sanitize } from 'xml-naming';
94
+
95
+ name('café', { asciiOnly: true }) // false — 'é' is not ASCII, even though it's
96
+ name('café') // true a valid XML 1.0/1.1 NameChar
97
+
98
+ sanitize('café', 'name', { asciiOnly: true }) // 'caf_' — non-ASCII replaced too
99
+ sanitize('café', 'name') // 'café' — left untouched by default
100
+ ```
101
+
102
+ ---
103
+
104
+ ### Memoized validator (`createValidator`)
105
+
106
+ Real documents tend to reuse a small vocabulary of tag/attribute names across many
107
+ siblings (`id`, `class`, `href`, ... repeated across hundreds of elements). Calling the
108
+ plain boolean validators re-runs the regex on every call, even for names seen before.
109
+
110
+ `createValidator(production, opts)` returns a memoized validator function: `xmlVersion`
111
+ and `asciiOnly` are fixed at creation time (so the regex is resolved once, not per call),
112
+ and repeated inputs after the first are served from an internal cache instead of
113
+ re-matching the regex.
114
+
115
+ ```js
116
+ import { createValidator } from 'xml-naming';
117
+
118
+ const isQName = createValidator('qName', { xmlVersion: '1.0' });
119
+
120
+ isQName('sku'); // false → regex test (cache miss), result cached
121
+ isQName('sku'); // false → cache hit, no regex run
122
+ ```
123
+
124
+ Use one instance per document/parse (or reuse across a session — your choice), rather
125
+ than creating one per call:
126
+
127
+ ```js
128
+ // e.g. inside a parser, once per parse call:
129
+ const isValidTag = createValidator('qName', { asciiOnly: true });
130
+
131
+ for (const tagName of tagNames) {
132
+ if (!isValidTag(tagName)) throw new Error(`Invalid tag name: ${tagName}`);
133
+ }
134
+ ```
135
+
136
+ Because the validator is a plain function, this loop already gets short-circuit
137
+ behaviour (via `break`/`throw` on first failure) and zero extra allocation on the happy
138
+ path — no separate "bulk" API is needed for that.
139
+
140
+ **Cache bound:** the internal cache is capped by `maxCacheSize` (default `2048`). Once
141
+ the cap is reached, new distinct strings are still validated correctly, they're just no
142
+ longer cached — existing cached entries keep being served. This keeps memory bounded
143
+ even against high-cardinality or adversarial input (e.g. externally-supplied names that
144
+ never repeat), without the cost of a full LRU or the perf cliff of reset-and-refill.
145
+
146
+ Call `.reset()` on the returned function to clear the cache manually, e.g. between
147
+ unrelated parse calls if you're reusing one validator instance across a long-running
148
+ process:
149
+
150
+ ```js
151
+ isQName.reset();
152
+ ```
153
+
154
+ The cache is private to each `createValidator()` instance — there's no shared/global
155
+ cache, so unrelated callers never interfere with each other.
156
+
157
+ ---
158
+
159
+ ### Diagnostic validation
160
+
161
+ ```js
162
+ import { validate } from 'xml-naming';
163
+
164
+ validate('svg:circle', 'qName')
165
+ // { valid: true, production: 'qName', input: 'svg:circle' }
166
+
167
+ validate('1foo', 'ncName')
168
+ // {
169
+ // valid: false,
170
+ // production: 'ncName',
171
+ // input: '1foo',
172
+ // reason: 'First character "1" is not a valid NameStartChar',
173
+ // position: 0
174
+ // }
175
+
176
+ validate('foo:bar', 'ncName')
177
+ // {
178
+ // valid: false,
179
+ // production: 'ncName',
180
+ // input: 'foo:bar',
181
+ // reason: 'Colon is not allowed in NCName',
182
+ // position: 3
183
+ // }
184
+
185
+ validate('a:b:c', 'qName')
186
+ // {
187
+ // valid: false,
188
+ // production: 'qName',
189
+ // input: 'a:b:c',
190
+ // reason: 'QName can have at most one colon',
191
+ // position: 3
192
+ // }
193
+ ```
194
+
195
+ ---
196
+
197
+ ### Batch validation
198
+
199
+ ```js
200
+ import { validateAll } from 'xml-naming';
201
+
202
+ validateAll(['svg', 'circle', '123bad', 'xlink:href'], 'ncName')
203
+ // [
204
+ // { valid: true, production: 'ncName', input: 'svg' },
205
+ // { valid: true, production: 'ncName', input: 'circle' },
206
+ // { valid: false, production: 'ncName', input: '123bad', reason: '...', position: 0 },
207
+ // { valid: false, production: 'ncName', input: 'xlink:href',reason: '...', position: 5 }
208
+ // ]
209
+ ```
210
+
211
+ ---
212
+
213
+ ### Sanitize / auto-fix
214
+
215
+ Useful when generating XML/SVG programmatically from user-supplied strings:
216
+
217
+ ```js
218
+ import { sanitize } from 'xml-naming';
219
+
220
+ sanitize('123abc', 'ncName') // '_123abc' ← digit start fixed
221
+ sanitize('my element','name') // 'my_element' ← space replaced
222
+ sanitize('foo:bar', 'ncName') // 'foobar' ← colon stripped
223
+ sanitize('hello!', 'name') // 'hello_' ← illegal char replaced
224
+
225
+ // Custom replacement character
226
+ sanitize('my element', 'name', { replacement: '-' }) // 'my-element'
227
+ ```
228
+
229
+ ---
230
+
231
+ ## Which production should I use?
232
+
233
+ | Context | Production |
234
+ |---|---|
235
+ | XML element/attribute names (namespace-aware) | `qName` |
236
+ | SVG `id` attribute values | `ncName` |
237
+ | Namespace prefix alone | `ncName` |
238
+ | DOCTYPE `<!ENTITY name ...>` | `name` |
239
+ | DOCTYPE `<!NOTATION name ...>` | `name` |
240
+ | DTD `NMTOKEN` attribute values | `nmToken` |
241
+ | DTD `NMTOKENS` attribute values | `nmTokens` |
242
+
243
+ > **Note:** DOCTYPE entity and notation names must use `Name`, not `QName`. Colons carry no namespace meaning in the DTD subset.
244
+
245
+ ---
246
+
247
+ ## API
248
+
249
+ ### `name(str, opts?)` → `boolean`
250
+ ### `ncName(str, opts?)` → `boolean`
251
+ ### `qName(str, opts?)` → `boolean`
252
+ ### `nmToken(str, opts?)` → `boolean`
253
+ ### `nmTokens(str, opts?)` → `boolean`
254
+
255
+ `opts`:
256
+ - `xmlVersion`: `'1.0'` (default) | `'1.1'`
257
+ - `asciiOnly`: boolean (default `false`) — ASCII-only fast path, see above
258
+
259
+ ### `createValidator(production, opts?)` → memoized `(str) => boolean`, with `.reset()`
260
+
261
+ `opts`:
262
+ - `xmlVersion`: `'1.0'` (default) | `'1.1'`
263
+ - `asciiOnly`: boolean (default `false`)
264
+ - `maxCacheSize`: number (default `2048`) — cache stops accepting new entries once reached; existing entries keep serving hits
265
+
266
+ ### `validate(str, production, opts?)` → `ValidationResult`
267
+
268
+ `production`: `'name'` | `'ncName'` | `'qName'` | `'nmToken'` | `'nmTokens'`
269
+
270
+ `opts`: same as boolean validators (`xmlVersion`, `asciiOnly`)
271
+
272
+ ### `validateAll(strings[], production, opts?)` → `ValidationResult[]`
273
+
274
+ `opts`: same as `validate`
275
+
276
+ ### `sanitize(str, production?, opts?)` → `string`
277
+
278
+ `opts`:
279
+ - `xmlVersion`: `'1.0'` | `'1.1'`
280
+ - `replacement`: string (default `'_'`)
281
+ - `asciiOnly`: boolean (default `false`) — also replaces non-ASCII characters, not just XML-illegal ones
282
+
283
+ ---
284
+
285
+ ## License
286
+
287
+ MIT
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "xml-naming",
3
+ "version": "0.3.0",
4
+ "description": "Validates XML name productions — Name, NCName, QName, NMToken, NMTokens — for XML 1.0 and 1.1",
5
+ "type": "module",
6
+ "main": "./src/index.js",
7
+ "types": "./src/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./src/index.js",
11
+ "types": "./src/index.d.ts"
12
+ }
13
+ },
14
+ "files": [
15
+ "src",
16
+ "README.md"
17
+ ],
18
+ "scripts": {
19
+ "test": "jasmine specs/*spec.js",
20
+ "perf": "node specs/perf.js"
21
+ },
22
+ "keywords": [
23
+ "fast",
24
+ "xml",
25
+ "xml-name",
26
+ "ncname",
27
+ "qname",
28
+ "nmtoken",
29
+ "xml-validation",
30
+ "xml-namespace",
31
+ "name-validator",
32
+ "xml-1.0",
33
+ "xml-1.1"
34
+ ],
35
+ "author": "Amit Gupta (https://solothought.com)",
36
+ "license": "MIT",
37
+ "funding": [
38
+ {
39
+ "type": "github",
40
+ "url": "https://github.com/sponsors/NaturalIntelligence"
41
+ }
42
+ ],
43
+ "devDependencies": {
44
+ "jasmine": "^5.0.0"
45
+ },
46
+ "engines": {
47
+ "node": ">=16.0.0"
48
+ },
49
+ "repository": {
50
+ "type": "git",
51
+ "url": "https://github.com/NaturalIntelligence/xml-naming"
52
+ },
53
+ "bugs": {
54
+ "url": "https://github.com/NaturalIntelligence/xml-naming/issues"
55
+ }
56
+ }
@@ -0,0 +1,108 @@
1
+ export interface ValidationOptions {
2
+ /** XML specification version to validate against. Defaults to '1.0'. */
3
+ xmlVersion?: '1.0' | '1.1';
4
+ /**
5
+ * Restrict matching to the ASCII subset of the NameStartChar/NameChar
6
+ * productions and skip unicode-aware regex matching entirely. Faster,
7
+ * especially for XML 1.1 (which otherwise requires the `/u` regex flag),
8
+ * but rejects legitimate non-ASCII XML names. Off by default for
9
+ * backward compatibility — opt in only when inputs are known to be ASCII.
10
+ * Defaults to false.
11
+ */
12
+ asciiOnly?: boolean;
13
+ }
14
+
15
+ export interface SanitizeOptions extends ValidationOptions {
16
+ /** Character used to replace invalid characters. Defaults to '_'. */
17
+ replacement?: string;
18
+ }
19
+
20
+ export type Production = 'name' | 'ncName' | 'qName' | 'nmToken' | 'nmTokens';
21
+
22
+ export interface ValidationResult {
23
+ valid: boolean;
24
+ production: Production;
25
+ input: string;
26
+ /** Present only when valid is false. */
27
+ reason?: string;
28
+ /** Index of the first offending character. Present only when valid is false. */
29
+ position?: number;
30
+ }
31
+
32
+ /**
33
+ * Returns true if the string is a valid XML Name.
34
+ * Colons are permitted anywhere (Name production).
35
+ * Used for: DOCTYPE entity names, notation names, DTD element declarations.
36
+ */
37
+ export function name(str: string, opts?: ValidationOptions): boolean;
38
+
39
+ /**
40
+ * Returns true if the string is a valid NCName (Non-Colonized Name).
41
+ * Colons are not permitted.
42
+ * Used for: namespace prefixes, local names, SVG id attributes.
43
+ */
44
+ export function ncName(str: string, opts?: ValidationOptions): boolean;
45
+
46
+ /**
47
+ * Returns true if the string is a valid QName (Qualified Name).
48
+ * Allows exactly one colon as a prefix separator: prefix:localName.
49
+ * Used for: element and attribute names in namespace-aware XML/SVG.
50
+ */
51
+ export function qName(str: string, opts?: ValidationOptions): boolean;
52
+
53
+ /**
54
+ * Returns true if the string is a valid NMToken.
55
+ * Same character set as Name but no restriction on the first character.
56
+ * Used for: DTD NMTOKEN attribute values.
57
+ */
58
+ export function nmToken(str: string, opts?: ValidationOptions): boolean;
59
+
60
+ /**
61
+ * Returns true if the string is a valid NMTokens value.
62
+ * A whitespace-separated list of NMToken values.
63
+ * Used for: DTD NMTOKENS attribute values.
64
+ */
65
+ export function nmTokens(str: string, opts?: ValidationOptions): boolean;
66
+
67
+ export interface CreateValidatorOptions extends ValidationOptions {
68
+ /**
69
+ * Max number of distinct strings to cache. Once reached, new strings are
70
+ * still validated correctly but are no longer cached; existing cached
71
+ * entries keep being served. Defaults to 2048.
72
+ */
73
+ maxCacheSize?: number;
74
+ }
75
+
76
+ export interface MemoizedValidator {
77
+ (str: string): boolean;
78
+ /** Clears the internal cache. */
79
+ reset(): void;
80
+ }
81
+
82
+ /**
83
+ * Returns a memoized boolean validator function for a single production.
84
+ * `opts` (xmlVersion, asciiOnly) are fixed at creation time. Repeated calls
85
+ * with the same string after the first are served from an internal cache
86
+ * instead of re-running the regex — useful when validating a small, reused
87
+ * vocabulary of names (e.g. tag/attribute names across many siblings in a
88
+ * document) many times.
89
+ */
90
+ export function createValidator(production: Production, opts?: CreateValidatorOptions): MemoizedValidator;
91
+
92
+ /**
93
+ * Validates a string against a named XML production and returns a detailed result.
94
+ */
95
+ export function validate(str: string, production: Production, opts?: ValidationOptions): ValidationResult;
96
+
97
+ /**
98
+ * Validates an array of strings against a named XML production.
99
+ */
100
+ export function validateAll(strings: string[], production: Production, opts?: ValidationOptions): ValidationResult[];
101
+
102
+ /**
103
+ * Transforms an invalid string into the nearest valid XML name for the given production.
104
+ * - Strips or replaces illegal characters
105
+ * - Fixes invalid start characters by prepending the replacement character
106
+ * - Removes colons for NCName production
107
+ */
108
+ export function sanitize(str: string, production?: Production, opts?: SanitizeOptions): string;