ranuts 0.4.1-alpha.1 → 0.5.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 (331) hide show
  1. package/CLAUDE.md +178 -26
  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 -90
  8. package/README.pt.md +62 -0
  9. package/README.zh-CN.md +35 -89
  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 +306 -1
  14. package/dist/src/_virtual/_rolldown/runtime/index.js +12 -0
  15. package/dist/src/conversation/engine.d.ts +109 -0
  16. package/dist/src/conversation/engine.js +101 -0
  17. package/dist/src/conversation/index.d.ts +12 -0
  18. package/dist/src/conversation/index.js +4 -0
  19. package/dist/src/conversation/types.d.ts +99 -0
  20. package/dist/src/stream/accumulator.d.ts +51 -0
  21. package/dist/src/stream/accumulator.js +79 -0
  22. package/dist/src/stream/budget.d.ts +89 -0
  23. package/dist/src/stream/budget.js +45 -0
  24. package/dist/src/stream/index.d.ts +25 -0
  25. package/dist/src/stream/index.js +11 -0
  26. package/dist/src/stream/sse.d.ts +51 -0
  27. package/dist/src/stream/sse.js +61 -0
  28. package/dist/src/stream/types.d.ts +106 -0
  29. package/dist/src/sw/index.js +52 -1
  30. package/dist/src/utils/async.js +49 -0
  31. package/dist/src/utils/audioRecorder.js +1121 -0
  32. package/dist/src/utils/behavior.js +9 -0
  33. package/dist/src/utils/binary.js +89 -0
  34. package/dist/src/utils/bom.d.ts +31 -9
  35. package/dist/src/utils/bom.js +165 -0
  36. package/dist/src/utils/bridge.js +310 -0
  37. package/dist/src/utils/canvas.d.ts +1 -0
  38. package/dist/src/utils/canvas.js +103 -0
  39. package/dist/src/utils/chain.js +76 -0
  40. package/dist/src/utils/color.d.ts +0 -1
  41. package/dist/src/utils/color.js +312 -0
  42. package/dist/src/utils/compose.js +22 -0
  43. package/dist/src/utils/console.js +22 -0
  44. package/dist/src/utils/debounce.js +18 -0
  45. package/dist/src/utils/device.d.ts +0 -9
  46. package/dist/src/utils/device.js +31 -0
  47. package/dist/src/utils/diff.d.ts +51 -0
  48. package/dist/src/utils/diff.js +110 -0
  49. package/dist/src/utils/dom.d.ts +1 -1
  50. package/dist/src/utils/dom.js +89 -0
  51. package/dist/src/utils/error.js +11 -0
  52. package/dist/src/utils/event.d.ts +3 -3
  53. package/dist/src/utils/event.js +39 -0
  54. package/dist/src/utils/file.js +14 -0
  55. package/dist/src/utils/func.js +4 -0
  56. package/dist/src/utils/i18n/index.js +79 -1
  57. package/dist/src/utils/idb.js +177 -0
  58. package/dist/src/utils/img.d.ts +1 -1
  59. package/dist/src/utils/img.js +68 -0
  60. package/dist/src/utils/index.d.ts +81 -77
  61. package/dist/src/utils/index.js +306 -1
  62. package/dist/src/utils/lang.d.ts +23 -6
  63. package/dist/src/utils/lang.js +42 -0
  64. package/dist/src/utils/localePath.js +48 -0
  65. package/dist/src/utils/memoize.d.ts +1 -7
  66. package/dist/src/utils/memoize.js +16 -0
  67. package/dist/src/utils/mimeType.js +841 -0
  68. package/dist/src/utils/monitor.js +84 -0
  69. package/dist/src/utils/network.js +117 -0
  70. package/dist/src/utils/noop.js +5 -0
  71. package/dist/src/utils/number.d.ts +20 -0
  72. package/dist/src/utils/number.js +185 -0
  73. package/dist/src/utils/obj.d.ts +2 -2
  74. package/dist/src/utils/obj.js +140 -0
  75. package/dist/src/utils/paginate.js +93 -0
  76. package/dist/src/utils/performance.js +26 -0
  77. package/dist/src/utils/placement.d.ts +42 -5
  78. package/dist/src/utils/placement.js +37 -0
  79. package/dist/src/utils/prefetch.js +69 -0
  80. package/dist/src/utils/queue.js +46 -0
  81. package/dist/src/utils/report.js +44 -0
  82. package/dist/src/utils/request.js +35 -0
  83. package/dist/src/utils/script.d.ts +1 -1
  84. package/dist/src/utils/script.js +46 -0
  85. package/dist/src/utils/scroll.d.ts +93 -0
  86. package/dist/src/utils/scroll.js +62 -0
  87. package/dist/src/utils/secure.js +36 -0
  88. package/dist/src/utils/segment.js +43 -0
  89. package/dist/src/utils/signal.d.ts +1 -1
  90. package/dist/src/utils/signal.js +13 -0
  91. package/dist/src/utils/speech.js +59 -0
  92. package/dist/src/utils/storage.js +53 -0
  93. package/dist/src/utils/str.d.ts +0 -6
  94. package/dist/src/utils/str.js +395 -0
  95. package/dist/src/utils/style.js +29 -0
  96. package/dist/src/utils/subscribe.js +58 -0
  97. package/dist/src/utils/throttle.js +17 -0
  98. package/dist/src/utils/time.d.ts +0 -21
  99. package/dist/src/utils/time.js +97 -0
  100. package/dist/src/utils/totp/sha/common.d.ts +1 -1
  101. package/dist/src/utils/totp/sha/common.js +201 -0
  102. package/dist/src/utils/totp/sha/converters.d.ts +1 -1
  103. package/dist/src/utils/totp/sha/converters.js +188 -0
  104. package/dist/src/utils/totp/sha/primitives_32.js +55 -0
  105. package/dist/src/utils/totp/sha/primitives_64.js +85 -0
  106. package/dist/src/utils/totp/sha/sha.d.ts +1 -1
  107. package/dist/src/utils/totp/sha/sha.js +30 -0
  108. package/dist/src/utils/totp/sha/sha1.d.ts +2 -2
  109. package/dist/src/utils/totp/sha/sha1.js +51 -0
  110. package/dist/src/utils/totp/sha/sha256.d.ts +2 -2
  111. package/dist/src/utils/totp/sha/sha256.js +56 -0
  112. package/dist/src/utils/totp/sha/sha3.d.ts +3 -3
  113. package/dist/src/utils/totp/sha/sha3.js +253 -0
  114. package/dist/src/utils/totp/sha/sha512.d.ts +3 -3
  115. package/dist/src/utils/totp/sha/sha512.js +177 -0
  116. package/dist/src/utils/totp/totp.js +49 -0
  117. package/dist/src/utils/tween.js +59 -0
  118. package/dist/src/utils/visual/application.d.ts +4 -4
  119. package/dist/src/utils/visual/application.js +42 -0
  120. package/dist/src/utils/visual/enums.js +19 -0
  121. package/dist/src/utils/visual/event/boundary.d.ts +2 -2
  122. package/dist/src/utils/visual/event/boundary.js +93 -0
  123. package/dist/src/utils/visual/event/event.d.ts +1 -1
  124. package/dist/src/utils/visual/event/event.js +34 -0
  125. package/dist/src/utils/visual/event/index.d.ts +4 -4
  126. package/dist/src/utils/visual/event/types.d.ts +2 -2
  127. package/dist/src/utils/visual/event/types.js +23 -0
  128. package/dist/src/utils/visual/graphics/graphics.d.ts +8 -8
  129. package/dist/src/utils/visual/graphics/graphics.js +168 -0
  130. package/dist/src/utils/visual/graphics/graphicsData.d.ts +3 -3
  131. package/dist/src/utils/visual/graphics/graphicsData.js +12 -0
  132. package/dist/src/utils/visual/graphics/graphicsGeometry.d.ts +7 -7
  133. package/dist/src/utils/visual/graphics/graphicsGeometry.js +39 -0
  134. package/dist/src/utils/visual/graphics/index.d.ts +3 -3
  135. package/dist/src/utils/visual/index.d.ts +8 -8
  136. package/dist/src/utils/visual/index.js +20 -1
  137. package/dist/src/utils/visual/math/bezier.js +15 -0
  138. package/dist/src/utils/visual/math/enums.js +6 -0
  139. package/dist/src/utils/visual/math/index.d.ts +4 -4
  140. package/dist/src/utils/visual/math/matrix.d.ts +1 -1
  141. package/dist/src/utils/visual/math/matrix.js +59 -0
  142. package/dist/src/utils/visual/math/transform.d.ts +2 -2
  143. package/dist/src/utils/visual/math/transform.js +50 -0
  144. package/dist/src/utils/visual/render/batchRenderer.d.ts +4 -4
  145. package/dist/src/utils/visual/render/batchRenderer.js +59 -0
  146. package/dist/src/utils/visual/render/canvasRenderer.d.ts +3 -3
  147. package/dist/src/utils/visual/render/canvasRenderer.js +17 -0
  148. package/dist/src/utils/visual/render/filter.d.ts +1 -1
  149. package/dist/src/utils/visual/render/filter.js +92 -0
  150. package/dist/src/utils/visual/render/index.d.ts +2 -2
  151. package/dist/src/utils/visual/render/index.js +20 -0
  152. package/dist/src/utils/visual/render/render.d.ts +4 -4
  153. package/dist/src/utils/visual/render/render.js +19 -0
  154. package/dist/src/utils/visual/render/renderTarget.js +28 -0
  155. package/dist/src/utils/visual/render/utils/batch/index.d.ts +4 -4
  156. package/dist/src/utils/visual/render/utils/batch/index.js +88 -0
  157. package/dist/src/utils/visual/render/utils/earcut.js +328 -0
  158. package/dist/src/utils/visual/render/utils/float.js +65 -0
  159. package/dist/src/utils/visual/render/utils/index.js +50 -0
  160. package/dist/src/utils/visual/render/utils/verticy.d.ts +2 -2
  161. package/dist/src/utils/visual/render/utils/verticy.js +162 -0
  162. package/dist/src/utils/visual/render/utils/webgl/initShader.d.ts +1 -1
  163. package/dist/src/utils/visual/render/utils/webgl/initShader.js +31 -0
  164. package/dist/src/utils/visual/render/utils/webgl/shaders.js +22 -0
  165. package/dist/src/utils/visual/render/utils/webgpu/shaders.js +32 -0
  166. package/dist/src/utils/visual/render/webGPURenderer.d.ts +2 -2
  167. package/dist/src/utils/visual/render/webGPURenderer.js +185 -0
  168. package/dist/src/utils/visual/render/webGlRenderer.d.ts +2 -2
  169. package/dist/src/utils/visual/render/webGlRenderer.js +88 -0
  170. package/dist/src/utils/visual/shape/circle.d.ts +3 -3
  171. package/dist/src/utils/visual/shape/circle.js +17 -0
  172. package/dist/src/utils/visual/shape/ellipse.d.ts +3 -3
  173. package/dist/src/utils/visual/shape/ellipse.js +18 -0
  174. package/dist/src/utils/visual/shape/index.d.ts +6 -6
  175. package/dist/src/utils/visual/shape/polygon.d.ts +3 -3
  176. package/dist/src/utils/visual/shape/polygon.js +29 -0
  177. package/dist/src/utils/visual/shape/rectangle.d.ts +3 -3
  178. package/dist/src/utils/visual/shape/rectangle.js +18 -0
  179. package/dist/src/utils/visual/shape/roundedRectangle.d.ts +3 -3
  180. package/dist/src/utils/visual/shape/roundedRectangle.js +32 -0
  181. package/dist/src/utils/visual/shape/shape.d.ts +2 -2
  182. package/dist/src/utils/visual/shape/shape.js +5 -0
  183. package/dist/src/utils/visual/style/fill.js +18 -0
  184. package/dist/src/utils/visual/style/index.d.ts +2 -2
  185. package/dist/src/utils/visual/style/line.d.ts +2 -2
  186. package/dist/src/utils/visual/style/line.js +18 -0
  187. package/dist/src/utils/visual/types.d.ts +1 -1
  188. package/dist/src/utils/visual/vertex/container.d.ts +5 -5
  189. package/dist/src/utils/visual/vertex/container.js +54 -0
  190. package/dist/src/utils/visual/vertex/point.js +37 -0
  191. package/dist/src/utils/visual/vertex/vertex.d.ts +7 -7
  192. package/dist/src/utils/visual/vertex/vertex.js +76 -0
  193. package/dist/src/utils/worker.js +89 -0
  194. package/dist/src/utils/zip.js +161 -0
  195. package/dist/src/vnode/h.d.ts +1 -1
  196. package/dist/src/vnode/h.js +22 -0
  197. package/dist/src/vnode/hooks.d.ts +1 -1
  198. package/dist/src/vnode/htmlDomApi.js +94 -0
  199. package/dist/src/vnode/index.d.ts +16 -16
  200. package/dist/src/vnode/index.js +28 -1
  201. package/dist/src/vnode/init.d.ts +1 -1
  202. package/dist/src/vnode/init.js +104 -0
  203. package/dist/src/vnode/is.d.ts +1 -1
  204. package/dist/src/vnode/is.js +20 -0
  205. package/dist/src/vnode/modules/attributes.d.ts +1 -1
  206. package/dist/src/vnode/modules/attributes.js +21 -0
  207. package/dist/src/vnode/modules/class.d.ts +1 -1
  208. package/dist/src/vnode/modules/class.js +18 -0
  209. package/dist/src/vnode/modules/index.js +15 -0
  210. package/dist/src/vnode/modules/listeners.d.ts +1 -1
  211. package/dist/src/vnode/modules/listeners.js +36 -0
  212. package/dist/src/vnode/modules/props.d.ts +1 -1
  213. package/dist/src/vnode/modules/props.js +17 -0
  214. package/dist/src/vnode/modules/style.d.ts +1 -1
  215. package/dist/src/vnode/modules/style.js +52 -0
  216. package/dist/src/vnode/vnode.d.ts +6 -6
  217. package/dist/src/vnode/vnode.js +13 -0
  218. package/dist/third-party/jschardet/LICENSE.txt +504 -0
  219. package/dist/third-party/jschardet/NOTICE.txt +33 -0
  220. package/docs/API.md +86 -65
  221. package/package.json +20 -15
  222. package/dist/bin/generate-api-docs.d.ts +0 -1
  223. package/dist/build/build.es.d.ts +0 -2
  224. package/dist/build/build.umd.d.ts +0 -2
  225. package/dist/build/build.umd.node.d.ts +0 -2
  226. package/dist/build/build.umd.utils.d.ts +0 -2
  227. package/dist/chain-CTywmh_H.js +0 -1
  228. package/dist/color-B_KMM8UX.js +0 -1
  229. package/dist/enums-BAgbyGdH.js +0 -1
  230. package/dist/examples/clone-deep-example.d.ts +0 -1
  231. package/dist/examples/is-equal-example.d.ts +0 -1
  232. package/dist/i18n-BJIS1fR1.js +0 -1
  233. package/dist/plugins/vite-plugins-banner.d.ts +0 -2
  234. package/dist/rolldown-runtime-I3TIJKkN.js +0 -1
  235. package/dist/src/node/appendFile.d.ts +0 -7
  236. package/dist/src/node/body.d.ts +0 -9
  237. package/dist/src/node/color.d.ts +0 -7
  238. package/dist/src/node/command.d.ts +0 -8
  239. package/dist/src/node/ctx2req.d.ts +0 -5
  240. package/dist/src/node/fileInfo.d.ts +0 -7
  241. package/dist/src/node/fs.d.ts +0 -7
  242. package/dist/src/node/get.d.ts +0 -10
  243. package/dist/src/node/getIPAdress.d.ts +0 -1
  244. package/dist/src/node/index.d.ts +0 -25
  245. package/dist/src/node/index.js +0 -1
  246. package/dist/src/node/isColorSupported.d.ts +0 -2
  247. package/dist/src/node/paresUrl.d.ts +0 -19
  248. package/dist/src/node/readDir.d.ts +0 -6
  249. package/dist/src/node/readFile.d.ts +0 -9
  250. package/dist/src/node/router.d.ts +0 -42
  251. package/dist/src/node/send.d.ts +0 -7
  252. package/dist/src/node/server.d.ts +0 -18
  253. package/dist/src/node/startTask.d.ts +0 -2
  254. package/dist/src/node/stream.d.ts +0 -15
  255. package/dist/src/node/taskEnd.d.ts +0 -2
  256. package/dist/src/node/traverse.d.ts +0 -17
  257. package/dist/src/node/watchFile.d.ts +0 -8
  258. package/dist/src/node/writeFile.d.ts +0 -8
  259. package/dist/src/node/ws.d.ts +0 -8
  260. package/dist/src/utils/visual/render/utils/batch/index.test.d.ts +0 -1
  261. package/dist/src/utils/visual/render/utils/index.test.d.ts +0 -1
  262. package/dist/test/binary.test.d.ts +0 -1
  263. package/dist/test/bridge.test.d.ts +0 -1
  264. package/dist/test/canvas.test.d.ts +0 -1
  265. package/dist/test/clearBr.test.d.ts +0 -1
  266. package/dist/test/cloneDeep.test.d.ts +0 -1
  267. package/dist/test/color.test.d.ts +0 -1
  268. package/dist/test/command.test.d.ts +0 -1
  269. package/dist/test/encodeUrl.test.d.ts +0 -1
  270. package/dist/test/escapeHtml.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/server.test.d.ts +0 -1
  275. package/dist/test/status.test.d.ts +0 -1
  276. package/dist/test/sw.test.d.ts +0 -1
  277. package/dist/test/totp.test.d.ts +0 -1
  278. package/dist/test/tween.test.d.ts +0 -1
  279. package/dist/test/utils/async.test.d.ts +0 -1
  280. package/dist/test/utils/autosize.test.d.ts +0 -1
  281. package/dist/test/utils/color-grade.test.d.ts +0 -1
  282. package/dist/test/utils/compose.test.d.ts +0 -1
  283. package/dist/test/utils/event.test.d.ts +0 -1
  284. package/dist/test/utils/file-read.test.d.ts +0 -1
  285. package/dist/test/utils/format.test.d.ts +0 -1
  286. package/dist/test/utils/i18n.test.d.ts +0 -1
  287. package/dist/test/utils/idb-collection.test.d.ts +0 -1
  288. package/dist/test/utils/idb.test.d.ts +0 -1
  289. package/dist/test/utils/instrumentation.test.d.ts +0 -1
  290. package/dist/test/utils/interp.test.d.ts +0 -1
  291. package/dist/test/utils/lang.test.d.ts +0 -1
  292. package/dist/test/utils/locale-path.test.d.ts +0 -1
  293. package/dist/test/utils/media-query.test.d.ts +0 -1
  294. package/dist/test/utils/mergeObj.test.d.ts +0 -1
  295. package/dist/test/utils/number-parse.test.d.ts +0 -1
  296. package/dist/test/utils/paginate.test.d.ts +0 -1
  297. package/dist/test/utils/placement.test.d.ts +0 -1
  298. package/dist/test/utils/prefetch.test.d.ts +0 -1
  299. package/dist/test/utils/query-storage.test.d.ts +0 -1
  300. package/dist/test/utils/queue.test.d.ts +0 -1
  301. package/dist/test/utils/report-config.test.d.ts +0 -1
  302. package/dist/test/utils/report-image.test.d.ts +0 -1
  303. package/dist/test/utils/secure.test.d.ts +0 -1
  304. package/dist/test/utils/segment.test.d.ts +0 -1
  305. package/dist/test/utils/signal-once.test.d.ts +0 -1
  306. package/dist/test/utils/single-flight.test.d.ts +0 -1
  307. package/dist/test/utils/speech.test.d.ts +0 -1
  308. package/dist/test/utils/text-boundary.test.d.ts +0 -1
  309. package/dist/test/utils/time.test.d.ts +0 -1
  310. package/dist/test/utils/timing.test.d.ts +0 -1
  311. package/dist/test/utils/truncate.test.d.ts +0 -1
  312. package/dist/test/utils/visual/filter.test.d.ts +0 -1
  313. package/dist/test/utils/worker-client.test.d.ts +0 -1
  314. package/dist/test/utils/worker-serve.test.d.ts +0 -1
  315. package/dist/test/utils/zip.test.d.ts +0 -1
  316. package/dist/test/visual/math.test.d.ts +0 -1
  317. package/dist/test/visual-application.test.d.ts +0 -1
  318. package/dist/test/visual-batch.test.d.ts +0 -1
  319. package/dist/test/visual-math.test.d.ts +0 -1
  320. package/dist/test/vnode/index.d.ts +0 -1
  321. package/dist/test/vnode/server.d.ts +0 -2
  322. package/dist/test/vnode/vnode.d.ts +0 -1
  323. package/dist/test/vnode.test.d.ts +0 -1
  324. package/dist/test/websocket.test.d.ts +0 -1
  325. package/dist/test/writeFile.test.d.ts +0 -1
  326. package/dist/umd/index.umd.cjs +0 -1
  327. package/dist/umd/node/node.umd.cjs +0 -1
  328. package/dist/umd/utils/utils.umd.cjs +0 -1
  329. package/dist/utils-BNwhohXq.js +0 -1
  330. package/dist/vite.config.d.ts +0 -8
  331. package/dist/vitest.config.d.ts +0 -2
