@davidsouther/jiffies 2.2.5 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (367) hide show
  1. package/LICENSE +1 -1
  2. package/lib/cjs/assert.d.ts +2 -2
  3. package/lib/cjs/awaitable.d.ts +1 -1
  4. package/lib/cjs/components/button_bar.d.ts +2 -2
  5. package/lib/cjs/components/inline_edit.d.ts +2 -2
  6. package/lib/cjs/components/logger.d.ts +1 -1
  7. package/lib/cjs/components/select.d.ts +4 -7
  8. package/lib/cjs/components/test.d.ts +1 -1
  9. package/lib/cjs/components/virtual_scroll.d.ts +6 -4
  10. package/lib/cjs/context.d.ts +5 -9
  11. package/lib/cjs/debounce.d.ts +1 -1
  12. package/lib/cjs/diff.d.ts +2 -2
  13. package/lib/cjs/display.d.ts +1 -1
  14. package/lib/cjs/dom/css/border.d.ts +2 -2
  15. package/lib/cjs/dom/css/constants.d.ts +3 -3
  16. package/lib/cjs/dom/css/core.d.ts +1 -1
  17. package/lib/cjs/dom/css/fstyle.d.ts +2 -2
  18. package/lib/cjs/dom/css/sizing.d.ts +2 -2
  19. package/lib/cjs/dom/dom.d.ts +8 -8
  20. package/lib/cjs/dom/fc.d.ts +8 -12
  21. package/lib/cjs/dom/form/form.d.ts +5 -6
  22. package/lib/cjs/dom/html.d.ts +112 -113
  23. package/lib/cjs/dom/observable.d.ts +1 -1
  24. package/lib/cjs/dom/provide.d.ts +1 -1
  25. package/lib/cjs/dom/router/router.d.ts +2 -2
  26. package/lib/cjs/dom/svg.d.ts +64 -64
  27. package/lib/cjs/dom/types/css.d.ts +10 -32
  28. package/lib/cjs/dom/types/html.d.ts +4 -6
  29. package/lib/cjs/equal.d.ts +8 -5
  30. package/lib/cjs/flags.d.ts +1 -1
  31. package/lib/cjs/fs.d.ts +3 -3
  32. package/lib/cjs/fs_node.d.ts +1 -1
  33. package/lib/cjs/lock.d.ts +1 -1
  34. package/lib/cjs/log.d.ts +7 -9
  35. package/lib/cjs/observable/event.d.ts +2 -2
  36. package/lib/cjs/observable/observable.d.ts +37 -35
  37. package/lib/cjs/result.d.ts +21 -21
  38. package/lib/cjs/safe.d.ts +1 -1
  39. package/lib/cjs/scope/describe.d.ts +4 -4
  40. package/lib/cjs/scope/display/console.d.ts +1 -1
  41. package/lib/cjs/scope/display/dom.d.ts +2 -2
  42. package/lib/cjs/scope/display/junit.d.ts +1 -1
  43. package/lib/cjs/scope/execute.d.ts +2 -2
  44. package/lib/cjs/scope/index.d.ts +3 -3
  45. package/lib/cjs/scope/scope.d.ts +3 -3
  46. package/lib/cjs/scope/state.d.ts +1 -1
  47. package/lib/cjs/server/http/apps.d.ts +1 -1
  48. package/lib/cjs/server/http/css.d.ts +1 -1
  49. package/lib/cjs/server/http/index.d.ts +4 -9
  50. package/lib/cjs/server/http/response.d.ts +3 -3
  51. package/lib/cjs/server/http/sitemap.d.ts +1 -1
  52. package/lib/cjs/server/http/static.d.ts +1 -1
  53. package/lib/cjs/server/http/typescript.d.ts +1 -1
  54. package/lib/cjs/test_all.d.ts +9 -9
  55. package/lib/cjs/tsconfig.tsbuildinfo +1 -1
  56. package/lib/esm/assert.d.ts +2 -2
  57. package/lib/esm/awaitable.d.ts +1 -1
  58. package/lib/esm/components/button_bar.d.ts +2 -2
  59. package/lib/esm/components/inline_edit.d.ts +2 -2
  60. package/lib/esm/components/logger.d.ts +1 -1
  61. package/lib/esm/components/select.d.ts +3 -3
  62. package/lib/esm/components/test.d.ts +1 -1
  63. package/lib/esm/components/virtual_scroll.d.ts +6 -4
  64. package/lib/esm/context.d.ts +5 -9
  65. package/lib/esm/debounce.d.ts +1 -2
  66. package/lib/esm/diff.d.ts +2 -2
  67. package/lib/esm/display.d.ts +1 -1
  68. package/lib/esm/dom/css/border.d.ts +2 -2
  69. package/lib/esm/dom/css/constants.d.ts +3 -3
  70. package/lib/esm/dom/css/core.d.ts +1 -1
  71. package/lib/esm/dom/css/fstyle.d.ts +2 -2
  72. package/lib/esm/dom/css/sizing.d.ts +2 -2
  73. package/lib/esm/dom/dom.d.ts +8 -8
  74. package/lib/esm/dom/fc.d.ts +8 -12
  75. package/lib/esm/dom/form/form.d.ts +5 -6
  76. package/lib/esm/dom/html.d.ts +112 -113
  77. package/lib/esm/dom/observable.d.ts +1 -1
  78. package/lib/esm/dom/provide.d.ts +1 -1
  79. package/lib/esm/dom/router/router.d.ts +2 -2
  80. package/lib/esm/dom/svg.d.ts +64 -64
  81. package/lib/esm/dom/types/css.d.ts +10 -32
  82. package/lib/esm/dom/types/html.d.ts +4 -6
  83. package/lib/esm/equal.d.ts +8 -5
  84. package/lib/esm/flags.d.ts +1 -1
  85. package/lib/esm/fs.d.ts +3 -3
  86. package/lib/esm/fs_node.d.ts +1 -1
  87. package/lib/esm/lock.d.ts +1 -1
  88. package/lib/esm/log.d.ts +7 -9
  89. package/lib/esm/observable/event.d.ts +2 -2
  90. package/lib/esm/observable/observable.d.ts +37 -35
  91. package/lib/esm/result.d.ts +21 -21
  92. package/lib/esm/safe.d.ts +1 -1
  93. package/lib/esm/scope/describe.d.ts +4 -4
  94. package/lib/esm/scope/display/console.d.ts +1 -1
  95. package/lib/esm/scope/display/dom.d.ts +2 -2
  96. package/lib/esm/scope/display/junit.d.ts +1 -1
  97. package/lib/esm/scope/execute.d.ts +2 -2
  98. package/lib/esm/scope/index.d.ts +3 -3
  99. package/lib/esm/scope/scope.d.ts +3 -3
  100. package/lib/esm/scope/state.d.ts +1 -1
  101. package/lib/esm/server/http/apps.d.ts +1 -1
  102. package/lib/esm/server/http/css.d.ts +1 -1
  103. package/lib/esm/server/http/index.d.ts +4 -9
  104. package/lib/esm/server/http/response.d.ts +3 -3
  105. package/lib/esm/server/http/sitemap.d.ts +1 -1
  106. package/lib/esm/server/http/static.d.ts +1 -1
  107. package/lib/esm/server/http/typescript.d.ts +1 -1
  108. package/lib/esm/test_all.d.ts +9 -9
  109. package/lib/esm/tsconfig.tsbuildinfo +1 -1
  110. package/package.json +11 -9
  111. package/src/assert.ts +5 -5
  112. package/src/components/button_bar.ts +28 -30
  113. package/src/components/inline_edit.ts +8 -7
  114. package/src/components/logger.ts +6 -6
  115. package/src/components/select.ts +7 -7
  116. package/src/components/test.ts +5 -0
  117. package/src/components/virtual_scroll.test.ts +9 -6
  118. package/src/components/virtual_scroll.ts +29 -24
  119. package/src/context.test.ts +4 -4
  120. package/src/context.ts +16 -11
  121. package/src/debounce.ts +9 -3
  122. package/src/diff.test.ts +4 -4
  123. package/src/diff.ts +14 -16
  124. package/src/dom/css/border.ts +11 -11
  125. package/src/dom/css/core.ts +1 -1
  126. package/src/dom/css/fstyle.ts +4 -4
  127. package/src/dom/css/sizing.ts +1 -1
  128. package/src/dom/dom.ts +57 -47
  129. package/src/dom/fc.test.ts +8 -8
  130. package/src/dom/fc.ts +32 -35
  131. package/src/dom/form/form.app.ts +9 -9
  132. package/src/dom/form/form.ts +25 -16
  133. package/src/dom/form/index.html +3 -2
  134. package/src/dom/html.test.ts +12 -10
  135. package/src/dom/html.ts +2 -3
  136. package/src/dom/observable.test.ts +6 -6
  137. package/src/dom/observable.ts +2 -2
  138. package/src/dom/provide.ts +1 -1
  139. package/src/dom/router/link.ts +3 -3
  140. package/src/dom/router/router.ts +5 -5
  141. package/src/dom/svg.ts +7 -6
  142. package/src/dom/test.ts +3 -0
  143. package/src/dom/types/css.ts +43 -61
  144. package/src/dom/types/html.ts +2 -4
  145. package/src/dom/xml.ts +2 -2
  146. package/src/equal.test.ts +3 -3
  147. package/src/equal.ts +27 -14
  148. package/src/flags.test.ts +2 -2
  149. package/src/flags.ts +2 -2
  150. package/src/fs.test.ts +5 -5
  151. package/src/fs.ts +26 -20
  152. package/src/fs_node.ts +4 -4
  153. package/src/fs_win.test.ts +1 -1
  154. package/src/generator.test.ts +4 -3
  155. package/src/generator.ts +1 -1
  156. package/src/hooks/_notes +4 -1
  157. package/src/index.html +7 -7
  158. package/src/lock.test.ts +4 -4
  159. package/src/lock.ts +8 -7
  160. package/src/log.ts +17 -18
  161. package/src/observable/event.ts +7 -7
  162. package/src/observable/observable.test.ts +3 -3
  163. package/src/observable/observable.ts +71 -52
  164. package/src/result.test.ts +7 -10
  165. package/src/result.ts +51 -47
  166. package/src/safe.ts +1 -1
  167. package/src/scope/describe.ts +12 -11
  168. package/src/scope/display/console.ts +4 -4
  169. package/src/scope/display/dom.ts +9 -9
  170. package/src/scope/display/junit.ts +21 -24
  171. package/src/scope/execute.ts +17 -12
  172. package/src/scope/expect.ts +22 -22
  173. package/src/scope/fix.ts +10 -7
  174. package/src/scope/index.ts +3 -3
  175. package/src/scope/scope.ts +2 -2
  176. package/src/scope/state.ts +2 -2
  177. package/src/server/http/apps.ts +5 -5
  178. package/src/server/http/css.ts +10 -26
  179. package/src/server/http/index.ts +30 -24
  180. package/src/server/http/response.ts +12 -5
  181. package/src/server/http/sitemap.ts +8 -8
  182. package/src/server/http/static.ts +9 -6
  183. package/src/server/http/typescript.ts +25 -25
  184. package/src/server/main.ts +7 -4
  185. package/src/test.mjs +8 -8
  186. package/src/test_all.ts +16 -13
  187. package/src/transpile.mjs +6 -18
  188. package/build/pico.css +0 -2466
  189. package/build/pico.css.map +0 -1
  190. package/lib/cjs/assert.js +0 -46
  191. package/lib/cjs/awaitable.js +0 -2
  192. package/lib/cjs/case.js +0 -9
  193. package/lib/cjs/components/button_bar.js +0 -29
  194. package/lib/cjs/components/inline_edit.js +0 -51
  195. package/lib/cjs/components/logger.js +0 -27
  196. package/lib/cjs/components/select.js +0 -6
  197. package/lib/cjs/components/test.js +0 -7
  198. package/lib/cjs/components/virtual_scroll.js +0 -102
  199. package/lib/cjs/components/virtual_scroll.test.js +0 -22
  200. package/lib/cjs/context.js +0 -48
  201. package/lib/cjs/context.test.js +0 -48
  202. package/lib/cjs/debounce.js +0 -12
  203. package/lib/cjs/diff.js +0 -58
  204. package/lib/cjs/diff.test.js +0 -41
  205. package/lib/cjs/display.js +0 -16
  206. package/lib/cjs/dom/css/border.js +0 -33
  207. package/lib/cjs/dom/css/constants.js +0 -31
  208. package/lib/cjs/dom/css/core.js +0 -31
  209. package/lib/cjs/dom/css/fstyle.js +0 -36
  210. package/lib/cjs/dom/css/sizing.js +0 -14
  211. package/lib/cjs/dom/dom.js +0 -110
  212. package/lib/cjs/dom/fc.js +0 -39
  213. package/lib/cjs/dom/fc.test.js +0 -23
  214. package/lib/cjs/dom/form/form.app.js +0 -27
  215. package/lib/cjs/dom/form/form.js +0 -49
  216. package/lib/cjs/dom/form/form.test.js +0 -1
  217. package/lib/cjs/dom/html.js +0 -119
  218. package/lib/cjs/dom/html.test.js +0 -60
  219. package/lib/cjs/dom/observable.js +0 -10
  220. package/lib/cjs/dom/observable.test.js +0 -35
  221. package/lib/cjs/dom/provide.js +0 -12
  222. package/lib/cjs/dom/router/link.js +0 -7
  223. package/lib/cjs/dom/router/router.js +0 -55
  224. package/lib/cjs/dom/svg.js +0 -69
  225. package/lib/cjs/dom/test.js +0 -13
  226. package/lib/cjs/dom/types/css.js +0 -24
  227. package/lib/cjs/dom/types/dom.js +0 -1
  228. package/lib/cjs/dom/types/html.js +0 -2
  229. package/lib/cjs/dom/xml.js +0 -8
  230. package/lib/cjs/equal.js +0 -48
  231. package/lib/cjs/equal.test.js +0 -22
  232. package/lib/cjs/flags.js +0 -52
  233. package/lib/cjs/flags.test.js +0 -37
  234. package/lib/cjs/fs.js +0 -235
  235. package/lib/cjs/fs.test.js +0 -86
  236. package/lib/cjs/fs_node.js +0 -50
  237. package/lib/cjs/fs_win.test.js +0 -10
  238. package/lib/cjs/generator.js +0 -14
  239. package/lib/cjs/generator.test.js +0 -26
  240. package/lib/cjs/is_browser.js +0 -4
  241. package/lib/cjs/loader-register.d.mts +0 -1
  242. package/lib/cjs/loader-register.d.ts +0 -1
  243. package/lib/cjs/loader-register.js +0 -4
  244. package/lib/cjs/loader-register.mjs +0 -4
  245. package/lib/cjs/loader.d.mts +0 -23
  246. package/lib/cjs/loader.mjs +0 -41
  247. package/lib/cjs/lock.js +0 -27
  248. package/lib/cjs/lock.test.js +0 -18
  249. package/lib/cjs/log.js +0 -103
  250. package/lib/cjs/observable/event.js +0 -61
  251. package/lib/cjs/observable/observable.js +0 -363
  252. package/lib/cjs/observable/observable.test.js +0 -65
  253. package/lib/cjs/package.json +0 -1
  254. package/lib/cjs/range.js +0 -11
  255. package/lib/cjs/result.js +0 -80
  256. package/lib/cjs/result.test.js +0 -78
  257. package/lib/cjs/safe.js +0 -14
  258. package/lib/cjs/scope/describe.js +0 -73
  259. package/lib/cjs/scope/display/console.js +0 -25
  260. package/lib/cjs/scope/display/dom.js +0 -30
  261. package/lib/cjs/scope/display/junit.js +0 -21
  262. package/lib/cjs/scope/execute.js +0 -91
  263. package/lib/cjs/scope/expect.js +0 -110
  264. package/lib/cjs/scope/fix.js +0 -26
  265. package/lib/cjs/scope/index.js +0 -15
  266. package/lib/cjs/scope/scope.js +0 -2
  267. package/lib/cjs/scope/state.js +0 -12
  268. package/lib/cjs/server/http/apps.js +0 -27
  269. package/lib/cjs/server/http/css.js +0 -54
  270. package/lib/cjs/server/http/index.js +0 -77
  271. package/lib/cjs/server/http/response.js +0 -45
  272. package/lib/cjs/server/http/sitemap.js +0 -46
  273. package/lib/cjs/server/http/static.js +0 -25
  274. package/lib/cjs/server/http/typescript.js +0 -44
  275. package/lib/cjs/server/main.js +0 -14
  276. package/lib/cjs/test.mjs +0 -28
  277. package/lib/cjs/test_all.js +0 -30
  278. package/lib/cjs/transpile.mjs +0 -22
  279. package/lib/esm/assert.js +0 -38
  280. package/lib/esm/awaitable.js +0 -1
  281. package/lib/esm/case.js +0 -5
  282. package/lib/esm/components/button_bar.js +0 -27
  283. package/lib/esm/components/inline_edit.js +0 -48
  284. package/lib/esm/components/logger.js +0 -22
  285. package/lib/esm/components/select.js +0 -3
  286. package/lib/esm/components/test.js +0 -3
  287. package/lib/esm/components/virtual_scroll.js +0 -94
  288. package/lib/esm/components/virtual_scroll.test.js +0 -20
  289. package/lib/esm/context.js +0 -43
  290. package/lib/esm/context.test.js +0 -46
  291. package/lib/esm/debounce.js +0 -8
  292. package/lib/esm/diff.js +0 -54
  293. package/lib/esm/diff.test.js +0 -39
  294. package/lib/esm/display.js +0 -11
  295. package/lib/esm/dom/css/border.js +0 -27
  296. package/lib/esm/dom/css/constants.js +0 -28
  297. package/lib/esm/dom/css/core.js +0 -24
  298. package/lib/esm/dom/css/fstyle.js +0 -32
  299. package/lib/esm/dom/css/sizing.js +0 -10
  300. package/lib/esm/dom/dom.js +0 -104
  301. package/lib/esm/dom/fc.js +0 -35
  302. package/lib/esm/dom/fc.test.js +0 -21
  303. package/lib/esm/dom/form/form.app.js +0 -23
  304. package/lib/esm/dom/form/form.js +0 -34
  305. package/lib/esm/dom/form/form.test.js +0 -1
  306. package/lib/esm/dom/html.js +0 -114
  307. package/lib/esm/dom/html.test.js +0 -58
  308. package/lib/esm/dom/observable.js +0 -6
  309. package/lib/esm/dom/observable.test.js +0 -33
  310. package/lib/esm/dom/provide.js +0 -7
  311. package/lib/esm/dom/router/link.js +0 -3
  312. package/lib/esm/dom/router/router.js +0 -52
  313. package/lib/esm/dom/svg.js +0 -65
  314. package/lib/esm/dom/test.js +0 -9
  315. package/lib/esm/dom/types/css.js +0 -23
  316. package/lib/esm/dom/types/dom.js +0 -1
  317. package/lib/esm/dom/types/html.js +0 -1
  318. package/lib/esm/dom/xml.js +0 -4
  319. package/lib/esm/equal.js +0 -41
  320. package/lib/esm/equal.test.js +0 -20
  321. package/lib/esm/flags.js +0 -48
  322. package/lib/esm/flags.test.js +0 -35
  323. package/lib/esm/fs.js +0 -226
  324. package/lib/esm/fs.test.js +0 -84
  325. package/lib/esm/fs_node.js +0 -45
  326. package/lib/esm/fs_win.test.js +0 -8
  327. package/lib/esm/generator.js +0 -10
  328. package/lib/esm/generator.test.js +0 -24
  329. package/lib/esm/is_browser.js +0 -1
  330. package/lib/esm/loader-register.d.mts +0 -1
  331. package/lib/esm/loader-register.mjs +0 -2
  332. package/lib/esm/loader.d.mts +0 -23
  333. package/lib/esm/loader.mjs +0 -36
  334. package/lib/esm/lock.js +0 -23
  335. package/lib/esm/lock.test.js +0 -16
  336. package/lib/esm/log.js +0 -93
  337. package/lib/esm/observable/event.js +0 -46
  338. package/lib/esm/observable/observable.js +0 -343
  339. package/lib/esm/observable/observable.test.js +0 -63
  340. package/lib/esm/range.js +0 -7
  341. package/lib/esm/result.js +0 -65
  342. package/lib/esm/result.test.js +0 -76
  343. package/lib/esm/safe.js +0 -10
  344. package/lib/esm/scope/describe.js +0 -60
  345. package/lib/esm/scope/display/console.js +0 -21
  346. package/lib/esm/scope/display/dom.js +0 -26
  347. package/lib/esm/scope/display/junit.js +0 -17
  348. package/lib/esm/scope/execute.js +0 -85
  349. package/lib/esm/scope/expect.js +0 -104
  350. package/lib/esm/scope/fix.js +0 -22
  351. package/lib/esm/scope/index.js +0 -3
  352. package/lib/esm/scope/scope.js +0 -1
  353. package/lib/esm/scope/state.js +0 -8
  354. package/lib/esm/server/http/apps.js +0 -23
  355. package/lib/esm/server/http/css.js +0 -50
  356. package/lib/esm/server/http/index.js +0 -73
  357. package/lib/esm/server/http/response.js +0 -40
  358. package/lib/esm/server/http/sitemap.js +0 -42
  359. package/lib/esm/server/http/static.js +0 -21
  360. package/lib/esm/server/http/typescript.js +0 -40
  361. package/lib/esm/server/main.js +0 -12
  362. package/lib/esm/test.mjs +0 -26
  363. package/lib/esm/test_all.js +0 -28
  364. package/lib/esm/transpile.mjs +0 -18
  365. package/src/components/test.js +0 -3
  366. package/src/loader-register.mjs +0 -3
  367. package/src/loader.mjs +0 -46
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.onConsole = void 0;
4
- const log_js_1 = require("../../log.js");
5
- const describe_js_1 = require("../describe.js");
6
- const execute_js_1 = require("../execute.js");
7
- const logger = (0, log_js_1.getLogger)("Scope Test Runner");
8
- function onConsole(results) {
9
- const { executed, failed } = results;
10
- logger.info("Executed test suite.", {
11
- executed,
12
- total: (0, describe_js_1.getTotalCases)(),
13
- failed,
14
- });
15
- const flat = (0, execute_js_1.flattenResults)(results);
16
- for (const { test } of flat) {
17
- logger.debug(test);
18
- }
19
- for (const { test, stack } of flat) {
20
- if (stack) {
21
- logger.error(test, { stack });
22
- }
23
- }
24
- }
25
- exports.onConsole = onConsole;
@@ -1,30 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.displayStatistics = void 0;
4
- const logger_js_1 = require("../../components/logger.js");
5
- const log_js_1 = require("../../log.js");
6
- const describe_js_1 = require("../describe.js");
7
- const execute_js_1 = require("../execute.js");
8
- function displayStatistics(results, root = document.body) {
9
- const { executed, failed } = results;
10
- const logger = (() => {
11
- try {
12
- return (0, logger_js_1.makeHTMLLogger)(`Executed ${executed} of ${(0, describe_js_1.getTotalCases)()}; ${failed} failed.`);
13
- }
14
- catch (e) {
15
- return log_js_1.DEFAULT_LOGGER;
16
- }
17
- })();
18
- logger.level = log_js_1.LEVEL.DEBUG;
19
- const flat = (0, execute_js_1.flattenResults)(results);
20
- for (const { test, stack } of flat) {
21
- if (stack) {
22
- logger.info(test);
23
- logger.debug(`${stack}`);
24
- }
25
- }
26
- if ((0, logger_js_1.isHTMLLogger)(logger)) {
27
- root.appendChild(logger.root);
28
- }
29
- }
30
- exports.displayStatistics = displayStatistics;
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.asXML = void 0;
4
- const xml_js_1 = require("../../dom/xml.js");
5
- const execute_js_1 = require("../execute.js");
6
- const cases = (results) => Object.entries(results).filter(([key]) => !["executed", "passed", "failed"].includes(key));
7
- function asXML(results) {
8
- return (`<?xml version="1.0" encoding="UTF-8" ?>` +
9
- (0, xml_js_1.xml)("testsuites", { tests: results.executed, failures: results.failed }, cases(results).map(([title, children]) => testsuite(title, children.executed, children.failed, (0, execute_js_1.flattenResults)(children)))));
10
- }
11
- exports.asXML = asXML;
12
- function testsuite(name, tests, failures, cases) {
13
- const id = name.replace("s+", "_");
14
- return (0, xml_js_1.xml)("testsuite", { id, name, tests, failures }, cases.map(({ test, stack }) => testcase({ name: `${name} ${test}` }, stack ? [stack] : [])));
15
- }
16
- function testcase({ name, id = name.replace(/\s+/g, "_"), time = "0.00", }, failures) {
17
- return (0, xml_js_1.xml)("testcase", { id, name, time }, failures.map((stack) => failure({ text: stack })));
18
- }
19
- function failure({ text, message = text.split("\n")[0], }) {
20
- return (0, xml_js_1.xml)("failure", { message }, [`<![CDATA[${text}]]>`]);
21
- }
@@ -1,91 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.flattenResults = exports.getError = exports.execute = void 0;
4
- const describe_js_1 = require("./describe.js");
5
- async function execute(cases = (0, describe_js_1.rootCases)()) {
6
- const beforeallfn = cases[describe_js_1.beforeall] ?? (() => { });
7
- const beforeeachfn = cases[describe_js_1.beforeeach] ?? (() => { });
8
- const afterallfn = cases[describe_js_1.afterall] ?? (() => { });
9
- const aftereachfn = cases[describe_js_1.aftereach] ?? (() => { });
10
- const result = { executed: 0, passed: 0, failed: 0, total: 0 };
11
- try {
12
- await beforeallfn();
13
- }
14
- catch (e) {
15
- result["_beforeAll"] = { error: e };
16
- return result;
17
- }
18
- for (const [title, block] of Object.entries(cases)) {
19
- if (typeof title === "symbol") {
20
- continue;
21
- }
22
- if (block instanceof Function) {
23
- try {
24
- result.executed += 1;
25
- await beforeeachfn();
26
- await block();
27
- await aftereachfn();
28
- result.passed += 1;
29
- result[title] = { passed: true };
30
- }
31
- catch (e) {
32
- result.failed += 1;
33
- result[title] = { error: /** @type Error */ e };
34
- }
35
- }
36
- else if (block) {
37
- const run = await execute(block);
38
- result.executed += run.executed;
39
- result.passed += run.passed;
40
- result.failed += run.failed;
41
- result[title] = run;
42
- }
43
- }
44
- try {
45
- await afterallfn();
46
- }
47
- catch (e) {
48
- result["_afterAll"] = { error: e };
49
- }
50
- return result;
51
- }
52
- exports.execute = execute;
53
- function getError({ error }) {
54
- if (typeof error == "string") {
55
- return error;
56
- }
57
- else if (error.message) {
58
- return error.stack;
59
- }
60
- else {
61
- return "unknown error";
62
- }
63
- }
64
- exports.getError = getError;
65
- function makeResult(test, result) {
66
- if (result.error)
67
- return [
68
- {
69
- test,
70
- stack: getError(result),
71
- stats: { executed: 1, failed: 1 },
72
- },
73
- ];
74
- if (result.passed === true) {
75
- return [{ test, stats: { executed: 1, failed: 0 } }];
76
- }
77
- return flattenResults(result, test);
78
- }
79
- function flattenResults(results, prefix = "") {
80
- const arrow = prefix == "" ? "" : " -> ";
81
- let errorList = [];
82
- for (const [title, result] of Object.entries(results).filter(([key]) => !["executed", "passed", "failed"].includes(key))) {
83
- const test = `${prefix}${arrow}${title}`;
84
- if (typeof result == "number")
85
- continue;
86
- const flatResult = makeResult(test, result);
87
- errorList = errorList.concat(flatResult);
88
- }
89
- return errorList;
90
- }
91
- exports.flattenResults = flattenResults;
@@ -1,110 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.expect = exports.NotMatcher = exports.Matcher = void 0;
4
- const assert_js_1 = require("../assert.js");
5
- const display_js_1 = require("../display.js");
6
- const equal_js_1 = require("../equal.js");
7
- class Matcher {
8
- actual;
9
- constructor(actual) {
10
- this.actual = actual;
11
- }
12
- get not() {
13
- return new NotMatcher(this.actual);
14
- }
15
- toBe(expected) {
16
- (0, assert_js_1.assert)(this.actual === expected, () => `${this.actual} !== ${expected}`);
17
- }
18
- toEqual(expected, partial = false) {
19
- (0, assert_js_1.assert)((0, equal_js_1.equals)(this.actual, expected, partial), () => `Objects are not equivalent: ${(0, display_js_1.display)(this.actual)}, ${(0, display_js_1.display)(expected)}`);
20
- }
21
- toMatch(expected) {
22
- (0, assert_js_1.assert)(typeof this.actual === "string", () => "Must have string for regexp match");
23
- // @ts-expect-error
24
- const actual = this.actual;
25
- if (typeof expected === "string") {
26
- (0, assert_js_1.assert)(actual.includes(expected), () => `${actual} does not include ${expected}`);
27
- }
28
- else {
29
- (0, assert_js_1.assert)(expected.test(actual), () => `${actual} does not match ${expected}`);
30
- }
31
- }
32
- toMatchObject(expected) {
33
- for (const [k, v] of Object.entries(expected)) {
34
- // @ts-expect-error
35
- const actual = this.actual[k];
36
- (0, assert_js_1.assert)((0, equal_js_1.equals)(actual, v, true), () => `Comparing ${k}, properties not equal: ${(0, display_js_1.display)(actual)}, ${(0, display_js_1.display)(v)}`);
37
- }
38
- }
39
- toBeNull() {
40
- (0, assert_js_1.assert)(this.actual === null, () => `Expected null, got ${JSON.stringify(this.actual)}`);
41
- }
42
- toThrow(message = "") {
43
- let didThrow = false;
44
- let result = undefined;
45
- try {
46
- // @ts-expect-error
47
- result = this.actual();
48
- }
49
- catch (e) {
50
- (0, assert_js_1.assert)((e.message ?? "").match(message) !== null, () => `Expected thrown message to match ${message}, got ${e}`);
51
- didThrow = true;
52
- }
53
- (0, assert_js_1.assert)(didThrow, () => `Expected throw but got ${JSON.stringify(result)}`);
54
- }
55
- }
56
- exports.Matcher = Matcher;
57
- class NotMatcher {
58
- actual;
59
- constructor(actual) {
60
- this.actual = actual;
61
- }
62
- get not() {
63
- return new Matcher(this.actual);
64
- }
65
- toBe(expected) {
66
- (0, assert_js_1.assert)(this.actual !== expected, () => `${this.actual} === ${expected}`);
67
- }
68
- toEqual(expected) {
69
- (0, assert_js_1.assert)(!(0, equal_js_1.equals)(this.actual, expected), () => `Objects are equivalent: ${JSON.stringify(this.actual)}, ${JSON.stringify(expected)}`);
70
- }
71
- toMatch(expected) {
72
- (0, assert_js_1.assert)(typeof this.actual === "string", () => "Must have string for regexp match");
73
- // @ts-expect-error
74
- const actual = this.actual;
75
- if (typeof expected === "string") {
76
- (0, assert_js_1.assert)(!actual.includes(expected), () => `${actual} includes ${expected}`);
77
- }
78
- else {
79
- (0, assert_js_1.assert)(!expected.test(actual), () => `${actual} matches ${expected}`);
80
- }
81
- }
82
- toMatchObject(expected) {
83
- for (const [k, v] of Object.entries(expected)) {
84
- // @ts-expect-error
85
- const actual = this.actual[k];
86
- (0, assert_js_1.assert)(!(0, equal_js_1.equals)(actual, v), () => `Comparing ${k}, properties equal: ${JSON.stringify(actual)}, ${JSON.stringify(v)}`);
87
- }
88
- }
89
- toBeNull() {
90
- (0, assert_js_1.assert)(this.actual !== null, () => `Expected not null`);
91
- }
92
- toThrow(message = "") {
93
- let didThrow = false;
94
- let result = undefined;
95
- try {
96
- // @ts-expect-error
97
- result = this.actual();
98
- }
99
- catch (e) {
100
- (0, assert_js_1.assert)((e.message ?? "").match(message) !== null, () => `Expected thrown message to match ${message}, got ${e}`);
101
- didThrow = true;
102
- }
103
- (0, assert_js_1.assert)(!didThrow, () => `Expected throw but got ${JSON.stringify(result)}`);
104
- }
105
- }
106
- exports.NotMatcher = NotMatcher;
107
- function expect(t) {
108
- return new Matcher(t);
109
- }
110
- exports.expect = expect;
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fix = void 0;
4
- /**
5
- * Given a value with numbers, attempt to fix all numbers to 1 decimal point.
6
- */
7
- function fix(n) {
8
- if (typeof n === "number") {
9
- // @ts-ignore
10
- return +n.toFixed(1);
11
- }
12
- if (n !== Object(n)) {
13
- // A primitive
14
- return n;
15
- }
16
- if (n instanceof Array) {
17
- // @ts-ignore
18
- return n.map(fix);
19
- }
20
- // @ts-ignore
21
- return mapreduce(fix, n);
22
- }
23
- exports.fix = fix;
24
- function mapreduce(fn, iter) {
25
- return Object.entries(iter).reduce((acc, [k, v]) => ((acc[k] = fn(v)), acc), {});
26
- }
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.it = exports.describe = exports.cleanState = exports.beforeEach = exports.beforeAll = exports.afterEach = exports.afterAll = exports.fix = exports.expect = void 0;
4
- var expect_js_1 = require("./expect.js");
5
- Object.defineProperty(exports, "expect", { enumerable: true, get: function () { return expect_js_1.expect; } });
6
- var fix_js_1 = require("./fix.js");
7
- Object.defineProperty(exports, "fix", { enumerable: true, get: function () { return fix_js_1.fix; } });
8
- var describe_js_1 = require("./describe.js");
9
- Object.defineProperty(exports, "afterAll", { enumerable: true, get: function () { return describe_js_1.afterAll; } });
10
- Object.defineProperty(exports, "afterEach", { enumerable: true, get: function () { return describe_js_1.afterEach; } });
11
- Object.defineProperty(exports, "beforeAll", { enumerable: true, get: function () { return describe_js_1.beforeAll; } });
12
- Object.defineProperty(exports, "beforeEach", { enumerable: true, get: function () { return describe_js_1.beforeEach; } });
13
- Object.defineProperty(exports, "cleanState", { enumerable: true, get: function () { return describe_js_1.cleanState; } });
14
- Object.defineProperty(exports, "describe", { enumerable: true, get: function () { return describe_js_1.describe; } });
15
- Object.defineProperty(exports, "it", { enumerable: true, get: function () { return describe_js_1.it; } });
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.cleanState = void 0;
4
- function cleanState(init, runner) {
5
- const state = {};
6
- runner(async () => {
7
- const freshState = await init();
8
- Object.assign(state, freshState);
9
- });
10
- return state;
11
- }
12
- exports.cleanState = cleanState;
@@ -1,27 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.findIndex = void 0;
4
- const fs = require("fs/promises");
5
- const path = require("path");
6
- const response_js_1 = require("./response.js");
7
- /**
8
- * Searches up the request path until the first index is found.
9
- */
10
- const findIndex = async ({ root }) => async (req) => {
11
- let filename = path.join(root, req.url ?? "");
12
- if (path.basename(filename).match(/\.[a-z]{1,3}$/)) {
13
- return undefined;
14
- }
15
- while (filename.startsWith(root)) {
16
- const index = path.join(filename, "index.html");
17
- try {
18
- const stat = await fs.stat(index);
19
- return (0, response_js_1.fileResponse)(index, stat);
20
- }
21
- catch (e) {
22
- filename = path.dirname(filename);
23
- }
24
- }
25
- return undefined;
26
- };
27
- exports.findIndex = findIndex;
@@ -1,54 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.cssFileServer = void 0;
4
- const fs = require("fs/promises");
5
- const path = require("path");
6
- const response_js_1 = require("./response.js");
7
- // @ts-ignore
8
- const sass_1 = require("sass");
9
- const { compileStringAsync } = sass_1.default;
10
- function render(source) {
11
- // Replace `from "@scope` with `from "/@scope`, for browsers
12
- // source = source
13
- // .replaceAll(`from "@`, 'from "/@')
14
- // .replaceAll(`import("@`, 'import("/@');
15
- return (0, response_js_1.contentResponse)(source, "text/css");
16
- }
17
- async function compile(filename, root, vars) {
18
- vars = vars.substring(1).replaceAll("=", ":");
19
- filename = filename.replaceAll("\\", "/"); // Normalize for dart-sass
20
- const sassString = `// Using variables: ${vars}\n${vars};\n@import "${filename}";`;
21
- return (await compileStringAsync(sassString, { loadPaths: [root] })).css;
22
- }
23
- /**
24
- * Serves .css files statically. Finds .sass files and transpiles them to css.
25
- */
26
- const cssFileServer = async ({ root, scopes = {} }) => async (req) => {
27
- const Url = new URL(req.url ?? "/", `http://${req.headers.host}`);
28
- if (Url.pathname.endsWith(".css")) {
29
- let scope = Object.entries(scopes).find(([s]) => Url.pathname.startsWith(`/${s}`));
30
- // Expand url with found scope
31
- Url.protocol = "file";
32
- let url = scope ? Url.pathname.replace(scope[0], scope[1]) : Url.pathname;
33
- let filename = path.join(root, url);
34
- try {
35
- const stat = await fs.stat(filename);
36
- if (stat.isFile()) {
37
- const css = (await fs.readFile(filename)).toString("utf-8");
38
- return render(css);
39
- }
40
- }
41
- catch { }
42
- filename = filename.replace(/\.css$/, ".scss");
43
- try {
44
- const stat = await fs.stat(filename);
45
- if (stat.isFile()) {
46
- const css = await compile(filename.replace(root, "."), root, Url.search);
47
- return render(css);
48
- }
49
- }
50
- catch { }
51
- }
52
- return undefined;
53
- };
54
- exports.cssFileServer = cssFileServer;
@@ -1,77 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.makeServer = void 0;
5
- const http_1 = require("http");
6
- const path = require("path");
7
- const log_js_1 = require("../../log.js");
8
- const apps_js_1 = require("./apps.js");
9
- const css_js_1 = require("./css.js");
10
- const response_js_1 = require("./response.js");
11
- const sitemap_js_1 = require("./sitemap.js");
12
- const static_js_1 = require("./static.js");
13
- const typescript_js_1 = require("./typescript.js");
14
- const notFound = async ({ root }) => async () => (0, response_js_1.fileResponse)(
15
- // path.join(path.dirname(FLAGS.argv0), "404.html"),
16
- path.join(root, "404.html"), undefined, 404);
17
- const BASE_MIDDLEWARES = [
18
- sitemap_js_1.sitemap,
19
- typescript_js_1.tsFileServer,
20
- css_js_1.cssFileServer,
21
- static_js_1.staticFileServer,
22
- apps_js_1.findIndex,
23
- notFound,
24
- ];
25
- const error = (res, message) => {
26
- console.error(message);
27
- res.statusCode = 500;
28
- res.write(message);
29
- res.end();
30
- return true;
31
- };
32
- const sendContent = async (res, { content, contentType, contentLength }) => {
33
- res.setHeader("Content-Length", `${contentLength}`);
34
- res.setHeader("Content-Type", contentType);
35
- await res.write(content);
36
- res.end();
37
- return true;
38
- };
39
- const log = (req) => {
40
- const when = new Date().toISOString();
41
- const who = req.socket.remoteAddress;
42
- const what = req.url;
43
- const how = `${req.method} ${what}`;
44
- (0, log_js_1.info)("Request", { when, who, how });
45
- };
46
- const makeServer = async (config, middlewares = []) => {
47
- const handlers = await Promise.all([...middlewares, ...BASE_MIDDLEWARES].map(async (m) => m(config)));
48
- const middlewareHandler = async (req, res) => {
49
- log(req);
50
- let handler;
51
- try {
52
- for (const middleware of handlers) {
53
- handler = await middleware(req);
54
- if (handler !== undefined) {
55
- break;
56
- }
57
- }
58
- if (handler) {
59
- sendContent(res, await handler());
60
- }
61
- else {
62
- res.end();
63
- }
64
- }
65
- catch (e) {
66
- error(res, e.message + "\n" + e.stack);
67
- }
68
- };
69
- // TODO(https)
70
- const server = (0, http_1.createServer)(middlewareHandler);
71
- server.on("listening", () => {
72
- const { address, port } = server.address();
73
- (0, log_js_1.info)("Server listening", { address: `http://${address}:${port}` });
74
- });
75
- return server;
76
- };
77
- exports.makeServer = makeServer;
@@ -1,45 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.contentResponse = exports.fileResponse = void 0;
4
- const fs = require("fs/promises");
5
- const MIME_TYPES = {
6
- js: "text/javascript",
7
- json: "text/javascript",
8
- css: "text/css",
9
- html: "text/html",
10
- png: "image/png",
11
- jpg: "image/jpeg",
12
- jpeg: "image/jpeg",
13
- svg: "image/svg+xml",
14
- eot: "application/vnd.ms-fontobject",
15
- ttf: "application/font-ttf",
16
- woff: "application/font-woff",
17
- woff2: "application/font-woff2",
18
- };
19
- const mime = (basename) => {
20
- const extension = basename
21
- .substring(basename.lastIndexOf(".") + 1)
22
- .toLowerCase();
23
- return MIME_TYPES[extension] ?? "application/octet-stream";
24
- };
25
- const fileResponse = (filename, stat, status = 200) => async () => {
26
- if (!stat) {
27
- stat = await fs.stat(filename);
28
- }
29
- const content = await fs.readFile(filename);
30
- const contentType = mime(filename);
31
- const contentLength = stat.size;
32
- return { status, contentType, contentLength, content };
33
- };
34
- exports.fileResponse = fileResponse;
35
- const CHARSET = "utf-8";
36
- const contentResponse = (content, contentType, status = 200) => async () => {
37
- const contentBuffer = Buffer.from(content, CHARSET);
38
- return {
39
- content: contentBuffer,
40
- contentType: contentType.split(";")[0] + "; charset=" + CHARSET,
41
- status,
42
- contentLength: contentBuffer.length,
43
- };
44
- };
45
- exports.contentResponse = contentResponse;
@@ -1,46 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.sitemap = void 0;
4
- const fs = require("fs/promises");
5
- const path = require("path");
6
- const log_js_1 = require("../../log.js");
7
- const response_js_1 = require("./response.js");
8
- const findSiteMap = async (root, prefix = root) => {
9
- if (root.startsWith("node_modules")) {
10
- return [];
11
- }
12
- const children = (await fs.readdir(root, { withFileTypes: true })).map(async (entry) => {
13
- const next = path
14
- .join(root, entry.name)
15
- // Normalize separators for web
16
- .replaceAll(path.sep, "/");
17
- if (entry.isFile()) {
18
- if (entry.name === "index.html") {
19
- let index = next.replace(prefix, "");
20
- (0, log_js_1.info)(`Adding to sitemap`, { index });
21
- return [index];
22
- }
23
- }
24
- else if (entry.isDirectory()) {
25
- if (entry.name.startsWith(".")) {
26
- return [];
27
- }
28
- const flattened = (await Promise.all(await findSiteMap(next, prefix))).flat();
29
- return flattened;
30
- }
31
- return [];
32
- });
33
- return children;
34
- };
35
- const sitemap = async ({ root }) => {
36
- const apps = await (await Promise.all(await findSiteMap(root)))
37
- .flat()
38
- .filter((a) => a !== undefined);
39
- return async (req) => {
40
- if ((req.url ?? "").endsWith("sitemap.json")) {
41
- return (0, response_js_1.contentResponse)(JSON.stringify(apps), "application/json");
42
- }
43
- return undefined;
44
- };
45
- };
46
- exports.sitemap = sitemap;
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.staticFileServer = void 0;
4
- const path = require("path");
5
- const fs = require("fs/promises");
6
- const response_js_1 = require("./response.js");
7
- const staticFileServer = async ({ root, scopes = {} }) => async (req) => {
8
- const scope = Object.entries(scopes).find(([s]) => req.url?.startsWith(`/${s}`));
9
- const url = new URL(req.url ?? "", `http://localhost`);
10
- const pathname = scope
11
- ? url.pathname.replace(scope[0], scope[1])
12
- : url.pathname;
13
- const filename = path.join(root, pathname);
14
- // Expand url with found scope
15
- console.log(scope, req.url, filename);
16
- try {
17
- const stat = await fs.stat(filename);
18
- return stat.isDirectory() ? undefined : (0, response_js_1.fileResponse)(filename, stat);
19
- }
20
- catch (e) {
21
- console.error(e);
22
- return undefined;
23
- }
24
- };
25
- exports.staticFileServer = staticFileServer;
@@ -1,44 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.tsFileServer = void 0;
4
- const fs = require("fs/promises");
5
- const path = require("path");
6
- const response_js_1 = require("./response.js");
7
- const transpile_mjs_1 = require("../../transpile.mjs");
8
- function render(source) {
9
- // Replace `from "@scope` with `from "/@scope`, for browsers
10
- source = source
11
- .replaceAll(`from "@`, 'from "/@')
12
- .replaceAll(`import("@`, 'import("/@');
13
- return (0, response_js_1.contentResponse)(source, "application/javascript");
14
- }
15
- /**
16
- * Serves .js files statically. Finds .ts files and transpiles them to JS.
17
- */
18
- const tsFileServer = async ({ root, scopes = {} }) => async (req) => {
19
- if (req.url?.endsWith(".js")) {
20
- let scope = Object.entries(scopes).find(([s]) => req.url?.startsWith(`/${s}`));
21
- // Expand url with found scope
22
- let url = scope ? req.url.replace(scope[0], scope[1]) : req.url;
23
- let filename = path.join(root, url);
24
- try {
25
- const stat = await fs.stat(filename);
26
- if (stat.isFile()) {
27
- const js = (await fs.readFile(filename)).toString("utf-8");
28
- return render(js);
29
- }
30
- }
31
- catch { }
32
- filename = filename.replace(/\.js$/, ".ts");
33
- try {
34
- const stat = await fs.stat(filename);
35
- if (stat.isFile()) {
36
- const js = await (0, transpile_mjs_1.transpile)(filename, () => fs.readFile(filename));
37
- return render(js);
38
- }
39
- }
40
- catch { }
41
- }
42
- return undefined;
43
- };
44
- exports.tsFileServer = tsFileServer;