@mrclrchtr/supi-code-intelligence 11.4.0 → 13.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 (330) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/README.md +17 -9
  3. package/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  4. package/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +1 -0
  5. package/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +51 -23
  6. package/node_modules/@mrclrchtr/supi-core/package.json +3 -1
  7. package/node_modules/@mrclrchtr/supi-core/src/api.ts +4 -0
  8. package/node_modules/@mrclrchtr/supi-core/src/context/context-tag.ts +1 -1
  9. package/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +22 -3
  10. package/node_modules/@mrclrchtr/supi-core/src/retired-packages.ts +152 -0
  11. package/node_modules/@mrclrchtr/supi-core/src/session.ts +1 -0
  12. package/node_modules/@mrclrchtr/supi-core/src/shell-hints.ts +46 -0
  13. package/node_modules/@mrclrchtr/supi-core/src/spill.ts +93 -0
  14. package/node_modules/@mrclrchtr/supi-lsp/README.md +21 -16
  15. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  16. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +1 -0
  17. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +51 -23
  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 +22 -3
  22. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/retired-packages.ts +152 -0
  23. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/session.ts +1 -0
  24. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/shell-hints.ts +46 -0
  25. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/spill.ts +93 -0
  26. package/node_modules/@mrclrchtr/supi-lsp/package.json +8 -8
  27. package/node_modules/@mrclrchtr/supi-lsp/src/api.ts +3 -2
  28. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-cache.ts +102 -47
  29. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-capabilities.ts +13 -3
  30. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-host.ts +8 -0
  31. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-refresh.ts +15 -1
  32. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-request.ts +1 -1
  33. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostics.ts +71 -13
  34. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-disk-stamp.ts +60 -0
  35. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-document-state.ts +3 -0
  36. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-document-sync.ts +28 -6
  37. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-edit-capture.ts +258 -0
  38. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-file-state.ts +17 -3
  39. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-semantic-input-barrier.ts +53 -4
  40. package/node_modules/@mrclrchtr/supi-lsp/src/client/client.ts +75 -14
  41. package/node_modules/@mrclrchtr/supi-lsp/src/config/capabilities.ts +8 -0
  42. package/node_modules/@mrclrchtr/supi-lsp/src/config/operation-support.ts +48 -79
  43. package/node_modules/@mrclrchtr/supi-lsp/src/config/tsconfig-extends.ts +2 -1
  44. package/node_modules/@mrclrchtr/supi-lsp/src/config/tsconfig-path.ts +2 -2
  45. package/node_modules/@mrclrchtr/supi-lsp/src/config/tsconfig-scope.ts +14 -5
  46. package/node_modules/@mrclrchtr/supi-lsp/src/config/typescript-module.ts +17 -0
  47. package/node_modules/@mrclrchtr/supi-lsp/src/diagnostics/evidence.ts +42 -0
  48. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-client-state.ts +2 -17
  49. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-removal-ledger.ts +52 -0
  50. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager.ts +43 -21
  51. package/node_modules/@mrclrchtr/supi-lsp/src/manager/typescript-file-local.ts +6 -1
  52. package/node_modules/@mrclrchtr/supi-lsp/src/provider/lsp-refactor-provider.ts +21 -35
  53. package/node_modules/@mrclrchtr/supi-lsp/src/provider/lsp-semantic-provider.ts +6 -1
  54. package/node_modules/@mrclrchtr/supi-lsp/src/provider/refactor-command-capture.ts +139 -0
  55. package/node_modules/@mrclrchtr/supi-lsp/src/provider/refactor-planning.ts +202 -47
  56. package/node_modules/@mrclrchtr/supi-lsp/src/provider/semantic-symbol-mapper.ts +13 -3
  57. package/node_modules/@mrclrchtr/supi-lsp/src/session/route-boundary.ts +26 -0
  58. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-diagnostic-surface.ts +11 -0
  59. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-diagnostics.ts +1 -0
  60. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-registry.ts +74 -14
  61. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-rename.ts +3 -0
  62. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-transition-debug.ts +11 -1
  63. package/node_modules/@mrclrchtr/supi-lsp/src/session/workspace-lsp-runtime.ts +24 -1
  64. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  65. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +1 -0
  66. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +51 -23
  67. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/package.json +3 -1
  68. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/api.ts +4 -0
  69. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/context/context-tag.ts +1 -1
  70. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +22 -3
  71. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/retired-packages.ts +152 -0
  72. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/session.ts +1 -0
  73. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/shell-hints.ts +46 -0
  74. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/spill.ts +93 -0
  75. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.cjs +50 -75
  76. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.cjs.map +2 -2
  77. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.js +50 -75
  78. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.js.map +2 -2
  79. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.wasm +0 -0
  80. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.wasm.map +6 -6
  81. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/package.json +1 -1
  82. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.cjs +50 -75
  83. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.cjs.map +2 -2
  84. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.d.cts +7 -7
  85. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.d.cts.map +1 -1
  86. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.d.ts +7 -7
  87. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.d.ts.map +1 -1
  88. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.js +50 -75
  89. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.js.map +2 -2
  90. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.wasm +0 -0
  91. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.wasm.map +5 -5
  92. package/node_modules/@mrclrchtr/supi-tree-sitter/package.json +5 -5
  93. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/kotlin/tree-sitter-kotlin.wasm.json +1 -1
  94. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/latex/tree-sitter-latex.wasm.json +1 -1
  95. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/sql/tree-sitter-sql.wasm.json +1 -1
  96. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/tsx/tree-sitter-tsx.wasm.json +1 -1
  97. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/typescript/tree-sitter-typescript.wasm.json +1 -1
  98. package/node_modules/@mrclrchtr/supi-tree-sitter/src/coordinates.ts +16 -2
  99. package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/structural-worker-client.ts +4 -3
  100. package/node_modules/@mrclrchtr/supi-tree-sitter/src/syntax-errors.ts +2 -0
  101. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/call-range.ts +94 -0
  102. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/call-sites.ts +26 -6
  103. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/callees.ts +6 -3
  104. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/exports.ts +13 -4
  105. package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/runtime.ts +1 -9
  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 +41 -12
  230. package/src/analysis/search/pattern.ts +3 -3
  231. package/src/analysis/target/anchored-structural.ts +4 -1
  232. package/src/analysis/target/anchored.ts +3 -6
  233. package/src/analysis/target/symbol.ts +42 -48
  234. package/src/analysis/target/types.ts +4 -9
  235. package/src/analysis/workspace/cmake-parser.ts +207 -0
  236. package/src/analysis/workspace/cmake.ts +141 -0
  237. package/src/analysis/workspace/maven.ts +310 -0
  238. package/src/analysis/workspace/membership.ts +100 -26
  239. package/src/analysis/workspace/metadata.ts +6 -1
  240. package/src/analysis/workspace/observe.ts +6 -0
  241. package/src/analysis/workspace/types.ts +11 -3
  242. package/src/diagnostics/coverage.ts +49 -0
  243. package/src/diagnostics/evidence.ts +10 -2
  244. package/src/session/find-types.ts +8 -4
  245. package/src/session/find-workflow.ts +11 -16
  246. package/src/session/health-workflow.ts +6 -0
  247. package/src/session/input/common.ts +1 -1
  248. package/src/session/input/health-refactor.ts +48 -34
  249. package/src/session/input/workflows.ts +45 -46
  250. package/src/session/inspect/file-point.ts +2 -2
  251. package/src/session/inspect-types.ts +1 -1
  252. package/src/session/inspect-workflow.ts +3 -3
  253. package/src/session/orientation/collect.ts +42 -7
  254. package/src/session/orientation/context-facts.ts +3 -3
  255. package/src/session/orientation/context-sections.ts +13 -15
  256. package/src/session/orientation/facts.ts +5 -8
  257. package/src/session/orientation-workflow.ts +4 -19
  258. package/src/session/refactor-file-actions.ts +122 -0
  259. package/src/session/refactor-plan-pipeline.ts +152 -0
  260. package/src/session/refactor-plans.ts +18 -15
  261. package/src/session/refactor-types.ts +24 -12
  262. package/src/session/refactor-workflow.ts +68 -243
  263. package/src/session/target-workflow.ts +25 -18
  264. package/src/tool/code_find/execute.ts +6 -7
  265. package/src/tool/code_find/result.ts +5 -7
  266. package/src/tool/code_find/spec.ts +9 -16
  267. package/src/tool/code_find/tui.ts +12 -6
  268. package/src/tool/code_graph/display.ts +5 -6
  269. package/src/tool/code_graph/format.ts +8 -24
  270. package/src/tool/code_graph/result.ts +16 -75
  271. package/src/tool/code_graph/section.ts +21 -33
  272. package/src/tool/code_graph/spec.ts +6 -0
  273. package/src/tool/code_graph/tui.ts +10 -5
  274. package/src/tool/code_health/diagnostic-tui.ts +49 -0
  275. package/src/tool/code_health/guidance.ts +27 -0
  276. package/src/tool/code_health/markdown.ts +60 -8
  277. package/src/tool/code_health/result.ts +20 -9
  278. package/src/tool/code_health/spec.ts +6 -0
  279. package/src/tool/code_health/structured-schema.ts +18 -4
  280. package/src/tool/code_health/structured.ts +22 -18
  281. package/src/tool/code_health/tui.ts +33 -40
  282. package/src/tool/code_inspect/execute.ts +1 -1
  283. package/src/tool/code_inspect/markdown.ts +33 -6
  284. package/src/tool/code_inspect/result.ts +24 -19
  285. package/src/tool/code_inspect/spec.ts +14 -6
  286. package/src/tool/code_inspect/structured.ts +4 -21
  287. package/src/tool/code_inspect/tui.ts +2 -2
  288. package/src/tool/code_orientation/result.ts +53 -100
  289. package/src/tool/code_orientation/spec.ts +8 -0
  290. package/src/tool/code_orientation/structured-schema.ts +16 -12
  291. package/src/tool/code_orientation/structured-workspace.ts +13 -7
  292. package/src/tool/code_orientation/structured.ts +31 -39
  293. package/src/tool/code_orientation/workspace-format.ts +4 -10
  294. package/src/tool/code_orientation/workspace-instructions.ts +4 -5
  295. package/src/tool/code_orientation/workspace-observations.ts +2 -2
  296. package/src/tool/code_orientation/workspace-output.ts +16 -7
  297. package/src/tool/code_orientation/workspace-projects.ts +7 -10
  298. package/src/tool/code_orientation/workspace-sections.ts +13 -19
  299. package/src/tool/code_refactor_apply/result.ts +2 -1
  300. package/src/tool/code_refactor_apply/spec.ts +7 -0
  301. package/src/tool/code_refactor_plan/execute.ts +0 -2
  302. package/src/tool/code_refactor_plan/result.ts +23 -13
  303. package/src/tool/code_refactor_plan/spec.ts +8 -2
  304. package/src/tool/code_refactor_plan/structured.ts +59 -12
  305. package/src/tool/code_refactor_plan/tui.ts +14 -17
  306. package/src/tool/code_resolve/markdown.ts +5 -47
  307. package/src/tool/code_resolve/result.ts +43 -72
  308. package/src/tool/code_resolve/spec.ts +6 -0
  309. package/src/tool/infra/truncate.ts +2 -16
  310. package/src/tool/namespace.ts +14 -0
  311. package/src/tool/refactor-markdown.ts +55 -15
  312. package/src/tool/register.ts +3 -0
  313. package/src/tool/result/candidate-selection.ts +141 -0
  314. package/src/tool/result/display.ts +41 -45
  315. package/src/tool/result/errors.ts +1 -0
  316. package/src/tool/result/model-budget.ts +26 -1
  317. package/src/tool/result/refactor-preview.ts +118 -0
  318. package/src/tool/result/refactor-unavailable.ts +16 -0
  319. package/src/tool/result/refactor.ts +19 -10
  320. package/src/tool/result/structured.ts +2 -1
  321. package/src/tool/result/types.ts +9 -8
  322. package/src/tool/schemas.ts +76 -38
  323. package/src/tool/specs.ts +3 -0
  324. package/src/ui/footer.ts +2 -4
  325. package/src/ui/status-overlay.ts +1 -1
  326. package/src/ui/status-presentation.ts +4 -7
  327. package/src/ui/tui/candidate-selection.ts +40 -95
  328. package/src/ui/tui/common.ts +16 -70
  329. package/src/ui/tui/display.ts +6 -24
  330. package/src/tool/result/candidate-row.ts +0 -49
