@alloy-js/core 0.1.0

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 (229) hide show
  1. package/LICENSE.txt +7 -0
  2. package/api-extractor.json +11 -0
  3. package/babel.config.cjs +4 -0
  4. package/dist/src/binder.d.ts +333 -0
  5. package/dist/src/binder.d.ts.map +1 -0
  6. package/dist/src/binder.js +444 -0
  7. package/dist/src/binder.js.map +1 -0
  8. package/dist/src/code.d.ts +3 -0
  9. package/dist/src/code.d.ts.map +1 -0
  10. package/dist/src/code.js +156 -0
  11. package/dist/src/code.js.map +1 -0
  12. package/dist/src/components/Declaration.d.ts +29 -0
  13. package/dist/src/components/Declaration.d.ts.map +1 -0
  14. package/dist/src/components/Declaration.js +47 -0
  15. package/dist/src/components/Declaration.js.map +1 -0
  16. package/dist/src/components/Indent.d.ts +13 -0
  17. package/dist/src/components/Indent.d.ts.map +1 -0
  18. package/dist/src/components/Indent.js +23 -0
  19. package/dist/src/components/Indent.js.map +1 -0
  20. package/dist/src/components/MemberDeclaration.d.ts +30 -0
  21. package/dist/src/components/MemberDeclaration.d.ts.map +1 -0
  22. package/dist/src/components/MemberDeclaration.js +52 -0
  23. package/dist/src/components/MemberDeclaration.js.map +1 -0
  24. package/dist/src/components/MemberName.d.ts +2 -0
  25. package/dist/src/components/MemberName.d.ts.map +1 -0
  26. package/dist/src/components/MemberName.js +11 -0
  27. package/dist/src/components/MemberName.js.map +1 -0
  28. package/dist/src/components/MemberScope.d.ts +27 -0
  29. package/dist/src/components/MemberScope.d.ts.map +1 -0
  30. package/dist/src/components/MemberScope.js +28 -0
  31. package/dist/src/components/MemberScope.js.map +1 -0
  32. package/dist/src/components/Name.d.ts +2 -0
  33. package/dist/src/components/Name.d.ts.map +1 -0
  34. package/dist/src/components/Name.js +11 -0
  35. package/dist/src/components/Name.js.map +1 -0
  36. package/dist/src/components/Output.d.ts +31 -0
  37. package/dist/src/components/Output.d.ts.map +1 -0
  38. package/dist/src/components/Output.js +44 -0
  39. package/dist/src/components/Output.js.map +1 -0
  40. package/dist/src/components/Scope.d.ts +10 -0
  41. package/dist/src/components/Scope.d.ts.map +1 -0
  42. package/dist/src/components/Scope.js +25 -0
  43. package/dist/src/components/Scope.js.map +1 -0
  44. package/dist/src/components/SourceDirectory.d.ts +7 -0
  45. package/dist/src/components/SourceDirectory.d.ts.map +1 -0
  46. package/dist/src/components/SourceDirectory.js +38 -0
  47. package/dist/src/components/SourceDirectory.js.map +1 -0
  48. package/dist/src/components/SourceFile.d.ts +12 -0
  49. package/dist/src/components/SourceFile.d.ts.map +1 -0
  50. package/dist/src/components/SourceFile.js +26 -0
  51. package/dist/src/components/SourceFile.js.map +1 -0
  52. package/dist/src/components/index.d.ts +11 -0
  53. package/dist/src/components/index.d.ts.map +1 -0
  54. package/dist/src/components/index.js +11 -0
  55. package/dist/src/components/index.js.map +1 -0
  56. package/dist/src/components/stc/index.d.ts +26 -0
  57. package/dist/src/components/stc/index.d.ts.map +1 -0
  58. package/dist/src/components/stc/index.js +9 -0
  59. package/dist/src/components/stc/index.js.map +1 -0
  60. package/dist/src/context/assignment.d.ts +39 -0
  61. package/dist/src/context/assignment.d.ts.map +1 -0
  62. package/dist/src/context/assignment.js +39 -0
  63. package/dist/src/context/assignment.js.map +1 -0
  64. package/dist/src/context/binder.d.ts +9 -0
  65. package/dist/src/context/binder.d.ts.map +1 -0
  66. package/dist/src/context/binder.js +12 -0
  67. package/dist/src/context/binder.js.map +1 -0
  68. package/dist/src/context/declaration.d.ts +4 -0
  69. package/dist/src/context/declaration.d.ts.map +1 -0
  70. package/dist/src/context/declaration.js +3 -0
  71. package/dist/src/context/declaration.js.map +1 -0
  72. package/dist/src/context/indent.d.ts +5 -0
  73. package/dist/src/context/indent.d.ts.map +1 -0
  74. package/dist/src/context/indent.js +8 -0
  75. package/dist/src/context/indent.js.map +1 -0
  76. package/dist/src/context/index.d.ts +11 -0
  77. package/dist/src/context/index.d.ts.map +1 -0
  78. package/dist/src/context/index.js +11 -0
  79. package/dist/src/context/index.js.map +1 -0
  80. package/dist/src/context/member-declaration.d.ts +9 -0
  81. package/dist/src/context/member-declaration.d.ts.map +1 -0
  82. package/dist/src/context/member-declaration.js +9 -0
  83. package/dist/src/context/member-declaration.js.map +1 -0
  84. package/dist/src/context/member-scope.d.ts +13 -0
  85. package/dist/src/context/member-scope.d.ts.map +1 -0
  86. package/dist/src/context/member-scope.js +12 -0
  87. package/dist/src/context/member-scope.js.map +1 -0
  88. package/dist/src/context/name-policy.d.ts +5 -0
  89. package/dist/src/context/name-policy.d.ts.map +1 -0
  90. package/dist/src/context/name-policy.js +10 -0
  91. package/dist/src/context/name-policy.js.map +1 -0
  92. package/dist/src/context/scope.d.ts +5 -0
  93. package/dist/src/context/scope.d.ts.map +1 -0
  94. package/dist/src/context/scope.js +6 -0
  95. package/dist/src/context/scope.js.map +1 -0
  96. package/dist/src/context/source-directory.d.ts +9 -0
  97. package/dist/src/context/source-directory.d.ts.map +1 -0
  98. package/dist/src/context/source-directory.js +3 -0
  99. package/dist/src/context/source-directory.js.map +1 -0
  100. package/dist/src/context/source-file.d.ts +12 -0
  101. package/dist/src/context/source-file.d.ts.map +1 -0
  102. package/dist/src/context/source-file.js +3 -0
  103. package/dist/src/context/source-file.js.map +1 -0
  104. package/dist/src/context.d.ts +13 -0
  105. package/dist/src/context.d.ts.map +1 -0
  106. package/dist/src/context.js +30 -0
  107. package/dist/src/context.js.map +1 -0
  108. package/dist/src/index.d.ts +13 -0
  109. package/dist/src/index.d.ts.map +1 -0
  110. package/dist/src/index.js +13 -0
  111. package/dist/src/index.js.map +1 -0
  112. package/dist/src/jsx-runtime.d.ts +43 -0
  113. package/dist/src/jsx-runtime.d.ts.map +1 -0
  114. package/dist/src/jsx-runtime.js +172 -0
  115. package/dist/src/jsx-runtime.js.map +1 -0
  116. package/dist/src/name-policy.d.ts +5 -0
  117. package/dist/src/name-policy.d.ts.map +1 -0
  118. package/dist/src/name-policy.js +8 -0
  119. package/dist/src/name-policy.js.map +1 -0
  120. package/dist/src/refkey.d.ts +9 -0
  121. package/dist/src/refkey.d.ts.map +1 -0
  122. package/dist/src/refkey.js +44 -0
  123. package/dist/src/refkey.js.map +1 -0
  124. package/dist/src/render.d.ts +147 -0
  125. package/dist/src/render.d.ts.map +1 -0
  126. package/dist/src/render.js +317 -0
  127. package/dist/src/render.js.map +1 -0
  128. package/dist/src/tsdoc-metadata.json +11 -0
  129. package/dist/src/utils.d.ts +80 -0
  130. package/dist/src/utils.d.ts.map +1 -0
  131. package/dist/src/utils.js +219 -0
  132. package/dist/src/utils.js.map +1 -0
  133. package/dist/test/children.test.d.ts +2 -0
  134. package/dist/test/children.test.d.ts.map +1 -0
  135. package/dist/test/components/source-file.test.d.ts +2 -0
  136. package/dist/test/components/source-file.test.d.ts.map +1 -0
  137. package/dist/test/name-policy.test.d.ts +2 -0
  138. package/dist/test/name-policy.test.d.ts.map +1 -0
  139. package/dist/test/reactivity/ref-rendering.test.d.ts +2 -0
  140. package/dist/test/reactivity/ref-rendering.test.d.ts.map +1 -0
  141. package/dist/test/reactivity/test.test.d.ts +2 -0
  142. package/dist/test/reactivity/test.test.d.ts.map +1 -0
  143. package/dist/test/refkey.test.d.ts +2 -0
  144. package/dist/test/refkey.test.d.ts.map +1 -0
  145. package/dist/test/rendering/basic.test.d.ts +2 -0
  146. package/dist/test/rendering/basic.test.d.ts.map +1 -0
  147. package/dist/test/rendering/code.test.d.ts +2 -0
  148. package/dist/test/rendering/code.test.d.ts.map +1 -0
  149. package/dist/test/rendering/indent.test.d.ts +2 -0
  150. package/dist/test/rendering/indent.test.d.ts.map +1 -0
  151. package/dist/test/rendering/linebreaks.test.d.ts +2 -0
  152. package/dist/test/rendering/linebreaks.test.d.ts.map +1 -0
  153. package/dist/test/rendering/refkeys.test.d.ts +2 -0
  154. package/dist/test/rendering/refkeys.test.d.ts.map +1 -0
  155. package/dist/test/stc.test.d.ts +2 -0
  156. package/dist/test/stc.test.d.ts.map +1 -0
  157. package/dist/test/symbols.test.d.ts +2 -0
  158. package/dist/test/symbols.test.d.ts.map +1 -0
  159. package/dist/test/utils.test.d.ts +2 -0
  160. package/dist/test/utils.test.d.ts.map +1 -0
  161. package/dist/testing/extend-expect.d.ts +2 -0
  162. package/dist/testing/extend-expect.d.ts.map +1 -0
  163. package/dist/testing/extend-expect.js +22 -0
  164. package/dist/testing/extend-expect.js.map +1 -0
  165. package/dist/testing/index.d.ts +3 -0
  166. package/dist/testing/index.d.ts.map +1 -0
  167. package/dist/testing/index.js +3 -0
  168. package/dist/testing/index.js.map +1 -0
  169. package/dist/testing/render.d.ts +7 -0
  170. package/dist/testing/render.d.ts.map +1 -0
  171. package/dist/testing/render.js +25 -0
  172. package/dist/testing/render.js.map +1 -0
  173. package/dist/testing/vitest.d.js +1 -0
  174. package/dist/testing/vitest.d.js.map +1 -0
  175. package/dist/tsconfig.tsbuildinfo +1 -0
  176. package/package.json +64 -0
  177. package/src/binder.ts +838 -0
  178. package/src/code.ts +220 -0
  179. package/src/components/Declaration.tsx +53 -0
  180. package/src/components/Indent.tsx +33 -0
  181. package/src/components/MemberDeclaration.tsx +62 -0
  182. package/src/components/MemberName.tsx +11 -0
  183. package/src/components/MemberScope.tsx +40 -0
  184. package/src/components/Name.tsx +11 -0
  185. package/src/components/Output.tsx +69 -0
  186. package/src/components/Scope.tsx +27 -0
  187. package/src/components/SourceDirectory.tsx +43 -0
  188. package/src/components/SourceFile.tsx +33 -0
  189. package/src/components/index.tsx +10 -0
  190. package/src/components/stc/index.ts +9 -0
  191. package/src/context/assignment.ts +57 -0
  192. package/src/context/binder.ts +14 -0
  193. package/src/context/declaration.ts +5 -0
  194. package/src/context/indent.ts +10 -0
  195. package/src/context/index.ts +10 -0
  196. package/src/context/member-declaration.ts +10 -0
  197. package/src/context/member-scope.ts +17 -0
  198. package/src/context/name-policy.ts +13 -0
  199. package/src/context/scope.ts +8 -0
  200. package/src/context/source-directory.ts +11 -0
  201. package/src/context/source-file.ts +12 -0
  202. package/src/context.ts +53 -0
  203. package/src/index.ts +21 -0
  204. package/src/jsx-runtime.ts +266 -0
  205. package/src/name-policy.ts +13 -0
  206. package/src/refkey.ts +62 -0
  207. package/src/render.ts +389 -0
  208. package/src/utils.ts +288 -0
  209. package/temp/api.json +8840 -0
  210. package/test/children.test.tsx +33 -0
  211. package/test/components/source-file.test.tsx +45 -0
  212. package/test/name-policy.test.tsx +19 -0
  213. package/test/reactivity/ref-rendering.test.tsx +50 -0
  214. package/test/reactivity/test.test.tsx +83 -0
  215. package/test/refkey.test.ts +32 -0
  216. package/test/rendering/basic.test.tsx +156 -0
  217. package/test/rendering/code.test.tsx +62 -0
  218. package/test/rendering/indent.test.tsx +608 -0
  219. package/test/rendering/linebreaks.test.tsx +72 -0
  220. package/test/rendering/refkeys.test.tsx +35 -0
  221. package/test/stc.test.tsx +21 -0
  222. package/test/symbols.test.ts +406 -0
  223. package/test/utils.test.tsx +150 -0
  224. package/testing/extend-expect.ts +20 -0
  225. package/testing/index.ts +2 -0
  226. package/testing/render.ts +37 -0
  227. package/testing/vitest.d.ts +10 -0
  228. package/tsconfig.json +17 -0
  229. package/vitest.config.ts +18 -0
