@davidsouther/jiffies 2.2.4 → 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 +9 -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 +9 -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 +28 -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 -98
  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 -88
  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,6 +1,6 @@
1
- import { debounce } from "../debounce.js";
2
- import { FC, State } from "../dom/fc.js";
3
- import { div } from "../dom/html.js";
1
+ import { debounce } from "../debounce.ts";
2
+ import { FC, State } from "../dom/fc.ts";
3
+ import { div } from "../dom/html.ts";
4
4
 
5
5
  export interface VirtualScrollSettings {
6
6
  minIndex: number;
@@ -11,9 +11,10 @@ export interface VirtualScrollSettings {
11
11
  tolerance: number;
12
12
  }
13
13
 
14
- export interface VirtualScrollDataAdapter<T> {
15
- (offset: number, limit: number): Iterable<T>;
16
- }
14
+ export type VirtualScrollDataAdapter<T> = (
15
+ offset: number,
16
+ limit: number,
17
+ ) => Iterable<T>;
17
18
 
18
19
  export function arrayAdapter<T>(data: T[]): VirtualScrollDataAdapter<T> {
19
20
  return (offset, limit) => data.slice(offset, offset + limit);
@@ -26,7 +27,7 @@ export interface VirtualScrollProps<T, U extends HTMLElement> {
26
27
  }
27
28
 
28
29
  export function fillVirtualScrollSettings(
29
- settings: Partial<VirtualScrollSettings>
30
+ settings: Partial<VirtualScrollSettings>,
30
31
  ): VirtualScrollSettings {
31
32
  const {
32
33
  minIndex = 0,
@@ -41,7 +42,7 @@ export function fillVirtualScrollSettings(
41
42
  }
42
43
 
43
44
  export function initialState<T>(
44
- settings: VirtualScrollSettings
45
+ settings: VirtualScrollSettings,
45
46
  ): VirtualScrollState<T> {
46
47
  // From Denis Hilt, https://blog.logrocket.com/virtual-scrolling-core-principles-and-basic-implementation-in-react/
47
48
  const { minIndex, maxIndex, startIndex, itemHeight, count, tolerance } =
@@ -75,7 +76,7 @@ export function getData<T>(
75
76
  maxIndex: number,
76
77
  offset: number,
77
78
  limit: number,
78
- get: VirtualScrollDataAdapter<T>
79
+ get: VirtualScrollDataAdapter<T>,
79
80
  ): T[] {
80
81
  const start = Math.max(0, minIndex, offset);
81
82
  const end = Math.min(maxIndex, offset + limit - 1);
@@ -86,7 +87,7 @@ export function getData<T>(
86
87
  export function doScroll<T>(
87
88
  scrollTop: number,
88
89
  state: VirtualScrollState<T>,
89
- get: VirtualScrollDataAdapter<T>
90
+ get: VirtualScrollDataAdapter<T>,
90
91
  ): {
91
92
  scrollTop: number;
92
93
  topPaddingHeight: number;
@@ -105,7 +106,7 @@ export function doScroll<T>(
105
106
  const topPaddingHeight = Math.max((index - minIndex) * itemHeight, 0);
106
107
  const bottomPaddingHeight = Math.max(
107
108
  totalHeight - (topPaddingHeight + data.length * itemHeight),
108
- 0
109
+ 0,
109
110
  );
110
111
 
111
112
  return { scrollTop, topPaddingHeight, bottomPaddingHeight, data };
@@ -124,23 +125,24 @@ interface VirtualScrollState<T, U extends HTMLElement = HTMLElement> {
124
125
  rows: U[];
125
126
  }
126
127
 
127
- // export interface VirtualScroll<T, U extends HTMLElement> {
128
- // state: VirtualScrollState<T>;
129
- // rows: UHTMLElement<U>[];
130
- // }
128
+ export interface VirtualScroll<T, U extends HTMLElement> {
129
+ state: VirtualScrollState<T>;
130
+ rows: U[];
131
+ }
131
132
 
132
133
  export const VirtualScroll = FC<
133
- VirtualScrollProps<any, HTMLElement>,
134
- VirtualScrollState<any, HTMLElement>
134
+ VirtualScrollProps<unknown, HTMLElement>,
135
+ VirtualScrollState<unknown, HTMLElement>
135
136
  >("virtual-scroll", (element, props) => {
136
137
  const settings = fillVirtualScrollSettings(props.settings);
137
- const state = (element[State] = {
138
+ const state = {
138
139
  ...initialState(settings),
139
140
  ...element[State],
140
- });
141
+ };
142
+ element[State] = state;
141
143
 
142
144
  const scrollTo = (
143
- { target }: { target?: { scrollTop: number } } = { target: state }
145
+ { target }: { target?: { scrollTop: number } } = { target: state },
144
146
  ) => {
145
147
  const scrollTop = target?.scrollTop ?? state.topPaddingHeight;
146
148
  const updatedSate = {
@@ -152,7 +154,10 @@ export const VirtualScroll = FC<
152
154
 
153
155
  const viewportElement = div({
154
156
  style: { height: `${state.viewportHeight}px`, overflowY: "scroll" },
155
- events: { scroll: debounce(scrollTo, 0) },
157
+ events: {
158
+ // @ts-expect-error
159
+ scroll: debounce(scrollTo, 0),
160
+ },
156
161
  });
157
162
  setTimeout(() => {
158
163
  viewportElement.scroll({ top: state.scrollTop });
@@ -176,13 +181,13 @@ export const VirtualScroll = FC<
176
181
  class: `VirtualScroll__item_${i}`,
177
182
  style: { height: `${settings.itemHeight}px` },
178
183
  },
179
- row
180
- )
184
+ row,
185
+ ),
181
186
  ),
182
187
  div({
183
188
  class: "VirtualScroll__bottomPadding",
184
189
  style: { height: `${state.bottomPaddingHeight}px` },
185
- })
190
+ }),
186
191
  );
187
192
  };
188
193
 
@@ -1,7 +1,7 @@
1
- import { Context, Enter, Exit, using } from "./context.js";
2
- import { Err, isErr, isOk, Ok, unwrap } from "./result.js";
3
- import { describe, it } from "./scope/describe.js";
4
- import { expect } from "./scope/expect.js";
1
+ import { type Context, Enter, Exit, using } from "./context.ts";
2
+ import { Err, isErr, isOk, Ok, unwrap } from "./result.ts";
3
+ import { describe, it } from "./scope/describe.ts";
4
+ import { expect } from "./scope/expect.ts";
5
5
 
6
6
  describe("Context", () => {
7
7
  it("performs an operation using a context", () => {
package/src/context.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Ok, Err, isResult, Result } from "./result.js";
1
+ import { Err, isResult, Ok, type Result } from "./result.ts";
2
2
 
3
3
  export const Enter = Symbol("Context Enter");
4
4
  export const Exit = Symbol("Context Exit");
@@ -8,18 +8,20 @@ export interface Context {
8
8
  [Exit]: () => void;
9
9
  }
10
10
 
11
- export interface Operation<T, E extends Error, C extends Context> {
12
- (c: C): T | Result<T, E>;
13
- }
11
+ export type Operation<T, E extends Error, C extends Context> = (
12
+ c: C,
13
+ ) => T | Result<T, E>;
14
14
 
15
- export interface AsyncOperation<T, E extends Error, C extends Context> {
16
- (c: C): Promise<T | Result<T, E>>;
17
- }
15
+ export type AsyncOperation<T, E extends Error, C extends Context> = (
16
+ c: C,
17
+ ) => Promise<T | Result<T, E>>;
18
18
 
19
19
  export function using<T, E extends Error, C extends Context>(
20
20
  context: C | (() => C) | Operation<T, E, C>,
21
21
  operation?: Operation<T, E, C>,
22
- normalizeError: (e: Error | unknown | any) => Err<E> = (e) => Err(e)
22
+ normalizeError: (e: Error | unknown) => Err<E> = (e) =>
23
+ // @ts-expect-error
24
+ Err(e),
23
25
  ): Result<T, E> {
24
26
  if (typeof context === "function") {
25
27
  if (context.length === 1) {
@@ -32,7 +34,7 @@ export function using<T, E extends Error, C extends Context>(
32
34
  let result: Result<T, E>;
33
35
  try {
34
36
  context[Enter]();
35
- const op = operation!(context);
37
+ const op = operation?.(context);
36
38
  result = isResult(op as Result<T, E>) ? (op as Result<T, E>) : Ok(op as T);
37
39
  } catch (e) {
38
40
  result = normalizeError(e);
@@ -45,7 +47,7 @@ export function using<T, E extends Error, C extends Context>(
45
47
  export async function asyncUsing<T, E extends Error, C extends Context>(
46
48
  context: C | (() => Promise<C>),
47
49
  operation: AsyncOperation<T, E, C>,
48
- normalizeError: (e: Error | unknown | any) => Err<E> = (e: E) => Err(e)
50
+ normalizeError: (e: E) => Err<E> = (e: E) => Err(e),
49
51
  ): Promise<Result<T, E>> {
50
52
  context = typeof context === "function" ? await context() : context;
51
53
  let result: Result<T, E>;
@@ -54,7 +56,10 @@ export async function asyncUsing<T, E extends Error, C extends Context>(
54
56
  const op = await operation(context);
55
57
  result = isResult(op as Result<T, E>) ? (op as Result<T, E>) : Ok(op as T);
56
58
  } catch (e) {
57
- result = normalizeError(e);
59
+ result = normalizeError(
60
+ // @ts-expect-error
61
+ e,
62
+ );
58
63
  } finally {
59
64
  context[Exit]();
60
65
  }
package/src/debounce.ts CHANGED
@@ -1,8 +1,14 @@
1
- export function debounce(fn: (...args: any[]) => any, ms = 32) {
1
+ export function debounce<T extends unknown[]>(
2
+ fn: (...args: T) => void,
3
+ ms = 32,
4
+ ): (...args: T) => void {
2
5
  let timer: ReturnType<typeof setTimeout>;
3
- return (...args: Parameters<typeof fn>) => {
6
+ return (...args: T) => {
4
7
  clearTimeout(timer);
5
- timer = setTimeout(() => (clearTimeout(timer), fn(...args)), ms);
8
+ timer = setTimeout(() => {
9
+ clearTimeout(timer);
10
+ return fn(...args);
11
+ }, ms);
6
12
  return timer;
7
13
  };
8
14
  }
package/src/diff.test.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { diff } from "./diff.js";
2
- import { describe, it } from "./scope/describe.js";
3
- import { expect } from "./scope/expect.js";
1
+ import { diff } from "./diff.ts";
2
+ import { describe, it } from "./scope/describe.ts";
3
+ import { expect } from "./scope/expect.ts";
4
4
 
5
5
  describe("diff", () => {
6
6
  it("diffs primitives", () => {
@@ -36,7 +36,7 @@ describe("diff", () => {
36
36
  it("diffs objects in an array", () => {
37
37
  const diffed = diff(
38
38
  [{ a: { b: 1 } }, { a: { b: 2 } }, { a: { b: 3 } }],
39
- [{ a: { b: 1 } }, { a: { b: 4 } }, { a: { b: 3 } }]
39
+ [{ a: { b: 1 } }, { a: { b: 4 } }, { a: { b: 3 } }],
40
40
  );
41
41
  expect(diffed).toEqual([
42
42
  {
package/src/diff.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { range } from "./range.js";
2
- import { isSome, None, Option, Some } from "./result.js";
1
+ import { range } from "./range.ts";
2
+ import { isSome, None, type Option, Some } from "./result.ts";
3
3
 
4
4
  export const DiffA = Symbol("A");
5
5
  export const DiffB = Symbol("B");
@@ -20,29 +20,27 @@ interface DiffList {
20
20
 
21
21
  function doDiff<T>(va: T, vb: T, k: DiffIndex): Option<DiffList | DiffEntry> {
22
22
  if (Array.isArray(va)) {
23
- // @ts-ignore
23
+ // @ts-expect-error
24
24
  return diffArray(va, vb, k);
25
25
  }
26
26
  if (typeof va === "object") {
27
- const d = diffObject(va, vb, k);
27
+ const d = diffObject(va ?? {}, vb ?? {}, k);
28
28
  if (d.children.length === 0) {
29
29
  return None();
30
- } else {
31
- return Some(d);
32
30
  }
31
+ return Some(d);
33
32
  }
34
33
  if (Object.is(va, vb)) {
35
34
  return None();
36
- } else {
37
- // @ts-ignore
38
- return { key: k, left: va, right: vb };
39
35
  }
36
+ // @ts-expect-error
37
+ return { key: k, left: va, right: vb };
40
38
  }
41
39
 
42
40
  function diffArray<T>(
43
41
  a: Partial<T>[],
44
42
  b: Partial<T>[],
45
- key: DiffIndex
43
+ key: DiffIndex,
46
44
  ): Option<DiffList> {
47
45
  const indexes = Math.max(a.length, b.length);
48
46
  const children = range(0, indexes)
@@ -54,11 +52,11 @@ function diffArray<T>(
54
52
  function diffObject<T>(
55
53
  a: Partial<T>,
56
54
  b: Partial<T>,
57
- key: DiffIndex = ""
55
+ key: DiffIndex = "",
58
56
  ): DiffList {
59
57
  const keys = new Set([...Object.keys(a), ...Object.keys(b)]);
60
58
  const children = [...keys]
61
- // @ts-ignore
59
+ // @ts-expect-error
62
60
  .map((k) => doDiff(a[k], b[k], k))
63
61
  .filter(isSome);
64
62
  return {
@@ -69,16 +67,16 @@ function diffObject<T>(
69
67
 
70
68
  export function diff<T>(
71
69
  a: Partial<T>,
72
- b: Partial<T>
70
+ b: Partial<T>,
73
71
  ): (DiffEntry | DiffList)[] {
74
- if (typeof a != "object" && !Object.is(a, b)) {
75
- // @ts-ignore
72
+ if (typeof a !== "object" && !Object.is(a, b)) {
73
+ // @ts-expect-error
76
74
  return [{ key: "", left: a, right: b }];
77
75
  }
78
76
  return (
79
77
  Array.isArray(a)
80
78
  ? // @ts-ignore
81
- diffArray(a, b, "") ?? { children: [] }
79
+ (diffArray(a, b, "") ?? { children: [] })
82
80
  : diffObject(a, b, "")
83
81
  ).children;
84
82
  }
@@ -1,6 +1,6 @@
1
- import { Properties } from "../types/css.js"
2
- import { Side, Size } from "./constants.js"
3
- import { isSide, getSize, getSide } from "./core.js"
1
+ import type { Properties } from "../types/css.ts";
2
+ import type { Side, Size } from "./constants.ts";
3
+ import { getSide, getSize, isSide } from "./core.ts";
4
4
 
5
5
  export function rounded(size: Size = "", side: Side = "") {
6
6
  if (isSide(size)) {
@@ -12,7 +12,7 @@ export function rounded(size: Size = "", side: Side = "") {
12
12
  if (curr === "") {
13
13
  prev.borderRadius = sized;
14
14
  } else {
15
- // @ts-ignore
15
+ // @ts-expect-error
16
16
  prev[`border${curr}Radius`] = sized;
17
17
  }
18
18
  return prev;
@@ -20,11 +20,11 @@ export function rounded(size: Size = "", side: Side = "") {
20
20
  }
21
21
 
22
22
  export function border({
23
- side = "",
24
- style = "solid",
25
- radius = "",
26
- width = 1,
27
- color = "black",
23
+ side: _side = "",
24
+ style: _style = "solid",
25
+ radius: _radius = "",
26
+ width: _width = 1,
27
+ color: _color = "black",
28
28
  }: {
29
29
  side?: Side;
30
30
  style?: "solid" | "dotted" | "dashed" | "double" | "none";
@@ -37,8 +37,8 @@ export function border({
37
37
 
38
38
  export function inset(
39
39
  width: 0 | 1 | 2 | 4 | 8,
40
- color1: string = "gray",
41
- color2: string = "lightgray"
40
+ color1 = "gray",
41
+ color2 = "lightgray",
42
42
  ) {
43
43
  return {
44
44
  ...border({ side: "tl", width, color: color1, radius: "none" }),
@@ -1,4 +1,4 @@
1
- import { Side, Sides, Size, Sizes } from "./constants.js"
1
+ import { type Side, Sides, type Size, Sizes } from "./constants.ts";
2
2
 
3
3
  export function isSide(v: string): v is Side {
4
4
  return Sides[v as keyof typeof Sides] !== undefined;
@@ -1,5 +1,5 @@
1
- import { dashCase } from "../../case.js"
2
- import { Properties } from "../types/css.js"
1
+ import { dashCase } from "../../case.ts";
2
+ import type { Properties } from "../types/css.ts";
3
3
 
4
4
  export type FStyle =
5
5
  | Properties
@@ -12,7 +12,7 @@ export function compileFStyle(fstyle: FStyle, prefix = ""): string {
12
12
  const rules: { key: string; value: FStyle }[] = [];
13
13
 
14
14
  for (const [key, value] of Object.entries(fstyle)) {
15
- if (typeof value == "string") {
15
+ if (typeof value === "string") {
16
16
  properties.push({ key, value });
17
17
  } else {
18
18
  rules.push({ key, value });
@@ -33,7 +33,7 @@ export function compileFStyle(fstyle: FStyle, prefix = ""): string {
33
33
  if (key.startsWith("@media")) {
34
34
  rule += `${key} {\n`;
35
35
  rule += compileFStyle(value, " ");
36
- rule += `}\n\n`;
36
+ rule += "}\n\n";
37
37
  } else {
38
38
  rule += compileFStyle(value, `${prefix} ${key}`);
39
39
  }
@@ -1,4 +1,4 @@
1
- import { Width, Widths } from "./constants.js"
1
+ import { type Width, Widths } from "./constants.ts";
2
2
 
3
3
  export function width(amount: Width, block?: "inline") {
4
4
  if (amount === undefined && Widths[block as Width] !== undefined) {
package/src/dom/dom.ts CHANGED
@@ -1,4 +1,8 @@
1
- import { Properties } from "./types/css.js";
1
+ import { assertExists } from "../assert.ts";
2
+ import type { Properties as SVGProperties } from "./types/css.ts";
3
+
4
+ export const XHTML_NAMESPACE_URI = "http://www.w3.org/1999/xhtml";
5
+ export const SVG_NAMESPACE_URI = "http://www.w3.org/2000/svg";
2
6
 
3
7
  const Events = Symbol("events");
4
8
  export const CLEAR = Symbol("Clear children");
@@ -10,18 +14,18 @@ export type DOMElement = Element & ElementCSSInlineStyle;
10
14
 
11
15
  export type DomAttrs = {
12
16
  class: string | string[];
13
- style: Partial<Properties> | string;
17
+ style: Partial<SVGProperties> | string;
14
18
  role: "button" | "list" | "listbox";
15
19
  events: Partial<{
16
20
  [K in keyof HTMLElementEventMap]: EventHandler | null;
17
21
  }>;
18
22
  };
19
23
 
20
- export type Attrs<E extends Omit<Element, "update">, S = {}> = Partial<
21
- Omit<E, "style"> & S & DomAttrs
24
+ export type Attrs<E extends Omit<Element, "update">, S = object> = Partial<
25
+ Omit<{ [k in keyof E]: string | number | boolean }, "style"> & S & DomAttrs
22
26
  >;
23
27
 
24
- export type DenormAttrs<E extends Omit<Element, "update">, S = {}> =
28
+ export type DenormAttrs<E extends Omit<Element, "update">, S = object> =
25
29
  | Attrs<E, S>
26
30
  | DenormChildren;
27
31
 
@@ -79,57 +83,63 @@ export function update(
79
83
  children: DenormChildren[]
80
84
  ): Element {
81
85
  // Track events, to remove later
82
- const $events = (element[Events] ??= new Map<string, EventHandler>());
83
- const { style = {}, events = {}, ...rest } = attrs;
84
-
85
- Object.entries(events as NonNullable<typeof attrs.events>).forEach(
86
- ([k, v]) => {
87
- if (v === null) {
88
- if ($events.has(k)) {
89
- const listener = $events.get(k)!;
90
- element.removeEventListener(k, listener);
91
- }
92
- } else if (v !== undefined) {
93
- element.addEventListener(k as keyof ElementEventMap, v);
94
- $events.set(k, v);
86
+ element[Events] ??= new Map<string, EventHandler>();
87
+ const $events = element[Events];
88
+ // const { style = {}, events = {}, ...rest } = attrs;
89
+
90
+ for (const [k, v] of Object.entries(
91
+ (attrs.events as NonNullable<typeof attrs.events>) ?? {}
92
+ )) {
93
+ if (v === null) {
94
+ if ($events.has(k)) {
95
+ const listener = assertExists($events.get(k));
96
+ element.removeEventListener(k, listener);
95
97
  }
98
+ } else if (v !== undefined) {
99
+ element.addEventListener(k as keyof ElementEventMap, v);
100
+ $events.set(k, v);
96
101
  }
97
- );
102
+ }
98
103
 
99
104
  const _style = (element as { style?: Partial<CSSStyleDeclaration> }).style;
100
105
  if (_style) {
101
- if (typeof style === "string") {
102
- _style.cssText = style;
106
+ if (typeof attrs.style === "string") {
107
+ _style.cssText = attrs.style;
103
108
  } else {
104
- Object.entries(style as Partial<CSSStyleDeclaration>).forEach(
105
- ([k, v]) => {
106
- // @ts-ignore Object.entries is unable to statically look into args
107
- _style[k] = v;
108
- }
109
- );
109
+ for (const [k, v] of Object.entries(
110
+ (attrs.style as Partial<CSSStyleDeclaration>) ?? {}
111
+ )) {
112
+ // @ts-expect-error Object.entries is unable to statically look into args
113
+ _style[k] = v;
114
+ }
110
115
  }
111
116
  }
112
117
 
113
- Object.entries(rest).forEach(([k, v]) => {
118
+ for (const [k, v] of Object.entries(attrs)) {
119
+ if (k === "style") {
120
+ continue;
121
+ }
122
+
123
+ if (k === "events") {
124
+ continue;
125
+ }
126
+
114
127
  if (k === "class") {
115
- v = Array.isArray(v)
116
- ? v
117
- : (typeof v === "string" ? v : `${v}`).split(/\s+/m);
118
- (v as string[])
119
- .filter((s) => s !== "")
120
- .forEach((c) => {
121
- if (c.startsWith("!")) {
122
- element.classList.remove(c.substring(1));
123
- } else {
124
- element.classList.add(c);
125
- }
126
- });
127
- return;
128
+ const cs = Array.isArray(v) ? v : String(v).split(/\s+/m).filter(Boolean);
129
+ for (const c of cs) {
130
+ if (c.startsWith("!")) {
131
+ element.classList.remove(c.substring(1));
132
+ } else {
133
+ element.classList.add(c);
134
+ }
135
+ }
136
+ continue;
128
137
  }
129
138
 
130
- const useNamespace =
131
- element.namespaceURI &&
132
- element.namespaceURI != "http://www.w3.org/1999/xhtml";
139
+ const useNamespace = false;
140
+ element.namespaceURI &&
141
+ element.namespaceURI !== XHTML_NAMESPACE_URI &&
142
+ element.namespaceURI !== SVG_NAMESPACE_URI;
133
143
  const remove = !v;
134
144
 
135
145
  if (useNamespace) {
@@ -138,7 +148,7 @@ export function update(
138
148
  } else if (v === true) {
139
149
  element.setAttributeNS(element.namespaceURI, k, k);
140
150
  } else {
141
- element.setAttributeNS(element.namespaceURI, k, v as string);
151
+ element.setAttributeNS(element.namespaceURI, k, String(v));
142
152
  }
143
153
  } else {
144
154
  if (remove) {
@@ -146,10 +156,10 @@ export function update(
146
156
  } else if (v === true) {
147
157
  element.setAttribute(k, k);
148
158
  } else {
149
- element.setAttribute(k, v as string);
159
+ element.setAttribute(k, String(v));
150
160
  }
151
161
  }
152
- });
162
+ }
153
163
 
154
164
  if (children?.length > 0) {
155
165
  element.replaceChildren(
@@ -1,6 +1,6 @@
1
- import { describe, it, expect } from "../scope/index.js";
2
- import { button, div, form, input, label, small } from "./html.js";
3
- import { FC } from "./fc.js";
1
+ import { describe, expect, it } from "../scope/index.ts";
2
+ import { FC } from "./fc.ts";
3
+ import { button, div, form, input, label, small } from "./html.ts";
4
4
 
5
5
  describe("FC", () => {
6
6
  it("creates FCs", () => {
@@ -9,8 +9,8 @@ describe("FC", () => {
9
9
  name: string;
10
10
  required?: boolean;
11
11
  type?: string;
12
- }>("fc-input", (el, attrs, children) =>
13
- label(attrs.placeholder ?? attrs.name, input(attrs), ...children)
12
+ }>("fc-input", (_el, attrs, children) =>
13
+ label(attrs.placeholder ?? attrs.name, input(attrs), ...children),
14
14
  );
15
15
 
16
16
  const f = form(
@@ -26,13 +26,13 @@ describe("FC", () => {
26
26
  name: "lastName",
27
27
  placeholder: "Last Name",
28
28
  required: true,
29
- })
29
+ }),
30
30
  ),
31
31
  Input(
32
32
  { name: "email", type: "email", placeholder: "E-Mail" },
33
- small("We'll never share your information.")
33
+ small("We'll never share your information."),
34
34
  ),
35
- button({ type: "submit" }, "Submit")
35
+ button({ type: "submit" }, "Submit"),
36
36
  );
37
37
 
38
38
  // document.body.appendChild(f);