@mrclrchtr/supi-code-intelligence 12.0.0 → 14.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +35 -0
- package/README.md +7 -5
- package/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-code-runtime/src/query-result.ts +10 -0
- 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 +78 -13
- package/node_modules/@mrclrchtr/supi-core/src/footer-registry.ts +41 -9
- package/node_modules/@mrclrchtr/supi-core/src/retired-packages.ts +152 -0
- package/node_modules/@mrclrchtr/supi-core/src/session.ts +3 -0
- package/node_modules/@mrclrchtr/supi-core/src/shell-hints.ts +46 -0
- package/node_modules/@mrclrchtr/supi-core/src/side-run.ts +46 -0
- package/node_modules/@mrclrchtr/supi-core/src/spill.ts +93 -0
- package/node_modules/@mrclrchtr/supi-lsp/README.md +6 -2
- 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-code-runtime/src/query-result.ts +10 -0
- 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 +78 -13
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/footer-registry.ts +41 -9
- 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 +3 -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/side-run.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 +20 -1
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-request.ts +4 -1
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-timing.ts +14 -1
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-typescript.ts +8 -1
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostics.ts +50 -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-input-admission.ts +7 -1
- 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 +12 -3
- package/node_modules/@mrclrchtr/supi-lsp/src/client/transport.ts +24 -8
- package/node_modules/@mrclrchtr/supi-lsp/src/config/server-config.ts +5 -0
- 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 +17 -5
- package/node_modules/@mrclrchtr/supi-lsp/src/config/typescript-module.ts +17 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/debug-telemetry.ts +64 -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-project-info.ts +3 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-removal-ledger.ts +52 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-typescript-coverage.ts +27 -2
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-workspace-symbol.ts +16 -112
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager.ts +561 -103
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/typescript-file-local.ts +6 -1
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/workspace-symbol-collection.ts +163 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/workspace-symbol-row-limit.ts +72 -0
- 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-controller.ts +11 -0
- 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 +53 -9
- 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-code-runtime/src/query-result.ts +10 -0
- 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 +78 -13
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/footer-registry.ts +41 -9
- 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 +3 -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/side-run.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 +0 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/sql/tree-sitter-sql.wasm.json +3 -3
- 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/health/server-status.ts +32 -9
- package/src/analysis/health/signals.ts +1 -0
- package/src/analysis/instruction-files.ts +11 -7
- package/src/analysis/search/exclusions.ts +18 -4
- package/src/analysis/search/pattern.ts +3 -3
- package/src/analysis/target/anchored.ts +3 -6
- package/src/analysis/target/file-outline-omissions.ts +17 -2
- package/src/analysis/target/symbol-selection.ts +100 -0
- package/src/analysis/target/symbol.ts +83 -49
- package/src/analysis/target/types.ts +12 -10
- 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/app/app.ts +37 -21
- package/src/diagnostics/coverage.ts +49 -0
- package/src/diagnostics/evidence.ts +10 -2
- package/src/extension.ts +1 -2
- package/src/headless.ts +4 -2
- package/src/session/health-types.ts +2 -0
- 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-types.ts +5 -0
- package/src/session/orientation-workflow.ts +12 -17
- package/src/session/target-workflow.ts +38 -25
- package/src/tool/code_find/render.ts +10 -11
- package/src/tool/code_find/result.ts +11 -8
- 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/structured.ts +3 -0
- 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 +63 -9
- package/src/tool/code_health/result.ts +20 -9
- package/src/tool/code_health/structured-schema.ts +15 -0
- package/src/tool/code_health/structured.ts +9 -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/markdown.ts +6 -1
- 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 +45 -73
- package/src/tool/code_resolve/structured.ts +6 -1
- package/src/tool/infra/truncate.ts +2 -16
- package/src/tool/result/candidate-selection.ts +157 -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 +147 -44
- package/src/ui/status-overlay.ts +13 -8
- 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,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
import { validate } from './validator.js';
|
|
4
|
+
import XMLParser from './xmlparser/XMLParser.js';
|
|
5
|
+
import XMLBuilder from './xmlbuilder/json2xml.js';
|
|
6
|
+
|
|
7
|
+
const XMLValidator = {
|
|
8
|
+
validate: validate
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
XMLParser,
|
|
12
|
+
XMLValidator,
|
|
13
|
+
XMLBuilder
|
|
14
|
+
};
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const nameStartChar = ':A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD';
|
|
4
|
+
const nameChar = nameStartChar + '\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040';
|
|
5
|
+
export const nameRegexp = '[' + nameStartChar + '][' + nameChar + ']*';
|
|
6
|
+
const regexName = new RegExp('^' + nameRegexp + '$');
|
|
7
|
+
|
|
8
|
+
export function getAllMatches(string, regex) {
|
|
9
|
+
const matches = [];
|
|
10
|
+
let match = regex.exec(string);
|
|
11
|
+
while (match) {
|
|
12
|
+
const allmatches = [];
|
|
13
|
+
allmatches.startIndex = regex.lastIndex - match[0].length;
|
|
14
|
+
const len = match.length;
|
|
15
|
+
for (let index = 0; index < len; index++) {
|
|
16
|
+
allmatches.push(match[index]);
|
|
17
|
+
}
|
|
18
|
+
matches.push(allmatches);
|
|
19
|
+
match = regex.exec(string);
|
|
20
|
+
}
|
|
21
|
+
return matches;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const isName = function (string) {
|
|
25
|
+
const match = regexName.exec(string);
|
|
26
|
+
return !(match === null || typeof match === 'undefined');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function isExist(v) {
|
|
30
|
+
return typeof v !== 'undefined';
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function isEmptyObject(obj) {
|
|
34
|
+
return Object.keys(obj).length === 0;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function getValue(v) {
|
|
38
|
+
if (exports.isExist(v)) {
|
|
39
|
+
return v;
|
|
40
|
+
} else {
|
|
41
|
+
return '';
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Dangerous property names that could lead to prototype pollution or security issues
|
|
47
|
+
*/
|
|
48
|
+
export const DANGEROUS_PROPERTY_NAMES = [
|
|
49
|
+
// '__proto__',
|
|
50
|
+
// 'constructor',
|
|
51
|
+
// 'prototype',
|
|
52
|
+
'hasOwnProperty',
|
|
53
|
+
'toString',
|
|
54
|
+
'valueOf',
|
|
55
|
+
'__defineGetter__',
|
|
56
|
+
'__defineSetter__',
|
|
57
|
+
'__lookupGetter__',
|
|
58
|
+
'__lookupSetter__'
|
|
59
|
+
];
|
|
60
|
+
|
|
61
|
+
export const criticalProperties = ["__proto__", "constructor", "prototype"];
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
"<" : "<", //tag start
|
|
3
|
+
">" : ">", //tag end
|
|
4
|
+
"/" : "/", //close tag
|
|
5
|
+
"!" : "!", //comment or docttype
|
|
6
|
+
"!--" : "!--", //comment
|
|
7
|
+
"-->" : "-->", //comment end
|
|
8
|
+
"?" : "?", //pi
|
|
9
|
+
"?>" : "?>", //pi end
|
|
10
|
+
"?xml" : "?xml", //pi end
|
|
11
|
+
"![" : "![", //cdata
|
|
12
|
+
"]]>" : "]]>", //cdata end
|
|
13
|
+
"[" : "[",
|
|
14
|
+
"-" : "-",
|
|
15
|
+
"D" : "D",
|
|
16
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
const ampEntity = { regex: /&(amp|#38|#x26);/g, val: "&" };
|
|
2
|
+
const htmlEntities = {
|
|
3
|
+
"space": { regex: /&(nbsp|#160);/g, val: " " },
|
|
4
|
+
// "lt" : { regex: /&(lt|#60);/g, val: "<" },
|
|
5
|
+
// "gt" : { regex: /&(gt|#62);/g, val: ">" },
|
|
6
|
+
// "amp" : { regex: /&(amp|#38);/g, val: "&" },
|
|
7
|
+
// "quot" : { regex: /&(quot|#34);/g, val: "\"" },
|
|
8
|
+
// "apos" : { regex: /&(apos|#39);/g, val: "'" },
|
|
9
|
+
"cent": { regex: /&(cent|#162);/g, val: "¢" },
|
|
10
|
+
"pound": { regex: /&(pound|#163);/g, val: "£" },
|
|
11
|
+
"yen": { regex: /&(yen|#165);/g, val: "¥" },
|
|
12
|
+
"euro": { regex: /&(euro|#8364);/g, val: "€" },
|
|
13
|
+
"copyright": { regex: /&(copy|#169);/g, val: "©" },
|
|
14
|
+
"reg": { regex: /&(reg|#174);/g, val: "®" },
|
|
15
|
+
"inr": { regex: /&(inr|#8377);/g, val: "₹" },
|
|
16
|
+
"num_dec": { regex: /&#([0-9]{1,7});/g, val: (_, str) => String.fromCodePoint(Number.parseInt(str, 10)) },
|
|
17
|
+
"num_hex": { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (_, str) => String.fromCodePoint(Number.parseInt(str, 16)) },
|
|
18
|
+
};
|
|
19
|
+
export default class EntitiesParser {
|
|
20
|
+
constructor(replaceHtmlEntities) {
|
|
21
|
+
this.replaceHtmlEntities = replaceHtmlEntities;
|
|
22
|
+
this.docTypeEntities = {};
|
|
23
|
+
this.lastEntities = {
|
|
24
|
+
"apos": { regex: /&(apos|#39|#x27);/g, val: "'" },
|
|
25
|
+
"gt": { regex: /&(gt|#62|#x3E);/g, val: ">" },
|
|
26
|
+
"lt": { regex: /&(lt|#60|#x3C);/g, val: "<" },
|
|
27
|
+
"quot": { regex: /&(quot|#34|#x22);/g, val: "\"" },
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
addExternalEntities(externalEntities) {
|
|
32
|
+
const entKeys = Object.keys(externalEntities);
|
|
33
|
+
for (let i = 0; i < entKeys.length; i++) {
|
|
34
|
+
const ent = entKeys[i];
|
|
35
|
+
this.addExternalEntity(ent, externalEntities[ent])
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
addExternalEntity(key, val) {
|
|
39
|
+
validateEntityName(key);
|
|
40
|
+
const escaped = key.replace(/[.\-+*:]/g, '\\.');
|
|
41
|
+
if (val.indexOf("&") !== -1) {
|
|
42
|
+
reportWarning(`Entity ${key} is not added as '&' is found in value;`)
|
|
43
|
+
return;
|
|
44
|
+
} else {
|
|
45
|
+
this.lastEntities[key] = {
|
|
46
|
+
regex: new RegExp("&" + escaped + ";", "g"),
|
|
47
|
+
val: val
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
addDocTypeEntities(entities) {
|
|
53
|
+
const entKeys = Object.keys(entities);
|
|
54
|
+
for (let i = 0; i < entKeys.length; i++) {
|
|
55
|
+
const ent = entKeys[i];
|
|
56
|
+
const escaped = ent.replace(/[.\-+*:]/g, '\\.');
|
|
57
|
+
this.docTypeEntities[ent] = {
|
|
58
|
+
regex: new RegExp("&" + escaped + ";", "g"),
|
|
59
|
+
val: entities[ent]
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
parse(val) {
|
|
65
|
+
return this.replaceEntitiesValue(val)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* 1. Replace DOCTYPE entities
|
|
70
|
+
* 2. Replace external entities
|
|
71
|
+
* 3. Replace HTML entities if asked
|
|
72
|
+
* @param {string} val
|
|
73
|
+
*/
|
|
74
|
+
replaceEntitiesValue(val) {
|
|
75
|
+
if (typeof val === "string" && val.length > 0) {
|
|
76
|
+
for (let entityName in this.docTypeEntities) {
|
|
77
|
+
const entity = this.docTypeEntities[entityName];
|
|
78
|
+
val = val.replace(entity.regx, entity.val);
|
|
79
|
+
}
|
|
80
|
+
for (let entityName in this.lastEntities) {
|
|
81
|
+
const entity = this.lastEntities[entityName];
|
|
82
|
+
val = val.replace(entity.regex, entity.val);
|
|
83
|
+
}
|
|
84
|
+
if (this.replaceHtmlEntities) {
|
|
85
|
+
for (let entityName in htmlEntities) {
|
|
86
|
+
const entity = htmlEntities[entityName];
|
|
87
|
+
val = val.replace(entity.regex, entity.val);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
val = val.replace(ampEntity.regex, ampEntity.val);
|
|
91
|
+
}
|
|
92
|
+
return val;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
//an entity name should not contains special characters that may be used in regex
|
|
97
|
+
//Eg !?\\\/[]$%{}^&*()<>
|
|
98
|
+
const specialChar = "!?\\/[]$%{}^&*()<>|+";
|
|
99
|
+
|
|
100
|
+
function validateEntityName(name) {
|
|
101
|
+
for (let i = 0; i < specialChar.length; i++) {
|
|
102
|
+
const ch = specialChar[i];
|
|
103
|
+
if (name.indexOf(ch) !== -1) throw new Error(`Invalid character ${ch} in entity name`);
|
|
104
|
+
}
|
|
105
|
+
return name;
|
|
106
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
|
|
2
|
+
import { JsObjOutputBuilder } from './OutputBuilders/JsObjBuilder.js';
|
|
3
|
+
|
|
4
|
+
export const defaultOptions = {
|
|
5
|
+
preserveOrder: false,
|
|
6
|
+
removeNSPrefix: false, // remove NS from tag name or attribute name if true
|
|
7
|
+
//ignoreRootElement : false,
|
|
8
|
+
stopNodes: [], //nested tags will not be parsed even for errors
|
|
9
|
+
// isArray: () => false, //User will set it
|
|
10
|
+
htmlEntities: false,
|
|
11
|
+
// skipEmptyListItem: false
|
|
12
|
+
tags: {
|
|
13
|
+
unpaired: [],
|
|
14
|
+
nameFor: {
|
|
15
|
+
cdata: false,
|
|
16
|
+
comment: false,
|
|
17
|
+
text: '#text'
|
|
18
|
+
},
|
|
19
|
+
separateTextProperty: false,
|
|
20
|
+
},
|
|
21
|
+
attributes: {
|
|
22
|
+
ignore: false,
|
|
23
|
+
booleanType: true,
|
|
24
|
+
entities: true,
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
// select: ["img[src]"],
|
|
28
|
+
// stop: ["anim", "[ads]"]
|
|
29
|
+
only: [], // rest tags will be skipped. It will result in flat array
|
|
30
|
+
hierarchy: false, //will be used when a particular tag is set to be parsed.
|
|
31
|
+
skip: [], // will be skipped from parse result. on('skip') will be triggered
|
|
32
|
+
|
|
33
|
+
select: [], // on('select', tag => tag ) will be called if match
|
|
34
|
+
stop: [], //given tagPath will not be parsed. innerXML will be set as string value
|
|
35
|
+
OutputBuilder: new JsObjOutputBuilder(),
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export const buildOptions = function (options) {
|
|
39
|
+
const finalOptions = { ...defaultOptions };
|
|
40
|
+
copyProperties(finalOptions, options)
|
|
41
|
+
return finalOptions;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
function copyProperties(target, source) {
|
|
45
|
+
for (let key in source) {
|
|
46
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
47
|
+
if (key === 'OutputBuilder') {
|
|
48
|
+
target[key] = source[key];
|
|
49
|
+
} else if (typeof source[key] === 'object' && !Array.isArray(source[key])) {
|
|
50
|
+
// Recursively copy nested properties
|
|
51
|
+
if (typeof target[key] === 'undefined') {
|
|
52
|
+
target[key] = {};
|
|
53
|
+
}
|
|
54
|
+
copyProperties(target[key], source[key]);
|
|
55
|
+
} else {
|
|
56
|
+
// Copy non-nested properties
|
|
57
|
+
target[key] = source[key];
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
export default class BaseOutputBuilder {
|
|
2
|
+
constructor() {
|
|
3
|
+
// this.attributes = {};
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
addAttribute(name, value) {
|
|
7
|
+
if (this.options.onAttribute) {
|
|
8
|
+
//TODO: better to pass tag path
|
|
9
|
+
const v = this.options.onAttribute(name, value, this.tagName);
|
|
10
|
+
if (v) this.attributes[v.name] = v.value;
|
|
11
|
+
} else {
|
|
12
|
+
name = this.options.attributes.prefix + name + this.options.attributes.suffix;
|
|
13
|
+
this.attributes[name] = this.parseValue(value, this.options.attributes.valueParsers);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* parse value by chain of parsers
|
|
19
|
+
* @param {string} val
|
|
20
|
+
* @returns {any} parsed value if matching parser found
|
|
21
|
+
*/
|
|
22
|
+
parseValue = function (val, valParsers) {
|
|
23
|
+
for (let i = 0; i < valParsers.length; i++) {
|
|
24
|
+
let valParser = valParsers[i];
|
|
25
|
+
if (typeof valParser === "string") {
|
|
26
|
+
valParser = this.registeredParsers[valParser];
|
|
27
|
+
}
|
|
28
|
+
if (valParser) {
|
|
29
|
+
val = valParser.parse(val);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return val;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* To add a nested empty tag.
|
|
37
|
+
* @param {string} key
|
|
38
|
+
* @param {any} val
|
|
39
|
+
*/
|
|
40
|
+
_addChild(key, val) { }
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* skip the comment if property is not set
|
|
44
|
+
*/
|
|
45
|
+
addComment(text) {
|
|
46
|
+
if (this.options.nameFor.comment)
|
|
47
|
+
this._addChild(this.options.nameFor.comment, text);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
//store CDATA separately if property is set
|
|
51
|
+
//otherwise add to tag's value
|
|
52
|
+
addCdata(text) {
|
|
53
|
+
if (this.options.nameFor.cdata) {
|
|
54
|
+
this._addChild(this.options.nameFor.cdata, text);
|
|
55
|
+
} else {
|
|
56
|
+
this.addRawValue(text || "");
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
addRawValue = text => this.addValue(text);
|
|
61
|
+
|
|
62
|
+
addDeclaration() {
|
|
63
|
+
if (!this.options.declaration) {
|
|
64
|
+
} else {
|
|
65
|
+
this.addPi("?xml");
|
|
66
|
+
}
|
|
67
|
+
this.attributes = {}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { buildOptions, registerCommonValueParsers } from './ParserOptionsBuilder.js';
|
|
2
|
+
|
|
3
|
+
export default class OutputBuilder {
|
|
4
|
+
constructor(options) {
|
|
5
|
+
this.options = buildOptions(options);
|
|
6
|
+
this.registeredParsers = registerCommonValueParsers(this.options);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
registerValueParser(name, parserInstance) {//existing name will override the parser without warning
|
|
10
|
+
this.registeredParsers[name] = parserInstance;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
getInstance(parserOptions) {
|
|
14
|
+
return new JsArrBuilder(parserOptions, this.options, this.registeredParsers);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const rootName = '!js_arr';
|
|
19
|
+
import BaseOutputBuilder from './BaseOutputBuilder.js';
|
|
20
|
+
|
|
21
|
+
class JsArrBuilder extends BaseOutputBuilder {
|
|
22
|
+
|
|
23
|
+
constructor(parserOptions, options, registeredParsers) {
|
|
24
|
+
super();
|
|
25
|
+
this.tagsStack = [];
|
|
26
|
+
this.parserOptions = parserOptions;
|
|
27
|
+
this.options = options;
|
|
28
|
+
this.registeredParsers = registeredParsers;
|
|
29
|
+
|
|
30
|
+
this.root = new Node(rootName);
|
|
31
|
+
this.currentNode = this.root;
|
|
32
|
+
this.attributes = {};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
addTag(tag) {
|
|
36
|
+
//when a new tag is added, it should be added as child of current node
|
|
37
|
+
//TODO: shift this check to the parser
|
|
38
|
+
if (tag.name === "__proto__") tag.name = "#__proto__";
|
|
39
|
+
|
|
40
|
+
this.tagsStack.push(this.currentNode);
|
|
41
|
+
this.currentNode = new Node(tag.name, this.attributes);
|
|
42
|
+
this.attributes = {};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Check if the node should be added by checking user's preference
|
|
47
|
+
* @param {Node} node
|
|
48
|
+
* @returns boolean: true if the node should not be added
|
|
49
|
+
*/
|
|
50
|
+
closeTag() {
|
|
51
|
+
const node = this.currentNode;
|
|
52
|
+
this.currentNode = this.tagsStack.pop(); //set parent node in scope
|
|
53
|
+
if (this.options.onClose !== undefined) {
|
|
54
|
+
//TODO TagPathMatcher
|
|
55
|
+
const resultTag = this.options.onClose(node,
|
|
56
|
+
new TagPathMatcher(this.tagsStack, node));
|
|
57
|
+
|
|
58
|
+
if (resultTag) return;
|
|
59
|
+
}
|
|
60
|
+
this.currentNode.child.push(node); //to parent node
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
//Called by parent class methods
|
|
64
|
+
_addChild(key, val) {
|
|
65
|
+
// if(key === "__proto__") tagName = "#__proto__";
|
|
66
|
+
this.currentNode.child.push({ [key]: val });
|
|
67
|
+
// this.currentNode.leafType = false;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Add text value child node
|
|
72
|
+
* @param {string} text
|
|
73
|
+
*/
|
|
74
|
+
addValue(text) {
|
|
75
|
+
this.currentNode.child.push({ [this.options.nameFor.text]: this.parseValue(text, this.options.tags.valueParsers) });
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
addPi(name) {
|
|
79
|
+
//TODO: set pi flag
|
|
80
|
+
if (!this.options.ignorePiTags) {
|
|
81
|
+
const node = new Node(name, this.attributes);
|
|
82
|
+
this.currentNode[":@"] = this.attributes;
|
|
83
|
+
this.currentNode.child.push(node);
|
|
84
|
+
}
|
|
85
|
+
this.attributes = {};
|
|
86
|
+
}
|
|
87
|
+
getOutput() {
|
|
88
|
+
return this.root.child[0];
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
class Node {
|
|
95
|
+
constructor(tagname, attributes) {
|
|
96
|
+
this.tagname = tagname;
|
|
97
|
+
this.child = []; //nested tags, text, cdata, comments
|
|
98
|
+
if (attributes && Object.keys(attributes).length > 0)
|
|
99
|
+
this[":@"] = attributes;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
module.exports = OutputBuilder;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import {buildOptions,registerCommonValueParsers} from"./ParserOptionsBuilder.js";
|
|
2
|
+
|
|
3
|
+
export default class OutputBuilder{
|
|
4
|
+
constructor(options){
|
|
5
|
+
this.options = buildOptions(options);
|
|
6
|
+
this.registeredParsers = registerCommonValueParsers(this.options);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
registerValueParser(name,parserInstance){//existing name will override the parser without warning
|
|
10
|
+
this.registeredParsers[name] = parserInstance;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
getInstance(parserOptions){
|
|
14
|
+
return new JsMinArrBuilder(parserOptions, this.options, this.registeredParsers);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
import BaseOutputBuilder from "./BaseOutputBuilder.js";
|
|
19
|
+
const rootName = '^';
|
|
20
|
+
|
|
21
|
+
class JsMinArrBuilder extends BaseOutputBuilder{
|
|
22
|
+
|
|
23
|
+
constructor(parserOptions, options,registeredParsers) {
|
|
24
|
+
super();
|
|
25
|
+
this.tagsStack = [];
|
|
26
|
+
this.parserOptions = parserOptions;
|
|
27
|
+
this.options = options;
|
|
28
|
+
this.registeredParsers = registeredParsers;
|
|
29
|
+
|
|
30
|
+
this.root = {[rootName]: []};
|
|
31
|
+
this.currentNode = this.root;
|
|
32
|
+
this.currentNodeTagName = rootName;
|
|
33
|
+
this.attributes = {};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
addTag(tag){
|
|
37
|
+
//when a new tag is added, it should be added as child of current node
|
|
38
|
+
//TODO: shift this check to the parser
|
|
39
|
+
if(tag.name === "__proto__") tag.name = "#__proto__";
|
|
40
|
+
|
|
41
|
+
this.tagsStack.push([this.currentNodeTagName,this.currentNode]); //this.currentNode is parent node here
|
|
42
|
+
this.currentNodeTagName = tag.name;
|
|
43
|
+
this.currentNode = { [tag.name]:[]}
|
|
44
|
+
if(Object.keys(this.attributes).length > 0){
|
|
45
|
+
this.currentNode[":@"] = this.attributes;
|
|
46
|
+
this.attributes = {};
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Check if the node should be added by checking user's preference
|
|
52
|
+
* @param {Node} node
|
|
53
|
+
* @returns boolean: true if the node should not be added
|
|
54
|
+
*/
|
|
55
|
+
closeTag(){
|
|
56
|
+
const node = this.currentNode;
|
|
57
|
+
const nodeName = this.currentNodeTagName;
|
|
58
|
+
const arr = this.tagsStack.pop(); //set parent node in scope
|
|
59
|
+
this.currentNodeTagName = arr[0];
|
|
60
|
+
this.currentNode = arr[1];
|
|
61
|
+
|
|
62
|
+
if(this.options.onClose !== undefined){
|
|
63
|
+
//TODO TagPathMatcher
|
|
64
|
+
const resultTag = this.options.onClose(node,
|
|
65
|
+
new TagPathMatcher(this.tagsStack,node));
|
|
66
|
+
|
|
67
|
+
if(resultTag) return;
|
|
68
|
+
}
|
|
69
|
+
this.currentNode[this.currentNodeTagName].push(node); //to parent node
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
//Called by parent class methods
|
|
73
|
+
_addChild(key, val){
|
|
74
|
+
// if(key === "__proto__") tagName = "#__proto__";
|
|
75
|
+
this.currentNode.push( {[key]: val });
|
|
76
|
+
// this.currentNode.leafType = false;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Add text value child node
|
|
81
|
+
* @param {string} text
|
|
82
|
+
*/
|
|
83
|
+
addValue(text){
|
|
84
|
+
this.currentNode[this.currentNodeTagName].push( {[this.options.nameFor.text]: this.parseValue(text, this.options.tags.valueParsers) });
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
addPi(name){
|
|
88
|
+
if(!this.options.ignorePiTags){
|
|
89
|
+
const node = { [name]:[]}
|
|
90
|
+
if(this.attributes){
|
|
91
|
+
node[":@"] = this.attributes;
|
|
92
|
+
}
|
|
93
|
+
this.currentNode.push(node);
|
|
94
|
+
}
|
|
95
|
+
this.attributes = {};
|
|
96
|
+
}
|
|
97
|
+
getOutput(){
|
|
98
|
+
return this.root[rootName];
|
|
99
|
+
}
|
|
100
|
+
}
|