@@ -0,0 +1,609 @@
1
+ 'use strict';
2
+ //parse Empty Node as self closing node
3
+ import buildFromOrderedJs from './orderedJs2Xml.js';
4
+ import getIgnoreAttributesFn from "./ignoreAttributes.js";
5
+ import { Expression, Matcher } from 'path-expression-matcher';
6
+ import { safeComment, safeCdata, escapeAttribute, valToStr } from './util.js';
7
+ import { createValidator } from 'xml-naming';
8
+
9
+ const defaultOptions = {
10
+ attributeNamePrefix: '@_',
11
+ attributesGroupName: false,
12
+ textNodeName: '#text',
13
+ ignoreAttributes: true,
14
+ cdataPropName: false,
15
+ format: false,
16
+ indentBy: ' ',
17
+ suppressEmptyNode: false,
18
+ suppressUnpairedNode: true,
19
+ suppressBooleanAttributes: true,
20
+ tagValueProcessor: function (key, a) {
21
+ return a;
22
+ },
23
+ attributeValueProcessor: function (attrName, a) {
24
+ return a;
25
+ },
26
+ preserveOrder: false,
27
+ commentPropName: false,
28
+ unpairedTags: [],
29
+ entities: [
30
+ { regex: new RegExp("&", "g"), val: "&" },//it must be on top
31
+ { regex: new RegExp(">", "g"), val: ">" },
32
+ { regex: new RegExp("<", "g"), val: "&lt;" },
33
+ { regex: new RegExp("\'", "g"), val: "&apos;" },
34
+ { regex: new RegExp("\"", "g"), val: "&quot;" }
35
+ ],
36
+ processEntities: true,
37
+ stopNodes: [],
38
+ // transformTagName: false,
39
+ // transformAttributeName: false,
40
+ oneListGroup: false,
41
+ maxNestedTags: 100,
42
+ jPath: true, // When true, callbacks receive string jPath; when false, receive Matcher instance
43
+ sanitizeName: false // false = allow all names as-is (default, backward-compatible).
44
+ // Set to a function (name, { isAttribute, matcher }) => string to
45
+ // validate/sanitize tag and attribute names. Throw inside the function
46
+ // to reject an invalid name.
47
+ };
48
+
49
+ export default function Builder(options) {
50
+ this.options = Object.assign({}, defaultOptions, options);
51
+
52
+ // Convert old-style stopNodes for backward compatibility
53
+ // Old syntax: "*.tag" meant "tag anywhere in tree"
54
+ // New syntax: "..tag" means "tag anywhere in tree"
55
+ if (this.options.stopNodes && Array.isArray(this.options.stopNodes)) {
56
+ this.options.stopNodes = this.options.stopNodes.map(node => {
57
+ if (typeof node === 'string' && node.startsWith('*.')) {
58
+ // Convert old wildcard syntax to deep wildcard
59
+ return '..' + node.substring(2);
60
+ }
61
+ return node;
62
+ });
63
+ }
64
+
65
+ // Pre-compile stopNode expressions for pattern matching
66
+ this.stopNodeExpressions = [];
67
+ if (this.options.stopNodes && Array.isArray(this.options.stopNodes)) {
68
+ for (let i = 0; i < this.options.stopNodes.length; i++) {
69
+ const node = this.options.stopNodes[i];
70
+ if (typeof node === 'string') {
71
+ this.stopNodeExpressions.push(new Expression(node));
72
+ } else if (node instanceof Expression) {
73
+ this.stopNodeExpressions.push(node);
74
+ }
75
+ }
76
+ }
77
+
78
+ if (this.options.ignoreAttributes === true || this.options.attributesGroupName) {
79
+ this.isAttribute = function (/*a*/) {
80
+ return false;
81
+ };
82
+ } else {
83
+ this.ignoreAttributesFn = getIgnoreAttributesFn(this.options.ignoreAttributes)
84
+ this.attrPrefixLen = this.options.attributeNamePrefix.length;
85
+ this.isAttribute = isAttribute;
86
+ }
87
+
88
+ this.processTextOrObjNode = processTextOrObjNode
89
+
90
+ if (this.options.format) {
91
+ this.indentate = indentate;
92
+ this.tagEndChar = '>\n';
93
+ this.newLine = '\n';
94
+ } else {
95
+ this.indentate = function () {
96
+ return '';
97
+ };
98
+ this.tagEndChar = '>';
99
+ this.newLine = '';
100
+ }
101
+ }
102
+
103
+ /**
104
+ * Detect XML version from the ?xml declaration at the root of a plain-object input.
105
+ * Checks both attributesGroupName and flat attribute forms.
106
+ * Returns '1.0' if no declaration is found.
107
+ */
108
+ function detectXmlVersionFromObj(jObj, options) {
109
+ const decl = jObj['?xml'];
110
+ if (decl && typeof decl === 'object') {
111
+ // attributesGroupName path e.g. { '$$': { '@_version': '1.1' } }
112
+ if (options.attributesGroupName && decl[options.attributesGroupName]) {
113
+ const v = decl[options.attributesGroupName][options.attributeNamePrefix + 'version'];
114
+ if (v) return v;
115
+ }
116
+ // flat attribute path e.g. { '@_version': '1.1' }
117
+ const v = decl[options.attributeNamePrefix + 'version'];
118
+ if (v) return v;
119
+ }
120
+ return '1.0';
121
+ }
122
+
123
+ /**
124
+ * Resolve a tag or attribute name through sanitizeName if configured.
125
+ * Validation via xml-naming's qName is performed first; the sanitizeName
126
+ * callback is invoked only when the name is invalid. If sanitizeName is
127
+ * false (default), no validation occurs and the name is used as-is.
128
+ *
129
+ * @param {string} name - raw name from the JS object
130
+ * @param {boolean} isAttribute - true when resolving an attribute name
131
+ * @param {object} options
132
+ * @param {Matcher} matcher - current matcher state (readonly from callback perspective)
133
+ * @param {function} qNameValidator - function to validate tag names
134
+ */
135
+ function resolveTagName(name, isAttribute, options, matcher, qNameValidator) {
136
+ if (!options.sanitizeName) return name;
137
+ if (qNameValidator(name)) return name;
138
+ return options.sanitizeName(name, { isAttribute, matcher: matcher.readOnly() });
139
+ }
140
+
141
+ Builder.prototype.build = function (jObj) {
142
+ if (this.options.preserveOrder) {
143
+ return buildFromOrderedJs(jObj, this.options);
144
+ } else {
145
+ if (Array.isArray(jObj) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1) {
146
+ jObj = {
147
+ [this.options.arrayNodeName]: jObj
148
+ }
149
+ }
150
+ // Initialize matcher for path tracking
151
+ const matcher = new Matcher();
152
+ const xmlVersion = detectXmlVersionFromObj(jObj, this.options);
153
+ const qNameValidator = createValidator('qName', { xmlVersion });
154
+ return this.j2x(jObj, 0, matcher, qNameValidator).val;
155
+ }
156
+ };
157
+
158
+ Builder.prototype.j2x = function (jObj, level, matcher, qNameValidator) {
159
+ let attrStr = '';
160
+ let val = '';
161
+ if (this.options.maxNestedTags && matcher.getDepth() >= this.options.maxNestedTags) {
162
+ throw new Error("Maximum nested tags exceeded");
163
+ }
164
+ // Get jPath based on option: string for backward compatibility, or Matcher for new features
165
+ const jPath = this.options.jPath ? matcher.toString() : matcher;
166
+
167
+ // Check if current node is a stopNode (will be used for attribute encoding)
168
+ const isCurrentStopNode = this.checkStopNode(matcher);
169
+
170
+ for (let key in jObj) {
171
+ if (!Object.prototype.hasOwnProperty.call(jObj, key)) continue;
172
+
173
+ // Resolve the key through sanitizeName before any use.
174
+ // Special keys (textNodeName, cdataPropName, commentPropName, attributeNamePrefix,
175
+ // attributesGroupName, "?" PI tags) are exempt — they are builder-internal conventions,
176
+ // not user-supplied XML names.
177
+ const isSpecialKey = key === this.options.textNodeName
178
+ || key === this.options.cdataPropName
179
+ || key === this.options.commentPropName
180
+ || (this.options.attributesGroupName && key === this.options.attributesGroupName)
181
+ || this.isAttribute(key)
182
+ || key[0] === '?';
183
+
184
+ const resolvedKey = isSpecialKey
185
+ ? key
186
+ : resolveTagName(key, false, this.options, matcher, qNameValidator);
187
+
188
+ if (typeof jObj[key] === 'undefined') {
189
+ // supress undefined node only if it is not an attribute
190
+ if (this.isAttribute(key)) {
191
+ val += '';
192
+ }
193
+ } else if (jObj[key] === null) {
194
+ // null attribute should be ignored by the attribute list, but should not cause the tag closing
195
+ if (this.isAttribute(key)) {
196
+ val += '';
197
+ } else if (resolvedKey === this.options.cdataPropName || resolvedKey === this.options.commentPropName) {
198
+ val += '';
199
+ } else if (resolvedKey[0] === '?') {
200
+ val += this.indentate(level) + '<' + resolvedKey + '?' + this.tagEndChar;
201
+ } else {
202
+ val += this.indentate(level) + '<' + resolvedKey + '/' + this.tagEndChar;
203
+ }
204
+ } else if (jObj[key] instanceof Date) {
205
+ val += this.buildTextValNode(jObj[key], resolvedKey, '', level, matcher);
206
+ } else if (typeof jObj[key] !== 'object') {
207
+ //premitive type
208
+ const attr = this.isAttribute(key);
209
+ if (attr && !this.ignoreAttributesFn(attr, jPath)) {
210
+ // Resolve the attribute name through sanitizeName
211
+ const resolvedAttr = resolveTagName(attr, true, this.options, matcher, qNameValidator);
212
+ attrStr += this.buildAttrPairStr(resolvedAttr, valToStr(jObj[key]), isCurrentStopNode);
213
+ } else if (!attr) {
214
+ //tag value
215
+ if (key === this.options.textNodeName) {
216
+ let newval = this.options.tagValueProcessor(key, valToStr(jObj[key]));
217
+ val += this.replaceEntitiesValue(newval);
218
+ } else {
219
+ // Check if this is a stopNode before building
220
+ matcher.push(resolvedKey);
221
+ const isStopNode = this.checkStopNode(matcher);
222
+ matcher.pop();
223
+
224
+ if (isStopNode) {
225
+ // Build as raw content without encoding
226
+ const textValue = valToStr(jObj[key]);
227
+ if (textValue === '') {
228
+ val += this.indentate(level) + '<' + resolvedKey + this.closeTag(resolvedKey) + this.tagEndChar;
229
+ } else {
230
+ val += this.indentate(level) + '<' + resolvedKey + '>' + textValue + '</' + resolvedKey + this.tagEndChar;
231
+ }
232
+ } else {
233
+ val += this.buildTextValNode(jObj[key], resolvedKey, '', level, matcher);
234
+ }
235
+ }
236
+ }
237
+ } else if (Array.isArray(jObj[key])) {
238
+ //repeated nodes
239
+ const arrLen = jObj[key].length;
240
+ let listTagVal = "";
241
+ let listTagAttr = "";
242
+ for (let j = 0; j < arrLen; j++) {
243
+ const item = jObj[key][j];
244
+ if (typeof item === 'undefined') {
245
+ // supress undefined node
246
+ } else if (item === null) {
247
+ if (resolvedKey[0] === "?") val += this.indentate(level) + '<' + resolvedKey + '?' + this.tagEndChar;
248
+ else val += this.indentate(level) + '<' + resolvedKey + '/' + this.tagEndChar;
249
+ } else if (typeof item === 'object') {
250
+ if (this.options.oneListGroup) {
251
+ // Push tag to matcher before recursive call
252
+ matcher.push(resolvedKey);
253
+ const result = this.j2x(item, level + 1, matcher, qNameValidator);
254
+ // Pop tag from matcher after recursive call
255
+ matcher.pop();
256
+
257
+ listTagVal += result.val;
258
+ if (this.options.attributesGroupName && item.hasOwnProperty(this.options.attributesGroupName)) {
259
+ listTagAttr += result.attrStr
260
+ }
261
+ } else {
262
+ listTagVal += this.processTextOrObjNode(item, resolvedKey, level, matcher, qNameValidator)
263
+ }
264
+ } else {
265
+ if (this.options.oneListGroup) {
266
+ let textValue = this.options.tagValueProcessor(resolvedKey, item);
267
+ textValue = this.replaceEntitiesValue(textValue);
268
+ textValue = valToStr(textValue);
269
+ listTagVal += textValue;
270
+ } else {
271
+ // Check if this is a stopNode before building
272
+ matcher.push(resolvedKey);
273
+ const isStopNode = this.checkStopNode(matcher);
274
+ matcher.pop();
275
+
276
+ if (isStopNode) {
277
+ // Build as raw content without encoding
278
+ const textValue = valToStr(item);
279
+ if (textValue === '') {
280
+ listTagVal += this.indentate(level) + '<' + resolvedKey + this.closeTag(resolvedKey) + this.tagEndChar;
281
+ } else {
282
+ listTagVal += this.indentate(level) + '<' + resolvedKey + '>' + textValue + '</' + resolvedKey + this.tagEndChar;
283
+ }
284
+ } else {
285
+ listTagVal += this.buildTextValNode(item, resolvedKey, '', level, matcher);
286
+ }
287
+ }
288
+ }
289
+ }
290
+ if (this.options.oneListGroup) {
291
+ listTagVal = this.buildObjectNode(listTagVal, resolvedKey, listTagAttr, level);
292
+ }
293
+ val += listTagVal;
294
+ } else {
295
+ //nested node
296
+ if (this.options.attributesGroupName && key === this.options.attributesGroupName) {
297
+ const Ks = Object.keys(jObj[key]);
298
+ const L = Ks.length;
299
+ for (let j = 0; j < L; j++) {
300
+ // Resolve attribute names inside attributesGroupName
301
+ const resolvedAttr = resolveTagName(Ks[j], true, this.options, matcher, qNameValidator);
302
+ attrStr += this.buildAttrPairStr(resolvedAttr, valToStr(jObj[key][Ks[j]]), isCurrentStopNode);
303
+ }
304
+ } else {
305
+ val += this.processTextOrObjNode(jObj[key], resolvedKey, level, matcher, qNameValidator)
306
+ }
307
+ }
308
+ }
309
+ return { attrStr: attrStr, val: val };
310
+ };
311
+
312
+ Builder.prototype.buildAttrPairStr = function (attrName, val, isStopNode) {
313
+ if (!isStopNode) {
314
+ val = this.options.attributeValueProcessor(attrName, valToStr(val));
315
+ val = this.replaceEntitiesValue(val);
316
+ }
317
+ if (this.options.suppressBooleanAttributes && val === "true") {
318
+ return ' ' + attrName;
319
+ } else return ' ' + attrName + '="' + escapeAttribute(val) + '"';
320
+ }
321
+
322
+ function processTextOrObjNode(object, key, level, matcher, qNameValidator) {
323
+ // Extract attributes to pass to matcher
324
+ const attrValues = this.extractAttributes(object);
325
+
326
+ // Push tag to matcher before recursion WITH attributes
327
+ matcher.push(key, attrValues);
328
+
329
+ // Check if this entire node is a stopNode
330
+ const isStopNode = this.checkStopNode(matcher);
331
+
332
+ if (isStopNode) {
333
+ // For stopNodes, build raw content without entity encoding
334
+ const rawContent = this.buildRawContent(object);
335
+ const attrStr = this.buildAttributesForStopNode(object);
336
+ matcher.pop();
337
+ return this.buildObjectNode(rawContent, key, attrStr, level);
338
+ }
339
+
340
+ const result = this.j2x(object, level + 1, matcher, qNameValidator);
341
+ // Pop tag from matcher after recursion
342
+ matcher.pop();
343
+
344
+ // PI/XML-declaration tags must never emit text content — route through
345
+ // buildTextValNode which correctly ignores the text node for "?" tags.
346
+ if (key[0] === '?') {
347
+ return this.buildTextValNode('', key, result.attrStr, level, matcher);
348
+ } else if (object[this.options.textNodeName] !== undefined && Object.keys(object).length === 1) {
349
+ return this.buildTextValNode(object[this.options.textNodeName], key, result.attrStr, level, matcher);
350
+ } else {
351
+ return this.buildObjectNode(result.val, key, result.attrStr, level);
352
+ }
353
+ }
354
+
355
+ // Helper method to extract attributes from an object
356
+ Builder.prototype.extractAttributes = function (obj) {
357
+ if (!obj || typeof obj !== 'object') return null;
358
+
359
+ const attrValues = {};
360
+ let hasAttrs = false;
361
+
362
+ // Check for attributesGroupName (when attributes are grouped)
363
+ if (this.options.attributesGroupName && obj[this.options.attributesGroupName]) {
364
+ const attrGroup = obj[this.options.attributesGroupName];
365
+ for (let attrKey in attrGroup) {
366
+ if (!Object.prototype.hasOwnProperty.call(attrGroup, attrKey)) continue;
367
+ // Remove attribute prefix if present
368
+ const cleanKey = attrKey.startsWith(this.options.attributeNamePrefix)
369
+ ? attrKey.substring(this.options.attributeNamePrefix.length)
370
+ : attrKey;
371
+ attrValues[cleanKey] = escapeAttribute(attrGroup[attrKey]);
372
+ hasAttrs = true;
373
+ }
374
+ } else {
375
+ // Look for individual attributes (prefixed with attributeNamePrefix)
376
+ for (let key in obj) {
377
+ if (!Object.prototype.hasOwnProperty.call(obj, key)) continue;
378
+ const attr = this.isAttribute(key);
379
+ if (attr) {
380
+ attrValues[attr] = escapeAttribute(obj[key]);
381
+ hasAttrs = true;
382
+ }
383
+ }
384
+ }
385
+
386
+ return hasAttrs ? attrValues : null;
387
+ };
388
+
389
+ // Build raw content for stopNode without entity encoding
390
+ Builder.prototype.buildRawContent = function (obj) {
391
+ if (typeof obj === 'string') {
392
+ return obj; // Already a string, return as-is
393
+ }
394
+
395
+ if (typeof obj !== 'object' || obj === null) {
396
+ return String(obj);
397
+ }
398
+
399
+ // Check if this is a stopNode data from parser: { "#text": "raw xml", "@_attr": "val" }
400
+ if (obj[this.options.textNodeName] !== undefined) {
401
+ return obj[this.options.textNodeName]; // Return raw text without encoding
402
+ }
403
+
404
+ // Build raw XML from nested structure
405
+ let content = '';
406
+
407
+ for (let key in obj) {
408
+ if (!Object.prototype.hasOwnProperty.call(obj, key)) continue;
409
+
410
+ // Skip attributes
411
+ if (this.isAttribute(key)) continue;
412
+ if (this.options.attributesGroupName && key === this.options.attributesGroupName) continue;
413
+
414
+ const value = obj[key];
415
+
416
+ if (key === this.options.textNodeName) {
417
+ content += value; // Raw text
418
+ } else if (Array.isArray(value)) {
419
+ // Array of same tag
420
+ for (let item of value) {
421
+ if (typeof item === 'string' || typeof item === 'number') {
422
+ content += `<${key}>${item}</${key}>`;
423
+ } else if (typeof item === 'object' && item !== null) {
424
+ const nestedContent = this.buildRawContent(item);
425
+ const nestedAttrs = this.buildAttributesForStopNode(item);
426
+ if (nestedContent === '') {
427
+ content += `<${key}${nestedAttrs}/>`;
428
+ } else {
429
+ content += `<${key}${nestedAttrs}>${nestedContent}</${key}>`;
430
+ }
431
+ }
432
+ }
433
+ } else if (typeof value === 'object' && value !== null) {
434
+ // Nested object
435
+ const nestedContent = this.buildRawContent(value);
436
+ const nestedAttrs = this.buildAttributesForStopNode(value);
437
+ if (nestedContent === '') {
438
+ content += `<${key}${nestedAttrs}/>`;
439
+ } else {
440
+ content += `<${key}${nestedAttrs}>${nestedContent}</${key}>`;
441
+ }
442
+ } else {
443
+ // Primitive value
444
+ content += `<${key}>${value}</${key}>`;
445
+ }
446
+ }
447
+
448
+ return content;
449
+ };
450
+
451
+ // Build attribute string for stopNode (no entity encoding)
452
+ Builder.prototype.buildAttributesForStopNode = function (obj) {
453
+ if (!obj || typeof obj !== 'object') return '';
454
+
455
+ let attrStr = '';
456
+
457
+ // Check for attributesGroupName (when attributes are grouped)
458
+ if (this.options.attributesGroupName && obj[this.options.attributesGroupName]) {
459
+ const attrGroup = obj[this.options.attributesGroupName];
460
+ for (let attrKey in attrGroup) {
461
+ if (!Object.prototype.hasOwnProperty.call(attrGroup, attrKey)) continue;
462
+ const cleanKey = attrKey.startsWith(this.options.attributeNamePrefix)
463
+ ? attrKey.substring(this.options.attributeNamePrefix.length)
464
+ : attrKey;
465
+ const val = attrGroup[attrKey];
466
+ if (val === true && this.options.suppressBooleanAttributes) {
467
+ attrStr += ' ' + cleanKey;
468
+ } else {
469
+ // stopNode content is raw, but the quote delimiter is always escaped
470
+ // so a quote in the value cannot break out of the attribute (see orderedJs2Xml attr_to_str)
471
+ attrStr += ' ' + cleanKey + '="' + escapeAttribute(val) + '"';
472
+ }
473
+ }
474
+ } else {
475
+ // Look for individual attributes
476
+ for (let key in obj) {
477
+ if (!Object.prototype.hasOwnProperty.call(obj, key)) continue;
478
+ const attr = this.isAttribute(key);
479
+ if (attr) {
480
+ const val = obj[key];
481
+ if (val === true && this.options.suppressBooleanAttributes) {
482
+ attrStr += ' ' + attr;
483
+ } else {
484
+ // stopNode content is raw, but the quote delimiter is always escaped
485
+ // so a quote in the value cannot break out of the attribute (see orderedJs2Xml attr_to_str)
486
+ attrStr += ' ' + attr + '="' + escapeAttribute(val) + '"';
487
+ }
488
+ }
489
+ }
490
+ }
491
+
492
+ return attrStr;
493
+ };
494
+
495
+ Builder.prototype.buildObjectNode = function (val, key, attrStr, level) {
496
+ if (val === "") {
497
+ if (key[0] === "?") return this.indentate(level) + '<' + key + attrStr + '?' + this.tagEndChar;
498
+ else {
499
+ return this.indentate(level) + '<' + key + attrStr + this.closeTag(key) + this.tagEndChar;
500
+ }
501
+ } else if (key[0] === "?") {
502
+ // PI/XML-declaration tags never have body content — treat them like empty.
503
+ return this.indentate(level) + '<' + key + attrStr + '?' + this.tagEndChar;
504
+ } else {
505
+ let tagEndExp = '</' + key + this.tagEndChar;
506
+ let piClosingChar = "";
507
+
508
+ if (key[0] === "?") {
509
+ piClosingChar = "?";
510
+ tagEndExp = "";
511
+ }
512
+
513
+ // attrStr is an empty string in case the attribute came as undefined or null
514
+ if ((attrStr || attrStr === '') && val.indexOf('<') === -1) {
515
+ return (this.indentate(level) + '<' + key + attrStr + piClosingChar + '>' + val + tagEndExp);
516
+ } else if (this.options.commentPropName !== false && key === this.options.commentPropName && piClosingChar.length === 0) {
517
+ return this.indentate(level) + `<!--${safeComment(val)}-->` + this.newLine;
518
+ } else {
519
+ return (
520
+ this.indentate(level) + '<' + key + attrStr + piClosingChar + this.tagEndChar +
521
+ val +
522
+ this.indentate(level) + tagEndExp);
523
+ }
524
+ }
525
+ }
526
+
527
+ Builder.prototype.closeTag = function (key) {
528
+ let closeTag = "";
529
+ if (this.options.unpairedTags.indexOf(key) !== -1) { //unpaired
530
+ if (!this.options.suppressUnpairedNode) closeTag = "/"
531
+ } else if (this.options.suppressEmptyNode) { //empty
532
+ closeTag = "/";
533
+ } else {
534
+ closeTag = `></${key}`
535
+ }
536
+ return closeTag;
537
+ }
538
+
539
+ Builder.prototype.checkStopNode = function (matcher) {
540
+ if (!this.stopNodeExpressions || this.stopNodeExpressions.length === 0) return false;
541
+
542
+ for (let i = 0; i < this.stopNodeExpressions.length; i++) {
543
+ if (matcher.matches(this.stopNodeExpressions[i])) {
544
+ return true;
545
+ }
546
+ }
547
+ return false;
548
+ }
549
+
550
+ function buildEmptyObjNode(val, key, attrStr, level) {
551
+ if (val !== '') {
552
+ return this.buildObjectNode(val, key, attrStr, level);
553
+ } else {
554
+ if (key[0] === "?") return this.indentate(level) + '<' + key + attrStr + '?' + this.tagEndChar;
555
+ else {
556
+ return this.indentate(level) + '<' + key + attrStr + '/' + this.tagEndChar;
557
+ }
558
+ }
559
+ }
560
+
561
+ Builder.prototype.buildTextValNode = function (val, key, attrStr, level, matcher) {
562
+ if (this.options.cdataPropName !== false && key === this.options.cdataPropName) {
563
+ const safeVal = safeCdata(val);
564
+ return this.indentate(level) + `<![CDATA[${safeVal}]]>` + this.newLine;
565
+ } else if (this.options.commentPropName !== false && key === this.options.commentPropName) {
566
+ const safeVal = safeComment(val);
567
+ return this.indentate(level) + `<!--${safeVal}-->` + this.newLine;
568
+ } else if (key[0] === "?") {//PI tag
569
+ return this.indentate(level) + '<' + key + attrStr + '?' + this.tagEndChar;
570
+ } else {
571
+ // Normal processing: apply tagValueProcessor and entity replacement
572
+ let textValue = this.options.tagValueProcessor(key, val);
573
+ textValue = this.replaceEntitiesValue(textValue);
574
+ // tagValueProcessor may return the raw value unchanged (default is identity), and
575
+ // replaceEntitiesValue no-ops on non-strings, so a plain number can still reach here;
576
+ // stringify it now, sign-preserving, before it's implicitly ToString'd below.
577
+ textValue = valToStr(textValue);
578
+
579
+ if (textValue === '') {
580
+ return this.indentate(level) + '<' + key + attrStr + this.closeTag(key) + this.tagEndChar;
581
+ } else {
582
+ return this.indentate(level) + '<' + key + attrStr + '>' +
583
+ textValue +
584
+ '</' + key + this.tagEndChar;
585
+ }
586
+ }
587
+ }
588
+
589
+ Builder.prototype.replaceEntitiesValue = function (textValue) {
590
+ if (textValue && textValue.length > 0 && this.options.processEntities) {
591
+ for (let i = 0; i < this.options.entities.length; i++) {
592
+ const entity = this.options.entities[i];
593
+ textValue = textValue.replace(entity.regex, entity.val);
594
+ }
595
+ }
596
+ return textValue;
597
+ }
598
+
599
+ function indentate(level) {
600
+ return this.options.indentBy.repeat(level);
601
+ }
602
+
603
+ function isAttribute(name /*, options*/) {
604
+ if (name.startsWith(this.options.attributeNamePrefix) && name !== this.options.textNodeName) {
605
+ return name.substr(this.attrPrefixLen);
606
+ } else {
607
+ return false;
608
+ }
609
+ }
@@ -0,0 +1,18 @@
1
+ export default function getIgnoreAttributesFn(ignoreAttributes) {
2
+ if (typeof ignoreAttributes === 'function') {
3
+ return ignoreAttributes
4
+ }
5
+ if (Array.isArray(ignoreAttributes)) {
6
+ return (attrName) => {
7
+ for (const pattern of ignoreAttributes) {
8
+ if (typeof pattern === 'string' && attrName === pattern) {
9
+ return true
10
+ }
11
+ if (pattern instanceof RegExp && pattern.test(attrName)) {
12
+ return true
13
+ }
14
+ }
15
+ }
16
+ }
17
+ return () => false
18
+ }