@gtkx/utils 0.21.0 → 1.0.0-rc.2

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 (307) hide show
  1. package/README.md +173 -0
  2. package/dist/array/index-before-or-end.d.ts +15 -0
  3. package/dist/array/index-before-or-end.d.ts.map +1 -0
  4. package/dist/array/index-before-or-end.js +21 -0
  5. package/dist/array/index-before-or-end.js.map +1 -0
  6. package/dist/array/index.d.ts +6 -0
  7. package/dist/array/index.d.ts.map +1 -0
  8. package/dist/array/index.js +6 -0
  9. package/dist/array/index.js.map +1 -0
  10. package/dist/array/remove.d.ts +14 -0
  11. package/dist/array/remove.d.ts.map +1 -0
  12. package/dist/array/remove.js +19 -0
  13. package/dist/array/remove.js.map +1 -0
  14. package/dist/array/sort-strings-by.d.ts +15 -0
  15. package/dist/array/sort-strings-by.d.ts.map +1 -0
  16. package/dist/array/sort-strings-by.js +17 -0
  17. package/dist/array/sort-strings-by.js.map +1 -0
  18. package/dist/array/sort-strings.d.ts +12 -0
  19. package/dist/array/sort-strings.d.ts.map +1 -0
  20. package/dist/array/sort-strings.js +14 -0
  21. package/dist/array/sort-strings.js.map +1 -0
  22. package/dist/array/uniq-by.d.ts +18 -0
  23. package/dist/array/uniq-by.d.ts.map +1 -0
  24. package/dist/array/uniq-by.js +29 -0
  25. package/dist/array/uniq-by.js.map +1 -0
  26. package/dist/class/any-class.d.ts +8 -0
  27. package/dist/class/any-class.d.ts.map +1 -0
  28. package/dist/class/any-class.js +2 -0
  29. package/dist/class/any-class.js.map +1 -0
  30. package/dist/class/get-parent-class.d.ts +10 -0
  31. package/dist/class/get-parent-class.d.ts.map +1 -0
  32. package/dist/class/get-parent-class.js +12 -0
  33. package/dist/class/get-parent-class.js.map +1 -0
  34. package/dist/class/index.d.ts +4 -0
  35. package/dist/class/index.d.ts.map +1 -0
  36. package/dist/class/index.js +3 -0
  37. package/dist/class/index.js.map +1 -0
  38. package/dist/class/walk-class-chain.d.ts +13 -0
  39. package/dist/class/walk-class-chain.d.ts.map +1 -0
  40. package/dist/class/walk-class-chain.js +23 -0
  41. package/dist/class/walk-class-chain.js.map +1 -0
  42. package/dist/error/error-like.d.ts +6 -0
  43. package/dist/error/error-like.d.ts.map +1 -0
  44. package/dist/error/error-like.js +15 -0
  45. package/dist/error/error-like.js.map +1 -0
  46. package/dist/error/error-message.d.ts +13 -0
  47. package/dist/error/error-message.d.ts.map +1 -0
  48. package/dist/error/error-message.js +16 -0
  49. package/dist/error/error-message.js.map +1 -0
  50. package/dist/error/format-child-process-error.d.ts +12 -0
  51. package/dist/error/format-child-process-error.d.ts.map +1 -0
  52. package/dist/error/format-child-process-error.js +21 -0
  53. package/dist/error/format-child-process-error.js.map +1 -0
  54. package/dist/error/index.d.ts +4 -0
  55. package/dist/error/index.d.ts.map +1 -0
  56. package/dist/error/index.js +4 -0
  57. package/dist/error/index.js.map +1 -0
  58. package/dist/error/normalize-error.d.ts +13 -0
  59. package/dist/error/normalize-error.d.ts.map +1 -0
  60. package/dist/error/normalize-error.js +20 -0
  61. package/dist/error/normalize-error.js.map +1 -0
  62. package/dist/function/call-method.d.ts +3 -0
  63. package/dist/function/call-method.d.ts.map +1 -0
  64. package/dist/function/call-method.js +19 -0
  65. package/dist/function/call-method.js.map +1 -0
  66. package/dist/function/index.d.ts +2 -0
  67. package/dist/function/index.d.ts.map +1 -0
  68. package/dist/function/index.js +2 -0
  69. package/dist/function/index.js.map +1 -0
  70. package/dist/index.d.ts +13 -6
  71. package/dist/index.d.ts.map +1 -1
  72. package/dist/index.js +13 -5
  73. package/dist/index.js.map +1 -1
  74. package/dist/log/create-logger.d.ts +15 -0
  75. package/dist/log/create-logger.d.ts.map +1 -0
  76. package/dist/log/create-logger.js +17 -0
  77. package/dist/log/create-logger.js.map +1 -0
  78. package/dist/log/default-logger.d.ts +36 -0
  79. package/dist/log/default-logger.d.ts.map +1 -0
  80. package/dist/log/default-logger.js +44 -0
  81. package/dist/log/default-logger.js.map +1 -0
  82. package/dist/log/index.d.ts +4 -0
  83. package/dist/log/index.d.ts.map +1 -0
  84. package/dist/log/index.js +4 -0
  85. package/dist/log/index.js.map +1 -0
  86. package/dist/log/logger.d.ts +64 -0
  87. package/dist/log/logger.d.ts.map +1 -0
  88. package/dist/log/logger.js +100 -0
  89. package/dist/log/logger.js.map +1 -0
  90. package/dist/map/get-or-insert.d.ts +23 -0
  91. package/dist/map/get-or-insert.d.ts.map +1 -0
  92. package/dist/map/get-or-insert.js +25 -0
  93. package/dist/map/get-or-insert.js.map +1 -0
  94. package/dist/map/index.d.ts +2 -0
  95. package/dist/map/index.d.ts.map +1 -0
  96. package/dist/map/index.js +2 -0
  97. package/dist/map/index.js.map +1 -0
  98. package/dist/object/index.d.ts +4 -0
  99. package/dist/object/index.d.ts.map +1 -0
  100. package/dist/object/index.js +4 -0
  101. package/dist/object/index.js.map +1 -0
  102. package/dist/object/omit.d.ts +15 -0
  103. package/dist/object/omit.d.ts.map +1 -0
  104. package/dist/object/omit.js +24 -0
  105. package/dist/object/omit.js.map +1 -0
  106. package/dist/object/pick-by.d.ts +15 -0
  107. package/dist/object/pick-by.d.ts.map +1 -0
  108. package/dist/object/pick-by.js +24 -0
  109. package/dist/object/pick-by.js.map +1 -0
  110. package/dist/object/structured-clone.d.ts +19 -0
  111. package/dist/object/structured-clone.d.ts.map +1 -0
  112. package/dist/object/structured-clone.js +28 -0
  113. package/dist/object/structured-clone.js.map +1 -0
  114. package/dist/predicate/are-object-keys-equal.d.ts +3 -0
  115. package/dist/predicate/are-object-keys-equal.d.ts.map +1 -0
  116. package/dist/predicate/are-object-keys-equal.js +9 -0
  117. package/dist/predicate/are-object-keys-equal.js.map +1 -0
  118. package/dist/predicate/index.d.ts +7 -0
  119. package/dist/predicate/index.d.ts.map +1 -0
  120. package/dist/predicate/index.js +7 -0
  121. package/dist/predicate/index.js.map +1 -0
  122. package/dist/predicate/is-deep-equal.d.ts +3 -0
  123. package/dist/predicate/is-deep-equal.d.ts.map +1 -0
  124. package/dist/predicate/is-deep-equal.js +35 -0
  125. package/dist/predicate/is-deep-equal.js.map +1 -0
  126. package/dist/predicate/is-plain-object.d.ts +17 -0
  127. package/dist/predicate/is-plain-object.d.ts.map +1 -0
  128. package/dist/predicate/is-plain-object.js +23 -0
  129. package/dist/predicate/is-plain-object.js.map +1 -0
  130. package/dist/predicate/is-record.d.ts +14 -0
  131. package/dist/predicate/is-record.d.ts.map +1 -0
  132. package/dist/predicate/is-record.js +16 -0
  133. package/dist/predicate/is-record.js.map +1 -0
  134. package/dist/predicate/is-same-array-by.d.ts +15 -0
  135. package/dist/predicate/is-same-array-by.d.ts.map +1 -0
  136. package/dist/predicate/is-same-array-by.js +20 -0
  137. package/dist/predicate/is-same-array-by.js.map +1 -0
  138. package/dist/predicate/is-same-array.d.ts +15 -0
  139. package/dist/predicate/is-same-array.d.ts.map +1 -0
  140. package/dist/predicate/is-same-array.js +18 -0
  141. package/dist/predicate/is-same-array.js.map +1 -0
  142. package/dist/predicate/is-shallow-equal.d.ts +3 -0
  143. package/dist/predicate/is-shallow-equal.d.ts.map +1 -0
  144. package/dist/predicate/is-shallow-equal.js +28 -0
  145. package/dist/predicate/is-shallow-equal.js.map +1 -0
  146. package/dist/process/exit-code-for-signal.d.ts +14 -0
  147. package/dist/process/exit-code-for-signal.d.ts.map +1 -0
  148. package/dist/process/exit-code-for-signal.js +19 -0
  149. package/dist/process/exit-code-for-signal.js.map +1 -0
  150. package/dist/process/index.d.ts +4 -0
  151. package/dist/process/index.d.ts.map +1 -0
  152. package/dist/process/index.js +4 -0
  153. package/dist/process/index.js.map +1 -0
  154. package/dist/process/install-graceful-shutdown.d.ts +16 -0
  155. package/dist/process/install-graceful-shutdown.d.ts.map +1 -0
  156. package/dist/process/install-graceful-shutdown.js +89 -0
  157. package/dist/process/install-graceful-shutdown.js.map +1 -0
  158. package/dist/process/resolve-executable.d.ts +14 -0
  159. package/dist/process/resolve-executable.d.ts.map +1 -0
  160. package/dist/process/resolve-executable.js +47 -0
  161. package/dist/process/resolve-executable.js.map +1 -0
  162. package/dist/set/drain.d.ts +11 -0
  163. package/dist/set/drain.d.ts.map +1 -0
  164. package/dist/set/drain.js +16 -0
  165. package/dist/set/drain.js.map +1 -0
  166. package/dist/set/index.d.ts +2 -0
  167. package/dist/set/index.d.ts.map +1 -0
  168. package/dist/set/index.js +2 -0
  169. package/dist/set/index.js.map +1 -0
  170. package/dist/source/index.d.ts +4 -0
  171. package/dist/source/index.d.ts.map +1 -0
  172. package/dist/source/index.js +4 -0
  173. package/dist/source/index.js.map +1 -0
  174. package/dist/source/sanitize-identifier.d.ts +14 -0
  175. package/dist/source/sanitize-identifier.d.ts.map +1 -0
  176. package/dist/source/sanitize-identifier.js +65 -0
  177. package/dist/source/sanitize-identifier.js.map +1 -0
  178. package/dist/source/source-string-literal.d.ts +13 -0
  179. package/dist/source/source-string-literal.d.ts.map +1 -0
  180. package/dist/source/source-string-literal.js +24 -0
  181. package/dist/source/source-string-literal.js.map +1 -0
  182. package/dist/source/to-camel-identifier.d.ts +13 -0
  183. package/dist/source/to-camel-identifier.d.ts.map +1 -0
  184. package/dist/source/to-camel-identifier.js +17 -0
  185. package/dist/source/to-camel-identifier.js.map +1 -0
  186. package/dist/string/camel-case.d.ts +17 -0
  187. package/dist/string/camel-case.d.ts.map +1 -0
  188. package/dist/string/camel-case.js +21 -0
  189. package/dist/string/camel-case.js.map +1 -0
  190. package/dist/string/index.d.ts +6 -0
  191. package/dist/string/index.d.ts.map +1 -0
  192. package/dist/string/index.js +6 -0
  193. package/dist/string/index.js.map +1 -0
  194. package/dist/string/kebab-case.d.ts +14 -0
  195. package/dist/string/kebab-case.d.ts.map +1 -0
  196. package/dist/string/kebab-case.js +16 -0
  197. package/dist/string/kebab-case.js.map +1 -0
  198. package/dist/string/lower-first.d.ts +13 -0
  199. package/dist/string/lower-first.d.ts.map +1 -0
  200. package/dist/string/lower-first.js +15 -0
  201. package/dist/string/lower-first.js.map +1 -0
  202. package/dist/string/pascal-case.d.ts +16 -0
  203. package/dist/string/pascal-case.d.ts.map +1 -0
  204. package/dist/string/pascal-case.js +20 -0
  205. package/dist/string/pascal-case.js.map +1 -0
  206. package/dist/string/upper-first.d.ts +13 -0
  207. package/dist/string/upper-first.d.ts.map +1 -0
  208. package/dist/string/upper-first.js +15 -0
  209. package/dist/string/upper-first.js.map +1 -0
  210. package/dist/string/word-segments.d.ts +3 -0
  211. package/dist/string/word-segments.d.ts.map +1 -0
  212. package/dist/string/word-segments.js +12 -0
  213. package/dist/string/word-segments.js.map +1 -0
  214. package/dist/util/index.d.ts +2 -0
  215. package/dist/util/index.d.ts.map +1 -0
  216. package/dist/util/index.js +2 -0
  217. package/dist/util/index.js.map +1 -0
  218. package/dist/util/package-version.d.ts +12 -0
  219. package/dist/util/package-version.d.ts.map +1 -0
  220. package/dist/util/package-version.js +15 -0
  221. package/dist/util/package-version.js.map +1 -0
  222. package/package.json +18 -7
  223. package/src/array/index-before-or-end.ts +27 -0
  224. package/src/array/index.ts +5 -0
  225. package/src/array/remove.ts +20 -0
  226. package/src/array/sort-strings-by.ts +17 -0
  227. package/src/array/sort-strings.ts +14 -0
  228. package/src/array/uniq-by.ts +33 -0
  229. package/src/class/any-class.ts +10 -0
  230. package/src/class/get-parent-class.ts +15 -0
  231. package/src/class/index.ts +3 -0
  232. package/src/class/walk-class-chain.ts +29 -0
  233. package/src/error/error-like.ts +19 -0
  234. package/src/error/error-message.ts +17 -0
  235. package/src/error/format-child-process-error.ts +24 -0
  236. package/src/error/index.ts +3 -0
  237. package/src/error/normalize-error.ts +22 -0
  238. package/src/function/call-method.ts +22 -0
  239. package/src/function/index.ts +1 -0
  240. package/src/index.ts +13 -10
  241. package/src/log/create-logger.ts +18 -0
  242. package/src/log/default-logger.ts +49 -0
  243. package/src/log/index.ts +3 -0
  244. package/src/log/logger.ts +142 -0
  245. package/src/map/get-or-insert.ts +33 -0
  246. package/src/map/index.ts +1 -0
  247. package/src/object/index.ts +3 -0
  248. package/src/object/omit.ts +26 -0
  249. package/src/object/pick-by.ts +30 -0
  250. package/src/object/structured-clone.ts +31 -0
  251. package/src/predicate/are-object-keys-equal.ts +15 -0
  252. package/src/predicate/index.ts +6 -0
  253. package/src/predicate/is-deep-equal.ts +41 -0
  254. package/src/predicate/is-plain-object.ts +25 -0
  255. package/src/predicate/is-record.ts +16 -0
  256. package/src/predicate/is-same-array-by.ts +21 -0
  257. package/src/predicate/is-same-array.ts +19 -0
  258. package/src/predicate/is-shallow-equal.ts +32 -0
  259. package/src/process/exit-code-for-signal.ts +20 -0
  260. package/src/process/index.ts +3 -0
  261. package/src/process/install-graceful-shutdown.ts +126 -0
  262. package/src/process/resolve-executable.ts +57 -0
  263. package/src/set/drain.ts +17 -0
  264. package/src/set/index.ts +1 -0
  265. package/src/source/index.ts +3 -0
  266. package/src/source/sanitize-identifier.ts +66 -0
  267. package/src/source/source-string-literal.ts +27 -0
  268. package/src/source/to-camel-identifier.ts +18 -0
  269. package/src/string/camel-case.ts +22 -0
  270. package/src/string/index.ts +5 -0
  271. package/src/string/kebab-case.ts +18 -0
  272. package/src/string/lower-first.ts +15 -0
  273. package/src/string/pascal-case.ts +21 -0
  274. package/src/string/upper-first.ts +15 -0
  275. package/src/string/word-segments.ts +15 -0
  276. package/src/util/index.ts +1 -0
  277. package/src/util/package-version.ts +16 -0
  278. package/dist/class.d.ts +0 -16
  279. package/dist/class.d.ts.map +0 -1
  280. package/dist/class.js +0 -2
  281. package/dist/class.js.map +0 -1
  282. package/dist/collection.d.ts +0 -58
  283. package/dist/collection.d.ts.map +0 -1
  284. package/dist/collection.js +0 -98
  285. package/dist/collection.js.map +0 -1
  286. package/dist/error.d.ts +0 -13
  287. package/dist/error.d.ts.map +0 -1
  288. package/dist/error.js +0 -13
  289. package/dist/error.js.map +0 -1
  290. package/dist/graceful-shutdown.d.ts +0 -70
  291. package/dist/graceful-shutdown.d.ts.map +0 -1
  292. package/dist/graceful-shutdown.js +0 -94
  293. package/dist/graceful-shutdown.js.map +0 -1
  294. package/dist/source.d.ts +0 -34
  295. package/dist/source.d.ts.map +0 -1
  296. package/dist/source.js +0 -99
  297. package/dist/source.js.map +0 -1
  298. package/dist/string.d.ts +0 -59
  299. package/dist/string.d.ts.map +0 -1
  300. package/dist/string.js +0 -73
  301. package/dist/string.js.map +0 -1
  302. package/src/class.ts +0 -17
  303. package/src/collection.ts +0 -103
  304. package/src/error.ts +0 -12
  305. package/src/graceful-shutdown.ts +0 -141
  306. package/src/source.ts +0 -103
  307. package/src/string.ts +0 -74
