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
package/src/formatter/index.ts
CHANGED
|
@@ -13,6 +13,11 @@ import {
|
|
|
13
13
|
type FunctionExpression,
|
|
14
14
|
type Identifier,
|
|
15
15
|
type ImportDeclaration,
|
|
16
|
+
type JSXAttribute,
|
|
17
|
+
type JSXChild,
|
|
18
|
+
type JSXElement,
|
|
19
|
+
type JSXSelfClosingElement,
|
|
20
|
+
type JSXTagName,
|
|
16
21
|
type Literal,
|
|
17
22
|
type MatchArm,
|
|
18
23
|
type MatchExpression,
|
|
@@ -45,6 +50,7 @@ import { convertPipelineStyle } from "../tooling/pipeline-style.js";
|
|
|
45
50
|
import { ASSOCIATIVITY, PRECEDENCE } from "./operator-precedence.js";
|
|
46
51
|
import {
|
|
47
52
|
CommentAttachments,
|
|
53
|
+
extractComments,
|
|
48
54
|
type Comment,
|
|
49
55
|
type AstInspectNode,
|
|
50
56
|
} from "./comments.js";
|
|
@@ -64,6 +70,7 @@ export interface FormatOptions {
|
|
|
64
70
|
export class Formatter {
|
|
65
71
|
private indentSize: number;
|
|
66
72
|
private lineWidth: number;
|
|
73
|
+
private inlinePipelineDepth = 0;
|
|
67
74
|
private leadingComments = new Map<AstInspectNode, Comment[]>();
|
|
68
75
|
private trailingComments = new Map<number, Comment>();
|
|
69
76
|
private eofComments: Comment[] = [];
|
|
@@ -254,11 +261,73 @@ export class Formatter {
|
|
|
254
261
|
}
|
|
255
262
|
|
|
256
263
|
private formatImportDeclaration(decl: ImportDeclaration): string {
|
|
264
|
+
const original = this.source.slice(
|
|
265
|
+
decl.span.start.offset,
|
|
266
|
+
decl.span.end.offset,
|
|
267
|
+
);
|
|
257
268
|
const firstPart = decl.source.parts[0];
|
|
258
269
|
const rawVal =
|
|
259
270
|
firstPart && firstPart.kind === "StringRawPart" ? firstPart.value : "";
|
|
260
271
|
const source = `"${this.escapeStringPart(rawVal)}"`;
|
|
261
|
-
|
|
272
|
+
const rendered = renderImport(decl, source).slice(0, -1);
|
|
273
|
+
const comments = extractComments(original);
|
|
274
|
+
if (comments.length === 0) return rendered;
|
|
275
|
+
|
|
276
|
+
// Line comments need a multiline import so they stay next to their specifier.
|
|
277
|
+
const open = rendered.indexOf("{");
|
|
278
|
+
const close = rendered.indexOf("}", open);
|
|
279
|
+
if (open < 0 || close < 0) return original;
|
|
280
|
+
const lines = [rendered.slice(0, open + 1)];
|
|
281
|
+
const indent = this.spaces(this.indentSize);
|
|
282
|
+
let commentIndex = 0;
|
|
283
|
+
const position = (comment: Comment) => ({
|
|
284
|
+
line: comment.line + decl.span.start.line - 1,
|
|
285
|
+
column:
|
|
286
|
+
comment.line === 1
|
|
287
|
+
? comment.col + decl.span.start.column - 1
|
|
288
|
+
: comment.col,
|
|
289
|
+
});
|
|
290
|
+
const before = (comment: Comment, line: number, column: number) => {
|
|
291
|
+
const pos = position(comment);
|
|
292
|
+
return pos.line < line || (pos.line === line && pos.column < column);
|
|
293
|
+
};
|
|
294
|
+
for (const specifier of decl.specifiers) {
|
|
295
|
+
while (
|
|
296
|
+
commentIndex < comments.length &&
|
|
297
|
+
before(
|
|
298
|
+
comments[commentIndex],
|
|
299
|
+
specifier.span.start.line,
|
|
300
|
+
specifier.span.start.column,
|
|
301
|
+
)
|
|
302
|
+
) {
|
|
303
|
+
const comment = comments[commentIndex++];
|
|
304
|
+
if (
|
|
305
|
+
comment.isTrailing &&
|
|
306
|
+
position(comment).line === decl.span.start.line
|
|
307
|
+
) {
|
|
308
|
+
lines[0] += ` ${comment.text}`;
|
|
309
|
+
} else {
|
|
310
|
+
lines.push(`${indent}${comment.text}`);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
const name = specifier.imported.name;
|
|
314
|
+
const alias =
|
|
315
|
+
specifier.local.name === name ? "" : ` as ${specifier.local.name}`;
|
|
316
|
+
let line = `${indent}${specifier.isTypeOnly ? "type " : ""}${name}${alias},`;
|
|
317
|
+
if (
|
|
318
|
+
commentIndex < comments.length &&
|
|
319
|
+
comments[commentIndex].isTrailing &&
|
|
320
|
+
position(comments[commentIndex]).line === specifier.span.end.line
|
|
321
|
+
) {
|
|
322
|
+
line += ` ${comments[commentIndex++].text}`;
|
|
323
|
+
}
|
|
324
|
+
lines.push(line);
|
|
325
|
+
}
|
|
326
|
+
while (commentIndex < comments.length) {
|
|
327
|
+
lines.push(`${indent}${comments[commentIndex++].text}`);
|
|
328
|
+
}
|
|
329
|
+
lines.push(rendered.slice(close));
|
|
330
|
+
return lines.join("\n");
|
|
262
331
|
}
|
|
263
332
|
|
|
264
333
|
private formatTypeParameters(
|
|
@@ -501,6 +570,12 @@ export class Formatter {
|
|
|
501
570
|
}
|
|
502
571
|
|
|
503
572
|
private shouldExpandPipeline(chain: Expression[], indent: number): boolean {
|
|
573
|
+
if (
|
|
574
|
+
this.inlinePipelineDepth > 0 &&
|
|
575
|
+
chain[0].span.start.line === chain[chain.length - 1].span.end.line
|
|
576
|
+
) {
|
|
577
|
+
return false;
|
|
578
|
+
}
|
|
504
579
|
if (chain.length > 2) return true;
|
|
505
580
|
if (
|
|
506
581
|
chain[0].span.end.line < chain[1].span.start.line ||
|
|
@@ -526,7 +601,13 @@ export class Formatter {
|
|
|
526
601
|
const isMulti = this.shouldExpandPipeline(chain, indent);
|
|
527
602
|
|
|
528
603
|
if (!isMulti) {
|
|
529
|
-
return
|
|
604
|
+
return chain
|
|
605
|
+
.map((step, index) =>
|
|
606
|
+
index === 0
|
|
607
|
+
? this.formatExpression(step, indent)
|
|
608
|
+
: `${operators[index - 1]} ${this.formatExpression(step, indent)}`,
|
|
609
|
+
)
|
|
610
|
+
.join(" ");
|
|
530
611
|
}
|
|
531
612
|
|
|
532
613
|
const head = this.formatExpression(chain[0], indent);
|
|
@@ -1159,8 +1240,9 @@ export class Formatter {
|
|
|
1159
1240
|
case "UpperIdentifier":
|
|
1160
1241
|
return expr.name;
|
|
1161
1242
|
case "JSXElement":
|
|
1243
|
+
return this.formatJsxElement(expr, indent);
|
|
1162
1244
|
case "JSXSelfClosingElement":
|
|
1163
|
-
return this.
|
|
1245
|
+
return this.formatJsxSelfClosingElement(expr, indent);
|
|
1164
1246
|
case "JsExpression":
|
|
1165
1247
|
return `js ${this.formatExpression(expr.expression, indent)}`;
|
|
1166
1248
|
case "TsEscapeExpression":
|
|
@@ -1170,6 +1252,214 @@ export class Formatter {
|
|
|
1170
1252
|
}
|
|
1171
1253
|
}
|
|
1172
1254
|
|
|
1255
|
+
private formatJsxTagName(name: JSXTagName): string {
|
|
1256
|
+
switch (name.kind) {
|
|
1257
|
+
case "Identifier":
|
|
1258
|
+
case "UpperIdentifier":
|
|
1259
|
+
return name.name;
|
|
1260
|
+
case "MemberExpression":
|
|
1261
|
+
return `${this.formatJsxTagName(name.object as JSXTagName)}.${name.property.name}`;
|
|
1262
|
+
default:
|
|
1263
|
+
return "";
|
|
1264
|
+
}
|
|
1265
|
+
}
|
|
1266
|
+
|
|
1267
|
+
private formatJsxAttribute(attr: JSXAttribute, indent: number): string {
|
|
1268
|
+
if (attr.kind === "JSXSpreadAttribute") {
|
|
1269
|
+
return `{...${this.formatExpression(attr.argument, indent)}}`;
|
|
1270
|
+
}
|
|
1271
|
+
|
|
1272
|
+
const name = attr.name.name;
|
|
1273
|
+
if (attr.value === undefined) {
|
|
1274
|
+
return name;
|
|
1275
|
+
}
|
|
1276
|
+
if (attr.value.kind === "StringLiteral") {
|
|
1277
|
+
return `${name}=${this.formatStringLiteral(attr.value)}`;
|
|
1278
|
+
}
|
|
1279
|
+
if (attr.value.kind === "JSXExpressionContainer") {
|
|
1280
|
+
return `${name}=${this.formatJsxExpressionContainer(
|
|
1281
|
+
attr.value.expression,
|
|
1282
|
+
attr.value.span,
|
|
1283
|
+
indent,
|
|
1284
|
+
)}`;
|
|
1285
|
+
}
|
|
1286
|
+
return `${name}=${this.formatJsxExpressionContainer(
|
|
1287
|
+
attr.value,
|
|
1288
|
+
attr.value.span,
|
|
1289
|
+
indent,
|
|
1290
|
+
)}`;
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1293
|
+
private formatJsxExpressionContainer(
|
|
1294
|
+
expression: Expression,
|
|
1295
|
+
span: { start: { line: number }; end: { line: number } },
|
|
1296
|
+
indent: number,
|
|
1297
|
+
): string {
|
|
1298
|
+
const isSingleLine = span.start.line === span.end.line;
|
|
1299
|
+
if (isSingleLine) this.inlinePipelineDepth++;
|
|
1300
|
+
try {
|
|
1301
|
+
return `{${this.formatExpression(expression, indent)}}`;
|
|
1302
|
+
} finally {
|
|
1303
|
+
if (isSingleLine) this.inlinePipelineDepth--;
|
|
1304
|
+
}
|
|
1305
|
+
}
|
|
1306
|
+
|
|
1307
|
+
private formatJsxOpeningTag(
|
|
1308
|
+
tagName: string,
|
|
1309
|
+
attributes: JSXAttribute[],
|
|
1310
|
+
startLine: number,
|
|
1311
|
+
endLine: number,
|
|
1312
|
+
indent: number,
|
|
1313
|
+
selfClosing: boolean,
|
|
1314
|
+
): string {
|
|
1315
|
+
if (tagName === "") {
|
|
1316
|
+
return selfClosing ? "< />" : "<>";
|
|
1317
|
+
}
|
|
1318
|
+
|
|
1319
|
+
const closeToken = selfClosing ? "/>" : ">";
|
|
1320
|
+
if (attributes.length === 0) {
|
|
1321
|
+
return selfClosing ? `<${tagName} />` : `<${tagName}>`;
|
|
1322
|
+
}
|
|
1323
|
+
|
|
1324
|
+
const attrIndentCount = indent + this.indentSize;
|
|
1325
|
+
const formattedAttrs = attributes.map((attr) =>
|
|
1326
|
+
this.formatJsxAttribute(attr, attrIndentCount),
|
|
1327
|
+
);
|
|
1328
|
+
const isMultiline =
|
|
1329
|
+
endLine > startLine || formattedAttrs.some((a) => a.includes("\n"));
|
|
1330
|
+
|
|
1331
|
+
if (!isMultiline) {
|
|
1332
|
+
return selfClosing
|
|
1333
|
+
? `<${tagName} ${formattedAttrs.join(" ")} />`
|
|
1334
|
+
: `<${tagName} ${formattedAttrs.join(" ")}>`;
|
|
1335
|
+
}
|
|
1336
|
+
|
|
1337
|
+
const attrIndent = this.spaces(attrIndentCount);
|
|
1338
|
+
const closeIndent = this.spaces(indent);
|
|
1339
|
+
const attrLines = formattedAttrs.map((a) => `${attrIndent}${a}`).join("\n");
|
|
1340
|
+
return `<${tagName}\n${attrLines}\n${closeIndent}${closeToken}`;
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1343
|
+
private formatJsxSelfClosingElement(
|
|
1344
|
+
el: JSXSelfClosingElement,
|
|
1345
|
+
indent = 0,
|
|
1346
|
+
): string {
|
|
1347
|
+
const tagName = this.formatJsxTagName(el.name);
|
|
1348
|
+
return this.formatJsxOpeningTag(
|
|
1349
|
+
tagName,
|
|
1350
|
+
el.attributes,
|
|
1351
|
+
el.span.start.line,
|
|
1352
|
+
el.span.end.line,
|
|
1353
|
+
indent,
|
|
1354
|
+
true,
|
|
1355
|
+
);
|
|
1356
|
+
}
|
|
1357
|
+
|
|
1358
|
+
private formatJsxChild(child: JSXChild, indent: number): string {
|
|
1359
|
+
switch (child.kind) {
|
|
1360
|
+
case "JSXText":
|
|
1361
|
+
return child.value;
|
|
1362
|
+
case "JSXExpressionContainer":
|
|
1363
|
+
return this.formatJsxExpressionContainer(
|
|
1364
|
+
child.expression,
|
|
1365
|
+
child.span,
|
|
1366
|
+
indent,
|
|
1367
|
+
);
|
|
1368
|
+
case "JSXElement":
|
|
1369
|
+
return this.formatJsxElement(child, indent);
|
|
1370
|
+
case "JSXSelfClosingElement":
|
|
1371
|
+
return this.formatJsxSelfClosingElement(child, indent);
|
|
1372
|
+
}
|
|
1373
|
+
}
|
|
1374
|
+
|
|
1375
|
+
private getJsxChildLineGap(prev: JSXChild, curr: JSXChild): number {
|
|
1376
|
+
if (prev.kind === "JSXText") {
|
|
1377
|
+
const prevRaw = prev.raw ?? prev.value;
|
|
1378
|
+
const trailingMatch = prevRaw.match(/((?:\r?\n\s*)+)$/);
|
|
1379
|
+
if (!trailingMatch) return 0;
|
|
1380
|
+
const newlineCount = (trailingMatch[1].match(/\n/g) ?? []).length;
|
|
1381
|
+
return Math.max(1, newlineCount);
|
|
1382
|
+
}
|
|
1383
|
+
if (curr.kind === "JSXText") {
|
|
1384
|
+
const currRaw = curr.raw ?? curr.value;
|
|
1385
|
+
const leadingMatch = currRaw.match(/^((?:\s*\r?\n)+)/);
|
|
1386
|
+
if (!leadingMatch) return 0;
|
|
1387
|
+
const newlineCount = (leadingMatch[1].match(/\n/g) ?? []).length;
|
|
1388
|
+
return Math.max(1, newlineCount);
|
|
1389
|
+
}
|
|
1390
|
+
return Math.max(0, curr.span.start.line - prev.span.end.line);
|
|
1391
|
+
}
|
|
1392
|
+
|
|
1393
|
+
private formatJsxElement(el: JSXElement, indent = 0): string {
|
|
1394
|
+
const tagName = this.formatJsxTagName(el.openingElement.name);
|
|
1395
|
+
const openTag = this.formatJsxOpeningTag(
|
|
1396
|
+
tagName,
|
|
1397
|
+
el.openingElement.attributes,
|
|
1398
|
+
el.openingElement.span.start.line,
|
|
1399
|
+
el.openingElement.span.end.line,
|
|
1400
|
+
indent,
|
|
1401
|
+
false,
|
|
1402
|
+
);
|
|
1403
|
+
const closeTag = tagName === "" ? "</>" : `</${tagName}>`;
|
|
1404
|
+
|
|
1405
|
+
if (el.children.length === 0) {
|
|
1406
|
+
return `${openTag}${closeTag}`;
|
|
1407
|
+
}
|
|
1408
|
+
|
|
1409
|
+
const childIndentCount = indent + this.indentSize;
|
|
1410
|
+
const formattedChildren = el.children.map((child) => ({
|
|
1411
|
+
node: child,
|
|
1412
|
+
text: this.formatJsxChild(child, childIndentCount),
|
|
1413
|
+
}));
|
|
1414
|
+
|
|
1415
|
+
const isMultiline =
|
|
1416
|
+
el.span.end.line > el.span.start.line ||
|
|
1417
|
+
openTag.includes("\n") ||
|
|
1418
|
+
formattedChildren.some((c) => c.text.includes("\n"));
|
|
1419
|
+
|
|
1420
|
+
if (!isMultiline) {
|
|
1421
|
+
return `${openTag}${formattedChildren.map((c) => c.text).join("")}${closeTag}`;
|
|
1422
|
+
}
|
|
1423
|
+
|
|
1424
|
+
const childIndent = this.spaces(childIndentCount);
|
|
1425
|
+
const closeIndent = this.spaces(indent);
|
|
1426
|
+
const lines: string[] = [];
|
|
1427
|
+
let currentLine = "";
|
|
1428
|
+
|
|
1429
|
+
const flushLine = () => {
|
|
1430
|
+
if (currentLine.length > 0) {
|
|
1431
|
+
lines.push(`${childIndent}${currentLine}`);
|
|
1432
|
+
currentLine = "";
|
|
1433
|
+
}
|
|
1434
|
+
};
|
|
1435
|
+
|
|
1436
|
+
for (let i = 0; i < formattedChildren.length; i++) {
|
|
1437
|
+
const curr = formattedChildren[i];
|
|
1438
|
+
if (i === 0) {
|
|
1439
|
+
currentLine = curr.text;
|
|
1440
|
+
continue;
|
|
1441
|
+
}
|
|
1442
|
+
|
|
1443
|
+
const prev = formattedChildren[i - 1];
|
|
1444
|
+
const gap = this.getJsxChildLineGap(prev.node, curr.node);
|
|
1445
|
+
const mustStayInline =
|
|
1446
|
+
gap === 0 && !prev.text.includes("\n") && !curr.text.includes("\n");
|
|
1447
|
+
|
|
1448
|
+
if (mustStayInline) {
|
|
1449
|
+
currentLine += curr.text;
|
|
1450
|
+
} else {
|
|
1451
|
+
flushLine();
|
|
1452
|
+
if (gap > 1) {
|
|
1453
|
+
lines.push("");
|
|
1454
|
+
}
|
|
1455
|
+
currentLine = curr.text;
|
|
1456
|
+
}
|
|
1457
|
+
}
|
|
1458
|
+
flushLine();
|
|
1459
|
+
|
|
1460
|
+
return `${openTag}\n${lines.join("\n")}\n${closeIndent}${closeTag}`;
|
|
1461
|
+
}
|
|
1462
|
+
|
|
1173
1463
|
private formatFunctionBody(body: FunctionBody, indent: number): string {
|
|
1174
1464
|
if (body.kind === "BlockStatement") {
|
|
1175
1465
|
return this.formatBlockStatement(body, indent);
|
|
@@ -1312,7 +1602,12 @@ export class Formatter {
|
|
|
1312
1602
|
expr.body,
|
|
1313
1603
|
indent + this.indentSize,
|
|
1314
1604
|
);
|
|
1315
|
-
|
|
1605
|
+
if (this.source.length === 0) {
|
|
1606
|
+
return body
|
|
1607
|
+
? `${sig} {\n${body}\n${this.spaces(indent)}}`
|
|
1608
|
+
: `${sig} {}`;
|
|
1609
|
+
}
|
|
1610
|
+
return `${sig}\n${body}`;
|
|
1316
1611
|
} else if (
|
|
1317
1612
|
expr.body.kind === "PipelineExpression" &&
|
|
1318
1613
|
this.shouldExpandPipeline(
|
package/src/index.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
export * from "./ast/types.js";
|
|
2
2
|
export * from "./compiler.js";
|
|
3
3
|
export * from "./compiler/check.js";
|
|
4
|
+
export * from "./compiler/diagnostics-json.js";
|
|
5
|
+
export * from "./compiler/escape-audit.js";
|
|
4
6
|
export * from "./compiler/incremental-build.js";
|
|
7
|
+
export * from "./compiler/query.js";
|
|
5
8
|
export * from "./emitter/emitter.js";
|
|
6
9
|
export * from "./errors.js";
|
|
7
10
|
export * from "./formatter/index.js";
|
package/src/lexer/lexer.ts
CHANGED
|
@@ -8,6 +8,8 @@ import {
|
|
|
8
8
|
TokenType,
|
|
9
9
|
} from "./tokens.js";
|
|
10
10
|
|
|
11
|
+
const TAB_WIDTH = 4;
|
|
12
|
+
|
|
11
13
|
export class LexerError extends FunScriptError {
|
|
12
14
|
constructor(message: string, span: Span) {
|
|
13
15
|
super(message, span);
|
|
@@ -27,9 +29,23 @@ export class Lexer {
|
|
|
27
29
|
private parenLevel = 0;
|
|
28
30
|
private bracketLevel = 0;
|
|
29
31
|
private braceStack: (
|
|
30
|
-
|
|
32
|
+
| "record"
|
|
33
|
+
| "block"
|
|
34
|
+
| "import"
|
|
35
|
+
| "interpolation"
|
|
36
|
+
| "template_interpolation"
|
|
37
|
+
| "jsx_expr"
|
|
31
38
|
)[] = [];
|
|
32
39
|
|
|
40
|
+
private isImportBrace(): boolean {
|
|
41
|
+
for (let i = this.tokens.length - 1; i >= 0; i--) {
|
|
42
|
+
const type = this.tokens[i].type;
|
|
43
|
+
if (type === TokenType.IMPORT) return true;
|
|
44
|
+
if (type === TokenType.NEWLINE || type === TokenType.LBRACE) return false;
|
|
45
|
+
}
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
|
|
33
49
|
private isBlockBrace(): boolean {
|
|
34
50
|
const lastToken = this.tokens[this.tokens.length - 1];
|
|
35
51
|
if (!lastToken) return false;
|
|
@@ -119,12 +135,6 @@ export class Lexer {
|
|
|
119
135
|
|
|
120
136
|
// Whitespace (inline)
|
|
121
137
|
if (char === " " || char === "\t") {
|
|
122
|
-
if (char === "\t") {
|
|
123
|
-
throw new LexerError(
|
|
124
|
-
"Tabs are not allowed for indentation or spacing; use 2 spaces",
|
|
125
|
-
this.currentSpan(1),
|
|
126
|
-
);
|
|
127
|
-
}
|
|
128
138
|
this.advance();
|
|
129
139
|
continue;
|
|
130
140
|
}
|
|
@@ -288,7 +298,13 @@ export class Lexer {
|
|
|
288
298
|
this.emitToken(TokenType.RBRACKET, "]", 1);
|
|
289
299
|
break;
|
|
290
300
|
case "{":
|
|
291
|
-
this.braceStack.push(
|
|
301
|
+
this.braceStack.push(
|
|
302
|
+
this.isImportBrace()
|
|
303
|
+
? "import"
|
|
304
|
+
: this.isBlockBrace()
|
|
305
|
+
? "block"
|
|
306
|
+
: "record",
|
|
307
|
+
);
|
|
292
308
|
this.emitToken(TokenType.LBRACE, "{", 1);
|
|
293
309
|
break;
|
|
294
310
|
case "}":
|
|
@@ -379,7 +395,11 @@ export class Lexer {
|
|
|
379
395
|
}
|
|
380
396
|
|
|
381
397
|
private handleIndentation(): void {
|
|
382
|
-
if (
|
|
398
|
+
if (
|
|
399
|
+
this.bracketLevel > 0 ||
|
|
400
|
+
this.braceStack[this.braceStack.length - 1] === "import" ||
|
|
401
|
+
this.isInJsxChildrenOrTag()
|
|
402
|
+
) {
|
|
383
403
|
this.atLineStart = false;
|
|
384
404
|
return;
|
|
385
405
|
}
|
|
@@ -393,10 +413,8 @@ export class Lexer {
|
|
|
393
413
|
spaces++;
|
|
394
414
|
this.advance();
|
|
395
415
|
} else if (c === "\t") {
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
this.currentSpan(1),
|
|
399
|
-
);
|
|
416
|
+
spaces += TAB_WIDTH - (spaces % TAB_WIDTH);
|
|
417
|
+
this.advance();
|
|
400
418
|
} else {
|
|
401
419
|
break;
|
|
402
420
|
}
|
|
@@ -425,6 +443,12 @@ export class Lexer {
|
|
|
425
443
|
span: { start: startPos, end: this.currentPosition() },
|
|
426
444
|
});
|
|
427
445
|
} else if (spaces < currentIndent) {
|
|
446
|
+
if (!this.indentStack.includes(spaces)) {
|
|
447
|
+
throw new LexerError(
|
|
448
|
+
`Indentation does not match an open block: found ${spaces} columns; expected one of ${this.indentStack.join(", ")}. Align this line with an existing block; tabs use 4-column stops.`,
|
|
449
|
+
{ start: startPos, end: this.currentPosition() },
|
|
450
|
+
);
|
|
451
|
+
}
|
|
428
452
|
while (
|
|
429
453
|
this.indentStack.length > 1 &&
|
|
430
454
|
this.indentStack[this.indentStack.length - 1] > spaces
|
|
@@ -436,12 +460,6 @@ export class Lexer {
|
|
|
436
460
|
span: { start: startPos, end: this.currentPosition() },
|
|
437
461
|
});
|
|
438
462
|
}
|
|
439
|
-
if (this.indentStack[this.indentStack.length - 1] !== spaces) {
|
|
440
|
-
throw new LexerError(
|
|
441
|
-
`Inconsistent indentation: unindent does not match any outer indentation level (expected ${this.indentStack.join(", ")}, got ${spaces})`,
|
|
442
|
-
{ start: startPos, end: this.currentPosition() },
|
|
443
|
-
);
|
|
444
|
-
}
|
|
445
463
|
}
|
|
446
464
|
}
|
|
447
465
|
|
|
@@ -978,7 +996,8 @@ export class Lexer {
|
|
|
978
996
|
(raw === "type" &&
|
|
979
997
|
lastToken?.type === TokenType.EXPORT &&
|
|
980
998
|
/^[ \t]*\{/.test(this.source.slice(this.offset))) ||
|
|
981
|
-
this.braceStack[this.braceStack.length - 1] === "record"
|
|
999
|
+
this.braceStack[this.braceStack.length - 1] === "record" ||
|
|
1000
|
+
this.braceStack[this.braceStack.length - 1] === "import"
|
|
982
1001
|
) {
|
|
983
1002
|
this.tokens.push({
|
|
984
1003
|
type: TokenType.IDENTIFIER,
|