package/LICENSE.txt ADDED
@@ -0,0 +1,7 @@
1
+ Copyright 2024 Microsoft
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,11 @@
1
+ {
2
+ "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
3
+ "extends": "../../api-extractor.base.json",
4
+ "messages": {
5
+ "extractorMessageReporting": {
6
+ "ae-wrong-input-file-type": {
7
+ "logLevel": "none"
8
+ }
9
+ }
10
+ }
11
+ }
@@ -0,0 +1,4 @@
1
+ module.exports = {
2
+ sourceMaps: true,
3
+ presets: ["@babel/preset-typescript", "@alloy-js/babel-preset"],
4
+ };
@@ -0,0 +1,333 @@
1
+ import { Ref } from "@vue/reactivity";
2
+ import { Refkey } from "./refkey.js";
3
+ export type Metadata = object;
4
+ /**
5
+ * Flags that describe an output symbol.
6
+ */
7
+ export declare enum OutputSymbolFlags {
8
+ None = 0,
9
+ /**
10
+ * The symbol is an instance member container. Symbols with this flag will have a
11
+ * instanceMemberScope property that contains symbols for instance members.
12
+ */
13
+ InstanceMemberContainer = 1,
14
+ /**
15
+ * The symbol is a static member container. Symbols with this flag will have a
16
+ * staticMemberScope property that contains symbols for static members.
17
+ */
18
+ StaticMemberContainer = 2,
19
+ /**
20
+ * Whether this symbol contains members of any kind.
21
+ */
22
+ MemberContainer = 3,
23
+ /**
24
+ * Whether this symbol is an instance member of another symbol (i.e that it is
25
+ * stored in an instance member scope).
26
+ */
27
+ InstanceMember = 4,
28
+ /**
29
+ * Whether this symbol is a static member of another symbol (i.e that it is
30
+ * stored in a static member scope).
31
+ */
32
+ StaticMember = 8,
33
+ /**
34
+ * Whether this is an instance member or static member of another symbol.
35
+ */
36
+ Member = 12
37
+ }
38
+ /**
39
+ * An output symbol is a named entity that can be referenced in your output
40
+ * code. Referencing symbols is generally accomplished by using a
41
+ * {@link Refkey}.
42
+ *
43
+ * @remarks
44
+ *
45
+ * This interface is the base implementation of symbol. Generally, most
46
+ * languages will have subtypes of this interface that provide additional,
47
+ * language-specific metadata about declared symbols. For example, symbols in
48
+ * TypeScript need to track whether they are exported or what kind of symbol
49
+ * they are (e.g. type, value, parameter, etc.)
50
+ *
51
+ * Symbols are reactive values, which allows you to observe changes to the symbol
52
+ * information. For example, a symbol's name may change if it becomes conflicted
53
+ * with a symbol that is added later.
54
+ */
55
+ export interface OutputSymbol {
56
+ /**
57
+ * The original name of the symbol, before any conflicts were resolved.
58
+ */
59
+ originalName: string;
60
+ /**
61
+ * The name of the symbol.
62
+ */
63
+ name: string;
64
+ /**
65
+ * The symbol's flags.
66
+ */
67
+ flags: OutputSymbolFlags;
68
+ /**
69
+ * The scope in which the symbol is defined.
70
+ */
71
+ scope: OutputScope;
72
+ /**
73
+ * The binder instance that created this symbol.
74
+ */
75
+ binder: Binder;
76
+ /**
77
+ * A unique value that references this symbol.
78
+ */
79
+ refkey: Refkey;
80
+ /**
81
+ * The instance members available on this symbol.
82
+ *
83
+ * @remarks
84
+ *
85
+ * Instance members are members that are available when this symbol is
86
+ * instantiated. Instantiation is language-specific. For example, in
87
+ * TypeScript, instance members of symbols for classes are available when the
88
+ * class is instantiated with a new expression.
89
+ *
90
+ * When a symbol cannot have instance members, this is undefined.
91
+ */
92
+ instanceMemberScope?: OutputScope;
93
+ /**
94
+ * The static members available on this symbol.
95
+ *
96
+ * @remarks
97
+ *
98
+ * Static members are members that are available on the symbol itself. These symbols
99
+ * can be accessed off the parent symbol directly with a refkey. There is only ever
100
+ * one static member symbol in the output (i.e., the symbol is unique).
101
+ */
102
+ staticMemberScope?: OutputScope;
103
+ }
104
+ /**
105
+ * Flags that describe an output scope.
106
+ */
107
+ export declare enum OutputScopeFlags {
108
+ None = 0,
109
+ /**
110
+ * This scope is a static member scope.
111
+ */
112
+ StaticMemberScope = 1,
113
+ /**
114
+ * This scope is an instance member scope.
115
+ */
116
+ InstanceMemberScope = 2,
117
+ /**
118
+ * This scope is a member scope. Scopes with this flag will have an `owner`
119
+ * property that points to the symbol whose member this scope holds.
120
+ */
121
+ MemberScope = 3
122
+ }
123
+ /**
124
+ * A container of symbols accessible within some scope in your output code.
125
+ *
126
+ * @remarks
127
+ *
128
+ * Scopes form a tree. All scopes except the global scope have a parent scope
129
+ * identified by `parent`. Scopes can have nested scopes which can be accessed
130
+ * using the `children` property. Whether a child scope can be accessed from
131
+ * the parent scope is determined by each language's scoping rules.
132
+ *
133
+ * This interface is the base implementation of scope. Generally, most languages
134
+ * will have subtypes of this interface that provide additional metadata about
135
+ * the scope. For example, TypeScript scopes need to track whether the scope
136
+ * represents a package, module, class, function, etc.
137
+ *
138
+ * Scopes are reactive values, which allows you to observe changes to the scope
139
+ * within a reactive context.
140
+ */
141
+ export interface OutputScope {
142
+ /**
143
+ * The kind of scope. Subtypes will likely provide a set of known scope kinds.
144
+ * The kind is not used by the binder itself.
145
+ */
146
+ kind: string;
147
+ /**
148
+ * The name of the scope.
149
+ */
150
+ name: string;
151
+ /**
152
+ * The flags that describe this scope.
153
+ */
154
+ flags: OutputScopeFlags;
155
+ /**
156
+ * The symbols defined within this scope.
157
+ */
158
+ symbols: Set<OutputSymbol>;
159
+ /**
160
+ * The symbols defined within this scope, indexed by refkey.
161
+ */
162
+ symbolsByRefkey: Map<Refkey, OutputSymbol>;
163
+ /**
164
+ * The scopes nested within this scope.
165
+ */
166
+ children: Set<OutputScope>;
167
+ /**
168
+ * The container of this scope.
169
+ */
170
+ parent: OutputScope | undefined;
171
+ /**
172
+ * The symbol that owns this scope. This is only defined for scopes that have
173
+ * the {@link OutputScopeFlags.StaticMemberScope} flag.
174
+ */
175
+ owner?: OutputSymbol;
176
+ /**
177
+ * The binder that created this scope.
178
+ */
179
+ binder: Binder;
180
+ /**
181
+ * Get the names of all symbols in this scope.
182
+ */
183
+ getSymbolNames(): Set<string>;
184
+ }
185
+ /**
186
+ * The binder tracks all output scopes and symbols. Scopes are nested containers
187
+ * for symbols.
188
+ *
189
+ * @remarks
190
+ *
191
+ * Symbol information is reactive because in certain situations this data may
192
+ * change. For example, when a symbol becomes conflicted with another symbol,
193
+ * one of the symbol names may change. Ensure that you interact with binder
194
+ * values in a reactive context (i.e. within JSX/code template, or within
195
+ * memo/computed/etc).
196
+ *
197
+ */
198
+ export interface Binder {
199
+ /**
200
+ * Create a new scope. The scope will be added to the parent scope's children.
201
+ * The returned scope object is reactive.
202
+ */
203
+ createScope<T extends OutputScope>(args: {
204
+ kind: T["kind"];
205
+ name: string;
206
+ parent?: OutputScope | undefined;
207
+ flags?: OutputScopeFlags;
208
+ owner?: OutputSymbol;
209
+ } & Omit<T, keyof OutputScope>): T;
210
+ /**
211
+ * Create a new symbol. The symbol will be added to the parent scope's symbols.
212
+ * The returned symbol object is reactive.
213
+ */
214
+ createSymbol<T extends OutputSymbol>(args: {
215
+ name: string;
216
+ scope?: OutputScope;
217
+ refkey?: unknown;
218
+ flags?: OutputSymbolFlags;
219
+ } & Omit<T, keyof OutputSymbol>): T;
220
+ /**
221
+ * Instantiate the static members of a symbol into the instance members of
222
+ * another symbol.
223
+ *
224
+ * @param sourceSym - The symbol to add instance members to.
225
+ * @param targetSym - The symbol with the static members to instantiate.
226
+ */
227
+ instantiateSymbolInto(sourceSym: OutputSymbol, targetSym: OutputSymbol): void;
228
+ /**
229
+ * Add static members to an existing symbol.
230
+ *
231
+ * @param symbol - The symbol to add static members to.
232
+ */
233
+ addStaticMembersToSymbol(symbol: OutputSymbol): void;
234
+ /**
235
+ * Add instance members to an existing symbol.
236
+ *
237
+ * @param symbol - The symbol to add instance members to.
238
+ */
239
+ addInstanceMembersToSymbol(symbol: OutputSymbol): void;
240
+ /**
241
+ * Resolve the given refkey in the current scope.
242
+ *
243
+ * @returns a ref for the resolution result.
244
+ * @see {@link resolve} a convenience function that uses the current scope and
245
+ * binder.
246
+ */
247
+ resolveDeclarationByKey<TScope extends OutputScope = OutputScope, TSymbol extends OutputSymbol = OutputSymbol>(currentScope: TScope | undefined, currentMemberScope: TScope | undefined, key: Refkey): Ref<ResolutionResult<TScope, TSymbol> | undefined>;
248
+ globalScope: OutputScope;
249
+ }
250
+ /**
251
+ * A successful resolution of a refkey.
252
+ *
253
+ * @example
254
+ *
255
+ * Let's say we have the following scopes and symbols:
256
+ *
257
+ * ```
258
+ * scope: global scope
259
+ * ├── scope: namespace scope 1
260
+ * │ └── symbol: foo
261
+ * │ └── static member scope
262
+ * │ └── symbol: bar
263
+ * └── scope: namespace scope 2
264
+ * └── (resolve bar from here)
265
+ * ```
266
+ *
267
+ * When we resolve the refkey for `bar` from within `namespace scope 2`, we will get the following
268
+ * resolution result:
269
+ *
270
+ * * **targetDeclaration**: symbol bar, the symbol we resolved.
271
+ * * **commonScope**: global scope, because this is the most specific scope that contains both the declaration and the reference.
272
+ * * **pathUp**: [namespace scope 2], because this is the scope between the reference and the common scope.
273
+ * * **pathDown**: [namespace scope 1], because this is the scope between the common scope and the declaration
274
+ * * **memberPath**: [foo, bar], because we resolved a member symbol and these are the symbols that lead from the base declaration to the member symbol.
275
+ */
276
+ export interface ResolutionResult<TScope extends OutputScope, TSymbol extends OutputSymbol> {
277
+ /**
278
+ * The symbol for the resolved declaration.
279
+ */
280
+ targetDeclaration: TSymbol;
281
+ /**
282
+ * The scopes between the common scope and the reference
283
+ */
284
+ pathUp: TScope[];
285
+ /**
286
+ * The scopes between the common scope and the declaration.
287
+ */
288
+ pathDown: TScope[];
289
+ /**
290
+ * The scope which contains both the reference and the declaration.
291
+ */
292
+ commonScope: TScope | undefined;
293
+ /**
294
+ * When resolving a member symbol, this is the path of symbols that lead from
295
+ * the base declaration to the member symbol.
296
+ */
297
+ memberPath?: TSymbol[];
298
+ }
299
+ export interface NameConflictResolver {
300
+ (name: string, symbols: OutputSymbol[]): void;
301
+ }
302
+ export interface BinderOptions {
303
+ nameConflictResolver?: NameConflictResolver;
304
+ }
305
+ export declare function createOutputBinder(options?: BinderOptions): Binder;
306
+ /**
307
+ * Resolve a refkey in the current scope. Returns a Ref for the resolution result.
308
+ * The value of the ref will be undefined if the identifier hasn't been resolved yet.
309
+ *
310
+ * @remarks
311
+ *
312
+ * This API may return a ref for undefined, but that does not mean that the symbol is
313
+ * not found. The symbol you're looking for may not have been declared yet. When the symbol
314
+ * is declared, the ref will be updated with the resolution result.
315
+ */
316
+ export declare function resolve<TScope extends OutputScope, TSymbol extends OutputSymbol>(refkey: Refkey): Ref<ResolutionResult<TScope, TSymbol>>;
317
+ declare const createSymbolsSymbol: unique symbol;
318
+ export declare function getSymbolCreator(creator: SymbolCreator): SymbolCreator[typeof createSymbolsSymbol];
319
+ export declare function getSymbolCreatorSymbol(): typeof createSymbolsSymbol;
320
+ export interface SymbolCreator {
321
+ [createSymbolsSymbol](binder: Binder): void;
322
+ }
323
+ /**
324
+ * Use symbol flags to determine the scope in which a symbol with those flags
325
+ * should be declared given the current context.
326
+ *
327
+ * @param flags - The symbol flags to use to determine the default scope.
328
+ * @returns an {@link OutputScope} that is the default scope for the given
329
+ * flags.
330
+ */
331
+ export declare function useDefaultScope(flags?: OutputSymbolFlags): OutputScope | undefined;
332
+ export {};
333
+ //# sourceMappingURL=binder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"binder.d.ts","sourceRoot":"","sources":["../../src/binder.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,GAAG,EAGJ,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAU,MAAM,EAAE,MAAM,aAAa,CAAC;AAC7C,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC;AAE9B;;GAEG;AACH,oBAAY,iBAAiB;IAC3B,IAAI,IAAI;IAER;;;OAGG;IACH,uBAAuB,IAAS;IAEhC;;;OAGG;IACH,qBAAqB,IAAS;IAE9B;;OAEG;IACH,eAAe,IAAkD;IAEjE;;;OAGG;IACH,cAAc,IAAS;IAEvB;;;OAGG;IACH,YAAY,IAAS;IAErB;;OAEG;IACH,MAAM,KAAgC;CACvC;AAED;;;;;;;;;;;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