@alloy-js/core 0.16.0 → 0.18.0-dev.2

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 (249) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/src/binder.d.ts +19 -235
  3. package/dist/src/binder.d.ts.map +1 -1
  4. package/dist/src/binder.js +85 -386
  5. package/dist/src/code.d.ts +1 -1
  6. package/dist/src/code.d.ts.map +1 -1
  7. package/dist/src/components/Block.d.ts +1 -1
  8. package/dist/src/components/Block.d.ts.map +1 -1
  9. package/dist/src/components/Block.js +3 -1
  10. package/dist/src/components/Declaration.d.ts +2 -2
  11. package/dist/src/components/Declaration.d.ts.map +1 -1
  12. package/dist/src/components/Declaration.js +6 -5
  13. package/dist/src/components/For.d.ts +1 -1
  14. package/dist/src/components/For.d.ts.map +1 -1
  15. package/dist/src/components/For.js +1 -1
  16. package/dist/src/components/Indent.d.ts +1 -1
  17. package/dist/src/components/Indent.d.ts.map +1 -1
  18. package/dist/src/components/List.d.ts +1 -1
  19. package/dist/src/components/List.d.ts.map +1 -1
  20. package/dist/src/components/List.js +3 -1
  21. package/dist/src/components/MemberDeclaration.d.ts +3 -3
  22. package/dist/src/components/MemberDeclaration.d.ts.map +1 -1
  23. package/dist/src/components/MemberDeclaration.js +4 -4
  24. package/dist/src/components/MemberScope.d.ts +2 -2
  25. package/dist/src/components/MemberScope.d.ts.map +1 -1
  26. package/dist/src/components/MemberScope.js +0 -2
  27. package/dist/src/components/Output.d.ts +1 -1
  28. package/dist/src/components/Output.d.ts.map +1 -1
  29. package/dist/src/components/Output.js +1 -1
  30. package/dist/src/components/Prose.d.ts +1 -1
  31. package/dist/src/components/Prose.d.ts.map +1 -1
  32. package/dist/src/components/ReferenceOrContent.d.ts +1 -1
  33. package/dist/src/components/ReferenceOrContent.d.ts.map +1 -1
  34. package/dist/src/components/Scope.d.ts +2 -2
  35. package/dist/src/components/Scope.d.ts.map +1 -1
  36. package/dist/src/components/Scope.js +3 -6
  37. package/dist/src/components/Show.d.ts +1 -1
  38. package/dist/src/components/Show.d.ts.map +1 -1
  39. package/dist/src/components/SourceDirectory.d.ts +1 -1
  40. package/dist/src/components/SourceDirectory.d.ts.map +1 -1
  41. package/dist/src/components/SourceDirectory.js +1 -1
  42. package/dist/src/components/SourceFile.d.ts +1 -1
  43. package/dist/src/components/SourceFile.d.ts.map +1 -1
  44. package/dist/src/components/SourceFile.js +1 -1
  45. package/dist/src/components/StatementList.d.ts +1 -1
  46. package/dist/src/components/StatementList.d.ts.map +1 -1
  47. package/dist/src/components/StatementList.js +1 -1
  48. package/dist/src/components/Switch.d.ts +2 -2
  49. package/dist/src/components/Switch.d.ts.map +1 -1
  50. package/dist/src/components/Switch.js +2 -1
  51. package/dist/src/components/Wrap.d.ts +1 -1
  52. package/dist/src/components/Wrap.d.ts.map +1 -1
  53. package/dist/src/context/assignment.d.ts +1 -1
  54. package/dist/src/context/assignment.d.ts.map +1 -1
  55. package/dist/src/context/binder.d.ts +3 -3
  56. package/dist/src/context/binder.d.ts.map +1 -1
  57. package/dist/src/context/declaration.d.ts +1 -1
  58. package/dist/src/context/declaration.d.ts.map +1 -1
  59. package/dist/src/context/member-declaration.d.ts +1 -1
  60. package/dist/src/context/member-declaration.d.ts.map +1 -1
  61. package/dist/src/context/member-declaration.js +0 -1
  62. package/dist/src/context/member-scope.d.ts +1 -1
  63. package/dist/src/context/member-scope.d.ts.map +1 -1
  64. package/dist/src/context/name-policy.d.ts +1 -1
  65. package/dist/src/context/name-policy.d.ts.map +1 -1
  66. package/dist/src/context/scope.d.ts +1 -1
  67. package/dist/src/context/scope.d.ts.map +1 -1
  68. package/dist/src/context/source-directory.d.ts +1 -1
  69. package/dist/src/context/source-directory.d.ts.map +1 -1
  70. package/dist/src/context/source-file.d.ts +2 -2
  71. package/dist/src/context/source-file.d.ts.map +1 -1
  72. package/dist/src/context.d.ts +2 -2
  73. package/dist/src/context.d.ts.map +1 -1
  74. package/dist/src/context.js +1 -1
  75. package/dist/src/debug.d.ts +1 -0
  76. package/dist/src/debug.d.ts.map +1 -1
  77. package/dist/src/debug.js +4 -1
  78. package/dist/src/index.d.ts +8 -2
  79. package/dist/src/index.d.ts.map +1 -1
  80. package/dist/src/index.js +8 -2
  81. package/dist/src/jsx-runtime.d.ts +4 -272
  82. package/dist/src/jsx-runtime.d.ts.map +1 -1
  83. package/dist/src/jsx-runtime.js +3 -315
  84. package/dist/src/props-combinators.d.ts +19 -0
  85. package/dist/src/props-combinators.d.ts.map +1 -0
  86. package/dist/src/props-combinators.js +108 -0
  87. package/dist/src/reactive-union-set.d.ts +29 -0
  88. package/dist/src/reactive-union-set.d.ts.map +1 -0
  89. package/dist/src/reactive-union-set.js +183 -0
  90. package/dist/src/reactivity.d.ts +75 -0
  91. package/dist/src/reactivity.d.ts.map +1 -0
  92. package/dist/src/reactivity.js +141 -0
  93. package/dist/src/refkey.d.ts +36 -0
  94. package/dist/src/refkey.d.ts.map +1 -1
  95. package/dist/src/refkey.js +40 -0
  96. package/dist/src/render.d.ts +5 -1
  97. package/dist/src/render.d.ts.map +1 -1
  98. package/dist/src/render.js +68 -15
  99. package/dist/src/runtime/component.d.ts +24 -0
  100. package/dist/src/runtime/component.d.ts.map +1 -0
  101. package/dist/src/runtime/component.js +19 -0
  102. package/dist/src/runtime/intrinsic.d.ts +168 -0
  103. package/dist/src/runtime/intrinsic.d.ts.map +1 -0
  104. package/dist/src/runtime/intrinsic.js +11 -0
  105. package/dist/src/scheduler.d.ts +2 -2
  106. package/dist/src/scheduler.d.ts.map +1 -1
  107. package/dist/src/scheduler.js +27 -6
  108. package/dist/src/slot.d.ts +2 -2
  109. package/dist/src/slot.d.ts.map +1 -1
  110. package/dist/src/slot.js +1 -1
  111. package/dist/src/stc.d.ts +1 -1
  112. package/dist/src/stc.d.ts.map +1 -1
  113. package/dist/src/sti.d.ts +7 -6
  114. package/dist/src/sti.d.ts.map +1 -1
  115. package/dist/src/sti.js +1 -1
  116. package/dist/src/symbols/flags.d.ts +70 -0
  117. package/dist/src/symbols/flags.d.ts.map +1 -0
  118. package/dist/src/symbols/flags.js +72 -0
  119. package/dist/src/symbols/index.d.ts +7 -0
  120. package/dist/src/symbols/index.d.ts.map +1 -0
  121. package/dist/src/symbols/index.js +6 -0
  122. package/dist/src/symbols/output-scope.d.ts +94 -0
  123. package/dist/src/symbols/output-scope.d.ts.map +1 -0
  124. package/dist/src/symbols/output-scope.js +222 -0
  125. package/dist/src/symbols/output-symbol.d.ts +89 -0
  126. package/dist/src/symbols/output-symbol.d.ts.map +1 -0
  127. package/dist/src/symbols/output-symbol.js +333 -0
  128. package/dist/src/symbols/symbol-flow.d.ts +13 -0
  129. package/dist/src/symbols/symbol-flow.d.ts.map +1 -0
  130. package/dist/src/symbols/symbol-flow.js +74 -0
  131. package/dist/src/symbols/symbol-slot.d.ts +12 -0
  132. package/dist/src/symbols/symbol-slot.d.ts.map +1 -0
  133. package/dist/src/symbols/symbol-slot.js +36 -0
  134. package/dist/src/symbols/symbol-table.d.ts +14 -0
  135. package/dist/src/symbols/symbol-table.d.ts.map +1 -0
  136. package/dist/src/symbols/symbol-table.js +42 -0
  137. package/dist/src/tap.d.ts +3 -2
  138. package/dist/src/tap.d.ts.map +1 -1
  139. package/dist/src/tracer.d.ts +238 -0
  140. package/dist/src/tracer.d.ts.map +1 -0
  141. package/dist/src/tracer.js +496 -0
  142. package/dist/src/tsdoc-metadata.json +1 -1
  143. package/dist/src/utils.d.ts +4 -3
  144. package/dist/src/utils.d.ts.map +1 -1
  145. package/dist/src/utils.js +2 -1
  146. package/dist/test/components/slot.test.js +5 -7
  147. package/dist/test/props-with-defaults.test.js +1 -1
  148. package/dist/test/reactive-union-set.test.d.ts +2 -0
  149. package/dist/test/reactive-union-set.test.d.ts.map +1 -0
  150. package/dist/test/reactive-union-set.test.js +170 -0
  151. package/dist/test/reactivity/cleanup.test.js +2 -1
  152. package/dist/test/reactivity/memo.test.js +1 -1
  153. package/dist/test/reactivity/untrack.test.js +1 -1
  154. package/dist/test/rendering/memoization.test.js +2 -1
  155. package/dist/test/split-props.test.js +1 -1
  156. package/dist/test/symbols/output-scope.test.d.ts +2 -0
  157. package/dist/test/symbols/output-scope.test.d.ts.map +1 -0
  158. package/dist/test/symbols/output-scope.test.js +343 -0
  159. package/dist/test/symbols/output-symbol.test.d.ts +2 -0
  160. package/dist/test/symbols/output-symbol.test.d.ts.map +1 -0
  161. package/dist/test/symbols/output-symbol.test.js +447 -0
  162. package/dist/test/symbols/resolution.test.d.ts +2 -0
  163. package/dist/test/symbols/resolution.test.d.ts.map +1 -0
  164. package/dist/test/symbols/resolution.test.js +141 -0
  165. package/dist/test/symbols/utils.d.ts +25 -0
  166. package/dist/test/symbols/utils.d.ts.map +1 -0
  167. package/dist/test/symbols/utils.js +47 -0
  168. package/dist/testing/extend-expect.d.ts +15 -0
  169. package/dist/testing/extend-expect.d.ts.map +1 -1
  170. package/dist/testing/extend-expect.js +2 -1
  171. package/dist/testing/render.d.ts +1 -1
  172. package/dist/testing/render.d.ts.map +1 -1
  173. package/dist/tsconfig.tsbuildinfo +1 -1
  174. package/package.json +28 -24
  175. package/src/binder.ts +146 -672
  176. package/src/code.ts +1 -1
  177. package/src/components/Block.tsx +4 -1
  178. package/src/components/Declaration.tsx +8 -7
  179. package/src/components/For.tsx +2 -1
  180. package/src/components/Indent.tsx +1 -1
  181. package/src/components/List.tsx +3 -1
  182. package/src/components/MemberDeclaration.tsx +7 -6
  183. package/src/components/MemberScope.tsx +2 -5
  184. package/src/components/Output.tsx +2 -1
  185. package/src/components/Prose.tsx +1 -1
  186. package/src/components/ReferenceOrContent.tsx +1 -1
  187. package/src/components/Scope.tsx +3 -7
  188. package/src/components/Show.tsx +1 -1
  189. package/src/components/SourceDirectory.tsx +2 -1
  190. package/src/components/SourceFile.tsx +2 -1
  191. package/src/components/StatementList.tsx +2 -1
  192. package/src/components/Switch.tsx +2 -1
  193. package/src/components/Wrap.tsx +1 -1
  194. package/src/context/assignment.ts +1 -1
  195. package/src/context/binder.ts +3 -3
  196. package/src/context/declaration.ts +1 -1
  197. package/src/context/member-declaration.ts +1 -1
  198. package/src/context/member-scope.ts +1 -1
  199. package/src/context/name-policy.ts +1 -1
  200. package/src/context/scope.ts +1 -1
  201. package/src/context/source-directory.ts +1 -1
  202. package/src/context/source-file.ts +2 -2
  203. package/src/context.ts +3 -7
  204. package/src/debug.ts +5 -1
  205. package/src/index.ts +15 -1
  206. package/src/jsx-runtime.ts +15 -674
  207. package/src/props-combinators.ts +148 -0
  208. package/src/reactive-union-set.ts +238 -0
  209. package/src/reactivity.ts +230 -0
  210. package/src/refkey.ts +40 -0
  211. package/src/render.ts +97 -26
  212. package/src/runtime/component.ts +67 -0
  213. package/src/runtime/intrinsic.ts +199 -0
  214. package/src/scheduler.ts +31 -6
  215. package/src/slot.ts +3 -4
  216. package/src/stc.ts +2 -2
  217. package/src/sti.ts +11 -11
  218. package/src/symbols/flags.ts +82 -0
  219. package/src/symbols/index.ts +6 -0
  220. package/src/symbols/output-scope.ts +296 -0
  221. package/src/symbols/output-symbol.ts +459 -0
  222. package/src/symbols/symbol-flow.ts +100 -0
  223. package/src/symbols/symbol-slot.tsx +48 -0
  224. package/src/symbols/symbol-table.ts +72 -0
  225. package/src/tap.ts +3 -2
  226. package/src/tracer.ts +474 -0
  227. package/src/utils.tsx +7 -5
  228. package/temp/api.json +7446 -5133
  229. package/test/components/slot.test.tsx +8 -11
  230. package/test/props-with-defaults.test.ts +1 -1
  231. package/test/reactive-union-set.test.tsx +191 -0
  232. package/test/reactivity/cleanup.test.tsx +2 -1
  233. package/test/reactivity/memo.test.tsx +1 -1
  234. package/test/reactivity/untrack.test.ts +1 -1
  235. package/test/rendering/basic.test.tsx +1 -1
  236. package/test/rendering/memoization.test.tsx +1 -1
  237. package/test/split-props.test.ts +1 -1
  238. package/test/symbols/output-scope.test.ts +300 -0
  239. package/test/symbols/output-symbol.test.ts +456 -0
  240. package/test/symbols/resolution.test.ts +170 -0
  241. package/test/symbols/utils.ts +93 -0
  242. package/test/utils.test.tsx +1 -1
  243. package/testing/extend-expect.ts +16 -0
  244. package/testing/render.ts +1 -2
  245. package/LICENSE +0 -7
  246. package/dist/test/symbols.test.d.ts +0 -2
  247. package/dist/test/symbols.test.d.ts.map +0 -1
  248. package/dist/test/symbols.test.js +0 -884
  249. package/test/symbols.test.ts +0 -1006
