@alloy-js/core 0.4.0 → 0.6.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 (228) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/babel.config.cjs +4 -1
  3. package/dist/src/binder.d.ts +20 -13
  4. package/dist/src/binder.d.ts.map +1 -1
  5. package/dist/src/binder.js +33 -15
  6. package/dist/src/binder.js.map +1 -1
  7. package/dist/src/code.d.ts +2 -2
  8. package/dist/src/code.d.ts.map +1 -1
  9. package/dist/src/code.js +4 -4
  10. package/dist/src/code.js.map +1 -1
  11. package/dist/src/components/Block.d.ts +25 -0
  12. package/dist/src/components/Block.d.ts.map +1 -0
  13. package/dist/src/components/Block.js +25 -0
  14. package/dist/src/components/Block.js.map +1 -0
  15. package/dist/src/components/Declaration.d.ts +1 -1
  16. package/dist/src/components/Declaration.d.ts.map +1 -1
  17. package/dist/src/components/Declaration.js +4 -0
  18. package/dist/src/components/Declaration.js.map +1 -1
  19. package/dist/src/components/For.d.ts +44 -0
  20. package/dist/src/components/For.d.ts.map +1 -0
  21. package/dist/src/components/For.js +41 -0
  22. package/dist/src/components/For.js.map +1 -0
  23. package/dist/src/components/Indent.d.ts +6 -10
  24. package/dist/src/components/Indent.d.ts.map +1 -1
  25. package/dist/src/components/Indent.js +7 -18
  26. package/dist/src/components/Indent.js.map +1 -1
  27. package/dist/src/components/List.d.ts +38 -0
  28. package/dist/src/components/List.d.ts.map +1 -0
  29. package/dist/src/components/List.js +40 -0
  30. package/dist/src/components/List.js.map +1 -0
  31. package/dist/src/components/MemberDeclaration.d.ts +1 -1
  32. package/dist/src/components/MemberDeclaration.d.ts.map +1 -1
  33. package/dist/src/components/MemberDeclaration.js.map +1 -1
  34. package/dist/src/components/MemberName.d.ts +1 -1
  35. package/dist/src/components/MemberName.d.ts.map +1 -1
  36. package/dist/src/components/MemberName.js +1 -1
  37. package/dist/src/components/MemberName.js.map +1 -1
  38. package/dist/src/components/MemberScope.d.ts +1 -1
  39. package/dist/src/components/MemberScope.d.ts.map +1 -1
  40. package/dist/src/components/MemberScope.js.map +1 -1
  41. package/dist/src/components/Name.d.ts +1 -1
  42. package/dist/src/components/Name.d.ts.map +1 -1
  43. package/dist/src/components/Name.js +1 -1
  44. package/dist/src/components/Name.js.map +1 -1
  45. package/dist/src/components/Output.d.ts +3 -2
  46. package/dist/src/components/Output.d.ts.map +1 -1
  47. package/dist/src/components/Output.js +12 -2
  48. package/dist/src/components/Output.js.map +1 -1
  49. package/dist/src/components/Scope.d.ts +1 -1
  50. package/dist/src/components/Scope.d.ts.map +1 -1
  51. package/dist/src/components/Scope.js.map +1 -1
  52. package/dist/src/components/Show.d.ts +8 -0
  53. package/dist/src/components/Show.d.ts.map +1 -0
  54. package/dist/src/components/Show.js +4 -0
  55. package/dist/src/components/Show.js.map +1 -0
  56. package/dist/src/components/SourceDirectory.d.ts +2 -2
  57. package/dist/src/components/SourceDirectory.d.ts.map +1 -1
  58. package/dist/src/components/SourceDirectory.js +1 -0
  59. package/dist/src/components/SourceDirectory.js.map +1 -1
  60. package/dist/src/components/SourceFile.d.ts +4 -8
  61. package/dist/src/components/SourceFile.d.ts.map +1 -1
  62. package/dist/src/components/SourceFile.js +6 -13
  63. package/dist/src/components/SourceFile.js.map +1 -1
  64. package/dist/src/components/StatementList.d.ts +9 -0
  65. package/dist/src/components/StatementList.d.ts.map +1 -0
  66. package/dist/src/components/StatementList.js +17 -0
  67. package/dist/src/components/StatementList.js.map +1 -0
  68. package/dist/src/components/Switch.d.ts +41 -0
  69. package/dist/src/components/Switch.d.ts.map +1 -0
  70. package/dist/src/components/Switch.js +41 -0
  71. package/dist/src/components/Switch.js.map +1 -0
  72. package/dist/src/components/Wrap.d.ts +20 -0
  73. package/dist/src/components/Wrap.d.ts.map +1 -0
  74. package/dist/src/components/Wrap.js +15 -0
  75. package/dist/src/components/Wrap.js.map +1 -0
  76. package/dist/src/components/index.d.ts +8 -1
  77. package/dist/src/components/index.d.ts.map +1 -1
  78. package/dist/src/components/index.js +7 -0
  79. package/dist/src/components/index.js.map +1 -1
  80. package/dist/src/components/stc/index.d.ts +89 -18
  81. package/dist/src/components/stc/index.d.ts.map +1 -1
  82. package/dist/src/components/stc/index.js +17 -1
  83. package/dist/src/components/stc/index.js.map +1 -1
  84. package/dist/src/context/index.d.ts +0 -1
  85. package/dist/src/context/index.d.ts.map +1 -1
  86. package/dist/src/context/index.js +0 -1
  87. package/dist/src/context/index.js.map +1 -1
  88. package/dist/src/context/member-declaration.d.ts +1 -0
  89. package/dist/src/context/member-declaration.d.ts.map +1 -1
  90. package/dist/src/context/member-declaration.js +4 -1
  91. package/dist/src/context/member-declaration.js.map +1 -1
  92. package/dist/src/context.d.ts.map +1 -1
  93. package/dist/src/context.js +3 -3
  94. package/dist/src/context.js.map +1 -1
  95. package/dist/src/index.browser.d.ts +3 -0
  96. package/dist/src/index.browser.d.ts.map +1 -0
  97. package/dist/src/index.browser.js +3 -0
  98. package/dist/src/index.browser.js.map +1 -0
  99. package/dist/src/index.d.ts +2 -0
  100. package/dist/src/index.d.ts.map +1 -1
  101. package/dist/src/index.js +2 -0
  102. package/dist/src/index.js.map +1 -1
  103. package/dist/src/jsx-runtime.d.ts +151 -7
  104. package/dist/src/jsx-runtime.d.ts.map +1 -1
  105. package/dist/src/jsx-runtime.js +113 -12
  106. package/dist/src/jsx-runtime.js.map +1 -1
  107. package/dist/src/render.d.ts +107 -132
  108. package/dist/src/render.d.ts.map +1 -1
  109. package/dist/src/render.js +272 -178
  110. package/dist/src/render.js.map +1 -1
  111. package/dist/src/stc.d.ts +14 -0
  112. package/dist/src/stc.d.ts.map +1 -0
  113. package/dist/src/stc.js +52 -0
  114. package/dist/src/stc.js.map +1 -0
  115. package/dist/src/tap.d.ts +19 -0
  116. package/dist/src/tap.d.ts.map +1 -0
  117. package/dist/src/tap.js +39 -0
  118. package/dist/src/tap.js.map +1 -0
  119. package/dist/src/utils.d.ts +22 -15
  120. package/dist/src/utils.d.ts.map +1 -1
  121. package/dist/src/utils.js +95 -59
  122. package/dist/src/utils.js.map +1 -1
  123. package/dist/test/browser-build.test.d.ts +2 -0
  124. package/dist/test/browser-build.test.d.ts.map +1 -0
  125. package/dist/test/components/block.test.d.ts +2 -0
  126. package/dist/test/components/block.test.d.ts.map +1 -0
  127. package/dist/test/components/declaration.test.d.ts +2 -0
  128. package/dist/test/components/declaration.test.d.ts.map +1 -0
  129. package/dist/test/components/list.test.d.ts +2 -0
  130. package/dist/test/components/list.test.d.ts.map +1 -0
  131. package/dist/test/components/wrap.test.d.ts +2 -0
  132. package/dist/test/components/wrap.test.d.ts.map +1 -0
  133. package/dist/test/control-flow/for.test.d.ts +2 -0
  134. package/dist/test/control-flow/for.test.d.ts.map +1 -0
  135. package/dist/test/control-flow/match.test.d.ts +2 -0
  136. package/dist/test/control-flow/match.test.d.ts.map +1 -0
  137. package/dist/test/control-flow/show.test.d.ts +2 -0
  138. package/dist/test/control-flow/show.test.d.ts.map +1 -0
  139. package/dist/test/reactivity/cleanup.test.d.ts +2 -0
  140. package/dist/test/reactivity/cleanup.test.d.ts.map +1 -0
  141. package/dist/test/reactivity/memo.test.d.ts +2 -0
  142. package/dist/test/reactivity/memo.test.d.ts.map +1 -0
  143. package/dist/test/reactivity/untrack.test.d.ts +2 -0
  144. package/dist/test/reactivity/untrack.test.d.ts.map +1 -0
  145. package/dist/test/rendering/formatting.test.d.ts +2 -0
  146. package/dist/test/rendering/formatting.test.d.ts.map +1 -0
  147. package/dist/test/rendering/memoization.test.d.ts +2 -0
  148. package/dist/test/rendering/memoization.test.d.ts.map +1 -0
  149. package/dist/test/split-props.test.d.ts +2 -0
  150. package/dist/test/split-props.test.d.ts.map +1 -0
  151. package/dist/test/stc.test.d.ts.map +1 -1
  152. package/dist/test/utils.test.d.ts.map +1 -1
  153. package/dist/testing/extend-expect.js +4 -4
  154. package/dist/testing/extend-expect.js.map +1 -1
  155. package/dist/testing/render.d.ts +2 -3
  156. package/dist/testing/render.d.ts.map +1 -1
  157. package/dist/testing/render.js +2 -4
  158. package/dist/testing/render.js.map +1 -1
  159. package/dist/tsconfig.tsbuildinfo +1 -1
  160. package/package.json +8 -9
  161. package/src/binder.ts +60 -50
  162. package/src/code.ts +17 -12
  163. package/src/components/Block.tsx +44 -0
  164. package/src/components/Declaration.tsx +10 -4
  165. package/src/components/For.tsx +81 -0
  166. package/src/components/Indent.tsx +20 -27
  167. package/src/components/List.tsx +94 -0
  168. package/src/components/MemberDeclaration.tsx +9 -6
  169. package/src/components/MemberScope.tsx +4 -2
  170. package/src/components/Output.tsx +27 -14
  171. package/src/components/Scope.tsx +4 -2
  172. package/src/components/Show.tsx +11 -0
  173. package/src/components/SourceDirectory.tsx +6 -2
  174. package/src/components/SourceFile.tsx +13 -17
  175. package/src/components/StatementList.tsx +16 -0
  176. package/src/components/Switch.tsx +62 -0
  177. package/src/components/Wrap.tsx +29 -0
  178. package/src/components/index.tsx +8 -1
  179. package/src/components/stc/index.ts +18 -1
  180. package/src/context/index.ts +0 -1
  181. package/src/context/member-declaration.ts +9 -1
  182. package/src/context.ts +2 -3
  183. package/src/index.browser.ts +2 -0
  184. package/src/index.ts +2 -0
  185. package/src/jsx-runtime.ts +265 -23
  186. package/src/render.ts +382 -200
  187. package/src/stc.ts +95 -0
  188. package/src/tap.ts +69 -0
  189. package/src/utils.ts +162 -95
  190. package/temp/api.json +8042 -1886
  191. package/test/browser-build.test.ts +91 -0
  192. package/test/children.test.tsx +8 -10
  193. package/test/components/block.test.tsx +48 -0
  194. package/test/components/declaration.test.tsx +37 -0
  195. package/test/components/list.test.tsx +91 -0
  196. package/test/components/slot.test.tsx +31 -25
  197. package/test/components/source-file.test.tsx +11 -31
  198. package/test/components/wrap.test.tsx +42 -0
  199. package/test/control-flow/for.test.tsx +194 -0
  200. package/test/control-flow/match.test.tsx +49 -0
  201. package/test/control-flow/show.test.tsx +25 -0
  202. package/test/name-policy.test.tsx +5 -5
  203. package/test/reactivity/cleanup.test.tsx +91 -0
  204. package/test/reactivity/memo.test.tsx +17 -0
  205. package/test/reactivity/ref-rendering.test.tsx +3 -8
  206. package/test/reactivity/test.test.tsx +7 -6
  207. package/test/reactivity/untrack.test.ts +33 -0
  208. package/test/rendering/basic.test.tsx +25 -47
  209. package/test/rendering/code.test.tsx +3 -3
  210. package/test/rendering/formatting.test.tsx +487 -0
  211. package/test/rendering/indent.test.tsx +42 -529
  212. package/test/rendering/memoization.test.tsx +30 -0
  213. package/test/split-props.test.ts +87 -0
  214. package/test/stc.test.tsx +29 -8
  215. package/test/symbols.test.ts +132 -3
  216. package/test/utils.test.tsx +129 -20
  217. package/testing/extend-expect.ts +14 -4
  218. package/testing/render.ts +2 -4
  219. package/testing/vitest.d.ts +6 -1
  220. package/vitest.config.ts +1 -1
  221. package/dist/src/context/indent.d.ts +0 -5
  222. package/dist/src/context/indent.d.ts.map +0 -1
  223. package/dist/src/context/indent.js +0 -8
  224. package/dist/src/context/indent.js.map +0 -1
  225. package/dist/test/rendering/linebreaks.test.d.ts +0 -2
  226. package/dist/test/rendering/linebreaks.test.d.ts.map +0 -1
  227. package/src/context/indent.ts +0 -17
  228. package/test/rendering/linebreaks.test.tsx +0 -72
