@elench/testkit 0.1.64 → 0.1.66
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/lib/app/browser-bridge.mjs +66 -0
- package/lib/app/configs.mjs +81 -0
- package/lib/app/configs.test.mjs +34 -0
- package/lib/cli/command-helpers.mjs +2 -10
- package/lib/cli/commands/browser/serve.mjs +3 -62
- package/lib/cli/db.mjs +3 -68
- package/lib/config/binaries.mjs +34 -0
- package/lib/config/database.mjs +9 -6
- package/lib/config/index.mjs +2 -31
- package/lib/config/runtime.mjs +24 -95
- package/lib/config/validation.mjs +18 -62
- package/lib/coverage/backend-discovery.mjs +68 -85
- package/lib/coverage/backend-discovery.test.mjs +55 -46
- package/lib/coverage/evidence.mjs +15 -3
- package/lib/coverage/evidence.test.mjs +13 -4
- package/lib/coverage/graph-builder.mjs +25 -26
- package/lib/coverage/next-ir-to-graph.mjs +239 -0
- package/lib/coverage/routing.mjs +2 -29
- package/lib/coverage/routing.test.mjs +0 -16
- package/lib/coverage/shared.mjs +22 -82
- package/lib/database/fingerprint.mjs +1 -1
- package/lib/known-failures/github-cache.mjs +159 -0
- package/lib/known-failures/github-transport.mjs +174 -0
- package/lib/known-failures/github.mjs +17 -325
- package/lib/runner/default-runtime-runner.mjs +4 -10
- package/lib/runner/execution-config.mjs +12 -83
- package/lib/runner/live-run.mjs +45 -0
- package/lib/runner/managed-processes.mjs +29 -0
- package/lib/runner/orchestrator.mjs +57 -188
- package/lib/runner/playwright-runner.mjs +4 -11
- package/lib/runner/run-finalization.mjs +132 -0
- package/lib/runner/run-guards.mjs +45 -0
- package/lib/runner/runtime-preparation.mjs +1 -1
- package/lib/runner/services.mjs +3 -4
- package/lib/runner/template-steps.mjs +8 -45
- package/lib/runner/template.mjs +7 -28
- package/lib/shared/configured-steps.mjs +178 -0
- package/lib/shared/configured-steps.test.mjs +73 -0
- package/lib/shared/execution-schema.mjs +74 -0
- package/lib/shared/execution-schema.test.mjs +26 -0
- package/node_modules/@elench/next-analysis/dist/api-routes.d.ts +7 -0
- package/node_modules/@elench/next-analysis/dist/api-routes.d.ts.map +1 -0
- package/node_modules/@elench/next-analysis/dist/api-routes.js +66 -0
- package/node_modules/@elench/next-analysis/dist/api-routes.js.map +1 -0
- package/node_modules/@elench/next-analysis/dist/app-root.d.ts +2 -0
- package/node_modules/@elench/next-analysis/dist/app-root.d.ts.map +1 -0
- package/node_modules/@elench/next-analysis/dist/app-root.js +7 -0
- package/node_modules/@elench/next-analysis/dist/app-root.js.map +1 -0
- package/node_modules/@elench/next-analysis/dist/backend-links.d.ts +8 -0
- package/node_modules/@elench/next-analysis/dist/backend-links.d.ts.map +1 -0
- package/node_modules/@elench/next-analysis/dist/backend-links.js +30 -0
- package/node_modules/@elench/next-analysis/dist/backend-links.js.map +1 -0
- package/node_modules/@elench/next-analysis/dist/index.d.ts +11 -0
- package/node_modules/@elench/next-analysis/dist/index.d.ts.map +1 -0
- package/node_modules/@elench/next-analysis/dist/index.js +10 -0
- package/node_modules/@elench/next-analysis/dist/index.js.map +1 -0
- package/node_modules/@elench/next-analysis/dist/pages.d.ts +7 -0
- package/node_modules/@elench/next-analysis/dist/pages.d.ts.map +1 -0
- package/node_modules/@elench/next-analysis/dist/pages.js +47 -0
- package/node_modules/@elench/next-analysis/dist/pages.js.map +1 -0
- package/node_modules/@elench/next-analysis/dist/project.d.ts +3 -0
- package/node_modules/@elench/next-analysis/dist/project.d.ts.map +1 -0
- package/node_modules/@elench/next-analysis/dist/project.js +102 -0
- package/node_modules/@elench/next-analysis/dist/project.js.map +1 -0
- package/node_modules/@elench/next-analysis/dist/route-tree.d.ts +7 -0
- package/node_modules/@elench/next-analysis/dist/route-tree.d.ts.map +1 -0
- package/node_modules/@elench/next-analysis/dist/route-tree.js +575 -0
- package/node_modules/@elench/next-analysis/dist/route-tree.js.map +1 -0
- package/node_modules/@elench/next-analysis/dist/routes.d.ts +6 -0
- package/node_modules/@elench/next-analysis/dist/routes.d.ts.map +1 -0
- package/node_modules/@elench/next-analysis/dist/routes.js +41 -0
- package/node_modules/@elench/next-analysis/dist/routes.js.map +1 -0
- package/node_modules/@elench/next-analysis/dist/server-actions.d.ts +7 -0
- package/node_modules/@elench/next-analysis/dist/server-actions.d.ts.map +1 -0
- package/node_modules/@elench/next-analysis/dist/server-actions.js +37 -0
- package/node_modules/@elench/next-analysis/dist/server-actions.js.map +1 -0
- package/node_modules/@elench/next-analysis/dist/shared.d.ts +57 -0
- package/node_modules/@elench/next-analysis/dist/shared.d.ts.map +1 -0
- package/node_modules/@elench/next-analysis/dist/shared.js +229 -0
- package/node_modules/@elench/next-analysis/dist/shared.js.map +1 -0
- package/node_modules/@elench/next-analysis/dist/swc.d.ts +53 -0
- package/node_modules/@elench/next-analysis/dist/swc.d.ts.map +1 -0
- package/node_modules/@elench/next-analysis/dist/swc.js +387 -0
- package/node_modules/@elench/next-analysis/dist/swc.js.map +1 -0
- package/node_modules/@elench/next-analysis/dist/types.d.ts +125 -0
- package/node_modules/@elench/next-analysis/dist/types.d.ts.map +1 -0
- package/node_modules/@elench/next-analysis/dist/types.js +2 -0
- package/node_modules/@elench/next-analysis/dist/types.js.map +1 -0
- package/node_modules/@elench/next-analysis/package.json +27 -0
- package/node_modules/@elench/testkit-bridge/dist/index.d.ts +36 -0
- package/node_modules/@elench/testkit-bridge/dist/index.d.ts.map +1 -0
- package/node_modules/@elench/testkit-bridge/dist/index.js +538 -0
- package/node_modules/@elench/testkit-bridge/dist/index.js.map +1 -0
- package/node_modules/@elench/testkit-bridge/package.json +16 -5
- package/node_modules/@elench/testkit-protocol/dist/index.d.ts +190 -0
- package/node_modules/@elench/testkit-protocol/dist/index.d.ts.map +1 -0
- package/node_modules/@elench/testkit-protocol/dist/index.js +296 -0
- package/node_modules/@elench/testkit-protocol/dist/index.js.map +1 -0
- package/node_modules/@elench/testkit-protocol/package.json +14 -7
- package/node_modules/@elench/ts-analysis/dist/callables.d.ts +8 -0
- package/node_modules/@elench/ts-analysis/dist/callables.d.ts.map +1 -0
- package/node_modules/@elench/ts-analysis/dist/callables.js +126 -0
- package/node_modules/@elench/ts-analysis/dist/callables.js.map +1 -0
- package/node_modules/@elench/ts-analysis/dist/exports.d.ts +6 -0
- package/node_modules/@elench/ts-analysis/dist/exports.d.ts.map +1 -0
- package/node_modules/@elench/ts-analysis/dist/exports.js +70 -0
- package/node_modules/@elench/ts-analysis/dist/exports.js.map +1 -0
- package/node_modules/@elench/ts-analysis/dist/index.d.ts +10 -0
- package/node_modules/@elench/ts-analysis/dist/index.d.ts.map +1 -0
- package/node_modules/@elench/ts-analysis/{src/index.mjs → dist/index.js} +9 -14
- package/node_modules/@elench/ts-analysis/dist/index.js.map +1 -0
- package/node_modules/@elench/ts-analysis/dist/jsx.d.ts +9 -0
- package/node_modules/@elench/ts-analysis/dist/jsx.d.ts.map +1 -0
- package/node_modules/@elench/ts-analysis/dist/jsx.js +68 -0
- package/node_modules/@elench/ts-analysis/dist/jsx.js.map +1 -0
- package/node_modules/@elench/ts-analysis/dist/project.d.ts +5 -0
- package/node_modules/@elench/ts-analysis/dist/project.d.ts.map +1 -0
- package/node_modules/@elench/ts-analysis/dist/project.js +90 -0
- package/node_modules/@elench/ts-analysis/dist/project.js.map +1 -0
- package/node_modules/@elench/ts-analysis/dist/requests.d.ts +6 -0
- package/node_modules/@elench/ts-analysis/dist/requests.d.ts.map +1 -0
- package/node_modules/@elench/ts-analysis/dist/requests.js +140 -0
- package/node_modules/@elench/ts-analysis/dist/requests.js.map +1 -0
- package/node_modules/@elench/ts-analysis/dist/resolution.d.ts +4 -0
- package/node_modules/@elench/ts-analysis/dist/resolution.d.ts.map +1 -0
- package/node_modules/@elench/ts-analysis/dist/resolution.js +53 -0
- package/node_modules/@elench/ts-analysis/dist/resolution.js.map +1 -0
- package/node_modules/@elench/ts-analysis/dist/shared.d.ts +6 -0
- package/node_modules/@elench/ts-analysis/dist/shared.d.ts.map +1 -0
- package/node_modules/@elench/ts-analysis/dist/shared.js +31 -0
- package/node_modules/@elench/ts-analysis/dist/shared.js.map +1 -0
- package/node_modules/@elench/ts-analysis/dist/syntax.d.ts +7 -0
- package/node_modules/@elench/ts-analysis/dist/syntax.d.ts.map +1 -0
- package/node_modules/@elench/ts-analysis/dist/syntax.js +27 -0
- package/node_modules/@elench/ts-analysis/dist/syntax.js.map +1 -0
- package/node_modules/@elench/ts-analysis/dist/types.d.ts +58 -0
- package/node_modules/@elench/ts-analysis/dist/types.d.ts.map +1 -0
- package/node_modules/@elench/ts-analysis/dist/types.js +2 -0
- package/node_modules/@elench/ts-analysis/dist/types.js.map +1 -0
- package/node_modules/@elench/ts-analysis/package.json +18 -2
- package/node_modules/@next/routing/README.md +91 -0
- package/node_modules/@next/routing/dist/__tests__/captures.test.d.ts +1 -0
- package/node_modules/@next/routing/dist/__tests__/conditions.test.d.ts +1 -0
- package/node_modules/@next/routing/dist/__tests__/dynamic-after-rewrites.test.d.ts +1 -0
- package/node_modules/@next/routing/dist/__tests__/i18n-resolve-routes.test.d.ts +1 -0
- package/node_modules/@next/routing/dist/__tests__/i18n.test.d.ts +1 -0
- package/node_modules/@next/routing/dist/__tests__/middleware.test.d.ts +1 -0
- package/node_modules/@next/routing/dist/__tests__/normalize-next-data.test.d.ts +1 -0
- package/node_modules/@next/routing/dist/__tests__/redirects.test.d.ts +1 -0
- package/node_modules/@next/routing/dist/__tests__/resolve-routes.test.d.ts +1 -0
- package/node_modules/@next/routing/dist/__tests__/rewrites.test.d.ts +1 -0
- package/node_modules/@next/routing/dist/destination.d.ts +22 -0
- package/node_modules/@next/routing/dist/i18n.d.ts +48 -0
- package/node_modules/@next/routing/dist/index.d.ts +5 -0
- package/node_modules/@next/routing/dist/index.js +1 -0
- package/node_modules/@next/routing/dist/matchers.d.ts +12 -0
- package/node_modules/@next/routing/dist/middleware.d.ts +12 -0
- package/node_modules/@next/routing/dist/next-data.d.ts +10 -0
- package/node_modules/@next/routing/dist/resolve-routes.d.ts +2 -0
- package/node_modules/@next/routing/dist/types.d.ts +97 -0
- package/node_modules/@next/routing/package.json +39 -0
- package/node_modules/@swc/core/README.md +100 -0
- package/node_modules/@swc/core/Visitor.d.ts +218 -0
- package/node_modules/@swc/core/Visitor.js +1399 -0
- package/node_modules/@swc/core/binding.d.ts +59 -0
- package/node_modules/@swc/core/binding.js +368 -0
- package/node_modules/@swc/core/index.d.ts +120 -0
- package/node_modules/@swc/core/index.js +443 -0
- package/node_modules/@swc/core/package.json +120 -0
- package/node_modules/@swc/core/postinstall.js +148 -0
- package/node_modules/@swc/core/spack.d.ts +51 -0
- package/node_modules/@swc/core/spack.js +87 -0
- package/node_modules/@swc/core/util.d.ts +1 -0
- package/node_modules/@swc/core/util.js +104 -0
- package/node_modules/@swc/core-linux-x64-gnu/README.md +3 -0
- package/node_modules/@swc/core-linux-x64-gnu/package.json +46 -0
- package/node_modules/@swc/core-linux-x64-gnu/swc.linux-x64-gnu.node +0 -0
- package/node_modules/@swc/counter/CHANGELOG.md +7 -0
- package/node_modules/@swc/counter/README.md +7 -0
- package/node_modules/@swc/counter/index.js +1 -0
- package/node_modules/@swc/counter/package.json +27 -0
- package/node_modules/@swc/types/LICENSE +201 -0
- package/node_modules/@swc/types/README.md +4 -0
- package/node_modules/@swc/types/assumptions.d.ts +92 -0
- package/node_modules/@swc/types/assumptions.js +2 -0
- package/node_modules/@swc/types/index.d.ts +2049 -0
- package/node_modules/@swc/types/index.js +2 -0
- package/node_modules/@swc/types/package.json +40 -0
- package/node_modules/typescript/LICENSE.txt +55 -0
- package/node_modules/typescript/README.md +50 -0
- package/node_modules/typescript/SECURITY.md +41 -0
- package/node_modules/typescript/ThirdPartyNoticeText.txt +193 -0
- package/node_modules/typescript/bin/tsc +2 -0
- package/node_modules/typescript/bin/tsserver +2 -0
- package/node_modules/typescript/lib/_tsc.js +133818 -0
- package/node_modules/typescript/lib/_tsserver.js +659 -0
- package/node_modules/typescript/lib/_typingsInstaller.js +222 -0
- package/node_modules/typescript/lib/cs/diagnosticMessages.generated.json +2122 -0
- package/node_modules/typescript/lib/de/diagnosticMessages.generated.json +2122 -0
- package/node_modules/typescript/lib/es/diagnosticMessages.generated.json +2122 -0
- package/node_modules/typescript/lib/fr/diagnosticMessages.generated.json +2122 -0
- package/node_modules/typescript/lib/it/diagnosticMessages.generated.json +2122 -0
- package/node_modules/typescript/lib/ja/diagnosticMessages.generated.json +2122 -0
- package/node_modules/typescript/lib/ko/diagnosticMessages.generated.json +2122 -0
- package/node_modules/typescript/lib/lib.d.ts +22 -0
- package/node_modules/typescript/lib/lib.decorators.d.ts +384 -0
- package/node_modules/typescript/lib/lib.decorators.legacy.d.ts +22 -0
- package/node_modules/typescript/lib/lib.dom.asynciterable.d.ts +41 -0
- package/node_modules/typescript/lib/lib.dom.d.ts +39429 -0
- package/node_modules/typescript/lib/lib.dom.iterable.d.ts +571 -0
- package/node_modules/typescript/lib/lib.es2015.collection.d.ts +147 -0
- package/node_modules/typescript/lib/lib.es2015.core.d.ts +597 -0
- package/node_modules/typescript/lib/lib.es2015.d.ts +28 -0
- package/node_modules/typescript/lib/lib.es2015.generator.d.ts +77 -0
- package/node_modules/typescript/lib/lib.es2015.iterable.d.ts +605 -0
- package/node_modules/typescript/lib/lib.es2015.promise.d.ts +81 -0
- package/node_modules/typescript/lib/lib.es2015.proxy.d.ts +128 -0
- package/node_modules/typescript/lib/lib.es2015.reflect.d.ts +144 -0
- package/node_modules/typescript/lib/lib.es2015.symbol.d.ts +46 -0
- package/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts +326 -0
- package/node_modules/typescript/lib/lib.es2016.array.include.d.ts +116 -0
- package/node_modules/typescript/lib/lib.es2016.d.ts +21 -0
- package/node_modules/typescript/lib/lib.es2016.full.d.ts +23 -0
- package/node_modules/typescript/lib/lib.es2016.intl.d.ts +31 -0
- package/node_modules/typescript/lib/lib.es2017.arraybuffer.d.ts +21 -0
- package/node_modules/typescript/lib/lib.es2017.d.ts +26 -0
- package/node_modules/typescript/lib/lib.es2017.date.d.ts +31 -0
- package/node_modules/typescript/lib/lib.es2017.full.d.ts +23 -0
- package/node_modules/typescript/lib/lib.es2017.intl.d.ts +44 -0
- package/node_modules/typescript/lib/lib.es2017.object.d.ts +49 -0
- package/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts +135 -0
- package/node_modules/typescript/lib/lib.es2017.string.d.ts +45 -0
- package/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts +53 -0
- package/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts +77 -0
- package/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts +53 -0
- package/node_modules/typescript/lib/lib.es2018.d.ts +24 -0
- package/node_modules/typescript/lib/lib.es2018.full.d.ts +24 -0
- package/node_modules/typescript/lib/lib.es2018.intl.d.ts +83 -0
- package/node_modules/typescript/lib/lib.es2018.promise.d.ts +30 -0
- package/node_modules/typescript/lib/lib.es2018.regexp.d.ts +37 -0
- package/node_modules/typescript/lib/lib.es2019.array.d.ts +79 -0
- package/node_modules/typescript/lib/lib.es2019.d.ts +24 -0
- package/node_modules/typescript/lib/lib.es2019.full.d.ts +24 -0
- package/node_modules/typescript/lib/lib.es2019.intl.d.ts +23 -0
- package/node_modules/typescript/lib/lib.es2019.object.d.ts +33 -0
- package/node_modules/typescript/lib/lib.es2019.string.d.ts +37 -0
- package/node_modules/typescript/lib/lib.es2019.symbol.d.ts +24 -0
- package/node_modules/typescript/lib/lib.es2020.bigint.d.ts +765 -0
- package/node_modules/typescript/lib/lib.es2020.d.ts +27 -0
- package/node_modules/typescript/lib/lib.es2020.date.d.ts +42 -0
- package/node_modules/typescript/lib/lib.es2020.full.d.ts +24 -0
- package/node_modules/typescript/lib/lib.es2020.intl.d.ts +474 -0
- package/node_modules/typescript/lib/lib.es2020.number.d.ts +28 -0
- package/node_modules/typescript/lib/lib.es2020.promise.d.ts +47 -0
- package/node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts +99 -0
- package/node_modules/typescript/lib/lib.es2020.string.d.ts +44 -0
- package/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts +41 -0
- package/node_modules/typescript/lib/lib.es2021.d.ts +23 -0
- package/node_modules/typescript/lib/lib.es2021.full.d.ts +24 -0
- package/node_modules/typescript/lib/lib.es2021.intl.d.ts +166 -0
- package/node_modules/typescript/lib/lib.es2021.promise.d.ts +48 -0
- package/node_modules/typescript/lib/lib.es2021.string.d.ts +33 -0
- package/node_modules/typescript/lib/lib.es2021.weakref.d.ts +78 -0
- package/node_modules/typescript/lib/lib.es2022.array.d.ts +121 -0
- package/node_modules/typescript/lib/lib.es2022.d.ts +25 -0
- package/node_modules/typescript/lib/lib.es2022.error.d.ts +75 -0
- package/node_modules/typescript/lib/lib.es2022.full.d.ts +24 -0
- package/node_modules/typescript/lib/lib.es2022.intl.d.ts +145 -0
- package/node_modules/typescript/lib/lib.es2022.object.d.ts +26 -0
- package/node_modules/typescript/lib/lib.es2022.regexp.d.ts +39 -0
- package/node_modules/typescript/lib/lib.es2022.string.d.ts +25 -0
- package/node_modules/typescript/lib/lib.es2023.array.d.ts +924 -0
- package/node_modules/typescript/lib/lib.es2023.collection.d.ts +21 -0
- package/node_modules/typescript/lib/lib.es2023.d.ts +22 -0
- package/node_modules/typescript/lib/lib.es2023.full.d.ts +24 -0
- package/node_modules/typescript/lib/lib.es2023.intl.d.ts +56 -0
- package/node_modules/typescript/lib/lib.es2024.arraybuffer.d.ts +65 -0
- package/node_modules/typescript/lib/lib.es2024.collection.d.ts +29 -0
- package/node_modules/typescript/lib/lib.es2024.d.ts +26 -0
- package/node_modules/typescript/lib/lib.es2024.full.d.ts +24 -0
- package/node_modules/typescript/lib/lib.es2024.object.d.ts +29 -0
- package/node_modules/typescript/lib/lib.es2024.promise.d.ts +35 -0
- package/node_modules/typescript/lib/lib.es2024.regexp.d.ts +25 -0
- package/node_modules/typescript/lib/lib.es2024.sharedmemory.d.ts +68 -0
- package/node_modules/typescript/lib/lib.es2024.string.d.ts +29 -0
- package/node_modules/typescript/lib/lib.es5.d.ts +4601 -0
- package/node_modules/typescript/lib/lib.es6.d.ts +23 -0
- package/node_modules/typescript/lib/lib.esnext.array.d.ts +35 -0
- package/node_modules/typescript/lib/lib.esnext.collection.d.ts +96 -0
- package/node_modules/typescript/lib/lib.esnext.d.ts +29 -0
- package/node_modules/typescript/lib/lib.esnext.decorators.d.ts +28 -0
- package/node_modules/typescript/lib/lib.esnext.disposable.d.ts +193 -0
- package/node_modules/typescript/lib/lib.esnext.error.d.ts +24 -0
- package/node_modules/typescript/lib/lib.esnext.float16.d.ts +445 -0
- package/node_modules/typescript/lib/lib.esnext.full.d.ts +24 -0
- package/node_modules/typescript/lib/lib.esnext.intl.d.ts +21 -0
- package/node_modules/typescript/lib/lib.esnext.iterator.d.ts +148 -0
- package/node_modules/typescript/lib/lib.esnext.promise.d.ts +34 -0
- package/node_modules/typescript/lib/lib.esnext.sharedmemory.d.ts +25 -0
- package/node_modules/typescript/lib/lib.scripthost.d.ts +322 -0
- package/node_modules/typescript/lib/lib.webworker.asynciterable.d.ts +41 -0
- package/node_modules/typescript/lib/lib.webworker.d.ts +13150 -0
- package/node_modules/typescript/lib/lib.webworker.importscripts.d.ts +23 -0
- package/node_modules/typescript/lib/lib.webworker.iterable.d.ts +340 -0
- package/node_modules/typescript/lib/pl/diagnosticMessages.generated.json +2122 -0
- package/node_modules/typescript/lib/pt-br/diagnosticMessages.generated.json +2122 -0
- package/node_modules/typescript/lib/ru/diagnosticMessages.generated.json +2122 -0
- package/node_modules/typescript/lib/tr/diagnosticMessages.generated.json +2122 -0
- package/node_modules/typescript/lib/tsc.js +8 -0
- package/node_modules/typescript/lib/tsserver.js +8 -0
- package/node_modules/typescript/lib/tsserverlibrary.d.ts +17 -0
- package/node_modules/typescript/lib/tsserverlibrary.js +21 -0
- package/node_modules/typescript/lib/typesMap.json +497 -0
- package/node_modules/typescript/lib/typescript.d.ts +11437 -0
- package/node_modules/typescript/lib/typescript.js +200276 -0
- package/node_modules/typescript/lib/typingsInstaller.js +8 -0
- package/node_modules/typescript/lib/watchGuard.js +53 -0
- package/node_modules/typescript/lib/zh-cn/diagnosticMessages.generated.json +2122 -0
- package/node_modules/typescript/lib/zh-tw/diagnosticMessages.generated.json +2122 -0
- package/node_modules/typescript/package.json +120 -0
- package/package.json +13 -8
- package/lib/coverage/fs-walk.mjs +0 -64
- package/lib/coverage/next-discovery.mjs +0 -205
- package/lib/coverage/next-static-analysis.mjs +0 -1045
- package/node_modules/@elench/testkit-bridge/src/index.mjs +0 -583
- package/node_modules/@elench/testkit-bridge/src/index.test.mjs +0 -409
- package/node_modules/@elench/testkit-protocol/src/index.d.ts +0 -231
- package/node_modules/@elench/testkit-protocol/src/index.mjs +0 -265
- package/node_modules/@elench/testkit-protocol/src/index.test.mjs +0 -242
- package/node_modules/@elench/ts-analysis/src/callables.mjs +0 -135
- package/node_modules/@elench/ts-analysis/src/callables.test.mjs +0 -55
- package/node_modules/@elench/ts-analysis/src/exports.mjs +0 -69
- package/node_modules/@elench/ts-analysis/src/exports.test.mjs +0 -50
- package/node_modules/@elench/ts-analysis/src/jsx.mjs +0 -69
- package/node_modules/@elench/ts-analysis/src/jsx.test.mjs +0 -43
- package/node_modules/@elench/ts-analysis/src/project.mjs +0 -100
- package/node_modules/@elench/ts-analysis/src/project.test.mjs +0 -54
- package/node_modules/@elench/ts-analysis/src/requests.mjs +0 -141
- package/node_modules/@elench/ts-analysis/src/requests.test.mjs +0 -35
- package/node_modules/@elench/ts-analysis/src/resolution.mjs +0 -53
- package/node_modules/@elench/ts-analysis/src/shared.mjs +0 -32
- package/node_modules/@elench/ts-analysis/src/syntax.mjs +0 -27
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import * as ts from "typescript";
|
|
2
|
+
import { extractStringLiteral } from "./syntax.js";
|
|
3
|
+
export function collectImports(sourceFile, options) {
|
|
4
|
+
const imports = new Map();
|
|
5
|
+
for (const statement of sourceFile.statements) {
|
|
6
|
+
if (!ts.isImportDeclaration(statement) || !statement.importClause)
|
|
7
|
+
continue;
|
|
8
|
+
const specifier = extractStringLiteral(statement.moduleSpecifier);
|
|
9
|
+
if (!specifier)
|
|
10
|
+
continue;
|
|
11
|
+
const resolvedFilePath = options.resolveImportPath(specifier);
|
|
12
|
+
const sourceContent = resolvedFilePath ? options.readSourceFile(resolvedFilePath) : null;
|
|
13
|
+
const serverActionImport = Boolean(sourceContent && options.isServerActionFile(sourceContent));
|
|
14
|
+
if (statement.importClause.name) {
|
|
15
|
+
imports.set(statement.importClause.name.text, {
|
|
16
|
+
importedName: "default",
|
|
17
|
+
specifier,
|
|
18
|
+
resolvedFilePath,
|
|
19
|
+
isServerAction: serverActionImport,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
const bindings = statement.importClause.namedBindings;
|
|
23
|
+
if (!bindings || !ts.isNamedImports(bindings))
|
|
24
|
+
continue;
|
|
25
|
+
for (const element of bindings.elements) {
|
|
26
|
+
const localName = element.name.text;
|
|
27
|
+
const importedName = element.propertyName?.text || localName;
|
|
28
|
+
imports.set(localName, {
|
|
29
|
+
importedName,
|
|
30
|
+
specifier,
|
|
31
|
+
resolvedFilePath,
|
|
32
|
+
isServerAction: serverActionImport,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return imports;
|
|
37
|
+
}
|
|
38
|
+
export function collectTopLevelFunctions(sourceFile) {
|
|
39
|
+
const functions = new Map();
|
|
40
|
+
for (const statement of sourceFile.statements) {
|
|
41
|
+
if (ts.isFunctionDeclaration(statement) && statement.name) {
|
|
42
|
+
functions.set(statement.name.text, statement);
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
if (!ts.isVariableStatement(statement))
|
|
46
|
+
continue;
|
|
47
|
+
for (const declaration of statement.declarationList.declarations) {
|
|
48
|
+
if (!ts.isIdentifier(declaration.name) || !declaration.initializer)
|
|
49
|
+
continue;
|
|
50
|
+
if (ts.isArrowFunction(declaration.initializer) || ts.isFunctionExpression(declaration.initializer)) {
|
|
51
|
+
functions.set(declaration.name.text, declaration.initializer);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return functions;
|
|
56
|
+
}
|
|
57
|
+
export function collectExportedCallables(sourceFile, topLevelFunctions) {
|
|
58
|
+
const exports = new Map();
|
|
59
|
+
for (const statement of sourceFile.statements) {
|
|
60
|
+
if (ts.isFunctionDeclaration(statement) && statement.name && hasExportModifier(statement.modifiers)) {
|
|
61
|
+
exports.set(statement.name.text, statement);
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
if (!ts.isVariableStatement(statement) || !hasExportModifier(statement.modifiers))
|
|
65
|
+
continue;
|
|
66
|
+
for (const declaration of statement.declarationList.declarations) {
|
|
67
|
+
if (!ts.isIdentifier(declaration.name) || !declaration.initializer)
|
|
68
|
+
continue;
|
|
69
|
+
if (ts.isArrowFunction(declaration.initializer) || ts.isFunctionExpression(declaration.initializer)) {
|
|
70
|
+
exports.set(declaration.name.text, declaration.initializer);
|
|
71
|
+
}
|
|
72
|
+
else if (ts.isIdentifier(declaration.initializer)) {
|
|
73
|
+
const referenced = topLevelFunctions.get(declaration.initializer.text);
|
|
74
|
+
if (referenced)
|
|
75
|
+
exports.set(declaration.name.text, referenced);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return exports;
|
|
80
|
+
}
|
|
81
|
+
export function collectScopeLocalFunctions(node) {
|
|
82
|
+
const functions = new Map();
|
|
83
|
+
const callableBody = "body" in node ? node.body : null;
|
|
84
|
+
if (!callableBody)
|
|
85
|
+
return functions;
|
|
86
|
+
const visit = (child) => {
|
|
87
|
+
if (ts.isFunctionDeclaration(child) && child.name) {
|
|
88
|
+
functions.set(child.name.text, child);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
if (child !== callableBody && (ts.isArrowFunction(child) || ts.isFunctionExpression(child))) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
if (ts.isVariableDeclaration(child) && ts.isIdentifier(child.name) && child.initializer) {
|
|
95
|
+
if (ts.isArrowFunction(child.initializer) || ts.isFunctionExpression(child.initializer)) {
|
|
96
|
+
functions.set(child.name.text, child.initializer);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
ts.forEachChild(child, visit);
|
|
100
|
+
};
|
|
101
|
+
visit(callableBody);
|
|
102
|
+
return functions;
|
|
103
|
+
}
|
|
104
|
+
export function findDefaultExportCallable(sourceFile, localFunctions) {
|
|
105
|
+
for (const statement of sourceFile.statements) {
|
|
106
|
+
if (ts.isFunctionDeclaration(statement) && hasDefaultModifier(statement.modifiers)) {
|
|
107
|
+
return statement;
|
|
108
|
+
}
|
|
109
|
+
if (ts.isExportAssignment(statement)) {
|
|
110
|
+
if (ts.isIdentifier(statement.expression)) {
|
|
111
|
+
return localFunctions.get(statement.expression.text) || null;
|
|
112
|
+
}
|
|
113
|
+
if (ts.isArrowFunction(statement.expression) || ts.isFunctionExpression(statement.expression)) {
|
|
114
|
+
return statement.expression;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
function hasExportModifier(modifiers) {
|
|
121
|
+
return Boolean(modifiers?.some((modifier) => modifier.kind === ts.SyntaxKind.ExportKeyword));
|
|
122
|
+
}
|
|
123
|
+
function hasDefaultModifier(modifiers) {
|
|
124
|
+
return Boolean(modifiers?.some((modifier) => modifier.kind === ts.SyntaxKind.DefaultKeyword));
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=callables.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"callables.js","sourceRoot":"","sources":["../src/callables.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAEjC,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEnD,MAAM,UAAU,cAAc,CAAC,UAAyB,EAAE,OAAkC;IAC1F,MAAM,OAAO,GA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AAS,CAAC,EAAE,CAAC;YACnF,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,IAAI,EAAE,CAAC,kBAAkB,CAAC,SAAS,CAAC,EAAE,CAAC;YACrC,IAAI,EAAE,CAAC,YAAY,CAAC,SAAS,CAAC,UAAU,CAAC,EAAE,CAAC;gBAC1C,OAAO,cAAc,CAAC,GAAG,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC;YAC/D,CAAC;YACD,IAAI,EAAE,CAAC,eAAe,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,oBAAoB,CAAC,SAAS,CAAC,UAAU,CAAC,EAAE,CAAC;gBAC9F,OAAO,SAAS,CAAC,UAAU,CAAC;YAC9B,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,iBAAiB,CAAC,SAAoD;IAC7E,OAAO,OAAO,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,KAAK,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC;AAC/F,CAAC;AAED,SAAS,kBAAkB,CAAC,SAAoD;IAC9E,OAAO,OAAO,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,KAAK,EAAE,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC,CAAC;AAChG,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ExportedFunctionBody } from "./types.js";
|
|
2
|
+
export declare function extractExportedMethodBodies(content: string, methods: string[], filePath?: string): Array<[string, string]>;
|
|
3
|
+
export declare function extractExportedFunctions(content: string, filePath?: string): ExportedFunctionBody[];
|
|
4
|
+
export declare function extractExportedFunctionBody(content: string, exportName: string, filePath?: string): string | null;
|
|
5
|
+
export declare function readBalancedBlock(content: string, startIndex: number): string | null;
|
|
6
|
+
//# sourceMappingURL=exports.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../src/exports.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAGvD,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EAAE,EACjB,QAAQ,SAAa,GACpB,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAOzB;AAED,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,SAAc,GAAG,oBAAoB,EAAE,CAaxG;AAED,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,SAAc,GAAG,MAAM,GAAG,IAAI,CAQtH;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAsBpF"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import * as ts from "typescript";
|
|
2
|
+
import { createSourceFile } from "./syntax.js";
|
|
3
|
+
export function extractExportedMethodBodies(content, methods, filePath = "route.ts") {
|
|
4
|
+
const bodies = [];
|
|
5
|
+
for (const method of methods) {
|
|
6
|
+
const body = extractExportedFunctionBody(content, method, filePath);
|
|
7
|
+
if (body)
|
|
8
|
+
bodies.push([method, body]);
|
|
9
|
+
}
|
|
10
|
+
return bodies;
|
|
11
|
+
}
|
|
12
|
+
export function extractExportedFunctions(content, filePath = "module.ts") {
|
|
13
|
+
const sourceFile = createSourceFile(filePath, content);
|
|
14
|
+
const exported = [];
|
|
15
|
+
for (const statement of sourceFile.statements) {
|
|
16
|
+
if (!ts.isFunctionDeclaration(statement) || !statement.name || !hasExportModifier(statement.modifiers) || !statement.body) {
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
exported.push({
|
|
20
|
+
name: statement.name.text,
|
|
21
|
+
body: bodyText(sourceFile, statement.body),
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
return exported;
|
|
25
|
+
}
|
|
26
|
+
export function extractExportedFunctionBody(content, exportName, filePath = "module.ts") {
|
|
27
|
+
const sourceFile = createSourceFile(filePath, content);
|
|
28
|
+
for (const statement of sourceFile.statements) {
|
|
29
|
+
if (!ts.isFunctionDeclaration(statement) || !statement.name || statement.name.text !== exportName)
|
|
30
|
+
continue;
|
|
31
|
+
if (!hasExportModifier(statement.modifiers) || !statement.body)
|
|
32
|
+
return null;
|
|
33
|
+
return bodyText(sourceFile, statement.body);
|
|
34
|
+
}
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
export function readBalancedBlock(content, startIndex) {
|
|
38
|
+
let depth = 0;
|
|
39
|
+
let inSingle = false;
|
|
40
|
+
let inDouble = false;
|
|
41
|
+
let inTemplate = false;
|
|
42
|
+
for (let index = startIndex; index < content.length; index += 1) {
|
|
43
|
+
const char = content[index];
|
|
44
|
+
const previous = content[index - 1];
|
|
45
|
+
if (char === "'" && !inDouble && !inTemplate && previous !== "\\")
|
|
46
|
+
inSingle = !inSingle;
|
|
47
|
+
if (char === '"' && !inSingle && !inTemplate && previous !== "\\")
|
|
48
|
+
inDouble = !inDouble;
|
|
49
|
+
if (char === "`" && !inSingle && !inDouble && previous !== "\\")
|
|
50
|
+
inTemplate = !inTemplate;
|
|
51
|
+
if (inSingle || inDouble || inTemplate)
|
|
52
|
+
continue;
|
|
53
|
+
if (char === "{")
|
|
54
|
+
depth += 1;
|
|
55
|
+
if (char === "}") {
|
|
56
|
+
depth -= 1;
|
|
57
|
+
if (depth === 0) {
|
|
58
|
+
return content.slice(startIndex, index + 1);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
function hasExportModifier(modifiers) {
|
|
65
|
+
return Boolean(modifiers?.some((modifier) => modifier.kind === ts.SyntaxKind.ExportKeyword));
|
|
66
|
+
}
|
|
67
|
+
function bodyText(sourceFile, bodyNode) {
|
|
68
|
+
return sourceFile.text.slice(bodyNode.getStart(sourceFile), bodyNode.end);
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=exports.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exports.js","sourceRoot":"","sources":["../src/exports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAEjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,MAAM,UAAU,2BAA2B,CACzC,OAAe,EACf,OAAiB,EACjB,QAAQ,GAAG,UAAU;IAErB,MAAM,MAAM,GAA4B,EAAE,CAAC;IAC3C,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,MAAM,IAAI,GAAG,2BAA2B,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;QACpE,IAAI,IAAI;YAAE,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;IACxC,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,OAAe,EAAE,QAAQ,GAAG,WAAW;IAC9E,MAAM,UAAU,GAAG,gBAAgB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IACvD,MAAM,QAAQ,GAA2B,EAAE,CAAC;IAC5C,KAAK,MAAM,SAAS,IAAI,UAAU,CAAC,UAAU,EAAE,CAAC;QAC9C,IAAI,CAAC,EAAE,CAAC,qBAAqB,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,IAAI,CAAC,iBAAiB,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;YAC1H,SAAS;QACX,CAAC;QACD,QAAQ,CAAC,IAAI,CA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ImportRecord, JsxAttributeMap, JsxAttributeValue, LoadedTsConfig, RequestExtractionOptions, } from "./types.js";
|
|
2
|
+
export { DEFAULT_DYNAMIC_SEGMENT_TOKEN, normalizePath } from "./shared.js";
|
|
3
|
+
export { createAnalysisProject, findNearestTsConfig, loadTsConfig } from "./project.js";
|
|
4
|
+
export { resolveImportToSourceFile, resolveSourceCandidate } from "./resolution.js";
|
|
5
|
+
export { collectExportedCallables, collectImports, collectScopeLocalFunctions, collectTopLevelFunctions, findDefaultExportCallable, } from "./callables.js";
|
|
6
|
+
export { collectJsxAttributes, extractJsxLabel, flattenJsxText, walkJsx } from "./jsx.js";
|
|
7
|
+
export { extractExportedFunctionBody, extractExportedFunctions, extractExportedMethodBodies, readBalancedBlock } from "./exports.js";
|
|
8
|
+
export { extractHttpRequests, extractPlaywrightVisitedRoutes, extractRouteLiteral } from "./requests.js";
|
|
9
|
+
export { createSourceFile, extractLineNumber, extractStringLiteral } from "./syntax.js";
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,eAAe,EACf,sBAAsB,EACtB,YAAY,EACZ,oBAAoB,EACpB,WAAW,EACX,yBAAyB,EACzB,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,cAAc,EACd,wBAAwB,GACzB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,6BAA6B,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC3E,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACxF,OAAO,EAAE,yBAAyB,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACpF,OAAO,EACL,wBAAwB,EACxB,cAAc,EACd,0BAA0B,EAC1B,wBAAwB,EACxB,yBAAyB,GAC1B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1F,OAAO,EAAE,2BAA2B,EAAE,wBAAwB,EAAE,2BAA2B,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACrI,OAAO,EAAE,mBAAmB,EAAE,8BAA8B,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACzG,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
export { DEFAULT_DYNAMIC_SEGMENT_TOKEN, normalizePath } from "./shared.
|
|
2
|
-
export { createAnalysisProject, findNearestTsConfig, loadTsConfig } from "./project.
|
|
3
|
-
export { resolveImportToSourceFile, resolveSourceCandidate } from "./resolution.
|
|
4
|
-
export {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
} from "./callables.mjs";
|
|
11
|
-
export { collectJsxAttributes, extractJsxLabel, flattenJsxText, walkJsx } from "./jsx.mjs";
|
|
12
|
-
export { extractExportedFunctionBody, extractExportedFunctions, extractExportedMethodBodies, readBalancedBlock } from "./exports.mjs";
|
|
13
|
-
export { extractHttpRequests, extractPlaywrightVisitedRoutes, extractRouteLiteral } from "./requests.mjs";
|
|
14
|
-
export { createSourceFile, extractLineNumber, extractStringLiteral } from "./syntax.mjs";
|
|
1
|
+
export { DEFAULT_DYNAMIC_SEGMENT_TOKEN, normalizePath } from "./shared.js";
|
|
2
|
+
export { createAnalysisProject, findNearestTsConfig, loadTsConfig } from "./project.js";
|
|
3
|
+
export { resolveImportToSourceFile, resolveSourceCandidate } from "./resolution.js";
|
|
4
|
+
export { collectExportedCallables, collectImports, collectScopeLocalFunctions, collectTopLevelFunctions, findDefaultExportCallable, } from "./callables.js";
|
|
5
|
+
export { collectJsxAttributes, extractJsxLabel, flattenJsxText, walkJsx } from "./jsx.js";
|
|
6
|
+
export { extractExportedFunctionBody, extractExportedFunctions, extractExportedMethodBodies, readBalancedBlock } from "./exports.js";
|
|
7
|
+
export { extractHttpRequests, extractPlaywrightVisitedRoutes, extractRouteLiteral } from "./requests.js";
|
|
8
|
+
export { createSourceFile, extractLineNumber, extractStringLiteral } from "./syntax.js";
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,6BAA6B,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC3E,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACxF,OAAO,EAAE,yBAAyB,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACpF,OAAO,EACL,wBAAwB,EACxB,cAAc,EACd,0BAA0B,EAC1B,wBAAwB,EACxB,yBAAyB,GAC1B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1F,OAAO,EAAE,2BAA2B,EAAE,wBAAwB,EAAE,2BAA2B,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACrI,OAAO,EAAE,mBAAmB,EAAE,8BAA8B,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACzG,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as ts from "typescript";
|
|
2
|
+
import type { JsxAttributeMap } from "./types.js";
|
|
3
|
+
type JsxVisitNode = ts.JsxElement | ts.JsxSelfClosingElement;
|
|
4
|
+
export declare function walkJsx(sourceFile: ts.SourceFile | ts.Node, visitor: (node: JsxVisitNode, formContext: unknown) => unknown): void;
|
|
5
|
+
export declare function collectJsxAttributes(openingElement: ts.JsxOpeningLikeElement): JsxAttributeMap;
|
|
6
|
+
export declare function flattenJsxText(children: readonly ts.JsxChild[]): string;
|
|
7
|
+
export declare function extractJsxLabel(node: JsxVisitNode, attributes: JsxAttributeMap): string | null;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=jsx.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsx.d.ts","sourceRoot":"","sources":["../src/jsx.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,KAAK,YAAY,GAAG,EAAE,CAAC,UAAU,GAAG,EAAE,CAAC,qBAAqB,CAAC;AAE7D,wBAAgB,OAAO,CACrB,UAAU,EAAE,EAAE,CAAC,UAAU,GAAG,EAAE,CAAC,IAAI,EACnC,OAAO,EAAE,CAAC,IAAI,EAAE,YAAY,EAAE,WAAW,EAAE,OAAO,KAAK,OAAO,GAC7D,IAAI,CAgBN;AAED,wBAAgB,oBAAoB,CAAC,cAAc,EAAE,EAAE,CAAC,qBAAqB,GAAG,eAAe,CAwB9F;AAED,wBAAgB,cAAc,CAAC,QAAQ,EAAE,SAAS,EAAE,CAAC,QAAQ,EAAE,GAAG,MAAM,CAYvE;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,YAAY,EAAE,UAAU,EAAE,eAAe,GAAG,MAAM,GAAG,IAAI,CAQ9F"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import * as ts from "typescript";
|
|
2
|
+
export function walkJsx(sourceFile, visitor) {
|
|
3
|
+
const visit = (node, formContext = null) => {
|
|
4
|
+
let nextFormContext = formContext;
|
|
5
|
+
if (ts.isJsxElement(node) || ts.isJsxSelfClosingElement(node)) {
|
|
6
|
+
nextFormContext = visitor(node, formContext);
|
|
7
|
+
}
|
|
8
|
+
if (ts.isJsxElement(node)) {
|
|
9
|
+
for (const child of node.children)
|
|
10
|
+
visit(child, nextFormContext);
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
ts.forEachChild(node, (child) => visit(child, nextFormContext));
|
|
14
|
+
};
|
|
15
|
+
visit(sourceFile, null);
|
|
16
|
+
}
|
|
17
|
+
export function collectJsxAttributes(openingElement) {
|
|
18
|
+
const attributes = {};
|
|
19
|
+
for (const property of openingElement.attributes.properties) {
|
|
20
|
+
if (!ts.isJsxAttribute(property))
|
|
21
|
+
continue;
|
|
22
|
+
const name = property.name.getText();
|
|
23
|
+
if (!property.initializer) {
|
|
24
|
+
attributes[name] = { stringValue: "true", expression: null };
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
if (ts.isStringLiteral(property.initializer)) {
|
|
28
|
+
attributes[name] = { stringValue: property.initializer.text, expression: null };
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
if (ts.isJsxExpression(property.initializer)) {
|
|
32
|
+
attributes[name] = {
|
|
33
|
+
stringValue: property.initializer.expression && ts.isStringLiteralLike(property.initializer.expression)
|
|
34
|
+
? property.initializer.expression.text
|
|
35
|
+
: null,
|
|
36
|
+
expression: property.initializer.expression || null,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return attributes;
|
|
41
|
+
}
|
|
42
|
+
export function flattenJsxText(children) {
|
|
43
|
+
let text = "";
|
|
44
|
+
for (const child of children) {
|
|
45
|
+
if (ts.isJsxText(child)) {
|
|
46
|
+
text += child.getText().replace(/\s+/gu, " ");
|
|
47
|
+
}
|
|
48
|
+
else if (ts.isJsxExpression(child) && child.expression && ts.isStringLiteralLike(child.expression)) {
|
|
49
|
+
text += child.expression.text;
|
|
50
|
+
}
|
|
51
|
+
else if (ts.isJsxElement(child)) {
|
|
52
|
+
text += flattenJsxText(child.children);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return text;
|
|
56
|
+
}
|
|
57
|
+
export function extractJsxLabel(node, attributes) {
|
|
58
|
+
const ariaLabel = attributes["aria-label"]?.stringValue || attributes.title?.stringValue || null;
|
|
59
|
+
if (ariaLabel)
|
|
60
|
+
return ariaLabel;
|
|
61
|
+
if (ts.isJsxElement(node)) {
|
|
62
|
+
const text = flattenJsxText(node.children).trim();
|
|
63
|
+
if (text)
|
|
64
|
+
return text;
|
|
65
|
+
}
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=jsx.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsx.js","sourceRoot":"","sources":["../src/jsx.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAKjC,MAAM,UAAU,OAAO,CACrB,UAAmC,EACnC,OAA8D;IAE9D,MAAM,KAAK,GAAG,CAAC,IAAa,EAAE,cAAuB,IAAI,EAAQ,EAAE;QACjE,IAAI,eAAe,GAAG,WAAW,CAAC;QAClC,IAAI,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,uBAAuB,CAAC,IAAI,CAAC,EAAE,CAAC;YAC9D,eAAe,GAAG,OAAO,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;QAC/C,CAAC;QAED,IAAI,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC;YAC1B,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,QAAQ;gBAAE,KAAK,CAAC,KAAK,EAAE,eAAe,CAAC,CAAC;YACjE,OAAO;QACT,CAAC;QAED,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,eAAe,CAAC,CAAC,CAAC;IAClE,CAAC,CAAC;IAEF,KAAK,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,cAAwC;IAC3E,MAAM,UAAU,GAAoB,EAAE,C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C;YACxB,IAAI,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QAChD,CAAC;aAAM,IAAI,EAAE,CAAC,eAAe,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,UAAU,IAAI,EAAE,CAAC,mBAAmB,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC;YACrG,IAAI,IAAI,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC;QAChC,CAAC;aAAM,IAAI,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;YAClC,IAAI,IAAI,cAAc,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QACzC,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,IAAkB,EAAE,UAA2B;IAC7E,MAAM,SAAS,GAAG,UAAU,CAAC,YAAY,CAAC,EAAE,WAAW,IAAI,UAAU,CAAC,KAAK,EAAE,WAAW,IAAI,IAAI,CAAC;IACjG,IAAI,SAAS;QAAE,OAAO,SAAS,CAAC;IAChC,IAAI,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,GAAG,cAAc,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,IAAI,EAAE,CAAC;QAClD,IAAI,IAAI;YAAE,OAAO,IAAI,CAAC;IACxB,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { AnalysisProject, AnalysisProjectOptions, LoadedTsConfig } from "./types.js";
|
|
2
|
+
export declare function findNearestTsConfig(startDir: string): string | null;
|
|
3
|
+
export declare function loadTsConfig(tsconfigPath: string): LoadedTsConfig;
|
|
4
|
+
export declare function createAnalysisProject({ rootDir, tsconfigPath }?: AnalysisProjectOptions): AnalysisProject;
|
|
5
|
+
//# sourceMappingURL=project.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../src/project.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAI1F,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAEnE;AAED,wBAAgB,YAAY,CAAC,YAAY,EAAE,MAAM,GAAG,cAAc,CA2BjE;AAED,wBAAgB,qBAAqB,CAAC,EAAE,OAAO,EAAE,YAAmB,EAAE,GAAE,sBAA2B,GAAG,eAAe,CAsCpH"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import * as fs from "node:fs";
|
|
2
|
+
import * as path from "node:path";
|
|
3
|
+
import * as ts from "typescript";
|
|
4
|
+
import { defaultCompilerOptions, normalizePath } from "./shared.js";
|
|
5
|
+
import { resolveImportToSourceFile } from "./resolution.js";
|
|
6
|
+
export function findNearestTsConfig(startDir) {
|
|
7
|
+
return ts.findConfigFile(startDir, ts.sys.fileExists, "tsconfig.json") || null;
|
|
8
|
+
}
|
|
9
|
+
export function loadTsConfig(tsconfigPath) {
|
|
10
|
+
const configFile = ts.readConfigFile(tsconfigPath, ts.sys.readFile);
|
|
11
|
+
if (configFile.error) {
|
|
12
|
+
return {
|
|
13
|
+
tsconfigPath,
|
|
14
|
+
rootDir: path.dirname(tsconfigPath),
|
|
15
|
+
fileNames: [],
|
|
16
|
+
options: defaultCompilerOptions(path.dirname(tsconfigPath)),
|
|
17
|
+
errors: [configFile.error],
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
const parsed = ts.parseJsonConfigFileContent(configFile.config, ts.sys, path.dirname(tsconfigPath), defaultCompilerOptions(path.dirname(tsconfigPath)), tsconfigPath);
|
|
21
|
+
return {
|
|
22
|
+
tsconfigPath,
|
|
23
|
+
rootDir: path.dirname(tsconfigPath),
|
|
24
|
+
fileNames: parsed.fileNames.map(normalizePath),
|
|
25
|
+
options: parsed.options,
|
|
26
|
+
errors: parsed.errors || [],
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export function createAnalysisProject({ rootDir, tsconfigPath = null } = {}) {
|
|
30
|
+
const resolvedRoot = path.resolve(rootDir || process.cwd());
|
|
31
|
+
const resolvedConfigPath = tsconfigPath ? path.resolve(tsconfigPath) : findNearestTsConfig(resolvedRoot);
|
|
32
|
+
const config = resolvedConfigPath
|
|
33
|
+
? loadTsConfig(resolvedConfigPath)
|
|
34
|
+
: {
|
|
35
|
+
tsconfigPath: null,
|
|
36
|
+
rootDir: resolvedRoot,
|
|
37
|
+
fileNames: listProjectFiles(resolvedRoot),
|
|
38
|
+
options: defaultCompilerOptions(resolvedRoot),
|
|
39
|
+
errors: [],
|
|
40
|
+
};
|
|
41
|
+
const program = ts.createProgram(config.fileNames, config.options);
|
|
42
|
+
const checker = program.getTypeChecker();
|
|
43
|
+
const diagnostics = [...config.errors, ...ts.getPreEmitDiagnostics(program)];
|
|
44
|
+
return {
|
|
45
|
+
rootDir: config.rootDir,
|
|
46
|
+
tsconfigPath: config.tsconfigPath,
|
|
47
|
+
program,
|
|
48
|
+
checker,
|
|
49
|
+
compilerOptions: config.options,
|
|
50
|
+
diagnostics,
|
|
51
|
+
getSourceFiles() {
|
|
52
|
+
return program.getSourceFiles().filter((file) => !file.isDeclarationFile);
|
|
53
|
+
},
|
|
54
|
+
getSourceFile(filePath) {
|
|
55
|
+
return program.getSourceFile(path.isAbsolute(filePath) ? filePath : path.join(config.rootDir, filePath)) || null;
|
|
56
|
+
},
|
|
57
|
+
readSourceFile(filePath) {
|
|
58
|
+
const sourceFile = this.getSourceFile(filePath);
|
|
59
|
+
return sourceFile ? sourceFile.text : null;
|
|
60
|
+
},
|
|
61
|
+
resolveImport(fromFilePath, specifier) {
|
|
62
|
+
return resolveImportToSourceFile(config.rootDir, normalizePath(fromFilePath), specifier, config.options);
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
function listProjectFiles(rootDir) {
|
|
67
|
+
const results = [];
|
|
68
|
+
const queue = [rootDir];
|
|
69
|
+
while (queue.length > 0) {
|
|
70
|
+
const current = queue.pop();
|
|
71
|
+
if (!current)
|
|
72
|
+
continue;
|
|
73
|
+
for (const entry of fs.readdirSync(current, { withFileTypes: true })) {
|
|
74
|
+
if (entry.isSymbolicLink())
|
|
75
|
+
continue;
|
|
76
|
+
const absolutePath = path.join(current, entry.name);
|
|
77
|
+
if (entry.isDirectory()) {
|
|
78
|
+
if (entry.name === "node_modules" || entry.name === ".next" || entry.name === ".git")
|
|
79
|
+
continue;
|
|
80
|
+
queue.push(absolutePath);
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
if (/\.(ts|tsx|js|jsx|mjs)$/u.test(entry.name)) {
|
|
84
|
+
results.push(normalizePath(absolutePath));
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return results.sort((left, right) => left.localeCompare(right));
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=project.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project.js","sourceRoot":"","sources":["../src/project.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAEjC,OAAO,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAE5D,MAAM,UAAU,mBAAmB,CAAC,QAAgB;IAClD,OAAO,EAAE,CAAC,cAAc,CAAC,QAAQ,EAAE,EAAE,CAAC,GAAG,CAAC,UAAU,EAAE,eAAe,CAAC,IAAI,IAAI,CAAC;AACjF,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,YAAoB;IAC/C,MA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CAAC,CAAC,CAAC;AAClE,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as ts from "typescript";
|
|
2
|
+
import type { HttpRequest, RequestExtractionOptions } from "./types.js";
|
|
3
|
+
export declare function extractHttpRequests(content: string, options?: RequestExtractionOptions): HttpRequest[];
|
|
4
|
+
export declare function extractPlaywrightVisitedRoutes(content: string, options?: RequestExtractionOptions): string[];
|
|
5
|
+
export declare function extractRouteLiteral(node: ts.Node | undefined, options?: RequestExtractionOptions): string | null;
|
|
6
|
+
//# sourceMappingURL=requests.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requests.d.ts","sourceRoot":"","sources":["../src/requests.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,KAAK,EAAE,WAAW,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAWxE,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,wBAA6B,GAAG,WAAW,EAAE,CAgB1G;AAED,wBAAgB,8BAA8B,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,wBAA6B,GAAG,MAAM,EAAE,CAgBhH;AAED,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,EAAE,CAAC,IAAI,GAAG,SAAS,EACzB,OAAO,GAAE,wBAA6B,GACrC,MAAM,GAAG,IAAI,CAKf"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import * as ts from "typescript";
|
|
2
|
+
import { createSourceFile, extractStringLiteral } from "./syntax.js";
|
|
3
|
+
const HTTP_WRAPPER_METHODS = {
|
|
4
|
+
getJson: "GET",
|
|
5
|
+
postJson: "POST",
|
|
6
|
+
putJson: "PUT",
|
|
7
|
+
patchJson: "PATCH",
|
|
8
|
+
deleteJson: "DELETE",
|
|
9
|
+
};
|
|
10
|
+
export function extractHttpRequests(content, options = {}) {
|
|
11
|
+
const filePath = options.filePath || "suite.testkit.ts";
|
|
12
|
+
const normalizeRoute = options.normalizeRoute || defaultNormalizeRoute;
|
|
13
|
+
const sourceFile = createSourceFile(filePath, content);
|
|
14
|
+
const requests = [];
|
|
15
|
+
const visit = (node) => {
|
|
16
|
+
if (ts.isCallExpression(node)) {
|
|
17
|
+
const request = resolveHttpRequestCall(node, { normalizeRoute, dynamicSegmentToken: options.dynamicSegmentToken });
|
|
18
|
+
if (request)
|
|
19
|
+
requests.push(request);
|
|
20
|
+
}
|
|
21
|
+
ts.forEachChild(node, visit);
|
|
22
|
+
};
|
|
23
|
+
visit(sourceFile);
|
|
24
|
+
return dedupeRequests(requests);
|
|
25
|
+
}
|
|
26
|
+
export function extractPlaywrightVisitedRoutes(content, options = {}) {
|
|
27
|
+
const filePath = options.filePath || "suite.pw.testkit.ts";
|
|
28
|
+
const normalizeRoute = options.normalizeRoute || defaultNormalizeRoute;
|
|
29
|
+
const sourceFile = createSourceFile(filePath, content);
|
|
30
|
+
const routes = [];
|
|
31
|
+
const visit = (node) => {
|
|
32
|
+
if (ts.isCallExpression(node)) {
|
|
33
|
+
const route = resolveGotoRoute(node, { normalizeRoute, dynamicSegmentToken: options.dynamicSegmentToken });
|
|
34
|
+
if (route)
|
|
35
|
+
routes.push(route);
|
|
36
|
+
}
|
|
37
|
+
ts.forEachChild(node, visit);
|
|
38
|
+
};
|
|
39
|
+
visit(sourceFile);
|
|
40
|
+
return [...new Set(routes)];
|
|
41
|
+
}
|
|
42
|
+
export function extractRouteLiteral(node, options = {}) {
|
|
43
|
+
const normalizeRoute = options.normalizeRoute || defaultNormalizeRoute;
|
|
44
|
+
const literal = extractStringLiteral(node, options);
|
|
45
|
+
if (!literal)
|
|
46
|
+
return null;
|
|
47
|
+
return normalizeRoute(literal.split("?")[0]);
|
|
48
|
+
}
|
|
49
|
+
function resolveGotoRoute(callExpression, options) {
|
|
50
|
+
const callee = callExpression.expression;
|
|
51
|
+
if (!ts.isPropertyAccessExpression(callee))
|
|
52
|
+
return null;
|
|
53
|
+
if (callee.name.text !== "goto")
|
|
54
|
+
return null;
|
|
55
|
+
const pathArg = callExpression.arguments[0];
|
|
56
|
+
const literal = extractStringLiteral(pathArg, options);
|
|
57
|
+
if (!literal)
|
|
58
|
+
return null;
|
|
59
|
+
if (/^https?:\/\//u.test(literal)) {
|
|
60
|
+
try {
|
|
61
|
+
const parsed = new URL(literal);
|
|
62
|
+
if (parsed.hostname === "localhost" || parsed.hostname === "127.0.0.1") {
|
|
63
|
+
return options.normalizeRoute(parsed.pathname.split("?")[0]);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
return options.normalizeRoute(literal.split("?")[0]);
|
|
72
|
+
}
|
|
73
|
+
function resolveHttpRequestCall(callExpression, options) {
|
|
74
|
+
const callee = callExpression.expression;
|
|
75
|
+
if (ts.isIdentifier(callee)) {
|
|
76
|
+
if (callee.text === "fetch") {
|
|
77
|
+
const path = extractRouteLiteral(callExpression.arguments[0], options);
|
|
78
|
+
if (!path || !path.startsWith("/api/"))
|
|
79
|
+
return null;
|
|
80
|
+
return {
|
|
81
|
+
method: extractFetchMethod(callExpression.arguments[1], options) || "GET",
|
|
82
|
+
path,
|
|
83
|
+
confidence: "high",
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
const method = HTTP_WRAPPER_METHODS[callee.text];
|
|
87
|
+
if (method) {
|
|
88
|
+
const path = extractRouteLiteral(callExpression.arguments[0], options);
|
|
89
|
+
if (!path || !path.startsWith("/api/"))
|
|
90
|
+
return null;
|
|
91
|
+
return { method, path, confidence: "high" };
|
|
92
|
+
}
|
|
93
|
+
if (callee.text === "rawReq") {
|
|
94
|
+
const methodLiteral = extractStringLiteral(callExpression.arguments[0], options);
|
|
95
|
+
const path = extractRouteLiteral(callExpression.arguments[1], options);
|
|
96
|
+
if (!methodLiteral || !path)
|
|
97
|
+
return null;
|
|
98
|
+
return { method: methodLiteral.toUpperCase(), path, confidence: "high" };
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
if (ts.isPropertyAccessExpression(callee) && callee.name.text === "rawReq") {
|
|
102
|
+
const methodLiteral = extractStringLiteral(callExpression.arguments[0], options);
|
|
103
|
+
const path = extractRouteLiteral(callExpression.arguments[1], options);
|
|
104
|
+
if (!methodLiteral || !path)
|
|
105
|
+
return null;
|
|
106
|
+
return { method: methodLiteral.toUpperCase(), path, confidence: "high" };
|
|
107
|
+
}
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
function extractFetchMethod(node, options) {
|
|
111
|
+
if (!node || !ts.isObjectLiteralExpression(node))
|
|
112
|
+
return null;
|
|
113
|
+
for (const property of node.properties) {
|
|
114
|
+
if (!ts.isPropertyAssignment(property))
|
|
115
|
+
continue;
|
|
116
|
+
if (property.name.getText() !== "method")
|
|
117
|
+
continue;
|
|
118
|
+
const value = extractStringLiteral(property.initializer, options);
|
|
119
|
+
return value ? value.toUpperCase() : null;
|
|
120
|
+
}
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
function dedupeRequests(requests) {
|
|
124
|
+
const seen = new Set();
|
|
125
|
+
return requests.filter((entry) => {
|
|
126
|
+
const key = `${entry.method}:${entry.path}`;
|
|
127
|
+
if (seen.has(key))
|
|
128
|
+
return false;
|
|
129
|
+
seen.add(key);
|
|
130
|
+
return true;
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
function defaultNormalizeRoute(value) {
|
|
134
|
+
const trimmed = String(value || "/").trim();
|
|
135
|
+
if (!trimmed || trimmed === "/")
|
|
136
|
+
return "/";
|
|
137
|
+
const withLeadingSlash = trimmed.startsWith("/") ? trimmed : `/${trimmed}`;
|
|
138
|
+
return withLeadingSlash.length > 1 ? withLeadingSlash.replace(/\/+$/u, "") : withLeadingSlash;
|
|
139
|
+
}
|
|
140
|
+
//# sourceMappingURL=requests.js.map
|
|
@@ -0,0 +1 @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