@reventlessdev/reventless-gwt 1.0.0-alpha.100

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 (184) hide show
  1. package/CHANGELOG.md +916 -0
  2. package/LICENSE +202 -0
  3. package/bin/reventless-dev.mjs +21 -0
  4. package/package.json +54 -0
  5. package/rescript.json +36 -0
  6. package/src/.gwtignore +10 -0
  7. package/src/Automation_GWT.res +207 -0
  8. package/src/Automation_GWT.res.mjs +160 -0
  9. package/src/Behavior_GWT.res +569 -0
  10. package/src/Behavior_GWT.res.mjs +523 -0
  11. package/src/Bind.res +29 -0
  12. package/src/Bind.res.mjs +22 -0
  13. package/src/BuildClassifier.res +147 -0
  14. package/src/BuildClassifier.res.mjs +136 -0
  15. package/src/Cancellation.res +37 -0
  16. package/src/Cancellation.res.mjs +46 -0
  17. package/src/ChildProcess.res +102 -0
  18. package/src/ChildProcess.res.mjs +107 -0
  19. package/src/Cli.res +905 -0
  20. package/src/Cli.res.mjs +952 -0
  21. package/src/Collector.res +212 -0
  22. package/src/Collector.res.mjs +218 -0
  23. package/src/ComponentMeta.res +77 -0
  24. package/src/ComponentMeta.res.mjs +91 -0
  25. package/src/ComponentScan.res +103 -0
  26. package/src/ComponentScan.res.mjs +105 -0
  27. package/src/Delegate_GWT.res +303 -0
  28. package/src/Delegate_GWT.res.mjs +372 -0
  29. package/src/Diff.res +91 -0
  30. package/src/Diff.res.mjs +98 -0
  31. package/src/Discovery.res +105 -0
  32. package/src/Discovery.res.mjs +99 -0
  33. package/src/DomainDeadCode.res +98 -0
  34. package/src/DomainDeadCode.res.mjs +72 -0
  35. package/src/DomainGraph.res +0 -0
  36. package/src/DomainGraph.res.mjs +0 -0
  37. package/src/EventMapping_GWT.res +29 -0
  38. package/src/EventMapping_GWT.res.mjs +44 -0
  39. package/src/Filter.res +45 -0
  40. package/src/Filter.res.mjs +47 -0
  41. package/src/Flow_GWT.res +664 -0
  42. package/src/Flow_GWT.res.mjs +604 -0
  43. package/src/FormatterHuman.res +109 -0
  44. package/src/FormatterHuman.res.mjs +115 -0
  45. package/src/FormatterJson.res +264 -0
  46. package/src/FormatterJson.res.mjs +322 -0
  47. package/src/FormatterJunit.res +93 -0
  48. package/src/FormatterJunit.res.mjs +90 -0
  49. package/src/FormatterTap.res +100 -0
  50. package/src/FormatterTap.res.mjs +131 -0
  51. package/src/FormatterVsCode.res +352 -0
  52. package/src/FormatterVsCode.res.mjs +546 -0
  53. package/src/Hint.res +119 -0
  54. package/src/Hint.res.mjs +124 -0
  55. package/src/InboundTranslation_GWT.res +83 -0
  56. package/src/InboundTranslation_GWT.res.mjs +94 -0
  57. package/src/JestBind.res +70 -0
  58. package/src/JestBind.res.mjs +63 -0
  59. package/src/Loader.res +24 -0
  60. package/src/Loader.res.mjs +23 -0
  61. package/src/LocalHost.res +119 -0
  62. package/src/LocalHost.res.mjs +99 -0
  63. package/src/Mapping_GWT.res +474 -0
  64. package/src/Mapping_GWT.res.mjs +322 -0
  65. package/src/MismatchRender.res +72 -0
  66. package/src/MismatchRender.res.mjs +127 -0
  67. package/src/MultiSourceProjection_GWT.res +316 -0
  68. package/src/MultiSourceProjection_GWT.res.mjs +354 -0
  69. package/src/OutboundTranslation_GWT.res +238 -0
  70. package/src/OutboundTranslation_GWT.res.mjs +186 -0
  71. package/src/Outcome.res +97 -0
  72. package/src/Outcome.res.mjs +93 -0
  73. package/src/PackageScan.res +80 -0
  74. package/src/PackageScan.res.mjs +81 -0
  75. package/src/PlatformRunner.res +181 -0
  76. package/src/PlatformRunner.res.mjs +176 -0
  77. package/src/PlatformScan.res +142 -0
  78. package/src/PlatformScan.res.mjs +132 -0
  79. package/src/ProcessManager.res +135 -0
  80. package/src/ProcessManager.res.mjs +119 -0
  81. package/src/Projection_GWT.res +312 -0
  82. package/src/Projection_GWT.res.mjs +332 -0
  83. package/src/Query_GWT.res +379 -0
  84. package/src/Query_GWT.res.mjs +367 -0
  85. package/src/RenderRescript.res +125 -0
  86. package/src/RenderRescript.res.mjs +141 -0
  87. package/src/RunWorker.res +24 -0
  88. package/src/RunWorker.res.mjs +16 -0
  89. package/src/RunnerTypes.res +68 -0
  90. package/src/RunnerTypes.res.mjs +60 -0
  91. package/src/SideEffect_GWT.res +157 -0
  92. package/src/SideEffect_GWT.res.mjs +113 -0
  93. package/src/StateChange/ExternalAddCategorySlice.res +25 -0
  94. package/src/StateChange/ExternalAddCategorySlice.res.mjs +34 -0
  95. package/src/StateChange/ExternalAddCategorySlice_Behavior.res +19 -0
  96. package/src/StateChange/ExternalAddCategorySlice_Behavior.res.mjs +46 -0
  97. package/src/StateChange/WithFixtures.res +22 -0
  98. package/src/StateChange/WithFixtures.res.mjs +31 -0
  99. package/src/StateChange/WithFixtures_Behavior.res +17 -0
  100. package/src/StateChange/WithFixtures_Behavior.res.mjs +37 -0
  101. package/src/StateChange/WithManualOpen.res +23 -0
  102. package/src/StateChange/WithManualOpen.res.mjs +31 -0
  103. package/src/StateChange/WithManualOpen_Behavior.res +17 -0
  104. package/src/StateChange/WithManualOpen_Behavior.res.mjs +37 -0
  105. package/src/StubRuntime.res +54 -0
  106. package/src/StubRuntime.res.mjs +55 -0
  107. package/src/TestFixtures.res +16 -0
  108. package/src/TestFixtures.res.mjs +34 -0
  109. package/src/Watch.res +108 -0
  110. package/src/Watch.res.mjs +85 -0
  111. package/src/WatcherProbe.res +56 -0
  112. package/src/WatcherProbe.res.mjs +59 -0
  113. package/src/Worker.res +24 -0
  114. package/src/Worker.res.mjs +9 -0
  115. package/tests/AutomationGwtTest.res +71 -0
  116. package/tests/AutomationGwtTest.res.mjs +189 -0
  117. package/tests/BuildClassifierTest.res +133 -0
  118. package/tests/BuildClassifierTest.res.mjs +176 -0
  119. package/tests/CliRunEntryTest.res +57 -0
  120. package/tests/CliRunEntryTest.res.mjs +65 -0
  121. package/tests/CliWatchScopeTest.res +62 -0
  122. package/tests/CliWatchScopeTest.res.mjs +95 -0
  123. package/tests/ComponentMetaTest.res +67 -0
  124. package/tests/ComponentMetaTest.res.mjs +71 -0
  125. package/tests/DelegateGwtTest.res +487 -0
  126. package/tests/DelegateGwtTest.res.mjs +891 -0
  127. package/tests/DiscoveryTest.res +42 -0
  128. package/tests/DiscoveryTest.res.mjs +43 -0
  129. package/tests/DomainDeadCodeTest.res +119 -0
  130. package/tests/DomainDeadCodeTest.res.mjs +158 -0
  131. package/tests/DomainGraphTest.res +448 -0
  132. package/tests/DomainGraphTest.res.mjs +505 -0
  133. package/tests/FlowAggregateGwtTest.res +171 -0
  134. package/tests/FlowAggregateGwtTest.res.mjs +273 -0
  135. package/tests/FlowCrossPluginGwtTest.res +340 -0
  136. package/tests/FlowCrossPluginGwtTest.res.mjs +798 -0
  137. package/tests/FlowGwtTest.res +222 -0
  138. package/tests/FlowGwtTest.res.mjs +433 -0
  139. package/tests/FormatterGoldenTest.res +125 -0
  140. package/tests/FormatterGoldenTest.res.mjs +162 -0
  141. package/tests/FormatterVsCodeMessageTest.res +41 -0
  142. package/tests/FormatterVsCodeMessageTest.res.mjs +42 -0
  143. package/tests/InboundTranslationGwtTest.res +34 -0
  144. package/tests/InboundTranslationGwtTest.res.mjs +99 -0
  145. package/tests/LocalHostIntegration.res +70 -0
  146. package/tests/LocalHostIntegration.res.mjs +64 -0
  147. package/tests/LocalHostTest.res +71 -0
  148. package/tests/LocalHostTest.res.mjs +63 -0
  149. package/tests/MappingGwtTest.res +350 -0
  150. package/tests/MappingGwtTest.res.mjs +596 -0
  151. package/tests/OutboundTranslationGwtTest.res +59 -0
  152. package/tests/OutboundTranslationGwtTest.res.mjs +139 -0
  153. package/tests/PlatformRunnerTest.res +66 -0
  154. package/tests/PlatformRunnerTest.res.mjs +85 -0
  155. package/tests/PlatformScanTest.res +61 -0
  156. package/tests/PlatformScanTest.res.mjs +56 -0
  157. package/tests/QueryGwtTest.res +161 -0
  158. package/tests/QueryGwtTest.res.mjs +314 -0
  159. package/tests/QueryResolverGwtTest.res +71 -0
  160. package/tests/QueryResolverGwtTest.res.mjs +136 -0
  161. package/tests/RunnerUnitTest.res +219 -0
  162. package/tests/RunnerUnitTest.res.mjs +244 -0
  163. package/tests/SideEffect/FakeOrderNotification.res +23 -0
  164. package/tests/SideEffect/FakeOrderNotification.res.mjs +36 -0
  165. package/tests/SideEffect/FakeOrderNotificationGwtTest.res +35 -0
  166. package/tests/SideEffect/FakeOrderNotificationGwtTest.res.mjs +73 -0
  167. package/tests/SideEffect/MockEmail.res +18 -0
  168. package/tests/SideEffect/MockEmail.res.mjs +47 -0
  169. package/tests/StateChange/ExternalAddCategorySlice_GWT.res +27 -0
  170. package/tests/StateChange/ExternalAddCategorySlice_GWT.res.mjs +70 -0
  171. package/tests/StateChange/WithFixtures_Fixtures.res +9 -0
  172. package/tests/StateChange/WithFixtures_Fixtures.res.mjs +20 -0
  173. package/tests/StateChange/WithFixtures_GWT.res +23 -0
  174. package/tests/StateChange/WithFixtures_GWT.res.mjs +56 -0
  175. package/tests/StateChange/WithManualOpen_Fixtures.res +7 -0
  176. package/tests/StateChange/WithManualOpen_Fixtures.res.mjs +20 -0
  177. package/tests/StateChange/WithManualOpen_GWT.res +17 -0
  178. package/tests/StateChange/WithManualOpen_GWT.res.mjs +56 -0
  179. package/tests/StateChangeSliceGwtTest.res +160 -0
  180. package/tests/StateChangeSliceGwtTest.res.mjs +280 -0
  181. package/tests/StateViewSliceGwtTest.res +64 -0
  182. package/tests/StateViewSliceGwtTest.res.mjs +161 -0
  183. package/tests/WatchDebounceTest.res +106 -0
  184. package/tests/WatchDebounceTest.res.mjs +128 -0
