@mrclrchtr/supi-code-intelligence 12.0.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.
- package/CHANGELOG.md +17 -0
- package/README.md +4 -2
- package/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-core/package.json +3 -1
- package/node_modules/@mrclrchtr/supi-core/src/api.ts +4 -0
- package/node_modules/@mrclrchtr/supi-core/src/context/context-tag.ts +1 -1
- package/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +22 -3
- package/node_modules/@mrclrchtr/supi-core/src/retired-packages.ts +152 -0
- package/node_modules/@mrclrchtr/supi-core/src/session.ts +1 -0
- package/node_modules/@mrclrchtr/supi-core/src/shell-hints.ts +46 -0
- package/node_modules/@mrclrchtr/supi-core/src/spill.ts +93 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/package.json +3 -1
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/api.ts +4 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/context/context-tag.ts +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +22 -3
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/retired-packages.ts +152 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/session.ts +1 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/shell-hints.ts +46 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/spill.ts +93 -0
- package/node_modules/@mrclrchtr/supi-lsp/package.json +8 -8
- package/node_modules/@mrclrchtr/supi-lsp/src/api.ts +1 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-cache.ts +102 -47
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-host.ts +8 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-refresh.ts +15 -1
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-request.ts +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostics.ts +46 -4
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-disk-stamp.ts +60 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-document-state.ts +3 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-document-sync.ts +21 -1
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-file-state.ts +17 -3
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-semantic-input-barrier.ts +53 -4
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client.ts +11 -3
- package/node_modules/@mrclrchtr/supi-lsp/src/config/tsconfig-extends.ts +2 -1
- package/node_modules/@mrclrchtr/supi-lsp/src/config/tsconfig-path.ts +2 -2
- package/node_modules/@mrclrchtr/supi-lsp/src/config/tsconfig-scope.ts +14 -5
- package/node_modules/@mrclrchtr/supi-lsp/src/config/typescript-module.ts +17 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/diagnostics/evidence.ts +42 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-client-state.ts +2 -17
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-removal-ledger.ts +52 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager.ts +40 -20
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/typescript-file-local.ts +6 -1
- package/node_modules/@mrclrchtr/supi-lsp/src/provider/lsp-semantic-provider.ts +6 -1
- package/node_modules/@mrclrchtr/supi-lsp/src/provider/semantic-symbol-mapper.ts +13 -3
- package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-diagnostic-surface.ts +11 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-diagnostics.ts +1 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-registry.ts +17 -2
- package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-transition-debug.ts +11 -1
- package/node_modules/@mrclrchtr/supi-lsp/src/session/workspace-lsp-runtime.ts +2 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/package.json +3 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/api.ts +4 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/context/context-tag.ts +1 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +22 -3
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/retired-packages.ts +152 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/session.ts +1 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/shell-hints.ts +46 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/spill.ts +93 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.cjs +50 -75
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.cjs.map +2 -2
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.js +50 -75
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.js.map +2 -2
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.wasm +0 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.wasm.map +6 -6
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.cjs +50 -75
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.cjs.map +2 -2
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.d.cts +7 -7
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.d.cts.map +1 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.d.ts +7 -7
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.d.ts.map +1 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.js +50 -75
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.js.map +2 -2
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.wasm +0 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.wasm.map +5 -5
- package/node_modules/@mrclrchtr/supi-tree-sitter/package.json +5 -5
- package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/kotlin/tree-sitter-kotlin.wasm.json +1 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/latex/tree-sitter-latex.wasm.json +1 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/sql/tree-sitter-sql.wasm.json +1 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/tsx/tree-sitter-tsx.wasm.json +1 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/typescript/tree-sitter-typescript.wasm.json +1 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/structural-worker-client.ts +1 -1
- package/node_modules/fast-xml-parser/CHANGELOG.md +886 -0
- package/node_modules/fast-xml-parser/LICENSE +21 -0
- package/node_modules/fast-xml-parser/README.md +204 -0
- package/node_modules/fast-xml-parser/lib/fxbuilder.min.js +2 -0
- package/node_modules/fast-xml-parser/lib/fxbuilder.min.js.map +1 -0
- package/node_modules/fast-xml-parser/lib/fxp.cjs +1 -0
- package/node_modules/fast-xml-parser/lib/fxp.d.cts +774 -0
- package/node_modules/fast-xml-parser/lib/fxp.min.js +2 -0
- package/node_modules/fast-xml-parser/lib/fxp.min.js.map +1 -0
- package/node_modules/fast-xml-parser/lib/fxparser.min.js +2 -0
- package/node_modules/fast-xml-parser/lib/fxparser.min.js.map +1 -0
- package/node_modules/fast-xml-parser/lib/fxvalidator.min.js +2 -0
- package/node_modules/fast-xml-parser/lib/fxvalidator.min.js.map +1 -0
- package/node_modules/fast-xml-parser/node_modules/@nodable/entities/README.md +92 -0
- package/node_modules/fast-xml-parser/node_modules/@nodable/entities/package.json +57 -0
- package/node_modules/fast-xml-parser/node_modules/@nodable/entities/src/EntityDecoder.js +644 -0
- package/node_modules/fast-xml-parser/node_modules/@nodable/entities/src/EntityEncoder.js +239 -0
- package/node_modules/fast-xml-parser/node_modules/@nodable/entities/src/all-entities.js +53 -0
- package/node_modules/fast-xml-parser/node_modules/@nodable/entities/src/entities.js +1139 -0
- package/node_modules/fast-xml-parser/node_modules/@nodable/entities/src/entityTries.js +60 -0
- package/node_modules/fast-xml-parser/node_modules/@nodable/entities/src/index.d.ts +358 -0
- package/node_modules/fast-xml-parser/node_modules/@nodable/entities/src/index.js +29 -0
- package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/CHANGELOG.md +52 -0
- package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/LICENSE +21 -0
- package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/README.md +77 -0
- package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/lib/fxb.cjs +1 -0
- package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/lib/fxb.d.cts +270 -0
- package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/lib/fxb.min.js +2 -0
- package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/lib/fxb.min.js.map +1 -0
- package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/package.json +77 -0
- package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/src/fxb.d.ts +270 -0
- package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/src/fxb.js +609 -0
- package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/src/ignoreAttributes.js +18 -0
- package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/src/orderedJs2Xml.js +360 -0
- package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/src/prettifyJs2Xml.js +0 -0
- package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/src/util.js +23 -0
- package/node_modules/fast-xml-parser/node_modules/is-unsafe/LICENSE +21 -0
- package/node_modules/fast-xml-parser/node_modules/is-unsafe/README.md +632 -0
- package/node_modules/fast-xml-parser/node_modules/is-unsafe/package.json +56 -0
- package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/contexts/html.js +102 -0
- package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/contexts/log.js +98 -0
- package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/contexts/nosql.js +114 -0
- package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/contexts/redos.js +60 -0
- package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/contexts/shell.js +105 -0
- package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/contexts/sql-strict.js +47 -0
- package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/contexts/sql.js +95 -0
- package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/contexts/svg.js +81 -0
- package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/contexts/xml.js +79 -0
- package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/index.cjs +27 -0
- package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/index.d.ts +103 -0
- package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/index.js +292 -0
- package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/util/decode-entities.js +48 -0
- package/node_modules/fast-xml-parser/node_modules/path-expression-matcher/LICENSE +21 -0
- package/node_modules/fast-xml-parser/node_modules/path-expression-matcher/README.md +947 -0
- package/node_modules/fast-xml-parser/node_modules/path-expression-matcher/lib/pem.cjs +1 -0
- package/node_modules/fast-xml-parser/node_modules/path-expression-matcher/lib/pem.d.cts +725 -0
- package/node_modules/fast-xml-parser/node_modules/path-expression-matcher/lib/pem.min.js +2 -0
- package/node_modules/fast-xml-parser/node_modules/path-expression-matcher/lib/pem.min.js.map +1 -0
- package/node_modules/fast-xml-parser/node_modules/path-expression-matcher/package.json +79 -0
- package/node_modules/fast-xml-parser/node_modules/path-expression-matcher/src/Expression.js +232 -0
- package/node_modules/fast-xml-parser/node_modules/path-expression-matcher/src/ExpressionSet.js +225 -0
- package/node_modules/fast-xml-parser/node_modules/path-expression-matcher/src/Matcher.js +663 -0
- package/node_modules/fast-xml-parser/node_modules/path-expression-matcher/src/index.d.ts +589 -0
- package/node_modules/fast-xml-parser/node_modules/path-expression-matcher/src/index.js +30 -0
- package/node_modules/fast-xml-parser/node_modules/strnum/CHANGELOG.md +63 -0
- package/node_modules/fast-xml-parser/node_modules/strnum/LICENSE +21 -0
- package/node_modules/fast-xml-parser/node_modules/strnum/README.md +113 -0
- package/node_modules/fast-xml-parser/node_modules/strnum/node_modules/anynum/LICENSE +21 -0
- package/node_modules/fast-xml-parser/node_modules/strnum/node_modules/anynum/README.md +142 -0
- package/node_modules/fast-xml-parser/node_modules/strnum/node_modules/anynum/anynum.js +135 -0
- package/node_modules/fast-xml-parser/node_modules/strnum/node_modules/anynum/digitTable.js +116 -0
- package/node_modules/fast-xml-parser/node_modules/strnum/node_modules/anynum/package.json +42 -0
- package/node_modules/fast-xml-parser/node_modules/strnum/package.json +36 -0
- package/node_modules/fast-xml-parser/node_modules/strnum/strnum.js +176 -0
- package/node_modules/fast-xml-parser/node_modules/xml-naming/LICENSE +21 -0
- package/node_modules/fast-xml-parser/node_modules/xml-naming/README.md +287 -0
- package/node_modules/fast-xml-parser/node_modules/xml-naming/package.json +56 -0
- package/node_modules/fast-xml-parser/node_modules/xml-naming/src/index.d.ts +108 -0
- package/node_modules/fast-xml-parser/node_modules/xml-naming/src/index.js +382 -0
- package/node_modules/fast-xml-parser/package.json +93 -0
- package/node_modules/fast-xml-parser/src/cli/cli.js +97 -0
- package/node_modules/fast-xml-parser/src/cli/man.js +17 -0
- package/node_modules/fast-xml-parser/src/cli/read.js +43 -0
- package/node_modules/fast-xml-parser/src/fxp.d.ts +754 -0
- package/node_modules/fast-xml-parser/src/fxp.js +14 -0
- package/node_modules/fast-xml-parser/src/ignoreAttributes.js +18 -0
- package/node_modules/fast-xml-parser/src/util.js +61 -0
- package/node_modules/fast-xml-parser/src/v6/CharsSymbol.js +16 -0
- package/node_modules/fast-xml-parser/src/v6/EntitiesParser.js +106 -0
- package/node_modules/fast-xml-parser/src/v6/OptionsBuilder.js +61 -0
- package/node_modules/fast-xml-parser/src/v6/OutputBuilders/BaseOutputBuilder.js +69 -0
- package/node_modules/fast-xml-parser/src/v6/OutputBuilders/JsArrBuilder.js +103 -0
- package/node_modules/fast-xml-parser/src/v6/OutputBuilders/JsMinArrBuilder.js +100 -0
- package/node_modules/fast-xml-parser/src/v6/OutputBuilders/JsObjBuilder.js +154 -0
- package/node_modules/fast-xml-parser/src/v6/OutputBuilders/ParserOptionsBuilder.js +94 -0
- package/node_modules/fast-xml-parser/src/v6/Report.js +0 -0
- package/node_modules/fast-xml-parser/src/v6/TagPath.js +81 -0
- package/node_modules/fast-xml-parser/src/v6/TagPathMatcher.js +13 -0
- package/node_modules/fast-xml-parser/src/v6/XMLParser.js +83 -0
- package/node_modules/fast-xml-parser/src/v6/Xml2JsParser.js +235 -0
- package/node_modules/fast-xml-parser/src/v6/XmlPartReader.js +210 -0
- package/node_modules/fast-xml-parser/src/v6/XmlSpecialTagsReader.js +111 -0
- package/node_modules/fast-xml-parser/src/v6/inputSource/BufferSource.js +116 -0
- package/node_modules/fast-xml-parser/src/v6/inputSource/StringSource.js +121 -0
- package/node_modules/fast-xml-parser/src/v6/valueParsers/EntitiesParser.js +105 -0
- package/node_modules/fast-xml-parser/src/v6/valueParsers/booleanParser.js +22 -0
- package/node_modules/fast-xml-parser/src/v6/valueParsers/booleanParserExt.js +19 -0
- package/node_modules/fast-xml-parser/src/v6/valueParsers/currency.js +38 -0
- package/node_modules/fast-xml-parser/src/v6/valueParsers/join.js +13 -0
- package/node_modules/fast-xml-parser/src/v6/valueParsers/number.js +14 -0
- package/node_modules/fast-xml-parser/src/v6/valueParsers/trim.js +6 -0
- package/node_modules/fast-xml-parser/src/validator.js +518 -0
- package/node_modules/fast-xml-parser/src/xmlbuilder/json2xml.js +6 -0
- package/node_modules/fast-xml-parser/src/xmlparser/DocTypeReader.js +426 -0
- package/node_modules/fast-xml-parser/src/xmlparser/OptionsBuilder.js +164 -0
- package/node_modules/fast-xml-parser/src/xmlparser/OrderedObjParser.js +907 -0
- package/node_modules/fast-xml-parser/src/xmlparser/XMLParser.js +77 -0
- package/node_modules/fast-xml-parser/src/xmlparser/node2json.js +177 -0
- package/node_modules/fast-xml-parser/src/xmlparser/xmlNode.js +54 -0
- package/package.json +10 -8
- package/src/analysis/evidence.ts +331 -73
- package/src/analysis/health/diagnostics.ts +66 -18
- package/src/analysis/health/evidence-reason.ts +44 -0
- package/src/analysis/search/pattern.ts +3 -3
- package/src/analysis/target/anchored.ts +3 -6
- package/src/analysis/target/symbol.ts +41 -47
- package/src/analysis/target/types.ts +4 -9
- package/src/analysis/workspace/cmake-parser.ts +207 -0
- package/src/analysis/workspace/cmake.ts +141 -0
- package/src/analysis/workspace/maven.ts +310 -0
- package/src/analysis/workspace/membership.ts +100 -26
- package/src/analysis/workspace/metadata.ts +6 -1
- package/src/analysis/workspace/observe.ts +6 -0
- package/src/analysis/workspace/types.ts +11 -3
- package/src/diagnostics/coverage.ts +49 -0
- package/src/diagnostics/evidence.ts +10 -2
- package/src/session/health-workflow.ts +6 -0
- package/src/session/input/common.ts +1 -1
- package/src/session/orientation/collect.ts +42 -7
- package/src/session/orientation/context-facts.ts +3 -3
- package/src/session/orientation/context-sections.ts +13 -15
- package/src/session/orientation/facts.ts +5 -8
- package/src/session/orientation-workflow.ts +4 -19
- package/src/session/target-workflow.ts +25 -18
- package/src/tool/code_find/result.ts +5 -7
- package/src/tool/code_graph/display.ts +5 -6
- package/src/tool/code_graph/format.ts +8 -24
- package/src/tool/code_graph/result.ts +16 -75
- package/src/tool/code_graph/section.ts +21 -33
- package/src/tool/code_graph/tui.ts +10 -5
- package/src/tool/code_health/diagnostic-tui.ts +49 -0
- package/src/tool/code_health/guidance.ts +27 -0
- package/src/tool/code_health/markdown.ts +60 -8
- package/src/tool/code_health/result.ts +20 -9
- package/src/tool/code_health/structured-schema.ts +14 -0
- package/src/tool/code_health/structured.ts +7 -1
- package/src/tool/code_health/tui.ts +33 -40
- package/src/tool/code_inspect/result.ts +23 -18
- package/src/tool/code_inspect/structured.ts +2 -19
- package/src/tool/code_orientation/result.ts +53 -100
- package/src/tool/code_orientation/structured-schema.ts +16 -12
- package/src/tool/code_orientation/structured-workspace.ts +13 -7
- package/src/tool/code_orientation/structured.ts +31 -39
- package/src/tool/code_orientation/workspace-format.ts +4 -10
- package/src/tool/code_orientation/workspace-instructions.ts +4 -5
- package/src/tool/code_orientation/workspace-observations.ts +2 -2
- package/src/tool/code_orientation/workspace-output.ts +16 -7
- package/src/tool/code_orientation/workspace-projects.ts +7 -10
- package/src/tool/code_orientation/workspace-sections.ts +13 -19
- package/src/tool/code_resolve/markdown.ts +4 -46
- package/src/tool/code_resolve/result.ts +43 -72
- package/src/tool/infra/truncate.ts +2 -16
- package/src/tool/result/candidate-selection.ts +141 -0
- package/src/tool/result/display.ts +41 -45
- package/src/tool/result/errors.ts +1 -0
- package/src/tool/result/model-budget.ts +26 -1
- package/src/tool/result/refactor.ts +11 -8
- package/src/tool/result/structured.ts +2 -1
- package/src/tool/result/types.ts +9 -8
- package/src/tool/schemas.ts +15 -20
- package/src/ui/footer.ts +2 -4
- package/src/ui/status-presentation.ts +4 -7
- package/src/ui/tui/candidate-selection.ts +40 -95
- package/src/ui/tui/common.ts +16 -70
- package/src/ui/tui/display.ts +6 -24
- package/src/tool/result/candidate-row.ts +0 -49
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* xml-naming
|
|
3
|
+
* Validates XML Name productions as defined in the XML 1.0 and 1.1 specifications.
|
|
4
|
+
* Covers: Name, NCName, QName, NMToken, NMTokens
|
|
5
|
+
*
|
|
6
|
+
* XML 1.0 spec: https://www.w3.org/TR/xml/#NT-Name
|
|
7
|
+
* XML 1.1 spec: https://www.w3.org/TR/xml11/#NT-NameStartChar
|
|
8
|
+
* XML NS spec: https://www.w3.org/TR/xml-names/#NT-NCName
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
// ---------------------------------------------------------------------------
|
|
12
|
+
// Character class strings — XML 1.0
|
|
13
|
+
//
|
|
14
|
+
// NameStartChar ::= ":" | [A-Z] | "_" | [a-z]
|
|
15
|
+
// | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF]
|
|
16
|
+
// | [#x370-#x37D] | [#x37F-#x1FFF] <- split to exclude #x0487
|
|
17
|
+
// | [#x200C-#x200D]
|
|
18
|
+
// | [#x2070-#x218F] | [#x2C00-#x2FEF]
|
|
19
|
+
// | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD]
|
|
20
|
+
//
|
|
21
|
+
// NameChar ::= NameStartChar | "-" | "." | [0-9]
|
|
22
|
+
// | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]
|
|
23
|
+
//
|
|
24
|
+
// Note: \u0487 (Combining Cyrillic Millions Sign) was added in Unicode 4.0,
|
|
25
|
+
// after XML 1.0 was defined against Unicode 2.0. It falls inside the range
|
|
26
|
+
// \u037F-\u1FFF but must be excluded. We split that range into
|
|
27
|
+
// \u037F-\u0486 and \u0488-\u1FFF to exclude it explicitly.
|
|
28
|
+
// ---------------------------------------------------------------------------
|
|
29
|
+
|
|
30
|
+
const nameStartChar10 =
|
|
31
|
+
':A-Za-z_' +
|
|
32
|
+
'\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF' +
|
|
33
|
+
'\u0370-\u037D' +
|
|
34
|
+
'\u037F-\u0486\u0488-\u1FFF' + // split to exclude \u0487
|
|
35
|
+
'\u200C-\u200D' +
|
|
36
|
+
'\u2070-\u218F' +
|
|
37
|
+
'\u2C00-\u2FEF' +
|
|
38
|
+
'\u3001-\uD7FF' +
|
|
39
|
+
'\uF900-\uFDCF' +
|
|
40
|
+
'\uFDF0-\uFFFD';
|
|
41
|
+
|
|
42
|
+
const nameChar10 =
|
|
43
|
+
nameStartChar10 +
|
|
44
|
+
'\\-\\.\\d' +
|
|
45
|
+
'\u00B7' +
|
|
46
|
+
'\u0300-\u036F' +
|
|
47
|
+
'\u203F-\u2040';
|
|
48
|
+
|
|
49
|
+
// ---------------------------------------------------------------------------
|
|
50
|
+
// Character class strings — XML 1.1
|
|
51
|
+
//
|
|
52
|
+
// Differences from XML 1.0:
|
|
53
|
+
//
|
|
54
|
+
// NameStartChar:
|
|
55
|
+
// 1.0 has split ranges: \u00C0-\u00D6, \u00D8-\u00F6, \u00F8-\u02FF
|
|
56
|
+
// 1.1 merges them into: \u00C0-\u02FF
|
|
57
|
+
// (\u00D7 x and \u00F7 / are division symbols, excluded in both versions)
|
|
58
|
+
//
|
|
59
|
+
// 1.0 tops out at \uFFFD (BMP only)
|
|
60
|
+
// 1.1 adds \u{10000}-\u{EFFFF} (supplementary planes)
|
|
61
|
+
// These require the /u flag on the RegExp — see buildRegexes below.
|
|
62
|
+
//
|
|
63
|
+
// NameChar:
|
|
64
|
+
// 1.1 adds \u0487 (Combining Cyrillic Millions Sign, added in Unicode 4.0)
|
|
65
|
+
// ---------------------------------------------------------------------------
|
|
66
|
+
|
|
67
|
+
const nameStartChar11 =
|
|
68
|
+
':A-Za-z_' +
|
|
69
|
+
'\u00C0-\u02FF' + // merged — 1.0 had three split ranges here
|
|
70
|
+
'\u0370-\u037D' +
|
|
71
|
+
'\u037F-\u0486\u0488-\u1FFF' + // split to exclude \u0487 (combining mark, never a NameStartChar)
|
|
72
|
+
'\u200C-\u200D' +
|
|
73
|
+
'\u2070-\u218F' +
|
|
74
|
+
'\u2C00-\u2FEF' +
|
|
75
|
+
'\u3001-\uD7FF' +
|
|
76
|
+
'\uF900-\uFDCF' +
|
|
77
|
+
'\uFDF0-\uFFFD' +
|
|
78
|
+
'\u{10000}-\u{EFFFF}'; // supplementary planes — REQUIRES /u flag on RegExp
|
|
79
|
+
|
|
80
|
+
const nameChar11 =
|
|
81
|
+
nameStartChar11 +
|
|
82
|
+
'\\-\\.\\d' +
|
|
83
|
+
'\u00B7' +
|
|
84
|
+
'\u0300-\u036F' +
|
|
85
|
+
'\u0487' + // Combining Cyrillic Millions Sign — valid in 1.1, not 1.0
|
|
86
|
+
'\u203F-\u2040';
|
|
87
|
+
|
|
88
|
+
// ---------------------------------------------------------------------------
|
|
89
|
+
// Regex builders
|
|
90
|
+
//
|
|
91
|
+
// XML 1.0 regexes: no flags — BMP only, standard JS regex behaviour.
|
|
92
|
+
// XML 1.1 regexes: /u flag — required for \u{10000}-\u{EFFFF} to match actual
|
|
93
|
+
// supplementary code points rather than lone surrogates (which are illegal XML).
|
|
94
|
+
// ---------------------------------------------------------------------------
|
|
95
|
+
|
|
96
|
+
const buildRegexes = (startChar, char, flags = '') => {
|
|
97
|
+
const ncStart = startChar.replace(':', '');
|
|
98
|
+
const ncChar = char.replace(':', '');
|
|
99
|
+
const ncNamePat = `[${ncStart}][${ncChar}]*`;
|
|
100
|
+
|
|
101
|
+
return {
|
|
102
|
+
name: new RegExp(`^[${startChar}][${char}]*$`, flags),
|
|
103
|
+
ncName: new RegExp(`^${ncNamePat}$`, flags),
|
|
104
|
+
qName: new RegExp(`^${ncNamePat}(?::${ncNamePat})?$`, flags),
|
|
105
|
+
nmToken: new RegExp(`^[${char}]+$`, flags),
|
|
106
|
+
nmTokens: new RegExp(`^[${char}]+(?:\\s+[${char}]+)*$`, flags),
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
const regexes10 = buildRegexes(nameStartChar10, nameChar10); // no /u — BMP only
|
|
111
|
+
const regexes11 = buildRegexes(nameStartChar11, nameChar11, 'u'); // /u — enables \u{10000}-\u{EFFFF}
|
|
112
|
+
|
|
113
|
+
// ---------------------------------------------------------------------------
|
|
114
|
+
// ASCII-only fast path (opt-in, off by default)
|
|
115
|
+
//
|
|
116
|
+
// The XML 1.0 vs 1.1 NameStartChar/NameChar productions differ *only* in
|
|
117
|
+
// their non-ASCII ranges (merged vs split Latin-1 ranges, \u0487, and
|
|
118
|
+
// supplementary planes). Restricted to ASCII, both versions collapse to the
|
|
119
|
+
// same character classes, so a single regex pair covers both xmlVersion
|
|
120
|
+
// values — no /u flag needed.
|
|
121
|
+
//
|
|
122
|
+
// Rationale: unicode-aware regexes (the /u flag, required for XML 1.1's
|
|
123
|
+
// supplementary-plane range) are measurably slower in V8 than plain
|
|
124
|
+
// non-unicode regexes on the same input, even when the input is pure ASCII.
|
|
125
|
+
// For the common case — HTML/SVG ids, XML tags — names are ASCII, so callers
|
|
126
|
+
// who know this can opt in to skip the unicode-aware matching path entirely.
|
|
127
|
+
// This is a real but *conditional* win: mainly for XML 1.1 input (avoids /u),
|
|
128
|
+
// or at scale where the larger unicode character classes add engine
|
|
129
|
+
// overhead. It also changes behaviour (rejects legitimate non-ASCII XML
|
|
130
|
+
// 1.0/1.1 names), so it must never be silently enabled — hence off by
|
|
131
|
+
// default.
|
|
132
|
+
// ---------------------------------------------------------------------------
|
|
133
|
+
|
|
134
|
+
const nameStartCharAscii = ':A-Za-z_';
|
|
135
|
+
const nameCharAscii = nameStartCharAscii + '\\-\\.\\d';
|
|
136
|
+
|
|
137
|
+
const regexesAscii = buildRegexes(nameStartCharAscii, nameCharAscii); // no /u — ASCII only
|
|
138
|
+
|
|
139
|
+
const getRegexes = (xmlVersion = '1.0', asciiOnly = false) => {
|
|
140
|
+
if (asciiOnly) return regexesAscii;
|
|
141
|
+
return xmlVersion === '1.1' ? regexes11 : regexes10;
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
// ---------------------------------------------------------------------------
|
|
145
|
+
// Boolean validators
|
|
146
|
+
// ---------------------------------------------------------------------------
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Returns true if the string is a valid XML Name.
|
|
150
|
+
* Colons are allowed anywhere (Name production).
|
|
151
|
+
* Used for: DOCTYPE entity names, notation names, DTD element declarations.
|
|
152
|
+
*
|
|
153
|
+
* @param {{ xmlVersion?: '1.0'|'1.1', asciiOnly?: boolean }} [opts]
|
|
154
|
+
* asciiOnly: skip unicode-aware matching, ASCII names only (default false).
|
|
155
|
+
*/
|
|
156
|
+
export const name = (str, { xmlVersion = '1.0', asciiOnly = false } = {}) =>
|
|
157
|
+
getRegexes(xmlVersion, asciiOnly).name.test(str);
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Returns true if the string is a valid NCName (Non-Colonized Name).
|
|
161
|
+
* Colons are not permitted.
|
|
162
|
+
* Used for: namespace prefixes, local names, SVG id attributes.
|
|
163
|
+
*
|
|
164
|
+
* @param {{ xmlVersion?: '1.0'|'1.1', asciiOnly?: boolean }} [opts]
|
|
165
|
+
* asciiOnly: skip unicode-aware matching, ASCII names only (default false).
|
|
166
|
+
*/
|
|
167
|
+
export const ncName = (str, { xmlVersion = '1.0', asciiOnly = false } = {}) =>
|
|
168
|
+
getRegexes(xmlVersion, asciiOnly).ncName.test(str);
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Returns true if the string is a valid QName (Qualified Name).
|
|
172
|
+
* Allows exactly one colon as a prefix separator: prefix:localName.
|
|
173
|
+
* Used for: element and attribute names in namespace-aware XML/SVG.
|
|
174
|
+
*
|
|
175
|
+
* @param {{ xmlVersion?: '1.0'|'1.1', asciiOnly?: boolean }} [opts]
|
|
176
|
+
* asciiOnly: skip unicode-aware matching, ASCII names only (default false).
|
|
177
|
+
*/
|
|
178
|
+
export const qName = (str, { xmlVersion = '1.0', asciiOnly = false } = {}) =>
|
|
179
|
+
getRegexes(xmlVersion, asciiOnly).qName.test(str);
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Returns true if the string is a valid NMToken.
|
|
183
|
+
* Like Name but no restriction on the first character.
|
|
184
|
+
* Used for: DTD NMTOKEN attribute values.
|
|
185
|
+
*
|
|
186
|
+
* @param {{ xmlVersion?: '1.0'|'1.1', asciiOnly?: boolean }} [opts]
|
|
187
|
+
* asciiOnly: skip unicode-aware matching, ASCII names only (default false).
|
|
188
|
+
*/
|
|
189
|
+
export const nmToken = (str, { xmlVersion = '1.0', asciiOnly = false } = {}) =>
|
|
190
|
+
getRegexes(xmlVersion, asciiOnly).nmToken.test(str);
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Returns true if the string is a valid NMTokens value.
|
|
194
|
+
* A whitespace-separated list of NMToken values.
|
|
195
|
+
* Used for: DTD NMTOKENS attribute values.
|
|
196
|
+
*
|
|
197
|
+
* @param {{ xmlVersion?: '1.0'|'1.1', asciiOnly?: boolean }} [opts]
|
|
198
|
+
* asciiOnly: skip unicode-aware matching, ASCII names only (default false).
|
|
199
|
+
*/
|
|
200
|
+
export const nmTokens = (str, { xmlVersion = '1.0', asciiOnly = false } = {}) =>
|
|
201
|
+
getRegexes(xmlVersion, asciiOnly).nmTokens.test(str);
|
|
202
|
+
|
|
203
|
+
// ---------------------------------------------------------------------------
|
|
204
|
+
// Memoized validator factory
|
|
205
|
+
//
|
|
206
|
+
// Real documents reuse a small vocabulary of tag/attribute names across many
|
|
207
|
+
// siblings (e.g. `id`, `class`, `href` repeated across hundreds of elements).
|
|
208
|
+
// The plain boolean validators above re-run the regex on every call
|
|
209
|
+
// regardless of repeats. `createValidator` returns a closure with a private
|
|
210
|
+
// string -> boolean cache, so repeated names after the first become O(1)
|
|
211
|
+
// lookups instead of regex tests.
|
|
212
|
+
//
|
|
213
|
+
// - opts (xmlVersion, asciiOnly) are fixed at creation time, so the regex is
|
|
214
|
+
// resolved once, not on every call.
|
|
215
|
+
// - The cache is private to the returned closure — no shared/global state,
|
|
216
|
+
// no cross-caller pollution.
|
|
217
|
+
// - `maxCacheSize` bounds memory: once the cache reaches this many entries,
|
|
218
|
+
// it stops accepting new ones (existing entries keep serving hits; new
|
|
219
|
+
// misses just fall through to the regex, uncached). This avoids unbounded
|
|
220
|
+
// growth against adversarial/high-cardinality input (e.g. validating
|
|
221
|
+
// attacker-supplied names with no repeats) without the cost/complexity of
|
|
222
|
+
// a full LRU, and without the perf cliff of reset-and-refill thrashing.
|
|
223
|
+
// - Call `.reset()` on the returned function to clear the cache manually
|
|
224
|
+
// (e.g. between unrelated parse calls).
|
|
225
|
+
// ---------------------------------------------------------------------------
|
|
226
|
+
|
|
227
|
+
const PRODUCTIONS = ['name', 'ncName', 'qName', 'nmToken', 'nmTokens'];
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Returns a memoized boolean validator function for a single production,
|
|
231
|
+
* with opts fixed at creation time.
|
|
232
|
+
*
|
|
233
|
+
* @param {'name'|'ncName'|'qName'|'nmToken'|'nmTokens'} production
|
|
234
|
+
* @param {{ xmlVersion?: '1.0'|'1.1', asciiOnly?: boolean, maxCacheSize?: number }} [opts]
|
|
235
|
+
* maxCacheSize: max number of distinct strings to cache (default 2048).
|
|
236
|
+
* Once reached, new strings are validated but not cached; existing cached
|
|
237
|
+
* entries keep being served.
|
|
238
|
+
* @returns {((str: string) => boolean) & { reset: () => void }}
|
|
239
|
+
*/
|
|
240
|
+
export const createValidator = (production, { xmlVersion = '1.0', asciiOnly = false, maxCacheSize = 2048 } = {}) => {
|
|
241
|
+
if (!PRODUCTIONS.includes(production)) {
|
|
242
|
+
throw new TypeError(
|
|
243
|
+
`Unknown production "${production}". Must be one of: ${PRODUCTIONS.join(', ')}`
|
|
244
|
+
);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
const regex = getRegexes(xmlVersion, asciiOnly)[production];
|
|
248
|
+
let cache = new Map();
|
|
249
|
+
|
|
250
|
+
const validator = (str) => {
|
|
251
|
+
const cached = cache.get(str);
|
|
252
|
+
if (cached !== undefined) return cached;
|
|
253
|
+
|
|
254
|
+
const result = regex.test(str);
|
|
255
|
+
if (cache.size < maxCacheSize) cache.set(str, result);
|
|
256
|
+
return result;
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
validator.reset = () => { cache = new Map(); };
|
|
260
|
+
|
|
261
|
+
return validator;
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
// ---------------------------------------------------------------------------
|
|
265
|
+
// Diagnostic validator
|
|
266
|
+
// ---------------------------------------------------------------------------
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Validates a string against a named production and returns a detailed result.
|
|
270
|
+
*
|
|
271
|
+
* @param {string} str
|
|
272
|
+
* @param {'name'|'ncName'|'qName'|'nmToken'|'nmTokens'} production
|
|
273
|
+
* @param {{ xmlVersion?: '1.0'|'1.1', asciiOnly?: boolean }} [opts]
|
|
274
|
+
* @returns {{ valid: boolean, production: string, input: string, reason?: string, position?: number }}
|
|
275
|
+
*/
|
|
276
|
+
export const validate = (str, production, { xmlVersion = '1.0', asciiOnly = false } = {}) => {
|
|
277
|
+
if (!PRODUCTIONS.includes(production)) {
|
|
278
|
+
throw new TypeError(
|
|
279
|
+
`Unknown production "${production}". Must be one of: ${PRODUCTIONS.join(', ')}`
|
|
280
|
+
);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
const validators = { name, ncName, qName, nmToken, nmTokens };
|
|
284
|
+
const isValid = validators[production](str, { xmlVersion, asciiOnly });
|
|
285
|
+
|
|
286
|
+
if (isValid) return { valid: true, production, input: str };
|
|
287
|
+
|
|
288
|
+
let reason = 'Does not match the production rules';
|
|
289
|
+
let position;
|
|
290
|
+
|
|
291
|
+
// Diagnostic fallback char checks must mirror the same character set the
|
|
292
|
+
// boolean validator above used, or the reported reason/position could
|
|
293
|
+
// contradict the `valid: false` result (e.g. flagging a char as illegal
|
|
294
|
+
// that the unicode-aware check would have accepted).
|
|
295
|
+
const startCharPattern = asciiOnly ? /^[:A-Za-z_]/ : /^[:A-Za-z_\u00C0-\uFFFD]/;
|
|
296
|
+
const namePattern = asciiOnly ? /[\w\-\\.:]/ : /[\w\-\\.:\u00B7\u00C0-\uFFFD]/;
|
|
297
|
+
|
|
298
|
+
if (str.length === 0) {
|
|
299
|
+
reason = 'Input is empty';
|
|
300
|
+
} else if (production === 'ncName' && str.includes(':')) {
|
|
301
|
+
position = str.indexOf(':');
|
|
302
|
+
reason = 'Colon is not allowed in NCName';
|
|
303
|
+
} else if (production === 'qName' && str.startsWith(':')) {
|
|
304
|
+
reason = 'QName cannot start with a colon';
|
|
305
|
+
position = 0;
|
|
306
|
+
} else if (production === 'qName' && str.endsWith(':')) {
|
|
307
|
+
reason = 'QName cannot end with a colon';
|
|
308
|
+
position = str.length - 1;
|
|
309
|
+
} else if (production === 'qName' && (str.match(/:/g) || []).length > 1) {
|
|
310
|
+
reason = 'QName can have at most one colon';
|
|
311
|
+
position = str.lastIndexOf(':');
|
|
312
|
+
} else if (
|
|
313
|
+
['name', 'ncName', 'qName'].includes(production) &&
|
|
314
|
+
!startCharPattern.test(str[0])
|
|
315
|
+
) {
|
|
316
|
+
reason = `First character "${str[0]}" is not a valid NameStartChar`;
|
|
317
|
+
position = 0;
|
|
318
|
+
} else {
|
|
319
|
+
for (let i = 0; i < str.length; i++) {
|
|
320
|
+
if (!namePattern.test(str[i])) {
|
|
321
|
+
reason = `Character "${str[i]}" at position ${i} is not a valid NameChar`;
|
|
322
|
+
position = i;
|
|
323
|
+
break;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
return { valid: false, production, input: str, reason, position };
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
// ---------------------------------------------------------------------------
|
|
332
|
+
// Batch validator
|
|
333
|
+
// ---------------------------------------------------------------------------
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* Validates an array of strings against a named production.
|
|
337
|
+
*
|
|
338
|
+
* @param {string[]} strings
|
|
339
|
+
* @param {'name'|'ncName'|'qName'|'nmToken'|'nmTokens'} production
|
|
340
|
+
* @param {{ xmlVersion?: '1.0'|'1.1', asciiOnly?: boolean }} [opts]
|
|
341
|
+
* @returns {Array<{ valid: boolean, production: string, input: string, reason?: string, position?: number }>}
|
|
342
|
+
*/
|
|
343
|
+
export const validateAll = (strings, production, opts = {}) =>
|
|
344
|
+
strings.map(str => validate(str, production, opts));
|
|
345
|
+
|
|
346
|
+
// ---------------------------------------------------------------------------
|
|
347
|
+
// Sanitizer
|
|
348
|
+
// ---------------------------------------------------------------------------
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* Transforms an invalid string into the nearest valid XML name for the given production.
|
|
352
|
+
*
|
|
353
|
+
* @param {string} str
|
|
354
|
+
* @param {'name'|'ncName'|'qName'|'nmToken'|'nmTokens'} production
|
|
355
|
+
* @param {{ replacement?: string, asciiOnly?: boolean }} [opts]
|
|
356
|
+
* asciiOnly: also replace any non-ASCII character, not just XML-illegal
|
|
357
|
+
* ones (default false).
|
|
358
|
+
* @returns {string}
|
|
359
|
+
*/
|
|
360
|
+
export const sanitize = (str, production = 'name', { replacement = '_', asciiOnly = false } = {}) => {
|
|
361
|
+
if (!str) return replacement;
|
|
362
|
+
|
|
363
|
+
let result = str;
|
|
364
|
+
|
|
365
|
+
// Strip colons for NCName
|
|
366
|
+
if (production === 'ncName') {
|
|
367
|
+
result = result.replace(/:/g, '');
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
// Replace illegal characters
|
|
371
|
+
const allowedCharPattern = asciiOnly ? /[^\w\-\.:]/g : /[^\w\-\.:\u00B7\u00C0-\uFFFD]/g;
|
|
372
|
+
result = result.replace(allowedCharPattern, replacement);
|
|
373
|
+
|
|
374
|
+
// Fix invalid start character for Name / NCName / QName
|
|
375
|
+
if (production !== 'nmToken' && production !== 'nmTokens') {
|
|
376
|
+
if (/^[\-\.\d]/.test(result)) {
|
|
377
|
+
result = replacement + result;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
return result || replacement;
|
|
382
|
+
};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "fast-xml-parser",
|
|
3
|
+
"version": "5.12.0",
|
|
4
|
+
"description": "Validate XML, Parse XML, Build XML without C/C++ based libraries",
|
|
5
|
+
"main": "./lib/fxp.cjs",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"module": "./src/fxp.js",
|
|
9
|
+
"types": "./src/fxp.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"import": {
|
|
13
|
+
"types": "./src/fxp.d.ts",
|
|
14
|
+
"default": "./src/fxp.js"
|
|
15
|
+
},
|
|
16
|
+
"require": {
|
|
17
|
+
"types": "./lib/fxp.d.cts",
|
|
18
|
+
"default": "./lib/fxp.cjs"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"test": "c8 --reporter=lcov --reporter=text jasmine spec/*spec.js",
|
|
24
|
+
"test-types": "tsc --noEmit spec/typings/typings-test.ts",
|
|
25
|
+
"unit": "jasmine",
|
|
26
|
+
"perf": "node ./benchmark/perfTest3.js",
|
|
27
|
+
"lint": "eslint src/**/*.js spec/**/*.js benchmark/**/*.js",
|
|
28
|
+
"bundle": "webpack --config webpack.cjs.config.js",
|
|
29
|
+
"prettier": "prettier --write src/**/*.js",
|
|
30
|
+
"preversion": "npm test"
|
|
31
|
+
},
|
|
32
|
+
"bin": {
|
|
33
|
+
"fxparser": "src/cli/cli.js"
|
|
34
|
+
},
|
|
35
|
+
"files": [
|
|
36
|
+
"lib",
|
|
37
|
+
"src",
|
|
38
|
+
"CHANGELOG.md"
|
|
39
|
+
],
|
|
40
|
+
"repository": {
|
|
41
|
+
"type": "git",
|
|
42
|
+
"url": "git+https://github.com/NaturalIntelligence/fast-xml-parser.git"
|
|
43
|
+
},
|
|
44
|
+
"keywords": [
|
|
45
|
+
"fast",
|
|
46
|
+
"xml",
|
|
47
|
+
"json",
|
|
48
|
+
"parser",
|
|
49
|
+
"xml2js",
|
|
50
|
+
"x2js",
|
|
51
|
+
"xml2json",
|
|
52
|
+
"js",
|
|
53
|
+
"validator",
|
|
54
|
+
"validate",
|
|
55
|
+
"transformer",
|
|
56
|
+
"assert",
|
|
57
|
+
"js2xml",
|
|
58
|
+
"json2xml",
|
|
59
|
+
"html"
|
|
60
|
+
],
|
|
61
|
+
"author": "Amit Gupta (https://solothought.com)",
|
|
62
|
+
"license": "MIT",
|
|
63
|
+
"devDependencies": {
|
|
64
|
+
"@babel/core": "^7.13.10",
|
|
65
|
+
"@babel/plugin-transform-runtime": "^7.13.10",
|
|
66
|
+
"@babel/preset-env": "^7.13.10",
|
|
67
|
+
"@babel/register": "^7.13.8",
|
|
68
|
+
"@byspec/xml": "^0.1.0",
|
|
69
|
+
"@types/node": "20",
|
|
70
|
+
"babel-loader": "^8.2.2",
|
|
71
|
+
"c8": "^10.1.3",
|
|
72
|
+
"eslint": "^8.3.0",
|
|
73
|
+
"jasmine": "^7.0.0",
|
|
74
|
+
"prettier": "^3.5.1",
|
|
75
|
+
"typescript": "5",
|
|
76
|
+
"webpack": "^5.64.4",
|
|
77
|
+
"webpack-cli": "^4.9.1"
|
|
78
|
+
},
|
|
79
|
+
"funding": [
|
|
80
|
+
{
|
|
81
|
+
"type": "github",
|
|
82
|
+
"url": "https://github.com/sponsors/NaturalIntelligence"
|
|
83
|
+
}
|
|
84
|
+
],
|
|
85
|
+
"dependencies": {
|
|
86
|
+
"@nodable/entities": "^3.1.0",
|
|
87
|
+
"fast-xml-builder": "^1.3.1",
|
|
88
|
+
"is-unsafe": "^2.0.3",
|
|
89
|
+
"path-expression-matcher": "^1.6.2",
|
|
90
|
+
"strnum": "^2.5.1",
|
|
91
|
+
"xml-naming": "^0.3.0"
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
/*eslint-disable no-console*/
|
|
4
|
+
import fs from 'fs';
|
|
5
|
+
import { resolve } from 'path';
|
|
6
|
+
import {XMLParser, XMLValidator} from "../fxp.js";
|
|
7
|
+
import ReadToEnd from './read.js';
|
|
8
|
+
import cmdDetail from "./man.js"
|
|
9
|
+
|
|
10
|
+
console.warn("\x1b[33m%s\x1b[0m", "⚠️ Warning: The built-in CLI interface is now deprecated.");
|
|
11
|
+
console.warn("Please install the dedicated CLI package instead:");
|
|
12
|
+
console.warn(" npm install -g fxp-cli");
|
|
13
|
+
|
|
14
|
+
if (process.argv[2] === '--help' || process.argv[2] === '-h') {
|
|
15
|
+
console.log(cmdDetail);
|
|
16
|
+
} else if (process.argv[2] === '--version') {
|
|
17
|
+
const packageJsonPath = resolve(process.cwd(), 'package.json');
|
|
18
|
+
const version = JSON.parse(fs.readFileSync(packageJsonPath).toString()).version;
|
|
19
|
+
console.log(version);
|
|
20
|
+
} else {
|
|
21
|
+
const options = {
|
|
22
|
+
removeNSPrefix: true,
|
|
23
|
+
ignoreAttributes: false,
|
|
24
|
+
parseTagValue: true,
|
|
25
|
+
parseAttributeValue: true,
|
|
26
|
+
};
|
|
27
|
+
let fileName = '';
|
|
28
|
+
let outputFileName;
|
|
29
|
+
let validate = false;
|
|
30
|
+
let validateOnly = false;
|
|
31
|
+
for (let i = 2; i < process.argv.length; i++) {
|
|
32
|
+
if (process.argv[i] === '-ns') {
|
|
33
|
+
options.removeNSPrefix = false;
|
|
34
|
+
} else if (process.argv[i] === '-a') {
|
|
35
|
+
options.ignoreAttributes = true;
|
|
36
|
+
} else if (process.argv[i] === '-c') {
|
|
37
|
+
options.parseTagValue = false;
|
|
38
|
+
options.parseAttributeValue = false;
|
|
39
|
+
} else if (process.argv[i] === '-o') {
|
|
40
|
+
outputFileName = process.argv[++i];
|
|
41
|
+
} else if (process.argv[i] === '-v') {
|
|
42
|
+
validate = true;
|
|
43
|
+
} else if (process.argv[i] === '-V') {
|
|
44
|
+
validateOnly = true;
|
|
45
|
+
} else {
|
|
46
|
+
//filename
|
|
47
|
+
fileName = process.argv[i];
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const callback = function(xmlData) {
|
|
52
|
+
let output = '';
|
|
53
|
+
if (validateOnly) {
|
|
54
|
+
output = XMLValidator.validate(xmlData);
|
|
55
|
+
process.exitCode = output === true ? 0 : 1;
|
|
56
|
+
} else {
|
|
57
|
+
const parser = new XMLParser(options);
|
|
58
|
+
output = JSON.stringify(parser.parse(xmlData,validate), null, 4);
|
|
59
|
+
}
|
|
60
|
+
if (outputFileName) {
|
|
61
|
+
writeToFile(outputFileName, output);
|
|
62
|
+
} else {
|
|
63
|
+
console.log(output);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
try {
|
|
69
|
+
|
|
70
|
+
if (!fileName) {
|
|
71
|
+
ReadToEnd.readToEnd(process.stdin, function(err, data) {
|
|
72
|
+
if (err) {
|
|
73
|
+
throw err;
|
|
74
|
+
}
|
|
75
|
+
callback(data.toString());
|
|
76
|
+
});
|
|
77
|
+
} else {
|
|
78
|
+
fs.readFile(fileName, function(err, data) {
|
|
79
|
+
if (err) {
|
|
80
|
+
throw err;
|
|
81
|
+
}
|
|
82
|
+
callback(data.toString());
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
} catch (e) {
|
|
86
|
+
console.log('Seems an invalid file or stream.' + e);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function writeToFile(fileName, data) {
|
|
91
|
+
fs.writeFile(fileName, data, function(err) {
|
|
92
|
+
if (err) {
|
|
93
|
+
throw err;
|
|
94
|
+
}
|
|
95
|
+
console.log('JSON output has been written to ' + fileName);
|
|
96
|
+
});
|
|
97
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import { resolve } from 'path';
|
|
3
|
+
const packageJsonPath = resolve(process.cwd(), 'package.json');
|
|
4
|
+
const version = JSON.parse(fs.readFileSync(packageJsonPath).toString()).version;
|
|
5
|
+
|
|
6
|
+
export default `Fast XML Parser ${version}
|
|
7
|
+
----------------
|
|
8
|
+
$ fxparser [-ns|-a|-c|-v|-V] <filename> [-o outputfile.json]
|
|
9
|
+
$ cat xmlfile.xml | fxparser [-ns|-a|-c|-v|-V] [-o outputfile.json]
|
|
10
|
+
|
|
11
|
+
Options
|
|
12
|
+
----------------
|
|
13
|
+
-ns: remove namespace from tag and atrribute name.
|
|
14
|
+
-a: don't parse attributes.
|
|
15
|
+
-c: parse values to premitive type.
|
|
16
|
+
-v: validate before parsing.
|
|
17
|
+
-V: validate only.`
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
import { Transform } from 'stream';
|
|
4
|
+
|
|
5
|
+
export default class ReadToEnd extends Transform {
|
|
6
|
+
constructor(options = {}) {
|
|
7
|
+
super(options);
|
|
8
|
+
this._encoding = options.encoding || 'utf8';
|
|
9
|
+
this._buffer = '';
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
_transform(chunk, encoding, done) {
|
|
13
|
+
this._buffer += chunk.toString(this._encoding);
|
|
14
|
+
this.push(chunk);
|
|
15
|
+
done();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
_flush(done) {
|
|
19
|
+
this.emit('complete', null, this._buffer);
|
|
20
|
+
done();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
static readToEnd(stream, options, callback) {
|
|
24
|
+
if (typeof options === 'function') {
|
|
25
|
+
callback = options;
|
|
26
|
+
options = {};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const dest = new ReadToEnd(options);
|
|
30
|
+
|
|
31
|
+
stream.pipe(dest);
|
|
32
|
+
|
|
33
|
+
stream.on('error', (err) => {
|
|
34
|
+
stream.unpipe(dest);
|
|
35
|
+
callback(err);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
dest.on('complete', callback);
|
|
39
|
+
dest.resume();
|
|
40
|
+
|
|
41
|
+
return dest;
|
|
42
|
+
}
|
|
43
|
+
}
|