@@ -1,229 +1,11 @@
1
- import { Ref } from "@vue/reactivity";
2
- import { Refkey } from "./refkey.js";
3
- import { RenderedTextTree } from "./render.js";
4
- export interface Disposable {
5
- (): void;
6
- }
7
- export interface Context {
8
- disposables: Disposable[];
9
- owner: Context | null;
10
- context?: Record<symbol, unknown>;
11
- meta?: Record<string, any>;
12
- /**
13
- * A cache of RenderTextTree nodes created within this context,
14
- * indexed by the component or function which created them.
15
- */
16
- elementCache: ElementCache;
17
- /**
18
- * When this context was created by a component, this will
19
- * be the component that created it.
20
- */
21
- componentOwner?: ComponentCreator<unknown>;
22
- }
23
- export declare function getContext(): Context | null;
24
- export declare function getElementCache(): ElementCache;
25
- export type ElementCacheKey = ComponentCreator | (() => unknown) | CustomContext;
26
- export type ElementCache = Map<ElementCacheKey, RenderedTextTree>;
27
- export interface RootOptions {
28
- componentOwner?: ComponentCreator<any>;
29
- }
30
- export declare function root<T>(fn: (d: Disposable) => T, options?: RootOptions): T;
31
- export declare function untrack<T>(fn: () => T): T;
32
- export declare function memo<T>(fn: () => T, equal?: boolean): () => T;
33
- export declare function effect<T>(fn: (prev?: T) => T, current?: T): void;
34
- /**
35
- * Register a cleanup function which is called when the current reactive scope
36
- * is recalculated or disposed. This is useful to clean up any side effects
37
- * created in the reactive scope.
38
- *
39
- * @remarks
40
- *
41
- * When onCleanup is called inside a component definition, the provided function
42
- * is called when the component is removed from the tree. This can be useful to
43
- * clean up any side effects created as a result of rendering the component. For
44
- * example, if rendering a component creates a symbol, `onCleanup` can be used
45
- * to remove the symbol when the component is removed from the tree.
46
- *
47
- * When onCleanup is called inside a memo or effect, the function is called when
48
- * the effect is refreshed (e.g. when a memo or computed recalculates) or
49
- * disposed (e.g. it is no longer needed because it is attached to a component
50
- * which was removed).
51
- */
52
- export declare function onCleanup(fn: Disposable): void;
53
- /**
54
- * Create a custom reactive context for the children returned by
55
- * the provided context.
56
- */
57
- export interface CustomContext {
58
- [CUSTOM_CONTEXT_SYM]: true;
59
- useCustomContext: (useCb: CustomContextChildrenCallback) => void;
60
- }
61
- export type CustomContextChildrenCallback = (child: Children) => void;
62
- declare const CUSTOM_CONTEXT_SYM: unique symbol;
63
- export declare function createCustomContext(useCallback: (useChildren: CustomContextChildrenCallback) => void): CustomContext;
64
- export declare function isCustomContext(child: Children): child is CustomContext;
65
- export type Child = string | boolean | number | undefined | null | void | (() => Children) | Ref | Refkey | CustomContext | IntrinsicElement;
66
- export type Children = Child | Children[];
67
- export type Props = Record<string, any>;
68
- export interface ComponentDefinition<TProps = Props> {
69
- (props: TProps): Children;
70
- }
71
- export interface Component<TProps = Props> {
72
- (props: TProps): Children;
73
- tag?: symbol;
74
- }
75
- export interface ComponentCreator<TProps = Props> {
76
- component: Component<TProps>;
77
- (): Children;
78
- props: TProps;
79
- tag?: symbol;
80
- }
81
- export declare function pushStack(component: Component<any>, props: Props): void;
82
- export declare function popStack(): void;
83
- export declare function printRenderStack(): void;
84
- export declare function isComponentCreator<TProps = any>(item: unknown, component?: Component<TProps>): item is ComponentCreator<TProps>;
1
+ import type { Children, Component, ComponentDefinition, IntrinsicElements as CoreIntrinsicElements } from "@alloy-js/core";
2
+ export { createComponent, createIntrinsic, memo, mergeProps, type Children, } from "@alloy-js/core";
85
3
  /**
86
4
  * This namespace is predominantly for interop with React tooling in VSCode
87
5
  * and controls the type of JSX elements, components, and the like.
88
6
  */
