ranuts 0.4.1-alpha.2 → 0.5.1

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 (333) hide show
  1. package/CLAUDE.md +23 -16
  2. package/README.de.md +62 -0
  3. package/README.es.md +62 -0
  4. package/README.fa.md +62 -0
  5. package/README.ja.md +62 -0
  6. package/README.ko.md +62 -0
  7. package/README.md +35 -92
  8. package/README.pt.md +62 -0
  9. package/README.zh-CN.md +35 -91
  10. package/dist/iife/index.iife.js +4 -0
  11. package/dist/iife/utils.iife.js +4 -0
  12. package/dist/index.d.ts +1 -1
  13. package/dist/index.js +307 -1
  14. package/dist/src/_virtual/_rolldown/runtime/index.js +12 -0
  15. package/dist/src/conversation/engine.d.ts +1 -1
  16. package/dist/src/conversation/engine.js +101 -0
  17. package/dist/src/conversation/index.d.ts +3 -3
  18. package/dist/src/conversation/index.js +4 -1
  19. package/dist/src/stream/accumulator.d.ts +1 -1
  20. package/dist/src/stream/accumulator.js +79 -0
  21. package/dist/src/stream/budget.d.ts +1 -1
  22. package/dist/src/stream/budget.js +45 -0
  23. package/dist/src/stream/index.d.ts +7 -7
  24. package/dist/src/stream/index.js +11 -1
  25. package/dist/src/stream/sse.d.ts +1 -1
  26. package/dist/src/stream/sse.js +61 -0
  27. package/dist/src/sw/index.js +52 -1
  28. package/dist/src/utils/async.js +49 -0
  29. package/dist/src/utils/audioRecorder.js +1121 -0
  30. package/dist/src/utils/behavior.js +9 -0
  31. package/dist/src/utils/binary.js +89 -0
  32. package/dist/src/utils/bom.d.ts +31 -9
  33. package/dist/src/utils/bom.js +165 -0
  34. package/dist/src/utils/bridge.js +310 -0
  35. package/dist/src/utils/canvas.js +103 -0
  36. package/dist/src/utils/chain.js +76 -0
  37. package/dist/src/utils/charset.d.ts +15 -0
  38. package/dist/src/utils/charset.js +21 -0
  39. package/dist/src/utils/color.d.ts +0 -1
  40. package/dist/src/utils/color.js +312 -0
  41. package/dist/src/utils/compose.js +22 -0
  42. package/dist/src/utils/console.js +22 -0
  43. package/dist/src/utils/debounce.js +18 -0
  44. package/dist/src/utils/device.d.ts +0 -9
  45. package/dist/src/utils/device.js +31 -0
  46. package/dist/src/utils/diff.js +110 -0
  47. package/dist/src/utils/dom.d.ts +1 -1
  48. package/dist/src/utils/dom.js +89 -0
  49. package/dist/src/utils/error.js +11 -0
  50. package/dist/src/utils/event.d.ts +3 -3
  51. package/dist/src/utils/event.js +39 -0
  52. package/dist/src/utils/file.js +14 -0
  53. package/dist/src/utils/func.js +4 -0
  54. package/dist/src/utils/i18n/index.js +79 -1
  55. package/dist/src/utils/idb.js +177 -0
  56. package/dist/src/utils/img.d.ts +1 -1
  57. package/dist/src/utils/img.js +68 -0
  58. package/dist/src/utils/index.d.ts +82 -80
  59. package/dist/src/utils/index.js +307 -1
  60. package/dist/src/utils/lang.d.ts +23 -6
  61. package/dist/src/utils/lang.js +42 -0
  62. package/dist/src/utils/localePath.js +48 -0
  63. package/dist/src/utils/memoize.d.ts +1 -7
  64. package/dist/src/utils/memoize.js +16 -0
  65. package/dist/src/utils/mimeType.js +841 -0
  66. package/dist/src/utils/monitor.js +84 -0
  67. package/dist/src/utils/network.js +117 -0
  68. package/dist/src/utils/noop.js +5 -0
  69. package/dist/src/utils/number.js +185 -0
  70. package/dist/src/utils/obj.d.ts +2 -2
  71. package/dist/src/utils/obj.js +140 -0
  72. package/dist/src/utils/paginate.js +93 -0
  73. package/dist/src/utils/performance.js +26 -0
  74. package/dist/src/utils/placement.js +37 -0
  75. package/dist/src/utils/prefetch.js +69 -0
  76. package/dist/src/utils/queue.js +46 -0
  77. package/dist/src/utils/report.js +44 -0
  78. package/dist/src/utils/request.js +35 -0
  79. package/dist/src/utils/script.d.ts +4 -2
  80. package/dist/src/utils/script.js +45 -0
  81. package/dist/src/utils/scroll.d.ts +2 -0
  82. package/dist/src/utils/scroll.js +62 -0
  83. package/dist/src/utils/secure.js +36 -0
  84. package/dist/src/utils/segment.js +43 -0
  85. package/dist/src/utils/signal.d.ts +1 -1
  86. package/dist/src/utils/signal.js +13 -0
  87. package/dist/src/utils/speech.js +59 -0
  88. package/dist/src/utils/storage.js +53 -0
  89. package/dist/src/utils/str.d.ts +0 -21
  90. package/dist/src/utils/str.js +377 -0
  91. package/dist/src/utils/style.js +29 -0
  92. package/dist/src/utils/subscribe.js +58 -0
  93. package/dist/src/utils/throttle.js +17 -0
  94. package/dist/src/utils/time.d.ts +0 -21
  95. package/dist/src/utils/time.js +97 -0
  96. package/dist/src/utils/totp/sha/common.d.ts +1 -1
  97. package/dist/src/utils/totp/sha/common.js +201 -0
  98. package/dist/src/utils/totp/sha/converters.d.ts +1 -1
  99. package/dist/src/utils/totp/sha/converters.js +188 -0
  100. package/dist/src/utils/totp/sha/primitives_32.js +55 -0
  101. package/dist/src/utils/totp/sha/primitives_64.js +85 -0
  102. package/dist/src/utils/totp/sha/sha.d.ts +1 -1
  103. package/dist/src/utils/totp/sha/sha.js +30 -0
  104. package/dist/src/utils/totp/sha/sha1.d.ts +2 -2
  105. package/dist/src/utils/totp/sha/sha1.js +51 -0
  106. package/dist/src/utils/totp/sha/sha256.d.ts +2 -2
  107. package/dist/src/utils/totp/sha/sha256.js +56 -0
  108. package/dist/src/utils/totp/sha/sha3.d.ts +3 -3
  109. package/dist/src/utils/totp/sha/sha3.js +253 -0
  110. package/dist/src/utils/totp/sha/sha512.d.ts +3 -3
  111. package/dist/src/utils/totp/sha/sha512.js +177 -0
  112. package/dist/src/utils/totp/totp.js +49 -0
  113. package/dist/src/utils/tween.js +59 -0
  114. package/dist/src/utils/visual/application.d.ts +4 -4
  115. package/dist/src/utils/visual/application.js +42 -0
  116. package/dist/src/utils/visual/enums.js +19 -0
  117. package/dist/src/utils/visual/event/boundary.d.ts +2 -2
  118. package/dist/src/utils/visual/event/boundary.js +93 -0
  119. package/dist/src/utils/visual/event/event.d.ts +1 -1
  120. package/dist/src/utils/visual/event/event.js +34 -0
  121. package/dist/src/utils/visual/event/index.d.ts +4 -4
  122. package/dist/src/utils/visual/event/types.d.ts +2 -2
  123. package/dist/src/utils/visual/event/types.js +23 -0
  124. package/dist/src/utils/visual/graphics/graphics.d.ts +8 -8
  125. package/dist/src/utils/visual/graphics/graphics.js +168 -0
  126. package/dist/src/utils/visual/graphics/graphicsData.d.ts +3 -3
  127. package/dist/src/utils/visual/graphics/graphicsData.js +12 -0
  128. package/dist/src/utils/visual/graphics/graphicsGeometry.d.ts +7 -7
  129. package/dist/src/utils/visual/graphics/graphicsGeometry.js +39 -0
  130. package/dist/src/utils/visual/graphics/index.d.ts +3 -3
  131. package/dist/src/utils/visual/index.d.ts +8 -8
  132. package/dist/src/utils/visual/index.js +20 -1
  133. package/dist/src/utils/visual/math/bezier.js +15 -0
  134. package/dist/src/utils/visual/math/enums.js +6 -0
  135. package/dist/src/utils/visual/math/index.d.ts +4 -4
  136. package/dist/src/utils/visual/math/matrix.d.ts +1 -1
  137. package/dist/src/utils/visual/math/matrix.js +59 -0
  138. package/dist/src/utils/visual/math/transform.d.ts +2 -2
  139. package/dist/src/utils/visual/math/transform.js +50 -0
  140. package/dist/src/utils/visual/render/batchRenderer.d.ts +4 -4
  141. package/dist/src/utils/visual/render/batchRenderer.js +59 -0
  142. package/dist/src/utils/visual/render/canvasRenderer.d.ts +3 -3
  143. package/dist/src/utils/visual/render/canvasRenderer.js +17 -0
  144. package/dist/src/utils/visual/render/filter.d.ts +1 -1
  145. package/dist/src/utils/visual/render/filter.js +92 -0
  146. package/dist/src/utils/visual/render/index.d.ts +2 -2
  147. package/dist/src/utils/visual/render/index.js +20 -0
  148. package/dist/src/utils/visual/render/render.d.ts +4 -4
  149. package/dist/src/utils/visual/render/render.js +19 -0
  150. package/dist/src/utils/visual/render/renderTarget.js +28 -0
  151. package/dist/src/utils/visual/render/utils/batch/index.d.ts +4 -4
  152. package/dist/src/utils/visual/render/utils/batch/index.js +88 -0
  153. package/dist/src/utils/visual/render/utils/earcut.js +328 -0
  154. package/dist/src/utils/visual/render/utils/float.js +65 -0
  155. package/dist/src/utils/visual/render/utils/index.js +50 -0
  156. package/dist/src/utils/visual/render/utils/verticy.d.ts +2 -2
  157. package/dist/src/utils/visual/render/utils/verticy.js +162 -0
  158. package/dist/src/utils/visual/render/utils/webgl/initShader.d.ts +1 -1
  159. package/dist/src/utils/visual/render/utils/webgl/initShader.js +31 -0
  160. package/dist/src/utils/visual/render/utils/webgl/shaders.js +22 -0
  161. package/dist/src/utils/visual/render/utils/webgpu/shaders.js +32 -0
  162. package/dist/src/utils/visual/render/webGPURenderer.d.ts +2 -2
  163. package/dist/src/utils/visual/render/webGPURenderer.js +185 -0
  164. package/dist/src/utils/visual/render/webGlRenderer.d.ts +2 -2
  165. package/dist/src/utils/visual/render/webGlRenderer.js +88 -0
  166. package/dist/src/utils/visual/shape/circle.d.ts +3 -3
  167. package/dist/src/utils/visual/shape/circle.js +17 -0
  168. package/dist/src/utils/visual/shape/ellipse.d.ts +3 -3
  169. package/dist/src/utils/visual/shape/ellipse.js +18 -0
  170. package/dist/src/utils/visual/shape/index.d.ts +6 -6
  171. package/dist/src/utils/visual/shape/polygon.d.ts +3 -3
  172. package/dist/src/utils/visual/shape/polygon.js +29 -0
  173. package/dist/src/utils/visual/shape/rectangle.d.ts +3 -3
  174. package/dist/src/utils/visual/shape/rectangle.js +18 -0
  175. package/dist/src/utils/visual/shape/roundedRectangle.d.ts +3 -3
  176. package/dist/src/utils/visual/shape/roundedRectangle.js +32 -0
  177. package/dist/src/utils/visual/shape/shape.d.ts +2 -2
  178. package/dist/src/utils/visual/shape/shape.js +5 -0
  179. package/dist/src/utils/visual/style/fill.js +18 -0
  180. package/dist/src/utils/visual/style/index.d.ts +2 -2
  181. package/dist/src/utils/visual/style/line.d.ts +2 -2
  182. package/dist/src/utils/visual/style/line.js +18 -0
  183. package/dist/src/utils/visual/types.d.ts +1 -1
  184. package/dist/src/utils/visual/vertex/container.d.ts +5 -5
  185. package/dist/src/utils/visual/vertex/container.js +54 -0
  186. package/dist/src/utils/visual/vertex/point.js +37 -0
  187. package/dist/src/utils/visual/vertex/vertex.d.ts +7 -7
  188. package/dist/src/utils/visual/vertex/vertex.js +76 -0
  189. package/dist/src/utils/worker.js +89 -0
  190. package/dist/src/utils/zip.js +161 -0
  191. package/dist/src/vnode/h.d.ts +1 -1
  192. package/dist/src/vnode/h.js +22 -0
  193. package/dist/src/vnode/hooks.d.ts +1 -1
  194. package/dist/src/vnode/htmlDomApi.js +94 -0
  195. package/dist/src/vnode/index.d.ts +16 -16
  196. package/dist/src/vnode/index.js +28 -1
  197. package/dist/src/vnode/init.d.ts +1 -1
  198. package/dist/src/vnode/init.js +104 -0
  199. package/dist/src/vnode/is.d.ts +1 -1
  200. package/dist/src/vnode/is.js +20 -0
  201. package/dist/src/vnode/modules/attributes.d.ts +1 -1
  202. package/dist/src/vnode/modules/attributes.js +21 -0
  203. package/dist/src/vnode/modules/class.d.ts +1 -1
  204. package/dist/src/vnode/modules/class.js +18 -0
  205. package/dist/src/vnode/modules/index.js +15 -0
  206. package/dist/src/vnode/modules/listeners.d.ts +1 -1
  207. package/dist/src/vnode/modules/listeners.js +36 -0
  208. package/dist/src/vnode/modules/props.d.ts +1 -1
  209. package/dist/src/vnode/modules/props.js +17 -0
  210. package/dist/src/vnode/modules/style.d.ts +1 -1
  211. package/dist/src/vnode/modules/style.js +52 -0
  212. package/dist/src/vnode/vnode.d.ts +6 -6
  213. package/dist/src/vnode/vnode.js +13 -0
  214. package/dist/third-party/jschardet/LICENSE.txt +504 -0
  215. package/dist/third-party/jschardet/NOTICE.txt +33 -0
  216. package/docs/API.md +8 -64
  217. package/package.json +14 -18
  218. package/dist/bin/generate-api-docs.d.ts +0 -1
  219. package/dist/build/build.es.d.ts +0 -2
  220. package/dist/build/build.umd.d.ts +0 -2
  221. package/dist/build/build.umd.node.d.ts +0 -2
  222. package/dist/build/build.umd.utils.d.ts +0 -2
  223. package/dist/chain-CTywmh_H.js +0 -1
  224. package/dist/color-BTvZUuf-.js +0 -1
  225. package/dist/enums-BAgbyGdH.js +0 -1
  226. package/dist/examples/clone-deep-example.d.ts +0 -1
  227. package/dist/examples/is-equal-example.d.ts +0 -1
  228. package/dist/i18n-DW21b_DJ.js +0 -1
  229. package/dist/plugins/vite-plugins-banner.d.ts +0 -2
  230. package/dist/rolldown-runtime-I3TIJKkN.js +0 -1
  231. package/dist/src/node/appendFile.d.ts +0 -7
  232. package/dist/src/node/body.d.ts +0 -9
  233. package/dist/src/node/color.d.ts +0 -7
  234. package/dist/src/node/command.d.ts +0 -8
  235. package/dist/src/node/ctx2req.d.ts +0 -5
  236. package/dist/src/node/fileInfo.d.ts +0 -7
  237. package/dist/src/node/fs.d.ts +0 -7
  238. package/dist/src/node/get.d.ts +0 -10
  239. package/dist/src/node/getIPAdress.d.ts +0 -1
  240. package/dist/src/node/index.d.ts +0 -25
  241. package/dist/src/node/index.js +0 -1
  242. package/dist/src/node/isColorSupported.d.ts +0 -2
  243. package/dist/src/node/paresUrl.d.ts +0 -19
  244. package/dist/src/node/readDir.d.ts +0 -6
  245. package/dist/src/node/readFile.d.ts +0 -9
  246. package/dist/src/node/router.d.ts +0 -42
  247. package/dist/src/node/send.d.ts +0 -7
  248. package/dist/src/node/server.d.ts +0 -18
  249. package/dist/src/node/startTask.d.ts +0 -2
  250. package/dist/src/node/stream.d.ts +0 -15
  251. package/dist/src/node/taskEnd.d.ts +0 -2
  252. package/dist/src/node/traverse.d.ts +0 -17
  253. package/dist/src/node/watchFile.d.ts +0 -8
  254. package/dist/src/node/writeFile.d.ts +0 -8
  255. package/dist/src/node/ws.d.ts +0 -8
  256. package/dist/src/utils/visual/render/utils/batch/index.test.d.ts +0 -1
  257. package/dist/src/utils/visual/render/utils/index.test.d.ts +0 -1
  258. package/dist/test/binary.test.d.ts +0 -1
  259. package/dist/test/bridge.test.d.ts +0 -1
  260. package/dist/test/budget.test.d.ts +0 -1
  261. package/dist/test/canvas.test.d.ts +0 -1
  262. package/dist/test/clearBr.test.d.ts +0 -1
  263. package/dist/test/cloneDeep.test.d.ts +0 -1
  264. package/dist/test/color.test.d.ts +0 -1
  265. package/dist/test/command.test.d.ts +0 -1
  266. package/dist/test/conversation.test.d.ts +0 -1
  267. package/dist/test/diff.test.d.ts +0 -1
  268. package/dist/test/encodeUrl.test.d.ts +0 -1
  269. package/dist/test/escapeHtml.test.d.ts +0 -1
  270. package/dist/test/formatBytes.test.d.ts +0 -1
  271. package/dist/test/is-equal.test.d.ts +0 -1
  272. package/dist/test/mimeType.test.d.ts +0 -1
  273. package/dist/test/package-exports.test.d.ts +0 -1
  274. package/dist/test/scroll.test.d.ts +0 -1
  275. package/dist/test/server.test.d.ts +0 -1
  276. package/dist/test/status.test.d.ts +0 -1
  277. package/dist/test/stream.test.d.ts +0 -1
  278. package/dist/test/sw.test.d.ts +0 -1
  279. package/dist/test/totp.test.d.ts +0 -1
  280. package/dist/test/tween.test.d.ts +0 -1
  281. package/dist/test/utils/async.test.d.ts +0 -1
  282. package/dist/test/utils/autosize.test.d.ts +0 -1
  283. package/dist/test/utils/color-grade.test.d.ts +0 -1
  284. package/dist/test/utils/compose.test.d.ts +0 -1
  285. package/dist/test/utils/event.test.d.ts +0 -1
  286. package/dist/test/utils/file-read.test.d.ts +0 -1
  287. package/dist/test/utils/format.test.d.ts +0 -1
  288. package/dist/test/utils/i18n.test.d.ts +0 -1
  289. package/dist/test/utils/idb-collection.test.d.ts +0 -1
  290. package/dist/test/utils/idb.test.d.ts +0 -1
  291. package/dist/test/utils/instrumentation.test.d.ts +0 -1
  292. package/dist/test/utils/interp.test.d.ts +0 -1
  293. package/dist/test/utils/lang.test.d.ts +0 -1
  294. package/dist/test/utils/locale-path.test.d.ts +0 -1
  295. package/dist/test/utils/media-query.test.d.ts +0 -1
  296. package/dist/test/utils/mergeObj.test.d.ts +0 -1
  297. package/dist/test/utils/number-parse.test.d.ts +0 -1
  298. package/dist/test/utils/paginate.test.d.ts +0 -1
  299. package/dist/test/utils/placement.test.d.ts +0 -1
  300. package/dist/test/utils/prefetch.test.d.ts +0 -1
  301. package/dist/test/utils/query-storage.test.d.ts +0 -1
  302. package/dist/test/utils/queue.test.d.ts +0 -1
  303. package/dist/test/utils/report-config.test.d.ts +0 -1
  304. package/dist/test/utils/report-image.test.d.ts +0 -1
  305. package/dist/test/utils/secure.test.d.ts +0 -1
  306. package/dist/test/utils/segment.test.d.ts +0 -1
  307. package/dist/test/utils/signal-once.test.d.ts +0 -1
  308. package/dist/test/utils/single-flight.test.d.ts +0 -1
  309. package/dist/test/utils/speech.test.d.ts +0 -1
  310. package/dist/test/utils/text-boundary.test.d.ts +0 -1
  311. package/dist/test/utils/time.test.d.ts +0 -1
  312. package/dist/test/utils/timing.test.d.ts +0 -1
  313. package/dist/test/utils/truncate.test.d.ts +0 -1
  314. package/dist/test/utils/visual/filter.test.d.ts +0 -1
  315. package/dist/test/utils/worker-client.test.d.ts +0 -1
  316. package/dist/test/utils/worker-serve.test.d.ts +0 -1
  317. package/dist/test/utils/zip.test.d.ts +0 -1
  318. package/dist/test/visual/math.test.d.ts +0 -1
  319. package/dist/test/visual-application.test.d.ts +0 -1
  320. package/dist/test/visual-batch.test.d.ts +0 -1
  321. package/dist/test/visual-math.test.d.ts +0 -1
  322. package/dist/test/vnode/index.d.ts +0 -1
  323. package/dist/test/vnode/server.d.ts +0 -2
  324. package/dist/test/vnode/vnode.d.ts +0 -1
  325. package/dist/test/vnode.test.d.ts +0 -1
  326. package/dist/test/websocket.test.d.ts +0 -1
  327. package/dist/test/writeFile.test.d.ts +0 -1
  328. package/dist/umd/index.umd.cjs +0 -1
  329. package/dist/umd/node/node.umd.cjs +0 -1
  330. package/dist/umd/utils/utils.umd.cjs +0 -1
  331. package/dist/utils-B4FnyUzW.js +0 -1
  332. package/dist/vite.config.d.ts +0 -8
  333. package/dist/vitest.config.d.ts +0 -2
