@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,754 @@
1
+ // Generated by ReScript, PLEASE EDIT WITH CARE
2
+
3
+ import * as Stdlib_Array from "@rescript/runtime/lib/es6/Stdlib_Array.js";
4
+ import * as Stdlib_JsExn from "@rescript/runtime/lib/es6/Stdlib_JsExn.js";
5
+ import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
6
+ import * as Watch$ReventlessGwt from "./Watch.res.mjs";
7
+ import * as Loader$ReventlessGwt from "./Loader.res.mjs";
8
+ import * as Primitive_exceptions from "@rescript/runtime/lib/es6/Primitive_exceptions.js";
9
+ import * as Outcome$ReventlessGwt from "./Outcome.res.mjs";
10
+ import * as Collector$ReventlessGwt from "./Collector.res.mjs";
11
+ import * as Discovery$ReventlessGwt from "./Discovery.res.mjs";
12
+ import * as LocalHost$ReventlessGwt from "./LocalHost.res.mjs";
13
+ import * as DomainGraph$ReventlessGwt from "./DomainGraph.res.mjs";
14
+ import * as PackageScan$ReventlessGwt from "./PackageScan.res.mjs";
15
+ import * as RunnerTypes$ReventlessGwt from "./RunnerTypes.res.mjs";
16
+ import * as Cancellation$ReventlessGwt from "./Cancellation.res.mjs";
17
+ import * as FormatterTap$ReventlessGwt from "./FormatterTap.res.mjs";
18
+ import * as PlatformScan$ReventlessGwt from "./PlatformScan.res.mjs";
19
+ import * as WatcherProbe$ReventlessGwt from "./WatcherProbe.res.mjs";
20
+ import * as ComponentScan$ReventlessGwt from "./ComponentScan.res.mjs";
21
+ import * as FormatterJson$ReventlessGwt from "./FormatterJson.res.mjs";
22
+ import * as DomainDeadCode$ReventlessGwt from "./DomainDeadCode.res.mjs";
23
+ import * as FormatterHuman$ReventlessGwt from "./FormatterHuman.res.mjs";
24
+ import * as FormatterJunit$ReventlessGwt from "./FormatterJunit.res.mjs";
25
+ import * as PlatformRunner$ReventlessGwt from "./PlatformRunner.res.mjs";
26
+ import * as ProcessManager$ReventlessGwt from "./ProcessManager.res.mjs";
27
+ import * as BuildClassifier$ReventlessGwt from "./BuildClassifier.res.mjs";
28
+ import * as FormatterVsCode$ReventlessGwt from "./FormatterVsCode.res.mjs";
29
+ import * as Platform_ComponentDefinitionsApi$ReventlessCore from "@reventlessdev/reventless-core/src/admin/Platform_ComponentDefinitionsApi.res.mjs";
30
+
31
+ let toolVersion = "0.1.0";
32
+
33
+ let dateNowIso = (() => new Date().toISOString());
34
+
35
+ function parseFormat(s) {
36
+ switch (s) {
37
+ case "human" :
38
+ return {
39
+ TAG: "Ok",
40
+ _0: "Human"
41
+ };
42
+ case "json" :
43
+ return {
44
+ TAG: "Ok",
45
+ _0: "Json"
46
+ };
47
+ case "junit" :
48
+ return {
49
+ TAG: "Ok",
50
+ _0: "Junit"
51
+ };
52
+ case "tap" :
53
+ return {
54
+ TAG: "Ok",
55
+ _0: "Tap"
56
+ };
57
+ case "vscode" :
58
+ return {
59
+ TAG: "Ok",
60
+ _0: "VsCode"
61
+ };
62
+ default:
63
+ return {
64
+ TAG: "Error",
65
+ _0: "Unknown --format value: " + s
66
+ };
67
+ }
68
+ }
69
+
70
+ function defaultRoots() {
71
+ return ["."];
72
+ }
73
+
74
+ function help() {
75
+ return `reventless-dev — Reventless dev CLI: GWT runner, domain graph, components, platform runner
76
+
77
+ USAGE:
78
+ reventless-dev run [--format=<fmt>] [--filter=<id>] [--stream] [--watch] [path...]
79
+ reventless-dev discover [--format=vscode] [path...]
80
+ reventless-dev watch [--format=<fmt>] [--filter=<id>] [path...]
81
+ reventless-dev platform [--format=vscode] [--backend=<b>] [--ui-ports] [path...]
82
+ reventless-dev platform --list [path...]
83
+
84
+ FORMATS:
85
+ human ANSI-coloured terminal output (default)
86
+ json Structured JSON envelope (--stream for NDJSON)
87
+ tap TAP 14 with YAML diagnostics
88
+ junit JUnit XML (single batch)
89
+ vscode NDJSON event stream for the VS Code Testing API
90
+
91
+ FLAGS:
92
+ --filter <id> Restrict execution to tests whose id contains <id>.
93
+ Repeatable.
94
+ --stream NDJSON streaming (json/vscode)
95
+ --watch Re-run on file change
96
+ --schema-version <v> Pin a JSON schema version for stable AI prompts
97
+ --backend <b> platform: storage backend for the spawned local platform
98
+ ("memory" default, or "sqlite:<path>[?reset]")
99
+ --ui-ports platform: pin the platform to the fixed default ports
100
+ (4000/4001/3001/3002) instead of ephemeral ones, so the
101
+ host-shell UI's Vite proxy can reach it
102
+ --list platform: list launchable platform packages as NDJSON
103
+ ({name, dir} per line) and exit
104
+ --help Show this help and exit
105
+
106
+ Exit code is 1 if any test failed, 0 otherwise.
107
+ `;
108
+ }
109
+
110
+ function parseArgv(argv) {
111
+ let slice = argv.slice(2, argv.length);
112
+ let subcommand = "Run";
113
+ let format = "Human";
114
+ let stream = false;
115
+ let watch = false;
116
+ let filters = [];
117
+ let schemaVersion;
118
+ let roots = [];
119
+ let backend = "memory";
120
+ let uiPorts = false;
121
+ let listPlatforms = false;
122
+ let error;
123
+ let showHelp = false;
124
+ let i = 0;
125
+ let len = slice.length;
126
+ if (len > 0) {
127
+ let first = slice[0];
128
+ switch (first) {
129
+ case "--help" :
130
+ case "-h" :
131
+ showHelp = true;
132
+ break;
133
+ case "discover" :
134
+ subcommand = "Discover";
135
+ format = "VsCode";
136
+ i = 1;
137
+ break;
138
+ case "platform" :
139
+ subcommand = "Platform";
140
+ i = 1;
141
+ break;
142
+ case "run" :
143
+ subcommand = "Run";
144
+ i = 1;
145
+ break;
146
+ case "watch" :
147
+ subcommand = "Watch";
148
+ watch = true;
149
+ i = 1;
150
+ break;
151
+ }
152
+ }
153
+ while (i < len && error === undefined && !showHelp) {
154
+ let arg = slice[i];
155
+ if (arg === "--help" || arg === "-h") {
156
+ showHelp = true;
157
+ } else if (arg.startsWith("--format=")) {
158
+ let v = arg.slice(9, arg.length);
159
+ let f = parseFormat(v);
160
+ if (f.TAG === "Ok") {
161
+ format = f._0;
162
+ } else {
163
+ error = f._0;
164
+ }
165
+ } else if (arg === "--format" && (i + 1 | 0) < len) {
166
+ let v$1 = slice[i + 1 | 0];
167
+ let f$1 = parseFormat(v$1);
168
+ if (f$1.TAG === "Ok") {
169
+ format = f$1._0;
170
+ } else {
171
+ error = f$1._0;
172
+ }
173
+ i = i + 1 | 0;
174
+ } else if (arg.startsWith("--filter=")) {
175
+ let v$2 = arg.slice(9, arg.length);
176
+ filters = filters.concat([v$2]);
177
+ } else if (arg === "--filter" && (i + 1 | 0) < len) {
178
+ let v$3 = slice[i + 1 | 0];
179
+ filters = filters.concat([v$3]);
180
+ i = i + 1 | 0;
181
+ } else if (arg === "--stream") {
182
+ stream = true;
183
+ } else if (arg === "--watch") {
184
+ watch = true;
185
+ } else if (arg.startsWith("--schema-version=")) {
186
+ let v$4 = arg.slice(17, arg.length);
187
+ schemaVersion = v$4;
188
+ } else if (arg.startsWith("--backend=")) {
189
+ backend = arg.slice(10, arg.length);
190
+ } else if (arg === "--backend" && (i + 1 | 0) < len) {
191
+ backend = slice[i + 1 | 0];
192
+ i = i + 1 | 0;
193
+ } else if (arg === "--ui-ports") {
194
+ uiPorts = true;
195
+ } else if (arg === "--list") {
196
+ listPlatforms = true;
197
+ } else if (arg.startsWith("--")) {
198
+ error = "Unknown flag: " + arg;
199
+ } else {
200
+ roots = roots.concat([arg]);
201
+ }
202
+ i = i + 1 | 0;
203
+ };
204
+ if (showHelp) {
205
+ return {
206
+ TAG: "Error",
207
+ _0: `reventless-dev — Reventless dev CLI: GWT runner, domain graph, components, platform runner
208
+
209
+ USAGE:
210
+ reventless-dev run [--format=<fmt>] [--filter=<id>] [--stream] [--watch] [path...]
211
+ reventless-dev discover [--format=vscode] [path...]
212
+ reventless-dev watch [--format=<fmt>] [--filter=<id>] [path...]
213
+ reventless-dev platform [--format=vscode] [--backend=<b>] [--ui-ports] [path...]
214
+ reventless-dev platform --list [path...]
215
+
216
+ FORMATS:
217
+ human ANSI-coloured terminal output (default)
218
+ json Structured JSON envelope (--stream for NDJSON)
219
+ tap TAP 14 with YAML diagnostics
220
+ junit JUnit XML (single batch)
221
+ vscode NDJSON event stream for the VS Code Testing API
222
+
223
+ FLAGS:
224
+ --filter <id> Restrict execution to tests whose id contains <id>.
225
+ Repeatable.
226
+ --stream NDJSON streaming (json/vscode)
227
+ --watch Re-run on file change
228
+ --schema-version <v> Pin a JSON schema version for stable AI prompts
229
+ --backend <b> platform: storage backend for the spawned local platform
230
+ ("memory" default, or "sqlite:<path>[?reset]")
231
+ --ui-ports platform: pin the platform to the fixed default ports
232
+ (4000/4001/3001/3002) instead of ephemeral ones, so the
233
+ host-shell UI's Vite proxy can reach it
234
+ --list platform: list launchable platform packages as NDJSON
235
+ ({name, dir} per line) and exit
236
+ --help Show this help and exit
237
+
238
+ Exit code is 1 if any test failed, 0 otherwise.
239
+ `
240
+ };
241
+ }
242
+ let e = error;
243
+ if (e !== undefined) {
244
+ return {
245
+ TAG: "Error",
246
+ _0: e + "\n\n" + `reventless-dev — Reventless dev CLI: GWT runner, domain graph, components, platform runner
247
+
248
+ USAGE:
249
+ reventless-dev run [--format=<fmt>] [--filter=<id>] [--stream] [--watch] [path...]
250
+ reventless-dev discover [--format=vscode] [path...]
251
+ reventless-dev watch [--format=<fmt>] [--filter=<id>] [path...]
252
+ reventless-dev platform [--format=vscode] [--backend=<b>] [--ui-ports] [path...]
253
+ reventless-dev platform --list [path...]
254
+
255
+ FORMATS:
256
+ human ANSI-coloured terminal output (default)
257
+ json Structured JSON envelope (--stream for NDJSON)
258
+ tap TAP 14 with YAML diagnostics
259
+ junit JUnit XML (single batch)
260
+ vscode NDJSON event stream for the VS Code Testing API
261
+
262
+ FLAGS:
263
+ --filter <id> Restrict execution to tests whose id contains <id>.
264
+ Repeatable.
265
+ --stream NDJSON streaming (json/vscode)
266
+ --watch Re-run on file change
267
+ --schema-version <v> Pin a JSON schema version for stable AI prompts
268
+ --backend <b> platform: storage backend for the spawned local platform
269
+ ("memory" default, or "sqlite:<path>[?reset]")
270
+ --ui-ports platform: pin the platform to the fixed default ports
271
+ (4000/4001/3001/3002) instead of ephemeral ones, so the
272
+ host-shell UI's Vite proxy can reach it
273
+ --list platform: list launchable platform packages as NDJSON
274
+ ({name, dir} per line) and exit
275
+ --help Show this help and exit
276
+
277
+ Exit code is 1 if any test failed, 0 otherwise.
278
+ `
279
+ };
280
+ } else {
281
+ return {
282
+ TAG: "Ok",
283
+ _0: {
284
+ subcommand: subcommand,
285
+ format: format,
286
+ stream: stream,
287
+ watch: watch,
288
+ filters: filters,
289
+ schemaVersion: schemaVersion,
290
+ roots: roots.length === 0 ? ["."] : roots,
291
+ backend: backend,
292
+ uiPorts: uiPorts,
293
+ listPlatforms: listPlatforms,
294
+ toolVersion: toolVersion
295
+ }
296
+ };
297
+ }
298
+ }
299
+
300
+ function passesFilter(id, filters) {
301
+ if (filters.length === 0) {
302
+ return true;
303
+ } else {
304
+ return filters.some(f => id.includes(f));
305
+ }
306
+ }
307
+
308
+ let exnMessage = (function(e) {
309
+ if (e == null) return "unknown error"
310
+ if (typeof e === "string") return e
311
+ if (typeof e.message === "string" && e.message.length) return e.message
312
+ if (typeof e.RE_EXN_ID === "string") {
313
+ var id = e.RE_EXN_ID
314
+ var tag = id.lastIndexOf(".") >= 0 ? id.slice(id.lastIndexOf(".") + 1) : id
315
+ return (typeof e._1 === "string" && e._1.length) ? e._1 : tag
316
+ }
317
+ return "unknown error"
318
+ });
319
+
320
+ async function runEntry(entry) {
321
+ let start = performance.now();
322
+ let status = "Pass";
323
+ let mismatch;
324
+ let match = entry.status;
325
+ let exit = 0;
326
+ switch (match) {
327
+ case "Skipped" :
328
+ status = "Skip";
329
+ break;
330
+ case "Runnable" :
331
+ case "Only" :
332
+ exit = 1;
333
+ break;
334
+ }
335
+ if (exit === 1) {
336
+ try {
337
+ let outcome = await entry.body();
338
+ if (outcome.TAG === "Ok") {
339
+ status = "Pass";
340
+ } else {
341
+ status = "Fail";
342
+ mismatch = outcome._0;
343
+ }
344
+ } catch (raw_exn) {
345
+ let exn = Primitive_exceptions.internalToException(raw_exn);
346
+ status = "Fail";
347
+ let err = exnMessage(exn);
348
+ let stack = ((e => (e && e.stack) || ""))(exn);
349
+ mismatch = {
350
+ TAG: "Throw",
351
+ error: err,
352
+ stack: stack
353
+ };
354
+ }
355
+ }
356
+ let durationMs = performance.now() - start;
357
+ return {
358
+ id: entry.id,
359
+ name: entry.name,
360
+ describePath: entry.describePath,
361
+ status: status,
362
+ durationMs: durationMs,
363
+ location: entry.location,
364
+ slice: entry.slice,
365
+ mismatch: mismatch,
366
+ skipReason: entry.status === "Skipped" ? "skipped at source" : undefined
367
+ };
368
+ }
369
+
370
+ async function loadAndCollect(path) {
371
+ Collector$ReventlessGwt.activate();
372
+ Collector$ReventlessGwt.setCurrentFile(path);
373
+ try {
374
+ await Loader$ReventlessGwt.loadFile(path);
375
+ } catch (raw_exn) {
376
+ let exn = Primitive_exceptions.internalToException(raw_exn);
377
+ let msg = Stdlib_Option.getOr(Stdlib_Option.flatMap(Stdlib_JsExn.fromException(exn), Stdlib_JsExn.message), "import failed");
378
+ Collector$ReventlessGwt.push(undefined, undefined, `<file-load-error>`, () => Promise.resolve(Outcome$ReventlessGwt.fail({
379
+ TAG: "Throw",
380
+ error: "Failed to load " + path + ": " + msg,
381
+ stack: ""
382
+ })));
383
+ }
384
+ let entries = Collector$ReventlessGwt.drain();
385
+ Collector$ReventlessGwt.deactivate();
386
+ return entries;
387
+ }
388
+
389
+ async function runFiles(opts, paths, onFileFinished, onTestStart, onTestFinished) {
390
+ let startedAt = dateNowIso();
391
+ let startTime = performance.now();
392
+ let files = [];
393
+ for (let i = 0, i_finish = paths.length; i < i_finish; ++i) {
394
+ let path = paths[i];
395
+ if (!Cancellation$ReventlessGwt.isCancelled()) {
396
+ let entries = await loadAndCollect(path);
397
+ let onlyActive = Collector$ReventlessGwt.hasOnly.contents;
398
+ let selected = entries.filter(e => {
399
+ let keepByOnly = onlyActive ? e.status === "Only" : true;
400
+ let qualifiedId = path + "::" + e.id;
401
+ let keepByFilter = passesFilter(e.id, opts.filters) || passesFilter(qualifiedId, opts.filters);
402
+ if (keepByOnly) {
403
+ return keepByFilter;
404
+ } else {
405
+ return false;
406
+ }
407
+ });
408
+ let tests = [];
409
+ for (let j = 0, j_finish = selected.length; j < j_finish; ++j) {
410
+ if (Cancellation$ReventlessGwt.isCancelled()) {
411
+ let e = selected[j];
412
+ let r_id = e.id;
413
+ let r_name = e.name;
414
+ let r_describePath = e.describePath;
415
+ let r_location = e.location;
416
+ let r_slice = e.slice;
417
+ let r_skipReason = "cancelled";
418
+ let r = {
419
+ id: r_id,
420
+ name: r_name,
421
+ describePath: r_describePath,
422
+ status: "Skip",
423
+ durationMs: 0.0,
424
+ location: r_location,
425
+ slice: r_slice,
426
+ mismatch: undefined,
427
+ skipReason: r_skipReason
428
+ };
429
+ tests.push(r);
430
+ if (onTestFinished !== undefined) {
431
+ onTestFinished(path, r);
432
+ }
433
+ } else {
434
+ let entry = selected[j];
435
+ if (onTestStart !== undefined) {
436
+ onTestStart(path, entry);
437
+ }
438
+ let r$1 = await runEntry(entry);
439
+ tests.push(r$1);
440
+ if (onTestFinished !== undefined) {
441
+ onTestFinished(path, r$1);
442
+ }
443
+ }
444
+ }
445
+ let fr = {
446
+ path: path,
447
+ tests: tests
448
+ };
449
+ files.push(fr);
450
+ if (onFileFinished !== undefined) {
451
+ onFileFinished(fr);
452
+ }
453
+ }
454
+ }
455
+ let durationMs = performance.now() - startTime;
456
+ let summary = RunnerTypes$ReventlessGwt.summaryOf(files, durationMs, startedAt);
457
+ return {
458
+ summary: summary,
459
+ files: files
460
+ };
461
+ }
462
+
463
+ function emitResult(opts, r) {
464
+ let match = opts.format;
465
+ switch (match) {
466
+ case "Human" :
467
+ return FormatterHuman$ReventlessGwt.emit(r);
468
+ case "Json" :
469
+ if (opts.stream) {
470
+ return FormatterJson$ReventlessGwt.streamRunEnd(r);
471
+ } else {
472
+ return FormatterJson$ReventlessGwt.emit(r, opts.toolVersion);
473
+ }
474
+ case "Tap" :
475
+ return FormatterTap$ReventlessGwt.emit(r);
476
+ case "Junit" :
477
+ return FormatterJunit$ReventlessGwt.emit(r);
478
+ case "VsCode" :
479
+ return FormatterVsCode$ReventlessGwt.runEnd(r.summary);
480
+ }
481
+ }
482
+
483
+ async function runOnce(opts) {
484
+ let paths = await Discovery$ReventlessGwt.discover(opts.roots);
485
+ if (opts.format === "Json" && opts.stream) {
486
+ FormatterJson$ReventlessGwt.streamRunStart(opts.toolVersion, dateNowIso());
487
+ }
488
+ let match = opts.format;
489
+ let match$1 = opts.stream;
490
+ let onFileFinished;
491
+ onFileFinished = match === "Json" && match$1 ? f => {
492
+ f.tests.forEach(FormatterJson$ReventlessGwt.streamTest);
493
+ FormatterJson$ReventlessGwt.streamFileFinished(f);
494
+ } : undefined;
495
+ let onTestStart = opts.format === "VsCode" ? (path, e) => FormatterVsCode$ReventlessGwt.testStart(path + "::" + e.id) : undefined;
496
+ let onTestFinished = opts.format === "VsCode" ? (path, t) => {
497
+ let id = path + "::" + t.id;
498
+ let match = t.status;
499
+ switch (match) {
500
+ case "Pass" :
501
+ return FormatterVsCode$ReventlessGwt.testPass(id, t.durationMs);
502
+ case "Fail" :
503
+ return FormatterVsCode$ReventlessGwt.testFail(t, id);
504
+ case "Skip" :
505
+ return FormatterVsCode$ReventlessGwt.testSkip(id, Stdlib_Option.getOr(t.skipReason, "skipped"));
506
+ }
507
+ } : undefined;
508
+ if (opts.format === "Json" && opts.stream) {
509
+ paths.forEach(FormatterJson$ReventlessGwt.streamFileStart);
510
+ } else if (opts.format === "VsCode") {
511
+ FormatterVsCode$ReventlessGwt.runStart(0, opts.filters);
512
+ }
513
+ let result = await runFiles(opts, paths, onFileFinished, onTestStart, onTestFinished);
514
+ emitResult(opts, result);
515
+ if (result.summary.failed > 0) {
516
+ return 1;
517
+ } else {
518
+ return 0;
519
+ }
520
+ }
521
+
522
+ async function emitDomainAnalysis(pkgs) {
523
+ let plugins = LocalHost$ReventlessGwt.discover(pkgs.map(p => p.dir));
524
+ if (plugins.length === 0) {
525
+ return;
526
+ }
527
+ let platformModulePath = LocalHost$ReventlessGwt.resolveLocalPlatform(plugins[0].packageDir);
528
+ if (platformModulePath === undefined) {
529
+ return;
530
+ }
531
+ try {
532
+ let loaded = await LocalHost$ReventlessGwt.loadGraph(platformModulePath, plugins);
533
+ FormatterVsCode$ReventlessGwt.deadCode(DomainDeadCode$ReventlessGwt.analyze(loaded.structures));
534
+ FormatterVsCode$ReventlessGwt.graph(DomainGraph$ReventlessGwt.build(loaded.structures));
535
+ return FormatterVsCode$ReventlessGwt.definitions(loaded.structures.map(param => Platform_ComponentDefinitionsApi$ReventlessCore.encodePluginStructureEntry(param[0], param[1])));
536
+ } catch (exn) {
537
+ return;
538
+ }
539
+ }
540
+
541
+ async function emitDiscovery(paths) {
542
+ FormatterVsCode$ReventlessGwt.discoverStart();
543
+ let fileTests = [];
544
+ for (let i = 0, i_finish = paths.length; i < i_finish; ++i) {
545
+ let path = paths[i];
546
+ let entries = await loadAndCollect(path);
547
+ let tests = entries.map(e => ({
548
+ id: e.id,
549
+ name: e.name,
550
+ describePath: e.describePath,
551
+ status: "Skip",
552
+ durationMs: 0.0,
553
+ location: e.location,
554
+ slice: e.slice,
555
+ mismatch: undefined,
556
+ skipReason: undefined
557
+ }));
558
+ fileTests.push([
559
+ path,
560
+ tests
561
+ ]);
562
+ }
563
+ FormatterVsCode$ReventlessGwt.emitDiscoveryItems(fileTests);
564
+ let total = Stdlib_Array.reduce(fileTests, 0, (a, param) => a + param[1].length | 0);
565
+ let pkgs = PackageScan$ReventlessGwt.scan(paths);
566
+ FormatterVsCode$ReventlessGwt.packages(pkgs);
567
+ let comps = await ComponentScan$ReventlessGwt.scan(pkgs.map(p => p.dir));
568
+ FormatterVsCode$ReventlessGwt.components(comps);
569
+ FormatterVsCode$ReventlessGwt.discoverEnd(total);
570
+ return await emitDomainAnalysis(pkgs);
571
+ }
572
+
573
+ async function runDiscover(opts) {
574
+ let paths = await Discovery$ReventlessGwt.discover(opts.roots);
575
+ await emitDiscovery(paths);
576
+ return 0;
577
+ }
578
+
579
+ function startBuildWatchers(paths) {
580
+ Cancellation$ReventlessGwt.onCancel(ProcessManager$ReventlessGwt.killAll);
581
+ PackageScan$ReventlessGwt.scan(paths).forEach(pkg => {
582
+ if (WatcherProbe$ReventlessGwt.hasLiveWatcher(pkg.dir)) {
583
+ return FormatterVsCode$ReventlessGwt.buildExternal(pkg.dir);
584
+ }
585
+ let feed = BuildClassifier$ReventlessGwt.make(undefined, {
586
+ onStart: () => FormatterVsCode$ReventlessGwt.buildStart(pkg.dir),
587
+ onOk: ms => FormatterVsCode$ReventlessGwt.buildOk(pkg.dir, ms),
588
+ onFail: msg => FormatterVsCode$ReventlessGwt.buildFail(pkg.dir, msg)
589
+ });
590
+ ProcessManager$ReventlessGwt.spawnWatcher(pkg, (_dir, line) => feed(line));
591
+ });
592
+ }
593
+
594
+ async function runWatch(opts) {
595
+ let roots = opts.roots;
596
+ if (opts.format === "VsCode") {
597
+ let paths = await Discovery$ReventlessGwt.discover(roots);
598
+ await emitDiscovery(paths);
599
+ startBuildWatchers(paths);
600
+ }
601
+ let runInProgress = {
602
+ contents: false
603
+ };
604
+ let rerunPending = {
605
+ contents: false
606
+ };
607
+ let run = async () => {
608
+ if (runInProgress.contents) {
609
+ rerunPending.contents = true;
610
+ return;
611
+ } else {
612
+ runInProgress.contents = true;
613
+ await runOnce(opts);
614
+ runInProgress.contents = false;
615
+ if (rerunPending.contents) {
616
+ rerunPending.contents = false;
617
+ await runOnce(opts);
618
+ return;
619
+ } else {
620
+ return;
621
+ }
622
+ }
623
+ };
624
+ await run();
625
+ Watch$ReventlessGwt.start(roots, (event, path) => {
626
+ if (opts.format === "VsCode" && Watch$ReventlessGwt.isStructuralSource(event, path)) {
627
+ let pkg = PackageScan$ReventlessGwt.findOwning(path);
628
+ if (pkg !== undefined) {
629
+ let t0 = Date.now();
630
+ FormatterVsCode$ReventlessGwt.buildStart(pkg.dir);
631
+ let feed = BuildClassifier$ReventlessGwt.make(undefined, {
632
+ onStart: () => {},
633
+ onOk: _ms => {},
634
+ onFail: msg => FormatterVsCode$ReventlessGwt.buildFail(pkg.dir, msg)
635
+ });
636
+ return ProcessManager$ReventlessGwt.cleanRebuild(pkg, (_dir, line) => feed(line), () => {
637
+ FormatterVsCode$ReventlessGwt.buildOk(pkg.dir, Date.now() - t0);
638
+ run();
639
+ });
640
+ }
641
+ run();
642
+ return;
643
+ } else {
644
+ run();
645
+ return;
646
+ }
647
+ });
648
+ await new Promise((resolve, _reject) => Cancellation$ReventlessGwt.onCancel(() => resolve()));
649
+ return 0;
650
+ }
651
+
652
+ async function runPlatform(opts) {
653
+ let callbacks = opts.format === "VsCode" ? ({
654
+ onStart: FormatterVsCode$ReventlessGwt.platformStart,
655
+ onReady: FormatterVsCode$ReventlessGwt.platformReady,
656
+ onDomainEvent: FormatterVsCode$ReventlessGwt.domainEvent,
657
+ onLog: FormatterVsCode$ReventlessGwt.platformLog,
658
+ onStop: FormatterVsCode$ReventlessGwt.platformStop
659
+ }) : ({
660
+ onStart: ($$package, param, domainPort, param$1) => {
661
+ console.log(`▶ platform ` + $$package + ` starting (domain http://localhost:` + domainPort.toString() + `)`);
662
+ },
663
+ onReady: domainEndpoint => {
664
+ console.log(`✓ platform ready — ` + domainEndpoint);
665
+ },
666
+ onDomainEvent: json => {
667
+ console.log("· event " + JSON.stringify(json));
668
+ },
669
+ onLog: line => {
670
+ console.log(line);
671
+ },
672
+ onStop: code => {
673
+ console.log(`■ platform stopped (code ` + Stdlib_Option.mapOr(code, "?", c => c.toString()) + `)`);
674
+ }
675
+ });
676
+ return await PlatformRunner$ReventlessGwt.run(opts.roots, opts.backend, opts.uiPorts, callbacks);
677
+ }
678
+
679
+ async function listPlatforms(opts) {
680
+ let pkgs = await PlatformScan$ReventlessGwt.scan(opts.roots);
681
+ pkgs.forEach(pkg => {
682
+ let obj = Object.fromEntries([
683
+ [
684
+ "name",
685
+ pkg.name
686
+ ],
687
+ [
688
+ "dir",
689
+ pkg.dir
690
+ ]
691
+ ]);
692
+ console.log(JSON.stringify(obj));
693
+ });
694
+ return 0;
695
+ }
696
+
697
+ async function main() {
698
+ Cancellation$ReventlessGwt.install();
699
+ let args = process.argv;
700
+ let msg = parseArgv(args);
701
+ if (msg.TAG === "Ok") {
702
+ let opts = msg._0;
703
+ if (opts.format === "VsCode") {
704
+ FormatterVsCode$ReventlessGwt.hello();
705
+ }
706
+ let match = opts.subcommand;
707
+ switch (match) {
708
+ case "Run" :
709
+ return await runOnce(opts);
710
+ case "Discover" :
711
+ return await runDiscover(opts);
712
+ case "Watch" :
713
+ return await runWatch(opts);
714
+ case "Platform" :
715
+ if (opts.listPlatforms) {
716
+ return await listPlatforms(opts);
717
+ } else {
718
+ return await runPlatform(opts);
719
+ }
720
+ }
721
+ } else {
722
+ console.error(msg._0);
723
+ if (args.some(a => a === "--help" ? true : a === "-h")) {
724
+ return 0;
725
+ } else {
726
+ return 2;
727
+ }
728
+ }
729
+ }
730
+
731
+ export {
732
+ toolVersion,
733
+ dateNowIso,
734
+ parseFormat,
735
+ defaultRoots,
736
+ help,
737
+ parseArgv,
738
+ passesFilter,
739
+ exnMessage,
740
+ runEntry,
741
+ loadAndCollect,
742
+ runFiles,
743
+ emitResult,
744
+ runOnce,
745
+ emitDomainAnalysis,
746
+ emitDiscovery,
747
+ runDiscover,
748
+ startBuildWatchers,
749
+ runWatch,
750
+ runPlatform,
751
+ listPlatforms,
752
+ main,
753
+ }
754
+ /* Stdlib_JsExn Not a pure module */