@alloy-js/core 0.20.0-dev.3 → 0.20.0-dev.6

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 (137) hide show
  1. package/dist/src/binder.d.ts +62 -38
  2. package/dist/src/binder.d.ts.map +1 -1
  3. package/dist/src/binder.js +214 -173
  4. package/dist/src/components/Declaration.d.ts +2 -2
  5. package/dist/src/components/Declaration.d.ts.map +1 -1
  6. package/dist/src/components/Declaration.js +8 -2
  7. package/dist/src/components/MemberDeclaration.d.ts +2 -2
  8. package/dist/src/components/MemberDeclaration.d.ts.map +1 -1
  9. package/dist/src/components/MemberDeclaration.js +9 -5
  10. package/dist/src/components/MemberScope.d.ts +30 -13
  11. package/dist/src/components/MemberScope.d.ts.map +1 -1
  12. package/dist/src/components/MemberScope.js +37 -15
  13. package/dist/src/components/Output.d.ts.map +1 -1
  14. package/dist/src/components/Output.js +2 -5
  15. package/dist/src/components/ReferenceOrContent.d.ts +1 -1
  16. package/dist/src/components/ReferenceOrContent.d.ts.map +1 -1
  17. package/dist/src/components/Scope.d.ts +5 -5
  18. package/dist/src/components/Scope.d.ts.map +1 -1
  19. package/dist/src/components/Scope.js +9 -5
  20. package/dist/src/context/member-scope.d.ts +7 -8
  21. package/dist/src/context/member-scope.d.ts.map +1 -1
  22. package/dist/src/context/member-scope.js +5 -5
  23. package/dist/src/context/name-policy.d.ts.map +1 -1
  24. package/dist/src/context/name-policy.js +3 -0
  25. package/dist/src/context/scope.d.ts +1 -0
  26. package/dist/src/context/scope.d.ts.map +1 -1
  27. package/dist/src/context/scope.js +7 -0
  28. package/dist/src/inspect.browser.d.ts +5 -0
  29. package/dist/src/inspect.browser.d.ts.map +1 -0
  30. package/dist/src/inspect.browser.js +5 -0
  31. package/dist/src/inspect.d.ts +2 -0
  32. package/dist/src/inspect.d.ts.map +1 -0
  33. package/dist/src/inspect.js +1 -0
  34. package/dist/src/name-policy.d.ts +11 -0
  35. package/dist/src/name-policy.d.ts.map +1 -1
  36. package/dist/src/name-policy.js +3 -0
  37. package/dist/src/reactive-union-set.d.ts.map +1 -1
  38. package/dist/src/reactive-union-set.js +12 -8
  39. package/dist/src/refkey.d.ts +39 -3
  40. package/dist/src/refkey.d.ts.map +1 -1
  41. package/dist/src/refkey.js +52 -8
  42. package/dist/src/symbols/basic-scope.d.ts +14 -0
  43. package/dist/src/symbols/basic-scope.d.ts.map +1 -0
  44. package/dist/src/symbols/basic-scope.js +20 -0
  45. package/dist/src/symbols/basic-symbol.d.ts +19 -0
  46. package/dist/src/symbols/basic-symbol.d.ts.map +1 -0
  47. package/dist/src/symbols/basic-symbol.js +28 -0
  48. package/dist/src/symbols/index.d.ts +3 -1
  49. package/dist/src/symbols/index.d.ts.map +1 -1
  50. package/dist/src/symbols/index.js +3 -1
  51. package/dist/src/symbols/output-scope.d.ts +70 -41
  52. package/dist/src/symbols/output-scope.d.ts.map +1 -1
  53. package/dist/src/symbols/output-scope.js +98 -130
  54. package/dist/src/symbols/output-space.d.ts +25 -0
  55. package/dist/src/symbols/output-space.d.ts.map +1 -0
  56. package/dist/src/symbols/output-space.js +35 -0
  57. package/dist/src/symbols/output-symbol.d.ts +213 -37
  58. package/dist/src/symbols/output-symbol.d.ts.map +1 -1
  59. package/dist/src/symbols/output-symbol.js +323 -203
  60. package/dist/src/symbols/symbol-flow.d.ts +1 -1
  61. package/dist/src/symbols/symbol-flow.d.ts.map +1 -1
  62. package/dist/src/symbols/symbol-flow.js +22 -7
  63. package/dist/src/symbols/symbol-slot.d.ts +27 -9
  64. package/dist/src/symbols/symbol-slot.d.ts.map +1 -1
  65. package/dist/src/symbols/symbol-slot.js +20 -4
  66. package/dist/src/symbols/symbol-table.d.ts +19 -8
  67. package/dist/src/symbols/symbol-table.d.ts.map +1 -1
  68. package/dist/src/symbols/symbol-table.js +65 -16
  69. package/dist/src/tracer.d.ts +15 -3
  70. package/dist/src/tracer.d.ts.map +1 -1
  71. package/dist/src/tracer.js +39 -63
  72. package/dist/src/utils.d.ts +1 -1
  73. package/dist/src/utils.d.ts.map +1 -1
  74. package/dist/src/utils.js +4 -4
  75. package/dist/src/write-output.d.ts +1 -1
  76. package/dist/src/write-output.d.ts.map +1 -1
  77. package/dist/src/write-output.js +31 -37
  78. package/dist/test/components/declaration.test.js +9 -14
  79. package/dist/test/components/reference-or-content.test.js +2 -2
  80. package/dist/test/symbols/output-scope.test.js +33 -198
  81. package/dist/test/symbols/output-symbol.test.js +139 -385
  82. package/dist/test/symbols/resolution.test.js +431 -114
  83. package/dist/test/symbols/symbol-table.test.d.ts +2 -0
  84. package/dist/test/symbols/symbol-table.test.d.ts.map +1 -0
  85. package/dist/test/symbols/symbol-table.test.js +14 -0
  86. package/dist/test/symbols/utils.d.ts +10 -24
  87. package/dist/test/symbols/utils.d.ts.map +1 -1
  88. package/dist/test/symbols/utils.js +23 -45
  89. package/dist/tsconfig.tsbuildinfo +1 -1
  90. package/package.json +4 -2
  91. package/src/binder.ts +348 -273
  92. package/src/components/Declaration.tsx +13 -3
  93. package/src/components/MemberDeclaration.tsx +15 -8
  94. package/src/components/MemberScope.tsx +61 -20
  95. package/src/components/Output.tsx +0 -4
  96. package/src/components/Scope.tsx +16 -9
  97. package/src/context/member-scope.ts +10 -10
  98. package/src/context/name-policy.ts +3 -0
  99. package/src/context/scope.ts +9 -0
  100. package/src/inspect.browser.ts +6 -0
  101. package/src/inspect.ts +1 -0
  102. package/src/name-policy.ts +14 -0
  103. package/src/reactive-union-set.ts +14 -8
  104. package/src/refkey.ts +88 -14
  105. package/src/symbols/basic-scope.ts +23 -0
  106. package/src/symbols/basic-symbol.ts +32 -0
  107. package/src/symbols/index.ts +3 -1
  108. package/src/symbols/output-scope.ts +131 -170
  109. package/src/symbols/output-space.ts +49 -0
  110. package/src/symbols/output-symbol.ts +434 -258
  111. package/src/symbols/symbol-flow.ts +38 -9
  112. package/src/symbols/symbol-slot.tsx +46 -8
  113. package/src/symbols/symbol-table.ts +95 -21
  114. package/src/tracer.ts +53 -83
  115. package/src/utils.tsx +4 -4
  116. package/src/write-output.ts +33 -45
  117. package/temp/api.json +5551 -3066
  118. package/test/components/declaration.test.tsx +6 -19
  119. package/test/components/reference-or-content.test.tsx +2 -2
  120. package/test/symbols/output-scope.test.ts +33 -125
  121. package/test/symbols/output-symbol.test.ts +128 -348
  122. package/test/symbols/resolution.test.ts +530 -117
  123. package/test/symbols/symbol-table.test.ts +15 -0
  124. package/test/symbols/utils.ts +38 -74
  125. package/tsdoc.json +4 -0
  126. package/dist/src/slot.d.ts +0 -15
  127. package/dist/src/slot.d.ts.map +0 -1
  128. package/dist/src/slot.js +0 -50
  129. package/dist/src/symbols/flags.d.ts +0 -70
  130. package/dist/src/symbols/flags.d.ts.map +0 -1
  131. package/dist/src/symbols/flags.js +0 -72
  132. package/dist/test/components/slot.test.d.ts +0 -2
  133. package/dist/test/components/slot.test.d.ts.map +0 -1
  134. package/dist/test/components/slot.test.js +0 -134
  135. package/src/slot.ts +0 -89
  136. package/src/symbols/flags.ts +0 -82
  137. package/test/components/slot.test.tsx +0 -174
