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