package/README.md ADDED
@@ -0,0 +1,173 @@
1
+ <p align="center">
2
+ <img src="https://raw.githubusercontent.com/gtkx-org/gtkx/main/logo.svg" alt="GTKX" width="100" />
3
+ </p>
4
+
5
+ <h1 align="center">GTKX</h1>
6
+
7
+ <p align="center">
8
+ The React framework for Linux.<br />
9
+ Build GTK4 and Adwaita apps in TypeScript, with React components and hooks driving GNOME's own widgets. What you ship is a GNOME app.
10
+ </p>
11
+
12
+ <p align="center">
13
+ <a href="https://www.npmjs.com/package/create-gtkx"><img src="https://img.shields.io/npm/v/create-gtkx?color=cb3837&logo=npm&label=create-gtkx" alt="npm version" /></a>
14
+ <a href="https://www.npmjs.com/package/create-gtkx"><img src="https://img.shields.io/npm/dm/create-gtkx?color=cb3837&logo=npm&label=downloads" alt="npm downloads" /></a>
15
+ <img src="https://img.shields.io/badge/node-%E2%89%A524-339933?logo=node.js&logoColor=white" alt="Node >= 24" />
16
+ <a href="https://github.com/gtkx-org/gtkx/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MPL--2.0-blue.svg" alt="License: MPL-2.0" /></a>
17
+ <a href="https://github.com/gtkx-org/gtkx/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/gtkx-org/gtkx/ci.yml?branch=main&logo=github&label=CI" alt="CI status" /></a>
18
+ <img src="https://img.shields.io/badge/TypeScript-strict-3178c6?logo=typescript&logoColor=white" alt="TypeScript" />
19
+ </p>
20
+
21
+ <p align="center">
22
+ <a href="https://gtkx.dev">Homepage</a> &middot;
23
+ <a href="https://gtkx.dev/guide/why-gtkx">Documentation</a> &middot;
24
+ <a href="https://github.com/gtkx-org/gtkx/tree/main/examples">Examples</a> &middot;
25
+ <a href="https://github.com/gtkx-org/gtkx/blob/main/CONTRIBUTING.md">Contributing</a>
26
+ </p>
27
+
28
+ ---
29
+
30
+ GTKX generates fully typed bindings for the entire GTK4 and Adwaita surface directly from GObject-Introspection. On top of those bindings you get the React programming model: components and hooks driving GObject instances, with Fast Refresh while you develop.
31
+
32
+ <p align="center">
33
+ <img src="https://raw.githubusercontent.com/gtkx-org/gtkx/main/examples/tutorial/assets/screenshot.png" alt="The Tasks app: an Adwaita window with a sidebar of smart views and colored lists on the left, and a boxed task list on the right." />
34
+ </p>
35
+
36
+ <p align="center">
37
+ <em>The Tasks app you build in the <a href="https://gtkx.dev/tutorial/">tutorial</a>.</em>
38
+ </p>
39
+
40
+ ## Demo
41
+
42
+ The intrinsic elements in this snippet render GTK4 widgets, and ordinary React hooks and events drive them:
43
+
44
+ ```tsx
45
+ import * as Gtk from "@gtkx/gi/gtk";
46
+ import { GtkApplication, GtkApplicationWindow, GtkBox, GtkButton, GtkLabel } from "@gtkx/jsx/gtk";
47
+ import { createRoot, quit } from "@gtkx/react";
48
+ import { useState } from "react";
49
+
50
+ const Counter = () => {
51
+ const [count, setCount] = useState(0);
52
+
53
+ return (
54
+ <GtkApplicationWindow
55
+ title="Hello GTKX"
56
+ defaultWidth={400}
57
+ defaultHeight={300}
58
+ onCloseRequest={quit}
59
+ >
60
+ <GtkBox
61
+ orientation={Gtk.Orientation.VERTICAL}
62
+ spacing={20}
63
+ marginTop={40}
64
+ marginBottom={40}
65
+ marginStart={40}
66
+ marginEnd={40}
67
+ valign={Gtk.Align.CENTER}
68
+ halign={Gtk.Align.CENTER}
69
+ >
70
+ <GtkLabel cssClasses={["title-1"]}>Welcome to GTKX!</GtkLabel>
71
+ <GtkLabel cssClasses={["title-2"]}>{`Count: ${count}`}</GtkLabel>
72
+ <GtkButton
73
+ label="Increment"
74
+ onClicked={() => setCount((c) => c + 1)}
75
+ cssClasses={["suggested-action", "pill"]}
76
+ />
77
+ </GtkBox>
78
+ </GtkApplicationWindow>
79
+ );
80
+ };
81
+
82
+ const App = () => (
83
+ <GtkApplication>
84
+ <Counter />
85
+ </GtkApplication>
86
+ );
87
+
88
+ createRoot().render(<App />);
89
+ ```
90
+
91
+ This is the [`hello-world`](https://github.com/gtkx-org/gtkx/tree/main/examples/hello-world) example, with `app.tsx` and `index.tsx` combined into a single snippet. `@gtkx/gi` and `@gtkx/jsx` are per-project bindings generated by the CLI, not packages you install from npm.
92
+
93
+ ## Why GTKX
94
+
95
+ ### A declarative layer for the GNOME stack
96
+
97
+ GTK4 is mature, and GtkBuilder XML can lay out a static interface, but nothing re-renders that interface when your application state changes, and nothing hot-reloads it as you work. GTKX adds that missing layer, and the tooling around it, on top of the stack you already know:
98
+
99
+ - a React reconciler that exposes every GObject as a JSX element,
100
+ - a CLI for scaffolding, development, and production builds,
101
+ - a dev server with Fast Refresh that patches your running UI in place,
102
+ - CSS-in-JS styling and high-level list, grid, and dialog components,
103
+ - a Testing Library-style API for querying and driving your widgets in tests,
104
+ - and a Model Context Protocol (MCP) server that exposes your live app to AI agents.
105
+
106
+ ### The full GNOME API surface
107
+
108
+ React Native and similar frameworks hide the native toolkit so one API can run everywhere. GTKX exposes it: GTK4, Adwaita, and any other GObject-Introspection library on your system. Linux-only by design.
109
+
110
+ ### Why Node.js, and why generated bindings
111
+
112
+ GTKX runs on Node.js, which puts native modules, the npm ecosystem, and the tooling built for Node.js APIs within reach. GJS is GNOME's own runtime, built on SpiderMonkey rather than V8; node-gtk runs on Node.js but is lightly maintained, on the older nan/V8 ABI rather than N-API, and still centered on GTK3. The [why-gtkx guide](https://gtkx.dev/guide/why-gtkx) covers the comparison in full.
113
+
114
+ GTKX generates the TypeScript types and the native FFI calls from the same GObject-Introspection data, so the types cannot drift from the calls they back. Codegen covers the whole GTK4 and Adwaita surface.
115
+
116
+ At runtime, the native Rust core calls straight into the system GTK4, Adwaita, and GLib libraries through libffi, without loading libgirepository at all.
117
+
118
+ ## Quick start
119
+
120
+ GTKX is Linux-only and needs Node.js 24 or later. See [Requirements](#requirements).
121
+
122
+ Scaffold a new app with the `create-gtkx` initializer:
123
+
124
+ ```sh
125
+ npm create gtkx@rc
126
+ ```
127
+
128
+ The same command works with other package managers: `pnpm create gtkx@rc` or `yarn create gtkx@rc`.
129
+
130
+ Then run your new app:
131
+
132
+ ```sh
133
+ cd my-app
134
+ npm run dev
135
+ ```
136
+
137
+ To go further, follow the [tutorial](https://gtkx.dev/tutorial/).
138
+
139
+ ## Documentation
140
+
141
+ The documentation at **[gtkx.dev](https://gtkx.dev)** includes a step-by-step tutorial that builds a complete GNOME app, from scaffolding to packaging and shipping, plus guides and a full API reference.
142
+
143
+ **[Read the docs &rarr;](https://gtkx.dev/guide/why-gtkx)**
144
+
145
+ ## Requirements
146
+
147
+ GTKX is Linux-only. You need:
148
+
149
+ - Linux with the GTK4 (4.20 or later), Adwaita (1.8 or later), and GLib development libraries
150
+ - Node.js 24 or later
151
+
152
+ The `@gtkx/native` addon ships prebuilt for x64 and arm64 glibc Linux; other targets need to build it from the GTKX repository, which requires a Rust toolchain.
153
+
154
+ ## Examples
155
+
156
+ Explore the [example apps](https://github.com/gtkx-org/gtkx/tree/main/examples):
157
+
158
+ - [`hello-world`](https://github.com/gtkx-org/gtkx/tree/main/examples/hello-world): the counter above.
159
+ - [`gtk-demo`](https://github.com/gtkx-org/gtkx/tree/main/examples/gtk-demo): a React port of the official GTK4 widget showcase, covering lists, dialogs, gestures, CSS, and OpenGL.
160
+ - [`browser`](https://github.com/gtkx-org/gtkx/tree/main/examples/browser): a WebKitWebView-based web browser.
161
+ - [`tutorial`](https://github.com/gtkx-org/gtkx/tree/main/examples/tutorial): the Tasks app the documentation builds.
162
+
163
+ ## Status
164
+
165
+ GTKX 1.0 is at the release candidate stage.
166
+
167
+ ## Contributing
168
+
169
+ Contributions are welcome. See [CONTRIBUTING.md](https://github.com/gtkx-org/gtkx/blob/main/CONTRIBUTING.md), the [Code of Conduct](https://github.com/gtkx-org/gtkx/blob/main/CODE_OF_CONDUCT.md), and the [security policy](https://github.com/gtkx-org/gtkx/blob/main/SECURITY.md). Building the repo needs Node.js 24 or later, pnpm, and a Rust toolchain.
170
+
171
+ ## License
172
+
173
+ GTKX is licensed under [MPL-2.0](https://github.com/gtkx-org/gtkx/blob/main/LICENSE).
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Finds the index of the first item matching `before`, or `list.length` when `before` is `null` or
3
+ * nothing matches. Use it to resolve where a new item should be inserted so it lands before the
4
+ * referenced one, defaulting to the end.
5
+ *
6
+ * @template T - The list item type.
7
+ * @template B - The reference value type.
8
+ * @param list - The list to search.
9
+ * @param before - The item to insert before, or `null` to target the end.
10
+ * @param isMatch - Called with each item and the non-null `before`; return `true` on a match.
11
+ * @returns The matched index, or `list.length`.
12
+ */
13
+ declare const indexBeforeOrEnd: <T, B>(list: T[], before: B | null, isMatch: (item: T, before: B) => boolean) => number;
14
+ export { indexBeforeOrEnd };
15
+ //# sourceMappingURL=index-before-or-end.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-before-or-end.d.ts","sourceRoot":"","sources":["../../src/array/index-before-or-end.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,QAAA,MAAM,gBAAgB,GAAI,CAAC,EAAE,CAAC,EAC1B,MAAM,CAAC,EAAE,EACT,QAAQ,CAAC,GAAG,IAAI,EAChB,SAAS,CAAC,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,KAAK,OAAO,KACzC,MAQF,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Finds the index of the first item matching `before`, or `list.length` when `before` is `null` or
3
+ * nothing matches. Use it to resolve where a new item should be inserted so it lands before the
4
+ * referenced one, defaulting to the end.
5
+ *
6
+ * @template T - The list item type.
7
+ * @template B - The reference value type.
8
+ * @param list - The list to search.
9
+ * @param before - The item to insert before, or `null` to target the end.
10
+ * @param isMatch - Called with each item and the non-null `before`; return `true` on a match.
11
+ * @returns The matched index, or `list.length`.
12
+ */
13
+ const indexBeforeOrEnd = (list, before, isMatch) => {
14
+ if (before === null) {
15
+ return list.length;
16
+ }
17
+ const index = list.findIndex((item) => isMatch(item, before));
18
+ return index === -1 ? list.length : index;
19
+ };
20
+ export { indexBeforeOrEnd };
21
+ //# sourceMappingURL=index-before-or-end.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-before-or-end.js","sourceRoot":"","sources":["../../src/array/index-before-or-end.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,MAAM,gBAAgB,GAAG,CACrB,IAAS,EACT,MAAgB,EAChB,OAAwC,EAClC,EAAE;IACR,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;QAClB,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;IAED,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;IAE9D,OAAO,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC;AAC9C,CAAC,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,CAAC","sourcesContent":["/**\n * Finds the index of the first item matching `before`, or `list.length` when `before` is `null` or\n * nothing matches. Use it to resolve where a new item should be inserted so it lands before the\n * referenced one, defaulting to the end.\n *\n * @template T - The list item type.\n * @template B - The reference value type.\n * @param list - The list to search.\n * @param before - The item to insert before, or `null` to target the end.\n * @param isMatch - Called with each item and the non-null `before`; return `true` on a match.\n * @returns The matched index, or `list.length`.\n */\nconst indexBeforeOrEnd = <T, B>(\n list: T[],\n before: B | null,\n isMatch: (item: T, before: B) => boolean,\n): number => {\n if (before === null) {\n return list.length;\n }\n\n const index = list.findIndex((item) => isMatch(item, before));\n\n return index === -1 ? list.length : index;\n};\n\nexport { indexBeforeOrEnd };\n"]}
@@ -0,0 +1,6 @@
1
+ export { indexBeforeOrEnd } from "./index-before-or-end.js";
2
+ export { remove } from "./remove.js";
3
+ export { sortStringsBy } from "./sort-strings-by.js";
4
+ export { sortStrings } from "./sort-strings.js";
5
+ export { uniqBy } from "./uniq-by.js";
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/array/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC"}
@@ -0,0 +1,6 @@
1
+ export { indexBeforeOrEnd } from "./index-before-or-end.js";
2
+ export { remove } from "./remove.js";
3
+ export { sortStringsBy } from "./sort-strings-by.js";
4
+ export { sortStrings } from "./sort-strings.js";
5
+ export { uniqBy } from "./uniq-by.js";
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/array/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC","sourcesContent":["export { indexBeforeOrEnd } from \"./index-before-or-end.js\";\nexport { remove } from \"./remove.js\";\nexport { sortStringsBy } from \"./sort-strings-by.js\";\nexport { sortStrings } from \"./sort-strings.js\";\nexport { uniqBy } from \"./uniq-by.js\";\n"]}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Removes the first strictly-equal (`===`) occurrence of `value` from `arr` in place.
3
+ *
4
+ * @template T - The type of the array elements.
5
+ * @param arr - The array to mutate.
6
+ * @param value - The value to remove.
7
+ *
8
+ * @example
9
+ * const items = ["a", "b", "c"];
10
+ * remove(items, "b"); // items is now ["a", "c"]
11
+ */
12
+ declare function remove<T>(arr: T[], value: T): void;
13
+ export { remove };
14
+ //# sourceMappingURL=remove.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remove.d.ts","sourceRoot":"","sources":["../../src/array/remove.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,iBAAS,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,CAM3C;AAED,OAAO,EAAE,MAAM,EAAE,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Removes the first strictly-equal (`===`) occurrence of `value` from `arr` in place.
3
+ *
4
+ * @template T - The type of the array elements.
5
+ * @param arr - The array to mutate.
6
+ * @param value - The value to remove.
7
+ *
8
+ * @example
9
+ * const items = ["a", "b", "c"];
10
+ * remove(items, "b"); // items is now ["a", "c"]
11
+ */
12
+ function remove(arr, value) {
13
+ const index = arr.indexOf(value);
14
+ if (index !== -1) {
15
+ arr.splice(index, 1);
16
+ }
17
+ }
18
+ export { remove };
19
+ //# sourceMappingURL=remove.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remove.js","sourceRoot":"","sources":["../../src/array/remove.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,SAAS,MAAM,CAAI,GAAQ,EAAE,KAAQ;IACjC,MAAM,KAAK,GAAG,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAEjC,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC;QACf,GAAG,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IACzB,CAAC;AACL,CAAC;AAED,OAAO,EAAE,MAAM,EAAE,CAAC","sourcesContent":["/**\n * Removes the first strictly-equal (`===`) occurrence of `value` from `arr` in place.\n *\n * @template T - The type of the array elements.\n * @param arr - The array to mutate.\n * @param value - The value to remove.\n *\n * @example\n * const items = [\"a\", \"b\", \"c\"];\n * remove(items, \"b\"); // items is now [\"a\", \"c\"]\n */\nfunction remove<T>(arr: T[], value: T): void {\n const index = arr.indexOf(value);\n\n if (index !== -1) {\n arr.splice(index, 1);\n }\n}\n\nexport { remove };\n"]}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Returns the items sorted by a string key using locale-aware comparison.
3
+ *
4
+ * @template T - The type of items being sorted.
5
+ * @param items - The items to sort.
6
+ * @param key - Maps an item to the string its order is decided by.
7
+ * @returns A new array of the items in ascending locale order of their keys.
8
+ *
9
+ * @example
10
+ * sortStringsBy([{ name: "b" }, { name: "a" }], (item) => item.name);
11
+ * // [{ name: "a" }, { name: "b" }]
12
+ */
13
+ declare function sortStringsBy<T>(items: Iterable<T>, key: (item: T) => string): T[];
14
+ export { sortStringsBy };
15
+ //# sourceMappingURL=sort-strings-by.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sort-strings-by.d.ts","sourceRoot":"","sources":["../../src/array/sort-strings-by.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,iBAAS,aAAa,CAAC,CAAC,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,GAAG,CAAC,EAAE,CAE3E;AAED,OAAO,EAAE,aAAa,EAAE,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Returns the items sorted by a string key using locale-aware comparison.
3
+ *
4
+ * @template T - The type of items being sorted.
5
+ * @param items - The items to sort.
6
+ * @param key - Maps an item to the string its order is decided by.
7
+ * @returns A new array of the items in ascending locale order of their keys.
8
+ *
9
+ * @example
10
+ * sortStringsBy([{ name: "b" }, { name: "a" }], (item) => item.name);
11
+ * // [{ name: "a" }, { name: "b" }]
12
+ */
13
+ function sortStringsBy(items, key) {
14
+ return [...items].toSorted((a, b) => key(a).localeCompare(key(b)));
15
+ }
16
+ export { sortStringsBy };
17
+ //# sourceMappingURL=sort-strings-by.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sort-strings-by.js","sourceRoot":"","sources":["../../src/array/sort-strings-by.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,SAAS,aAAa,CAAI,KAAkB,EAAE,GAAwB;IAClE,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACvE,CAAC;AAED,OAAO,EAAE,aAAa,EAAE,CAAC","sourcesContent":["/**\n * Returns the items sorted by a string key using locale-aware comparison.\n *\n * @template T - The type of items being sorted.\n * @param items - The items to sort.\n * @param key - Maps an item to the string its order is decided by.\n * @returns A new array of the items in ascending locale order of their keys.\n *\n * @example\n * sortStringsBy([{ name: \"b\" }, { name: \"a\" }], (item) => item.name);\n * // [{ name: \"a\" }, { name: \"b\" }]\n */\nfunction sortStringsBy<T>(items: Iterable<T>, key: (item: T) => string): T[] {\n return [...items].toSorted((a, b) => key(a).localeCompare(key(b)));\n}\n\nexport { sortStringsBy };\n"]}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Returns the values sorted as strings using locale-aware comparison.
3
+ *
4
+ * @param values - The strings to sort.
5
+ * @returns A new array of the values in ascending locale order.
6
+ *
7
+ * @example
8
+ * sortStrings(["b", "a", "c"]); // ["a", "b", "c"]
9
+ */
10
+ declare function sortStrings(values: Iterable<string>): string[];
11
+ export { sortStrings };
12
+ //# sourceMappingURL=sort-strings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sort-strings.d.ts","sourceRoot":"","sources":["../../src/array/sort-strings.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,iBAAS,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,MAAM,EAAE,CAEvD;AAED,OAAO,EAAE,WAAW,EAAE,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Returns the values sorted as strings using locale-aware comparison.
3
+ *
4
+ * @param values - The strings to sort.
5
+ * @returns A new array of the values in ascending locale order.
6
+ *
7
+ * @example
8
+ * sortStrings(["b", "a", "c"]); // ["a", "b", "c"]
9
+ */
10
+ function sortStrings(values) {
11
+ return [...values].toSorted((a, b) => a.localeCompare(b));
12
+ }
13
+ export { sortStrings };
14
+ //# sourceMappingURL=sort-strings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sort-strings.js","sourceRoot":"","sources":["../../src/array/sort-strings.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,SAAS,WAAW,CAAC,MAAwB;IACzC,OAAO,CAAC,GAAG,MAAM,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;AAC9D,CAAC;AAED,OAAO,EAAE,WAAW,EAAE,CAAC","sourcesContent":["/**\n * Returns the values sorted as strings using locale-aware comparison.\n *\n * @param values - The strings to sort.\n * @returns A new array of the values in ascending locale order.\n *\n * @example\n * sortStrings([\"b\", \"a\", \"c\"]); // [\"a\", \"b\", \"c\"]\n */\nfunction sortStrings(values: Iterable<string>): string[] {\n return [...values].toSorted((a, b) => a.localeCompare(b));\n}\n\nexport { sortStrings };\n"]}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Returns a new array of the unique elements of `arr`, keyed by the value the `mapper` returns.
3
+ *
4
+ * When two elements map to the same key the first occurrence is kept and later ones discarded,
5
+ * preserving first-seen order.
6
+ *
7
+ * @template T - The type of elements in the array.
8
+ * @param arr - The array to deduplicate.
9
+ * @param mapper - Maps an element to the key its uniqueness is decided by.
10
+ * @returns A new array containing only the first element seen for each distinct key.
11
+ *
12
+ * @example
13
+ * uniqBy([2.1, 1.2, 2.3], Math.floor); // [2.1, 1.2]
14
+ * uniqBy([{ id: "a" }, { id: "a" }, { id: "b" }], (item) => item.id); // [{ id: "a" }, { id: "b" }]
15
+ */
16
+ declare function uniqBy<T>(arr: T[], mapper: (item: T, index: number, array: T[]) => unknown): T[];
17
+ export { uniqBy };
18
+ //# sourceMappingURL=uniq-by.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uniq-by.d.ts","sourceRoot":"","sources":["../../src/array/uniq-by.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,iBAAS,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,OAAO,GAAG,CAAC,EAAE,CAezF;AAED,OAAO,EAAE,MAAM,EAAE,CAAC"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Returns a new array of the unique elements of `arr`, keyed by the value the `mapper` returns.
3
+ *
4
+ * When two elements map to the same key the first occurrence is kept and later ones discarded,
5
+ * preserving first-seen order.
6
+ *
7
+ * @template T - The type of elements in the array.
8
+ * @param arr - The array to deduplicate.
9
+ * @param mapper - Maps an element to the key its uniqueness is decided by.
10
+ * @returns A new array containing only the first element seen for each distinct key.
11
+ *
12
+ * @example
13
+ * uniqBy([2.1, 1.2, 2.3], Math.floor); // [2.1, 1.2]
14
+ * uniqBy([{ id: "a" }, { id: "a" }, { id: "b" }], (item) => item.id); // [{ id: "a" }, { id: "b" }]
15
+ */
16
+ function uniqBy(arr, mapper) {
17
+ const seen = new Map();
18
+ let index = 0;
19
+ for (const item of arr) {
20
+ const key = mapper(item, index, arr);
21
+ if (!seen.has(key)) {
22
+ seen.set(key, item);
23
+ }
24
+ index++;
25
+ }
26
+ return seen.values().toArray();
27
+ }
28
+ export { uniqBy };
29
+ //# sourceMappingURL=uniq-by.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uniq-by.js","sourceRoot":"","sources":["../../src/array/uniq-by.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,SAAS,MAAM,CAAI,GAAQ,EAAE,MAAuD;IAChF,MAAM,IAAI,GAAoB,IAAI,GAAG,EAAE,CAAC;IACxC,IAAI,KAAK,GAAG,CAAC,CAAC;IAEd,KAAK,MAAM,IAAI,IAAI,GAAG,EAAE,CAAC;QACrB,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;QAErC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YACjB,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QACxB,CAAC;QAED,KAAK,EAAE,CAAC;IACZ,CAAC;IAED,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE,CAAC;AACnC,CAAC;AAED,OAAO,EAAE,MAAM,EAAE,CAAC","sourcesContent":["/**\n * Returns a new array of the unique elements of `arr`, keyed by the value the `mapper` returns.\n *\n * When two elements map to the same key the first occurrence is kept and later ones discarded,\n * preserving first-seen order.\n *\n * @template T - The type of elements in the array.\n * @param arr - The array to deduplicate.\n * @param mapper - Maps an element to the key its uniqueness is decided by.\n * @returns A new array containing only the first element seen for each distinct key.\n *\n * @example\n * uniqBy([2.1, 1.2, 2.3], Math.floor); // [2.1, 1.2]\n * uniqBy([{ id: \"a\" }, { id: \"a\" }, { id: \"b\" }], (item) => item.id); // [{ id: \"a\" }, { id: \"b\" }]\n */\nfunction uniqBy<T>(arr: T[], mapper: (item: T, index: number, array: T[]) => unknown): T[] {\n const seen: Map<unknown, T> = new Map();\n let index = 0;\n\n for (const item of arr) {\n const key = mapper(item, index, arr);\n\n if (!seen.has(key)) {\n seen.set(key, item);\n }\n\n index++;\n }\n\n return seen.values().toArray();\n}\n\nexport { uniqBy };\n"]}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * A constructor value of any (possibly abstract) class producing instances of `T`.
3
+ */
4
+ type AnyClass<T extends object = object> = (abstract new (...args: never[]) => T) & {
5
+ prototype: T;
6
+ };
7
+ export { type AnyClass };
8
+ //# sourceMappingURL=any-class.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"any-class.d.ts","sourceRoot":"","sources":["../../src/class/any-class.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,KAAK,QAAQ,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI,CAAC,QAAQ,MAChD,GAAG,IAAI,EAAE,KAAK,EAAE,KACf,CAAC,CAAC,GAAG;IACN,SAAS,EAAE,CAAC,CAAC;CAChB,CAAC;AAEF,OAAO,EAAE,KAAK,QAAQ,EAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=any-class.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"any-class.js","sourceRoot":"","sources":["../../src/class/any-class.ts"],"names":[],"mappings":"AASA,OAAO,EAAiB,CAAC","sourcesContent":["/**\n * A constructor value of any (possibly abstract) class producing instances of `T`.\n */\ntype AnyClass<T extends object = object> = (abstract new (\n ...args: never[]\n) => T) & {\n prototype: T;\n};\n\nexport { type AnyClass };\n"]}
@@ -0,0 +1,10 @@
1
+ import type { AnyClass } from "./any-class.js";
2
+ /**
3
+ * Returns the direct superclass of `cls`, or `null` when it has no class ancestor.
4
+ *
5
+ * @param cls - The class whose prototype parent to inspect.
6
+ * @returns The parent class, or `null` when there is none.
7
+ */
8
+ declare function getParentClass(cls: AnyClass): AnyClass | null;
9
+ export { getParentClass };
10
+ //# sourceMappingURL=get-parent-class.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-parent-class.d.ts","sourceRoot":"","sources":["../../src/class/get-parent-class.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C;;;;;GAKG;AACH,iBAAS,cAAc,CAAC,GAAG,EAAE,QAAQ,GAAG,QAAQ,GAAG,IAAI,CAItD;AAED,OAAO,EAAE,cAAc,EAAE,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Returns the direct superclass of `cls`, or `null` when it has no class ancestor.
3
+ *
4
+ * @param cls - The class whose prototype parent to inspect.
5
+ * @returns The parent class, or `null` when there is none.
6
+ */
7
+ function getParentClass(cls) {
8
+ const parent = Object.getPrototypeOf(cls);
9
+ return typeof parent === "function" && parent !== Function.prototype ? parent : null;
10
+ }
11
+ export { getParentClass };
12
+ //# sourceMappingURL=get-parent-class.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-parent-class.js","sourceRoot":"","sources":["../../src/class/get-parent-class.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,SAAS,cAAc,CAAC,GAAa;IACjC,MAAM,MAAM,GAAY,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;IAEnD,OAAO,OAAO,MAAM,KAAK,UAAU,IAAI,MAAM,KAAK,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAE,MAAmB,CAAC,CAAC,CAAC,IAAI,CAAC;AACvG,CAAC;AAED,OAAO,EAAE,cAAc,EAAE,CAAC","sourcesContent":["import type { AnyClass } from \"./any-class.js\";\n\n/**\n * Returns the direct superclass of `cls`, or `null` when it has no class ancestor.\n *\n * @param cls - The class whose prototype parent to inspect.\n * @returns The parent class, or `null` when there is none.\n */\nfunction getParentClass(cls: AnyClass): AnyClass | null {\n const parent: unknown = Object.getPrototypeOf(cls);\n\n return typeof parent === \"function\" && parent !== Function.prototype ? (parent as AnyClass) : null;\n}\n\nexport { getParentClass };\n"]}
@@ -0,0 +1,4 @@
1
+ export type { AnyClass } from "./any-class.js";
2
+ export { getParentClass } from "./get-parent-class.js";
3
+ export { walkClassChain } from "./walk-class-chain.js";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/class/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { getParentClass } from "./get-parent-class.js";
2
+ export { walkClassChain } from "./walk-class-chain.js";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/class/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC","sourcesContent":["export type { AnyClass } from \"./any-class.js\";\nexport { getParentClass } from \"./get-parent-class.js\";\nexport { walkClassChain } from \"./walk-class-chain.js\";\n"]}
@@ -0,0 +1,13 @@
1
+ import type { AnyClass } from "./any-class.js";
2
+ /**
3
+ * Walks the class chain from `cls` up through its ancestors, calling `visit` on each and returning
4
+ * the first result that is not `undefined`.
5
+ *
6
+ * @template T - The type produced by the visitor.
7
+ * @param cls - The class to start from, or `null` to visit nothing.
8
+ * @param visit - Called with each class in the chain; a defined return value stops the walk.
9
+ * @returns The first defined result from `visit`, or `undefined` when none was produced.
10
+ */
11
+ declare function walkClassChain<T>(cls: AnyClass | null, visit: (ancestor: AnyClass) => T | undefined): T | undefined;
12
+ export { walkClassChain };
13
+ //# sourceMappingURL=walk-class-chain.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"walk-class-chain.d.ts","sourceRoot":"","sources":["../../src/class/walk-class-chain.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAG/C;;;;;;;;GAQG;AACH,iBAAS,cAAc,CAAC,CAAC,EAAE,GAAG,EAAE,QAAQ,GAAG,IAAI,EAAE,KAAK,EAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,CAAC,GAAG,SAAS,GAAG,CAAC,GAAG,SAAS,CAc5G;AAED,OAAO,EAAE,cAAc,EAAE,CAAC"}
@@ -0,0 +1,23 @@
1
+ import { getParentClass } from "./get-parent-class.js";
2
+ /**
3
+ * Walks the class chain from `cls` up through its ancestors, calling `visit` on each and returning
4
+ * the first result that is not `undefined`.
5
+ *
6
+ * @template T - The type produced by the visitor.
7
+ * @param cls - The class to start from, or `null` to visit nothing.
8
+ * @param visit - Called with each class in the chain; a defined return value stops the walk.
9
+ * @returns The first defined result from `visit`, or `undefined` when none was produced.
10
+ */
11
+ function walkClassChain(cls, visit) {
12
+ let current = cls;
13
+ while (current !== null) {
14
+ const result = visit(current);
15
+ if (result !== undefined) {
16
+ return result;
17
+ }
18
+ current = getParentClass(current);
19
+ }
20
+ return undefined;
21
+ }
22
+ export { walkClassChain };
23
+ //# sourceMappingURL=walk-class-chain.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"walk-class-chain.js","sourceRoot":"","sources":["../../src/class/walk-class-chain.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD;;;;;;;;GAQG;AACH,SAAS,cAAc,CAAI,GAAoB,EAAE,KAA4C;IACzF,IAAI,OAAO,GAAG,GAAG,CAAC;IAElB,OAAO,OAAO,KAAK,IAAI,EAAE,CAAC;QACtB,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC;QAE9B,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YACvB,OAAO,MAAM,CAAC;QAClB,CAAC;QAED,OAAO,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC;IACtC,CAAC;IAED,OAAO,SAAS,CAAC;AACrB,CAAC;AAED,OAAO,EAAE,cAAc,EAAE,CAAC","sourcesContent":["import type { AnyClass } from \"./any-class.js\";\nimport { getParentClass } from \"./get-parent-class.js\";\n\n/**\n * Walks the class chain from `cls` up through its ancestors, calling `visit` on each and returning\n * the first result that is not `undefined`.\n *\n * @template T - The type produced by the visitor.\n * @param cls - The class to start from, or `null` to visit nothing.\n * @param visit - Called with each class in the chain; a defined return value stops the walk.\n * @returns The first defined result from `visit`, or `undefined` when none was produced.\n */\nfunction walkClassChain<T>(cls: AnyClass | null, visit: (ancestor: AnyClass) => T | undefined): T | undefined {\n let current = cls;\n\n while (current !== null) {\n const result = visit(current);\n\n if (result !== undefined) {\n return result;\n }\n\n current = getParentClass(current);\n }\n\n return undefined;\n}\n\nexport { walkClassChain };\n"]}
@@ -0,0 +1,6 @@
1
+ declare function isErrorLike(value: unknown): value is {
2
+ message: string;
3
+ };
4
+ declare function readStream(value: unknown): string;
5
+ export { isErrorLike, readStream };
6
+ //# sourceMappingURL=error-like.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-like.d.ts","sourceRoot":"","sources":["../../src/error/error-like.ts"],"names":[],"mappings":"AAEA,iBAAS,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAEjE;AAED,iBAAS,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAU1C;AAED,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { isRecord } from "../predicate/is-record.js";
2
+ function isErrorLike(value) {
3
+ return isRecord(value) && "message" in value && typeof value.message === "string";
4
+ }
5
+ function readStream(value) {
6
+ if (typeof value === "string") {
7
+ return value;
8
+ }
9
+ if (value instanceof Uint8Array || Buffer.isBuffer(value)) {
10
+ return value.toString();
11
+ }
12
+ return "";
13
+ }
14
+ export { isErrorLike, readStream };
15
+ //# sourceMappingURL=error-like.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-like.js","sourceRoot":"","sources":["../../src/error/error-like.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAErD,SAAS,WAAW,CAAC,KAAc;IAC/B,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,SAAS,IAAI,KAAK,IAAI,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ,CAAC;AACtF,CAAC;AAED,SAAS,UAAU,CAAC,KAAc;IAC9B,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC5B,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,IAAI,KAAK,YAAY,UAAU,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QACxD,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAC;IAC5B,CAAC;IAED,OAAO,EAAE,CAAC;AACd,CAAC;AAED,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC","sourcesContent":["import { isRecord } from \"../predicate/is-record.js\";\n\nfunction isErrorLike(value: unknown): value is { message: string } {\n return isRecord(value) && \"message\" in value && typeof value.message === \"string\";\n}\n\nfunction readStream(value: unknown): string {\n if (typeof value === \"string\") {\n return value;\n }\n\n if (value instanceof Uint8Array || Buffer.isBuffer(value)) {\n return value.toString();\n }\n\n return \"\";\n}\n\nexport { isErrorLike, readStream };\n"]}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Extracts a human-readable message from an unknown thrown value, falling back to its string form.
3
+ *
4
+ * @param error - The caught value to describe.
5
+ * @returns The value's message when it has one, otherwise its string form.
6
+ *
7
+ * @example
8
+ * errorMessage(new Error("boom")); // "boom"
9
+ * errorMessage(42); // "42"
10
+ */
11
+ declare function errorMessage(error: unknown): string;
12
+ export { errorMessage };
13
+ //# sourceMappingURL=error-message.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-message.d.ts","sourceRoot":"","sources":["../../src/error/error-message.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AACH,iBAAS,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAE5C;AAED,OAAO,EAAE,YAAY,EAAE,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { isErrorLike } from "./error-like.js";
2
+ /**
3
+ * Extracts a human-readable message from an unknown thrown value, falling back to its string form.
4
+ *
5
+ * @param error - The caught value to describe.
6
+ * @returns The value's message when it has one, otherwise its string form.
7
+ *
8
+ * @example
9
+ * errorMessage(new Error("boom")); // "boom"
10
+ * errorMessage(42); // "42"
11
+ */
12
+ function errorMessage(error) {
13
+ return Error.isError(error) || isErrorLike(error) ? error.message : String(error);
14
+ }
15
+ export { errorMessage };
16
+ //# sourceMappingURL=error-message.js.map