funkscript 0.2.4 → 0.2.6
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 +5 -3
- 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.map +1 -1
- package/dist/cli/check.d.ts.map +1 -1
- package/dist/cli/check.js.map +1 -1
- package/dist/cli/commands.d.ts.map +1 -1
- 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 +4 -2
- 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 +0 -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/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.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 +5 -3
- 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 +95 -103
- package/dist/compiler/check.js.map +1 -1
- 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/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.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 +3 -0
- package/dist/compiler/modules/source-files.d.ts.map +1 -0
- package/dist/compiler/modules/source-files.js +5 -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.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.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/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.map +1 -1
- package/dist/compiler/type-view-paths.d.ts +4 -0
- package/dist/compiler/type-view-paths.d.ts.map +1 -0
- package/dist/compiler/type-view-paths.js +4 -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.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.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.map +1 -1
- package/dist/formatter/index.js +57 -3
- 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.map +1 -1
- 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.map +1 -1
- package/dist/lsp/completion.js.map +1 -1
- package/dist/lsp/definition.d.ts.map +1 -1
- 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.map +1 -1
- package/dist/lsp/hover.js +16 -5
- package/dist/lsp/hover.js.map +1 -1
- package/dist/lsp/imports.d.ts.map +1 -1
- package/dist/lsp/imports.js +10 -1
- 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.map +1 -1
- 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/rename-worker.d.ts.map +1 -1
- package/dist/lsp/rename-worker.js.map +1 -1
- package/dist/lsp/server.d.ts +2 -1
- package/dist/lsp/server.d.ts.map +1 -1
- package/dist/lsp/server.js +20 -0
- 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.map +1 -1
- 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.map +1 -1
- package/dist/plugins/bun.js.map +1 -1
- package/dist/plugins/esbuild.d.ts.map +1 -1
- package/dist/plugins/esbuild.js.map +1 -1
- 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.map +1 -1
- 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 +6 -3
- package/src/cli/doctor.ts +8 -2
- package/src/cli/init.ts +66 -21
- package/src/cli/tsc.ts +8 -3
- package/src/compiler/boolean-operators.ts +11 -2
- package/src/compiler/check.ts +124 -132
- package/src/compiler/modules/resolution.ts +2 -1
- package/src/compiler/modules/source-files.ts +4 -0
- package/src/compiler/project-config.ts +30 -19
- package/src/compiler/rules/resource-escape.ts +223 -0
- package/src/compiler/rules/resource-providers.ts +293 -0
- package/src/compiler/type-view-paths.ts +3 -0
- 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 +70 -2
- package/src/lexer/lexer.ts +39 -20
- package/src/lsp/diagnostics-worker.ts +1 -4
- package/src/lsp/docs.ts +4 -3
- package/src/lsp/hover.ts +23 -4
- package/src/lsp/imports.ts +20 -1
- package/src/lsp/server.ts +30 -0
- package/src/lsp/signature-help.ts +226 -0
- package/src/lsp/validation.ts +3 -2
- package/src/parser/declarations.ts +27 -1
- package/src/plugins/type-view.ts +11 -3
- 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/lsp/hover.ts
CHANGED
|
@@ -28,7 +28,12 @@ function isExpectedHoverError(error: unknown): boolean {
|
|
|
28
28
|
return error instanceof FunScriptError || error instanceof URIError;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
function symbolHover(
|
|
31
|
+
function symbolHover(
|
|
32
|
+
source: string,
|
|
33
|
+
uri: string,
|
|
34
|
+
token: Token,
|
|
35
|
+
companion?: string,
|
|
36
|
+
): Hover | null {
|
|
32
37
|
if (
|
|
33
38
|
token.type !== TokenType.IDENTIFIER &&
|
|
34
39
|
token.type !== TokenType.UPPER_IDENTIFIER
|
|
@@ -40,7 +45,7 @@ function symbolHover(source: string, uri: string, token: Token): Hover | null {
|
|
|
40
45
|
const result = Effect.runSync(
|
|
41
46
|
compileString(source, filename, { context, sourcemap: false }),
|
|
42
47
|
);
|
|
43
|
-
return symbolHoverFromResult(source, token, context, result);
|
|
48
|
+
return symbolHoverFromResult(source, token, context, result, companion);
|
|
44
49
|
} catch (error) {
|
|
45
50
|
if (!isExpectedHoverError(error)) throw error;
|
|
46
51
|
return null;
|
|
@@ -52,6 +57,7 @@ function symbolHoverFromResult(
|
|
|
52
57
|
token: Token,
|
|
53
58
|
context: TypeScriptCompilationContext,
|
|
54
59
|
result: CompileResult,
|
|
60
|
+
companion?: string,
|
|
55
61
|
): Hover | null {
|
|
56
62
|
try {
|
|
57
63
|
const schema = result.ast.body.flatMap((entry) => {
|
|
@@ -110,7 +116,15 @@ function symbolHoverFromResult(
|
|
|
110
116
|
character: number;
|
|
111
117
|
}> = [];
|
|
112
118
|
const visit = (node: ts.Node): void => {
|
|
113
|
-
if (
|
|
119
|
+
if (
|
|
120
|
+
ts.isIdentifier(node) &&
|
|
121
|
+
node.text === token.value &&
|
|
122
|
+
(!companion ||
|
|
123
|
+
(ts.isPropertyAccessExpression(node.parent) &&
|
|
124
|
+
node.parent.name === node &&
|
|
125
|
+
ts.isIdentifier(node.parent.expression) &&
|
|
126
|
+
node.parent.expression.text === companion))
|
|
127
|
+
) {
|
|
114
128
|
const symbol = checked.checker.getSymbolAtLocation(node);
|
|
115
129
|
if (symbol) {
|
|
116
130
|
found.set(symbol, node);
|
|
@@ -465,10 +479,15 @@ function findHoverInTokens(
|
|
|
465
479
|
new TypeScriptCompilationContext(filename),
|
|
466
480
|
).stageResolutions.get(token.span.start.offset);
|
|
467
481
|
if (resolution) {
|
|
482
|
+
const resolved = `${resolution.module}.${resolution.method}`;
|
|
483
|
+
const typedHover = skipSymbol
|
|
484
|
+
? null
|
|
485
|
+
: symbolHover(source, uri, token, resolution.module);
|
|
486
|
+
const typedDetails = typedHover?.contents;
|
|
468
487
|
return {
|
|
469
488
|
contents: {
|
|
470
489
|
kind: MarkupKind.Markdown,
|
|
471
|
-
value: `Resolves to \`${
|
|
490
|
+
value: `Resolves to \`${resolved}\`.${typeof typedDetails === "object" && "value" in typedDetails ? `\n\n${typedDetails.value}` : ""}`,
|
|
472
491
|
},
|
|
473
492
|
range: spanToRange(token.span),
|
|
474
493
|
};
|
package/src/lsp/imports.ts
CHANGED
|
@@ -14,6 +14,19 @@ import { COMPANION_IMPORT_SOURCE } from "../compiler/pipelines/catalog.js";
|
|
|
14
14
|
import { Lexer } from "../lexer/lexer.js";
|
|
15
15
|
import { TokenType, type Token } from "../lexer/tokens.js";
|
|
16
16
|
import { Parser } from "../parser/parser.js";
|
|
17
|
+
import { extractComments } from "../formatter/comments.js";
|
|
18
|
+
|
|
19
|
+
function hasImportComments(source: string, decl: ImportDeclaration): boolean {
|
|
20
|
+
const lineEnd = source.indexOf("\n", decl.span.end.offset);
|
|
21
|
+
return (
|
|
22
|
+
extractComments(
|
|
23
|
+
source.slice(
|
|
24
|
+
decl.span.start.offset,
|
|
25
|
+
lineEnd < 0 ? source.length : lineEnd,
|
|
26
|
+
),
|
|
27
|
+
).length > 0
|
|
28
|
+
);
|
|
29
|
+
}
|
|
17
30
|
|
|
18
31
|
export const EFFECT_MODULE_EXPORTS = new Set([
|
|
19
32
|
"Array",
|
|
@@ -167,6 +180,7 @@ export function findAutoImportCodeActions(
|
|
|
167
180
|
if (
|
|
168
181
|
targetSource === "effect" &&
|
|
169
182
|
existingEffectImport &&
|
|
183
|
+
!hasImportComments(source, existingEffectImport) &&
|
|
170
184
|
existingEffectImport.specifiers.length > 0
|
|
171
185
|
) {
|
|
172
186
|
// Add to existing import { ... } from "effect"
|
|
@@ -295,7 +309,12 @@ export function findRemoveUnusedImportsCodeActions(
|
|
|
295
309
|
const organizeEdits: TextEdit[] = [];
|
|
296
310
|
|
|
297
311
|
for (const decl of importDecls) {
|
|
298
|
-
if (
|
|
312
|
+
if (
|
|
313
|
+
decl.isSideEffect ||
|
|
314
|
+
decl.defaultBinding ||
|
|
315
|
+
decl.namespaceBinding ||
|
|
316
|
+
hasImportComments(source, decl)
|
|
317
|
+
) {
|
|
299
318
|
continue;
|
|
300
319
|
}
|
|
301
320
|
|
package/src/lsp/server.ts
CHANGED
|
@@ -53,6 +53,8 @@ import {
|
|
|
53
53
|
type PublishDiagnosticsParams,
|
|
54
54
|
type ReferenceParams,
|
|
55
55
|
type RenameParams,
|
|
56
|
+
type SignatureHelp,
|
|
57
|
+
type SignatureHelpParams,
|
|
56
58
|
type RequestMessage,
|
|
57
59
|
type ResponseMessage,
|
|
58
60
|
type SymbolInformation,
|
|
@@ -75,6 +77,7 @@ import {
|
|
|
75
77
|
findRemoveUnusedImportsCodeActions,
|
|
76
78
|
} from "./imports.js";
|
|
77
79
|
import { findInlayHints } from "./inlay-hints.js";
|
|
80
|
+
import { findSignatureHelp } from "./signature-help.js";
|
|
78
81
|
import { InteropRenameSession, renameInterop } from "./interop-rename.js";
|
|
79
82
|
import { findFillMatchArmsCodeActions } from "./match-arms.js";
|
|
80
83
|
import { findThunkPipelineCodeActions } from "./thunk-pipeline.js";
|
|
@@ -219,6 +222,7 @@ export class FunScriptLspServer extends EventEmitter {
|
|
|
219
222
|
);
|
|
220
223
|
connection.onDefinition((params) => this.onDefinitionHandler(params));
|
|
221
224
|
connection.onHover((params) => this.onHoverHandler(params));
|
|
225
|
+
connection.onSignatureHelp((params) => this.onSignatureHelpHandler(params));
|
|
222
226
|
connection.onCompletion((params) => this.onCompletionHandler(params));
|
|
223
227
|
connection.onDocumentSymbol((params) =>
|
|
224
228
|
this.onDocumentSymbolHandler(params),
|
|
@@ -273,6 +277,10 @@ export class FunScriptLspServer extends EventEmitter {
|
|
|
273
277
|
referencesProvider: true,
|
|
274
278
|
renameProvider: { prepareProvider: true },
|
|
275
279
|
hoverProvider: true,
|
|
280
|
+
signatureHelpProvider: {
|
|
281
|
+
triggerCharacters: ["(", ","],
|
|
282
|
+
retriggerCharacters: [","],
|
|
283
|
+
},
|
|
276
284
|
completionProvider: {
|
|
277
285
|
resolveProvider: false,
|
|
278
286
|
triggerCharacters: [".", "<", ">"],
|
|
@@ -700,6 +708,20 @@ export class FunScriptLspServer extends EventEmitter {
|
|
|
700
708
|
return findInlayHints(doc.text, uri, params?.range);
|
|
701
709
|
}
|
|
702
710
|
|
|
711
|
+
public onSignatureHelpHandler(
|
|
712
|
+
params: SignatureHelpParams,
|
|
713
|
+
): SignatureHelp | null {
|
|
714
|
+
const uri = params?.textDocument?.uri;
|
|
715
|
+
const doc = uri ? this.documents.get(uri) : undefined;
|
|
716
|
+
if (!doc || !params?.position) return null;
|
|
717
|
+
return findSignatureHelp(
|
|
718
|
+
doc.text,
|
|
719
|
+
uri,
|
|
720
|
+
params.position,
|
|
721
|
+
this.getDocuments(),
|
|
722
|
+
);
|
|
723
|
+
}
|
|
724
|
+
|
|
703
725
|
public onCompletionHandler(params: CompletionParams): CompletionItem[] {
|
|
704
726
|
const uri = params?.textDocument?.uri;
|
|
705
727
|
const doc = uri ? this.documents.get(uri) : undefined;
|
|
@@ -1087,6 +1109,14 @@ export class FunScriptLspServer extends EventEmitter {
|
|
|
1087
1109
|
};
|
|
1088
1110
|
}
|
|
1089
1111
|
|
|
1112
|
+
if (req.method === "textDocument/signatureHelp") {
|
|
1113
|
+
return {
|
|
1114
|
+
jsonrpc: "2.0",
|
|
1115
|
+
id: req.id,
|
|
1116
|
+
result: this.onSignatureHelpHandler(req.params as SignatureHelpParams),
|
|
1117
|
+
};
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1090
1120
|
if (req.method === "textDocument/inlayHint") {
|
|
1091
1121
|
const result = this.onInlayHintHandler(req.params as InlayHintParams);
|
|
1092
1122
|
return {
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
4
|
+
import { resolve } from "node:path";
|
|
5
|
+
import ts from "typescript";
|
|
6
|
+
import {
|
|
7
|
+
MarkupKind,
|
|
8
|
+
type Position,
|
|
9
|
+
type SignatureHelp,
|
|
10
|
+
} from "vscode-languageserver/node";
|
|
11
|
+
import { compileString } from "../compiler.js";
|
|
12
|
+
import { TypeScriptCompilationContext } from "../compiler/typescript-context.js";
|
|
13
|
+
import { resolveFunModule } from "../compiler/modules/resolution.js";
|
|
14
|
+
import { FunScriptError } from "../errors.js";
|
|
15
|
+
import { Lexer } from "../lexer/lexer.js";
|
|
16
|
+
import { TokenType, type Token } from "../lexer/tokens.js";
|
|
17
|
+
|
|
18
|
+
const marker = "__funkscript_signature_help_argument__";
|
|
19
|
+
const opening = new Set([
|
|
20
|
+
TokenType.LPAREN,
|
|
21
|
+
TokenType.LBRACKET,
|
|
22
|
+
TokenType.LBRACE,
|
|
23
|
+
]);
|
|
24
|
+
const closing = new Map([
|
|
25
|
+
[TokenType.RPAREN, TokenType.LPAREN],
|
|
26
|
+
[TokenType.RBRACKET, TokenType.LBRACKET],
|
|
27
|
+
[TokenType.RBRACE, TokenType.LBRACE],
|
|
28
|
+
]);
|
|
29
|
+
|
|
30
|
+
function cursorOffset(source: string, position: Position): number | undefined {
|
|
31
|
+
if (position.line < 0 || position.character < 0) return undefined;
|
|
32
|
+
const lines = source.split("\n");
|
|
33
|
+
if (
|
|
34
|
+
position.line >= lines.length ||
|
|
35
|
+
position.character > lines[position.line].length
|
|
36
|
+
)
|
|
37
|
+
return undefined;
|
|
38
|
+
return (
|
|
39
|
+
lines.slice(0, position.line).reduce((n, line) => n + line.length + 1, 0) +
|
|
40
|
+
position.character
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function activeArgument(
|
|
45
|
+
tokens: Token[],
|
|
46
|
+
offset: number,
|
|
47
|
+
): { start: number; end: number; index: number; closed: boolean } | undefined {
|
|
48
|
+
const stack: number[] = [];
|
|
49
|
+
for (
|
|
50
|
+
let i = 0;
|
|
51
|
+
i < tokens.length && tokens[i].span.start.offset < offset;
|
|
52
|
+
i++
|
|
53
|
+
) {
|
|
54
|
+
const token = tokens[i];
|
|
55
|
+
if (opening.has(token.type)) stack.push(i);
|
|
56
|
+
else if (
|
|
57
|
+
closing.has(token.type) &&
|
|
58
|
+
tokens[stack[stack.length - 1]]?.type === closing.get(token.type)
|
|
59
|
+
)
|
|
60
|
+
stack.pop();
|
|
61
|
+
}
|
|
62
|
+
const openIndex = [...stack]
|
|
63
|
+
.reverse()
|
|
64
|
+
.find((i) => tokens[i].type === TokenType.LPAREN);
|
|
65
|
+
if (openIndex === undefined) return undefined;
|
|
66
|
+
const previous = tokens[openIndex - 1];
|
|
67
|
+
if (
|
|
68
|
+
!previous ||
|
|
69
|
+
![
|
|
70
|
+
TokenType.IDENTIFIER,
|
|
71
|
+
TokenType.UPPER_IDENTIFIER,
|
|
72
|
+
TokenType.RPAREN,
|
|
73
|
+
TokenType.RBRACKET,
|
|
74
|
+
].includes(previous.type)
|
|
75
|
+
)
|
|
76
|
+
return undefined;
|
|
77
|
+
let depth = 0;
|
|
78
|
+
let start = tokens[openIndex].span.end.offset;
|
|
79
|
+
let index = 0;
|
|
80
|
+
for (let i = openIndex + 1; i < tokens.length; i++) {
|
|
81
|
+
const token = tokens[i];
|
|
82
|
+
if (
|
|
83
|
+
depth === 0 &&
|
|
84
|
+
(token.type === TokenType.COMMA || token.type === TokenType.RPAREN)
|
|
85
|
+
) {
|
|
86
|
+
if (token.span.start.offset >= offset)
|
|
87
|
+
return { start, end: token.span.start.offset, index, closed: true };
|
|
88
|
+
if (token.type === TokenType.RPAREN) return undefined;
|
|
89
|
+
start = token.span.end.offset;
|
|
90
|
+
index++;
|
|
91
|
+
} else if (opening.has(token.type)) depth++;
|
|
92
|
+
else if (closing.has(token.type)) depth = Math.max(0, depth - 1);
|
|
93
|
+
}
|
|
94
|
+
return { start, end: offset, index, closed: false };
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export function findSignatureHelp(
|
|
98
|
+
source: string,
|
|
99
|
+
uri: string,
|
|
100
|
+
position: Position,
|
|
101
|
+
documents: ReadonlyArray<{ uri: string; text: string }> = [],
|
|
102
|
+
): SignatureHelp | null {
|
|
103
|
+
const offset = cursorOffset(source, position);
|
|
104
|
+
if (offset === undefined || source.includes(marker)) return null;
|
|
105
|
+
try {
|
|
106
|
+
let tokens: Token[];
|
|
107
|
+
try {
|
|
108
|
+
tokens = new Lexer(source, uri).tokenize();
|
|
109
|
+
} catch (error) {
|
|
110
|
+
if (!(error instanceof FunScriptError)) throw error;
|
|
111
|
+
// The cursor is often inside a string that has not been closed yet.
|
|
112
|
+
tokens = new Lexer(
|
|
113
|
+
source.slice(0, offset) + '"' + source.slice(offset),
|
|
114
|
+
uri,
|
|
115
|
+
).tokenize();
|
|
116
|
+
}
|
|
117
|
+
const active = activeArgument(tokens, offset);
|
|
118
|
+
if (!active) return null;
|
|
119
|
+
const repaired =
|
|
120
|
+
`ts { declare const ${marker}: any; }\n` +
|
|
121
|
+
source.slice(0, active.start) +
|
|
122
|
+
marker +
|
|
123
|
+
(active.closed ? "" : ")") +
|
|
124
|
+
source.slice(active.end);
|
|
125
|
+
const filename = uri.startsWith("file:") ? fileURLToPath(uri) : uri;
|
|
126
|
+
const context = new TypeScriptCompilationContext(filename);
|
|
127
|
+
const result = Effect.runSync(
|
|
128
|
+
compileString(repaired, filename, { context, sourcemap: false }),
|
|
129
|
+
);
|
|
130
|
+
const openFiles = new Map<string, string>();
|
|
131
|
+
for (const document of documents) {
|
|
132
|
+
if (document.uri.startsWith("file:")) {
|
|
133
|
+
openFiles.set(resolve(fileURLToPath(document.uri)), document.text);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
const auxiliary = new Map<string, string>();
|
|
137
|
+
for (const declaration of result.ast.body) {
|
|
138
|
+
if (declaration.kind !== "ImportDeclaration") continue;
|
|
139
|
+
const specifier = declaration.source.parts
|
|
140
|
+
.map((part) => (part.kind === "StringRawPart" ? part.value : ""))
|
|
141
|
+
.join("");
|
|
142
|
+
const target = resolveFunModule(
|
|
143
|
+
filename,
|
|
144
|
+
specifier,
|
|
145
|
+
(file) => openFiles.has(file) || existsSync(file),
|
|
146
|
+
);
|
|
147
|
+
if (!target) continue;
|
|
148
|
+
const virtualFile = target.replace(
|
|
149
|
+
/\.funx?$/,
|
|
150
|
+
target.endsWith(".funx") ? ".tsx" : ".ts",
|
|
151
|
+
);
|
|
152
|
+
// A real TypeScript sibling must never masquerade as an explicit FunkScript import.
|
|
153
|
+
if (existsSync(virtualFile)) return null;
|
|
154
|
+
const importedSource =
|
|
155
|
+
openFiles.get(target) ?? readFileSync(target, "utf8");
|
|
156
|
+
const imported = Effect.runSync(
|
|
157
|
+
compileString(importedSource, target, { sourcemap: false }),
|
|
158
|
+
);
|
|
159
|
+
auxiliary.set(virtualFile, imported.typescript);
|
|
160
|
+
}
|
|
161
|
+
if (auxiliary.size) context.setAuxiliarySources(auxiliary);
|
|
162
|
+
const checked = context.check(result.typescript);
|
|
163
|
+
if (!checked) return null;
|
|
164
|
+
let call: ts.CallExpression | undefined;
|
|
165
|
+
const visit = (node: ts.Node): void => {
|
|
166
|
+
if (
|
|
167
|
+
ts.isIdentifier(node) &&
|
|
168
|
+
node.text === marker &&
|
|
169
|
+
ts.isCallExpression(node.parent) &&
|
|
170
|
+
node.parent.arguments.includes(node)
|
|
171
|
+
)
|
|
172
|
+
call = node.parent;
|
|
173
|
+
else ts.forEachChild(node, visit);
|
|
174
|
+
};
|
|
175
|
+
visit(checked.sourceFile);
|
|
176
|
+
if (!call) return null;
|
|
177
|
+
const signatures = checked.checker
|
|
178
|
+
.getTypeAtLocation(call.expression)
|
|
179
|
+
.getCallSignatures();
|
|
180
|
+
if (!signatures.length) return null;
|
|
181
|
+
const resolved = checked.checker.getResolvedSignature(call);
|
|
182
|
+
const selected = Math.max(
|
|
183
|
+
0,
|
|
184
|
+
signatures.findIndex(
|
|
185
|
+
(signature) =>
|
|
186
|
+
signature === resolved ||
|
|
187
|
+
(resolved &&
|
|
188
|
+
signature.getDeclaration() === resolved.getDeclaration()),
|
|
189
|
+
),
|
|
190
|
+
);
|
|
191
|
+
return {
|
|
192
|
+
signatures: signatures.map((signature) => ({
|
|
193
|
+
label: checked.checker.signatureToString(
|
|
194
|
+
signature,
|
|
195
|
+
call,
|
|
196
|
+
ts.TypeFormatFlags.NoTruncation,
|
|
197
|
+
),
|
|
198
|
+
documentation: {
|
|
199
|
+
kind: MarkupKind.Markdown,
|
|
200
|
+
value: ts.displayPartsToString(
|
|
201
|
+
signature.getDocumentationComment(checked.checker),
|
|
202
|
+
),
|
|
203
|
+
},
|
|
204
|
+
parameters: signature.getParameters().map((parameter) => ({
|
|
205
|
+
label: parameter.getName(),
|
|
206
|
+
documentation: {
|
|
207
|
+
kind: MarkupKind.Markdown,
|
|
208
|
+
value: ts.displayPartsToString(
|
|
209
|
+
parameter.getDocumentationComment(checked.checker),
|
|
210
|
+
),
|
|
211
|
+
},
|
|
212
|
+
})),
|
|
213
|
+
})),
|
|
214
|
+
activeSignature: selected,
|
|
215
|
+
activeParameter: active.index,
|
|
216
|
+
};
|
|
217
|
+
} catch (error) {
|
|
218
|
+
if (
|
|
219
|
+
error instanceof FunScriptError ||
|
|
220
|
+
error instanceof URIError ||
|
|
221
|
+
error instanceof TypeError
|
|
222
|
+
)
|
|
223
|
+
return null;
|
|
224
|
+
throw error;
|
|
225
|
+
}
|
|
226
|
+
}
|
package/src/lsp/validation.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { pathToFileURL } from "node:url";
|
|
1
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
2
2
|
import {
|
|
3
3
|
DiagnosticSeverity,
|
|
4
4
|
type Diagnostic,
|
|
@@ -134,7 +134,8 @@ export function validateFunScript(
|
|
|
134
134
|
const { diagnostics, ast } = validateSyntax(source, uri);
|
|
135
135
|
if (!diagnostics.length && ast) {
|
|
136
136
|
try {
|
|
137
|
-
const
|
|
137
|
+
const filename = uri.startsWith("file:") ? fileURLToPath(uri) : uri;
|
|
138
|
+
const context = new TypeScriptCompilationContext(filename);
|
|
138
139
|
if (!ast.body.some((decl) => decl.kind === "AsDeclaration"))
|
|
139
140
|
validateNumericComparisons(ast, source, context);
|
|
140
141
|
validateBooleanOperators(ast, source, context);
|
|
@@ -277,6 +277,16 @@ export function parseImportDeclaration(
|
|
|
277
277
|
namespaceBinding = ctx.parseAnyIdentifier();
|
|
278
278
|
} else {
|
|
279
279
|
ctx.consume(TokenType.LBRACE, "Expected '{' or '*' in import declaration");
|
|
280
|
+
const skipImportWhitespace = () => {
|
|
281
|
+
while (
|
|
282
|
+
ctx.match(TokenType.NEWLINE) ||
|
|
283
|
+
ctx.match(TokenType.INDENT) ||
|
|
284
|
+
ctx.match(TokenType.DEDENT)
|
|
285
|
+
) {
|
|
286
|
+
// Consume indentation tokens that only separate import specifiers.
|
|
287
|
+
}
|
|
288
|
+
};
|
|
289
|
+
skipImportWhitespace();
|
|
280
290
|
if (!ctx.check(TokenType.RBRACE)) {
|
|
281
291
|
do {
|
|
282
292
|
let specTypeOnly = false;
|
|
@@ -321,7 +331,23 @@ export function parseImportDeclaration(
|
|
|
321
331
|
local: localId,
|
|
322
332
|
span: { start: importedId.span.start, end: localId.span.end },
|
|
323
333
|
});
|
|
324
|
-
|
|
334
|
+
// Keep the newline as a recovery boundary if the next token cannot
|
|
335
|
+
// continue the import; it may start another top-level declaration.
|
|
336
|
+
let lookahead = 0;
|
|
337
|
+
while (
|
|
338
|
+
ctx.peekAhead(lookahead).type === TokenType.NEWLINE ||
|
|
339
|
+
ctx.peekAhead(lookahead).type === TokenType.INDENT ||
|
|
340
|
+
ctx.peekAhead(lookahead).type === TokenType.DEDENT
|
|
341
|
+
)
|
|
342
|
+
lookahead++;
|
|
343
|
+
if (
|
|
344
|
+
ctx.peekAhead(lookahead).type === TokenType.COMMA ||
|
|
345
|
+
ctx.peekAhead(lookahead).type === TokenType.RBRACE
|
|
346
|
+
)
|
|
347
|
+
skipImportWhitespace();
|
|
348
|
+
if (!ctx.match(TokenType.COMMA)) break;
|
|
349
|
+
skipImportWhitespace();
|
|
350
|
+
} while (!ctx.check(TokenType.RBRACE));
|
|
325
351
|
}
|
|
326
352
|
ctx.consume(TokenType.RBRACE, "Expected '}' after import specifiers");
|
|
327
353
|
}
|
package/src/plugins/type-view.ts
CHANGED
|
@@ -5,6 +5,11 @@ import * as path from "node:path";
|
|
|
5
5
|
import ts from "typescript";
|
|
6
6
|
import { compileString } from "../compiler.js";
|
|
7
7
|
import { TypeScriptCompilationContext } from "../compiler/typescript-context.js";
|
|
8
|
+
import {
|
|
9
|
+
DEFAULT_TYPE_VIEW_DIR,
|
|
10
|
+
TYPE_VIEW_MANIFEST,
|
|
11
|
+
} from "../compiler/type-view-paths.js";
|
|
12
|
+
import { isFunSourceFile } from "../compiler/modules/source-files.js";
|
|
8
13
|
|
|
9
14
|
export interface TypeViewOptions {
|
|
10
15
|
/** Project-relative source directories or files. Defaults to ["app"]. */
|
|
@@ -69,11 +74,14 @@ export class TypeView {
|
|
|
69
74
|
|
|
70
75
|
constructor(root: string, options: TypeViewOptions = {}) {
|
|
71
76
|
this.root = path.resolve(root);
|
|
72
|
-
this.outDir = path.resolve(
|
|
77
|
+
this.outDir = path.resolve(
|
|
78
|
+
this.root,
|
|
79
|
+
options.outDir ?? DEFAULT_TYPE_VIEW_DIR,
|
|
80
|
+
);
|
|
73
81
|
this.inputs = (options.include ?? ["app"]).map((input) =>
|
|
74
82
|
path.resolve(this.root, input),
|
|
75
83
|
);
|
|
76
|
-
this.manifest = path.join(this.outDir,
|
|
84
|
+
this.manifest = path.join(this.outDir, TYPE_VIEW_MANIFEST);
|
|
77
85
|
this.context = new TypeScriptCompilationContext(
|
|
78
86
|
path.join(this.root, "__funscript_type_view__.fun"),
|
|
79
87
|
);
|
|
@@ -116,7 +124,7 @@ export class TypeView {
|
|
|
116
124
|
throw error;
|
|
117
125
|
}
|
|
118
126
|
if (stat.isSymbolicLink()) return [];
|
|
119
|
-
if (stat.isFile()) return
|
|
127
|
+
if (stat.isFile()) return isFunSourceFile(entry) ? [entry] : [];
|
|
120
128
|
if (!stat.isDirectory()) return [];
|
|
121
129
|
const entries = await fs.readdir(entry, { withFileTypes: true });
|
|
122
130
|
const nested = entries
|
package/dist/Widget.tsx
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Schema } from "effect";
|
|
2
|
-
|
|
3
|
-
const Props = Schema.Struct({
|
|
4
|
-
name: Schema.String
|
|
5
|
-
});
|
|
6
|
-
type Props = typeof Props.Type;
|
|
7
|
-
const PropsFromUnknown = (input: unknown): Props => Schema.decodeUnknownSync(Props)(input);
|
|
8
|
-
|
|
9
|
-
export const Widget = (props: Props) => <div className="widget"><h3>{props.name}</h3></div>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"output-collisions.d.ts","sources":["../../src/cli/output-collisions.ts"],"names":[],"mappings":"AAMA,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,GACnC,MAAM,GAAG,SAAS,CAuCpB"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { existsSync } from "node:fs";
|
|
2
|
-
import * as path from "node:path";
|
|
3
|
-
import { FunScriptError } from "../errors.js";
|
|
4
|
-
import { Lexer } from "../lexer/lexer.js";
|
|
5
|
-
import { Parser } from "../parser/parser.js";
|
|
6
|
-
export function sourceOutputCollision(sources) {
|
|
7
|
-
const stems = new Map([...sources.keys()].map((file) => [
|
|
8
|
-
path.resolve(file).replace(/\.funx?$/, ""),
|
|
9
|
-
path.resolve(file),
|
|
10
|
-
]));
|
|
11
|
-
for (const [file, source] of sources) {
|
|
12
|
-
let declarations;
|
|
13
|
-
try {
|
|
14
|
-
declarations = new Parser(new Lexer(source, file).tokenize(), file, source).parse().body;
|
|
15
|
-
}
|
|
16
|
-
catch (error) {
|
|
17
|
-
if (!(error instanceof FunScriptError))
|
|
18
|
-
throw error;
|
|
19
|
-
continue;
|
|
20
|
-
}
|
|
21
|
-
for (const declaration of declarations) {
|
|
22
|
-
if (declaration.kind !== "ImportDeclaration" &&
|
|
23
|
-
declaration.kind !== "ExportFromDeclaration")
|
|
24
|
-
continue;
|
|
25
|
-
if (declaration.source.parts.length !== 1 ||
|
|
26
|
-
declaration.source.parts[0].kind !== "StringRawPart")
|
|
27
|
-
continue;
|
|
28
|
-
const specifier = declaration.source.parts[0].value;
|
|
29
|
-
if (!/^\.{1,2}\//.test(specifier) || !/\.tsx?$/.test(specifier))
|
|
30
|
-
continue;
|
|
31
|
-
const target = path.resolve(path.dirname(file), specifier);
|
|
32
|
-
const conflict = stems.get(target.replace(/\.tsx?$/, ""));
|
|
33
|
-
if (conflict && existsSync(target))
|
|
34
|
-
return `Build output collision: '${conflict}' and '${target}' both compile to the same JavaScript module. Rename one of the files.`;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return undefined;
|
|
38
|
-
}
|
|
39
|
-
//# sourceMappingURL=output-collisions.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"output-collisions.js","sources":["../../src/cli/output-collisions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,MAAM,UAAU,qBAAqB,CACnC,OAAoC;IAEpC,MAAM,KAAK,GAAG,IAAI,GAAG,CACnB,CAAC,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;QAChC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC;QAC1C,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;KACnB,CAAC,CACH,CAAC;IACF,KAAK,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,OAAO,EAAE,CAAC;QACrC,IAAI,YAAY,CAAC;QACjB,IAAI,CAAC;YACH,YAAY,GAAG,IAAI,MAAM,CACvB,IAAI,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,QAAQ,EAAE,EAClC,IAAI,EACJ,MAAM,CACP,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC;QACjB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,CAAC,KAAK,YAAY,cAAc,CAAC;gBAAE,MAAM,KAAK,CAAC;YACpD,SAAS;QACX,CAAC;QACD,KAAK,MAAM,WAAW,IAAI,YAAY,EAAE,CAAC;YACvC,IACE,WAAW,CAAC,IAAI,KAAK,mBAAmB;gBACxC,WAAW,CAAC,IAAI,KAAK,uBAAuB;gBAE5C,SAAS;YACX,IACE,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC;gBACrC,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,eAAe;gBAEpD,SAAS;YACX,MAAM,SAAS,GAAG,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;YACpD,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC;gBAAE,SAAS;YAC1E,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,SAAS,CAAC,CAAC;YAC3D,MAAM,QAAQ,GAAG,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,CAAC;YAC1D,IAAI,QAAQ,IAAI,UAAU,CAAC,MAAM,CAAC;gBAChC,OAAO,4BAA4B,QAAQ,UAAU,MAAM,wEAAwE,CAAC;QACxI,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { Program, RecordTypeNode, TypeNode } from "../ast/types.js";
|
|
2
|
-
/** Resolve only unambiguous FunScript functions; unknown targets remain restricted. */
|
|
3
|
-
export declare function resolveImportedRecordFunctions(ast: Program, filename: string, virtualSources?: ReadonlyMap<string, string>, importedContracts?: Map<string, RecordTypeNode>, importedIdentitySchemas?: Set<string>, importedGenericDataSchemas?: Map<string, number>, importedDataSchemas?: Set<string>, importedNullishSchemas?: Map<string, Map<string, TypeNode>>, importedTaggedUnionVariants?: Map<string, Set<string>>): Map<string, ReadonlySet<number>>;
|
|
4
|
-
//# sourceMappingURL=imported-record-functions.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"imported-record-functions.d.ts","sources":["../../src/compiler/imported-record-functions.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAKV,OAAO,EACP,cAAc,EACd,QAAQ,EAET,MAAM,iBAAiB,CAAC;AAOzB,uFAAuF;AACvF,wBAAgB,8BAA8B,CAC5C,GAAG,EAAE,OAAO,EACZ,QAAQ,EAAE,MAAM,EAChB,cAAc,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,EAC5C,iBAAiB,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,EAC/C,uBAAuB,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,EACrC,0BAA0B,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAChD,mBAAmB,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,EACjC,sBAAsB,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,EAC3D,2BAA2B,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,GACrD,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC,CA07BlC"}
|