89
7
  export declare namespace JSX {
90
- interface IntrinsicElements {
91
- /**
92
- * Attempt to render the children on a single line if possible. If a group
93
- * contains `<breakParent />` or a hard line, or if the group exceeds the
94
- * print width, all linebreaks in the group will be broken.
95
- */
96
- group: {
97
- shouldBreak?: boolean;
98
- id?: symbol;
99
- children: Children;
100
- };
101
- /**
102
- * A regular line break. This will break if the line exceeds the print
103
- * width, otherwise it will be a space.
104
- */
105
- line: {};
106
- /**
107
- * A regular line break. This will break if the line exceeds the print
108
- * width, otherwise it will be a space.
109
- */
110
- br: {};
111
- /**
112
- * A hard line break. This is a line that will always break, even if the
113
- * group does not exceed print width.
114
- */
115
- hardline: {};
116
- /**
117
- * A hard line break. This is a line that will always break, even if the
118
- * group does not exceed print width.
119
- */
120
- hbr: {};
121
- /**
122
- * A soft line break. This will break if the line exceeds the print width,
123
- * otherwise it will be be nothing.
124
- */
125
- softline: {};
126
- /**
127
- * A soft line break. This will break if the line exceeds the print width,
128
- * otherwise it will be be nothing.
129
- */
130
- sbr: {};
131
- /**
132
- * A literal line break. This will always break, even if the group does not
133
- * exceed print width. The new line will ignore indentation.
134
- */
135
- literalline: {};
136
- /**
137
- * A literal line break. This will always break, even if the group does not
138
- * exceed print width. The new line will ignore indentation.
139
- */
140
- lbr: {};
141
- /**
142
- * Increase the indentation level of the children of this component.
143
- * Indentation is determined by the print options provided to the Output
144
- * component or source file.
145
- */
146
- indent: {
147
- children: Children;
148
- };
149
- /**
150
- * Indent the children of this component if the group specified by `groupId`
151
- * is broken (or not broken if `negate` is passed). The specified group must
152
- * already be printed.
153
- */
154
- indentIfBreak: {
155
- children: Children;
156
- groupId: symbol;
157
- negate?: boolean;
158
- };
159
- /**
160
- * Similar to `group`, but will only place a line break before the last
161
- * segment to exceed the print width. This is useful for formatting
162
- * paragraphs of text where breaks are inserted prior to words which would
163
- * otherwise exceed the print width.
164
- */
165
- fill: {
166
- children: Children;
167
- };
168
- /**
169
- * Force the parent group to break.
170
- */
171
- breakParent: {};
172
- /**
173
- * Print children if the current group or already printed group specified by
174
- * `groupId` is broken. Otherwise, `flatContents` is printed instead.
175
- */
176
- ifBreak: {
177
- children: Children;
178
- flatContents?: Children;
179
- groupId?: symbol;
180
- };
181
- /**
182
- * Print this content at the end of the line. Useful for things like line
183
- * comments.
184
- */
185
- lineSuffix: {
186
- children: Children;
187
- };
188
- /**
189
- * Force any line suffixes to print at this point.
190
- */
191
- lineSuffixBoundary: {};
192
- /**
193
- * Decrease the indentation level of the children of this component.
194
- * Indentation is determined by the print options provided to the Output
195
- * component or source file.
196
- */
197
- dedent: {
198
- children: Children;
199
- };
200
- /**
201
- * Indent the children of this component by either the number of characters
202
- * indicated by the `width` prop, or by the provided string indicated by the
203
- * `string` prop.
204
- */
205
- align: {
206
- children: Children;
207
- width: number;
208
- } | {
209
- children: Children;
210
- string: string;
211
- };
212
- /**
213
- * Mark the current indentation level as "root" for the purposes of literal
214
- * line breaks and `dedentToRoot`.
215
- */
216
- markAsRoot: {
217
- children: Children;
218
- };
219
- /**
220
- * Decrease the indentation level to the root level specified by
221
- * `<markAsRoot />`, or else to no indentation.
222
- */
223
- dedentToRoot: {
224
- children: Children;
225
- };
226
- }
8
+ type IntrinsicElements = CoreIntrinsicElements;
227
9
  type ElementType = string | ComponentDefinition<any>;
228
10
  type Element = Children;
229
11
  interface ElementChildrenAttribute {
@@ -233,56 +15,6 @@ export declare namespace JSX {
233
15
  props: {};
234
16
  }
235
17
  }
236
- export declare function jsx(type: Component<any>, props: Record<string, unknown>): ComponentCreator<Record<string, unknown>>;
18
+ export declare function jsx(type: Component<any>, props: Record<string, unknown>): import("@alloy-js/core").ComponentCreator<Record<string, unknown>>;
237
19
  export declare const jsxs: typeof jsx;
238
- export declare function createComponent<TProps extends Props = Props>(C: Component<TProps>, props: TProps): ComponentCreator<TProps>;
239
- export declare function taggedComponent<TProps = Props>(tag: symbol, component: Component<TProps>): Component<TProps> & Required<Pick<Component<TProps>, "tag">>;
240
- export declare const intrinsicElementKey: unique symbol;
241
- export type IndentIntrinsicElement = IntrinsicElementBase<"indent">;
242
- export type IndentIfBreakIntrinsicElement = IntrinsicElementBase<"indentIfBreak">;
243
- export type BrIntrinsicElement = IntrinsicElementBase<"br">;
244
- export type LineIntrinsicElement = IntrinsicElementBase<"line">;
245
- export type HbrIntrinsicElement = IntrinsicElementBase<"hbr">;
246
- export type HardlineIntrinsicElement = IntrinsicElementBase<"hardline">;
247
- export type SbrIntrinsicElement = IntrinsicElementBase<"sbr">;
248
- export type SoftlineIntrinsicElement = IntrinsicElementBase<"softline">;
249
- export type GroupIntrinsicElement = IntrinsicElementBase<"group">;
250
- export type AlignIntrinsicElement = IntrinsicElementBase<"align">;
251
- export type FillIntrinsicElement = IntrinsicElementBase<"fill">;
252
- export type BreakParentIntrinsicElement = IntrinsicElementBase<"breakParent">;
253
- export type LineSuffixIntrinsicElement = IntrinsicElementBase<"lineSuffix">;
254
- export type LineSuffixBoundaryIntrinsicElement = IntrinsicElementBase<"lineSuffixBoundary">;
255
- export type DedentIntrinsicElement = IntrinsicElementBase<"dedent">;
256
- export type DedentToRootIntrinsicElement = IntrinsicElementBase<"dedentToRoot">;
257
- export type MarkAsRootIntrinsicElement = IntrinsicElementBase<"markAsRoot">;
258
- export type LiterallineIntrinsicElement = IntrinsicElementBase<"literalline">;
259
- export type LbrIntrinsicElement = IntrinsicElementBase<"lbr">;
260
- export type IfBreakIntrinsicElement = IntrinsicElementBase<"ifBreak">;
261
- export type IntrinsicElement = IndentIntrinsicElement | IndentIfBreakIntrinsicElement | BrIntrinsicElement | LineIntrinsicElement | HbrIntrinsicElement | HardlineIntrinsicElement | SbrIntrinsicElement | SoftlineIntrinsicElement | GroupIntrinsicElement | AlignIntrinsicElement | FillIntrinsicElement | BreakParentIntrinsicElement | LineSuffixIntrinsicElement | LineSuffixBoundaryIntrinsicElement | DedentIntrinsicElement | LiterallineIntrinsicElement | LbrIntrinsicElement | DedentToRootIntrinsicElement | MarkAsRootIntrinsicElement | IfBreakIntrinsicElement;
262
- export interface IntrinsicElementBase<TKey extends keyof JSX.IntrinsicElements = keyof JSX.IntrinsicElements> {
263
- [intrinsicElementKey]: true;
264
- name: TKey;
265
- props: JSX.IntrinsicElements[TKey];
266
- }
267
- export declare function createIntrinsic<TKey extends keyof JSX.IntrinsicElements>(name: TKey, props: JSX.IntrinsicElements[TKey]): IntrinsicElementBase<TKey>;
268
- export declare function isIntrinsicElement(type: unknown): type is IntrinsicElement;
269
- export declare function mergeProps<T, U>(source: T, source1: U): T & U;
270
- export declare function mergeProps<T, U, V>(source: T, source1: U, source2: V): T & U & V;
271
- export declare function mergeProps<T, U, V, W>(source: T, source1: U, source2: V, source3: W): T & U & V & W;
272
- export type SplitProps<T, K extends (readonly (keyof T)[])[]> = [
273
- ...{
274
- [P in keyof K]: P extends `${number}` ? Pick<T, Extract<K[P], readonly (keyof T)[]>[number]> : never;
275
- },
276
- {
277
- [P in keyof T as Exclude<P, K[number][number]>]: T[P];
278
- }
279
- ];
280
- export declare function splitProps<T extends Record<any, any>, K extends [readonly (keyof T)[], ...(readonly (keyof T)[])[]]>(props: T, ...keys: K): SplitProps<T, K>;
281
- /**
282
- * Applies default values to a props object. Reactive props are handled properly
283
- * by ensuring that their value is not accessed by `defaultProps`, avoiding any
284
- * unintended side effects.
285
- */
286
- export declare function defaultProps<T extends {}>(props: T, defaults: Partial<T>): T;
287
- export {};
288
20
  //# sourceMappingURL=jsx-runtime.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"jsx-runtime.d.ts","sourceRoot":"","sources":["../../src/jsx-runtime.ts"],"names":[],"mappings":"AAEA,OAAO,EAML,GAAG,EAMJ,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAU/C,MAAM,WAAW,UAAU;IACzB,IAAI,IAAI,CAAC;CACV;AAED,MAAM,WAAW,OAAO;IACtB,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;IAGtB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAGlC,IAAI,CAAC,EAAE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x-runtime.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,QAAQ,EACR,SAAS,EACT,mBAAmB,EACnB,iBAAiB,IAAI,qBAAqB,EAC3C,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,eAAe,EACf,eAAe,EACf,IAAI,EACJ,UAAU,EACV,KAAK,QAAQ,GACd,MAAM,gBAAgB,CAAC;AAExB;;;GAGG;AAEH,yBAAiB,GAAG,CAAC;IACnB,KAAY,iBAAiB,GAAG,qBAAqB,CAAC;IACtD,KAAY,WAAW,GAAG,MAAM,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAAC;IAC5D,KAAY,OAAO,GAAG,QAAQ,CAAC;IAC/B,UAAiB,wBAAwB;QACvC,QAAQ,EAAE,EAAE,CAAC;KACd;IACD,UAAiB,yBAAyB;QACxC,KAAK,EAAE,EAAE,CAAC;KACX;CACF;AAED,wBAAgB,GAAG,CAAC,IAAI,EAAE,SAAS,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,sEAEvE;AAED,eAAO,MAAM,IAAI,YAAM,CAAC"}
@@ -1,187 +1,8 @@
1
1
  // Much of the implementations in this file are inspired by vuerx-js
2
2
  // See: https://github.com/ryansolid/vuerx-jsx.
3
- import { computed, isReactive, pauseTracking, proxyRefs, resetTracking, shallowRef, stop, toRefs, effect as vueEffect } from "@vue/reactivity";
4
- import { scheduler } from "./scheduler.js";
5
- if (globalThis.ALLOY) {
6
- throw new Error("Multiple versions of the JSX Runtime have been loaded. This will likely cause undesirable behavior.");
7
- }
8
- globalThis.ALLOY = true;
9
- let globalContext = null;
10
- export function getContext() {
11
- return globalContext;
12
- }
13
- export function getElementCache() {
14
- return getContext().elementCache;
15
- }
16
- export function root(fn, options) {
17
- const context = {
18
- componentOwner: options?.componentOwner,
19
- disposables: [],
20
- owner: globalContext,
21
- context: {},
22
- elementCache: new Map()
23
- };
24
- globalContext = context;
25
- let ret;
26
- try {
27
- ret = untrack(() => fn(() => {
28
- for (const d of context.disposables) {
29
- d();
30
- }
31
- }));
32
- } finally {
33
- globalContext = globalContext.owner;
34
- }
35
- return ret;
36
- }
37
- export function untrack(fn) {
38
- pauseTracking();
39
- const v = fn();
40
- resetTracking();
41
- return v;
42
- }
43
- export function memo(fn, equal) {
44
- const o = shallowRef();
45
- effect(prev => {
46
- const res = fn();
47
- // eslint-disable-next-line @typescript-eslint/no-unused-expressions
48
- (!equal || prev !== res) && (o.value = res);
49
- return res;
50
- }, undefined);
51
- return () => o.value;
52
- }
53
- export function effect(fn, current) {
54
- const context = {
55
- context: {},
56
- disposables: [],
57
- owner: globalContext,
58
- elementCache: new Map()
59
- };
60
- const cleanupFn = final => {
61
- const d = context.disposables;
62
- context.disposables = [];
63
- for (let k = 0, len = d.length; k < len; k++) d[k]();
64
-
65
- // eslint-disable-next-line @typescript-eslint/no-unused-expressions
66
- final && stop(runner);
67
- };
68
- onCleanup(() => cleanupFn(true));
69
- const runner = vueEffect(() => {
70
- cleanupFn(false);
71
- const oldContext = globalContext;
72
- globalContext = context;
73
- try {
74
- current = fn(current);
75
- } finally {
76
- globalContext = oldContext;
77
- }
78
- }, {
79
- scheduler: scheduler(() => runner)
80
- });
81
-
82
- // allow recursive effects (recursive option does nothing, possible bug)
83
- runner.effect.flags |= 1 << 5;
84
- }
85
3
 
86
- /**
87
- * Register a cleanup function which is called when the current reactive scope
88
- * is recalculated or disposed. This is useful to clean up any side effects
89
- * created in the reactive scope.
90
- *
91
- * @remarks
92
- *
93
- * When onCleanup is called inside a component definition, the provided function
94
- * is called when the component is removed from the tree. This can be useful to
95
- * clean up any side effects created as a result of rendering the component. For
96
- * example, if rendering a component creates a symbol, `onCleanup` can be used
97
- * to remove the symbol when the component is removed from the tree.
98
- *
99
- * When onCleanup is called inside a memo or effect, the function is called when
100
- * the effect is refreshed (e.g. when a memo or computed recalculates) or
101
- * disposed (e.g. it is no longer needed because it is attached to a component
102
- * which was removed).
103
- */
104
- export function onCleanup(fn) {
105
- if (globalContext != null) {
106
- globalContext.disposables.push(fn);
107
- }
108
- }
109
-
110
- /**
111
- * Create a custom reactive context for the children returned by
112
- * the provided context.
113
- */
114
-
115
- const CUSTOM_CONTEXT_SYM = Symbol();
116
- export function createCustomContext(useCallback) {
117
- return {
118
- [CUSTOM_CONTEXT_SYM]: true,
119
- useCustomContext(useCb) {
120
- useCallback(useCb);
121
- }
122
- };
123
- }
124
- export function isCustomContext(child) {
125
- return typeof child === "object" && child !== null && Object.hasOwn(child, CUSTOM_CONTEXT_SYM);
126
- }
127
- // debugging utilities
128
- const renderStack = [];
129
- export function pushStack(component, props) {
130
- if (!shouldDebug()) return;
131
- renderStack.push({
132
- component,
133
- props
134
- });
135
- }
136
- export function popStack() {
137
- if (!shouldDebug()) return;
138
- renderStack.pop();
139
- }
140
- export function printRenderStack() {
141
- if (!shouldDebug()) return;
142
-
143
- // eslint-disable-next-line no-console
144
- console.error("Error rendering:");
145
- for (let i = renderStack.length - 1; i >= 0; i--) {
146
- const {
147
- component,
148
- props
149
- } = renderStack[i];
150
- // eslint-disable-next-line no-console
151
- console.error(` at ${component.name}(${inspectProps(props)})`);
152
- }
153
- }
154
- function inspectProps(props) {
155
- return JSON.stringify(Object.fromEntries(Object.entries(props).map(([key, value]) => {
156
- let safeValue;
157
- switch (typeof value) {
158
- case "string":
159
- case "number":
160
- case "boolean":
161
- safeValue = value;
162
- break;
163
- case "undefined":
164
- safeValue = "undefined";
165
- break;
166
- case "object":
167
- safeValue = value ? "{...}" : null;
168
- break;
169
- case "function":
170
- safeValue = "function";
171
- break;
172
- }
173
- return [key, safeValue];
174
- })));
175
- }
176
-
177
- // These can be removed with a smarter transform that encodes the information we
178
- // need in the compiled JSX output.
179
- export function isComponentCreator(item, component) {
180
- if (!component) {
181
- return typeof item === "function" && item.component;
182
- }
183
- return typeof item === "function" && item.component === component;
184
- }
4
+ import { createComponent } from "@alloy-js/core";
5
+ export { createComponent, createIntrinsic, memo, mergeProps } from "@alloy-js/core";
185
6
 
186
7
  /**
187
8
  * This namespace is predominantly for interop with React tooling in VSCode
@@ -192,137 +13,4 @@ export let JSX;
192
13
  export function jsx(type, props) {
193
14
  return createComponent(type, props);
194
15
  }
195
- export const jsxs = jsx;
196
- export function createComponent(C, props) {
197
- const creator = () => /* */C(props);
198
- creator.props = props;
199
- creator.component = C;
200
- if (C.tag) {
201
- creator.tag = C.tag;
202
- }
203
- return creator;
204
- }
205
- export function taggedComponent(tag, component) {
206
- component.tag = tag;
207
- return component;
208
- }
209
- export const intrinsicElementKey = Symbol();
210
- export function createIntrinsic(name, props) {
211
- return {
212
- [intrinsicElementKey]: true,
213
- name,
214
- props
215
- };
216
- }
217
- export function isIntrinsicElement(type) {
218
- return typeof type === "object" && type !== null && intrinsicElementKey in type;
219
- }
220
- export function mergeProps(...sources) {
221
- const target = {};
222
- for (let i = 0; i < sources.length; i++) {
223
- let source = sources[i];
224
- if (typeof source === "function") source = source();
225
- if (source) {
226
- const descriptors = Object.getOwnPropertyDescriptors(source);
227
- for (const key in descriptors) {
228
- if (key in target) continue;
229
- Object.defineProperty(target, key, {
230
- enumerable: true,
231
- get() {
232
- for (let i = sources.length - 1; i >= 0; i--) {
233
- let s = sources[i];
234
- if (typeof s === "function") s = s();
235
- const v = (s || {})[key];
236
- if (v !== undefined) return v;
237
- }
238
- }
239
- });
240
- }
241
- }
242
- }
243
- return target;
244
- }
245
- export function splitProps(props, ...keys) {
246
- if (isReactive(props)) {
247
- const refs = untrack(() => toRefs(props));
248
- const remainingKeys = new Set(Object.keys(refs));
249
- const result = keys.map(keySet => {
250
- const resultSet = {};
251
- for (const key of keySet) {
252
- resultSet[key] = refs[key];
253
- remainingKeys.delete(key);
254
- }
255
- return proxyRefs(resultSet);
256
- });
257
- const remaining = {};
258
- for (const key of remainingKeys) {
259
- remaining[key] = refs[key];
260
- }
261
- return [...result, proxyRefs(remaining)];
262
- }
263
- const descriptors = Object.getOwnPropertyDescriptors(props);
264
- const remainingKeys = new Set(Object.keys(descriptors));
265
- const result = keys.map(keySet => {
266
- const resultSet = {};
267
- for (const key of keySet) {
268
- if (key in descriptors) {
269
- Object.defineProperty(resultSet, key, descriptors[key]);
270
- remainingKeys.delete(key);
271
- }
272
- }
273
- return resultSet;
274
- });
275
- const remaining = {};
276
- for (const key of remainingKeys) {
277
- Object.defineProperty(remaining, key, descriptors[key]);
278
- }
279
- return [...result, remaining];
280
- }
281
-
282
- /**
283
- * Applies default values to a props object. Reactive props are handled properly
284
- * by ensuring that their value is not accessed by `defaultProps`, avoiding any
285
- * unintended side effects.
286
- */
287
- export function defaultProps(props, defaults) {
288
- if (isReactive(props)) {
289
- const refs = untrack(() => toRefs(props));
290
- for (const key in defaults) {
291
- const originalRef = refs[key];
292
- refs[key] = computed(() => originalRef.value === undefined ? defaults[key] : originalRef.value);
293
- }
294
- return proxyRefs(refs);
295
- }
296
- const withDefaults = {};
297
- const copied = new Set();
298
- for (const key in defaults) {
299
- copied.add(key);
300
- const desc = Object.getOwnPropertyDescriptor(props, key);
301
- if (!desc) {
302
- withDefaults[key] = defaults[key];
303
- continue;
304
- }
305
- if (desc.get) {
306
- const originalGet = desc.get;
307
- desc.get = function () {
308
- const value = originalGet.call(this);
309
- return value === undefined ? defaults[key] : value;
310
- };
311
- Object.defineProperty(withDefaults, key, desc);
312
- } else {
313
- desc.value = desc.value === undefined ? defaults[key] : desc.value;
314
- Object.defineProperty(withDefaults, key, desc);
315
- }
316
- }
317
- const descriptors = Object.getOwnPropertyDescriptors(props);
318
- for (const key in descriptors) {
319
- if (copied.has(key)) {
320
- continue;
321
- }
322
- Object.defineProperty(withDefaults, key, descriptors[key]);
323
- }
324
- return withDefaults;
325
- }
326
- function shouldDebug() {
327
- return typeof process !== "undefined" && !!process.env?.ALLOY_DEBUG;
328
- }
16
+ export const jsxs = jsx;
@@ -0,0 +1,19 @@
1
+ export declare function mergeProps<T, U>(source: T, source1: U): T & U;
2
+ export declare function mergeProps<T, U, V>(source: T, source1: U, source2: V): T & U & V;
3
+ export declare function mergeProps<T, U, V, W>(source: T, source1: U, source2: V, source3: W): T & U & V & W;
4
+ export type SplitProps<T, K extends (readonly (keyof T)[])[]> = [
5
+ ...{
6
+ [P in keyof K]: P extends `${number}` ? Pick<T, Extract<K[P], readonly (keyof T)[]>[number]> : never;
7
+ },
8
+ {
9
+ [P in keyof T as Exclude<P, K[number][number]>]: T[P];
10
+ }
11
+ ];
12
+ export declare function splitProps<T extends Record<any, any>, K extends [readonly (keyof T)[], ...(readonly (keyof T)[])[]]>(props: T, ...keys: K): SplitProps<T, K>;
13
+ /**
14
+ * Applies default values to a props object. Reactive props are handled properly
15
+ * by ensuring that their value is not accessed by `defaultProps`, avoiding any
16
+ * unintended side effects.
17
+ */
18
+ export declare function defaultProps<T extends {}>(props: T, defaults: Partial<T>): T;
19
+ //# sourceMappingURL=props-combinators.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"props-combinators.d.ts","sourceRoot":"","sources":["../../src/props-combinators.ts"],"names":[],"mappings":"AAGA,wBAAgB,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAC/D,wBAAgB,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAChC,MAAM,EAAE,CAAC,EACT,OAAO,EAAE,CAAC,EACV,OAAO,EAAE,CAAC,GACT,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACb,wBAAgB,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EACnC,MAAM,EAAE,CAAC,EACT,OAAO,EAAE,CAAC,EACV,OAAO,EAAE,CAAC,EACV,OAAO,EAAE,CAAC,GACT,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AA2BjB,MAAM,MAAM,UAAU,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE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