@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
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { createComponent as _$createComponent, memo as _$memo, createIntrinsic as _$createIntrinsic } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { createSymbolSlot, Declaration, For, Indent } from "@alloy-js/core";
|
|
3
|
+
import { createParameterSymbol } from "../../symbols/factories.js";
|
|
4
|
+
import { Name } from "../Name.js";
|
|
5
|
+
/** Define a parameter to be used in functions. */
|
|
6
|
+
export function FunctionParameter(props) {
|
|
7
|
+
const TypeSlot = createSymbolSlot();
|
|
8
|
+
const memberSymbol = createParameterSymbol(props.name, {
|
|
9
|
+
refkeys: props.refkey,
|
|
10
|
+
type: TypeSlot.firstSymbol
|
|
11
|
+
});
|
|
12
|
+
return _$createComponent(Declaration, {
|
|
13
|
+
symbol: memberSymbol,
|
|
14
|
+
get children() {
|
|
15
|
+
return [_$createComponent(Name, {}), " ", _$memo(() => props.variadic ? "..." : null), _$createComponent(TypeSlot, {
|
|
16
|
+
get children() {
|
|
17
|
+
return props.type;
|
|
18
|
+
}
|
|
19
|
+
})];
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
/** Render a collection of parameters */
|
|
24
|
+
export function FunctionParameters(props) {
|
|
25
|
+
const params = props.parameters ?? [];
|
|
26
|
+
for (let i = 0; i < (params.length ?? 0); i++) {
|
|
27
|
+
if (i < params.length - 1 && params[i].variadic) {
|
|
28
|
+
throw new Error("Variadic parameter must be the last parameter.");
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return _$createIntrinsic("group", {
|
|
32
|
+
get children() {
|
|
33
|
+
return ["(", _$memo(() => _$memo(() => !!props.parameters)() && _$createComponent(Indent, {
|
|
34
|
+
softline: true,
|
|
35
|
+
get children() {
|
|
36
|
+
return _$createComponent(For, {
|
|
37
|
+
each: params,
|
|
38
|
+
get joiner() {
|
|
39
|
+
return [",", _$createIntrinsic("ifBreak", {
|
|
40
|
+
flatContents: " ",
|
|
41
|
+
get children() {
|
|
42
|
+
return _$createIntrinsic("sbr", {});
|
|
43
|
+
}
|
|
44
|
+
})];
|
|
45
|
+
},
|
|
46
|
+
get ender() {
|
|
47
|
+
return _$createIntrinsic("ifBreak", {
|
|
48
|
+
children: ","
|
|
49
|
+
});
|
|
50
|
+
},
|
|
51
|
+
children: param => _$createComponent(FunctionParameter, param)
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
})), _$createIntrinsic("sbr", {}), ")"];
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=parameters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createSymbolSlot","Declaration","For","Indent","createParameterSymbol","Name","FunctionParameter","props","TypeSlot","memberSymbol","name","refkeys","refkey","type","firstSymbol","_$createComponent","symbol","children","_$memo","variadic","FunctionParameters","params","parameters","i","length","Error","_$createIntrinsic","softline","each","joiner","flatContents","ender","param"],"sources":["../../../../src/components/parameters/parameters.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAEEA,gBAAgB,EAChBC,WAAW,EACXC,GAAG,EACHC,MAAM,QAGD,gBAAgB;AACvB,SAASC,qBAAqB,QAAQ,4BAA4B;AAClE,SAASC,IAAI;AASb;AACA,OAAO,SAASC,iBAAiBA,CAACC,KAA6B,EAAE;EAC/D,MAAMC,QAAQ,GAAGR,gBAAgB,CAAC,CAAC;EAEnC,MAAMS,YAAY,GAAGL,qBAAqB,CAACG,KAAK,CAACG,IAAI,EAAE;IACrDC,OAAO,EA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A,CAAMT,iBAAiB,EAAK0B,KAAK;UAAI;QAAA;MAAA,EAGjD,GAAAN,iBAAA,aAEA,GAAG;IAAA;EAAA;AAGV","ignoreList":[]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Children, Namekey, Refkey } from "@alloy-js/core";
|
|
2
|
+
/**
|
|
3
|
+
* Information for a Go generic type parameter.
|
|
4
|
+
*/
|
|
5
|
+
export interface TypeParameterProps {
|
|
6
|
+
/**
|
|
7
|
+
* The name of the type parameter.
|
|
8
|
+
*/
|
|
9
|
+
name: string | Namekey;
|
|
10
|
+
/**
|
|
11
|
+
* The parameter constraint
|
|
12
|
+
*/
|
|
13
|
+
constraint: Children;
|
|
14
|
+
/**
|
|
15
|
+
* A refkey for this type parameter.
|
|
16
|
+
*/
|
|
17
|
+
refkey?: Refkey;
|
|
18
|
+
}
|
|
19
|
+
export declare function TypeParameter(props: TypeParameterProps): Children;
|
|
20
|
+
export interface TypeParametersProps {
|
|
21
|
+
/** Parameters */
|
|
22
|
+
parameters?: TypeParameterProps[];
|
|
23
|
+
}
|
|
24
|
+
export declare function TypeParameters(props: TypeParametersProps): Children;
|
|
25
|
+
//# sourceMappingURL=typeparameters.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typeparameters.d.ts","sourceRoot":"","sources":["../../../../src/components/parameters/typeparameters.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAKR,OAAO,EACP,MAAM,EACP,MAAM,gBAAgB,CAAC;AAGxB;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IAEvB;;OAEG;IACH,UAAU,EAAE,QAAQ,CAAC;IAErB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,YAStD;AAED,MAAM,WAAW,mBAAmB;IAClC,iBAAiB;IACjB,UAAU,CAAC,EAAE,kBAAkB,EAAE,CAAC;CACnC;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,YA8BxD"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { createComponent as _$createComponent, memo as _$memo, createIntrinsic as _$createIntrinsic } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { For, Indent, MemberDeclaration, MemberName } from "@alloy-js/core";
|
|
3
|
+
import { createTypeParameterSymbol } from "../../symbols/factories.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Information for a Go generic type parameter.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export function TypeParameter(props) {
|
|
10
|
+
const symbol = createTypeParameterSymbol(props.name, {
|
|
11
|
+
refkeys: props.refkey
|
|
12
|
+
});
|
|
13
|
+
return _$createComponent(MemberDeclaration, {
|
|
14
|
+
symbol: symbol,
|
|
15
|
+
get children() {
|
|
16
|
+
return [_$createComponent(MemberName, {}), " ", _$memo(() => props.constraint)];
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
export function TypeParameters(props) {
|
|
21
|
+
if (!props.parameters || props.parameters.length === 0) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
return _$createIntrinsic("group", {
|
|
25
|
+
get children() {
|
|
26
|
+
return ["[", _$memo(() => _$memo(() => !!props.parameters)() && _$createComponent(Indent, {
|
|
27
|
+
softline: true,
|
|
28
|
+
get children() {
|
|
29
|
+
return _$createComponent(For, {
|
|
30
|
+
get each() {
|
|
31
|
+
return props.parameters;
|
|
32
|
+
},
|
|
33
|
+
get joiner() {
|
|
34
|
+
return [",", _$createIntrinsic("ifBreak", {
|
|
35
|
+
flatContents: " ",
|
|
36
|
+
get children() {
|
|
37
|
+
return _$createIntrinsic("sbr", {});
|
|
38
|
+
}
|
|
39
|
+
})];
|
|
40
|
+
},
|
|
41
|
+
get ender() {
|
|
42
|
+
return _$createIntrinsic("ifBreak", {
|
|
43
|
+
children: ","
|
|
44
|
+
});
|
|
45
|
+
},
|
|
46
|
+
children: param => _$createComponent(TypeParameter, param)
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
})), _$createIntrinsic("sbr", {}), "]"];
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=typeparameters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["For","Indent","MemberDeclaration","MemberName","createTypeParameterSymbol","TypeParameter","props","symbol","name","refkeys","refkey","_$createComponent","children","_$memo","constraint","TypeParameters","parameters","length","_$createIntrinsic","softline","each","joiner","flatContents","ender","param"],"sources":["../../../../src/components/parameters/typeparameters.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAEEA,GAAG,EACHC,MAAM,EACNC,iBAAiB,EACjBC,UAAU,QAGL,gBAAgB;AACvB,SAASC,yBAAyB,QAAQ,4BAA4B;;AAEtE;AACA;AACA;;AAkBA,OAAO,SAASC,aAAaA,CAACC,KAAyB,EAAE;EACvD,MAAMC,MAAM,GAAGH,yBAAyB,CAACE,KAAK,CAACE,IAAI,EAAE;IACnDC,OAAO,EAAEH,KAAK,CAACI;EACjB,CAAC,CAAC;EACF,OAAAC,iBAAA,CACGT,iBAAiB;IAACK,MAAM,EAAEA,MAAM;IAAA,IAAAK,SAAA;MAAA,QAAAD,iBAAA,CAC9BR,UAAU,YAAAU,MAAA,OAAKP,KAAK,CAACQ,UAAU;IAAA;EAAA;AAGtC;AAOA,OAAO,SAASC,cAAcA,CAACT,KAA0B,EAAE;EACzD,IAAI,CAACA,KAAK,CAACU,UAAU,IAAIV,KAAK,CAACU,UAAU,CAACC,MAAM,KAAK,CAAC,EAAE;IACtD,OAAO,IAAI;EACb;EAEA,OAAAC,iBAAA;IAAA,IAAAN,SAAA;MAAA,QAEK,GAAG,EAAAC,MAAA,OACHA,MAAA,SAAAP,KAAK,CAACU,UAAU,OAAAL,iBAAA,CACdV,MAAM;QAACkB,QAAQ;QAAA,IAAAP,SAAA;UAAA,OAAAD,iBAAA,CACbX,GAAG;YAAA,IACFoB,IAAIA,CAAA;cAAA,OAAEd,KAAK,CAACU,UAAU;YAAA;YAAA,IACtBK,MAAMA,CAAA;cAAA,QAED,GAAG,EAAAH,iBAAA;gBACKI,YAAY;gBAAA,IAAAV,SAAA;kBAAA,OAAAM,iBAAA;gBAAA;cAAA;YAAA;YAAA,IAKzBK,KAAKA,CAAA;cAAA,OAAAL,iBAAA;gBAAAN,QAAA;cAAA;YAAA;YAAAA,QAAA,EAEHY,KAAK,IAAAb,iBAAA,CAAMN,aAAa,EAAKmB,KAAK;UAAI;QAAA;MAAA,EAG7C,GAAAN,iBAAA,aAEA,GAAG;IAAA;EAAA;AAGV","ignoreList":[]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Children } from "@alloy-js/core";
|
|
2
|
+
export interface PointerProps {
|
|
3
|
+
children: Children;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* A Go pointer type that wraps the given type.
|
|
7
|
+
*/
|
|
8
|
+
export declare function Pointer(props: PointerProps): Children;
|
|
9
|
+
//# sourceMappingURL=pointer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pointer.d.ts","sourceRoot":"","sources":["../../../../src/components/pointer/pointer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,QAAQ,CAAC;CACpB;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,YAAY,YAE1C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Pointer","props","_$memo","children"],"sources":["../../../../src/components/pointer/pointer.tsx"],"sourcesContent":[null],"mappings":";AAMA;AACA;AACA;AACA,OAAO,SAASA,OAAOA,CAACC,KAAmB,EAAE;EAC3C,aAAAC,MAAA,OAAWD,KAAK,CAACE,QAAQ;AAC3B","ignoreList":[]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as core from "@alloy-js/core";
|
|
2
|
+
import * as base from "../index.js";
|
|
3
|
+
export declare const LineComment: core.StcSignature<base.LineCommentProps>;
|
|
4
|
+
export declare const BlockComment: core.StcSignature<base.BlockCommentProps>;
|
|
5
|
+
export declare const FunctionDeclaration: core.StcSignature<base.FunctionProps>;
|
|
6
|
+
export declare const FunctionReceiver: core.StcSignature<base.FuncReceiverProps>;
|
|
7
|
+
export declare const InterfaceDeclaration: core.StcSignature<base.InterfaceDeclarationProps>;
|
|
8
|
+
export declare const InterfaceFunction: core.StcSignature<base.InterfaceFunctionProps>;
|
|
9
|
+
export declare const InterfaceEmbed: core.StcSignature<base.InterfaceEmbedProps>;
|
|
10
|
+
export declare const FunctionParameter: core.StcSignature<base.FunctionParameterProps>;
|
|
11
|
+
export declare const FunctionParameters: core.StcSignature<base.FunctionParametersProps>;
|
|
12
|
+
export declare const Pointer: core.StcSignature<base.PointerProps>;
|
|
13
|
+
export declare const StructDeclaration: core.StcSignature<base.StructDeclarationProps>;
|
|
14
|
+
export declare const StructMember: core.StcSignature<base.StructMemberProps>;
|
|
15
|
+
export declare const StructEmbed: core.StcSignature<base.StructEmbedProps>;
|
|
16
|
+
export declare const TypeDeclarationGroup: core.StcSignature<base.TypeDeclarationGroupProps>;
|
|
17
|
+
export declare const TypeDeclaration: core.StcSignature<base.TypeDeclarationProps>;
|
|
18
|
+
export declare const VariableDeclarationGroup: core.StcSignature<base.VariableDeclarationGroupProps>;
|
|
19
|
+
export declare const VariableDeclaration: core.StcSignature<base.VariableDeclarationProps>;
|
|
20
|
+
export declare const ImportStatements: core.StcSignature<base.ImportStatementsProps>;
|
|
21
|
+
export declare const SingleImportStatement: core.StcSignature<base.ImportStatementProps>;
|
|
22
|
+
export declare const ModuleDirectory: core.StcSignature<base.ModuleDirectoryProps>;
|
|
23
|
+
export declare const Name: core.StcSignature<{}>;
|
|
24
|
+
export declare const Reference: core.StcSignature<base.ReferenceProps>;
|
|
25
|
+
export declare const SourceDirectory: core.StcSignature<base.SourceDirectoryProps>;
|
|
26
|
+
export declare const SourceFile: core.StcSignature<base.SourceFileProps>;
|
|
27
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/stc/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,aAAa,CAAC;AAEpC,eAAO,MAAM,WAAW,0CAA6B,CAAC;AACtD,eAAO,MAAM,YAAY,2CAA8B,CAAC;AACxD,eAAO,MAAM,mBAAmB,uCAAqC,CAAC;AACtE,eAAO,MAAM,gBAAgB,2CAAkC,CAAC;AAChE,eAAO,MAAM,oBAAoB,mDAAsC,CAAC;AACxE,eAAO,MAAM,iBAAiB,gDAAmC,CAAC;AAClE,eAAO,MAAM,cAAc,6CAAgC,CAAC;AAC5D,eAAO,MAAM,iBAAiB,gDAAmC,CAAC;AAClE,eAAO,MAAM,kBAAkB,iDAAoC,CAAC;AACpE,eAAO,MAAM,OAAO,sCAAyB,CAAC;AAC9C,eAAO,MAAM,iBAAiB,gDAAmC,CAAC;AAClE,eAAO,MAAM,YAAY,2CAA8B,CAAC;AACxD,eAAO,MAAM,WAAW,0CAA6B,CAAC;AACtD,eAAO,MAAM,oBAAoB,mDAAsC,CAAC;AACxE,eAAO,MAAM,eAAe,8CAAiC,CAAC;AAC9D,eAAO,MAAM,wBAAwB,uDAA0C,CAAC;AAChF,eAAO,MAAM,mBAAmB,kDAAqC,CAAC;AACtE,eAAO,MAAM,gBAAgB,+CAAkC,CAAC;AAChE,eAAO,MAAM,qBAAqB,8CAAuC,CAAC;AAC1E,eAAO,MAAM,eAAe,8CAAiC,CAAC;AAC9D,eAAO,MAAM,IAAI,uBAAsB,CAAC;AACxC,eAAO,MAAM,SAAS,wCAA2B,CAAC;AAClD,eAAO,MAAM,eAAe,8CAAiC,CAAC;AAC9D,eAAO,MAAM,UAAU,yCAA4B,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as core from "@alloy-js/core";
|
|
2
|
+
import * as base from "../index.js";
|
|
3
|
+
export const LineComment = core.stc(base.LineComment);
|
|
4
|
+
export const BlockComment = core.stc(base.BlockComment);
|
|
5
|
+
export const FunctionDeclaration = core.stc(base.FunctionDeclaration);
|
|
6
|
+
export const FunctionReceiver = core.stc(base.FunctionReceiver);
|
|
7
|
+
export const InterfaceDeclaration = core.stc(base.InterfaceDeclaration);
|
|
8
|
+
export const InterfaceFunction = core.stc(base.InterfaceFunction);
|
|
9
|
+
export const InterfaceEmbed = core.stc(base.InterfaceEmbed);
|
|
10
|
+
export const FunctionParameter = core.stc(base.FunctionParameter);
|
|
11
|
+
export const FunctionParameters = core.stc(base.FunctionParameters);
|
|
12
|
+
export const Pointer = core.stc(base.Pointer);
|
|
13
|
+
export const StructDeclaration = core.stc(base.StructDeclaration);
|
|
14
|
+
export const StructMember = core.stc(base.StructMember);
|
|
15
|
+
export const StructEmbed = core.stc(base.StructEmbed);
|
|
16
|
+
export const TypeDeclarationGroup = core.stc(base.TypeDeclarationGroup);
|
|
17
|
+
export const TypeDeclaration = core.stc(base.TypeDeclaration);
|
|
18
|
+
export const VariableDeclarationGroup = core.stc(base.VariableDeclarationGroup);
|
|
19
|
+
export const VariableDeclaration = core.stc(base.VariableDeclaration);
|
|
20
|
+
export const ImportStatements = core.stc(base.ImportStatements);
|
|
21
|
+
export const SingleImportStatement = core.stc(base.SingleImportStatement);
|
|
22
|
+
export const ModuleDirectory = core.stc(base.ModuleDirectory);
|
|
23
|
+
export const Name = core.stc(base.Name);
|
|
24
|
+
export const Reference = core.stc(base.Reference);
|
|
25
|
+
export const SourceDirectory = core.stc(base.SourceDirectory);
|
|
26
|
+
export const SourceFile = core.stc(base.SourceFile);
|
|
27
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["core","base","LineComment","stc","BlockComment","FunctionDeclaration","FunctionReceiver","InterfaceDeclaration","InterfaceFunction","InterfaceEmbed","FunctionParameter","FunctionParameters","Pointer","StructDeclaration","StructMember","StructEmbed","TypeDeclarationGroup","TypeDeclaration","VariableDeclarationGroup","VariableDeclaration","ImportStatements","SingleImportStatement","ModuleDirectory","Name","Reference","SourceDirectory","SourceFile"],"sources":["../../../../src/components/stc/index.ts"],"sourcesContent":[null],"mappings":"AAAA,OAAO,KAAKA,IAAI,MAAM,gBAAgB;AACtC,OAAO,KAAKC,IAAI,MAAM,aAAa;AAEnC,OAAO,MAAMC,WAAW,GAAGF,IAAI,CAACG,GAAG,CAACF,IAAI,CAACC,WAAW,CAAC;AACrD,OAAO,MAAME,YAAY,GAAGJ,IAAI,CAACG,GAAG,CAACF,IAAI,CAACG,YAAY,CAAC;AACvD,OAAO,MAAMC,mBAAmB,GAAGL,IAAI,CAACG,GAAG,CAACF,IAAI,CAACI,mBAAmB,CAAC;AACrE,OAAO,MAAMC,gBAAgB,GAAGN,IAAI,CAACG,GAAG,CAACF,IAAI,CAACK,gBAAgB,CAAC;AAC/D,OAAO,MAAMC,oBAAoB,GAAGP,IAAI,CAACG,GAAG,CAACF,IAAI,CAACM,oBAAoB,CAAC;AACvE,OAAO,MAAMC,iBAAiB,GAAGR,IAAI,CAACG,GAAG,CAACF,IAAI,CAACO,iBAAiB,CAAC;AACjE,OAAO,MAAMC,cAAc,GAAGT,IAAI,CAACG,GAAG,CAACF,IAAI,CAACQ,cAAc,CAAC;AAC3D,OAAO,MAAMC,iBAAiB,GAAGV,IAAI,CAACG,GAAG,CAACF,IAAI,CAACS,iBAAiB,CAAC;AACjE,OAAO,MAAMC,kBAAkB,GAAGX,IAAI,CAACG,GAAG,CAACF,IAAI,CAACU,kBAAkB,CAAC;AACnE,OAAO,MAAMC,OAA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ACyB,UAAU,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Children, Namekey, Refkey } from "@alloy-js/core";
|
|
2
|
+
import { TypeDeclarationProps } from "../type/declaration.jsx";
|
|
3
|
+
/**
|
|
4
|
+
* Properties for creating a struct declaration.
|
|
5
|
+
* This can be used for both named and anonymous structs.
|
|
6
|
+
* For named structs, use `StructTypeDeclarationProps` instead.
|
|
7
|
+
*/
|
|
8
|
+
export interface StructDeclarationProps {
|
|
9
|
+
refkey?: Refkey;
|
|
10
|
+
children?: Children;
|
|
11
|
+
/**
|
|
12
|
+
* Whether to render the struct in a single line.
|
|
13
|
+
* This will only compile if `children` is a single line as well.
|
|
14
|
+
* This is not common in Go, so use with caution.
|
|
15
|
+
*/
|
|
16
|
+
singleLine?: boolean;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Properties for creating a named struct type declaration.
|
|
20
|
+
* This is a combination of `StructDeclarationProps` and `TypeDeclarationProps`.
|
|
21
|
+
*/
|
|
22
|
+
export interface StructTypeDeclarationProps extends StructDeclarationProps, TypeDeclarationProps {
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Wrapper for creating a named struct type declaration.
|
|
26
|
+
*/
|
|
27
|
+
export declare function StructTypeDeclaration(props: StructTypeDeclarationProps): Children;
|
|
28
|
+
/**
|
|
29
|
+
* Go struct declaration.
|
|
30
|
+
* @example
|
|
31
|
+
* ```tsx
|
|
32
|
+
* <StructDeclaration>
|
|
33
|
+
* <StructEmbed pointer>{MyOtherStruct}</StructEmbed>
|
|
34
|
+
* <StructMember exported name="MyProperty" type="int" />
|
|
35
|
+
* </StructDeclaration>
|
|
36
|
+
* ```
|
|
37
|
+
* This will produce:
|
|
38
|
+
* ```go
|
|
39
|
+
* struct {
|
|
40
|
+
* MyOtherStruct
|
|
41
|
+
* MyProperty int
|
|
42
|
+
* }
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export declare function StructDeclaration(props: StructDeclarationProps): Children;
|
|
46
|
+
export interface StructMemberProps {
|
|
47
|
+
name: string | Namekey;
|
|
48
|
+
type: Children;
|
|
49
|
+
refkey?: Refkey;
|
|
50
|
+
tag?: string | Record<string, string>;
|
|
51
|
+
/** Doc comment */
|
|
52
|
+
doc?: Children;
|
|
53
|
+
}
|
|
54
|
+
export declare function StructMember(props: StructMemberProps): Children;
|
|
55
|
+
export interface StructEmbedProps {
|
|
56
|
+
refkey?: Refkey;
|
|
57
|
+
children?: Children;
|
|
58
|
+
/** Doc comment */
|
|
59
|
+
doc?: Children;
|
|
60
|
+
}
|
|
61
|
+
export declare function StructEmbed(props: StructEmbedProps): Children;
|
|
62
|
+
//# sourceMappingURL=declaration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"declaration.d.ts","sourceRoot":"","sources":["../../../../src/components/struct/declaration.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAMR,OAAO,EACP,MAAM,EAOP,MAAM,gBAAgB,CAAC;AAYxB,OAAO,EAAmB,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAEhF;;;;GAIG;AACH,MAAM,WAAW,sBAAsB;IACrC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IAEpB;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED;;;GAGG;AACH,MAAM,WAAW,0BACf,SAAQ,sBAAsB,EAC5B,oBAAoB;CAAG;AAE3B;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,0BAA0B,YAMtE;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,YAsD9D;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IACvB,IAAI,EAAE,QAAQ,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,kBAAkB;IAClB,GAAG,CAAC,EAAE,QAAQ,CAAC;CAChB;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,YA+BpD;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,kBAAkB;IAClB,GAAG,CAAC,EAAE,QAAQ,CAAC;CAChB;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,YAuClD"}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { createComponent as _$createComponent, mergeProps as _$mergeProps, memo as _$memo, createIntrinsic as _$createIntrinsic } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { Block, computed, Declaration, DeclarationContext, effect, memo, Scope, Show, takeSymbols, untrack, useContext, watch } from "@alloy-js/core";
|
|
3
|
+
import { useGoScope, useNamedTypeScope } from "../../scopes/contexts.js";
|
|
4
|
+
import { createNamedTypeScope } from "../../scopes/factories.js";
|
|
5
|
+
import { GoNamedTypeScope } from "../../scopes/named-type.js";
|
|
6
|
+
import { createAnonymousTypeSymbol, createStructMemberSymbol } from "../../symbols/factories.js";
|
|
7
|
+
import { LineComment } from "../doc/comment.js";
|
|
8
|
+
import { Name } from "../Name.js";
|
|
9
|
+
import { TypeDeclaration } from "../type/declaration.js";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Properties for creating a struct declaration.
|
|
13
|
+
* This can be used for both named and anonymous structs.
|
|
14
|
+
* For named structs, use `StructTypeDeclarationProps` instead.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Properties for creating a named struct type declaration.
|
|
19
|
+
* This is a combination of `StructDeclarationProps` and `TypeDeclarationProps`.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Wrapper for creating a named struct type declaration.
|
|
24
|
+
*/
|
|
25
|
+
export function StructTypeDeclaration(props) {
|
|
26
|
+
return _$createComponent(TypeDeclaration, _$mergeProps(props, {
|
|
27
|
+
get children() {
|
|
28
|
+
return _$createComponent(StructDeclaration, props);
|
|
29
|
+
}
|
|
30
|
+
}));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Go struct declaration.
|
|
35
|
+
* @example
|
|
36
|
+
* ```tsx
|
|
37
|
+
* <StructDeclaration>
|
|
38
|
+
* <StructEmbed pointer>{MyOtherStruct}</StructEmbed>
|
|
39
|
+
* <StructMember exported name="MyProperty" type="int" />
|
|
40
|
+
* </StructDeclaration>
|
|
41
|
+
* ```
|
|
42
|
+
* This will produce:
|
|
43
|
+
* ```go
|
|
44
|
+
* struct {
|
|
45
|
+
* MyOtherStruct
|
|
46
|
+
* MyProperty int
|
|
47
|
+
* }
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export function StructDeclaration(props) {
|
|
51
|
+
const scope = useGoScope();
|
|
52
|
+
let structScope;
|
|
53
|
+
if (!(scope instanceof GoNamedTypeScope) || scope.ownerSymbol.typeKind !== "type") {
|
|
54
|
+
const declSymbol = useContext(DeclarationContext);
|
|
55
|
+
// this is an anonymous struct
|
|
56
|
+
if (!declSymbol) {
|
|
57
|
+
// this can only happen when instantiating a struct directly
|
|
58
|
+
const anonymousSymbol = createAnonymousTypeSymbol("struct");
|
|
59
|
+
const anonymousScope = createNamedTypeScope(anonymousSymbol);
|
|
60
|
+
structScope = anonymousScope;
|
|
61
|
+
} else {
|
|
62
|
+
// this is most likely a struct field
|
|
63
|
+
const anonymousScope = createNamedTypeScope(declSymbol);
|
|
64
|
+
structScope = anonymousScope;
|
|
65
|
+
}
|
|
66
|
+
} else {
|
|
67
|
+
scope.ownerSymbol.typeKind = "struct";
|
|
68
|
+
}
|
|
69
|
+
const content = memo(() => {
|
|
70
|
+
if (props.children) {
|
|
71
|
+
if (props.singleLine) {
|
|
72
|
+
return ["{", " ", _$memo(() => props.children), " ", "}"];
|
|
73
|
+
} else {
|
|
74
|
+
return [" ", _$createComponent(Block, {
|
|
75
|
+
get children() {
|
|
76
|
+
return props.children;
|
|
77
|
+
}
|
|
78
|
+
})];
|
|
79
|
+
}
|
|
80
|
+
} else {
|
|
81
|
+
return "{}";
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
return ["struct", structScope ? _$createComponent(Scope, {
|
|
85
|
+
value: structScope,
|
|
86
|
+
children: content
|
|
87
|
+
}) : content];
|
|
88
|
+
}
|
|
89
|
+
export function StructMember(props) {
|
|
90
|
+
const symbol = createStructMemberSymbol(props.name, {
|
|
91
|
+
refkeys: props.refkey
|
|
92
|
+
});
|
|
93
|
+
const tagString = computed(() => {
|
|
94
|
+
if (typeof props.tag === "string") {
|
|
95
|
+
return props.tag;
|
|
96
|
+
} else if (typeof props.tag === "object") {
|
|
97
|
+
return Object.entries(props.tag).sort((a, b) => a[0].localeCompare(b[0])).map(([key, value]) => `${key}:"${value}"`).join(" ");
|
|
98
|
+
}
|
|
99
|
+
return "";
|
|
100
|
+
});
|
|
101
|
+
return _$createComponent(Declaration, {
|
|
102
|
+
symbol: symbol,
|
|
103
|
+
get children() {
|
|
104
|
+
return [_$createComponent(Show, {
|
|
105
|
+
get when() {
|
|
106
|
+
return Boolean(props.doc);
|
|
107
|
+
},
|
|
108
|
+
get children() {
|
|
109
|
+
return [_$createComponent(LineComment, {
|
|
110
|
+
get children() {
|
|
111
|
+
return props.doc;
|
|
112
|
+
}
|
|
113
|
+
}), _$createIntrinsic("hbr", {})];
|
|
114
|
+
}
|
|
115
|
+
}), _$createComponent(Name, {}), " ", _$memo(() => props.type), _$memo(() => _$memo(() => tagString.value === "")() ? "" : tagString.value.includes('"') ? ` \`${tagString.value}\`` : ` "${tagString.value}"`)];
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
export function StructEmbed(props) {
|
|
120
|
+
let typeName = "<Unresolved symbol>";
|
|
121
|
+
if (props.children) {
|
|
122
|
+
if (typeof props.children === "string") {
|
|
123
|
+
typeName = props.children;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
const memberSymbol = createStructMemberSymbol(typeName, {
|
|
127
|
+
refkeys: props.refkey
|
|
128
|
+
});
|
|
129
|
+
const taken = takeSymbols();
|
|
130
|
+
effect(() => {
|
|
131
|
+
if (taken.size !== 1) return;
|
|
132
|
+
untrack(() => {
|
|
133
|
+
const symbol = Array.from(taken)[0];
|
|
134
|
+
memberSymbol.name = symbol.name;
|
|
135
|
+
watch(() => symbol.name, () => {
|
|
136
|
+
memberSymbol.name = symbol.name;
|
|
137
|
+
});
|
|
138
|
+
const namedTypeScope = useNamedTypeScope();
|
|
139
|
+
// TODO: somehow mark it as "promoted" such that it cannot be constructed directly
|
|
140
|
+
symbol.copyMembersTo(namedTypeScope.ownerSymbol);
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
return _$createComponent(Declaration, {
|
|
144
|
+
symbol: memberSymbol,
|
|
145
|
+
get children() {
|
|
146
|
+
return [_$createComponent(Show, {
|
|
147
|
+
get when() {
|
|
148
|
+
return Boolean(props.doc);
|
|
149
|
+
},
|
|
150
|
+
get children() {
|
|
151
|
+
return [_$createComponent(LineComment, {
|
|
152
|
+
get children() {
|
|
153
|
+
return props.doc;
|
|
154
|
+
}
|
|
155
|
+
}), _$createIntrinsic("hbr", {})];
|
|
156
|
+
}
|
|
157
|
+
}), _$memo(() => props.children)];
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
//# sourceMappingURL=declaration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Block","computed","Declaration","DeclarationContext","effect","memo","Scope","Show","takeSymbols","untrack","useContext","watch","useGoScope","useNamedTypeScope","createNamedTypeScope","GoNamedTypeScope","createAnonymousTypeSymbol","createStructMemberSymbol","LineComment","Name","TypeDeclaration","StructTypeDeclaration","props","_$createComponent","_$mergeProps","children","StructDeclaration","scope","structScope","ownerSymbol","typeKind","declSymbol","anonymousSymbol","anonymousScope","content","singleLine","_$memo","value","StructMember","symbol","name","refkeys","refkey","tagString","tag","Object","entries","sort","a","b","localeCompare","map","key","join","when","Boolean","doc","_$createIntrinsic","type","includes","StructEmbed","typeName","memberSymbol","taken","size","Array","from","namedTypeScope","copyMembersTo"],"sources":["../../../../src/components/struct/declaration.tsx"],"sourcesContent":[null],"mappings":";AAAA,SACEA,KAAK,EAELC,QAAQ,EACRC,WAAW,EACXC,kBAAkB,EAClBC,MAAM,EACNC,IAAI,EAGJC,KAAK,EACLC,IAAI,EACJC,WAAW,EACXC,OAAO,EACPC,UAAU,EACVC,KAAK,QACA,gBAAgB;AACvB,SAASC,UAAU,EAAEC,iBAAiB,QAAQ,0BAA0B;AACxE,SAASC,oBAAoB,QAAQ,2BAA2B;AAChE,SAASC,gBAAgB,QAAQ,4BAA4B;AAC7D,SACEC,yBAAyB,EACzBC,wBAAwB,QACnB,4BAA4B;AAGnC,SAASC,WAAW,QAAQ,mBAAmB;AAC/C,SAASC,IAAI,QAAQ,YAAY;AACjC,SAASC,eAAe;;AAExB;AACA;AACA;AACA;AACA;;AAaA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA,OAAO,SAASC,qBAAqBA,CAACC,KAAiC,EAAE;EACvE,OAAAC,iBAAA,CACGH,eAAe,EAAAI,YAAA,CAAKF,KAAK;IAAA,IAAAG,SAAA;MAAA,OAAAF,iBAAA,CACvBG,iBAAiB,EAAKJ,KAAK;IAAA;EAAA;AAGlC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASI,iBAAiBA,CAACJ,KAA6B,EAAE;EAC/D,MAAMK,KAAK,GAAGf,UAAU,CAAC,CAAC;EAC1B,IAAIgB,WAAyC;EAC7C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B,MAAA,OAGjCd,KAAK,CAACG,QAAQ;IAAA;EAAA;AAGrB","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"struct.test.d.ts","sourceRoot":"","sources":["../../../../src/components/struct/struct.test.tsx"],"names":[],"mappings":""}
|