@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.
Files changed (264) hide show
  1. package/CHANGELOG.md +1 -0
  2. package/LICENSE +7 -0
  3. package/api-extractor.json +4 -0
  4. package/dist/src/builtins/fmt/fmt.d.ts +147 -0
  5. package/dist/src/builtins/fmt/fmt.d.ts.map +1 -0
  6. package/dist/src/builtins/fmt/fmt.js +148 -0
  7. package/dist/src/builtins/fmt/fmt.js.map +1 -0
  8. package/dist/src/builtins/index.d.ts +2004 -0
  9. package/dist/src/builtins/index.d.ts.map +1 -0
  10. package/dist/src/builtins/index.js +9 -0
  11. package/dist/src/builtins/index.js.map +1 -0
  12. package/dist/src/builtins/io/io.d.ts +648 -0
  13. package/dist/src/builtins/io/io.d.ts.map +1 -0
  14. package/dist/src/builtins/io/io.js +650 -0
  15. package/dist/src/builtins/io/io.js.map +1 -0
  16. package/dist/src/builtins/net/net.d.ts +1210 -0
  17. package/dist/src/builtins/net/net.d.ts.map +1 -0
  18. package/dist/src/builtins/net/net.js +1212 -0
  19. package/dist/src/builtins/net/net.js.map +1 -0
  20. package/dist/src/components/ImportStatement.d.ts +15 -0
  21. package/dist/src/components/ImportStatement.d.ts.map +1 -0
  22. package/dist/src/components/ImportStatement.js +90 -0
  23. package/dist/src/components/ImportStatement.js.map +1 -0
  24. package/dist/src/components/ModuleDirectory.d.ts +8 -0
  25. package/dist/src/components/ModuleDirectory.d.ts.map +1 -0
  26. package/dist/src/components/ModuleDirectory.js +20 -0
  27. package/dist/src/components/ModuleDirectory.js.map +1 -0
  28. package/dist/src/components/Name.d.ts +2 -0
  29. package/dist/src/components/Name.d.ts.map +1 -0
  30. package/dist/src/components/Name.js +12 -0
  31. package/dist/src/components/Name.js.map +1 -0
  32. package/dist/src/components/Reference.d.ts +6 -0
  33. package/dist/src/components/Reference.d.ts.map +1 -0
  34. package/dist/src/components/Reference.js +15 -0
  35. package/dist/src/components/Reference.js.map +1 -0
  36. package/dist/src/components/SourceDirectory.d.ts +6 -0
  37. package/dist/src/components/SourceDirectory.d.ts.map +1 -0
  38. package/dist/src/components/SourceDirectory.js +30 -0
  39. package/dist/src/components/SourceDirectory.js.map +1 -0
  40. package/dist/src/components/SourceFile.d.ts +16 -0
  41. package/dist/src/components/SourceFile.d.ts.map +1 -0
  42. package/dist/src/components/SourceFile.js +75 -0
  43. package/dist/src/components/SourceFile.js.map +1 -0
  44. package/dist/src/components/doc/comment.d.ts +21 -0
  45. package/dist/src/components/doc/comment.d.ts.map +1 -0
  46. package/dist/src/components/doc/comment.js +30 -0
  47. package/dist/src/components/doc/comment.js.map +1 -0
  48. package/dist/src/components/doc/comment.test.d.ts +2 -0
  49. package/dist/src/components/doc/comment.test.d.ts.map +1 -0
  50. package/dist/src/components/doc/comment.test.js +215 -0
  51. package/dist/src/components/doc/comment.test.js.map +1 -0
  52. package/dist/src/components/function/function.d.ts +31 -0
  53. package/dist/src/components/function/function.d.ts.map +1 -0
  54. package/dist/src/components/function/function.js +134 -0
  55. package/dist/src/components/function/function.js.map +1 -0
  56. package/dist/src/components/function/function.test.d.ts +2 -0
  57. package/dist/src/components/function/function.test.d.ts.map +1 -0
  58. package/dist/src/components/function/function.test.js +410 -0
  59. package/dist/src/components/function/function.test.js.map +1 -0
  60. package/dist/src/components/index.d.ts +16 -0
  61. package/dist/src/components/index.d.ts.map +1 -0
  62. package/dist/src/components/index.js +16 -0
  63. package/dist/src/components/index.js.map +1 -0
  64. package/dist/src/components/interface/declaration.d.ts +68 -0
  65. package/dist/src/components/interface/declaration.d.ts.map +1 -0
  66. package/dist/src/components/interface/declaration.js +181 -0
  67. package/dist/src/components/interface/declaration.js.map +1 -0
  68. package/dist/src/components/interface/interface.test.d.ts +2 -0
  69. package/dist/src/components/interface/interface.test.d.ts.map +1 -0
  70. package/dist/src/components/interface/interface.test.js +517 -0
  71. package/dist/src/components/interface/interface.test.js.map +1 -0
  72. package/dist/src/components/package.test.d.ts +2 -0
  73. package/dist/src/components/package.test.d.ts.map +1 -0
  74. package/dist/src/components/package.test.js +89 -0
  75. package/dist/src/components/package.test.js.map +1 -0
  76. package/dist/src/components/parameters/parameters.d.ts +15 -0
  77. package/dist/src/components/parameters/parameters.d.ts.map +1 -0
  78. package/dist/src/components/parameters/parameters.js +58 -0
  79. package/dist/src/components/parameters/parameters.js.map +1 -0
  80. package/dist/src/components/parameters/typeparameters.d.ts +25 -0
  81. package/dist/src/components/parameters/typeparameters.d.ts.map +1 -0
  82. package/dist/src/components/parameters/typeparameters.js +53 -0
  83. package/dist/src/components/parameters/typeparameters.js.map +1 -0
  84. package/dist/src/components/pointer/pointer.d.ts +9 -0
  85. package/dist/src/components/pointer/pointer.d.ts.map +1 -0
  86. package/dist/src/components/pointer/pointer.js +8 -0
  87. package/dist/src/components/pointer/pointer.js.map +1 -0
  88. package/dist/src/components/stc/index.d.ts +27 -0
  89. package/dist/src/components/stc/index.d.ts.map +1 -0
  90. package/dist/src/components/stc/index.js +27 -0
  91. package/dist/src/components/stc/index.js.map +1 -0
  92. package/dist/src/components/struct/declaration.d.ts +62 -0
  93. package/dist/src/components/struct/declaration.d.ts.map +1 -0
  94. package/dist/src/components/struct/declaration.js +161 -0
  95. package/dist/src/components/struct/declaration.js.map +1 -0
  96. package/dist/src/components/struct/struct.test.d.ts +2 -0
  97. package/dist/src/components/struct/struct.test.d.ts.map +1 -0
  98. package/dist/src/components/struct/struct.test.js +741 -0
  99. package/dist/src/components/struct/struct.test.js.map +1 -0
  100. package/dist/src/components/type/declaration.d.ts +29 -0
  101. package/dist/src/components/type/declaration.d.ts.map +1 -0
  102. package/dist/src/components/type/declaration.js +63 -0
  103. package/dist/src/components/type/declaration.js.map +1 -0
  104. package/dist/src/components/var/declaration.d.ts +27 -0
  105. package/dist/src/components/var/declaration.d.ts.map +1 -0
  106. package/dist/src/components/var/declaration.js +84 -0
  107. package/dist/src/components/var/declaration.js.map +1 -0
  108. package/dist/src/components/var/var-declaration.test.d.ts +2 -0
  109. package/dist/src/components/var/var-declaration.test.d.ts.map +1 -0
  110. package/dist/src/components/var/var-declaration.test.js +340 -0
  111. package/dist/src/components/var/var-declaration.test.js.map +1 -0
  112. package/dist/src/context/package.d.ts +9 -0
  113. package/dist/src/context/package.d.ts.map +1 -0
  114. package/dist/src/context/package.js +6 -0
  115. package/dist/src/context/package.js.map +1 -0
  116. package/dist/src/create-module.d.ts +47 -0
  117. package/dist/src/create-module.d.ts.map +1 -0
  118. package/dist/src/create-module.js +158 -0
  119. package/dist/src/create-module.js.map +1 -0
  120. package/dist/src/create-module.test.d.ts +2 -0
  121. package/dist/src/create-module.test.d.ts.map +1 -0
  122. package/dist/src/create-module.test.js +147 -0
  123. package/dist/src/create-module.test.js.map +1 -0
  124. package/dist/src/index.d.ts +6 -0
  125. package/dist/src/index.d.ts.map +1 -0
  126. package/dist/src/index.js +6 -0
  127. package/dist/src/index.js.map +1 -0
  128. package/dist/src/name-policy.d.ts +5 -0
  129. package/dist/src/name-policy.d.ts.map +1 -0
  130. package/dist/src/name-policy.js +27 -0
  131. package/dist/src/name-policy.js.map +1 -0
  132. package/dist/src/scopes/contexts.d.ts +9 -0
  133. package/dist/src/scopes/contexts.d.ts.map +1 -0
  134. package/dist/src/scopes/contexts.js +34 -0
  135. package/dist/src/scopes/contexts.js.map +1 -0
  136. package/dist/src/scopes/factories.d.ts +7 -0
  137. package/dist/src/scopes/factories.d.ts.map +1 -0
  138. package/dist/src/scopes/factories.js +16 -0
  139. package/dist/src/scopes/factories.js.map +1 -0
  140. package/dist/src/scopes/function.d.ts +9 -0
  141. package/dist/src/scopes/function.d.ts.map +1 -0
  142. package/dist/src/scopes/function.js +14 -0
  143. package/dist/src/scopes/function.js.map +1 -0
  144. package/dist/src/scopes/go.d.ts +8 -0
  145. package/dist/src/scopes/go.d.ts.map +1 -0
  146. package/dist/src/scopes/go.js +12 -0
  147. package/dist/src/scopes/go.js.map +1 -0
  148. package/dist/src/scopes/index.d.ts +10 -0
  149. package/dist/src/scopes/index.d.ts.map +1 -0
  150. package/dist/src/scopes/index.js +10 -0
  151. package/dist/src/scopes/index.js.map +1 -0
  152. package/dist/src/scopes/lexical.d.ts +8 -0
  153. package/dist/src/scopes/lexical.d.ts.map +1 -0
  154. package/dist/src/scopes/lexical.js +11 -0
  155. package/dist/src/scopes/lexical.js.map +1 -0
  156. package/dist/src/scopes/module.d.ts +9 -0
  157. package/dist/src/scopes/module.d.ts.map +1 -0
  158. package/dist/src/scopes/module.js +31 -0
  159. package/dist/src/scopes/module.js.map +1 -0
  160. package/dist/src/scopes/named-type.d.ts +23 -0
  161. package/dist/src/scopes/named-type.d.ts.map +1 -0
  162. package/dist/src/scopes/named-type.js +33 -0
  163. package/dist/src/scopes/named-type.js.map +1 -0
  164. package/dist/src/scopes/package.d.ts +11 -0
  165. package/dist/src/scopes/package.d.ts.map +1 -0
  166. package/dist/src/scopes/package.js +39 -0
  167. package/dist/src/scopes/package.js.map +1 -0
  168. package/dist/src/scopes/source-file.d.ts +17 -0
  169. package/dist/src/scopes/source-file.d.ts.map +1 -0
  170. package/dist/src/scopes/source-file.js +42 -0
  171. package/dist/src/scopes/source-file.js.map +1 -0
  172. package/dist/src/symbols/factories.d.ts +25 -0
  173. package/dist/src/symbols/factories.d.ts.map +1 -0
  174. package/dist/src/symbols/factories.js +114 -0
  175. package/dist/src/symbols/factories.js.map +1 -0
  176. package/dist/src/symbols/function.d.ts +10 -0
  177. package/dist/src/symbols/function.d.ts.map +1 -0
  178. package/dist/src/symbols/function.js +12 -0
  179. package/dist/src/symbols/function.js.map +1 -0
  180. package/dist/src/symbols/go.d.ts +22 -0
  181. package/dist/src/symbols/go.d.ts.map +1 -0
  182. package/dist/src/symbols/go.js +56 -0
  183. package/dist/src/symbols/go.js.map +1 -0
  184. package/dist/src/symbols/index.d.ts +7 -0
  185. package/dist/src/symbols/index.d.ts.map +1 -0
  186. package/dist/src/symbols/index.js +7 -0
  187. package/dist/src/symbols/index.js.map +1 -0
  188. package/dist/src/symbols/named-type.d.ts +24 -0
  189. package/dist/src/symbols/named-type.d.ts.map +1 -0
  190. package/dist/src/symbols/named-type.js +53 -0
  191. package/dist/src/symbols/named-type.js.map +1 -0
  192. package/dist/src/symbols/package.d.ts +18 -0
  193. package/dist/src/symbols/package.d.ts.map +1 -0
  194. package/dist/src/symbols/package.js +38 -0
  195. package/dist/src/symbols/package.js.map +1 -0
  196. package/dist/src/symbols/reference.d.ts +3 -0
  197. package/dist/src/symbols/reference.d.ts.map +1 -0
  198. package/dist/src/symbols/reference.js +76 -0
  199. package/dist/src/symbols/reference.js.map +1 -0
  200. package/dist/test/utils.d.ts +8 -0
  201. package/dist/test/utils.d.ts.map +1 -0
  202. package/dist/test/utils.js +68 -0
  203. package/dist/test/utils.js.map +1 -0
  204. package/dist/test/vitest.setup.d.ts +2 -0
  205. package/dist/test/vitest.setup.d.ts.map +1 -0
  206. package/dist/test/vitest.setup.js +2 -0
  207. package/dist/test/vitest.setup.js.map +1 -0
  208. package/dist/tsconfig.tsbuildinfo +1 -0
  209. package/package.json +45 -0
  210. package/src/builtins/fmt/fmt.ts +78 -0
  211. package/src/builtins/index.ts +9 -0
  212. package/src/builtins/io/io.ts +355 -0
  213. package/src/builtins/net/net.ts +502 -0
  214. package/src/components/ImportStatement.tsx +115 -0
  215. package/src/components/ModuleDirectory.tsx +18 -0
  216. package/src/components/Name.tsx +11 -0
  217. package/src/components/Reference.tsx +18 -0
  218. package/src/components/SourceDirectory.tsx +32 -0
  219. package/src/components/SourceFile.tsx +74 -0
  220. package/src/components/doc/comment.test.tsx +278 -0
  221. package/src/components/doc/comment.tsx +40 -0
  222. package/src/components/function/function.test.tsx +387 -0
  223. package/src/components/function/function.tsx +194 -0
  224. package/src/components/index.ts +15 -0
  225. package/src/components/interface/declaration.tsx +250 -0
  226. package/src/components/interface/interface.test.tsx +390 -0
  227. package/src/components/package.test.tsx +63 -0
  228. package/src/components/parameters/parameters.tsx +74 -0
  229. package/src/components/parameters/typeparameters.tsx +78 -0
  230. package/src/components/pointer/pointer.tsx +12 -0
  231. package/src/components/stc/index.ts +27 -0
  232. package/src/components/struct/declaration.tsx +228 -0
  233. package/src/components/struct/struct.test.tsx +558 -0
  234. package/src/components/type/declaration.tsx +93 -0
  235. package/src/components/var/declaration.tsx +138 -0
  236. package/src/components/var/var-declaration.test.tsx +236 -0
  237. package/src/context/package.ts +13 -0
  238. package/src/create-module.test.tsx +128 -0
  239. package/src/create-module.ts +347 -0
  240. package/src/index.ts +5 -0
  241. package/src/name-policy.ts +65 -0
  242. package/src/scopes/contexts.ts +45 -0
  243. package/src/scopes/factories.ts +29 -0
  244. package/src/scopes/function.ts +22 -0
  245. package/src/scopes/go.ts +18 -0
  246. package/src/scopes/index.ts +9 -0
  247. package/src/scopes/lexical.ts +14 -0
  248. package/src/scopes/module.ts +35 -0
  249. package/src/scopes/named-type.ts +49 -0
  250. package/src/scopes/package.ts +55 -0
  251. package/src/scopes/source-file.ts +66 -0
  252. package/src/symbols/factories.ts +234 -0
  253. package/src/symbols/function.ts +17 -0
  254. package/src/symbols/go.ts +82 -0
  255. package/src/symbols/index.ts +6 -0
  256. package/src/symbols/named-type.ts +90 -0
  257. package/src/symbols/package.ts +54 -0
  258. package/src/symbols/reference.ts +87 -0
  259. package/temp/api.json +8753 -0
  260. package/test/utils.tsx +77 -0
  261. package/test/vitest.setup.ts +1 -0
  262. package/tsconfig.json +15 -0
  263. package/tsdoc-metadata.json +11 -0
  264. package/vitest.config.ts +13 -0
