funkscript 0.2.4 → 0.2.7
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/README.md +23 -5
- package/dist/ast/types.d.ts.map +1 -1
- package/dist/ast/types.js.map +1 -1
- package/dist/ast/walk.d.ts.map +1 -1
- package/dist/ast/walk.js.map +1 -1
- package/dist/cli/build-bun.d.ts.map +1 -1
- package/dist/cli/build-bun.js.map +1 -1
- package/dist/cli/build-watch.d.ts.map +1 -1
- package/dist/cli/build-watch.js +9 -27
- package/dist/cli/build-watch.js.map +1 -1
- package/dist/cli/build.d.ts +1 -1
- package/dist/cli/build.d.ts.map +1 -1
- package/dist/cli/build.js +3 -58
- package/dist/cli/build.js.map +1 -1
- package/dist/cli/check-policy.d.ts +9 -0
- package/dist/cli/check-policy.d.ts.map +1 -0
- package/dist/cli/check-policy.js +39 -0
- package/dist/cli/check-policy.js.map +1 -0
- package/dist/cli/check.d.ts.map +1 -1
- package/dist/cli/check.js +16 -30
- package/dist/cli/check.js.map +1 -1
- package/dist/cli/commands.d.ts.map +1 -1
- package/dist/cli/commands.js +11 -0
- package/dist/cli/commands.js.map +1 -1
- package/dist/cli/doc.d.ts.map +1 -1
- package/dist/cli/doc.js.map +1 -1
- package/dist/cli/doctor.d.ts.map +1 -1
- package/dist/cli/doctor.js +5 -7
- package/dist/cli/doctor.js.map +1 -1
- package/dist/cli/emit.d.ts +1 -1
- package/dist/cli/emit.d.ts.map +1 -1
- package/dist/cli/emit.js.map +1 -1
- package/dist/cli/explain.d.ts.map +1 -1
- package/dist/cli/explain.js.map +1 -1
- package/dist/cli/fmt.d.ts.map +1 -1
- package/dist/cli/fmt.js.map +1 -1
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +3 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/init.d.ts +1 -1
- package/dist/cli/init.d.ts.map +1 -1
- package/dist/cli/init.js +66 -21
- package/dist/cli/init.js.map +1 -1
- package/dist/cli/io.d.ts.map +1 -1
- package/dist/cli/io.js.map +1 -1
- package/dist/cli/pipeline-style.d.ts.map +1 -1
- package/dist/cli/pipeline-style.js.map +1 -1
- package/dist/cli/query.d.ts +3 -0
- package/dist/cli/query.d.ts.map +1 -0
- package/dist/cli/query.js +152 -0
- package/dist/cli/query.js.map +1 -0
- package/dist/cli/repl.d.ts.map +1 -1
- package/dist/cli/repl.js.map +1 -1
- package/dist/cli/run.d.ts.map +1 -1
- package/dist/cli/run.js +2 -29
- package/dist/cli/run.js.map +1 -1
- package/dist/cli/test.d.ts +1 -1
- package/dist/cli/test.d.ts.map +1 -1
- package/dist/cli/test.js.map +1 -1
- package/dist/cli/tsc.d.ts.map +1 -1
- package/dist/cli/tsc.js +6 -8
- package/dist/cli/tsc.js.map +1 -1
- package/dist/cli/typecheck.d.ts.map +1 -1
- package/dist/cli/typecheck.js.map +1 -1
- package/dist/compiler/ast-inspection.d.ts.map +1 -1
- package/dist/compiler/ast-inspection.js.map +1 -1
- package/dist/compiler/boolean-operators.d.ts.map +1 -1
- package/dist/compiler/boolean-operators.js +12 -2
- package/dist/compiler/boolean-operators.js.map +1 -1
- package/dist/compiler/check.d.ts.map +1 -1
- package/dist/compiler/check.js +113 -131
- package/dist/compiler/check.js.map +1 -1
- package/dist/compiler/diagnostics-json.d.ts +73 -0
- package/dist/compiler/diagnostics-json.d.ts.map +1 -0
- package/dist/compiler/diagnostics-json.js +957 -0
- package/dist/compiler/diagnostics-json.js.map +1 -0
- package/dist/compiler/diagnostics.d.ts.map +1 -1
- package/dist/compiler/diagnostics.js.map +1 -1
- package/dist/compiler/effect-mutation-rule.d.ts.map +1 -1
- package/dist/compiler/effect-mutation-rule.js.map +1 -1
- package/dist/compiler/entry-rules.d.ts.map +1 -1
- package/dist/compiler/entry-rules.js.map +1 -1
- package/dist/compiler/escape-audit.d.ts +46 -0
- package/dist/compiler/escape-audit.d.ts.map +1 -0
- package/dist/compiler/escape-audit.js +682 -0
- package/dist/compiler/escape-audit.js.map +1 -0
- package/dist/compiler/incremental-build.d.ts.map +1 -1
- package/dist/compiler/incremental-build.js.map +1 -1
- package/dist/compiler/incremental-dependencies.d.ts.map +1 -1
- package/dist/compiler/incremental-dependencies.js.map +1 -1
- package/dist/compiler/js-interop-nullability.d.ts.map +1 -1
- package/dist/compiler/js-interop-nullability.js.map +1 -1
- package/dist/compiler/modules/output-collisions.d.ts.map +1 -1
- package/dist/compiler/modules/output-collisions.js.map +1 -1
- package/dist/compiler/modules/output-plan.d.ts.map +1 -1
- package/dist/compiler/modules/output-plan.js +10 -5
- package/dist/compiler/modules/output-plan.js.map +1 -1
- package/dist/compiler/modules/resolution.d.ts.map +1 -1
- package/dist/compiler/modules/resolution.js +2 -1
- package/dist/compiler/modules/resolution.js.map +1 -1
- package/dist/compiler/modules/source-files.d.ts +5 -0
- package/dist/compiler/modules/source-files.d.ts.map +1 -0
- package/dist/compiler/modules/source-files.js +13 -0
- package/dist/compiler/modules/source-files.js.map +1 -0
- package/dist/compiler/numeric-comparisons.d.ts.map +1 -1
- package/dist/compiler/numeric-comparisons.js +13 -7
- package/dist/compiler/numeric-comparisons.js.map +1 -1
- package/dist/compiler/optional-arguments.d.ts.map +1 -1
- package/dist/compiler/optional-arguments.js.map +1 -1
- package/dist/compiler/package-fingerprint.d.ts.map +1 -1
- package/dist/compiler/package-fingerprint.js.map +1 -1
- package/dist/compiler/package-record-contracts.d.ts.map +1 -1
- package/dist/compiler/package-record-contracts.js.map +1 -1
- package/dist/compiler/pipelines/catalog.d.ts.map +1 -1
- package/dist/compiler/pipelines/catalog.js.map +1 -1
- package/dist/compiler/pipelines/companions.d.ts.map +1 -1
- package/dist/compiler/pipelines/companions.js.map +1 -1
- package/dist/compiler/pipelines/resolution.d.ts.map +1 -1
- package/dist/compiler/pipelines/resolution.js +24 -23
- package/dist/compiler/pipelines/resolution.js.map +1 -1
- package/dist/compiler/project-config.d.ts.map +1 -1
- package/dist/compiler/project-config.js +29 -19
- package/dist/compiler/project-config.js.map +1 -1
- package/dist/compiler/query.d.ts +53 -0
- package/dist/compiler/query.d.ts.map +1 -0
- package/dist/compiler/query.js +781 -0
- package/dist/compiler/query.js.map +1 -0
- package/dist/compiler/record-contracts.d.ts.map +1 -1
- package/dist/compiler/record-contracts.js.map +1 -1
- package/dist/compiler/rules/control-flow.d.ts.map +1 -1
- package/dist/compiler/rules/control-flow.js.map +1 -1
- package/dist/compiler/rules/diagnostic.d.ts.map +1 -1
- package/dist/compiler/rules/diagnostic.js.map +1 -1
- package/dist/compiler/rules/module-scope-refs.d.ts.map +1 -1
- package/dist/compiler/rules/module-scope-refs.js.map +1 -1
- package/dist/compiler/rules/resource-escape.d.ts +7 -0
- package/dist/compiler/rules/resource-escape.d.ts.map +1 -0
- package/dist/compiler/rules/resource-escape.js +146 -0
- package/dist/compiler/rules/resource-escape.js.map +1 -0
- package/dist/compiler/rules/resource-providers.d.ts +19 -0
- package/dist/compiler/rules/resource-providers.d.ts.map +1 -0
- package/dist/compiler/rules/resource-providers.js +222 -0
- package/dist/compiler/rules/resource-providers.js.map +1 -0
- package/dist/compiler/schemas/analysis.d.ts.map +1 -1
- package/dist/compiler/schemas/analysis.js.map +1 -1
- package/dist/compiler/schemas/imported-record-functions.d.ts.map +1 -1
- package/dist/compiler/schemas/imported-record-functions.js.map +1 -1
- package/dist/compiler/schemas/imported-schemas.d.ts.map +1 -1
- package/dist/compiler/schemas/imported-schemas.js.map +1 -1
- package/dist/compiler/source-map.d.ts.map +1 -1
- package/dist/compiler/source-map.js +2 -7
- package/dist/compiler/source-map.js.map +1 -1
- package/dist/compiler/type-view-paths.d.ts +6 -0
- package/dist/compiler/type-view-paths.d.ts.map +1 -0
- package/dist/compiler/type-view-paths.js +12 -0
- package/dist/compiler/type-view-paths.js.map +1 -0
- package/dist/compiler/typescript-context.d.ts.map +1 -1
- package/dist/compiler/typescript-context.js +5 -7
- package/dist/compiler/typescript-context.js.map +1 -1
- package/dist/compiler.d.ts.map +1 -1
- package/dist/compiler.js.map +1 -1
- package/dist/emitter/assemblyscript.d.ts.map +1 -1
- package/dist/emitter/assemblyscript.js +120 -136
- package/dist/emitter/assemblyscript.js.map +1 -1
- package/dist/emitter/declarations.d.ts.map +1 -1
- package/dist/emitter/declarations.js.map +1 -1
- package/dist/emitter/emitter.d.ts +3 -1
- package/dist/emitter/emitter.d.ts.map +1 -1
- package/dist/emitter/emitter.js +10 -1
- package/dist/emitter/emitter.js.map +1 -1
- package/dist/emitter/imports.d.ts.map +1 -1
- package/dist/emitter/imports.js.map +1 -1
- package/dist/emitter/indent.d.ts.map +1 -1
- package/dist/emitter/indent.js.map +1 -1
- package/dist/emitter/jsx.d.ts.map +1 -1
- package/dist/emitter/jsx.js.map +1 -1
- package/dist/emitter/local-bindings.d.ts.map +1 -1
- package/dist/emitter/local-bindings.js.map +1 -1
- package/dist/emitter/match.d.ts.map +1 -1
- package/dist/emitter/match.js.map +1 -1
- package/dist/emitter/runtime-helpers.d.ts.map +1 -1
- package/dist/emitter/runtime-helpers.js.map +1 -1
- package/dist/emitter/schemas.d.ts.map +1 -1
- package/dist/emitter/schemas.js.map +1 -1
- package/dist/emitter/statements.d.ts +1 -0
- package/dist/emitter/statements.d.ts.map +1 -1
- package/dist/emitter/statements.js +1 -0
- package/dist/emitter/statements.js.map +1 -1
- package/dist/emitter/tagged-match.d.ts.map +1 -1
- package/dist/emitter/tagged-match.js.map +1 -1
- package/dist/emitter/types.d.ts.map +1 -1
- package/dist/emitter/types.js.map +1 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js.map +1 -1
- package/dist/formatter/comments.d.ts.map +1 -1
- package/dist/formatter/comments.js +13 -0
- package/dist/formatter/comments.js.map +1 -1
- package/dist/formatter/index.d.ts +9 -0
- package/dist/formatter/index.d.ts.map +1 -1
- package/dist/formatter/index.js +215 -5
- package/dist/formatter/index.js.map +1 -1
- package/dist/formatter/operator-precedence.d.ts.map +1 -1
- package/dist/formatter/operator-precedence.js.map +1 -1
- package/dist/formatter/prettier.d.ts.map +1 -1
- package/dist/formatter/prettier.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/interop/callback.d.ts.map +1 -1
- package/dist/interop/callback.js.map +1 -1
- package/dist/interop/js.d.ts.map +1 -1
- package/dist/interop/js.js.map +1 -1
- package/dist/interop/record.d.ts.map +1 -1
- package/dist/interop/record.js.map +1 -1
- package/dist/interop/valibot.d.ts.map +1 -1
- package/dist/interop/valibot.js.map +1 -1
- package/dist/interop/zod.d.ts.map +1 -1
- package/dist/interop/zod.js.map +1 -1
- package/dist/lexer/lexer.d.ts +1 -0
- package/dist/lexer/lexer.d.ts.map +1 -1
- package/dist/lexer/lexer.js +26 -10
- package/dist/lexer/lexer.js.map +1 -1
- package/dist/lexer/tokens.d.ts.map +1 -1
- package/dist/lexer/tokens.js.map +1 -1
- package/dist/lsp/code-action-worker.d.ts.map +1 -1
- package/dist/lsp/code-action-worker.js.map +1 -1
- package/dist/lsp/completion.d.ts +25 -0
- package/dist/lsp/completion.d.ts.map +1 -1
- package/dist/lsp/completion.js +1114 -51
- package/dist/lsp/completion.js.map +1 -1
- package/dist/lsp/definition.d.ts +2 -0
- package/dist/lsp/definition.d.ts.map +1 -1
- package/dist/lsp/definition.js +52 -58
- package/dist/lsp/definition.js.map +1 -1
- package/dist/lsp/diagnostics-worker.d.ts.map +1 -1
- package/dist/lsp/diagnostics-worker.js +1 -1
- package/dist/lsp/diagnostics-worker.js.map +1 -1
- package/dist/lsp/docs.d.ts +1 -1
- package/dist/lsp/docs.d.ts.map +1 -1
- package/dist/lsp/docs.js +4 -3
- package/dist/lsp/docs.js.map +1 -1
- package/dist/lsp/error-channel.d.ts.map +1 -1
- package/dist/lsp/error-channel.js.map +1 -1
- package/dist/lsp/hover.d.ts +5 -1
- package/dist/lsp/hover.d.ts.map +1 -1
- package/dist/lsp/hover.js +1016 -46
- package/dist/lsp/hover.js.map +1 -1
- package/dist/lsp/imports.d.ts +2 -0
- package/dist/lsp/imports.d.ts.map +1 -1
- package/dist/lsp/imports.js +45 -21
- package/dist/lsp/imports.js.map +1 -1
- package/dist/lsp/index.d.ts.map +1 -1
- package/dist/lsp/index.js.map +1 -1
- package/dist/lsp/inlay-hints.d.ts.map +1 -1
- package/dist/lsp/inlay-hints.js.map +1 -1
- package/dist/lsp/interop-rename.d.ts.map +1 -1
- package/dist/lsp/interop-rename.js.map +1 -1
- package/dist/lsp/match-arms.d.ts.map +1 -1
- package/dist/lsp/match-arms.js.map +1 -1
- package/dist/lsp/navigation.d.ts +1 -1
- package/dist/lsp/navigation.d.ts.map +1 -1
- package/dist/lsp/navigation.js +30 -12
- package/dist/lsp/navigation.js.map +1 -1
- package/dist/lsp/parsed-documents.d.ts.map +1 -1
- package/dist/lsp/parsed-documents.js.map +1 -1
- package/dist/lsp/range-format.d.ts +4 -0
- package/dist/lsp/range-format.d.ts.map +1 -0
- package/dist/lsp/range-format.js +88 -0
- package/dist/lsp/range-format.js.map +1 -0
- package/dist/lsp/rename-worker.d.ts.map +1 -1
- package/dist/lsp/rename-worker.js.map +1 -1
- package/dist/lsp/schema-import-hover.d.ts +8 -0
- package/dist/lsp/schema-import-hover.d.ts.map +1 -0
- package/dist/lsp/schema-import-hover.js +52 -0
- package/dist/lsp/schema-import-hover.js.map +1 -0
- package/dist/lsp/server.d.ts +3 -1
- package/dist/lsp/server.d.ts.map +1 -1
- package/dist/lsp/server.js +73 -48
- package/dist/lsp/server.js.map +1 -1
- package/dist/lsp/signature-help.d.ts +6 -0
- package/dist/lsp/signature-help.d.ts.map +1 -0
- package/dist/lsp/signature-help.js +183 -0
- package/dist/lsp/signature-help.js.map +1 -0
- package/dist/lsp/thunk-pipeline.d.ts.map +1 -1
- package/dist/lsp/thunk-pipeline.js.map +1 -1
- package/dist/lsp/validation.d.ts.map +1 -1
- package/dist/lsp/validation.js +3 -2
- package/dist/lsp/validation.js.map +1 -1
- package/dist/lsp/workspace.d.ts +3 -1
- package/dist/lsp/workspace.d.ts.map +1 -1
- package/dist/lsp/workspace.js +66 -10
- package/dist/lsp/workspace.js.map +1 -1
- package/dist/parser/declarations.d.ts.map +1 -1
- package/dist/parser/declarations.js +22 -1
- package/dist/parser/declarations.js.map +1 -1
- package/dist/parser/errors.d.ts.map +1 -1
- package/dist/parser/errors.js.map +1 -1
- package/dist/parser/jsx.d.ts.map +1 -1
- package/dist/parser/jsx.js.map +1 -1
- package/dist/parser/operator-expressions.d.ts.map +1 -1
- package/dist/parser/operator-expressions.js.map +1 -1
- package/dist/parser/parser.d.ts.map +1 -1
- package/dist/parser/parser.js.map +1 -1
- package/dist/parser/patterns.d.ts.map +1 -1
- package/dist/parser/patterns.js.map +1 -1
- package/dist/parser/pipeline-expressions.d.ts.map +1 -1
- package/dist/parser/pipeline-expressions.js.map +1 -1
- package/dist/parser/scope.d.ts.map +1 -1
- package/dist/parser/scope.js.map +1 -1
- package/dist/parser/statements.d.ts.map +1 -1
- package/dist/parser/statements.js.map +1 -1
- package/dist/parser/types.d.ts.map +1 -1
- package/dist/parser/types.js.map +1 -1
- package/dist/plugins/bun-preload.d.ts.map +1 -1
- package/dist/plugins/bun-preload.js.map +1 -1
- package/dist/plugins/bun.d.ts +2 -18
- package/dist/plugins/bun.d.ts.map +1 -1
- package/dist/plugins/bun.js +5 -30
- package/dist/plugins/bun.js.map +1 -1
- package/dist/plugins/esbuild.d.ts +1 -1
- package/dist/plugins/esbuild.d.ts.map +1 -1
- package/dist/plugins/esbuild.js +10 -36
- package/dist/plugins/esbuild.js.map +1 -1
- package/dist/plugins/server-boundary.d.ts +14 -0
- package/dist/plugins/server-boundary.d.ts.map +1 -0
- package/dist/plugins/server-boundary.js +25 -0
- package/dist/plugins/server-boundary.js.map +1 -0
- package/dist/plugins/type-view.d.ts.map +1 -1
- package/dist/plugins/type-view.js +5 -3
- package/dist/plugins/type-view.js.map +1 -1
- package/dist/plugins/vite.d.ts +2 -18
- package/dist/plugins/vite.d.ts.map +1 -1
- package/dist/plugins/vite.js +4 -29
- package/dist/plugins/vite.js.map +1 -1
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js.map +1 -1
- package/dist/tooling/doc.d.ts.map +1 -1
- package/dist/tooling/doc.js.map +1 -1
- package/dist/tooling/idiomatic.d.ts.map +1 -1
- package/dist/tooling/idiomatic.js.map +1 -1
- package/dist/tooling/pipeline-style.d.ts.map +1 -1
- package/dist/tooling/pipeline-style.js.map +1 -1
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +13 -6
- package/src/cli/build-watch.ts +10 -29
- package/src/cli/build.ts +9 -60
- package/src/cli/check-policy.ts +54 -0
- package/src/cli/check.ts +19 -31
- package/src/cli/commands.ts +13 -0
- package/src/cli/doctor.ts +10 -7
- package/src/cli/index.ts +3 -0
- package/src/cli/init.ts +66 -21
- package/src/cli/query.ts +191 -0
- package/src/cli/run.ts +5 -30
- package/src/cli/tsc.ts +10 -8
- package/src/compiler/boolean-operators.ts +11 -2
- package/src/compiler/check.ts +152 -180
- package/src/compiler/diagnostics-json.ts +1205 -0
- package/src/compiler/escape-audit.ts +913 -0
- package/src/compiler/modules/output-plan.ts +11 -9
- package/src/compiler/modules/resolution.ts +2 -1
- package/src/compiler/modules/source-files.ts +13 -0
- package/src/compiler/numeric-comparisons.ts +14 -8
- package/src/compiler/pipelines/resolution.ts +30 -26
- package/src/compiler/project-config.ts +30 -19
- package/src/compiler/query.ts +1177 -0
- package/src/compiler/rules/resource-escape.ts +223 -0
- package/src/compiler/rules/resource-providers.ts +293 -0
- package/src/compiler/source-map.ts +3 -7
- package/src/compiler/type-view-paths.ts +10 -0
- package/src/compiler/typescript-context.ts +6 -7
- package/src/emitter/assemblyscript.ts +101 -147
- package/src/emitter/emitter.ts +13 -1
- package/src/emitter/statements.ts +2 -0
- package/src/formatter/comments.ts +14 -0
- package/src/formatter/index.ts +299 -4
- package/src/index.ts +3 -0
- package/src/lexer/lexer.ts +39 -20
- package/src/lsp/completion.ts +1452 -66
- package/src/lsp/definition.ts +50 -58
- package/src/lsp/diagnostics-worker.ts +1 -4
- package/src/lsp/docs.ts +4 -3
- package/src/lsp/hover.ts +1465 -44
- package/src/lsp/imports.ts +75 -22
- package/src/lsp/navigation.ts +41 -22
- package/src/lsp/range-format.ts +102 -0
- package/src/lsp/schema-import-hover.ts +76 -0
- package/src/lsp/server.ts +99 -69
- package/src/lsp/signature-help.ts +226 -0
- package/src/lsp/validation.ts +3 -2
- package/src/lsp/workspace.ts +63 -9
- package/src/parser/declarations.ts +27 -1
- package/src/plugins/bun.ts +14 -66
- package/src/plugins/esbuild.ts +16 -55
- package/src/plugins/server-boundary.ts +41 -0
- package/src/plugins/type-view.ts +11 -3
- package/src/plugins/vite.ts +12 -62
- package/dist/Widget.tsx +0 -9
- package/dist/cli/output-collisions.d.ts +0 -2
- package/dist/cli/output-collisions.d.ts.map +0 -1
- package/dist/cli/output-collisions.js +0 -39
- package/dist/cli/output-collisions.js.map +0 -1
- package/dist/compiler/imported-record-functions.d.ts +0 -4
- package/dist/compiler/imported-record-functions.d.ts.map +0 -1
- package/dist/compiler/imported-record-functions.js +0 -706
- package/dist/compiler/imported-record-functions.js.map +0 -1
- package/dist/compiler/imported-schemas.d.ts +0 -21
- package/dist/compiler/imported-schemas.d.ts.map +0 -1
- package/dist/compiler/imported-schemas.js +0 -461
- package/dist/compiler/imported-schemas.js.map +0 -1
- package/dist/compiler/module-resolution.d.ts +0 -6
- package/dist/compiler/module-resolution.d.ts.map +0 -1
- package/dist/compiler/module-resolution.js +0 -44
- package/dist/compiler/module-resolution.js.map +0 -1
- package/dist/compiler/pipeline-companions.d.ts +0 -18
- package/dist/compiler/pipeline-companions.d.ts.map +0 -1
- package/dist/compiler/pipeline-companions.js +0 -1042
- package/dist/compiler/pipeline-companions.js.map +0 -1
- package/dist/compiler/providers.d.ts +0 -4
- package/dist/compiler/providers.d.ts.map +0 -1
- package/dist/compiler/providers.js +0 -101
- package/dist/compiler/providers.js.map +0 -1
- package/dist/emitter/pipeline-catalog.d.ts +0 -15
- package/dist/emitter/pipeline-catalog.d.ts.map +0 -1
- package/dist/emitter/pipeline-catalog.js +0 -55
- package/dist/emitter/pipeline-catalog.js.map +0 -1
- package/dist/emitter/pipeline-resolution.d.ts +0 -38
- package/dist/emitter/pipeline-resolution.d.ts.map +0 -1
- package/dist/emitter/pipeline-resolution.js +0 -571
- package/dist/emitter/pipeline-resolution.js.map +0 -1
- package/dist/interop/index.d.ts +0 -6
- package/dist/interop/index.d.ts.map +0 -1
- package/dist/interop/index.js +0 -6
- package/dist/interop/index.js.map +0 -1
- package/dist/math.ts +0 -1
- package/dist/parser/index.d.ts +0 -9
- package/dist/parser/index.d.ts.map +0 -1
- package/dist/parser/index.js +0 -9
- package/dist/parser/index.js.map +0 -1
- package/dist/service.ts +0 -3
- package/dist/service.ts.map +0 -1
- package/dist/tooling/migrate.d.ts +0 -62
- package/dist/tooling/migrate.d.ts.map +0 -1
- package/dist/tooling/migrate.js +0 -608
- package/dist/tooling/migrate.js.map +0 -1
|
@@ -0,0 +1,682 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import * as fs from "node:fs/promises";
|
|
3
|
+
import * as path from "node:path";
|
|
4
|
+
import { Lexer } from "../lexer/lexer.js";
|
|
5
|
+
import { Parser } from "../parser/parser.js";
|
|
6
|
+
const MAX_SNIPPET_LENGTH = 120;
|
|
7
|
+
function emptyCounts() {
|
|
8
|
+
return {
|
|
9
|
+
rawTs: 0,
|
|
10
|
+
jsInterop: 0,
|
|
11
|
+
wildcardMatch: 0,
|
|
12
|
+
typedHole: 0,
|
|
13
|
+
total: 0,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function incrementCounts(counts, kind) {
|
|
17
|
+
counts.total += 1;
|
|
18
|
+
switch (kind) {
|
|
19
|
+
case "raw-ts":
|
|
20
|
+
counts.rawTs += 1;
|
|
21
|
+
break;
|
|
22
|
+
case "js-interop":
|
|
23
|
+
counts.jsInterop += 1;
|
|
24
|
+
break;
|
|
25
|
+
case "wildcard-match":
|
|
26
|
+
counts.wildcardMatch += 1;
|
|
27
|
+
break;
|
|
28
|
+
case "typed-hole":
|
|
29
|
+
counts.typedHole += 1;
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function mergeCounts(target, addition) {
|
|
34
|
+
target.rawTs += addition.rawTs;
|
|
35
|
+
target.jsInterop += addition.jsInterop;
|
|
36
|
+
target.wildcardMatch += addition.wildcardMatch;
|
|
37
|
+
target.typedHole += addition.typedHole;
|
|
38
|
+
target.total += addition.total;
|
|
39
|
+
}
|
|
40
|
+
function truncateSnippet(text) {
|
|
41
|
+
const normalized = text.trim();
|
|
42
|
+
if (normalized.length <= MAX_SNIPPET_LENGTH) {
|
|
43
|
+
return normalized;
|
|
44
|
+
}
|
|
45
|
+
return `${normalized.slice(0, MAX_SNIPPET_LENGTH - 3)}...`;
|
|
46
|
+
}
|
|
47
|
+
function extractLineSnippet(sourceLines, span) {
|
|
48
|
+
const lineText = sourceLines[span.start.line - 1] ?? "";
|
|
49
|
+
return truncateSnippet(lineText);
|
|
50
|
+
}
|
|
51
|
+
function extractSpanSnippet(source, sourceLines, span, fallback) {
|
|
52
|
+
const start = span.start.offset;
|
|
53
|
+
const end = span.end.offset;
|
|
54
|
+
if (start >= 0 && end > start && end <= source.length) {
|
|
55
|
+
const raw = source.slice(start, end);
|
|
56
|
+
const firstLine = raw.split(/\r?\n/)[0]?.trim() ?? "";
|
|
57
|
+
if (firstLine.length > 0) {
|
|
58
|
+
return truncateSnippet(firstLine);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
const lineText = extractLineSnippet(sourceLines, span);
|
|
62
|
+
return lineText.length > 0 ? lineText : truncateSnippet(fallback);
|
|
63
|
+
}
|
|
64
|
+
function isWildcardArmPattern(pattern) {
|
|
65
|
+
if (pattern.kind === "WildcardPattern") {
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
if (pattern.kind === "OrPattern") {
|
|
69
|
+
return pattern.patterns.some((part) => isWildcardArmPattern(part));
|
|
70
|
+
}
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
function collectBindingTargetNames(target) {
|
|
74
|
+
switch (target.kind) {
|
|
75
|
+
case "Identifier":
|
|
76
|
+
case "UpperIdentifier":
|
|
77
|
+
return [target.name];
|
|
78
|
+
case "VariablePattern":
|
|
79
|
+
return [target.name.name];
|
|
80
|
+
case "RestPattern":
|
|
81
|
+
return collectBindingTargetNames(target.argument);
|
|
82
|
+
case "RecordPattern":
|
|
83
|
+
return target.fields.flatMap((field) => field.pattern
|
|
84
|
+
? collectBindingTargetNames(field.pattern)
|
|
85
|
+
: [field.key.name]);
|
|
86
|
+
case "ArrayPattern":
|
|
87
|
+
return target.elements.flatMap((elem) => collectBindingTargetNames(elem));
|
|
88
|
+
case "OrPattern":
|
|
89
|
+
return target.patterns.flatMap((part) => collectBindingTargetNames(part));
|
|
90
|
+
case "WildcardPattern":
|
|
91
|
+
case "LiteralPattern":
|
|
92
|
+
case "ConstructorPattern":
|
|
93
|
+
return [];
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
function formatBindingDeclarationName(target) {
|
|
97
|
+
if (target.kind === "Identifier" || target.kind === "UpperIdentifier") {
|
|
98
|
+
return target.name;
|
|
99
|
+
}
|
|
100
|
+
const names = collectBindingTargetNames(target);
|
|
101
|
+
return names.length > 0 ? names.join(", ") : undefined;
|
|
102
|
+
}
|
|
103
|
+
class EscapeAuditVisitor {
|
|
104
|
+
source;
|
|
105
|
+
filename;
|
|
106
|
+
findings = [];
|
|
107
|
+
sourceLines;
|
|
108
|
+
constructor(source, filename) {
|
|
109
|
+
this.source = source;
|
|
110
|
+
this.filename = filename;
|
|
111
|
+
this.sourceLines = source.split(/\r?\n/);
|
|
112
|
+
}
|
|
113
|
+
visitProgram(program) {
|
|
114
|
+
for (const decl of program.body) {
|
|
115
|
+
this.visitTopLevelDeclaration(decl, undefined);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
addFinding(kind, span, declaration, snippet) {
|
|
119
|
+
const finding = {
|
|
120
|
+
kind,
|
|
121
|
+
file: this.filename,
|
|
122
|
+
line: span.start.line,
|
|
123
|
+
column: span.start.column,
|
|
124
|
+
snippet,
|
|
125
|
+
};
|
|
126
|
+
if (declaration !== undefined) {
|
|
127
|
+
finding.declaration = declaration;
|
|
128
|
+
}
|
|
129
|
+
this.findings.push(finding);
|
|
130
|
+
}
|
|
131
|
+
visitTopLevelDeclaration(decl, declaration) {
|
|
132
|
+
switch (decl.kind) {
|
|
133
|
+
case "ImportDeclaration":
|
|
134
|
+
case "ExportFromDeclaration":
|
|
135
|
+
case "AsDeclaration":
|
|
136
|
+
return;
|
|
137
|
+
case "ExportDeclaration":
|
|
138
|
+
this.visitTopLevelDeclaration(decl.declaration, declaration);
|
|
139
|
+
return;
|
|
140
|
+
case "ExportDefaultDeclaration":
|
|
141
|
+
this.visitExpression(decl.expression, declaration);
|
|
142
|
+
return;
|
|
143
|
+
case "TsEscapeDeclaration":
|
|
144
|
+
this.addFinding("raw-ts", decl.span, declaration, extractSpanSnippet(this.source, this.sourceLines, decl.span, `ts { ${decl.code.trim()} }`));
|
|
145
|
+
return;
|
|
146
|
+
case "SchemaDeclaration": {
|
|
147
|
+
const declName = decl.id.name;
|
|
148
|
+
this.visitSchemaBody(decl.body, declName);
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
case "ErrorDeclaration": {
|
|
152
|
+
const declName = decl.id.name;
|
|
153
|
+
for (const field of decl.fields) {
|
|
154
|
+
this.visitTypeNode(field.typeAnnotation, declName);
|
|
155
|
+
}
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
case "ServiceDeclaration": {
|
|
159
|
+
const declName = decl.id.name;
|
|
160
|
+
for (const member of decl.members) {
|
|
161
|
+
this.visitTypeNode(member.signature, declName);
|
|
162
|
+
}
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
case "BindingDeclaration":
|
|
166
|
+
this.visitBindingDeclaration(decl, declaration);
|
|
167
|
+
return;
|
|
168
|
+
case "WhenStatement":
|
|
169
|
+
this.visitExpression(decl.condition, declaration);
|
|
170
|
+
this.visitFunctionBody(decl.consequent, declaration);
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
visitBindingDeclaration(decl, enclosingDeclaration) {
|
|
175
|
+
const declName = formatBindingDeclarationName(decl.id) ?? enclosingDeclaration;
|
|
176
|
+
if (decl.isJs) {
|
|
177
|
+
this.addFinding("js-interop", decl.span, declName, extractLineSnippet(this.sourceLines, decl.span) ||
|
|
178
|
+
`js ${declName ?? "..."}`);
|
|
179
|
+
}
|
|
180
|
+
if (decl.typeAnnotation) {
|
|
181
|
+
this.visitTypeNode(decl.typeAnnotation, declName);
|
|
182
|
+
}
|
|
183
|
+
this.visitExpression(decl.init, declName);
|
|
184
|
+
}
|
|
185
|
+
visitSchemaBody(body, declaration) {
|
|
186
|
+
switch (body.kind) {
|
|
187
|
+
case "RecordSchema":
|
|
188
|
+
for (const field of body.fields) {
|
|
189
|
+
this.visitTypeNode(field.typeAnnotation, declaration);
|
|
190
|
+
if (field.refinement) {
|
|
191
|
+
this.visitExpression(field.refinement, declaration);
|
|
192
|
+
}
|
|
193
|
+
if (field.defaultValue) {
|
|
194
|
+
this.visitExpression(field.defaultValue, declaration);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
return;
|
|
198
|
+
case "TaggedUnionSchema":
|
|
199
|
+
for (const variant of body.variants) {
|
|
200
|
+
for (const field of variant.fields) {
|
|
201
|
+
this.visitTypeNode(field.typeAnnotation, declaration);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
return;
|
|
205
|
+
case "StructuralUnionSchema":
|
|
206
|
+
for (const member of body.members) {
|
|
207
|
+
this.visitTypeNode(member, declaration);
|
|
208
|
+
}
|
|
209
|
+
return;
|
|
210
|
+
case "RefinementSchema":
|
|
211
|
+
this.visitTypeNode(body.baseType, declaration);
|
|
212
|
+
this.visitExpression(body.refinement, declaration);
|
|
213
|
+
return;
|
|
214
|
+
case "TypeSignatureSchema":
|
|
215
|
+
this.visitTypeNode(body.signature, declaration);
|
|
216
|
+
return;
|
|
217
|
+
case "TsDerivedSchema":
|
|
218
|
+
this.visitTypeNode(body.targetType, declaration);
|
|
219
|
+
return;
|
|
220
|
+
case "ImportedTsSchema":
|
|
221
|
+
this.visitTypeNode(body.typeNode, declaration);
|
|
222
|
+
for (const arg of body.typeArgs) {
|
|
223
|
+
this.visitTypeNode(arg, declaration);
|
|
224
|
+
}
|
|
225
|
+
for (const arg of body.typeArguments) {
|
|
226
|
+
this.visitTypeNode(arg, declaration);
|
|
227
|
+
}
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
visitTypeNode(node, declaration) {
|
|
232
|
+
switch (node.kind) {
|
|
233
|
+
case "TsEscapeTypeNode":
|
|
234
|
+
this.addFinding("raw-ts", node.span, declaration, extractSpanSnippet(this.source, this.sourceLines, node.span, `ts { ${node.code.trim()} }`));
|
|
235
|
+
return;
|
|
236
|
+
case "TypeReferenceNode":
|
|
237
|
+
case "QualifiedTypeReferenceNode":
|
|
238
|
+
if (node.typeArgs) {
|
|
239
|
+
for (const arg of node.typeArgs) {
|
|
240
|
+
this.visitTypeNode(arg, declaration);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
return;
|
|
244
|
+
case "FunctionTypeNode":
|
|
245
|
+
if (node.typeParams) {
|
|
246
|
+
for (const tp of node.typeParams) {
|
|
247
|
+
if (tp.constraint) {
|
|
248
|
+
this.visitTypeNode(tp.constraint, declaration);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
for (const param of node.params) {
|
|
253
|
+
if (param.typeAnnotation) {
|
|
254
|
+
this.visitTypeNode(param.typeAnnotation, declaration);
|
|
255
|
+
}
|
|
256
|
+
if (param.defaultValue) {
|
|
257
|
+
this.visitExpression(param.defaultValue, declaration);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
this.visitTypeNode(node.returnType, declaration);
|
|
261
|
+
return;
|
|
262
|
+
case "EffectTypeNode":
|
|
263
|
+
this.visitTypeNode(node.success, declaration);
|
|
264
|
+
if (node.error) {
|
|
265
|
+
this.visitTypeNode(node.error, declaration);
|
|
266
|
+
}
|
|
267
|
+
if (node.requirements) {
|
|
268
|
+
this.visitTypeNode(node.requirements, declaration);
|
|
269
|
+
}
|
|
270
|
+
return;
|
|
271
|
+
case "RecordTypeNode":
|
|
272
|
+
for (const field of node.fields) {
|
|
273
|
+
this.visitTypeNode(field.typeAnnotation, declaration);
|
|
274
|
+
if (field.defaultValue) {
|
|
275
|
+
this.visitExpression(field.defaultValue, declaration);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
return;
|
|
279
|
+
case "ArrayTypeNode":
|
|
280
|
+
this.visitTypeNode(node.elementType, declaration);
|
|
281
|
+
return;
|
|
282
|
+
case "UnionTypeNode":
|
|
283
|
+
case "IntersectionTypeNode":
|
|
284
|
+
for (const member of node.types) {
|
|
285
|
+
this.visitTypeNode(member, declaration);
|
|
286
|
+
}
|
|
287
|
+
return;
|
|
288
|
+
case "TypeQueryNode":
|
|
289
|
+
this.visitExpression(node.expr, declaration);
|
|
290
|
+
return;
|
|
291
|
+
case "IndexedAccessTypeNode":
|
|
292
|
+
this.visitTypeNode(node.objectType, declaration);
|
|
293
|
+
this.visitTypeNode(node.indexType, declaration);
|
|
294
|
+
return;
|
|
295
|
+
case "ParenthesizedTypeNode":
|
|
296
|
+
this.visitTypeNode(node.typeNode, declaration);
|
|
297
|
+
return;
|
|
298
|
+
case "LiteralTypeNode":
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
visitFunctionBody(body, declaration) {
|
|
303
|
+
if (body.kind === "BlockStatement") {
|
|
304
|
+
this.visitBlockStatement(body, declaration);
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
this.visitExpression(body, declaration);
|
|
308
|
+
}
|
|
309
|
+
visitBlockStatement(block, declaration) {
|
|
310
|
+
for (const stmt of block.statements) {
|
|
311
|
+
this.visitStatement(stmt, declaration);
|
|
312
|
+
}
|
|
313
|
+
if (block.finalExpression) {
|
|
314
|
+
this.visitExpression(block.finalExpression, declaration);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
visitStatement(stmt, declaration) {
|
|
318
|
+
switch (stmt.kind) {
|
|
319
|
+
case "BindingDeclaration":
|
|
320
|
+
this.visitBindingDeclaration(stmt, declaration);
|
|
321
|
+
return;
|
|
322
|
+
case "AssignmentStatement":
|
|
323
|
+
if (stmt.target.kind === "IndexExpression") {
|
|
324
|
+
this.visitExpression(stmt.target, declaration);
|
|
325
|
+
}
|
|
326
|
+
this.visitExpression(stmt.value, declaration);
|
|
327
|
+
return;
|
|
328
|
+
case "ExpressionStatement":
|
|
329
|
+
this.visitExpression(stmt.expression, declaration);
|
|
330
|
+
return;
|
|
331
|
+
case "ReturnStatement":
|
|
332
|
+
this.visitExpression(stmt.argument, declaration);
|
|
333
|
+
return;
|
|
334
|
+
case "WhenStatement":
|
|
335
|
+
this.visitExpression(stmt.condition, declaration);
|
|
336
|
+
this.visitFunctionBody(stmt.consequent, declaration);
|
|
337
|
+
return;
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
visitEffectStatement(stmt, declaration) {
|
|
341
|
+
switch (stmt.kind) {
|
|
342
|
+
case "EffectBindStatement":
|
|
343
|
+
this.visitExpression(stmt.effect, declaration);
|
|
344
|
+
return;
|
|
345
|
+
case "EffectDiscardStatement":
|
|
346
|
+
this.visitExpression(stmt.effect, declaration);
|
|
347
|
+
return;
|
|
348
|
+
case "EffectControlFlowStatement":
|
|
349
|
+
this.visitExpression(stmt.statement, declaration);
|
|
350
|
+
return;
|
|
351
|
+
case "BindingDeclaration":
|
|
352
|
+
case "AssignmentStatement":
|
|
353
|
+
case "WhenStatement":
|
|
354
|
+
this.visitStatement(stmt, declaration);
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
visitMatchArm(arm, declaration) {
|
|
359
|
+
if (isWildcardArmPattern(arm.pattern)) {
|
|
360
|
+
this.addFinding("wildcard-match", arm.span, declaration, extractSpanSnippet(this.source, this.sourceLines, arm.span, "| _ => ..."));
|
|
361
|
+
}
|
|
362
|
+
this.visitPattern(arm.pattern, declaration);
|
|
363
|
+
if (arm.guard) {
|
|
364
|
+
this.visitExpression(arm.guard, declaration);
|
|
365
|
+
}
|
|
366
|
+
this.visitFunctionBody(arm.body, declaration);
|
|
367
|
+
}
|
|
368
|
+
visitPattern(pattern, declaration) {
|
|
369
|
+
switch (pattern.kind) {
|
|
370
|
+
case "WildcardPattern":
|
|
371
|
+
case "VariablePattern":
|
|
372
|
+
return;
|
|
373
|
+
case "LiteralPattern": {
|
|
374
|
+
const rawExpr = pattern.literal.rawExpr;
|
|
375
|
+
if (rawExpr) {
|
|
376
|
+
this.visitExpression(rawExpr, declaration);
|
|
377
|
+
}
|
|
378
|
+
else if (pattern.literal.kind === "StringLiteral") {
|
|
379
|
+
for (const part of pattern.literal.parts) {
|
|
380
|
+
if (part.kind === "StringInterpolationPart") {
|
|
381
|
+
this.visitExpression(part.expression, declaration);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
387
|
+
case "ConstructorPattern":
|
|
388
|
+
for (const arg of pattern.args) {
|
|
389
|
+
this.visitPattern(arg, declaration);
|
|
390
|
+
}
|
|
391
|
+
return;
|
|
392
|
+
case "RecordPattern":
|
|
393
|
+
for (const field of pattern.fields) {
|
|
394
|
+
if (field.pattern) {
|
|
395
|
+
this.visitPattern(field.pattern, declaration);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
return;
|
|
399
|
+
case "ArrayPattern":
|
|
400
|
+
for (const elem of pattern.elements) {
|
|
401
|
+
this.visitPattern(elem, declaration);
|
|
402
|
+
}
|
|
403
|
+
return;
|
|
404
|
+
case "RestPattern":
|
|
405
|
+
this.visitPattern(pattern.argument, declaration);
|
|
406
|
+
return;
|
|
407
|
+
case "OrPattern":
|
|
408
|
+
for (const part of pattern.patterns) {
|
|
409
|
+
this.visitPattern(part, declaration);
|
|
410
|
+
}
|
|
411
|
+
return;
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
visitJsxChild(child, declaration) {
|
|
415
|
+
switch (child.kind) {
|
|
416
|
+
case "JSXText":
|
|
417
|
+
return;
|
|
418
|
+
case "JSXExpressionContainer":
|
|
419
|
+
this.visitExpression(child.expression, declaration);
|
|
420
|
+
return;
|
|
421
|
+
case "JSXElement":
|
|
422
|
+
case "JSXSelfClosingElement":
|
|
423
|
+
this.visitExpression(child, declaration);
|
|
424
|
+
return;
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
visitExpression(expr, declaration) {
|
|
428
|
+
switch (expr.kind) {
|
|
429
|
+
case "NumberLiteral":
|
|
430
|
+
case "Identifier":
|
|
431
|
+
case "UpperIdentifier":
|
|
432
|
+
case "Placeholder":
|
|
433
|
+
return;
|
|
434
|
+
case "BooleanLiteral":
|
|
435
|
+
if (expr.rawExpr) {
|
|
436
|
+
this.visitExpression(expr.rawExpr, declaration);
|
|
437
|
+
}
|
|
438
|
+
return;
|
|
439
|
+
case "StringLiteral":
|
|
440
|
+
case "TemplateLiteral":
|
|
441
|
+
for (const part of expr.parts) {
|
|
442
|
+
if (part.kind === "StringInterpolationPart") {
|
|
443
|
+
this.visitExpression(part.expression, declaration);
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
return;
|
|
447
|
+
case "TaggedTemplateExpression":
|
|
448
|
+
this.visitExpression(expr.tag, declaration);
|
|
449
|
+
if (expr.typeArguments) {
|
|
450
|
+
for (const typeArg of expr.typeArguments) {
|
|
451
|
+
this.visitTypeNode(typeArg, declaration);
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
this.visitExpression(expr.template, declaration);
|
|
455
|
+
return;
|
|
456
|
+
case "SpreadElement":
|
|
457
|
+
this.visitExpression(expr.argument, declaration);
|
|
458
|
+
return;
|
|
459
|
+
case "TypedHole":
|
|
460
|
+
this.addFinding("typed-hole", expr.span, declaration, extractSpanSnippet(this.source, this.sourceLines, expr.span, expr.label ? `??? "${expr.label}"` : "???"));
|
|
461
|
+
return;
|
|
462
|
+
case "TsEscapeExpression":
|
|
463
|
+
this.addFinding("raw-ts", expr.span, declaration, extractSpanSnippet(this.source, this.sourceLines, expr.span, `ts { ${expr.code.trim()} }`));
|
|
464
|
+
return;
|
|
465
|
+
case "JsExpression":
|
|
466
|
+
this.addFinding("js-interop", expr.span, declaration, extractSpanSnippet(this.source, this.sourceLines, expr.span, "js ..."));
|
|
467
|
+
this.visitExpression(expr.expression, declaration);
|
|
468
|
+
return;
|
|
469
|
+
case "PipelineExpression":
|
|
470
|
+
this.visitExpression(expr.left, declaration);
|
|
471
|
+
if (expr.right.kind === "Identifier" && expr.right.name === "js") {
|
|
472
|
+
const snippet = expr.span.start.line === expr.right.span.start.line
|
|
473
|
+
? extractSpanSnippet(this.source, this.sourceLines, expr.span, "|> js")
|
|
474
|
+
: extractLineSnippet(this.sourceLines, expr.right.span) ||
|
|
475
|
+
"|> js";
|
|
476
|
+
this.addFinding("js-interop", expr.right.span, declaration, snippet);
|
|
477
|
+
return;
|
|
478
|
+
}
|
|
479
|
+
this.visitExpression(expr.right, declaration);
|
|
480
|
+
return;
|
|
481
|
+
case "BinaryExpression":
|
|
482
|
+
this.visitExpression(expr.left, declaration);
|
|
483
|
+
this.visitExpression(expr.right, declaration);
|
|
484
|
+
return;
|
|
485
|
+
case "UnaryExpression":
|
|
486
|
+
this.visitExpression(expr.argument, declaration);
|
|
487
|
+
return;
|
|
488
|
+
case "CallExpression":
|
|
489
|
+
this.visitExpression(expr.callee, declaration);
|
|
490
|
+
for (const arg of expr.args) {
|
|
491
|
+
this.visitExpression(arg, declaration);
|
|
492
|
+
}
|
|
493
|
+
return;
|
|
494
|
+
case "MemberExpression":
|
|
495
|
+
this.visitExpression(expr.object, declaration);
|
|
496
|
+
return;
|
|
497
|
+
case "IndexExpression":
|
|
498
|
+
this.visitExpression(expr.object, declaration);
|
|
499
|
+
this.visitExpression(expr.index, declaration);
|
|
500
|
+
return;
|
|
501
|
+
case "RecordExpression":
|
|
502
|
+
for (const entry of expr.entries) {
|
|
503
|
+
if (entry.kind === "SpreadEntry") {
|
|
504
|
+
this.visitExpression(entry.argument, declaration);
|
|
505
|
+
}
|
|
506
|
+
else if (entry.kind === "FieldEntry" ||
|
|
507
|
+
entry.kind === "DotPathEntry") {
|
|
508
|
+
this.visitExpression(entry.value, declaration);
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
return;
|
|
512
|
+
case "ArrayExpression":
|
|
513
|
+
for (const elem of expr.elements) {
|
|
514
|
+
this.visitExpression(elem, declaration);
|
|
515
|
+
}
|
|
516
|
+
return;
|
|
517
|
+
case "FunctionExpression":
|
|
518
|
+
if (expr.typeParams) {
|
|
519
|
+
for (const tp of expr.typeParams) {
|
|
520
|
+
if (tp.constraint) {
|
|
521
|
+
this.visitTypeNode(tp.constraint, declaration);
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
for (const param of expr.params) {
|
|
526
|
+
if (param.typeAnnotation) {
|
|
527
|
+
this.visitTypeNode(param.typeAnnotation, declaration);
|
|
528
|
+
}
|
|
529
|
+
if (param.defaultValue) {
|
|
530
|
+
this.visitExpression(param.defaultValue, declaration);
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
if (expr.returnType) {
|
|
534
|
+
this.visitTypeNode(expr.returnType, declaration);
|
|
535
|
+
}
|
|
536
|
+
this.visitFunctionBody(expr.body, declaration);
|
|
537
|
+
return;
|
|
538
|
+
case "MutBlockExpression":
|
|
539
|
+
this.visitFunctionBody(expr.body, declaration);
|
|
540
|
+
return;
|
|
541
|
+
case "MatchExpression":
|
|
542
|
+
if (expr.scrutinee) {
|
|
543
|
+
this.visitExpression(expr.scrutinee, declaration);
|
|
544
|
+
}
|
|
545
|
+
for (const arm of expr.arms) {
|
|
546
|
+
this.visitMatchArm(arm, declaration);
|
|
547
|
+
}
|
|
548
|
+
return;
|
|
549
|
+
case "EffectBlockExpression":
|
|
550
|
+
for (const stmt of expr.body) {
|
|
551
|
+
this.visitEffectStatement(stmt, declaration);
|
|
552
|
+
}
|
|
553
|
+
this.visitExpression(expr.finalExpression, declaration);
|
|
554
|
+
return;
|
|
555
|
+
case "ParBlockExpression":
|
|
556
|
+
if (expr.concurrency) {
|
|
557
|
+
this.visitExpression(expr.concurrency, declaration);
|
|
558
|
+
}
|
|
559
|
+
for (const stmt of expr.body) {
|
|
560
|
+
this.visitEffectStatement(stmt, declaration);
|
|
561
|
+
}
|
|
562
|
+
this.visitExpression(expr.finalExpression, declaration);
|
|
563
|
+
return;
|
|
564
|
+
case "JSXSelfClosingElement":
|
|
565
|
+
if (expr.name.kind === "MemberExpression") {
|
|
566
|
+
this.visitExpression(expr.name, declaration);
|
|
567
|
+
}
|
|
568
|
+
this.visitJsxAttributes(expr.attributes, declaration);
|
|
569
|
+
return;
|
|
570
|
+
case "JSXElement":
|
|
571
|
+
if (expr.openingElement.name.kind === "MemberExpression") {
|
|
572
|
+
this.visitExpression(expr.openingElement.name, declaration);
|
|
573
|
+
}
|
|
574
|
+
this.visitJsxAttributes(expr.openingElement.attributes, declaration);
|
|
575
|
+
for (const child of expr.children) {
|
|
576
|
+
this.visitJsxChild(child, declaration);
|
|
577
|
+
}
|
|
578
|
+
return;
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
visitJsxAttributes(attributes, declaration) {
|
|
582
|
+
for (const attr of attributes) {
|
|
583
|
+
if (attr.kind === "JSXSpreadAttribute") {
|
|
584
|
+
this.visitExpression(attr.argument, declaration);
|
|
585
|
+
continue;
|
|
586
|
+
}
|
|
587
|
+
if (attr.value) {
|
|
588
|
+
if (attr.value.kind === "JSXExpressionContainer") {
|
|
589
|
+
this.visitExpression(attr.value.expression, declaration);
|
|
590
|
+
}
|
|
591
|
+
else {
|
|
592
|
+
this.visitExpression(attr.value, declaration);
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
/**
|
|
599
|
+
* Audits a single FunkScript source string for AST-level escape hatches.
|
|
600
|
+
*/
|
|
601
|
+
export function auditEscapeHatches(source, filename = "<anonymous>") {
|
|
602
|
+
const lexer = new Lexer(source, filename);
|
|
603
|
+
const tokens = lexer.tokenize();
|
|
604
|
+
const parser = new Parser(tokens, filename, source);
|
|
605
|
+
const ast = parser.parse();
|
|
606
|
+
const visitor = new EscapeAuditVisitor(source, filename);
|
|
607
|
+
visitor.visitProgram(ast);
|
|
608
|
+
const findings = visitor.findings.sort((a, b) => a.line - b.line || a.column - b.column);
|
|
609
|
+
const counts = emptyCounts();
|
|
610
|
+
for (const finding of findings) {
|
|
611
|
+
incrementCounts(counts, finding.kind);
|
|
612
|
+
}
|
|
613
|
+
return {
|
|
614
|
+
file: filename,
|
|
615
|
+
counts,
|
|
616
|
+
findings,
|
|
617
|
+
};
|
|
618
|
+
}
|
|
619
|
+
/**
|
|
620
|
+
* Audits a map of virtual FunkScript files and aggregates counts into a report.
|
|
621
|
+
*/
|
|
622
|
+
export function auditEscapeHatchesVirtualFiles(virtualInputFiles) {
|
|
623
|
+
const counts = emptyCounts();
|
|
624
|
+
const files = [];
|
|
625
|
+
for (const [file, source] of Object.entries(virtualInputFiles)) {
|
|
626
|
+
const fileReport = auditEscapeHatches(source, file);
|
|
627
|
+
files.push(fileReport);
|
|
628
|
+
mergeCounts(counts, fileReport.counts);
|
|
629
|
+
}
|
|
630
|
+
return {
|
|
631
|
+
schemaVersion: 1,
|
|
632
|
+
counts,
|
|
633
|
+
files,
|
|
634
|
+
};
|
|
635
|
+
}
|
|
636
|
+
/**
|
|
637
|
+
* Reads and audits FunkScript files on disk as an Effect.
|
|
638
|
+
*/
|
|
639
|
+
export function auditEscapeHatchesFiles(files) {
|
|
640
|
+
return Effect.gen(function* () {
|
|
641
|
+
const virtualFiles = {};
|
|
642
|
+
for (const filePath of files) {
|
|
643
|
+
const fullPath = path.isAbsolute(filePath)
|
|
644
|
+
? filePath
|
|
645
|
+
: path.resolve(process.cwd(), filePath);
|
|
646
|
+
const content = yield* Effect.tryPromise({
|
|
647
|
+
try: () => fs.readFile(fullPath, "utf-8"),
|
|
648
|
+
catch: (err) => new Error(`Failed to read file '${filePath}': ${err instanceof Error ? err.message : String(err)}`),
|
|
649
|
+
});
|
|
650
|
+
virtualFiles[filePath] = content;
|
|
651
|
+
}
|
|
652
|
+
return yield* Effect.try({
|
|
653
|
+
try: () => auditEscapeHatchesVirtualFiles(virtualFiles),
|
|
654
|
+
catch: (err) => err instanceof Error ? err : new Error(String(err)),
|
|
655
|
+
});
|
|
656
|
+
});
|
|
657
|
+
}
|
|
658
|
+
/**
|
|
659
|
+
* Formats an escape-hatch audit report as human-readable text or JSON.
|
|
660
|
+
*/
|
|
661
|
+
export function formatEscapeAudit(report, options) {
|
|
662
|
+
if (options?.json) {
|
|
663
|
+
return JSON.stringify(report, null, 2);
|
|
664
|
+
}
|
|
665
|
+
const lines = [];
|
|
666
|
+
const allFindings = report.files.flatMap((f) => f.findings);
|
|
667
|
+
if (allFindings.length === 0) {
|
|
668
|
+
lines.push(`No escape hatches found across ${report.files.length} file(s).`);
|
|
669
|
+
}
|
|
670
|
+
else {
|
|
671
|
+
for (const finding of allFindings) {
|
|
672
|
+
const declPart = finding.declaration ? ` (${finding.declaration})` : "";
|
|
673
|
+
lines.push(`${finding.file}:${finding.line}:${finding.column} [${finding.kind}]${declPart}: ${finding.snippet}`);
|
|
674
|
+
}
|
|
675
|
+
lines.push("");
|
|
676
|
+
lines.push(`Summary: ${report.counts.total} escape hatch(es) across ${report.files.length} file(s) ` +
|
|
677
|
+
`(raw-ts: ${report.counts.rawTs}, js-interop: ${report.counts.jsInterop}, ` +
|
|
678
|
+
`wildcard-match: ${report.counts.wildcardMatch}, typed-hole: ${report.counts.typedHole})`);
|
|
679
|
+
}
|
|
680
|
+
return lines.join("\n");
|
|
681
|
+
}
|
|
682
|
+
//# sourceMappingURL=escape-audit.js.map
|