@reventlessdev/reventless-gwt 1.0.0-alpha.74

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 (172) hide show
  1. package/CHANGELOG.md +698 -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 +603 -0
  10. package/src/Behavior_GWT.res.mjs +426 -0
  11. package/src/Bind.res +29 -0
  12. package/src/Bind.res.mjs +22 -0
  13. package/src/BuildClassifier.res +137 -0
  14. package/src/BuildClassifier.res.mjs +136 -0
  15. package/src/Cancellation.res +31 -0
  16. package/src/Cancellation.res.mjs +45 -0
  17. package/src/ChildProcess.res +84 -0
  18. package/src/ChildProcess.res.mjs +92 -0
  19. package/src/Cli.res +671 -0
  20. package/src/Cli.res.mjs +754 -0
  21. package/src/Collector.res +201 -0
  22. package/src/Collector.res.mjs +215 -0
  23. package/src/ComponentMeta.res +104 -0
  24. package/src/ComponentMeta.res.mjs +120 -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 +103 -0
  33. package/src/DomainDeadCode.res +93 -0
  34. package/src/DomainDeadCode.res.mjs +69 -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 +36 -0
  40. package/src/Filter.res.mjs +40 -0
  41. package/src/Flow_GWT.res +664 -0
  42. package/src/Flow_GWT.res.mjs +604 -0
  43. package/src/FormatterHuman.res +138 -0
  44. package/src/FormatterHuman.res.mjs +122 -0
  45. package/src/FormatterJson.res +257 -0
  46. package/src/FormatterJson.res.mjs +320 -0
  47. package/src/FormatterJunit.res +93 -0
  48. package/src/FormatterJunit.res.mjs +90 -0
  49. package/src/FormatterTap.res +139 -0
  50. package/src/FormatterTap.res.mjs +149 -0
  51. package/src/FormatterVsCode.res +362 -0
  52. package/src/FormatterVsCode.res.mjs +564 -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 +135 -0
  62. package/src/LocalHost.res.mjs +127 -0
  63. package/src/Mapping_GWT.res +474 -0
  64. package/src/Mapping_GWT.res.mjs +322 -0
  65. package/src/MultiSourceProjection_GWT.res +316 -0
  66. package/src/MultiSourceProjection_GWT.res.mjs +354 -0
  67. package/src/OutboundTranslation_GWT.res +238 -0
  68. package/src/OutboundTranslation_GWT.res.mjs +186 -0
  69. package/src/Outcome.res +161 -0
  70. package/src/Outcome.res.mjs +140 -0
  71. package/src/PackageScan.res +80 -0
  72. package/src/PackageScan.res.mjs +81 -0
  73. package/src/PlatformRunner.res +160 -0
  74. package/src/PlatformRunner.res.mjs +155 -0
  75. package/src/PlatformScan.res +138 -0
  76. package/src/PlatformScan.res.mjs +131 -0
  77. package/src/ProcessManager.res +91 -0
  78. package/src/ProcessManager.res.mjs +80 -0
  79. package/src/Projection_GWT.res +312 -0
  80. package/src/Projection_GWT.res.mjs +332 -0
  81. package/src/Query_GWT.res +379 -0
  82. package/src/Query_GWT.res.mjs +367 -0
  83. package/src/RenderRescript.res +125 -0
  84. package/src/RenderRescript.res.mjs +141 -0
  85. package/src/RunnerTypes.res +68 -0
  86. package/src/RunnerTypes.res.mjs +60 -0
  87. package/src/SideEffect_GWT.res +157 -0
  88. package/src/SideEffect_GWT.res.mjs +113 -0
  89. package/src/StateChange/ExternalAddCategorySlice.res +25 -0
  90. package/src/StateChange/ExternalAddCategorySlice.res.mjs +34 -0
  91. package/src/StateChange/ExternalAddCategorySlice_Behavior.res +19 -0
  92. package/src/StateChange/ExternalAddCategorySlice_Behavior.res.mjs +46 -0
  93. package/src/StateChange/WithFixtures.res +22 -0
  94. package/src/StateChange/WithFixtures.res.mjs +31 -0
  95. package/src/StateChange/WithFixtures_Behavior.res +17 -0
  96. package/src/StateChange/WithFixtures_Behavior.res.mjs +37 -0
  97. package/src/StateChange/WithManualOpen.res +23 -0
  98. package/src/StateChange/WithManualOpen.res.mjs +31 -0
  99. package/src/StateChange/WithManualOpen_Behavior.res +17 -0
  100. package/src/StateChange/WithManualOpen_Behavior.res.mjs +37 -0
  101. package/src/StubRuntime.res +53 -0
  102. package/src/StubRuntime.res.mjs +54 -0
  103. package/src/TestFixtures.res +16 -0
  104. package/src/TestFixtures.res.mjs +34 -0
  105. package/src/Watch.res +92 -0
  106. package/src/Watch.res.mjs +83 -0
  107. package/src/WatcherProbe.res +48 -0
  108. package/src/WatcherProbe.res.mjs +46 -0
  109. package/tests/AutomationGwtTest.res +71 -0
  110. package/tests/AutomationGwtTest.res.mjs +189 -0
  111. package/tests/BuildClassifierTest.res +94 -0
  112. package/tests/BuildClassifierTest.res.mjs +132 -0
  113. package/tests/ComponentMetaTest.res +52 -0
  114. package/tests/ComponentMetaTest.res.mjs +57 -0
  115. package/tests/DelegateGwtTest.res +487 -0
  116. package/tests/DelegateGwtTest.res.mjs +891 -0
  117. package/tests/DiscoveryTest.res +42 -0
  118. package/tests/DiscoveryTest.res.mjs +43 -0
  119. package/tests/DomainDeadCodeTest.res +116 -0
  120. package/tests/DomainDeadCodeTest.res.mjs +155 -0
  121. package/tests/DomainGraphTest.res +365 -0
  122. package/tests/DomainGraphTest.res.mjs +413 -0
  123. package/tests/FlowAggregateGwtTest.res +169 -0
  124. package/tests/FlowAggregateGwtTest.res.mjs +269 -0
  125. package/tests/FlowCrossPluginGwtTest.res +340 -0
  126. package/tests/FlowCrossPluginGwtTest.res.mjs +798 -0
  127. package/tests/FlowGwtTest.res +222 -0
  128. package/tests/FlowGwtTest.res.mjs +432 -0
  129. package/tests/FormatterVsCodeMessageTest.res +41 -0
  130. package/tests/FormatterVsCodeMessageTest.res.mjs +42 -0
  131. package/tests/InboundTranslationGwtTest.res +34 -0
  132. package/tests/InboundTranslationGwtTest.res.mjs +98 -0
  133. package/tests/LocalHostIntegration.res +70 -0
  134. package/tests/LocalHostIntegration.res.mjs +64 -0
  135. package/tests/LocalHostTest.res +71 -0
  136. package/tests/LocalHostTest.res.mjs +63 -0
  137. package/tests/MappingGwtTest.res +348 -0
  138. package/tests/MappingGwtTest.res.mjs +592 -0
  139. package/tests/OutboundTranslationGwtTest.res +59 -0
  140. package/tests/OutboundTranslationGwtTest.res.mjs +138 -0
  141. package/tests/PlatformRunnerTest.res +66 -0
  142. package/tests/PlatformRunnerTest.res.mjs +85 -0
  143. package/tests/PlatformScanTest.res +61 -0
  144. package/tests/PlatformScanTest.res.mjs +56 -0
  145. package/tests/QueryGwtTest.res +161 -0
  146. package/tests/QueryGwtTest.res.mjs +314 -0
  147. package/tests/QueryResolverGwtTest.res +71 -0
  148. package/tests/QueryResolverGwtTest.res.mjs +136 -0
  149. package/tests/RunnerUnitTest.res +219 -0
  150. package/tests/RunnerUnitTest.res.mjs +244 -0
  151. package/tests/SideEffect/FakeOrderNotification.res +23 -0
  152. package/tests/SideEffect/FakeOrderNotification.res.mjs +36 -0
  153. package/tests/SideEffect/FakeOrderNotificationGwtTest.res +35 -0
  154. package/tests/SideEffect/FakeOrderNotificationGwtTest.res.mjs +73 -0
  155. package/tests/SideEffect/MockEmail.res +18 -0
  156. package/tests/SideEffect/MockEmail.res.mjs +47 -0
  157. package/tests/StateChange/ExternalAddCategorySlice_GWT.res +27 -0
  158. package/tests/StateChange/ExternalAddCategorySlice_GWT.res.mjs +70 -0
  159. package/tests/StateChange/WithFixtures_Fixtures.res +9 -0
  160. package/tests/StateChange/WithFixtures_Fixtures.res.mjs +20 -0
  161. package/tests/StateChange/WithFixtures_GWT.res +23 -0
  162. package/tests/StateChange/WithFixtures_GWT.res.mjs +56 -0
  163. package/tests/StateChange/WithManualOpen_Fixtures.res +7 -0
  164. package/tests/StateChange/WithManualOpen_Fixtures.res.mjs +20 -0
  165. package/tests/StateChange/WithManualOpen_GWT.res +17 -0
  166. package/tests/StateChange/WithManualOpen_GWT.res.mjs +56 -0
  167. package/tests/StateChangeSliceGwtTest.res +160 -0
  168. package/tests/StateChangeSliceGwtTest.res.mjs +280 -0
  169. package/tests/StateViewSliceGwtTest.res +64 -0
  170. package/tests/StateViewSliceGwtTest.res.mjs +161 -0
  171. package/tests/WatchDebounceTest.res +78 -0
  172. package/tests/WatchDebounceTest.res.mjs +97 -0