package/docs/API.md CHANGED
@@ -8,13 +8,12 @@ constraints, conventions) read [../CLAUDE.md](../CLAUDE.md) first.
8
8
  Import from the **subpath** that owns the symbol, e.g. `import { debounce } from
9
9
  'ranuts/utils'`. The root `ranuts` barrel re-exports the utils + visual surface.
10
10
 
11
- **454 exports** across 8 entry points.
11
+ **422 exports** across 7 entry points.
12
12
 
13
13
  ## Entry points
14
14
 
15
- - [`ranuts/utils`](#ranuts-utils) — Browser and general-purpose utilities · _browser + node_ · 339 exports
15
+ - [`ranuts/utils`](#ranuts-utils) — Browser and general-purpose utilities · _browser + node_ · 333 exports
16
16
  - [`ranuts/sw`](#ranuts-sw) — Service Worker caching strategies and the precache protocol · _service worker only_ · 9 exports
17
- - [`ranuts/node`](#ranuts-node) — Node server utilities (fs / http / ws / middleware) · _node only_ · 26 exports
18
17
  - [`ranuts/visual`](#ranuts-visual) — 2D rendering engine (Canvas / WebGL / WebGPU) · _browser only_ · 16 exports
19
18
  - [`ranuts/i18n`](#ranuts-i18n) — Framework-agnostic i18n engine (also re-exported from ranuts/utils) · _browser + node_ · 9 exports
20
19
  - [`ranuts/vnode`](#ranuts-vnode) — Snabbdom-style virtual DOM · _browser_ · 26 exports
@@ -58,7 +57,7 @@ import { /* … */ } from 'ranuts/utils';
58
57
  - `compose<T>(middleware: Array<Middleware<T>>) => ComposedMiddleware<T>` — Run a chain of async functions as if it were sequential
59
58
  - `computePlacement(options: ComputePlacementOptions) => ComputedPlacement` — Position a floating panel relative to an anchor rect: flips to the opposite
60
59
  - `concatBytes(chunks: readonly Uint8Array[]) => Uint8Array` — Join byte chunks into one buffer, in order.
61
- - `connection() => number | undefined` — Current network status: type, throughput, and whether the connection changed
60
+ - `connection() => NetworkInformation | undefined` — Current network status: type, throughput, and whether the connection changed
62
61
  - `convertImageToBase64(file: File) => Promise<convertImageToBase64Return>` — Convert an image to base64
63
62
  - `cosinePalette(t: number, a: RGB, b: RGB, c: RGB, d: RGB) => RGB` — Inigo Quilez cosine gradient palette: `a + b * cos(2π(c·t + d))`. Each of `a,b,c,d` is an RGB triple; `t` is the position 0..1. Returns an RGB triple.
64
63
  - `crc32(data: Uint8Array) => number` — CRC32 checksum (IEEE 802.3 polynomial), the one ZIP stores per entry.
@@ -70,7 +69,7 @@ import { /* … */ } from 'ranuts/utils';
70
69
  - `createHandoff<T>({ dbName, storeName, key }: HandoffOptions) => Handoff<T>` — A one-shot value handoff between two pages of the same origin, backed by
71
70
  - `createI18n<TDict extends StringValues<TDict> = MessageDict>(config?: I18nConfig<TDict>) => I18nCore<TDict>` — Create and register the global i18n singleton.
72
71
  - `createLocalePath(config: LocalePathConfig) => LocalePath` — Create the set of locale path conversion functions.
73
- - `createObjectURL(src: Blob | ArrayBuffer | Response) => Promise<string>`
72
+ - `createObjectURL(src: string | Blob | ArrayBuffer | Response) => Promise<string>`
74
73
  - `createPortBridge(port: MessagePort) => PortBridge` — Build a bridge on any MessagePort (a Web Worker, a SharedWorker, or a port from a completed handshake).
75
74
  - `createRaceGuard() => RaceGuard` — Bump-and-compare guard against a stale async response overwriting a newer
76
75
  - `createSignal<T = unknown>(value: T, options?: SignalOptions<T>) => [() => T, (newValue: T) => void]` — Create a minimal signal with optional event broadcasting, returned as
@@ -84,7 +83,7 @@ import { /* … */ } from 'ranuts/utils';
84
83
  - `decodeTextBytes(bytes: Uint8Array, encodings?: string[]) => string` — Decode text bytes, trying encodings in order until one holds.
85
84
  - `deferred<T = void>() => Deferred<T>` — A promise plus its `resolve` / `reject`, for the case where the thing that
86
85
  - `delay(ms: number) => Promise<void>` — Resolve after `ms` milliseconds. Uses the bare `setTimeout`, so it works in
87
- - `detectLanguage(text: string, sampleSize?: number) => TextLanguage` — Decide a text's primary language from the ratio of CJK to Latin characters.
86
+ - `detectLanguage(text: string, sampleSize?: number) => TextLanguage` — Decide a text's primary script from character ratios. Pure statistics, no
88
87
  - `diffLines(oldText: string, newText: string, options?: DiffOptions) => DiffHunk[]` — Diffs two texts by line.
89
88
  - `durationHandler<T, U>(handler: (...args: T[]) => U, ...params: T[]) => ((a: number) => Promise<U>)` — Run a function repeatedly at a fixed interval
90
89
  - `encodeUrl(url: string) => string` — Encode a URL to a percent-encoded form, excluding already-encoded sequences.
@@ -92,7 +91,7 @@ import { /* … */ } from 'ranuts/utils';
92
91
  - `fanShapedByArc(ctx: CanvasRenderingContext2D, maxRadius: number, start: number, end: number, gutter: number) => void` — Trace a pie slice with arc(), including the gutter between slices.
93
92
  - `fenceCode(body: string, lang?: string) => string` — Wrap text in a Markdown code fence long enough to survive backticks inside it.
94
93
  - `fetchMaybeGzip(input: RequestInfo | URL, init?: RequestInit) => Promise<Uint8Array>` — Fetch a resource that may be delivered gzipped or already
95
- - `filterObj(obj: Record<string, unknown>, list: Array<string>) => Record<string, unknown>` — Return a new object without the properties whose values appear in `list` — typically used to drop empty strings and nulls
94
+ - `filterObj(obj: Record<string, unknown>, list: Array<string>) => Record<string, unknown>` — Return a new object without the listed keys — typically used to drop fields before sending an object on
96
95
  - `fit(value: number, a1: number, a2: number, b1: number, b2: number) => number` — Remap `value` from `[a1, a2]` onto `[b1, b2]` and clamp to the output range — the shader `fit`.
97
96
  - `formatBytes(bytes: number) => string` — Format a byte count for a person to read.
98
97
  - `formatDate(value?: DateInput, pattern?: string) => string` — Format a date with a token pattern. Accepts a timestamp, a date string, a
@@ -161,8 +160,6 @@ import { /* … */ } from 'ranuts/utils';
161
160
  - `luma(r: number, g: number, b: number) => number` — Perceived brightness (luma) of an RGB colour using Rec. 601 weights. Channels may be 0..1 or 0..255 — the result keeps that scale.
162
161
  - `matchMediaQuery(query: string) => boolean` — Read whether a media query currently matches, synchronously. Returns false under SSR.
163
162
  - `mathjs(a: number, type: string, b: number) => ComputeNumberResult`
164
- - `md5(str: string) => string` — MD5 hash function implementation
165
- - `memoize<T extends Func>(fn: T | unknown) => ((...args: Parameters<T>) => ReturnType<T>)` — Former name of `once`. The name is misleading — it does not cache per
166
163
  - `merge(a: Obj, b?: Obj) => Obj` — Merge objects
167
164
  - `mergeExports(obj: Record<string, string>, exports: Record<string, string>) => Record<string, string>` — Copy an exports object onto `obj`, then freeze it
168
165
  - `navigatorLanguage() => TextLanguage` — Map the browser UI language into the same buckets (the default when there is
@@ -198,7 +195,7 @@ import { /* … */ } from 'ranuts/utils';
198
195
  - `removeClassToElement(element: Element, removeClass: string) => void` — Remove a class from an element
199
196
  - `replaceOld(source: any, name: string, replacement: (...args: unknown[]) => unknown, isForced?: boolean) => () => void` — Replace a property on an object, wrapping whatever was there before.
200
197
  - `report({ url, type, payload }: BeaconPayload) => boolean` — Send a telemetry beacon. Prefers `navigator.sendBeacon` (does not block
201
- - `requestUrlToBuffer(src: string, options: Partial<RequestUrlToArraybufferOption>) => Promise<requestUrlToArraybufferReturn>` — Fetch a URL as an ArrayBuffer
198
+ - `requestUrlToBuffer{ (src: string, options?: Partial<RequestUrlToArraybufferOption<'' | 'arraybuffer'>>): Promise<requestUrlToArraybufferReturn>; <T extends XML… (+2 overloads)` — Fetch a URL as an ArrayBuffer by default, or as the requested XHR response type
202
199
  - `resolveLocale(options: ResolveLocaleOptions) => string` — Resolve which of your supported locales to use, from the usual chain:
203
200
  - `rewriteZip(bytes: Uint8Array, options?: RewriteZipOptions) => Promise<Uint8Array>` — Rebuild an archive with some entries replaced and/or new entries appended.
204
201
  - `rgbaString(r: number, g: number, b: number, a: number) => string` — Build a CSS `rgba()` string. Alpha is 0–100 rather than 0–1, matching the
@@ -226,8 +223,6 @@ import { /* … */ } from 'ranuts/utils';
226
223
  - `srgbToLinear(c: number) => number` — Convert one sRGB channel (0..1) to linear-light (IEC 61966-2-1 transfer function).
227
224
  - `strParse(str?: string, sep?: string | RegExp, eq?: string | RegExp) => Record<string, string>` — Parse a delimited string into an object, e.g.
228
225
  - `throttle<T extends (...args: any[]) => any>(fn: T, delay?: number) => Throttled<T>` — Throttle — under a burst of calls, run at a fixed interval: the first call
229
- - `timeFormat(time: number) => string` — Format a number of seconds as a colon-separated duration
230
- - `timestampToTime(timestamp?: number | string) => Date & { format?: Function; }` — Turn a timestamp into a `Date` carrying a `format` method.
231
226
  - `toFullWidth(value: string) => string` — Convert half-width characters to full-width (the inverse of `toHalfWidth`)
232
227
  - `toHalfWidth(value: string) => string` — Convert full-width characters to half-width (digits, letters, punctuation and
233
228
  - `toString(value: string | number) => string`
@@ -349,7 +344,7 @@ import { /* … */ } from 'ranuts/utils';
349
344
  - `type RGB` — An RGB triple with each channel in 0..1 (linear or sRGB depending on the operation).
350
345
  - `type SpeechErrorKind` — `denied` means the user or the browser refused the microphone — worth surfacing.
351
346
  - `type StringValues` — "An object whose values are all strings" — the constraint the dictionary type parameter
352
- - `type TextLanguage` — Coarse language bucket: Chinese / English / other only
347
+ - `type TextLanguage` — Coarse script bucket: the four writing systems that need different handling, plus
353
348
  - `type TranslateParams`
354
349
  - `type TruncatePosition` — Which end of the string gets dropped when it is too long.
355
350
 
@@ -364,9 +359,7 @@ import { /* … */ } from 'ranuts/utils';
364
359
  - `const cubic: SpeedType`
365
360
  - `const DEFAULT_CHANNEL: "default"`
366
361
  - `const expo: SpeedType`
367
- - `const FMT: Record<string, string[]>`
368
362
  - `const HEX_COLOR_REGEX: RegExp` — `#rgb` / `#rrggbb` (the `#` is required)
369
- - `const isClient: boolean` — Whether a `window` existed **when this module was first imported**.
370
363
  - `const MessageCodec: { encode(data: any): string; decode<T = any>(encodedStr: string): T | null; encodeFile(file: File): Promise<string>; decodeFile(encoded: st…` — Message codec.
371
364
  - `const MimeType: Map<string, string>`
372
365
  - `const MOBILE_MEDIA_QUERY: "(max-width: 768px)"` — Viewport breakpoint, matching where the mobile layout takes over
@@ -406,55 +399,6 @@ import { /* … */ } from 'ranuts/sw';
406
399
  - `interface ServePrecacheOptions`
407
400
  - `interface SWScope` — Minimal view of the SW global the helpers touch, so they can be unit-tested with a stub.
408
401
 
409
- ## `ranuts/node`
410
-
411
- Node server utilities (fs / http / ws / middleware) · runtime: **node only** · source: `src/node/index.ts`
412
-
413
- ```ts
414
- import { /* … */ } from 'ranuts/node';
415
- ```
416
-
417
- ### Functions
418
-
419
- - `appendFile(path: string, content: string) => Promise<Ranuts.Identification>` — Append content to an existing file
420
- - `bodyMiddleware(options?: Partial<ServerBody>) => MiddlewareFunction`
421
- - `connect(connectMiddleware: ConnectMiddleware) => MiddlewareFunction`
422
- - `get({ url }: Request) => Promise<Response>`
423
- - `getIPAdress() => string | undefined`
424
- - `default(req: Req) => ParseUrl | undefined` — Parse an IncomingMessage's request URL; the return type is always ParseUrl
425
- - `prompt({ message, stream, defaultResponse }: PromptOption) => Promise<boolean>`
426
- - `queryFileInfo(path: string) => Promise<Ranuts.Identification>` — Stat a file — typically to tell a file from a directory via data.isDirectory()
427
- - `readDir(options: Options) => Array<string>`
428
- - `readFile(path: string, format?: BufferEncoding) => FilePromiseResult` — Read a file, returning a status code and the content on success
429
- - `readStream(option: ReadOption) => ReadStream`
430
- - `runCommand(command: string, args: string[]) => Promise<void>`
431
- - `startTask() => symbol`
432
- - `staticMiddleware(option?: Partial<Option>) => MiddlewareFunction`
433
- - `taskEnd(symbol: symbol) => number | bigint`
434
- - `traverse(dir: string, callback: Caller, pre?: string) => Promise<any>` — Walk every directory recursively, running a function for each file found
435
- - `traverseSync(dir: string, callback: Caller, pre?: string) => void` — Synchronous: walk every directory recursively, running a function for each file found
436
- - `watchFile(path: string, interval?: number) => Promise<Ranuts.Identification>` — Watch a file for changes and report its status
437
- - `writeFile(path: string, content: string) => Promise<Ranuts.Identification>` — Write a file at the given path, truncating it if it exists and creating it if it does not
438
- - `writeStream(option: WriteOption) => WriteStream`
439
- - `WSS(this: any, server: http.Server) => void` — Create a WebSocket Server
440
-
441
- ### Classes
442
-
443
- - `class Router`
444
- - `class Server`
445
-
446
- ### Interfaces
447
-
448
- - `interface Context`
449
-
450
- ### Constants
451
-
452
- - `const isColorSupported: boolean`
453
-
454
- ### Other
455
-
456
- - `default`
457
-
458
402
  ## `ranuts/visual`
459
403
 
460
404
  2D rendering engine (Canvas / WebGL / WebGPU) · runtime: **browser only** · source: `src/utils/visual/index.ts`
package/package.json CHANGED
@@ -1,29 +1,25 @@
1
1
  {
2
2
  "name": "ranuts",
3
- "version": "0.4.1-alpha.2",
3
+ "version": "0.5.1",
4
4
  "description": "Tree-shakeable TypeScript utility library: DOM/BOM helpers, string/object/number/color utils, debounce/throttle/compose, a 2D rendering engine and a virtual DOM.",
5
- "main": "dist/umd/index.umd.cjs",
5
+ "main": "dist/index.js",
6
6
  "module": "dist/index.js",
7
7
  "type": "module",
8
+ "sideEffects": [
9
+ "./dist/iife/**"
10
+ ],
8
11
  "types": "dist/index.d.ts",
9
12
  "engines": {
10
- "node": ">=23.10.0"
13
+ "node": ">=24.0.0"
11
14
  },
12
15
  "exports": {
13
16
  ".": {
14
17
  "types": "./dist/index.d.ts",
15
- "import": "./dist/index.js",
16
- "require": "./dist/umd/index.umd.cjs"
17
- },
18
- "./node": {
19
- "types": "./dist/src/node/index.d.ts",
20
- "import": "./dist/src/node/index.js",
21
- "require": "./dist/umd/node/node.umd.cjs"
18
+ "import": "./dist/index.js"
22
19
  },
23
20
  "./utils": {
24
21
  "types": "./dist/src/utils/index.d.ts",
25
- "import": "./dist/src/utils/index.js",
26
- "require": "./dist/umd/utils/utils.umd.cjs"
22
+ "import": "./dist/src/utils/index.js"
27
23
  },
28
24
  "./visual": {
29
25
  "types": "./dist/src/utils/visual/index.d.ts",
@@ -97,14 +93,14 @@
97
93
  "license": "MIT",
98
94
  "devDependencies": {
99
95
  "@types/node": "26.1.2",
100
- "@vitest/coverage-v8": "4.1.10",
96
+ "@vitest/coverage-v8": "4.1.11",
101
97
  "@webgpu/types": "0.1.71",
102
- "jsdom": "29.1.1",
98
+ "jsdom": "30.0.1",
103
99
  "terser": "5.49.2",
104
100
  "tsx": "4.23.10",
105
101
  "typescript": "7.0.2",
106
- "vite": "8.2.1",
107
- "vitest": "4.1.10"
102
+ "vite": "8.2.4",
103
+ "vitest": "4.1.11"
108
104
  },
109
105
  "dependencies": {
110
106
  "jschardet": "3.1.4"
@@ -113,10 +109,10 @@
113
109
  "build": "sh ./bin/build.sh",
114
110
  "test": "vitest run",
115
111
  "test:coverage": "vitest run --coverage",
112
+ "verify:package": "node bin/verify-package.ts",
116
113
  "tsc": "tsc --noEmit",
117
114
  "dev": "vite --host",
118
115
  "doc:api": "tsx ./bin/generate-api-docs.ts",
119
- "doc:api:check": "tsx ./bin/generate-api-docs.ts --check",
120
- "prepublish": "npm run build"
116
+ "doc:api:check": "tsx ./bin/generate-api-docs.ts --check"
121
117
  }
122
118
  }
@@ -1 +0,0 @@
1
- export {};
@@ -1,2 +0,0 @@
1
- declare const _default: import("vite").UserConfig;
2
- export default _default;
@@ -1,2 +0,0 @@
1
- declare const _default: import("vite").UserConfig;
2
- export default _default;
@@ -1,2 +0,0 @@
1
- declare const _default: import("vite").UserConfig;
2
- export default _default;
@@ -1,2 +0,0 @@
1
- declare const _default: import("vite").UserConfig;
2
- export default _default;
@@ -1 +0,0 @@
1
- var e=["svg","path","g","circle","rect","line","polyline","polygon","ellipse","text","tspan","textPath","defs","marker","radialGradient","stop","linearGradient","clipPath","mask","pattern","image","use","symbol","foreignObject","feGaussianBlur","feColorMatrix"],t=class t{listener;element;constructor(e,t){this.element=this.create(e,t),this.listener=/* @__PURE__ */new Map}create=(t,n)=>e.includes(t)?document.createElementNS("http://www.w3.org/2000/svg",t,n):document.createElement(t,n);setAttribute=(e,t)=>(this.element.setAttribute(e,t),this);removeAttribute=e=>(this.element.removeAttribute(e),this);append=e=>(this.element.appendChild(e),this);remove=e=>(this.element.removeChild(e),this);setTextContent=e=>(this.element.textContent=e,this);setStyle=(e,t)=>(this.element.style.setProperty(e,t),this);addElementByType=(e,n)=>{e instanceof t&&n.appendChild(e.element),e instanceof HTMLElement&&n.appendChild(e)};addChild=e=>{if(Array.isArray(e)){const t=document.createDocumentFragment();e.forEach(e=>{this.addElementByType(e,t)}),this.element.appendChild(t)}else this.addElementByType(e,this.element);return this};listen=(e,t,n)=>{let s=this.listener.get(e);s||(s=/* @__PURE__ */new Map,this.listener.set(e,s));const i=s.get(t.name);return i===t&&console.warn(`${i.name} listener has been added to ${e} event, please remove it first.`),this.element.addEventListener(e,t,n),s.set(t.name,t),this};clearListener=(e,t,n)=>{this.element.removeEventListener(e,t,n);const s=this.listener.get(e);return s?s.delete(t.name):console.warn(`No ${e} event listener has been added.`),this};clearAllListener=()=>{for(const[e,t]of this.listener){for(const[n,s]of t)this.element.removeEventListener(e,s),t.delete(n);this.listener.delete(e)}return this}},n=(e,n)=>new t(e,n);export{n,t};