@@ -5,14 +5,16 @@ import {
5
5
  } from "../binder.js";
6
6
  import { BinderContext } from "../context/binder.js";
7
7
  import { NamePolicyContext } from "../context/name-policy.js";
8
- import { Children } from "../jsx-runtime.js";
8
+ import { Children, getContext } from "../jsx-runtime.js";
9
9
  import { NamePolicy } from "../name-policy.js";
10
+ import { PrintTreeOptions } from "../render.js";
11
+ import { extensionEffects } from "../slot.js";
10
12
  import { SourceDirectory } from "./SourceDirectory.js";
13
+
11
14
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
12
- import { extensionEffects } from "../slot.js";
13
15
  import { SourceFile } from "./SourceFile.js";
14
16
 
15
- export interface OutputProps {
17
+ export interface OutputProps extends PrintTreeOptions {
16
18
  children?: Children;
17
19
  /**
18
20
  * External libraries whose symbols should be available for reference.
@@ -47,10 +49,18 @@ export function Output(props: OutputProps) {
47
49
  const binder = createOutputBinder({
48
50
  nameConflictResolver: props.nameConflictResolver,
49
51
  });
50
- const dir =
51
- <SourceDirectory path={basePath}>
52
- {props.children}
53
- </SourceDirectory>;
52
+
53
+ const nodeContext = getContext()!;
54
+ nodeContext.meta ??= {};
55
+ nodeContext.meta.printOptions = {
56
+ printWidth: props.printWidth,
57
+ tabWidth: props.tabWidth,
58
+ useTabs: props.useTabs,
59
+ };
60
+
61
+ const dir = (
62
+ <SourceDirectory path={basePath}>{props.children}</SourceDirectory>
63
+ );
54
64
 
55
65
  if (props.externals) {
56
66
  for (const global of props.externals) {
@@ -58,13 +68,16 @@ export function Output(props: OutputProps) {
58
68
  }
59
69
  }
60
70
 
61
- return <BinderContext.Provider value={binder}>
62
- {() => { extensionEffects.forEach(e => e())}}{
63
- props.namePolicy ?
71
+ return (
72
+ <BinderContext.Provider value={binder}>
73
+ {() => {
74
+ extensionEffects.forEach((e) => e());
75
+ }}
76
+ {props.namePolicy ?
64
77
  <NamePolicyContext.Provider value={props.namePolicy}>
65
78
  {dir}
66
- </NamePolicyContext.Provider> :
67
- dir
68
- }
69
- </BinderContext.Provider>;
79
+ </NamePolicyContext.Provider>
80
+ : dir}
81
+ </BinderContext.Provider>
82
+ );
70
83
  }
@@ -21,7 +21,9 @@ export function Scope(props: ScopeProps) {
21
21
  scope = binder.createScope({ kind, name: props.name! });
22
22
  }
23
23
 
24
- return <ScopeContext.Provider value={scope}>
24
+ return (
25
+ <ScopeContext.Provider value={scope}>
25
26
  {props.children}
26
- </ScopeContext.Provider>;
27
+ </ScopeContext.Provider>
28
+ );
27
29
  }
@@ -0,0 +1,11 @@
1
+ import { Children } from "@alloy-js/core/jsx-runtime";
2
+
3
+ export interface ShowProps {
4
+ children: Children;
5
+ fallback?: Children;
6
+ when: boolean | undefined | null;
7
+ }
8
+
9
+ export function Show(props: ShowProps) {
10
+ return () => (props.when ? props.children : props.fallback);
11
+ }
@@ -6,7 +6,7 @@ import { Children, getContext } from "../jsx-runtime.js";
6
6
 
7
7
  export interface SourceDirectoryProps {
8
8
  path: string;
9
- children?: Children[];
9
+ children?: Children;
10
10
  }
11
11
 
12
12
  export function SourceDirectory(props: SourceDirectoryProps) {
@@ -20,7 +20,11 @@ export function SourceDirectory(props: SourceDirectoryProps) {
20
20
  nodeContext.meta.directory = {
21
21
  path: sdPath,
22
22
  };
23
- return <SourceDirectoryContext.Provider value={context}>{props.children}</SourceDirectoryContext.Provider>;
23
+ return (
24
+ <SourceDirectoryContext.Provider value={context}>
25
+ {props.children}
26
+ </SourceDirectoryContext.Provider>
27
+ );
24
28
  }
25
29
 
26
30
  function createSourceDirectoryContext(
@@ -1,12 +1,12 @@
1
1
  import { join } from "pathe";
2
2
  import { useContext } from "../context.js";
3
- import { IndentContext } from "../context/indent.js";
4
3
  import { SourceDirectoryContext } from "../context/source-directory.js";
5
4
  import { SourceFileContext } from "../context/source-file.js";
6
5
  import { Children, ComponentDefinition, getContext } from "../jsx-runtime.js";
7
6
  import { Refkey } from "../refkey.js";
7
+ import { PrintTreeOptions } from "../render.js";
8
8
 
9
- export interface SourceFileProps {
9
+ export interface SourceFileProps extends PrintTreeOptions {
10
10
  /**
11
11
  * The path of this file relative to its parent directory
12
12
  */
@@ -17,19 +17,13 @@ export interface SourceFileProps {
17
17
  */
18
18
  filetype: string;
19
19
 
20
- children?: Children[];
20
+ children?: Children;
21
21
 
22
22
  /**
23
23
  * The component to use to render refkeys references within the file's
24
24
  * contents.
25
25
  */
26
26
  reference?: ComponentDefinition<{ refkey: Refkey }>;
27
-
28
- /**
29
- * A string representing one indent level, used when reindenting contents of
30
- * this file.
31
- */
32
- indent?: string;
33
27
  }
34
28
 
35
29
  export function SourceFile(props: SourceFileProps) {
@@ -43,13 +37,15 @@ export function SourceFile(props: SourceFileProps) {
43
37
  const nodeContext = getContext()!;
44
38
  nodeContext.meta ??= {};
45
39
  nodeContext.meta.sourceFile = context;
40
+ nodeContext.meta.printOptions = {
41
+ printWidth: props.printWidth,
42
+ tabWidth: props.tabWidth,
43
+ useTabs: props.useTabs,
44
+ };
46
45
 
47
- return <SourceFileContext.Provider value={context}>
48
- { props.indent
49
- ? <IndentContext.Provider value={{ level: 0, indent: props.indent, indentString: "" }}>
50
- {props.children}
51
- </IndentContext.Provider>
52
- : props.children
53
- }
54
- </SourceFileContext.Provider>;
46
+ return (
47
+ <SourceFileContext.Provider value={context}>
48
+ {props.children}
49
+ </SourceFileContext.Provider>
50
+ );
55
51
  }
@@ -0,0 +1,16 @@
1
+ import { Children, List } from "@alloy-js/core";
2
+
3
+ export interface StatementListProps {
4
+ children: Children;
5
+ }
6
+
7
+ /**
8
+ * Join child elements with semicolons and hardlines.
9
+ */
10
+ export function StatementList(props: StatementListProps) {
11
+ return (
12
+ <List semicolon hardline enderPunctuation>
13
+ {props.children}
14
+ </List>
15
+ );
16
+ }
@@ -0,0 +1,62 @@
1
+ import { Children, memo, taggedComponent } from "@alloy-js/core/jsx-runtime";
2
+ import { childrenArray, findKeyedChildren } from "../utils.js";
3
+
4
+ export interface SwitchProps {
5
+ children: Children;
6
+ }
7
+
8
+ /**
9
+ * Conditionally render blocks of content based on the `when` prop of nested
10
+ * {@link Match} components.
11
+ *
12
+ * @example
13
+ *
14
+ * ```tsx
15
+ * <Switch>
16
+ * <Match when={someCondition}>
17
+ * <div>Condition met!</div>
18
+ * </Match>
19
+ * <Match else>
20
+ * <div>Condition not met!</div>
21
+ * </Match>
22
+ * </Switch>
23
+ * ```
24
+ */
25
+ export function Switch(props: SwitchProps) {
26
+ const children = childrenArray(() => props.children);
27
+ const matches = findKeyedChildren(children, matchTag);
28
+
29
+ return memo(() => {
30
+ for (const match of matches) {
31
+ if (match.props.when || match.props.else) {
32
+ return match.props.children;
33
+ }
34
+ }
35
+
36
+ return undefined;
37
+ });
38
+ }
39
+
40
+ export interface MatchProps {
41
+ /**
42
+ * Condition under which the children of this element will be rendered.
43
+ */
44
+ when?: boolean;
45
+
46
+ /**
47
+ * If no `when` is matched, the children of this element will be rendered.
48
+ * The `else` match must be placed last.
49
+ */
50
+ else?: boolean;
51
+ children: Children;
52
+ }
53
+
54
+ export const matchTag = Symbol();
55
+
56
+ /**
57
+ * The Match component is used inside of a {@link Switch} component to
58
+ * define conditionally rendered blocks of content.
59
+ */
60
+ export const Match = taggedComponent(matchTag, (props: MatchProps) => {
61
+ return () => (props.when ? props.children : undefined);
62
+ });
@@ -0,0 +1,29 @@
1
+ import { Children, ComponentDefinition } from "@alloy-js/core/jsx-runtime";
2
+
3
+ export interface WrapProps<TProps> {
4
+ /**
5
+ * When true, the children will be wrapped with the provided component.
6
+ * Otherwise, the children will be rendered as is.
7
+ */
8
+ when: boolean;
9
+
10
+ /** Children to be wrapped. */
11
+ children: Children;
12
+
13
+ /** Component to be used for wrapping. */
14
+ with: ComponentDefinition<TProps>;
15
+
16
+ /** Props to pass to the wrapper component. */
17
+ props?: Omit<TProps, "children">;
18
+ }
19
+
20
+ /**
21
+ * Conditionally wrap the children of this component with the component given to
22
+ * `with` and passing `props` to it.
23
+ */
24
+ export function Wrap<TProps>(props: WrapProps<TProps>) {
25
+ const Wrapper = props.with as any;
26
+ return props.when ?
27
+ <Wrapper {...(props.props ?? {})}>{props.children}</Wrapper>
28
+ : props.children;
29
+ }
@@ -1,10 +1,17 @@
1
+ export * from "./Block.js";
1
2
  export * from "./Declaration.js";
2
- export * from "./Indent.js";
3
+ export * from "./For.js";
4
+ export * from "./Indent.jsx";
5
+ export * from "./List.jsx";
3
6
  export * from "./MemberDeclaration.jsx";
4
7
  export * from "./MemberName.jsx";
5
8
  export * from "./MemberScope.jsx";
6
9
  export * from "./Name.jsx";
7
10
  export * from "./Output.js";
8
11
  export * from "./Scope.js";
12
+ export * from "./Show.jsx";
9
13
  export * from "./SourceDirectory.js";
10
14
  export * from "./SourceFile.js";
15
+ export * from "./StatementList.jsx";
16
+ export * from "./Switch.jsx";
17
+ export * from "./Wrap.jsx";
@@ -1,9 +1,26 @@
1
- import { stc } from "../../utils.js";
1
+ import { stc, sti } from "../../stc.js";
2
2
  import * as base from "../index.js";
3
3
 
4
+ export const Block = stc(base.Block);
4
5
  export const Declaration = stc(base.Declaration);
6
+ export const For = stc(base.For);
5
7
  export const Indent = stc(base.Indent);
8
+ export const List = stc(base.List);
9
+ export const MemberDeclaration = stc(base.MemberDeclaration);
10
+ export const MemberName = stc(base.MemberName);
11
+ export const MemberScope = stc(base.MemberScope);
12
+ export const Name = stc(base.Name);
6
13
  export const Output = stc(base.Output);
7
14
  export const Scope = stc(base.Scope);
15
+ export const Show = stc(base.Show);
16
+ export const StatementList = stc(base.StatementList);
8
17
  export const SourceDirectory = stc(base.SourceDirectory);
9
18
  export const SourceFile = stc(base.SourceFile);
19
+ export const Switch = stc(base.Switch);
20
+ export const Wrap = stc(base.Wrap);
21
+
22
+ export const indent = sti("indent");
23
+ export const hbr = sti("hbr");
24
+ export const sbr = sti("sbr");
25
+ export const lbr = sti("lbr");
26
+ export const br = sti("br");
@@ -1,7 +1,6 @@
1
1
  export * from "./assignment.js";
2
2
  export * from "./binder.js";
3
3
  export * from "./declaration.js";
4
- export * from "./indent.js";
5
4
  export * from "./member-declaration.js";
6
5
  export * from "./member-scope.js";
7
6
  export * from "./name-policy.js";
@@ -1,5 +1,9 @@
1
1
  import { OutputSymbol } from "../binder.js";
2
- import { ComponentContext, createNamedContext } from "../context.js";
2
+ import {
3
+ ComponentContext,
4
+ createNamedContext,
5
+ useContext,
6
+ } from "../context.js";
3
7
 
4
8
  /**
5
9
  * Provides the symbol for the member currently being declared.
@@ -8,3 +12,7 @@ import { ComponentContext, createNamedContext } from "../context.js";
8
12
  */
9
13
  export const MemberDeclarationContext: ComponentContext<OutputSymbol> =
10
14
  createNamedContext("MemberDeclaration");
15
+
16
+ export function useMemberDeclaration() {
17
+ return useContext(MemberDeclarationContext);
18
+ }
package/src/context.ts CHANGED
@@ -4,7 +4,6 @@ import {
4
4
  ComponentDefinition,
5
5
  effect,
6
6
  getContext,
7
- untrack,
8
7
  } from "./jsx-runtime.js";
9
8
 
10
9
  export interface ComponentContext<T> {
@@ -49,8 +48,8 @@ export function createContext<T = unknown>(
49
48
  const rendered = shallowRef();
50
49
  effect(() => {
51
50
  context!.context![id] = props.value;
52
- rendered.value = untrack(() => props.children);
53
- });
51
+ rendered.value = () => props.children;
52
+ }, undefined);
54
53
 
55
54
  return rendered.value;
56
55
  },
@@ -0,0 +1,2 @@
1
+ export * from "./index.js"; // Re-export everything
2
+ export { writeOutput } from "./write-output.browser.js"; // Override writeOutput for browsers
package/src/index.ts CHANGED
@@ -17,6 +17,8 @@ export * from "./jsx-runtime.js";
17
17
  export * from "./name-policy.js";
18
18
  export * from "./refkey.js";
19
19
  export * from "./render.js";
20
+ export * from "./stc.js";
21
+ export * from "./tap.js";
20
22
  export * from "./utils.js";
21
23
  export * from "./write-output.js";
22
24
  import "./debug.js";