@@ -0,0 +1,410 @@
1
+ import { createComponent as _$createComponent, createIntrinsic as _$createIntrinsic, memo as _$memo } from "@alloy-js/core/jsx-runtime";
2
+ import { code, Output, refkey, render } from "@alloy-js/core";
3
+ import { describe, expect, it } from "vitest";
4
+ import { TestPackage } from "../../../test/utils.js";
5
+ import { ModuleDirectory } from "../ModuleDirectory.js";
6
+ import { SourceDirectory } from "../SourceDirectory.js";
7
+ import { SourceFile } from "../SourceFile.js";
8
+ import { StructDeclaration } from "../struct/declaration.js";
9
+ import { TypeDeclaration } from "../type/declaration.js";
10
+ import { FunctionDeclaration, FunctionReceiver } from "./function.js";
11
+ const Wrapper = props => _$createComponent(TestPackage, {
12
+ get children() {
13
+ return [_$createComponent(TypeDeclaration, {
14
+ get refkey() {
15
+ return props.refkey;
16
+ },
17
+ name: "TestStruct",
18
+ get children() {
19
+ return [_$createComponent(StructDeclaration, {}), _$createIntrinsic("hbr", {})];
20
+ }
21
+ }), _$memo(() => props.children)];
22
+ }
23
+ });
24
+ it("applies PascalCase naming policy when exported", () => {
25
+ expect(_$createComponent(TestPackage, {
26
+ get children() {
27
+ return _$createComponent(FunctionDeclaration, {
28
+ name: "MethodOne"
29
+ });
30
+ }
31
+ })).toRenderTo(`
32
+ package alloy
33
+
34
+ func MethodOne() {}
35
+ `);
36
+ });
37
+ it("applies camelCase naming policy when not exported", () => {
38
+ expect(_$createComponent(TestPackage, {
39
+ get children() {
40
+ return _$createComponent(FunctionDeclaration, {
41
+ name: "methodOne"
42
+ });
43
+ }
44
+ })).toRenderTo(`
45
+ package alloy
46
+
47
+ func methodOne() {}
48
+ `);
49
+ });
50
+ it("defines single-line params and return type", () => {
51
+ const params = [{
52
+ name: "intParam",
53
+ type: "int"
54
+ }, {
55
+ name: "stringParam",
56
+ type: "string"
57
+ }];
58
+ const res = _$createComponent(TestPackage, {
59
+ get children() {
60
+ return _$createComponent(FunctionDeclaration, {
61
+ name: "MethodOne",
62
+ parameters: params,
63
+ returns: "string"
64
+ });
65
+ }
66
+ });
67
+ expect(res).toRenderTo(`
68
+ package alloy
69
+
70
+ func MethodOne(intParam int, stringParam string) string {}
71
+ `);
72
+ });
73
+ it("defines multi-line params and return type", () => {
74
+ const params = [{
75
+ name: "intParam",
76
+ type: "int"
77
+ }, {
78
+ name: "stringParam",
79
+ type: "string"
80
+ }, {
81
+ name: "stringParam2",
82
+ type: "string"
83
+ }, {
84
+ name: "stringParam3",
85
+ type: "string"
86
+ }];
87
+ const res = _$createComponent(TestPackage, {
88
+ get children() {
89
+ return _$createComponent(FunctionDeclaration, {
90
+ name: "MethodOne",
91
+ parameters: params,
92
+ returns: "string"
93
+ });
94
+ }
95
+ });
96
+ expect(res).toRenderTo(`
97
+ package alloy
98
+
99
+ func MethodOne(
100
+ intParam int,
101
+ stringParam string,
102
+ stringParam2 string,
103
+ stringParam3 string,
104
+ ) string {}
105
+ `);
106
+ });
107
+ it("defines single-line return type", () => {
108
+ const res = _$createComponent(TestPackage, {
109
+ get children() {
110
+ return _$createComponent(FunctionDeclaration, {
111
+ name: "MethodOne",
112
+ returns: ["string", "error"]
113
+ });
114
+ }
115
+ });
116
+ expect(res).toRenderTo(`
117
+ package alloy
118
+
119
+ func MethodOne() (string, error) {}
120
+ `);
121
+ });
122
+ it("defines multi-line return type", () => {
123
+ const res = _$createComponent(TestPackage, {
124
+ get children() {
125
+ return _$createComponent(FunctionDeclaration, {
126
+ name: "MethodOne",
127
+ returns: ["string", "string", "string", "string", "string", "string", "string", "string", "string", "string", "error"]
128
+ });
129
+ }
130
+ });
131
+ expect(res).toRenderTo(`
132
+ package alloy
133
+
134
+ func MethodOne() (
135
+ string,
136
+ string,
137
+ string,
138
+ string,
139
+ string,
140
+ string,
141
+ string,
142
+ string,
143
+ string,
144
+ string,
145
+ error,
146
+ ) {}
147
+ `);
148
+ });
149
+ it("specify doc comment", () => {
150
+ expect(_$createComponent(TestPackage, {
151
+ get children() {
152
+ return _$createComponent(FunctionDeclaration, {
153
+ name: "MethodOne",
154
+ get doc() {
155
+ return ["This is a test", _$createIntrinsic("hbr", {}), "This is another test"];
156
+ }
157
+ });
158
+ }
159
+ })).toRenderTo(`
160
+ package alloy
161
+
162
+ // This is a test
163
+ // This is another test
164
+ func MethodOne() {}
165
+ `);
166
+ });
167
+ it("use single-line form", () => {
168
+ expect(_$createComponent(TestPackage, {
169
+ get children() {
170
+ return _$createComponent(FunctionDeclaration, {
171
+ name: "MethodOne",
172
+ singleLine: true,
173
+ children: "return nil"
174
+ });
175
+ }
176
+ })).toRenderTo(`
177
+ package alloy
178
+
179
+ func MethodOne() { return nil }
180
+ `);
181
+ });
182
+ it("use children", () => {
183
+ expect(_$createComponent(TestPackage, {
184
+ get children() {
185
+ return _$createComponent(FunctionDeclaration, {
186
+ name: "MethodOne",
187
+ children: "return nil"
188
+ });
189
+ }
190
+ })).toRenderTo(`
191
+ package alloy
192
+
193
+ func MethodOne() {
194
+ return nil
195
+ }
196
+ `);
197
+ });
198
+ it("use multiple children", () => {
199
+ expect(_$createComponent(TestPackage, {
200
+ get children() {
201
+ return _$createComponent(FunctionDeclaration, {
202
+ name: "MethodOne",
203
+ children: code`
204
+ lineOne()
205
+ lineTwo()
206
+ return nil
207
+ `
208
+ });
209
+ }
210
+ })).toRenderTo(`
211
+ package alloy
212
+
213
+ func MethodOne() {
214
+ lineOne()
215
+ lineTwo()
216
+ return nil
217
+ }
218
+ `);
219
+ });
220
+ it("use method", () => {
221
+ const ReceiverRefkey = refkey("ReceiverRefkey");
222
+ expect(_$createComponent(Wrapper, {
223
+ refkey: ReceiverRefkey,
224
+ get children() {
225
+ return _$createComponent(FunctionDeclaration, {
226
+ name: "MethodOne",
227
+ get receiver() {
228
+ return _$createComponent(FunctionReceiver, {
229
+ name: "s",
230
+ type: ReceiverRefkey
231
+ });
232
+ }
233
+ });
234
+ }
235
+ })).toRenderTo(`
236
+ package alloy
237
+
238
+ type TestStruct struct{}
239
+ func (s TestStruct) MethodOne() {}
240
+ `);
241
+ });
242
+ it("use method variadic params", () => {
243
+ const ReceiverRefkey = refkey("ReceiverRefkey");
244
+ expect(_$createComponent(Wrapper, {
245
+ refkey: ReceiverRefkey,
246
+ get children() {
247
+ return _$createComponent(FunctionDeclaration, {
248
+ name: "MethodOne",
249
+ get receiver() {
250
+ return _$createComponent(FunctionReceiver, {
251
+ name: "s",
252
+ type: ReceiverRefkey
253
+ });
254
+ },
255
+ parameters: [{
256
+ name: "i",
257
+ type: "int"
258
+ }, {
259
+ name: "args",
260
+ type: "string",
261
+ variadic: true
262
+ }]
263
+ });
264
+ }
265
+ })).toRenderTo(`
266
+ package alloy
267
+
268
+ type TestStruct struct{}
269
+ func (s TestStruct) MethodOne(i int, args ...string) {}
270
+ `);
271
+ });
272
+ it("use method cross-package fail", () => {
273
+ const ReceiverRefkey = refkey("ReceiverRefkey");
274
+ expect(() => render(_$createComponent(Output, {
275
+ get children() {
276
+ return _$createComponent(ModuleDirectory, {
277
+ name: "github.com/alloy-framework/alloy",
278
+ get children() {
279
+ return [_$createComponent(SourceDirectory, {
280
+ path: "hello",
281
+ get children() {
282
+ return _$createComponent(SourceFile, {
283
+ path: "types.go",
284
+ get children() {
285
+ return _$createComponent(TypeDeclaration, {
286
+ refkey: ReceiverRefkey,
287
+ name: "TestStruct",
288
+ get children() {
289
+ return _$createComponent(StructDeclaration, {});
290
+ }
291
+ });
292
+ }
293
+ });
294
+ }
295
+ }), _$createComponent(SourceDirectory, {
296
+ path: "world",
297
+ get children() {
298
+ return _$createComponent(SourceFile, {
299
+ path: "test.go",
300
+ get children() {
301
+ return _$createComponent(FunctionDeclaration, {
302
+ name: "MethodOne",
303
+ get receiver() {
304
+ return _$createComponent(FunctionReceiver, {
305
+ name: "s",
306
+ type: ReceiverRefkey
307
+ });
308
+ }
309
+ });
310
+ }
311
+ });
312
+ }
313
+ })];
314
+ }
315
+ });
316
+ }
317
+ }))).toThrowError("Receiver symbol s must be in the same package as the type TestStruct.");
318
+ });
319
+ describe("type parameters", () => {
320
+ it("function type param", () => {
321
+ const T = refkey("T");
322
+ expect(_$createComponent(TestPackage, {
323
+ get children() {
324
+ return _$createComponent(FunctionDeclaration, {
325
+ name: "MethodOne",
326
+ parameters: [{
327
+ name: "arg",
328
+ type: T
329
+ }],
330
+ typeParameters: [{
331
+ name: "T",
332
+ constraint: "any",
333
+ refkey: T
334
+ }]
335
+ });
336
+ }
337
+ })).toRenderTo(`
338
+ package alloy
339
+
340
+ func MethodOne[T any](arg T) {}
341
+ `);
342
+ });
343
+ it("method auto type param", () => {
344
+ const ReceiverRefkey = refkey("ReceiverRefkey");
345
+ expect(_$createComponent(TestPackage, {
346
+ get children() {
347
+ return [_$createComponent(TypeDeclaration, {
348
+ refkey: ReceiverRefkey,
349
+ name: "TestStruct",
350
+ typeParameters: [{
351
+ name: "T",
352
+ constraint: "any"
353
+ }],
354
+ get children() {
355
+ return [_$createComponent(StructDeclaration, {}), _$createIntrinsic("hbr", {})];
356
+ }
357
+ }), _$createComponent(FunctionDeclaration, {
358
+ name: "MethodOne",
359
+ get receiver() {
360
+ return _$createComponent(FunctionReceiver, {
361
+ name: "s",
362
+ type: ReceiverRefkey
363
+ });
364
+ }
365
+ })];
366
+ }
367
+ })).toRenderTo(`
368
+ package alloy
369
+
370
+ type TestStruct[T any] struct{}
371
+ func (s TestStruct[T any]) MethodOne() {}
372
+ `);
373
+ });
374
+ it("method type param", () => {
375
+ const ReceiverRefkey = refkey("ReceiverRefkey");
376
+ expect(_$createComponent(TestPackage, {
377
+ get children() {
378
+ return [_$createComponent(TypeDeclaration, {
379
+ refkey: ReceiverRefkey,
380
+ name: "TestStruct",
381
+ typeParameters: [{
382
+ name: "T",
383
+ constraint: "any"
384
+ }],
385
+ get children() {
386
+ return [_$createComponent(StructDeclaration, {}), _$createIntrinsic("hbr", {})];
387
+ }
388
+ }), _$createComponent(FunctionDeclaration, {
389
+ name: "MethodOne",
390
+ get receiver() {
391
+ return _$createComponent(FunctionReceiver, {
392
+ name: "s",
393
+ type: ReceiverRefkey,
394
+ typeParameters: [{
395
+ name: "U",
396
+ constraint: "any"
397
+ }]
398
+ });
399
+ }
400
+ })];
401
+ }
402
+ })).toRenderTo(`
403
+ package alloy
404
+
405
+ type TestStruct[T any] struct{}
406
+ func (s TestStruct[U any]) MethodOne() {}
407
+ `);
408
+ });
409
+ });
410
+ //# sourceMappingURL=function.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["code","Output","refkey","render","describe","expect","it","TestPackage","ModuleDirectory","SourceDirectory","SourceFile","StructDeclaration","TypeDeclaration","FunctionDeclaration","FunctionReceiver","Wrapper","props","_$createComponent","children","name","_$createIntrinsic","_$memo","toRenderTo","params","type","res","parameters","returns","doc","singleLine","ReceiverRefkey","receiver","variadic","path","toThrowError","T","typeParameters","constraint"],"sources":["../../../../src/components/function/function.test.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAAmBA,IAAI,EAAEC,MAAM,EAAEC,MAAM,EAAUC,MAAM,QAAQ,gBAAgB;AAC/E,SAASC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;AAC7C,SAASC,WAAW,QAAQ,wBAAwB;AACpD,SAASC,eAAe,QAAQ,uBAAuB;AACvD,SAASC,eAAe,QAAQ,uBAAuB;AACvD,SAASC,UAAU,QAAQ,kBAAkB;AAC7C,SAASC,iBAAiB,QAAQ,0BAA0B;AAC5D,SAASC,eAAe,QAAQ,wBAAwB;AACxD,SAASC,mBAAmB,EAAEC,gBAAgB,QAAQ,eAAe;AAErE,MAAMC,OAAO,GAAIC,KAA6C,IAAAC,iBAAA,CAC3DV,WAAW;EAAA,IAAAW,SAAA;IAAA,QAAAD,iBAAA,CACTL,eAAe;MAAA,IAACV,MAAMA,CAAA;QAAA,OAAEc,KAAK,CAACd,MAAM;MAAA;MAAEiB,IAAI;MAAA,IAAAD,SAAA;QAAA,QAAAD,iBAAA,CACxCN,iBAAiB,OAAAS,iBAAA;MAAA;IAAA,IAAAC,MAAA,OAGnBL,KAAK,CAACE,QAAQ;EAAA;AAAA,EAElB;AAEDZ,EAAE,CAAC,gDAAgD,EAAE,MAAM;EACzDD,MAAM,CAAAY,iBAAA,CACHV,WAAW;IAAA,IAAAW,SAAA;MAAA,OAAAD,iBAAA,CACTJ,mBAAmB;QAACM,IAAI;MAAA;IAAA;EAAA,EAE7B,CAAC,CAACG,UAAU,CAAC;AACf;AACA;AACA;AACA,GAAG,CAAC;AACJ,CAAC,CAAC;AAEFhB,EAAE,CAAC,mDAAmD,EAAE,MAAM;E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,UAAU,EAAE;UAAM,CAAC,CAAC;UAAA,IAAAnB,SAAA;YAAA,QAAAD,iBAAA,CAEjDN,iBAAiB,OAAAS,iBAAA;UAAA;QAAA,IAAAH,iBAAA,CAGnBJ,mBAAmB;UAClBM,IAAI;UAAA,IACJY,QAAQA,CAAA;YAAA,OAAAd,iBAAA,CAAGH,gBAAgB;cAACK,IAAI;cAAKK,IAAI,EAAEM;YAAc;UAAA;QAAA;MAAA;IAAA,EAG/D,CAAC,CAACR,UAAU,CAAC;AACjB;AACA;AACA;AACA;AACA,GAAG,CAAC;EACF,CAAC,CAAC;EAEFhB,EAAE,CAAC,mBAAmB,EAAE,MAAM;IAC5B,MAAMwB,cAAc,GAAG5B,MAAM,CAAC,gBAAgB,CAAC;IAE/CG,MAAM,CAAAY,iBAAA,CACHV,WAAW;MAAA,IAAAW,SAAA;QAAA,QAAAD,iBAAA,CACTL,eAAe;UACdV,MAAM,EAAE4B,cAAc;UACtBX,IAAI;UACJiB,cAAc,EAAE,CAAC;YAAEjB,IAAI,EAAE,GAAG;YAAEkB,UAAU,EAAE;UAAM,CAAC,CAAC;UAAA,IAAAnB,SAAA;YAAA,QAAAD,iBAAA,CAEjDN,iBAAiB,OAAAS,iBAAA;UAAA;QAAA,IAAAH,iBAAA,CAGnBJ,mBAAmB;UAClBM,IAAI;UAAA,IACJY,QAAQA,CAAA;YAAA,OAAAd,iBAAA,CACLH,gBAAgB;cACfK,IAAI;cACJK,IAAI,EAAEM,cAAc;cACpBM,cAAc,EAAE,CAAC;gBAAEjB,IAAI,EAAE,GAAG;gBAAEkB,UAAU,EAAE;cAAM,CAAC;YAAC;UAAA;QAAA;MAAA;IAAA,EAK5D,CAAC,CAACf,UAAU,CAAC;AACjB;AACA;AACA;AACA;AACA,GAAG,CAAC;EACF,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,16 @@
1
+ export * from "./doc/comment.js";
2
+ export * from "./function/function.js";
3
+ export * from "./ImportStatement.js";
4
+ export * from "./interface/declaration.js";
5
+ export * from "./ModuleDirectory.js";
6
+ export * from "./Name.js";
7
+ export * from "./parameters/parameters.js";
8
+ export * from "./parameters/typeparameters.jsx";
9
+ export * from "./pointer/pointer.js";
10
+ export * from "./Reference.js";
11
+ export * from "./SourceDirectory.js";
12
+ export * from "./SourceFile.js";
13
+ export * from "./struct/declaration.js";
14
+ export * from "./type/declaration.js";
15
+ export * from "./var/declaration.js";
16
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AACrC,cAAc,WAAW,CAAC;AAC1B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,iCAAiC,CAAC;AAChD,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC"}
@@ -0,0 +1,16 @@
1
+ export * from "./doc/comment.js";
2
+ export * from "./function/function.js";
3
+ export * from "./ImportStatement.js";
4
+ export * from "./interface/declaration.js";
5
+ export * from "./ModuleDirectory.js";
6
+ export * from "./Name.js";
7
+ export * from "./parameters/parameters.js";
8
+ export * from "./parameters/typeparameters.js";
9
+ export * from "./pointer/pointer.js";
10
+ export * from "./Reference.js";
11
+ export * from "./SourceDirectory.js";
12
+ export * from "./SourceFile.js";
13
+ export * from "./struct/declaration.js";
14
+ export * from "./type/declaration.js";
15
+ export * from "./var/declaration.js";
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["../../../src/components/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc,kBAAkB;AAChC,cAAc,wBAAwB;AACtC,cAAc,sBAAsB;AACpC,cAAc,4BAA4B;AAC1C,cAAc,sBAAsB;AACpC,cAAc,WAAW;AACzB,cAAc,4BAA4B;AAC1C;AACA,cAAc,sBAAsB;AACpC,cAAc,gBAAgB;AAC9B,cAAc,sBAAsB;AACpC,cAAc,iBAAiB;AAC/B,cAAc,yBAAyB;AACvC,cAAc,uBAAuB;AACrC,cAAc,sBAAsB","ignoreList":[]}
@@ -0,0 +1,68 @@
1
+ import { Children, Namekey, Refkey } from "@alloy-js/core";
2
+ import { FunctionParameterProps } from "../parameters/parameters.js";
3
+ import { TypeDeclarationProps } from "../type/declaration.jsx";
4
+ /**
5
+ * Properties for creating an interface declaration.
6
+ * This can be used for both named and anonymous interfaces.
7
+ * For named interfaces, use `InterfaceTypeDeclarationProps` instead.
8
+ */
9
+ export interface InterfaceDeclarationProps {
10
+ refkey?: Refkey;
11
+ children?: Children;
12
+ /**
13
+ * Whether to render the interface in a single line.
14
+ * This will only compile if `children` is a single line as well.
15
+ * This is not common in Go, so use with caution.
16
+ */
17
+ singleLine?: boolean;
18
+ }
19
+ /**
20
+ * Properties for creating a named interface type declaration.
21
+ * This is a combination of `InterfaceDeclarationProps` and `TypeDeclarationProps`.
22
+ */
23
+ export interface InterfaceTypeDeclarationProps extends InterfaceDeclarationProps, TypeDeclarationProps {
24
+ }
25
+ /**
26
+ * Wrapper for creating a named interface type declaration.
27
+ */
28
+ export declare function InterfaceTypeDeclaration(props: InterfaceTypeDeclarationProps): Children;
29
+ /**
30
+ * Go interface declaration.
31
+ * @example
32
+ * ```tsx
33
+ * <InterfaceDeclaration>
34
+ * <InterfaceEmbed>{MyOtherInterface}</InterfaceEmbed>
35
+ * <InterfaceFunction name="MyFunc" parameters={params} returns="int" />
36
+ * </InterfaceDeclaration>
37
+ * ```
38
+ * This will produce:
39
+ * ```go
40
+ * interface {
41
+ * MyOtherInterface
42
+ * func MyFunc(param Param) int
43
+ * }
44
+ * ```
45
+ */
46
+ export declare function InterfaceDeclaration(props: InterfaceDeclarationProps): Children;
47
+ export interface InterfaceFunctionProps {
48
+ name: string | Namekey;
49
+ parameters?: FunctionParameterProps[];
50
+ returns?: Children;
51
+ refkey?: Refkey;
52
+ /** Doc comment */
53
+ doc?: Children;
54
+ }
55
+ export declare function InterfaceFunction(props: InterfaceFunctionProps): Children;
56
+ export interface InterfaceEmbedProps {
57
+ refkey?: Refkey;
58
+ children?: Children;
59
+ /** Doc comment */
60
+ doc?: Children;
61
+ }
62
+ export declare function InterfaceEmbed(props: InterfaceEmbedProps): Children;
63
+ export interface TypeConstraintProps {
64
+ constraints?: Children[];
65
+ children?: Children;
66
+ }
67
+ export declare function TypeConstraint(props: TypeConstraintProps): Children;
68
+ //# sourceMappingURL=declaration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"declaration.d.ts","sourceRoot":"","sources":["../../../../src/components/interface/declaration.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAMR,OAAO,EACP,MAAM,EAMP,MAAM,gBAAgB,CAAC;AAexB,OAAO,EACL,sBAAsB,EAEvB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAmB,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAEhF;;;;GAIG;AACH,MAAM,WAAW,yBAAyB;IACxC,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,6BACf,SAAQ,yBAAyB,EAC/B,oBAAoB;CAAG;AAE3B;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,6BAA6B,YAM5E;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,yBAAyB,YAsDpE;AAED,MAAM,WAAW,sBAA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