@@ -1,174 +0,0 @@
1
- import { it } from "vitest";
2
- import { Output } from "../../src/components/Output.jsx";
3
- import { SourceFile } from "../../src/components/SourceFile.jsx";
4
- import {
5
- Declaration,
6
- Name,
7
- Ref,
8
- refkey,
9
- Scope,
10
- useBinder,
11
- } from "../../src/index.js";
12
- import { render } from "../../src/render.js";
13
- import { defineSlot, rename, replace } from "../../src/slot.js";
14
- import { OutputSymbol } from "../../src/symbols/output-symbol.js";
15
- import "../../testing/extend-expect.js";
16
-
17
- it("works with string keys", () => {
18
- interface FunctionSlotProps extends FunctionComponentProps {
19
- additionalProp: string;
20
- }
21
-
22
- const FunctionSlot = defineSlot<FunctionSlotProps>(
23
- (query: { name: string }) => query.name,
24
- );
25
-
26
- interface FunctionComponentProps {
27
- name: string;
28
- }
29
-
30
- function MyFunctionComponent(props: FunctionComponentProps) {
31
- const FunctionSlotInstance = FunctionSlot.create(
32
- props.name,
33
- { ...props, additionalProp: "hi" },
34
- <>
35
- function {props.name}() {"{"}
36
- console.log("hello world");
37
- {"}"}
38
- </>,
39
- );
40
-
41
- return <FunctionSlotInstance />;
42
- }
43
-
44
- // extension.tsx
45
- replace(FunctionSlot.find({ name: "foo" }), (props: any) => {
46
- return (
47
- <>
48
- // original
49
- {props.original}
50
- </>
51
- );
52
- });
53
-
54
- const _tree = render(
55
- <Output>
56
- <SourceFile path="test.ts" filetype="ts">
57
- <MyFunctionComponent name="foo" />
58
- </SourceFile>
59
- </Output>,
60
- );
61
-
62
- // console.log(tree.contents[0].contents);
63
- });
64
-
65
- it("works with symbols", () => {
66
- interface FunctionSlotProps extends FunctionComponentProps {
67
- additionalProp: string;
68
- }
69
-
70
- const FunctionSlot = defineSlot<FunctionSlotProps>(
71
- (query: { fqn: string }) => {
72
- const binder = useBinder();
73
- return binder!.resolveFQN(query.fqn);
74
- },
75
- );
76
-
77
- interface FunctionComponentProps {
78
- name: string;
79
- }
80
-
81
- function MyFunctionComponent(props: FunctionComponentProps) {
82
- const sym = new OutputSymbol(props.name, {
83
- refkeys: refkey(),
84
- });
85
-
86
- const FunctionSlotInstance = FunctionSlot.create(
87
- sym,
88
- { ...props, additionalProp: "hi" },
89
- <Declaration symbol={sym}>
90
- function <Name />
91
- () {"{"}
92
- console.log("hello world");
93
- {"}"}
94
- </Declaration>,
95
- );
96
-
97
- return <FunctionSlotInstance />;
98
- }
99
-
100
- // extension.tsx
101
- replace(FunctionSlot.find({ fqn: "foo.bar" }), (props: any) => {
102
- return (
103
- <>
104
- // original
105
- {props.original}
106
- </>
107
- );
108
- });
109
-
110
- const _tree = render(
111
- <Output>
112
- <SourceFile path="test.ts" filetype="ts">
113
- <Scope name="foo">
114
- <MyFunctionComponent name="bar" />
115
- </Scope>
116
- </SourceFile>
117
- </Output>,
118
- );
119
-
120
- // console.log(tree.contents[0].contents);
121
- });
122
-
123
- it("can rename", () => {
124
- interface FunctionSlotProps extends FunctionComponentProps {
125
- additionalProp: string;
126
- }
127
-
128
- const FunctionSlot = defineSlot<FunctionSlotProps>(
129
- (query: { fqn: string }) => {
130
- const binder = useBinder()!;
131
- return binder.resolveFQN(query.fqn);
132
- },
133
- );
134
-
135
- interface FunctionComponentProps {
136
- name: string;
137
- }
138
-
139
- function MyFunctionComponent(props: FunctionComponentProps) {
140
- const sym = new OutputSymbol(props.name, {
141
- refkeys: refkey(),
142
- });
143
-
144
- const FunctionSlotInstance = FunctionSlot.create(
145
- sym,
146
- { ...props, additionalProp: "hi" },
147
- <Declaration symbol={sym}>
148
- function <Name />
149
- () {"{"}
150
- console.log("hello world");
151
- {"}"}
152
- </Declaration>,
153
- );
154
-
155
- return <FunctionSlotInstance />;
156
- }
157
-
158
- rename(() => {
159
- const binder = useBinder();
160
- return binder!.resolveFQN("foo.bar") as Ref<OutputSymbol | undefined>;
161
- }, "bazxxx");
162
-
163
- const _tree = render(
164
- <Output>
165
- <SourceFile path="test.ts" filetype="ts">
166
- <Scope name="foo">
167
- <MyFunctionComponent name="bar" />
168
- </Scope>
169
- </SourceFile>
170
- </Output>,
171
- );
172
-
173
- // console.log(tree.contents[0].contents);
174
- });