@@ -0,0 +1,564 @@
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_Dict from "@rescript/runtime/lib/es6/Stdlib_Dict.js";
6
+ import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
7
+ import * as Primitive_option from "@rescript/runtime/lib/es6/Primitive_option.js";
8
+ import * as Hint$ReventlessGwt from "./Hint.res.mjs";
9
+ import * as Outcome$ReventlessGwt from "./Outcome.res.mjs";
10
+ import * as ComponentMeta$ReventlessGwt from "./ComponentMeta.res.mjs";
11
+ import * as RenderRescript$ReventlessGwt from "./RenderRescript.res.mjs";
12
+ import * as Protocol$ReventlessVscodeProtocol from "@reventlessdev/reventless-vscode-protocol/src/Protocol.res.mjs";
13
+
14
+ function write(s) {
15
+ process.stdout.write(s);
16
+ }
17
+
18
+ function writeLine(s) {
19
+ process.stdout.write(s + "\n");
20
+ }
21
+
22
+ function emit(e) {
23
+ let s = Protocol$ReventlessVscodeProtocol.toJsonLine(e);
24
+ process.stdout.write(s + "\n");
25
+ }
26
+
27
+ function uriOf(path) {
28
+ return "file://" + path;
29
+ }
30
+
31
+ function fileLabelOf(abs) {
32
+ let base = Nodepath.basename(abs);
33
+ if (base.endsWith(".res.mjs")) {
34
+ return base.slice(0, base.length - 8 | 0);
35
+ } else {
36
+ return base;
37
+ }
38
+ }
39
+
40
+ function relativeToCwd(abs) {
41
+ return Nodepath.relative(process.cwd(), abs);
42
+ }
43
+
44
+ let sourceLineCache = {};
45
+
46
+ function resetLocateCache() {
47
+ Object.keys(sourceLineCache).forEach(k => Stdlib_Dict.$$delete(sourceLineCache, k));
48
+ }
49
+
50
+ function mjsToRes(mjsPath) {
51
+ if (mjsPath.endsWith(".res.mjs")) {
52
+ return mjsPath.slice(0, mjsPath.length - 4 | 0);
53
+ }
54
+ }
55
+
56
+ function readLinesCached(resPath) {
57
+ let v = sourceLineCache[resPath];
58
+ if (v !== undefined) {
59
+ return Primitive_option.valFromOption(v);
60
+ }
61
+ let v$1;
62
+ try {
63
+ v$1 = Nodefs.existsSync(resPath) ? Nodefs.readFileSync(resPath, "utf8").split("\n") : undefined;
64
+ } catch (exn) {
65
+ v$1 = undefined;
66
+ }
67
+ sourceLineCache[resPath] = v$1;
68
+ return v$1;
69
+ }
70
+
71
+ function escapeForDouble(s) {
72
+ return s.replaceAll("\\", "\\\\").replaceAll("\"", "\\\"");
73
+ }
74
+
75
+ function escapeForSingle(s) {
76
+ return s.replaceAll("\\", "\\\\").replaceAll("'", "\\'");
77
+ }
78
+
79
+ function locateInSource(mjsPath, label) {
80
+ let resPath = mjsToRes(mjsPath);
81
+ if (resPath === undefined) {
82
+ return;
83
+ }
84
+ let lines = readLinesCached(resPath);
85
+ if (lines === undefined) {
86
+ return;
87
+ }
88
+ let needleD = "\"" + escapeForDouble(label) + "\"";
89
+ let needleS = "'" + escapeForSingle(label) + "'";
90
+ let total = lines.length;
91
+ let _i = 0;
92
+ while (true) {
93
+ let i = _i;
94
+ if (i >= total) {
95
+ return;
96
+ }
97
+ let line = lines[i];
98
+ let idxD = line.indexOf(needleD);
99
+ let idxS = line.indexOf(needleS);
100
+ let col = idxD !== -1 ? (
101
+ idxS !== -1 ? (
102
+ idxD < idxS ? idxD : idxS
103
+ ) + 1 | 0 : idxD + 1 | 0
104
+ ) : (
105
+ idxS !== -1 ? idxS + 1 | 0 : -1
106
+ );
107
+ if (col >= 0) {
108
+ return {
109
+ file: resPath,
110
+ line: i + 1 | 0,
111
+ column: col
112
+ };
113
+ }
114
+ _i = i + 1 | 0;
115
+ continue;
116
+ };
117
+ }
118
+
119
+ function rangeOf(loc) {
120
+ let pos_line = loc.line - 1 | 0;
121
+ let pos_character = loc.column - 1 | 0;
122
+ let pos = {
123
+ line: pos_line,
124
+ character: pos_character
125
+ };
126
+ return {
127
+ start: pos,
128
+ end: pos
129
+ };
130
+ }
131
+
132
+ function locationOf(loc) {
133
+ return {
134
+ uri: "file://" + loc.file,
135
+ range: rangeOf(loc)
136
+ };
137
+ }
138
+
139
+ function hello() {
140
+ let s = Protocol$ReventlessVscodeProtocol.toJsonLine({
141
+ event: "hello",
142
+ protocol: Protocol$ReventlessVscodeProtocol.protocolVersion
143
+ });
144
+ process.stdout.write(s + "\n");
145
+ }
146
+
147
+ function discoverStart() {
148
+ let s = Protocol$ReventlessVscodeProtocol.toJsonLine({
149
+ event: "discoverStart"
150
+ });
151
+ process.stdout.write(s + "\n");
152
+ }
153
+
154
+ function emitDiscoveryItems(files) {
155
+ files.forEach(param => {
156
+ let path = param[0];
157
+ let resPath = mjsToRes(path);
158
+ let fileUri = resPath !== undefined ? (
159
+ Nodefs.existsSync(resPath) ? "file://" + resPath : "file://" + path
160
+ ) : "file://" + path;
161
+ let component = Stdlib_Option.map(ComponentMeta$ReventlessGwt.componentOfTestFile(path), c => ({
162
+ kind: c.kind,
163
+ name: c.name
164
+ }));
165
+ let e_3 = fileLabelOf(path);
166
+ let e_4 = Nodepath.relative(process.cwd(), path);
167
+ let e_5 = fileUri;
168
+ let e = {
169
+ event: "item",
170
+ id: path,
171
+ kind: "file",
172
+ label: e_3,
173
+ description: e_4,
174
+ uri: e_5,
175
+ component: component
176
+ };
177
+ let s = Protocol$ReventlessVscodeProtocol.toJsonLine(e);
178
+ process.stdout.write(s + "\n");
179
+ let seenDescribes = {};
180
+ param[1].forEach(t => {
181
+ let stack = {
182
+ contents: []
183
+ };
184
+ t.describePath.forEach(label => {
185
+ let parent = stack.contents.length === 0 ? path : path + "::" + stack.contents.join("::");
186
+ stack.contents = stack.contents.concat([label]);
187
+ let id = path + "::" + stack.contents.join("::");
188
+ let match = seenDescribes[id];
189
+ if (match !== undefined) {
190
+ return;
191
+ }
192
+ seenDescribes[id] = true;
193
+ let loc = locateInSource(path, label);
194
+ let e_1 = parent;
195
+ let e_5 = Stdlib_Option.map(loc, l => "file://" + l.file);
196
+ let e_6 = Stdlib_Option.map(loc, rangeOf);
197
+ let e = {
198
+ event: "item",
199
+ id: id,
200
+ parent: e_1,
201
+ kind: "suite",
202
+ label: label,
203
+ uri: e_5,
204
+ range: e_6
205
+ };
206
+ let s = Protocol$ReventlessVscodeProtocol.toJsonLine(e);
207
+ process.stdout.write(s + "\n");
208
+ });
209
+ let parent = t.describePath.length === 0 ? path : path + "::" + t.describePath.join("::");
210
+ let testId = path + "::" + t.id;
211
+ let resLoc = locateInSource(path, t.name);
212
+ let match = t.location;
213
+ let loc = resLoc !== undefined ? resLoc : (
214
+ match !== undefined ? match : undefined
215
+ );
216
+ let e_1 = parent;
217
+ let e_3 = t.name;
218
+ let e_5 = Stdlib_Option.map(loc, l => "file://" + l.file);
219
+ let e_6 = Stdlib_Option.map(loc, rangeOf);
220
+ let e = {
221
+ event: "item",
222
+ id: testId,
223
+ parent: e_1,
224
+ kind: "test",
225
+ label: e_3,
226
+ uri: e_5,
227
+ range: e_6
228
+ };
229
+ let s = Protocol$ReventlessVscodeProtocol.toJsonLine(e);
230
+ process.stdout.write(s + "\n");
231
+ });
232
+ });
233
+ }
234
+
235
+ function discoverEnd(total) {
236
+ let s = Protocol$ReventlessVscodeProtocol.toJsonLine({
237
+ event: "discoverEnd",
238
+ total: total
239
+ });
240
+ process.stdout.write(s + "\n");
241
+ }
242
+
243
+ function packages(pkgs) {
244
+ let e = {
245
+ event: "packages",
246
+ packages: pkgs.map(p => ({
247
+ name: p.name,
248
+ dir: p.dir,
249
+ build: p.build
250
+ }))
251
+ };
252
+ let s = Protocol$ReventlessVscodeProtocol.toJsonLine(e);
253
+ process.stdout.write(s + "\n");
254
+ }
255
+
256
+ function components(comps) {
257
+ let e = {
258
+ event: "components",
259
+ components: comps.map(c => ({
260
+ kind: c.kind,
261
+ name: c.name,
262
+ dir: c.dir,
263
+ files: c.files
264
+ }))
265
+ };
266
+ let s = Protocol$ReventlessVscodeProtocol.toJsonLine(e);
267
+ process.stdout.write(s + "\n");
268
+ }
269
+
270
+ function deadCode(findings) {
271
+ let e = {
272
+ event: "deadCode",
273
+ findings: findings.map(f => ({
274
+ kind: f.kind,
275
+ plugin: f.pluginName,
276
+ component: f.componentName,
277
+ detail: f.detail
278
+ }))
279
+ };
280
+ let s = Protocol$ReventlessVscodeProtocol.toJsonLine(e);
281
+ process.stdout.write(s + "\n");
282
+ }
283
+
284
+ function graph(g) {
285
+ let e_0 = g.nodes.map(n => ({
286
+ id: n.id,
287
+ kind: n.kind,
288
+ label: n.label,
289
+ plugin: n.plugin
290
+ }));
291
+ let e_1 = g.edges.map(e => ({
292
+ from: e.from,
293
+ to: e.to,
294
+ kind: e.kind
295
+ }));
296
+ let e = {
297
+ event: "graph",
298
+ nodes: e_0,
299
+ edges: e_1
300
+ };
301
+ let s = Protocol$ReventlessVscodeProtocol.toJsonLine(e);
302
+ process.stdout.write(s + "\n");
303
+ }
304
+
305
+ function definitions(entries) {
306
+ let s = Protocol$ReventlessVscodeProtocol.toJsonLine({
307
+ event: "definitions",
308
+ entries: entries
309
+ });
310
+ process.stdout.write(s + "\n");
311
+ }
312
+
313
+ function buildStart(pkg) {
314
+ let s = Protocol$ReventlessVscodeProtocol.toJsonLine({
315
+ event: "buildStart",
316
+ package: pkg
317
+ });
318
+ process.stdout.write(s + "\n");
319
+ }
320
+
321
+ function buildOk(pkg, durationMs) {
322
+ let s = Protocol$ReventlessVscodeProtocol.toJsonLine({
323
+ event: "buildOk",
324
+ package: pkg,
325
+ durationMs: durationMs
326
+ });
327
+ process.stdout.write(s + "\n");
328
+ }
329
+
330
+ function buildFail(pkg, message) {
331
+ let s = Protocol$ReventlessVscodeProtocol.toJsonLine({
332
+ event: "buildFail",
333
+ package: pkg,
334
+ message: message
335
+ });
336
+ process.stdout.write(s + "\n");
337
+ }
338
+
339
+ function buildExternal(pkg) {
340
+ let s = Protocol$ReventlessVscodeProtocol.toJsonLine({
341
+ event: "buildExternal",
342
+ package: pkg
343
+ });
344
+ process.stdout.write(s + "\n");
345
+ }
346
+
347
+ function platformStart($$package, dir, domainPort, platformPort) {
348
+ let s = Protocol$ReventlessVscodeProtocol.toJsonLine({
349
+ event: "platformStart",
350
+ package: $$package,
351
+ dir: dir,
352
+ domainPort: domainPort,
353
+ platformPort: platformPort
354
+ });
355
+ process.stdout.write(s + "\n");
356
+ }
357
+
358
+ function platformReady(domainEndpoint) {
359
+ let s = Protocol$ReventlessVscodeProtocol.toJsonLine({
360
+ event: "platformReady",
361
+ domainEndpoint: domainEndpoint
362
+ });
363
+ process.stdout.write(s + "\n");
364
+ }
365
+
366
+ function domainEvent(payload) {
367
+ let s = JSON.stringify(payload);
368
+ process.stdout.write(s + "\n");
369
+ }
370
+
371
+ function platformLog(line) {
372
+ let s = Protocol$ReventlessVscodeProtocol.toJsonLine({
373
+ event: "platformLog",
374
+ line: line
375
+ });
376
+ process.stdout.write(s + "\n");
377
+ }
378
+
379
+ function platformStop(code) {
380
+ let s = Protocol$ReventlessVscodeProtocol.toJsonLine({
381
+ event: "platformStop",
382
+ code: code
383
+ });
384
+ process.stdout.write(s + "\n");
385
+ }
386
+
387
+ function runStart(total, filter) {
388
+ let s = Protocol$ReventlessVscodeProtocol.toJsonLine({
389
+ event: "runStart",
390
+ total: total,
391
+ filter: filter
392
+ });
393
+ process.stdout.write(s + "\n");
394
+ }
395
+
396
+ function testStart(id) {
397
+ let s = Protocol$ReventlessVscodeProtocol.toJsonLine({
398
+ event: "testStart",
399
+ id: id
400
+ });
401
+ process.stdout.write(s + "\n");
402
+ }
403
+
404
+ function testPass(id, durationMs) {
405
+ let s = Protocol$ReventlessVscodeProtocol.toJsonLine({
406
+ event: "testPass",
407
+ id: id,
408
+ durationMs: durationMs
409
+ });
410
+ process.stdout.write(s + "\n");
411
+ }
412
+
413
+ function testSkip(id, reason) {
414
+ let s = Protocol$ReventlessVscodeProtocol.toJsonLine({
415
+ event: "testSkip",
416
+ id: id,
417
+ reason: reason
418
+ });
419
+ process.stdout.write(s + "\n");
420
+ }
421
+
422
+ function messagePayload(t) {
423
+ let m = t.mismatch;
424
+ if (m === undefined) {
425
+ return {
426
+ message: "failed"
427
+ };
428
+ }
429
+ let hint = Hint$ReventlessGwt.forMismatch(t.slice, m);
430
+ let match;
431
+ switch (m.TAG) {
432
+ case "ErrorMismatch" :
433
+ let actual = m.actual;
434
+ let actStr = actual !== undefined ? "Error(" + RenderRescript$ReventlessGwt.render(undefined, actual) + ")" : "Ok(" + RenderRescript$ReventlessGwt.renderMany(m.actualEvents) + ")";
435
+ match = [
436
+ "Error(" + RenderRescript$ReventlessGwt.render(undefined, m.expected) + ")",
437
+ actStr
438
+ ];
439
+ break;
440
+ case "StateMismatch" :
441
+ match = [
442
+ RenderRescript$ReventlessGwt.renderOption(m.expected),
443
+ RenderRescript$ReventlessGwt.renderOption(m.actual)
444
+ ];
445
+ break;
446
+ case "NoEventExpected" :
447
+ match = [
448
+ "[]",
449
+ RenderRescript$ReventlessGwt.renderMany(m.actual)
450
+ ];
451
+ break;
452
+ case "TodoMismatch" :
453
+ match = [
454
+ Outcome$ReventlessGwt.format(m),
455
+ ""
456
+ ];
457
+ break;
458
+ case "AppendConditionMismatch" :
459
+ match = [
460
+ RenderRescript$ReventlessGwt.render(undefined, m.expected),
461
+ RenderRescript$ReventlessGwt.render(undefined, m.actual)
462
+ ];
463
+ break;
464
+ case "TranslateError" :
465
+ match = [
466
+ m.expected,
467
+ Stdlib_Option.getOr(m.actual, "(none)")
468
+ ];
469
+ break;
470
+ case "Throw" :
471
+ match = [
472
+ "",
473
+ m.error
474
+ ];
475
+ break;
476
+ default:
477
+ match = [
478
+ RenderRescript$ReventlessGwt.renderMany(m.expected),
479
+ RenderRescript$ReventlessGwt.renderMany(m.actual)
480
+ ];
481
+ }
482
+ let location = Stdlib_Option.map(t.location, loc => locationOf(Stdlib_Option.getOr(locateInSource(loc.file, t.name), loc)));
483
+ return {
484
+ message: hint.message,
485
+ kind: Outcome$ReventlessGwt.kindName(m),
486
+ expected: match[0],
487
+ actual: match[1],
488
+ location: location
489
+ };
490
+ }
491
+
492
+ function testFail(t, id) {
493
+ let e_1 = t.durationMs;
494
+ let e_2 = [messagePayload(t)];
495
+ let e = {
496
+ event: "testFail",
497
+ id: id,
498
+ durationMs: e_1,
499
+ messages: e_2
500
+ };
501
+ let s = Protocol$ReventlessVscodeProtocol.toJsonLine(e);
502
+ process.stdout.write(s + "\n");
503
+ }
504
+
505
+ function runEnd(s) {
506
+ let s$1 = Protocol$ReventlessVscodeProtocol.toJsonLine({
507
+ event: "runEnd",
508
+ passed: s.passed,
509
+ failed: s.failed,
510
+ skipped: s.skipped,
511
+ durationMs: s.durationMs
512
+ });
513
+ process.stdout.write(s$1 + "\n");
514
+ }
515
+
516
+ let P;
517
+
518
+ let protocolVersion = Protocol$ReventlessVscodeProtocol.protocolVersion;
519
+
520
+ export {
521
+ P,
522
+ write,
523
+ writeLine,
524
+ emit,
525
+ uriOf,
526
+ fileLabelOf,
527
+ relativeToCwd,
528
+ sourceLineCache,
529
+ resetLocateCache,
530
+ mjsToRes,
531
+ readLinesCached,
532
+ escapeForDouble,
533
+ escapeForSingle,
534
+ locateInSource,
535
+ rangeOf,
536
+ locationOf,
537
+ protocolVersion,
538
+ hello,
539
+ discoverStart,
540
+ emitDiscoveryItems,
541
+ discoverEnd,
542
+ packages,
543
+ components,
544
+ deadCode,
545
+ graph,
546
+ definitions,
547
+ buildStart,
548
+ buildOk,
549
+ buildFail,
550
+ buildExternal,
551
+ platformStart,
552
+ platformReady,
553
+ domainEvent,
554
+ platformLog,
555
+ platformStop,
556
+ runStart,
557
+ testStart,
558
+ testPass,
559
+ testSkip,
560
+ messagePayload,
561
+ testFail,
562
+ runEnd,
563
+ }
564
+ /* 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
+ }