@alloy-js/go 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1 -0
- package/LICENSE +7 -0
- package/api-extractor.json +4 -0
- package/dist/src/builtins/fmt/fmt.d.ts +147 -0
- package/dist/src/builtins/fmt/fmt.d.ts.map +1 -0
- package/dist/src/builtins/fmt/fmt.js +148 -0
- package/dist/src/builtins/fmt/fmt.js.map +1 -0
- package/dist/src/builtins/index.d.ts +2004 -0
- package/dist/src/builtins/index.d.ts.map +1 -0
- package/dist/src/builtins/index.js +9 -0
- package/dist/src/builtins/index.js.map +1 -0
- package/dist/src/builtins/io/io.d.ts +648 -0
- package/dist/src/builtins/io/io.d.ts.map +1 -0
- package/dist/src/builtins/io/io.js +650 -0
- package/dist/src/builtins/io/io.js.map +1 -0
- package/dist/src/builtins/net/net.d.ts +1210 -0
- package/dist/src/builtins/net/net.d.ts.map +1 -0
- package/dist/src/builtins/net/net.js +1212 -0
- package/dist/src/builtins/net/net.js.map +1 -0
- package/dist/src/components/ImportStatement.d.ts +15 -0
- package/dist/src/components/ImportStatement.d.ts.map +1 -0
- package/dist/src/components/ImportStatement.js +90 -0
- package/dist/src/components/ImportStatement.js.map +1 -0
- package/dist/src/components/ModuleDirectory.d.ts +8 -0
- package/dist/src/components/ModuleDirectory.d.ts.map +1 -0
- package/dist/src/components/ModuleDirectory.js +20 -0
- package/dist/src/components/ModuleDirectory.js.map +1 -0
- package/dist/src/components/Name.d.ts +2 -0
- package/dist/src/components/Name.d.ts.map +1 -0
- package/dist/src/components/Name.js +12 -0
- package/dist/src/components/Name.js.map +1 -0
- package/dist/src/components/Reference.d.ts +6 -0
- package/dist/src/components/Reference.d.ts.map +1 -0
- package/dist/src/components/Reference.js +15 -0
- package/dist/src/components/Reference.js.map +1 -0
- package/dist/src/components/SourceDirectory.d.ts +6 -0
- package/dist/src/components/SourceDirectory.d.ts.map +1 -0
- package/dist/src/components/SourceDirectory.js +30 -0
- package/dist/src/components/SourceDirectory.js.map +1 -0
- package/dist/src/components/SourceFile.d.ts +16 -0
- package/dist/src/components/SourceFile.d.ts.map +1 -0
- package/dist/src/components/SourceFile.js +75 -0
- package/dist/src/components/SourceFile.js.map +1 -0
- package/dist/src/components/doc/comment.d.ts +21 -0
- package/dist/src/components/doc/comment.d.ts.map +1 -0
- package/dist/src/components/doc/comment.js +30 -0
- package/dist/src/components/doc/comment.js.map +1 -0
- package/dist/src/components/doc/comment.test.d.ts +2 -0
- package/dist/src/components/doc/comment.test.d.ts.map +1 -0
- package/dist/src/components/doc/comment.test.js +215 -0
- package/dist/src/components/doc/comment.test.js.map +1 -0
- package/dist/src/components/function/function.d.ts +31 -0
- package/dist/src/components/function/function.d.ts.map +1 -0
- package/dist/src/components/function/function.js +134 -0
- package/dist/src/components/function/function.js.map +1 -0
- package/dist/src/components/function/function.test.d.ts +2 -0
- package/dist/src/components/function/function.test.d.ts.map +1 -0
- package/dist/src/components/function/function.test.js +410 -0
- package/dist/src/components/function/function.test.js.map +1 -0
- package/dist/src/components/index.d.ts +16 -0
- package/dist/src/components/index.d.ts.map +1 -0
- package/dist/src/components/index.js +16 -0
- package/dist/src/components/index.js.map +1 -0
- package/dist/src/components/interface/declaration.d.ts +68 -0
- package/dist/src/components/interface/declaration.d.ts.map +1 -0
- package/dist/src/components/interface/declaration.js +181 -0
- package/dist/src/components/interface/declaration.js.map +1 -0
- package/dist/src/components/interface/interface.test.d.ts +2 -0
- package/dist/src/components/interface/interface.test.d.ts.map +1 -0
- package/dist/src/components/interface/interface.test.js +517 -0
- package/dist/src/components/interface/interface.test.js.map +1 -0
- package/dist/src/components/package.test.d.ts +2 -0
- package/dist/src/components/package.test.d.ts.map +1 -0
- package/dist/src/components/package.test.js +89 -0
- package/dist/src/components/package.test.js.map +1 -0
- package/dist/src/components/parameters/parameters.d.ts +15 -0
- package/dist/src/components/parameters/parameters.d.ts.map +1 -0
- package/dist/src/components/parameters/parameters.js +58 -0
- package/dist/src/components/parameters/parameters.js.map +1 -0
- package/dist/src/components/parameters/typeparameters.d.ts +25 -0
- package/dist/src/components/parameters/typeparameters.d.ts.map +1 -0
- package/dist/src/components/parameters/typeparameters.js +53 -0
- package/dist/src/components/parameters/typeparameters.js.map +1 -0
- package/dist/src/components/pointer/pointer.d.ts +9 -0
- package/dist/src/components/pointer/pointer.d.ts.map +1 -0
- package/dist/src/components/pointer/pointer.js +8 -0
- package/dist/src/components/pointer/pointer.js.map +1 -0
- package/dist/src/components/stc/index.d.ts +27 -0
- package/dist/src/components/stc/index.d.ts.map +1 -0
- package/dist/src/components/stc/index.js +27 -0
- package/dist/src/components/stc/index.js.map +1 -0
- package/dist/src/components/struct/declaration.d.ts +62 -0
- package/dist/src/components/struct/declaration.d.ts.map +1 -0
- package/dist/src/components/struct/declaration.js +161 -0
- package/dist/src/components/struct/declaration.js.map +1 -0
- package/dist/src/components/struct/struct.test.d.ts +2 -0
- package/dist/src/components/struct/struct.test.d.ts.map +1 -0
- package/dist/src/components/struct/struct.test.js +741 -0
- package/dist/src/components/struct/struct.test.js.map +1 -0
- package/dist/src/components/type/declaration.d.ts +29 -0
- package/dist/src/components/type/declaration.d.ts.map +1 -0
- package/dist/src/components/type/declaration.js +63 -0
- package/dist/src/components/type/declaration.js.map +1 -0
- package/dist/src/components/var/declaration.d.ts +27 -0
- package/dist/src/components/var/declaration.d.ts.map +1 -0
- package/dist/src/components/var/declaration.js +84 -0
- package/dist/src/components/var/declaration.js.map +1 -0
- package/dist/src/components/var/var-declaration.test.d.ts +2 -0
- package/dist/src/components/var/var-declaration.test.d.ts.map +1 -0
- package/dist/src/components/var/var-declaration.test.js +340 -0
- package/dist/src/components/var/var-declaration.test.js.map +1 -0
- package/dist/src/context/package.d.ts +9 -0
- package/dist/src/context/package.d.ts.map +1 -0
- package/dist/src/context/package.js +6 -0
- package/dist/src/context/package.js.map +1 -0
- package/dist/src/create-module.d.ts +47 -0
- package/dist/src/create-module.d.ts.map +1 -0
- package/dist/src/create-module.js +158 -0
- package/dist/src/create-module.js.map +1 -0
- package/dist/src/create-module.test.d.ts +2 -0
- package/dist/src/create-module.test.d.ts.map +1 -0
- package/dist/src/create-module.test.js +147 -0
- package/dist/src/create-module.test.js.map +1 -0
- package/dist/src/index.d.ts +6 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +6 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/name-policy.d.ts +5 -0
- package/dist/src/name-policy.d.ts.map +1 -0
- package/dist/src/name-policy.js +27 -0
- package/dist/src/name-policy.js.map +1 -0
- package/dist/src/scopes/contexts.d.ts +9 -0
- package/dist/src/scopes/contexts.d.ts.map +1 -0
- package/dist/src/scopes/contexts.js +34 -0
- package/dist/src/scopes/contexts.js.map +1 -0
- package/dist/src/scopes/factories.d.ts +7 -0
- package/dist/src/scopes/factories.d.ts.map +1 -0
- package/dist/src/scopes/factories.js +16 -0
- package/dist/src/scopes/factories.js.map +1 -0
- package/dist/src/scopes/function.d.ts +9 -0
- package/dist/src/scopes/function.d.ts.map +1 -0
- package/dist/src/scopes/function.js +14 -0
- package/dist/src/scopes/function.js.map +1 -0
- package/dist/src/scopes/go.d.ts +8 -0
- package/dist/src/scopes/go.d.ts.map +1 -0
- package/dist/src/scopes/go.js +12 -0
- package/dist/src/scopes/go.js.map +1 -0
- package/dist/src/scopes/index.d.ts +10 -0
- package/dist/src/scopes/index.d.ts.map +1 -0
- package/dist/src/scopes/index.js +10 -0
- package/dist/src/scopes/index.js.map +1 -0
- package/dist/src/scopes/lexical.d.ts +8 -0
- package/dist/src/scopes/lexical.d.ts.map +1 -0
- package/dist/src/scopes/lexical.js +11 -0
- package/dist/src/scopes/lexical.js.map +1 -0
- package/dist/src/scopes/module.d.ts +9 -0
- package/dist/src/scopes/module.d.ts.map +1 -0
- package/dist/src/scopes/module.js +31 -0
- package/dist/src/scopes/module.js.map +1 -0
- package/dist/src/scopes/named-type.d.ts +23 -0
- package/dist/src/scopes/named-type.d.ts.map +1 -0
- package/dist/src/scopes/named-type.js +33 -0
- package/dist/src/scopes/named-type.js.map +1 -0
- package/dist/src/scopes/package.d.ts +11 -0
- package/dist/src/scopes/package.d.ts.map +1 -0
- package/dist/src/scopes/package.js +39 -0
- package/dist/src/scopes/package.js.map +1 -0
- package/dist/src/scopes/source-file.d.ts +17 -0
- package/dist/src/scopes/source-file.d.ts.map +1 -0
- package/dist/src/scopes/source-file.js +42 -0
- package/dist/src/scopes/source-file.js.map +1 -0
- package/dist/src/symbols/factories.d.ts +25 -0
- package/dist/src/symbols/factories.d.ts.map +1 -0
- package/dist/src/symbols/factories.js +114 -0
- package/dist/src/symbols/factories.js.map +1 -0
- package/dist/src/symbols/function.d.ts +10 -0
- package/dist/src/symbols/function.d.ts.map +1 -0
- package/dist/src/symbols/function.js +12 -0
- package/dist/src/symbols/function.js.map +1 -0
- package/dist/src/symbols/go.d.ts +22 -0
- package/dist/src/symbols/go.d.ts.map +1 -0
- package/dist/src/symbols/go.js +56 -0
- package/dist/src/symbols/go.js.map +1 -0
- package/dist/src/symbols/index.d.ts +7 -0
- package/dist/src/symbols/index.d.ts.map +1 -0
- package/dist/src/symbols/index.js +7 -0
- package/dist/src/symbols/index.js.map +1 -0
- package/dist/src/symbols/named-type.d.ts +24 -0
- package/dist/src/symbols/named-type.d.ts.map +1 -0
- package/dist/src/symbols/named-type.js +53 -0
- package/dist/src/symbols/named-type.js.map +1 -0
- package/dist/src/symbols/package.d.ts +18 -0
- package/dist/src/symbols/package.d.ts.map +1 -0
- package/dist/src/symbols/package.js +38 -0
- package/dist/src/symbols/package.js.map +1 -0
- package/dist/src/symbols/reference.d.ts +3 -0
- package/dist/src/symbols/reference.d.ts.map +1 -0
- package/dist/src/symbols/reference.js +76 -0
- package/dist/src/symbols/reference.js.map +1 -0
- package/dist/test/utils.d.ts +8 -0
- package/dist/test/utils.d.ts.map +1 -0
- package/dist/test/utils.js +68 -0
- package/dist/test/utils.js.map +1 -0
- package/dist/test/vitest.setup.d.ts +2 -0
- package/dist/test/vitest.setup.d.ts.map +1 -0
- package/dist/test/vitest.setup.js +2 -0
- package/dist/test/vitest.setup.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +45 -0
- package/src/builtins/fmt/fmt.ts +78 -0
- package/src/builtins/index.ts +9 -0
- package/src/builtins/io/io.ts +355 -0
- package/src/builtins/net/net.ts +502 -0
- package/src/components/ImportStatement.tsx +115 -0
- package/src/components/ModuleDirectory.tsx +18 -0
- package/src/components/Name.tsx +11 -0
- package/src/components/Reference.tsx +18 -0
- package/src/components/SourceDirectory.tsx +32 -0
- package/src/components/SourceFile.tsx +74 -0
- package/src/components/doc/comment.test.tsx +278 -0
- package/src/components/doc/comment.tsx +40 -0
- package/src/components/function/function.test.tsx +387 -0
- package/src/components/function/function.tsx +194 -0
- package/src/components/index.ts +15 -0
- package/src/components/interface/declaration.tsx +250 -0
- package/src/components/interface/interface.test.tsx +390 -0
- package/src/components/package.test.tsx +63 -0
- package/src/components/parameters/parameters.tsx +74 -0
- package/src/components/parameters/typeparameters.tsx +78 -0
- package/src/components/pointer/pointer.tsx +12 -0
- package/src/components/stc/index.ts +27 -0
- package/src/components/struct/declaration.tsx +228 -0
- package/src/components/struct/struct.test.tsx +558 -0
- package/src/components/type/declaration.tsx +93 -0
- package/src/components/var/declaration.tsx +138 -0
- package/src/components/var/var-declaration.test.tsx +236 -0
- package/src/context/package.ts +13 -0
- package/src/create-module.test.tsx +128 -0
- package/src/create-module.ts +347 -0
- package/src/index.ts +5 -0
- package/src/name-policy.ts +65 -0
- package/src/scopes/contexts.ts +45 -0
- package/src/scopes/factories.ts +29 -0
- package/src/scopes/function.ts +22 -0
- package/src/scopes/go.ts +18 -0
- package/src/scopes/index.ts +9 -0
- package/src/scopes/lexical.ts +14 -0
- package/src/scopes/module.ts +35 -0
- package/src/scopes/named-type.ts +49 -0
- package/src/scopes/package.ts +55 -0
- package/src/scopes/source-file.ts +66 -0
- package/src/symbols/factories.ts +234 -0
- package/src/symbols/function.ts +17 -0
- package/src/symbols/go.ts +82 -0
- package/src/symbols/index.ts +6 -0
- package/src/symbols/named-type.ts +90 -0
- package/src/symbols/package.ts +54 -0
- package/src/symbols/reference.ts +87 -0
- package/temp/api.json +8753 -0
- package/test/utils.tsx +77 -0
- package/test/vitest.setup.ts +1 -0
- package/tsconfig.json +15 -0
- package/tsdoc-metadata.json +11 -0
- package/vitest.config.ts +13 -0
package/test/utils.tsx
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Children,
|
|
3
|
+
ContentOutputFile,
|
|
4
|
+
Output,
|
|
5
|
+
OutputDirectory,
|
|
6
|
+
OutputFile,
|
|
7
|
+
PrintTreeOptions,
|
|
8
|
+
render,
|
|
9
|
+
} from "@alloy-js/core";
|
|
10
|
+
import { dedent } from "@alloy-js/core/testing";
|
|
11
|
+
import { expect } from "vitest";
|
|
12
|
+
import * as go from "../src/index.js";
|
|
13
|
+
|
|
14
|
+
export function toSourceText(c: Children, options?: PrintTreeOptions): string {
|
|
15
|
+
const res = render(
|
|
16
|
+
<Output>
|
|
17
|
+
<go.SourceFile path="test.go">{c}</go.SourceFile>
|
|
18
|
+
</Output>,
|
|
19
|
+
options,
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
return findFile(res, "test.go").contents;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function findFile(
|
|
26
|
+
res: OutputDirectory,
|
|
27
|
+
path: string,
|
|
28
|
+
): ContentOutputFile {
|
|
29
|
+
const result = findFileWorker(res, path);
|
|
30
|
+
|
|
31
|
+
if (!result) {
|
|
32
|
+
throw new Error("Expected to find file " + path);
|
|
33
|
+
}
|
|
34
|
+
return result as ContentOutputFile;
|
|
35
|
+
|
|
36
|
+
function findFileWorker(
|
|
37
|
+
res: OutputDirectory,
|
|
38
|
+
path: string,
|
|
39
|
+
): OutputFile | null {
|
|
40
|
+
for (const item of res.contents) {
|
|
41
|
+
if (item.kind === "file") {
|
|
42
|
+
if (item.path === path) {
|
|
43
|
+
return item;
|
|
44
|
+
}
|
|
45
|
+
continue;
|
|
46
|
+
} else {
|
|
47
|
+
const found = findFileWorker(item, path);
|
|
48
|
+
if (found) {
|
|
49
|
+
return found;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function assertFileContents(
|
|
58
|
+
res: OutputDirectory,
|
|
59
|
+
expectedFiles: Record<string, string>,
|
|
60
|
+
) {
|
|
61
|
+
for (const [path, contents] of Object.entries(expectedFiles)) {
|
|
62
|
+
const file = findFile(res, path);
|
|
63
|
+
expect(file.contents.trim()).toBe(dedent(contents).trim());
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function TestPackage(props: { children: Children }): Children {
|
|
68
|
+
return (
|
|
69
|
+
<Output>
|
|
70
|
+
<go.ModuleDirectory name="github.com/alloy-framework/alloy">
|
|
71
|
+
<go.SourceDirectory path=".">
|
|
72
|
+
<go.SourceFile path="Test.go">{props.children}</go.SourceFile>
|
|
73
|
+
</go.SourceDirectory>
|
|
74
|
+
</go.ModuleDirectory>
|
|
75
|
+
</Output>
|
|
76
|
+
);
|
|
77
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "@alloy-js/core/testing";
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../tsconfig.base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"emitDeclarationOnly": true,
|
|
5
|
+
"declaration": true,
|
|
6
|
+
"outDir": "dist",
|
|
7
|
+
"types": ["@alloy-js/core/testing/matchers"],
|
|
8
|
+
"paths": {
|
|
9
|
+
"#components/*": ["./src/components/*"]
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"references": [{ "path": "../core" }],
|
|
13
|
+
"include": ["src/**/*.ts", "src/**/*.tsx", "test/**/*.ts", "test/**/*.tsx"],
|
|
14
|
+
"exclude": ["node_modules", "dist"]
|
|
15
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// This file is read by tools that parse documentation comments conforming to the TSDoc standard.
|
|
2
|
+
// It should be published with your NPM package. It should not be tracked by Git.
|
|
3
|
+
{
|
|
4
|
+
"tsdocVersion": "0.12",
|
|
5
|
+
"toolPackages": [
|
|
6
|
+
{
|
|
7
|
+
"packageName": "@microsoft/api-extractor",
|
|
8
|
+
"packageVersion": "7.52.9"
|
|
9
|
+
}
|
|
10
|
+
]
|
|
11
|
+
}
|
package/vitest.config.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import alloyPlugin from "@alloy-js/rollup-plugin";
|
|
2
|
+
import { defineConfig } from "vitest/config";
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
esbuild: {
|
|
6
|
+
jsx: "preserve",
|
|
7
|
+
sourcemap: "both",
|
|
8
|
+
},
|
|
9
|
+
test: {
|
|
10
|
+
setupFiles: ["./test/vitest.setup.ts"],
|
|
11
|
+
},
|
|
12
|
+
plugins: [alloyPlugin()],
|
|
13
|
+
});
|