@@ -1,4 +1,18 @@
1
- export type Placement = 'top' | 'bottom' | 'left' | 'right';
1
+ /** The side of the anchor a floating panel sits on. */
2
+ export type PlacementSide = 'top' | 'bottom' | 'left' | 'right';
3
+ /**
4
+ * Where the panel lines up along the cross axis: with the anchor's leading
5
+ * edge, its centre, or its trailing edge. For a `top`/`bottom` placement that
6
+ * is horizontal (left edge / centre / right edge); for `left`/`right` it is
7
+ * vertical (top edge / centre / bottom edge).
8
+ */
9
+ export type PlacementAlign = 'start' | 'center' | 'end';
10
+ /**
11
+ * A side, optionally suffixed with a cross-axis alignment — the same grammar
12
+ * Floating UI and Popper use (`bottom`, `bottom-end`, `right-center`, …).
13
+ * A bare side means `-start`, which is what this module has always done.
14
+ */
15
+ export type Placement = PlacementSide | `${PlacementSide}-${PlacementAlign}`;
2
16
  export interface PlacementRect {
3
17
  top: number;
4
18
  left: number;
@@ -13,7 +27,7 @@ export interface ComputePlacementOptions {
13
27
  width: number;
14
28
  height: number;
15
29
  };
16
- /** Preferred side. Flips to the opposite side when it lacks room and the opposite side has more. */
30
+ /** Preferred side, optionally with a cross-axis alignment. Flips to the opposite side when it lacks room and the opposite side has more; the alignment is carried across the flip. */
17
31
  placement: Placement;
18
32
  /** Gap kept between the anchor and the floating panel, in px. */
19
33
  offset?: number;
@@ -25,14 +39,37 @@ export interface ComputePlacementOptions {
25
39
  export interface ComputedPlacement {
26
40
  top: number;
27
41
  left: number;
28
- /** The side actually used, after flip. */
42
+ /**
43
+ * The placement actually used, after flip, in the form the caller asked for:
44
+ * a bare side stays bare, a suffixed one keeps its suffix. Callers that key a
45
+ * lookup table off four sides therefore keep working unchanged.
46
+ */
29
47
  placement: Placement;
48
+ /** The side actually used, after flip — always bare, whatever form `placement` took. */
49
+ side: PlacementSide;
50
+ /** The cross-axis alignment actually used. `start` when the caller named none. */
51
+ align: PlacementAlign;
30
52
  }
53
+ /**
54
+ * @description: Where a floating panel starts along the cross axis, given how
55
+ * it should line up with its anchor. `start` pins the leading edges together,
56
+ * `end` the trailing ones, `center` splits the difference. Exported because a
57
+ * caller that computes its own coordinates -- a panel positioned inside a
58
+ * custom container rather than the viewport -- still has to align the same way
59
+ * `computePlacement` does, and two implementations of that would drift.
60
+ * @param align cross-axis alignment
61
+ * @param anchorStart anchor's leading edge on that axis (`left` or `top`)
62
+ * @param anchorSize anchor's size on that axis (`width` or `height`)
63
+ * @param floatingSize the panel's size on that axis
64
+ * @return the panel's leading edge on that axis
65
+ */
66
+ export declare const alignCrossAxis: (align: PlacementAlign, anchorStart: number, anchorSize: number, floatingSize: number) => number;
31
67
  /**
32
68
  * Position a floating panel relative to an anchor rect: flips to the opposite
33
69
  * side when the preferred side doesn't have room and the opposite side has
34
- * more, then shifts along the cross axis to stay within `boundary`. Mirrors
35
- * Floating UI's `flip`/`shift` middleware, minus the dependency.
70
+ * more, aligns along the cross axis as asked, then shifts to stay within
71
+ * `boundary`. Mirrors Floating UI's `flip`/`shift` middleware, minus the
72
+ * dependency.
36
73
  *
37
74
  * Coordinates are viewport-relative throughout (same space as `anchor`); the
38
75
  * caller adds `scrollX`/`scrollY` when writing `position: absolute` styles.
@@ -0,0 +1,37 @@
1
+ var y = (s, t, e, f) => s === "end" ? t + e - f : s === "center" ? t + (e - f) / 2 : t, b = () => ({
2
+ top: 0,
3
+ left: 0,
4
+ width: typeof window < "u" ? window.innerWidth : 1 / 0,
5
+ height: typeof window < "u" ? window.innerHeight : 1 / 0
6
+ }), x = (s) => {
7
+ const { anchor: t, floating: e, offset: f = 0, padding: p = 8 } = s, n = s.boundary ?? b(), [m, c] = s.placement.split("-"), w = c ?? "start";
8
+ let i = m;
9
+ const r = i === "top" || i === "bottom", a = t.width > 0 && t.height > 0 && e.width > 0 && e.height > 0;
10
+ if (a && r) {
11
+ const h = n.top + n.height - (t.top + t.height), o = t.top - n.top;
12
+ i === "bottom" && h < e.height + f && o > h ? i = "top" : i === "top" && o < e.height + f && h > o && (i = "bottom");
13
+ } else if (a) {
14
+ const h = n.left + n.width - (t.left + t.width), o = t.left - n.left;
15
+ i === "right" && h < e.width + f && o > h ? i = "left" : i === "left" && o < e.width + f && h > o && (i = "right");
16
+ }
17
+ const g = (h, o, u) => y(w, h, o, u);
18
+ let d, l;
19
+ if (i === "bottom" ? (d = t.top + t.height + f, l = g(t.left, t.width, e.width)) : i === "top" ? (d = t.top - e.height - f, l = g(t.left, t.width, e.width)) : i === "right" ? (d = g(t.top, t.height, e.height), l = t.left + t.width + f) : (d = g(t.top, t.height, e.height), l = t.left - e.width - f), a && r) {
20
+ const h = n.left + p, o = n.left + n.width - e.width - p;
21
+ o >= h && (l = Math.min(Math.max(l, h), o));
22
+ } else if (a) {
23
+ const h = n.top + p, o = n.top + n.height - e.height - p;
24
+ o >= h && (d = Math.min(Math.max(d, h), o));
25
+ }
26
+ return {
27
+ top: d,
28
+ left: l,
29
+ placement: c ? `${i}-${w}` : i,
30
+ side: i,
31
+ align: w
32
+ };
33
+ };
34
+ export {
35
+ y as alignCrossAxis,
36
+ x as computePlacement
37
+ };
@@ -0,0 +1,69 @@
1
+ var o = () => typeof window < "u", f = (e, r = {}) => {
2
+ const { timeout: t = 8e3, fallbackDelay: a = 2500 } = r;
3
+ if (!o()) return () => {
4
+ };
5
+ const c = window.requestIdleCallback;
6
+ if (c) {
7
+ const s = c(e, { timeout: t });
8
+ return () => window.cancelIdleCallback?.(s);
9
+ }
10
+ const i = setTimeout(e, a);
11
+ return () => clearTimeout(i);
12
+ }, l = (e = {}) => {
13
+ const { optOutKey: r, slowTypes: t = ["slow-2g", "2g"] } = e;
14
+ if (!o()) return !1;
15
+ if (r) try {
16
+ if (localStorage.getItem(r)) return !1;
17
+ } catch {
18
+ }
19
+ const a = navigator.connection;
20
+ return !(a?.saveData || a?.effectiveType && t.includes(a.effectiveType));
21
+ }, d = () => typeof caches < "u", u = async (e) => {
22
+ if (!d()) return !1;
23
+ try {
24
+ return !!await caches.match(e);
25
+ } catch {
26
+ return !1;
27
+ }
28
+ }, n = /* @__PURE__ */ new Map(), h = (e) => {
29
+ const r = n.get(e);
30
+ if (r) return r;
31
+ const t = (async () => {
32
+ try {
33
+ if (await u(e)) return;
34
+ const a = (await fetch(e, { cache: "force-cache" })).body?.getReader();
35
+ if (!a) return;
36
+ try {
37
+ for (; !(await a.read()).done; ) ;
38
+ } finally {
39
+ a.releaseLock();
40
+ }
41
+ } catch {
42
+ }
43
+ })().finally(() => n.delete(e));
44
+ return n.set(e, t), t;
45
+ }, v = (e, r) => {
46
+ try {
47
+ const t = typeof navigator < "u" && "serviceWorker" in navigator ? navigator.serviceWorker.controller : null;
48
+ return t ? (t.postMessage({
49
+ type: r,
50
+ urls: e
51
+ }), !0) : !1;
52
+ } catch {
53
+ return !1;
54
+ }
55
+ }, w = async (e, r = {}) => {
56
+ if (e.length !== 0 && !(r.serviceWorkerMessage && v(e, r.serviceWorkerMessage)))
57
+ for (const t of e) await h(t);
58
+ }, y = (e, r = {}) => l(r) ? f(() => {
59
+ w(e, r);
60
+ }, r) : () => {
61
+ };
62
+ export {
63
+ u as isUrlCached,
64
+ l as networkAllowsDownload,
65
+ h as prefetchUrl,
66
+ w as prefetchUrls,
67
+ y as prefetchWhenIdle,
68
+ f as whenIdle
69
+ };
@@ -0,0 +1,46 @@
1
+ var i = class {
2
+ running = 0;
3
+ executed = 0;
4
+ simultaneous;
5
+ queue = [];
6
+ idleWaiters = [];
7
+ constructor({ simultaneous: e = 1 } = {}) {
8
+ this.simultaneous = Math.max(1, e);
9
+ }
10
+ get pending() {
11
+ return this.queue.length;
12
+ }
13
+ get idle() {
14
+ return this.queue.length === 0 && this.running === 0;
15
+ }
16
+ add = (e) => typeof e != "function" ? Promise.reject(/* @__PURE__ */ new TypeError("QuestQueue.add expects a function")) : new Promise((t, s) => {
17
+ this.queue.push({
18
+ task: e,
19
+ resolve: t,
20
+ reject: s
21
+ }), this.next();
22
+ });
23
+ allSettled = (e) => Promise.allSettled(e.map((t) => this.add(t)));
24
+ onIdle = () => this.idle ? Promise.resolve() : new Promise((e) => this.idleWaiters.push(e));
25
+ clear = () => {
26
+ const e = this.queue.splice(0, this.queue.length);
27
+ for (const t of e) t.reject(/* @__PURE__ */ new Error("QuestQueue cleared"));
28
+ this.settleIdle();
29
+ };
30
+ next = () => {
31
+ for (; this.running < this.simultaneous && this.queue.length > 0; ) {
32
+ const e = this.queue.shift();
33
+ this.running++, Promise.resolve().then(e.task).then(e.resolve, e.reject).finally(() => {
34
+ this.running--, this.executed++, this.settleIdle(), this.next();
35
+ });
36
+ }
37
+ };
38
+ settleIdle = () => {
39
+ if (!this.idle) return;
40
+ const e = this.idleWaiters.splice(0, this.idleWaiters.length);
41
+ for (const t of e) t();
42
+ };
43
+ };
44
+ export {
45
+ i as QuestQueue
46
+ };
@@ -0,0 +1,44 @@
1
+ import { randomString as i } from "./str.js";
2
+ import { getCookie as a, getWindow as s } from "./bom.js";
3
+ import { querystring as f } from "./obj.js";
4
+ var o = {}, l = (e) => {
5
+ typeof e == "string" ? o.url = e : Object.assign(o, e);
6
+ }, u = () => o.url ?? "", d = ({ url: e = "", type: t = "application/json; charset=UTF-8", payload: r = {} }) => {
7
+ if (typeof navigator > "u" || !navigator.sendBeacon || !e) return !1;
8
+ const n = new Blob([JSON.stringify(r)], { type: t });
9
+ return navigator.sendBeacon(e, n);
10
+ }, g = ({ url: e = "", payload: t = {} }) => {
11
+ if (typeof document > "u" || !e) return !1;
12
+ const r = new Image();
13
+ return r.width = 1, r.height = 1, r.src = `${e}?${f(t)}`, !0;
14
+ }, w = ({ url: e, type: t = "application/json; charset=UTF-8", payload: r = {} }) => {
15
+ const n = e || u();
16
+ return n ? d({
17
+ url: n,
18
+ type: t,
19
+ payload: r
20
+ }) || g({
21
+ url: n,
22
+ payload: r
23
+ }) : !1;
24
+ };
25
+ function h(e = {}) {
26
+ if (typeof window > "u") return {};
27
+ const { width: t, height: r } = s();
28
+ return {
29
+ id: i(),
30
+ path: window.location.href,
31
+ time: Date.now(),
32
+ referrer: document.referrer,
33
+ ratio: `${t}x${r}`,
34
+ userAgent: window.navigator.userAgent,
35
+ ...o.userIdCookie ? { userId: a(o.userIdCookie) } : {},
36
+ ...e
37
+ };
38
+ }
39
+ export {
40
+ h as createData,
41
+ u as getReportUrl,
42
+ w as report,
43
+ l as setReportUrl
44
+ };
@@ -0,0 +1,35 @@
1
+ import { noop as o } from "./noop.js";
2
+ import { replaceOld as c } from "./obj.js";
3
+ var y = (s = {}) => {
4
+ if (typeof window > "u") return o;
5
+ const { requestHook: r = o, responseHook: d = o, errorHook: u = o } = s;
6
+ return c(window, "fetch", (i) => {
7
+ if (typeof i != "function") return;
8
+ const f = i;
9
+ return (n, t) => (r(n, t), f.apply(window, [n, t]).then((e) => (d(n, t, e), e)).catch((e) => {
10
+ throw u(n, e), e;
11
+ }));
12
+ });
13
+ }, H = (s = {}) => {
14
+ if (typeof window > "u" || typeof XMLHttpRequest > "u") return o;
15
+ const r = XMLHttpRequest.prototype, { requestHook: d = o, responseHook: u = o, errorHook: i = o } = s, f = c(r, "open", (t) => {
16
+ if (typeof t != "function") return;
17
+ const e = t;
18
+ return function(...p) {
19
+ d(p), e.apply(this, p);
20
+ };
21
+ }), n = c(r, "send", (t) => {
22
+ if (typeof t != "function") return;
23
+ const e = t;
24
+ return function(...p) {
25
+ this.addEventListener("loadend", () => u(this), { once: !0 }), this.addEventListener("error", () => i(this), { once: !0 }), e.apply(this, p);
26
+ };
27
+ });
28
+ return () => {
29
+ n(), f();
30
+ };
31
+ };
32
+ export {
33
+ y as handleFetchHook,
34
+ H as handleXhrHook
35
+ };
@@ -12,7 +12,7 @@ export interface LoadScriptOptions {
12
12
  * and **guarantees the same script is evaluated only once** — injecting a third-party SDK
13
13
  * twice usually means its initialisation side effects ran twice.
14
14
  *
15
- * The de-duplication key is the md5 of `type + content`, so a URL and an identically named inline script cannot be confused.
15
+ * The key includes the type and exact content, so distinct sources and URL/inline scripts stay separate.
16
16
  *
17
17
  * @param {LoadScriptOptions} options
18
18
  * @return {Promise<{ success: boolean }>} rejects with `{ success: false, error }` on failure
@@ -0,0 +1,46 @@
1
+ var d = /* @__PURE__ */ new Set(), p = ({ type: t, content: o }) => new Promise((r, a) => {
2
+ const e = `${t}:${o}`;
3
+ if (d.has(e)) {
4
+ r({ success: !0 });
5
+ return;
6
+ }
7
+ const n = document.createElement("script");
8
+ if (n.onload = function() {
9
+ d.add(e), r({ success: !0 });
10
+ }, n.onerror = function(s) {
11
+ a({
12
+ success: !1,
13
+ error: s
14
+ });
15
+ }, t === "content") {
16
+ n.textContent = o, document.body.append(n), d.add(e), r({ success: !0 });
17
+ return;
18
+ }
19
+ n.src = o, document.body.append(n);
20
+ }), m = (t, o, r) => {
21
+ t = Array.isArray(t) ? t : [t];
22
+ const a = t.map((e) => {
23
+ const n = e.toLowerCase().endsWith(".css");
24
+ let s;
25
+ if (n) {
26
+ const c = document.createElement("link");
27
+ c.type = "text/css", c.rel = "stylesheet", c.href = e, s = c;
28
+ } else
29
+ s = document.createElement("script"), s.type = "text/javascript", s.src = e;
30
+ const i = document.getElementsByTagName("body")[0];
31
+ return (o || i).appendChild(s), new Promise((c) => {
32
+ s.onload = () => {
33
+ c();
34
+ };
35
+ });
36
+ });
37
+ return new Promise((e) => {
38
+ Promise.all(a).then(() => {
39
+ r && r(), e();
40
+ });
41
+ });
42
+ };
43
+ export {
44
+ p as loadScript,
45
+ m as scriptOnLoad
46
+ };
@@ -0,0 +1,93 @@
1
+ /**
2
+ * Bottom-follow for append-only scrollers — a streaming chat transcript, a log tail, a
3
+ * terminal pane.
4
+ *
5
+ * The requirement sounds trivial and is not: stay pinned to the floor as content arrives,
6
+ * but the instant the reader scrolls up to read something, stop — and re-pin only when
7
+ * they come back down themselves. Naive implementations fight the reader, because they
8
+ * cannot tell their own scroll writes apart from the reader's.
9
+ *
10
+ * The mechanism here is an **observed-top ledger**. Every programmatic write records the
11
+ * `scrollTop` it produced. When a scroll event arrives, a position that matches the ledger
12
+ * is this module's own write echoing back; a position that deviates is the reader. That
13
+ * covers wheel, touch, scrollbar drag, keyboard, and `scrollIntoView` from unrelated code
14
+ * uniformly, without listening for any input device — which matters because no set of
15
+ * device listeners is ever complete.
16
+ *
17
+ * Two cases the ledger has to survive:
18
+ *
19
+ * - **Shrink-clamp.** When content shrinks, the browser clamps `scrollTop` to the new
20
+ * floor without any reader involvement. Comparing against `min(ledger, floor)` treats
21
+ * that clamp as the ledger's own value rather than as a reader scroll, so a clamp
22
+ * never changes who owns the scroll position — a reader who had scrolled up stays
23
+ * unpinned even when the clamp happens to leave them at the floor, and re-pins on
24
+ * their next scroll. Re-pinning on a clamp would take control back without input.
25
+ * - **Growth while pinned.** Appended content moves the floor away. A scroll event that
26
+ * the reader did not cause, while pinned, re-snaps to the new floor.
27
+ *
28
+ * Scrolling is always instant. Smooth scrolling animates over a moving target, so during
29
+ * streaming it visibly lags the content and, worse, its own intermediate positions read as
30
+ * reader input on the next event.
31
+ */
32
+ /** How to construct a follower. */
33
+ export interface BottomFollowerOptions {
34
+ /** The element that scrolls. */
35
+ scrollport: HTMLElement;
36
+ /**
37
+ * Elements whose size changes should re-follow the floor while pinned — the content
38
+ * column, and any sticky footer that resizes outside it. Streaming text grows an
39
+ * existing node rather than appending one, so growth is observed rather than announced.
40
+ */
41
+ observe?: readonly HTMLElement[];
42
+ /** Distance from the floor still counted as pinned. Defaults to 24. */
43
+ threshold?: number;
44
+ /**
45
+ * Called when the pinned state flips, so a caller can show or hide a "jump to latest"
46
+ * affordance. Never called for a change the caller itself just made synchronously.
47
+ */
48
+ onPinnedChange?: (pinned: boolean) => void;
49
+ }
50
+ /** Imperative bottom-follow controller. */
51
+ export interface BottomFollower {
52
+ /** Whether new content is currently being followed. */
53
+ readonly pinned: boolean;
54
+ /** Scrolls to the floor and pins, regardless of the current state. */
55
+ toBottom(): void;
56
+ /**
57
+ * Follows the floor only if currently pinned. Safe to call on every content change —
58
+ * a reader who has scrolled up is left alone.
59
+ */
60
+ follow(): void;
61
+ /**
62
+ * Remembers a row's current offset from the scrollport top, before content is prepended
63
+ * above it. Capture a row that is actually on screen, so the restore keeps what the
64
+ * reader is looking at exactly where it was.
65
+ *
66
+ * @param row The row to keep still.
67
+ */
68
+ captureAnchor(row: HTMLElement): void;
69
+ /**
70
+ * Restores the captured row to its captured offset, then forgets it.
71
+ *
72
+ * @param resolve Re-resolves the row after the prepend, for callers that replace nodes
73
+ * rather than reuse them. Omit when the captured element is still in the document.
74
+ * @returns Whether an anchor was restored.
75
+ */
76
+ restoreAnchor(resolve?: () => HTMLElement | null): boolean;
77
+ /** Discards any captured anchor without restoring it. */
78
+ releaseAnchor(): void;
79
+ /** Removes the scroll listener and disconnects the resize observer. */
80
+ destroy(): void;
81
+ }
82
+ /**
83
+ * Creates a bottom-follow controller for one scrollport.
84
+ *
85
+ * The controller starts pinned, which is what an append-only view wants on first paint and
86
+ * after a reload. To restore a remembered position instead, set `scrollTop` before or
87
+ * after construction and the first scroll event will settle the pinned state from the
88
+ * geometry.
89
+ *
90
+ * @param options Scrollport, elements to observe, and threshold.
91
+ * @returns The controller; call `destroy` to release its listeners.
92
+ */
93
+ export declare function createBottomFollower(options: BottomFollowerOptions): BottomFollower;
@@ -0,0 +1,62 @@
1
+ var b = 24;
2
+ function H(r) {
3
+ return Math.max(0, r.scrollHeight - r.clientHeight);
4
+ }
5
+ function h(r, e) {
6
+ return r.getBoundingClientRect().top - e.getBoundingClientRect().top;
7
+ }
8
+ function m(r) {
9
+ const { scrollport: e, observe: u = [], threshold: g = b, onPinnedChange: T } = r;
10
+ let l = !0, n = e.scrollTop, t = null, f = !1;
11
+ const p = (o) => {
12
+ o !== l && (l = o, T?.(o));
13
+ }, s = (o) => {
14
+ e.scrollTop = o, n = e.scrollTop;
15
+ }, a = () => {
16
+ t = null, s(e.scrollHeight), p(!0);
17
+ }, d = () => {
18
+ const o = H(e);
19
+ if (!(Math.abs(e.scrollTop - Math.min(n, o)) > 0.5)) {
20
+ l ? a() : n = e.scrollTop;
21
+ return;
22
+ }
23
+ n = e.scrollTop, p(o - e.scrollTop <= g);
24
+ };
25
+ e.addEventListener("scroll", d, { passive: !0 });
26
+ let c = null;
27
+ if (u.length > 0 && typeof ResizeObserver < "u") {
28
+ c = new ResizeObserver(() => {
29
+ l && !f && s(e.scrollHeight);
30
+ });
31
+ for (const o of u) c.observe(o);
32
+ }
33
+ return {
34
+ get pinned() {
35
+ return l;
36
+ },
37
+ toBottom: a,
38
+ follow() {
39
+ l && s(e.scrollHeight);
40
+ },
41
+ captureAnchor(o) {
42
+ t = {
43
+ row: o,
44
+ top: h(o, e)
45
+ };
46
+ },
47
+ restoreAnchor(o) {
48
+ if (t === null) return !1;
49
+ const i = o === void 0 ? t.row : o(), { top: v } = t;
50
+ return t = null, i === null || !e.contains(i) ? !1 : (s(e.scrollTop + h(i, e) - v), !0);
51
+ },
52
+ releaseAnchor() {
53
+ t = null;
54
+ },
55
+ destroy() {
56
+ f = !0, e.removeEventListener("scroll", d), c?.disconnect();
57
+ }
58
+ };
59
+ }
60
+ export {
61
+ m as createBottomFollower
62
+ };
@@ -0,0 +1,36 @@
1
+ var u = () => {
2
+ const e = globalThis.crypto;
3
+ if (!e?.getRandomValues) throw new Error("ranuts/secure: Web Crypto is unavailable (needs a browser, Node >= 19, Deno or a Worker)");
4
+ return e;
5
+ }, c = (e, r) => {
6
+ const o = new TextEncoder(), s = typeof e == "string" ? o.encode(e) : e, a = typeof r == "string" ? o.encode(r) : r;
7
+ if (s.length !== a.length) return !1;
8
+ let n = 0;
9
+ for (let t = 0; t < s.length; t++) n |= s[t] ^ a[t];
10
+ return n === 0;
11
+ }, g = "ABCDEFGHJKLMNPQRSTUVWXYZ23456789", l = (e, r = g) => {
12
+ if (!Number.isInteger(e) || e < 0) throw new RangeError("secureRandomString: length must be a whole number");
13
+ if (r.length < 2) throw new RangeError("secureRandomString: alphabet needs at least two characters");
14
+ if (r.length > 256) throw new RangeError("secureRandomString: alphabet must fit in one byte");
15
+ if (e === 0) return "";
16
+ const o = u(), s = Math.floor(256 / r.length) * r.length;
17
+ let a = "";
18
+ const n = new Uint8Array(Math.min(Math.max(e, 16), 4096));
19
+ let t = n.length;
20
+ for (; a.length < e; ) {
21
+ t >= n.length && (o.getRandomValues(n), t = 0);
22
+ const i = n[t++];
23
+ i < s && (a += r[i % r.length]);
24
+ }
25
+ return a;
26
+ }, f = (e = 32) => {
27
+ if (!Number.isInteger(e) || e < 1) throw new RangeError("secureToken: bytes must be a positive whole number");
28
+ const r = new Uint8Array(e);
29
+ return u().getRandomValues(r), Array.from(r, (o) => o.toString(16).padStart(2, "0")).join("");
30
+ };
31
+ export {
32
+ g as UNAMBIGUOUS_ALPHABET,
33
+ c as safeEqual,
34
+ l as secureRandomString,
35
+ f as secureToken
36
+ };
@@ -0,0 +1,43 @@
1
+ var u = (l) => {
2
+ const n = Array.from({ length: l.length });
3
+ let i = 0;
4
+ for (let t = 0; t < l.length; t++)
5
+ n[t] = i, i += l[t] || 0;
6
+ return n;
7
+ }, h = (l, n) => {
8
+ if (l.length === 0) return 0;
9
+ let i = 0, t = l.length - 1, f = 0;
10
+ for (; i <= t; ) {
11
+ const r = i + t >> 1;
12
+ l[r] <= n ? (f = r, i = r + 1) : t = r - 1;
13
+ }
14
+ return f;
15
+ }, c = (l, n, i) => {
16
+ const t = n + l.length, f = i.map((e) => ({
17
+ value: e.value,
18
+ s: Math.max(e.start, n) - n,
19
+ e: Math.min(e.end, t) - n
20
+ })).filter((e) => e.e > e.s).sort((e, s) => e.s - s.s || e.e - s.e), r = [], a = (e, s, g) => {
21
+ r.push({
22
+ text: l.slice(e, s),
23
+ start: n + e,
24
+ end: n + s,
25
+ value: g
26
+ });
27
+ };
28
+ let o = 0;
29
+ for (const e of f) {
30
+ let s = e.s;
31
+ if (s < o) {
32
+ if (e.e <= o) continue;
33
+ s = o;
34
+ }
35
+ s > o && a(o, s, null), a(s, e.e, e.value), o = e.e;
36
+ }
37
+ return o < l.length && a(o, l.length, null), r.length === 0 && a(0, l.length, null), r;
38
+ };
39
+ export {
40
+ u as buildOffsets,
41
+ h as indexForOffset,
42
+ c as segmentByRanges
43
+ };
@@ -1,4 +1,4 @@
1
- import { SyncHook } from './subscribe';
1
+ import { SyncHook } from "./subscribe.js";
2
2
  /** Global event bus: a signal carrying a `subscriber` broadcasts through it on change */
3
3
  export declare const subscribers: SyncHook;
4
4
  export interface SignalOptions<T> {
@@ -0,0 +1,13 @@
1
+ import { SyncHook as u } from "./subscribe.js";
2
+ var f = new u(), g = (c, o = {}) => {
3
+ const { subscriber: n, equals: t } = o;
4
+ let e = c;
5
+ const i = (r, s) => t === !1 ? !0 : typeof t == "function" ? !t(r, s) : !Object.is(r, s);
6
+ return [() => e, (r) => {
7
+ i(e, r) && (e = r, n && f.call(n));
8
+ }];
9
+ };
10
+ export {
11
+ g as createSignal,
12
+ f as subscribers
13
+ };
@@ -0,0 +1,59 @@
1
+ var u = () => {
2
+ if (typeof window > "u") return;
3
+ const e = window;
4
+ return e.SpeechRecognition ?? e.webkitSpeechRecognition;
5
+ }, z = (e) => e === "not-allowed" || e === "service-not-allowed" ? "denied" : e === "no-speech" ? "noSpeech" : e === "aborted" ? "aborted" : "failed", E = () => u() !== void 0, k = (e = {}) => {
6
+ const { lang: s, continuous: S = !0, interimResults: R = !0, onResult: b, onError: d, onStart: m, onEnd: f } = e;
7
+ let n = null;
8
+ const y = () => {
9
+ n = null, f?.();
10
+ }, l = {
11
+ get supported() {
12
+ return u() !== void 0;
13
+ },
14
+ get active() {
15
+ return n !== null;
16
+ },
17
+ start() {
18
+ const p = u();
19
+ if (!(!p || n))
20
+ try {
21
+ const t = new p();
22
+ t.lang = typeof s == "function" ? s() : s ?? "", t.continuous = S, t.interimResults = R, t.maxAlternatives = 1;
23
+ let a = "", r = 0;
24
+ t.onresult = (o) => {
25
+ const i = o.results, g = Math.min(o.resultIndex ?? 0, i.length);
26
+ for (g < r && (r = 0, a = ""); r < g; r++) a += i[r]?.[0]?.transcript ?? "";
27
+ let h = "", v = !0;
28
+ for (let c = r; c < i.length; c++) {
29
+ const w = i[c];
30
+ h += w?.[0]?.transcript ?? "", w?.isFinal === !1 && (v = !1);
31
+ }
32
+ b?.(a + h, v);
33
+ }, t.onerror = (o) => d?.({
34
+ kind: z(o.error),
35
+ detail: o.error
36
+ }), t.onstart = () => m?.(), t.onend = y, n = t, t.start();
37
+ } catch (t) {
38
+ n = null, d?.({
39
+ kind: "failed",
40
+ detail: t instanceof Error ? t.message : String(t)
41
+ }), f?.();
42
+ }
43
+ },
44
+ stop() {
45
+ n?.stop();
46
+ },
47
+ abort() {
48
+ n?.abort();
49
+ },
50
+ toggle() {
51
+ n ? l.stop() : l.start();
52
+ }
53
+ };
54
+ return l;
55
+ };
56
+ export {
57
+ k as createSpeechRecognizer,
58
+ E as isSpeechRecognitionSupported
59
+ };