@@ -0,0 +1,546 @@
1
+ // Generated by ReScript, PLEASE EDIT WITH CARE
2
+
3
+ import * as Nodefs from "node:fs";
4
+ import * as Nodepath from "node:path";
5
+ import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
6
+ import * as Primitive_option from "@rescript/runtime/lib/es6/Primitive_option.js";
7
+ import * as Hint$ReventlessGwt from "./Hint.res.mjs";
8
+ import * as Outcome$ReventlessGwt from "./Outcome.res.mjs";
9
+ import * as ComponentMeta$ReventlessGwt from "./ComponentMeta.res.mjs";
10
+ import * as RenderRescript$ReventlessGwt from "./RenderRescript.res.mjs";
11
+ import * as Protocol$ReventlessVscodeProtocol from "@reventlessdev/reventless-vscode-protocol/src/Protocol.res.mjs";
12
+
13
+ function write(s) {
14
+ process.stdout.write(s);
15
+ }
16
+
17
+ function writeLine(s) {
18
+ process.stdout.write(s + "\n");
19
+ }
20
+
21
+ function emit(e) {
22
+ let s = Protocol$ReventlessVscodeProtocol.toJsonLine(e);
23
+ process.stdout.write(s + "\n");
24
+ }
25
+
26
+ function uriOf(path) {
27
+ return "file://" + path;
28
+ }
29
+
30
+ function fileLabelOf(abs) {
31
+ let base = Nodepath.basename(abs);
32
+ if (base.endsWith(".res.mjs")) {
33
+ return base.slice(0, base.length - 8 | 0);
34
+ } else {
35
+ return base;
36
+ }
37
+ }
38
+
39
+ function relativeToCwd(abs) {
40
+ return Nodepath.relative(process.cwd(), abs);
41
+ }
42
+
43
+ let sourceLineCache = {};
44
+
45
+ function mjsToRes(mjsPath) {
46
+ if (mjsPath.endsWith(".res.mjs")) {
47
+ return mjsPath.slice(0, mjsPath.length - 4 | 0);
48
+ }
49
+ }
50
+
51
+ function readLinesCached(resPath) {
52
+ let v = sourceLineCache[resPath];
53
+ if (v !== undefined) {
54
+ return Primitive_option.valFromOption(v);
55
+ }
56
+ let v$1;
57
+ try {
58
+ v$1 = Nodefs.existsSync(resPath) ? Nodefs.readFileSync(resPath, "utf8").split("\n") : undefined;
59
+ } catch (exn) {
60
+ v$1 = undefined;
61
+ }
62
+ sourceLineCache[resPath] = v$1;
63
+ return v$1;
64
+ }
65
+
66
+ function escapeForDouble(s) {
67
+ return s.replaceAll("\\", "\\\\").replaceAll("\"", "\\\"");
68
+ }
69
+
70
+ function escapeForSingle(s) {
71
+ return s.replaceAll("\\", "\\\\").replaceAll("'", "\\'");
72
+ }
73
+
74
+ function locateInSource(mjsPath, label) {
75
+ let resPath = mjsToRes(mjsPath);
76
+ if (resPath === undefined) {
77
+ return;
78
+ }
79
+ let lines = readLinesCached(resPath);
80
+ if (lines === undefined) {
81
+ return;
82
+ }
83
+ let needleD = "\"" + escapeForDouble(label) + "\"";
84
+ let needleS = "'" + escapeForSingle(label) + "'";
85
+ let total = lines.length;
86
+ let _i = 0;
87
+ while (true) {
88
+ let i = _i;
89
+ if (i >= total) {
90
+ return;
91
+ }
92
+ let line = lines[i];
93
+ let idxD = line.indexOf(needleD);
94
+ let idxS = line.indexOf(needleS);
95
+ let col = idxD !== -1 ? (
96
+ idxS !== -1 ? (
97
+ idxD < idxS ? idxD : idxS
98
+ ) + 1 | 0 : idxD + 1 | 0
99
+ ) : (
100
+ idxS !== -1 ? idxS + 1 | 0 : -1
101
+ );
102
+ if (col >= 0) {
103
+ return {
104
+ file: resPath,
105
+ line: i + 1 | 0,
106
+ column: col
107
+ };
108
+ }
109
+ _i = i + 1 | 0;
110
+ continue;
111
+ };
112
+ }
113
+
114
+ function rangeOf(loc) {
115
+ let pos_line = loc.line - 1 | 0;
116
+ let pos_character = loc.column - 1 | 0;
117
+ let pos = {
118
+ line: pos_line,
119
+ character: pos_character
120
+ };
121
+ return {
122
+ start: pos,
123
+ end: pos
124
+ };
125
+ }
126
+
127
+ function locationOf(loc) {
128
+ return {
129
+ uri: "file://" + loc.file,
130
+ range: rangeOf(loc)
131
+ };
132
+ }
133
+
134
+ function hello() {
135
+ let s = Protocol$ReventlessVscodeProtocol.toJsonLine({
136
+ event: "hello",
137
+ protocol: Protocol$ReventlessVscodeProtocol.protocolVersion
138
+ });
139
+ process.stdout.write(s + "\n");
140
+ }
141
+
142
+ function discoverStart() {
143
+ let s = Protocol$ReventlessVscodeProtocol.toJsonLine({
144
+ event: "discoverStart"
145
+ });
146
+ process.stdout.write(s + "\n");
147
+ }
148
+
149
+ function emitDiscoveryItems(files) {
150
+ files.forEach(param => {
151
+ let path = param[0];
152
+ let resPath = mjsToRes(path);
153
+ let fileUri = resPath !== undefined ? (
154
+ Nodefs.existsSync(resPath) ? "file://" + resPath : "file://" + path
155
+ ) : "file://" + path;
156
+ let component = Stdlib_Option.map(ComponentMeta$ReventlessGwt.componentOfTestFile(path), c => ({
157
+ kind: c.kind,
158
+ name: c.name
159
+ }));
160
+ let e_3 = fileLabelOf(path);
161
+ let e_4 = Nodepath.relative(process.cwd(), path);
162
+ let e_5 = fileUri;
163
+ let e = {
164
+ event: "item",
165
+ id: path,
166
+ kind: "File",
167
+ label: e_3,
168
+ description: e_4,
169
+ uri: e_5,
170
+ component: component
171
+ };
172
+ let s = Protocol$ReventlessVscodeProtocol.toJsonLine(e);
173
+ process.stdout.write(s + "\n");
174
+ let seenDescribes = {};
175
+ param[1].forEach(t => {
176
+ let stack = {
177
+ contents: []
178
+ };
179
+ t.describePath.forEach(label => {
180
+ let parent = stack.contents.length === 0 ? path : path + "::" + stack.contents.join("::");
181
+ stack.contents = stack.contents.concat([label]);
182
+ let id = path + "::" + stack.contents.join("::");
183
+ let match = seenDescribes[id];
184
+ if (match !== undefined) {
185
+ return;
186
+ }
187
+ seenDescribes[id] = true;
188
+ let loc = locateInSource(path, label);
189
+ let e_1 = parent;
190
+ let e_5 = Stdlib_Option.map(loc, l => "file://" + l.file);
191
+ let e_6 = Stdlib_Option.map(loc, rangeOf);
192
+ let e = {
193
+ event: "item",
194
+ id: id,
195
+ parent: e_1,
196
+ kind: "Suite",
197
+ label: label,
198
+ uri: e_5,
199
+ range: e_6
200
+ };
201
+ let s = Protocol$ReventlessVscodeProtocol.toJsonLine(e);
202
+ process.stdout.write(s + "\n");
203
+ });
204
+ let parent = t.describePath.length === 0 ? path : path + "::" + t.describePath.join("::");
205
+ let testId = path + "::" + t.id;
206
+ let resLoc = locateInSource(path, t.name);
207
+ let match = t.location;
208
+ let loc = resLoc !== undefined ? resLoc : (
209
+ match !== undefined ? match : undefined
210
+ );
211
+ let e_1 = parent;
212
+ let e_3 = t.name;
213
+ let e_5 = Stdlib_Option.map(loc, l => "file://" + l.file);
214
+ let e_6 = Stdlib_Option.map(loc, rangeOf);
215
+ let e = {
216
+ event: "item",
217
+ id: testId,
218
+ parent: e_1,
219
+ kind: "Test",
220
+ label: e_3,
221
+ uri: e_5,
222
+ range: e_6
223
+ };
224
+ let s = Protocol$ReventlessVscodeProtocol.toJsonLine(e);
225
+ process.stdout.write(s + "\n");
226
+ });
227
+ });
228
+ }
229
+
230
+ function discoverEnd(total) {
231
+ let s = Protocol$ReventlessVscodeProtocol.toJsonLine({
232
+ event: "discoverEnd",
233
+ total: total
234
+ });
235
+ process.stdout.write(s + "\n");
236
+ }
237
+
238
+ function packages(pkgs) {
239
+ let e = {
240
+ event: "packages",
241
+ packages: pkgs.map(p => ({
242
+ name: p.name,
243
+ dir: p.dir,
244
+ build: p.build
245
+ }))
246
+ };
247
+ let s = Protocol$ReventlessVscodeProtocol.toJsonLine(e);
248
+ process.stdout.write(s + "\n");
249
+ }
250
+
251
+ function components(comps) {
252
+ let e = {
253
+ event: "components",
254
+ components: comps.map(c => ({
255
+ kind: c.kind,
256
+ name: c.name,
257
+ dir: c.dir,
258
+ files: c.files
259
+ }))
260
+ };
261
+ let s = Protocol$ReventlessVscodeProtocol.toJsonLine(e);
262
+ process.stdout.write(s + "\n");
263
+ }
264
+
265
+ function deadCode(findings) {
266
+ let e = {
267
+ event: "deadCode",
268
+ findings: findings.map(f => ({
269
+ kind: f.kind,
270
+ plugin: f.pluginName,
271
+ component: f.componentName,
272
+ detail: f.detail
273
+ }))
274
+ };
275
+ let s = Protocol$ReventlessVscodeProtocol.toJsonLine(e);
276
+ process.stdout.write(s + "\n");
277
+ }
278
+
279
+ function graph(g) {
280
+ let s = Protocol$ReventlessVscodeProtocol.toJsonLine({
281
+ event: "graph",
282
+ nodes: g.nodes,
283
+ edges: g.edges
284
+ });
285
+ process.stdout.write(s + "\n");
286
+ }
287
+
288
+ function definitions(entries) {
289
+ let s = Protocol$ReventlessVscodeProtocol.toJsonLine({
290
+ event: "definitions",
291
+ entries: entries
292
+ });
293
+ process.stdout.write(s + "\n");
294
+ }
295
+
296
+ function buildStart(pkg) {
297
+ let s = Protocol$ReventlessVscodeProtocol.toJsonLine({
298
+ event: "buildStart",
299
+ package: pkg
300
+ });
301
+ process.stdout.write(s + "\n");
302
+ }
303
+
304
+ function buildOk(pkg, durationMs) {
305
+ let s = Protocol$ReventlessVscodeProtocol.toJsonLine({
306
+ event: "buildOk",
307
+ package: pkg,
308
+ durationMs: durationMs
309
+ });
310
+ process.stdout.write(s + "\n");
311
+ }
312
+
313
+ function buildFail(pkg, message) {
314
+ let s = Protocol$ReventlessVscodeProtocol.toJsonLine({
315
+ event: "buildFail",
316
+ package: pkg,
317
+ message: message
318
+ });
319
+ process.stdout.write(s + "\n");
320
+ }
321
+
322
+ function buildExternal(pkg) {
323
+ let s = Protocol$ReventlessVscodeProtocol.toJsonLine({
324
+ event: "buildExternal",
325
+ package: pkg
326
+ });
327
+ process.stdout.write(s + "\n");
328
+ }
329
+
330
+ function platformStart($$package, dir, domainPort, platformPort) {
331
+ let s = Protocol$ReventlessVscodeProtocol.toJsonLine({
332
+ event: "platformStart",
333
+ package: $$package,
334
+ dir: dir,
335
+ domainPort: domainPort,
336
+ platformPort: platformPort
337
+ });
338
+ process.stdout.write(s + "\n");
339
+ }
340
+
341
+ function platformReady(domainEndpoint) {
342
+ let s = Protocol$ReventlessVscodeProtocol.toJsonLine({
343
+ event: "platformReady",
344
+ domainEndpoint: domainEndpoint
345
+ });
346
+ process.stdout.write(s + "\n");
347
+ }
348
+
349
+ function domainEvent(payload) {
350
+ let s = JSON.stringify(payload);
351
+ process.stdout.write(s + "\n");
352
+ }
353
+
354
+ function platformLog(line) {
355
+ let s = Protocol$ReventlessVscodeProtocol.toJsonLine({
356
+ event: "platformLog",
357
+ line: line
358
+ });
359
+ process.stdout.write(s + "\n");
360
+ }
361
+
362
+ function platformStop(code) {
363
+ let s = Protocol$ReventlessVscodeProtocol.toJsonLine({
364
+ event: "platformStop",
365
+ code: code
366
+ });
367
+ process.stdout.write(s + "\n");
368
+ }
369
+
370
+ function runStart(total, filter) {
371
+ let s = Protocol$ReventlessVscodeProtocol.toJsonLine({
372
+ event: "runStart",
373
+ total: total,
374
+ filter: filter
375
+ });
376
+ process.stdout.write(s + "\n");
377
+ }
378
+
379
+ function testStart(id) {
380
+ let s = Protocol$ReventlessVscodeProtocol.toJsonLine({
381
+ event: "testStart",
382
+ id: id
383
+ });
384
+ process.stdout.write(s + "\n");
385
+ }
386
+
387
+ function testPass(id, durationMs) {
388
+ let s = Protocol$ReventlessVscodeProtocol.toJsonLine({
389
+ event: "testPass",
390
+ id: id,
391
+ durationMs: durationMs
392
+ });
393
+ process.stdout.write(s + "\n");
394
+ }
395
+
396
+ function testSkip(id, reason) {
397
+ let s = Protocol$ReventlessVscodeProtocol.toJsonLine({
398
+ event: "testSkip",
399
+ id: id,
400
+ reason: reason
401
+ });
402
+ process.stdout.write(s + "\n");
403
+ }
404
+
405
+ function messagePayload(t) {
406
+ let m = t.mismatch;
407
+ if (m === undefined) {
408
+ return {
409
+ message: "failed"
410
+ };
411
+ }
412
+ let hint = Hint$ReventlessGwt.forMismatch(t.slice, m);
413
+ let match;
414
+ switch (m.TAG) {
415
+ case "ErrorMismatch" :
416
+ let actual = m.actual;
417
+ let actStr = actual !== undefined ? "Error(" + RenderRescript$ReventlessGwt.render(undefined, actual) + ")" : "Ok(" + RenderRescript$ReventlessGwt.renderMany(m.actualEvents) + ")";
418
+ match = [
419
+ "Error(" + RenderRescript$ReventlessGwt.render(undefined, m.expected) + ")",
420
+ actStr
421
+ ];
422
+ break;
423
+ case "StateMismatch" :
424
+ match = [
425
+ RenderRescript$ReventlessGwt.renderOption(m.expected),
426
+ RenderRescript$ReventlessGwt.renderOption(m.actual)
427
+ ];
428
+ break;
429
+ case "NoEventExpected" :
430
+ match = [
431
+ "[]",
432
+ RenderRescript$ReventlessGwt.renderMany(m.actual)
433
+ ];
434
+ break;
435
+ case "TodoMismatch" :
436
+ match = [
437
+ Outcome$ReventlessGwt.format(m),
438
+ ""
439
+ ];
440
+ break;
441
+ case "AppendConditionMismatch" :
442
+ match = [
443
+ RenderRescript$ReventlessGwt.render(undefined, m.expected),
444
+ RenderRescript$ReventlessGwt.render(undefined, m.actual)
445
+ ];
446
+ break;
447
+ case "TranslateError" :
448
+ match = [
449
+ m.expected,
450
+ Stdlib_Option.getOr(m.actual, "(none)")
451
+ ];
452
+ break;
453
+ case "Throw" :
454
+ match = [
455
+ "",
456
+ m.error
457
+ ];
458
+ break;
459
+ default:
460
+ match = [
461
+ RenderRescript$ReventlessGwt.renderMany(m.expected),
462
+ RenderRescript$ReventlessGwt.renderMany(m.actual)
463
+ ];
464
+ }
465
+ let location = Stdlib_Option.map(t.location, loc => locationOf(Stdlib_Option.getOr(locateInSource(loc.file, t.name), loc)));
466
+ return {
467
+ message: hint.message,
468
+ kind: Outcome$ReventlessGwt.kindName(m),
469
+ expected: match[0],
470
+ actual: match[1],
471
+ location: location
472
+ };
473
+ }
474
+
475
+ function testFail(t, id) {
476
+ let e_1 = t.durationMs;
477
+ let e_2 = [messagePayload(t)];
478
+ let e = {
479
+ event: "testFail",
480
+ id: id,
481
+ durationMs: e_1,
482
+ messages: e_2
483
+ };
484
+ let s = Protocol$ReventlessVscodeProtocol.toJsonLine(e);
485
+ process.stdout.write(s + "\n");
486
+ }
487
+
488
+ function runEnd(s) {
489
+ let s$1 = Protocol$ReventlessVscodeProtocol.toJsonLine({
490
+ event: "runEnd",
491
+ passed: s.passed,
492
+ failed: s.failed,
493
+ skipped: s.skipped,
494
+ durationMs: s.durationMs
495
+ });
496
+ process.stdout.write(s$1 + "\n");
497
+ }
498
+
499
+ let P;
500
+
501
+ let protocolVersion = Protocol$ReventlessVscodeProtocol.protocolVersion;
502
+
503
+ export {
504
+ P,
505
+ write,
506
+ writeLine,
507
+ emit,
508
+ uriOf,
509
+ fileLabelOf,
510
+ relativeToCwd,
511
+ sourceLineCache,
512
+ mjsToRes,
513
+ readLinesCached,
514
+ escapeForDouble,
515
+ escapeForSingle,
516
+ locateInSource,
517
+ rangeOf,
518
+ locationOf,
519
+ protocolVersion,
520
+ hello,
521
+ discoverStart,
522
+ emitDiscoveryItems,
523
+ discoverEnd,
524
+ packages,
525
+ components,
526
+ deadCode,
527
+ graph,
528
+ definitions,
529
+ buildStart,
530
+ buildOk,
531
+ buildFail,
532
+ buildExternal,
533
+ platformStart,
534
+ platformReady,
535
+ domainEvent,
536
+ platformLog,
537
+ platformStop,
538
+ runStart,
539
+ testStart,
540
+ testPass,
541
+ testSkip,
542
+ messagePayload,
543
+ testFail,
544
+ runEnd,
545
+ }
546
+ /* node:fs Not a pure module */
package/src/Hint.res ADDED
@@ -0,0 +1,119 @@
1
+ // Maps each `Outcome.mismatch` variant to a fix-locus hint.
2
+ //
3
+ // Single source of truth for the `(kind, locus, branch, message)` mapping
4
+ // referenced by the human formatter, the JSON envelope, and the AI loop.
5
+ // See `docs/analysis/given-when-then-specifications.md` §3.2 (locus table)
6
+ // and §3.3 (JSON `hint` field).
7
+ //
8
+ // `locus` is a dotted pointer like "CategoryBehavior.decide" filled in by
9
+ // the DSL at `then*` call time when the slice module name is in scope. If the
10
+ // DSL can't provide it (e.g. Projection has no single "locus" function name
11
+ // the user controls), `locus` falls back to a generic pointer.
12
+
13
+ type t = {
14
+ locus: string,
15
+ branch: option<string>,
16
+ message: string,
17
+ }
18
+
19
+ // The constructor name of an encoded variant, if any: a payload-less variant is
20
+ // a bare string; a variant with a payload is an object carrying "TAG".
21
+ let variantTag = (j: JSON.t): option<string> =>
22
+ switch j {
23
+ | String(s) => Some(s)
24
+ | Object(dict) =>
25
+ switch dict->Dict.get("TAG") {
26
+ | Some(String(s)) => Some(s)
27
+ | _ => None
28
+ }
29
+ | _ => None
30
+ }
31
+
32
+ // Generic fallback mapping, parameterised by the slice module name when the
33
+ // caller can supply one. Branch specificity lives in the DSLs (they can pass
34
+ // a richer hint through `withLocus` below).
35
+ let forMismatch = (~slice="<slice>", m: Outcome.mismatch): t =>
36
+ switch m {
37
+ | EventsMismatch(_) => {
38
+ locus: `${slice}.decide`,
39
+ branch: None,
40
+ message: "decide() returned different events than expected. Check the event payload and count.",
41
+ }
42
+ | ErrorMismatch({actual: None}) => {
43
+ locus: `${slice}.decide`,
44
+ branch: None,
45
+ message: "decide() returned Ok([...]) but the test expected Error.",
46
+ }
47
+ | ErrorMismatch({expected, actual: Some(actual)}) => {
48
+ // Same constructor, different payload is the common case (e.g. a wrong
49
+ // field value) — don't mislabel it as a different variant.
50
+ let message = switch (variantTag(expected), variantTag(actual)) {
51
+ | (Some(e), Some(a)) if e == a =>
52
+ `decide() returned Error(${e}) as expected, but with a different payload.`
53
+ | _ => "decide() returned a different Error variant than expected."
54
+ }
55
+ {
56
+ locus: `${slice}.decide`,
57
+ branch: None,
58
+ message,
59
+ }
60
+ }
61
+ | StateMismatch(_) => {
62
+ locus: `${slice}.evolve`,
63
+ branch: None,
64
+ message: "evolve() produced a different state than expected. Check the fold and missing event branches.",
65
+ }
66
+ | NoEventExpected(_) => {
67
+ locus: `${slice}.decide`,
68
+ branch: None,
69
+ message: "decide() emitted events but the test expected none — possible idempotency miss.",
70
+ }
71
+ | TodoMismatch(_) => {
72
+ locus: `${slice}.collect / ${slice}.resolve`,
73
+ branch: None,
74
+ message: "The automation slice's TODO projection diverged from the expected set.",
75
+ }
76
+ | AppendConditionMismatch(_) => {
77
+ locus: `${slice}.commandSchema`,
78
+ branch: None,
79
+ message: "DCB optimistic-concurrency condition drift — likely a missing `@s.matches(DcbTag.string)` annotation on a command field, or the expected condition documented in the test disagrees with what the runtime would build.",
80
+ }
81
+ | TranslateError(_) => {
82
+ locus: `${slice}.translate`,
83
+ branch: None,
84
+ message: "The translation slice returned a different result than expected.",
85
+ }
86
+ | QueryRowsMismatch(_) => {
87
+ locus: `${slice}.config`,
88
+ branch: None,
89
+ message: "The read-model query returned wrong rows — likely a missing index, sub-id, or resolver.",
90
+ }
91
+ | PublishedActionsMismatch(_) => {
92
+ locus: `${slice}.mapOutgoingEvent / ${slice}.mapIncomingEvent`,
93
+ branch: None,
94
+ message: "The ExtensionPoint mapping / Extension delegate published a different set of events or commands than expected. Check the variant match arms and the one-to-many fan-out.",
95
+ }
96
+ | Throw({error}) => {
97
+ locus: `${slice}`,
98
+ branch: None,
99
+ message: `The slice threw an exception: ${error}`,
100
+ }
101
+ }
102
+
103
+ // Convert to the JSON shape documented in §3.3.
104
+ let toJson = (h: t): JSON.t => {
105
+ let obj = Dict.make()
106
+ obj->Dict.set("locus", JSON.Encode.string(h.locus))
107
+ obj->Dict.set(
108
+ "branch",
109
+ h.branch->Option.mapOr(JSON.Encode.null, JSON.Encode.string),
110
+ )
111
+ obj->Dict.set("message", JSON.Encode.string(h.message))
112
+ JSON.Encode.object(obj)
113
+ }
114
+
115
+ let format = (h: t) =>
116
+ switch h.branch {
117
+ | None => `hint: ${h.message}\n Look at ${h.locus}.`
118
+ | Some(b) => `hint: ${h.message}\n Look at ${h.locus}'s branch ${b}.`
119
+ }