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 +0,0 @@
1
- var t=class{_events=/* @__PURE__ */new Map;tap=(t,a)=>{this._events.get(t)&&t!==Symbol.for("NEW_LISTENER")&&this.call(Symbol.for("NEW_LISTENER"),t);const e=this._events.get(t)||/* @__PURE__ */new Set;return"function"==typeof a?e.add({name:t,callback:a}):e.add(a),this._events.set(t,e),this};call=(t,...a)=>((this._events.get(t)||/* @__PURE__ */new Set).forEach(t=>{const{callback:e}=t;e(...a)}),this);callSync=async(t,...a)=>{const e=this._events.get(t)||/* @__PURE__ */new Set;for(const n of e){const{callback:t}=n;await t(...a)}return this};once=(t,a)=>{let e;if("function"==typeof a)e={name:t,callback:(...n)=>{a(...n),this.off(t,e)},initialCallback:a};else{const{callback:n}=a;e={name:t,callback:(...a)=>{n(...a),this.off(t,e)},initialCallback:n}}return this.tap(t,e),this};off=(t,a)=>{const e=[...this._events.get(t)||/* @__PURE__ */new Set].filter(t=>{if("function"==typeof a)return t.callback!==a&&t.initialCallback!==a;{const{callback:e}=a;return t.callback!==e&&t.initialCallback!==e}});return this._events.set(t,new Set(e)),this}},a=Math.PI/180,e=180/Math.PI,n=2*Math.PI;export{t as i,n,e as r,a as t};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- var e=(e,t=2)=>String(e).padStart(t,"0"),t=e=>null==e?/* @__PURE__ */new Date:new Date(e),n=/YYYY|YY|MM|M|DD|D|HH|H|hh|h|mm|m|ss|s|SSS|A|a|\[([^\]]*)]/g,r=(r,s="YYYY-MM-DD HH:mm:ss")=>{const a=t(r);if(Number.isNaN(a.getTime()))return"Invalid Date";const o=a.getHours(),i=o%12||12,c={YYYY:String(a.getFullYear()),YY:e(a.getFullYear()%100),MM:e(a.getMonth()+1),M:String(a.getMonth()+1),DD:e(a.getDate()),D:String(a.getDate()),HH:e(o),H:String(o),hh:e(i),h:String(i),mm:e(a.getMinutes()),m:String(a.getMinutes()),ss:e(a.getSeconds()),s:String(a.getSeconds()),SSS:e(a.getMilliseconds(),3),A:o<12?"AM":"PM",a:o<12?"am":"pm"};return s.replace(n,(e,t)=>void 0!==t?t:c[e])};function s(e){const t=e?new Date(e):/* @__PURE__ */new Date;return t.format=(e="YYYY-MM-DD HH:mm:ss")=>r(t,e),t}var a=t=>{if(!Number.isFinite(t))return"";const n=Math.max(0,Math.trunc(t)),r=Math.trunc(n/3600),s=Math.trunc(n%3600/60),a=e(n%60);return 0===r?`${e(s)}:${a}`:`${e(r)}:${e(s)}:${a}`},o=e=>a(e),i=/(?:(\d{2,}):)?(\d{2}):(\d{2})\.(\d{3})/,c=e=>{const t=e.trim().match(i);if(!t)return;const[,n,r,s,a]=t;return(n?3600*Number(n):0)+60*Number(r)+Number(s)+Number(a)/1e3},u=e=>{const[t,n]=e.split("--\x3e");if(!t||!n)return;const r=c(t),s=c(n.trim().split(/\s+/)[0]??"");return void 0!==r&&void 0!==s?{start:r,end:s}:void 0},l=[["year",315576e5],["month",26298e5],["week",6048e5],["day",864e5],["hour",36e5],["minute",6e4],["second",1e3]],d={year:"y",quarter:"q",month:"mo",week:"w",day:"d",hour:"h",minute:"m",second:"s"},f=/* @__PURE__ */new Map,h=(e,n={})=>{const{now:r,locale:s,style:a="long",numeric:o="auto"}=n,i=t(e).getTime(),c=t(r).getTime();if(Number.isNaN(i)||Number.isNaN(c))return"";const u=i-c,h=Math.abs(u);let g=l.findIndex(([,e])=>h>=e);-1===g&&(g=l.length-1);const m=u<0?-1:1;let[p,w]=l[g],y=m*Math.round(h/w);if(g>0&&Math.abs(y)*w>=l[g-1][1]&&([p,w]=l[g-1],y=m*Math.round(h/w)),"compact"===a)return`${Math.abs(y)}${d[p]??""}`;const _=((e,t,n)=>{if("undefined"==typeof Intl||"function"!=typeof Intl.RelativeTimeFormat)return;const r=`${String(e)}|${t}|${n}`;let s=f.get(r);return s||(s=new Intl.RelativeTimeFormat(e,{style:t,numeric:n}),f.set(r,s)),s})(s,a,o);if(!_){const e=d[p]??"";return y<0?`${Math.abs(y)}${e} ago`:`in ${y}${e}`}return _.format(y,p)},g=()=>{if("undefined"!=typeof document)return performance.now();if("undefined"!=typeof process){const[e,t]=process.hrtime();return 1e3*e+t/1e6}return Date.now()},m=e=>{const t=document.cookie.split("; ");for(let n=0;n<t.length;n++){const r=t[n].split("=");if(r[0]===e)return decodeURIComponent(r[1])}return""},p=(e,t)=>new Promise(function(n,r){const s=new XMLHttpRequest;s.open(t.method||"GET",e,!0),s.responseType=t.responseType||"arraybuffer",s.onload=function(){200===s.status?n({success:!0,data:s.response,message:""}):r({success:!1,data:s.status,message:`The request status is${s.status}`})},s.onerror=function(e){r({success:!1,data:e,message:""})},s.onprogress=e=>{t.onProgress&&t.onProgress(e)},s.withCredentials=t.withCredentials||!1,t.headers&&Object.keys(t.headers).forEach(function(e){t.headers?.[e]&&s.setRequestHeader(e,t.headers[e])}),s.send(t.body)}),w=e=>{const t=e.backingStorePixelRatio||e.webkitBackingStorePixelRatio||e.mozBackingStorePixelRatio||e.msBackingStorePixelRatio||e.oBackingStorePixelRatio||1;return(("undefined"==typeof window?1:window.devicePixelRatio)||1)/t},y=async e=>{if("string"==typeof e)return e;if(e instanceof Blob)return URL.createObjectURL(e);if(e instanceof ArrayBuffer)return URL.createObjectURL(new Blob([e]));if(e instanceof Response){const t=await e.blob();return URL.createObjectURL(t)}return e},_=(e=10)=>{const t=[];let n,r=0;return new Promise(s=>{const a=()=>{const o=g(),i=o-r;0!==r&&t.push(i),r=o,t.length>e&&(s(1/(t.reduce((e,t)=>e+t)/e)),cancelAnimationFrame(n)),n=requestAnimationFrame(a)};t.length<=e&&(n=requestAnimationFrame(a))})},b=e=>{const t={},n=(e=>{const t=e??("undefined"==typeof window?"":window.location.href),n=t.indexOf("?");if(-1===n)return"";const r=t.slice(n+1),s=r.indexOf("#");return-1===s?r:r.slice(0,s)})(e);if(!n)return t;for(const r of n.split("&")){if(!r)continue;const e=r.indexOf("="),n=-1===e?r:r.slice(0,e),s=-1===e?"":r.slice(e+1);if(n)try{t[decodeURIComponent(n.replace(/\+/g," "))]=decodeURIComponent(s.replace(/\+/g," "))}catch{t[n]=s}}return t},v=(e,t)=>{const n=b(t)[e];if(void 0===n)return!1;const r=n.toLowerCase();return""===r||"1"===r||"true"===r},M=()=>{if("undefined"==typeof window)return!1;try{return window.parent!==window}catch{return!0}};function S(e,t={}){let n=e;0===n.indexOf("//")&&(n=n.replace("//","https://"));const r=new URL(n);return t&&Object.keys(t).forEach(e=>{t[e]&&r.searchParams.set(e,t[e])}),r.href}function x(e){if("undefined"!=typeof window){const t=new RegExp(`(^| )${e}(?:=([^;]*))?(;|$)`).exec(document.cookie);if(t&&t[2])return t[2]}return""}var D=()=>"undefined"!=typeof window?{width:window.innerWidth,height:window.innerHeight}:{width:0,height:0},k=()=>{if("undefined"!=typeof window)return window.navigator.connection},$=/(?:[^\x21\x25\x26-\x3B\x3D\x3F-\x5B\x5D\x5F\x7E]|%(?:[^\da-f]|[\da-f][^\da-f]|$))+/gi,R=/(^|[^\uD800-\uDBFF])[\uDC00-\uDFFF]|[\uD800-\uDBFF]([^\uDC00-\uDFFF]|$)/g;function F(e){return String(e).replace(R,"$1�$2").replace($,encodeURI)}var Y=e=>new Promise((t,n)=>{const r=new Image,s=/* @__PURE__ */(new Date).getTime();r.src=e||`https://github.com/favicon.ico?d=${s}`,r.onload=()=>{t(/* @__PURE__ */(new Date).getTime()-s)},r.onerror=e=>{n(e)}}),N=(e,...t)=>n=>new Promise((r,s)=>{setTimeout(async()=>{try{r(await e(...t))}catch(n){s(n)}},n)}),O=async e=>{const{url:t,duration:n=3e3,count:r=5}=e;let s=0,a=0;const o=[];for(let i=0;i<r;i++){const e=await N(Y,t)(n);o.push(e)}return s=Math.max(...o)-Math.min(...o),a=o.reduce((e,t)=>e+t)/o.length,{ping:a,jitter:s}},L=()=>{if("undefined"!=typeof navigator)return navigator.vendor&&navigator.vendor.indexOf("Apple")>-1&&navigator.userAgent&&!navigator.userAgent.includes("CriOS")&&!navigator.userAgent.includes("FxiOS")},I=()=>{try{return"undefined"==typeof localStorage?null:localStorage}catch{return null}},P=(e,t)=>{try{I()?.setItem(e,t)}catch{}},C=e=>{try{return I()?.getItem(e)??""}catch{return""}},H=e=>{try{I()?.removeItem(e)}catch{}},A=(e="")=>{const t=t=>`${e}${t}`;return{keyOf:t,get:(e,n)=>{const r=C(t(e));if(!r)return n;try{return JSON.parse(r)}catch{return n}},set:(e,n)=>{let r;try{r=JSON.stringify(n)}catch{return!1}return P(t(e),r),C(t(e))===r},remove:e=>H(t(e))}},T=(e,t=2e4)=>{const n=e.slice(0,t);let r=0,s=0;for(const a of n){const e=a.codePointAt(0)??0;e>=19968&&e<=40959||e>=13312&&e<=19903?r++:(e>=65&&e<=90||e>=97&&e<=122)&&s++}return 0===r&&0===s?"other":r>=s?"zh":s>3*r?"en":"zh"},B=()=>{if("undefined"==typeof navigator)return"other";const e=(navigator.language||"").toLowerCase();return e.startsWith("zh")?"zh":e.startsWith("en")?"en":"other"},U=e=>{const{supported:t,query:n,cookie:r,storageKey:s,useNavigator:a=!0,url:o}=e,i=e.fallback??t[0]??"en";if(0===t.length)return i;const c=t.map(e=>e.toLowerCase()),u=e=>{if(!e)return;const n=e.trim().toLowerCase();if(!n)return;const r=c.indexOf(n);if(-1!==r)return t[r];const s=n.split("-")[0],a=c.findIndex(e=>e===s||e.split("-")[0]===s);return-1===a?void 0:t[a]},l=[];if(n&&l.push(b(o)[n]),r&&l.push(x(r)),s&&l.push(C(s)),a&&"undefined"!=typeof navigator){const{languages:e,language:t}=navigator;l.push(...e??[],t)}for(const d of l){const e=u(d);if(e)return e}return i},j=Object.freeze({}),q=class{_locale;_fallback;_messages;_persist;_storageKey;_handlers=/* @__PURE__ */new Set;constructor(e={}){this._messages={...e.messages},this._fallback=e.fallbackLocale??"en",this._persist=e.persist??!1,this._storageKey=e.storageKey??"ran-locale",this._locale=this._resolveInitialLocale(e)}_resolveInitialLocale(e){const t=Object.keys(this._messages),n=this._persist&&C(this._storageKey)||null;if(n&&(this._messages[n]||0===t.length))return n;if(e.locale)return e.locale;if(e.detectNavigator){const e=U({supported:t,useNavigator:!0,fallback:""});if(e)return e}return this._fallback}get locale(){return this._locale}getLocale(){return this._locale}setLocale(e){e!==this._locale&&(this._locale=e,this._persist&&P(this._storageKey,e),this._notify())}addMessages(e,t){this._messages[e]={...this._messages[e],...t}}getMessages(e=this._locale){return this._messages[e]??{}}get availableLocales(){return Object.keys(this._messages)}t(e,t){const n=this._messages[this._locale]?.[e]??this._messages[this._fallback]?.[e]??e;return this._interpolate(n,t)}_interpolate(e,t){const n=t??j;return e.replace(/\{\{|\}\}|\{(\w+)\}/g,(e,t)=>"{{"===e?"{":"}}"===e?"}":null!=n[t]?String(n[t]):e)}onChange(e){return this._handlers.add(e),()=>{this._handlers.delete(e)}}_notify(){for(const e of this._handlers)e(this._locale)}destroy(){this._handlers.clear()}},z=null;function E(e={}){const t=new q(e);return z=t,t}function K(){return z}export{h as A,M as C,p as D,v as E,s as F,c as M,g as N,r as O,o as P,Y as S,O as T,m as _,B as a,w as b,C as c,S as d,k as f,b as g,F as h,T as i,u as j,a as k,H as l,N as m,E as n,U as o,y as p,K as r,A as s,q as t,P as u,x as v,L as w,D as x,_ as y};
@@ -1,2 +0,0 @@
1
- import type { Plugin } from 'vite';
2
- export default function vitePluginBanner(): Plugin;
@@ -1 +0,0 @@
1
- var e=Object.defineProperty,r=(e,r)=>()=>(r||(e((r={exports:{}}).exports,r),e=null),r.exports),t=(r,t)=>{let o={};for(var a in r)e(o,a,{get:r[a],enumerable:!0});return t||e(o,Symbol.toStringTag,{value:"Module"}),o};export{t as n,r as t};
@@ -1,7 +0,0 @@
1
- /**
2
- * @description: Append content to an existing file
3
- * @param {string} path file path
4
- * @param {string} content content to append
5
- * @return {Promise}
6
- */
7
- export declare const appendFile: (path: string, content: string) => Promise<Ranuts.Identification>;
@@ -1,9 +0,0 @@
1
- import type { MiddlewareFunction } from '@/node/server';
2
- interface ServerBody {
3
- uploadDir: string;
4
- encoding: BufferEncoding;
5
- urlencoded: boolean;
6
- json: boolean;
7
- }
8
- declare const bodyMiddleware: (options?: Partial<ServerBody>) => MiddlewareFunction;
9
- export default bodyMiddleware;
@@ -1,7 +0,0 @@
1
- declare const _default: Record<string, (input: string) => string | StringConstructor> & {
2
- isColorSupported: boolean;
3
- reset: (s: string) => string;
4
- bold: (input: string) => string;
5
- dim: (input: string) => string;
6
- };
7
- export default _default;
@@ -1,8 +0,0 @@
1
- export declare const runCommand: (command: string, args: string[]) => Promise<void>;
2
- interface PromptOption {
3
- message: string;
4
- defaultResponse: string;
5
- stream: NodeJS.ReadWriteStream;
6
- }
7
- export declare const prompt: ({ message, stream, defaultResponse }: PromptOption) => Promise<boolean>;
8
- export {};
@@ -1,5 +0,0 @@
1
- import type { IncomingMessage, ServerResponse } from 'node:http';
2
- import type { MiddlewareFunction } from '@/node/server';
3
- type ConnectMiddleware = (req: IncomingMessage, res: ServerResponse, next?: Function) => void;
4
- declare function connect(connectMiddleware: ConnectMiddleware): MiddlewareFunction;
5
- export default connect;
@@ -1,7 +0,0 @@
1
- /**
2
- * @description: Stat a file — typically to tell a file from a directory via data.isDirectory()
3
- * @param {string} path file path
4
- * @return {Promise}
5
- */
6
- declare const queryFileInfo: (path: string) => Promise<Ranuts.Identification>;
7
- export default queryFileInfo;
@@ -1,7 +0,0 @@
1
- import fs from 'node:fs';
2
- import type { Noop } from '@/utils/noop';
3
- export type FilePromiseResult = Promise<Ranuts.Identification> & {
4
- abort?: Noop;
5
- };
6
- export type Error = NodeJS.ErrnoException | null;
7
- export default fs;
@@ -1,10 +0,0 @@
1
- interface Request {
2
- url: string;
3
- }
4
- interface Response {
5
- success: boolean;
6
- data: unknown;
7
- message: string;
8
- }
9
- declare const get: ({ url }: Request) => Promise<Response>;
10
- export default get;
@@ -1 +0,0 @@
1
- export declare const getIPAdress: () => string | undefined;
@@ -1,25 +0,0 @@
1
- import Server from './server';
2
- import { appendFile } from './appendFile';
3
- import colors from './color';
4
- import body from './body';
5
- import { prompt, runCommand } from './command';
6
- import connect from './ctx2req';
7
- import queryFileInfo from './fileInfo';
8
- import get from './get';
9
- import { getIPAdress } from './getIPAdress';
10
- import isColorSupported from './isColorSupported';
11
- import paresUrl from './paresUrl';
12
- import readDir from './readDir';
13
- import readFile from './readFile';
14
- import Router from './router';
15
- import staticMiddleware from './send';
16
- import startTask from './startTask';
17
- import { readStream, writeStream } from './stream';
18
- import taskEnd from './taskEnd';
19
- import { traverse, traverseSync } from './traverse';
20
- import watchFile from './watchFile';
21
- import WSS from './ws';
22
- import writeFile from './writeFile';
23
- import type { Context } from './server';
24
- export { appendFile, colors, body, prompt, runCommand, connect, queryFileInfo, get, getIPAdress, isColorSupported, paresUrl, readDir, Router, readFile, staticMiddleware, Server, startTask, readStream, writeStream, taskEnd, traverse, traverseSync, watchFile, WSS, writeFile, };
25
- export type { Context };
@@ -1 +0,0 @@
1
- import{G as e,W as t,at as n,r}from"../../color-B_KMM8UX.js";import{Socket as o}from"node:net";import s from"node:http";import i from"node:os";import a,{createReadStream as c,createWriteStream as d,readdir as l,readdirSync as u,stat as f,statSync as h}from"node:fs";import p from"node:tty";import m,{hrtime as w}from"node:process";import g from"node:child_process";import y from"node:readline";import b from"node:https";import E,{join as v,resolve as x}from"node:path";import{promisify as T}from"node:util";import{Buffer as S}from"node:buffer";import O from"node:crypto";function P(){const e=i.networkInterfaces();for(const t in e){const n=e[t];if(n)for(let e=0;e<n.length;e++){const t=n[e];if("IPv4"===t.family&&"127.0.0.1"!==t.address&&!t.internal)return t.address}}}var q=class{middleware;ctx;constructor(){const e=new s.IncomingMessage(new o),t=new s.ServerResponse(e);this.ctx={ipv4:P,req:e,res:t},this.middleware=[]}use(e){if(!e)throw new Error("the use function has an incorrect argument");this.middleware.push(e)}listen(...e){const t=function(e){if(!Array.isArray(e))throw new TypeError("Middleware stack must be an array!");for(const t of e)if("function"!=typeof t)throw new TypeError("Middleware must be composed of functions!");return function(t,n){let r=-1;function o(s){if(s<=r)return Promise.reject(/* @__PURE__ */new Error("next() called multiple times"));r=s;let i=e[s];if(s===e.length&&n&&(i=n),!i)return Promise.resolve();try{return Promise.resolve(i(t,o.bind(null,s+1)))}catch(a){return Promise.reject(a)}}return o(0)}}(this.middleware);return s.createServer((e,n)=>{this.ctx.req=e,this.ctx.res=n,t(this.ctx).catch(C)}).listen(...e)}};function C(e){console.error(e.stack||e.toString())}var H=a,M=(e,t="utf-8")=>{const n=new AbortController,r=n.signal,o=new Promise((o,s)=>{H.readFile(e,{encoding:t,signal:r},(e,t)=>{e?(n.abort(),s({success:!1,_identification:!1,data:e})):o({success:!0,_identification:!0,data:t})})});return o.abort=n.abort,o},_=(e,t)=>new Promise((n,r)=>{H.appendFile(e,t,t=>{t?r({success:!1,_identification:!1,data:t}):M(e).then(e=>{n(e)})})}),F=m?.env&&!("NO_COLOR"in m.env||m.argv.includes("--no-color"))&&("FORCE_COLOR"in m.env||m.argv.includes("--color")||"win32"===m.platform||p.isatty(1)&&"dumb"!==m.env.TERM||"CI"in m.env),U=(e,t,n=e)=>r=>{const o=""+r,s=o.indexOf(t,e.length);return~s?e+j(o,t,n,s)+t:e+o+t},j=(e,t,n,r)=>{const o=e.substring(0,r)+n,s=e.substring(r+t.length),i=s.indexOf(t);return~i?o+j(s,t,n,i):o+s},k=Object.assign({},((e=F)=>{const t={};return Object.keys(r).forEach(n=>t[n]=e?U(r[n][0],r[n][1]):String),t})(),((e=F)=>({isColorSupported:e,reset:e?e=>`${r.reset[0]}${e}${r.reset[1]}`:String,bold:e?U(r.bold[0],r.bold[1],`${r.bold[1]}${r.bold[0]}`):String,dim:e?U(r.dim[0],r.dim[1],`${r.dim[1]}${r.dim[0]}`):String}))()),$=(e={})=>{const{uploadDir:t=".",encoding:r="",json:o=!0}=e;return(e,s)=>{const{req:i,res:c}=e,{url:d,method:l}=i,[u="",f=""]=d?.split("?")||[],h=f?new URLSearchParams(f):{};e.request||(e.request={}),e.request.method=l,e.request.path=u,e.request.url=d,e.request.query=h;const p=i.headers["content-type"];if("application/json"===p){r?i.setEncoding(r):i.setEncoding("utf-8");let t="";i.on("data",e=>{t+=e}),i.on("end",()=>{c.setHeader("content-type","application/json;charset=UTF-8");try{e.request.body=o?JSON.parse(t):t}catch{e.request.body=t}s()})}if(p?.includes("multipart/form-data;")){const[e,o]=i.headers["content-type"]?.split(";").map(e=>e.trim())||[],[d,l]=o.split("=");r?i.setEncoding(r):i.setEncoding("binary");let u="";i.on("data",e=>{u+=e}),i.on("end",()=>{const e={};u.split("\r\n").slice(0,4).forEach(t=>{Object.assign(e,n(t,";",/=|:/))});const r=e["Content-Type"],o=Buffer.from(e.filename,"latin1").toString("utf8"),i=u.indexOf(r)+r.length,d=u.substring(i).replace(/^\s+/,""),f=d.substring(0,d.indexOf(`--${l}--`));a.writeFile(`${t}/${o}`,f,{encoding:"binary"},e=>{if(e)throw e;c.setHeader("content-type","application/json;charset=UTF-8"),s()})})}}},I=(e,t)=>new Promise((n,r)=>{const o=g.spawn(e,t,{stdio:"inherit",shell:!1});o.on("error",e=>r(e)),o.on("exit",e=>0===e?n():r(/* @__PURE__ */new Error(`Command exited with code ${e}`)))}),A=({message:e,stream:t=process.stderr,defaultResponse:n="Y"})=>{const r=y.createInterface({input:process.stdin,output:t});return new Promise(t=>{r.question(`${e} `,e=>{r.close();const o=(e||n).toLowerCase();t("y"===o||"yes"===o)})})},B=()=>{};function D(e,t,n){return t(e.req,e.res,B),n()}function L(e,t,n){return new Promise((r,o)=>{t(e.req,e.res,e=>{e?o(e):r(n())})})}function R(e){const t=e.length<3?D:L;return function(n,r){return t(n,e,r)}}var N=e=>new Promise((t,n)=>{H.stat(e,(e,r)=>{e?n({success:!1,_identification:!1,data:e}):t({success:!0,_identification:!0,data:r})})}),K=({url:e})=>new Promise((t,n)=>{b.get(e,e=>{const n=[];e.on("data",e=>{n.push(e)}),e.on("end",()=>{const{data:e=[]}=JSON.parse(Buffer.concat(n).toString());e.forEach(e=>{}),t({success:!0,data:e,message:"request success"})})}).on("error",e=>{e.message,n({success:!1,data:e,message:e.message})})}),W=()=>{const e=i.networkInterfaces();for(const t in e){const n=e[t];for(let e=0;e<n.length;e++){const t=n[e];if("IPv4"===t.family&&"127.0.0.1"!==t.address&&!t.internal)return t.address}}};function z(e){const t=e.url;if(void 0===t)return;let n=e._parsedUrl;if(n&&n._raw===t)return n;n={},n.query=n.search=void 0,n.href=n.path=n.pathname=t;const r=t.indexOf("?",1);return-1!==r&&(n.search=t.substring(r),n.query=n.search.substring(1),n.pathname=t.substring(0,r)),n._raw=t,e._parsedUrl=n}var G=e=>{const{dirPath:t}=e;try{return H.readdirSync(t)}catch(n){throw n}},J=class{ctx;map;methods;paths;constructor(){this.map=/* @__PURE__ */new Map,this.methods=/* @__PURE__ */new Set,this.paths=/* @__PURE__ */new Set}get(e,t){this.addHandlerToMap("GET")(e,t)}post(e,t){this.addHandlerToMap("POST")(e,t)}put(e,t){this.addHandlerToMap("PUT")(e,t)}patch(e,t){this.addHandlerToMap("PATCH")(e,t)}del(e,t){this.addHandlerToMap("DELETE")(e,t)}head(e,t){this.addHandlerToMap("HEAD")(e,t)}options(e,t){this.addHandlerToMap("OPTIONS")(e,t)}addHandlerToMap(e){return this.methods.add(e),(t,n)=>{this.paths.add(t);let r=this.map.get(e);r||(r=/* @__PURE__ */new Map,this.map.set(e,r)),r.set(t,n)}}routes(){return(e,t)=>{this.ctx=e;const{path:n,method:r}=e.request,o=this.map.get(r),s=o?o.get(n):t;s&&s(e,t)}}allowedMethods(){return e=>{const{res:t}=e,{path:n,method:r}=e.request;!this.methods.has(r)&&this.paths.has(n)&&(t.statusCode=405,t.end("405, method is not allowed")),this.methods.has(r)&&!this.paths.has(n)&&(t.statusCode=404,t.end("404, the request address does not exist")),this.methods.has(r)||this.paths.has(n)||(t.statusCode=501,t.end("501, not support the functionality needed to satisfy the request"))}}},Y=(n={})=>{const{pathname:r,fileTypes:o={}}=n;return async(n,s)=>{try{const{req:i,res:c}=n;if(i.url){const n="text/html",s=r||process.cwd(),d=E.normalize(E.resolve(s)),l=E.extname(i.url).slice(1);Object.keys(o).forEach(t=>e(t,o[t]));const u=l?t(l):n;if(!Boolean(u))return c.writeHead(404,{"Content-Type":"text/html"}),void c.end("404: File not found");let f=i.url;if("/"===i.url)f="index.html";else if(!l)try{a.accessSync(E.join(d,i.url+".html"),a.constants.F_OK),f=i.url+".html"}catch{f=E.join(i.url,"index.html")}const h=E.join(d,f);if(!E.normalize(E.resolve(h)).startsWith(d))return c.writeHead(404,{"Content-Type":"text/html"}),void c.end("404: File not found");a.readFile(h,(e,t)=>{e?(c.writeHead(404,{"Content-Type":"text/html"}),c.end("404: File not found")):(c.writeHead(200,{"Content-Type":u}),c.end(t))})}await s()}catch{}}},Q=()=>{if("undefined"!=typeof window){const e=window.performance.now();return Symbol.for(`${e}`)}if("undefined"!=typeof process){const e=w.bigint();return Symbol.for(`${e}`)}return Symbol.for(`${Date.now()}`)},V=e=>{const{path:t}=e;if(t)return c(t);throw new Error("path is not defined")},X=e=>{const{path:t}=e;if(t)return d(t);throw new Error("path is not defined")},Z=e=>{const t=Symbol.keyFor(e);return"undefined"!=typeof window&&t?window.performance.now()-Number(t):"undefined"!=typeof process&&t?w.bigint()-BigInt(t):Date.now()-Number(t)},ee=T(f),te=T(l);async function ne(e,t,n=""){e=x(".",e);const r=await te(e);await Promise.all(r.map(async r=>{const o=v(e,r),s=await ee(o);return s.isDirectory()?ne(o,t,v(n,r)):t(v(n,r),o,s)}))}function re(e,t,n=""){e=x(".",e);const r=u(e);let o,s,i=0;for(;i<r.length;i++)o=v(e,r[i]),s=h(o),s.isDirectory()?re(o,t,v(n,r[i])):t(v(n,r[i]),o,s)}var oe=(e,t=20)=>new Promise(n=>{H.watchFile(e,{interval:t},(t,r)=>{t.mtime!==r.mtime?(H.unwatchFile(e),n({success:!0,_identification:!0,data:{},message:"file is changed"})):n({success:!1,_identification:!1,data:{},message:"file is not changed"})})});function se(e,t){const n=S.byteLength(e);let r=null;if(n>65535?(r=S.alloc(10+n),r[1]=127,r.writeUInt32BE(n,6),r.write(e,10)):n>125?(r=S.alloc(4+n),r[1]=126,r.writeUInt16BE(n,2),r.write(e,4)):(r=S.alloc(2+n),r[1]=n,r.write(e,2)),t){const e=t.opcode;e&&e<15&&e>=0&&(r[0]=128|e)}else r[0]=129;return r}function ie(e,t){if(!t)return e;const n=S.from(e);for(let r=0;r<n.length;++r)n[r]=n[r]^t[r%4];return n}function ae(){const e={};this.on=(t,n)=>{e[t]?e[t].push(n):e[t]=[n]},this.off=(t,n)=>{const r=e[t],o=r.indexOf(n);r&&-1!==o&&r.splice(o,1)},this.emit=(t,n)=>{e[t]&&e[t].forEach(e=>e(n))}}function ce(e){ae.call(this);const t=[];this.server=e,this.clients=t,this.broadcast=e=>{t.forEach(t=>{t.send(e)})},e.on("upgrade",(e,n)=>{n.write(["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade","Sec-WebSocket-Accept: "+O.createHash("sha1").update(e.headers["sec-websocket-key"]+"258EAFA5-E914-47DA-95CA-C5AB0DC85B11").digest("base64")].join("\n")+"\n\n");const r={send(e,t){n.write(se(e,t))},ping(){n.write(se("",{opcode:9}))},pong(){n.write(se("",{opcode:10}))},close(){if(-1===t.indexOf(r))return!1;t.splice(t.indexOf(r),1),n.write(se("",{opcode:8})),r.emit("close"),n.destroy()},socket:n};ae.call(r),this.emit("connect",r),t.push(r);let o=S.allocUnsafe(0),s=S.allocUnsafe(0);const i=[];let a=!0;function c(){const e=function(e){const t=S.from(e),n=127&t[1];let r=0,o=0;const s=t[1]>=128;return 127===n?(r=t.readUInt32BE(6),o=10):126===n?(r=t.readUInt16BE(2),o=4):(r=n,o=2),{fin:t[0]>=128,opcode:15&t[0],mask:s,maskKey:s?t.subarray(o,o+(s?4:0)):null,len7:n,len:r,lenMeta:o+(s?4:0)}}(o);i.push({l:e.lenMeta,f:()=>{a=!1,i.push({l:e.len,f:t=>{if(s=S.concat([s,ie(t,e.maskKey)]),a=!0,e.fin){if(8===e.opcode)return r.close();if(9===e.opcode)return r.pong();r.emit("message",s),s=S.allocUnsafe(0)}}})}})}n.on("data",e=>{for(o=S.concat([o,e]),a&&c();i[0]&&o.byteLength>=i[0].l;){const e=i[0].l;i[0].f(o.subarray(0,e)),o=o.subarray(e),i.splice(0,1)}}),n.on("end",()=>{r.close()}),n.on("error",e=>{r.emit("error",e),r.close()})})}var de=(e,t)=>new Promise((n,r)=>{H.writeFile(e,t,{mode:438,flag:"w+",encoding:"utf-8"},o=>{if(o)throw r({success:!1,_identification:!1,data:o}),o;n({success:!0,_identification:!1,data:{path:e,content:t}})})});export{J as Router,q as Server,ce as WSS,_ as appendFile,$ as body,k as colors,R as connect,K as get,W as getIPAdress,F as isColorSupported,z as paresUrl,A as prompt,N as queryFileInfo,G as readDir,M as readFile,V as readStream,I as runCommand,Q as startTask,Y as staticMiddleware,Z as taskEnd,ne as traverse,re as traverseSync,oe as watchFile,de as writeFile,X as writeStream};
@@ -1,2 +0,0 @@
1
- declare const isColorSupported: boolean;
2
- export default isColorSupported;
@@ -1,19 +0,0 @@
1
- import type { IncomingMessage } from 'node:http';
2
- interface ParseUrl {
3
- search?: string;
4
- query?: string;
5
- pathname?: string;
6
- path?: string;
7
- href?: string;
8
- _raw?: string;
9
- }
10
- interface Req extends IncomingMessage {
11
- _parsedUrl?: ParseUrl;
12
- }
13
- /**
14
- * @description: Parse an IncomingMessage's request URL; the return type is always ParseUrl
15
- * @param {Req} req
16
- * @return {ParseUrl}
17
- */
18
- export default function (req: Req): ParseUrl | undefined;
19
- export {};
@@ -1,6 +0,0 @@
1
- interface Options {
2
- dirPath: string;
3
- ignores?: Array<string>;
4
- }
5
- declare const readDir: (options: Options) => Array<string>;
6
- export default readDir;
@@ -1,9 +0,0 @@
1
- import type { FilePromiseResult } from '@/node/fs';
2
- /**
3
- * @description: Read a file, returning a status code and the content on success
4
- * @param {string} path file path
5
- * @param {string} format encoding, defaults to utf-8
6
- * @return {Promise}
7
- */
8
- declare const readFile: (path: string, format?: BufferEncoding) => FilePromiseResult;
9
- export default readFile;
@@ -1,42 +0,0 @@
1
- import type { Context, MiddlewareFunction, Next } from '@/node/server';
2
- /**
3
- * @description:
4
- *
5
- * Basic usage:
6
- *
7
- * ```javascript
8
- * import Server from '@/server/server'
9
- * import Router from '@/server/router'
10
- *
11
- * const app = new Server();
12
- * const router = new Router();
13
- *
14
- * router.get('/', (ctx, next) => {
15
- * // ctx.router available
16
- * });
17
- *
18
- * app
19
- * .use(router.routes())
20
- * .use(router.allowedMethods());
21
- * ```
22
- * @return {*}
23
- */
24
- type Handler = (ctx: Context, next: Next) => void;
25
- declare class Router {
26
- ctx?: Context;
27
- map: Map<string, Map<string, Handler>>;
28
- methods: Set<string>;
29
- paths: Set<string>;
30
- constructor();
31
- get(url: string, handler: Handler): void;
32
- post(url: string, handler: Handler): void;
33
- put(url: string, handler: Handler): void;
34
- patch(url: string, handler: Handler): void;
35
- del(url: string, handler: Handler): void;
36
- head(url: string, handler: Handler): void;
37
- options(url: string, handler: Handler): void;
38
- private addHandlerToMap;
39
- routes(): MiddlewareFunction;
40
- allowedMethods(): MiddlewareFunction;
41
- }
42
- export default Router;
@@ -1,7 +0,0 @@
1
- import type { MiddlewareFunction } from '@/node/server';
2
- interface Option {
3
- pathname: string;
4
- fileTypes: Record<string, string>;
5
- }
6
- declare const staticMiddleware: (option?: Partial<Option>) => MiddlewareFunction;
7
- export default staticMiddleware;
@@ -1,18 +0,0 @@
1
- import type { IncomingMessage, ServerResponse } from 'node:http';
2
- import http from 'node:http';
3
- export type Next = () => Promise<never> | Promise<void>;
4
- export type MiddlewareFunction = (ctx: Context, next: Next) => void | Promise<void>;
5
- export interface Context {
6
- [x: string]: any;
7
- ipv4: () => string | undefined;
8
- req: IncomingMessage;
9
- res: ServerResponse;
10
- }
11
- declare class Server {
12
- middleware: Array<MiddlewareFunction>;
13
- ctx: Context;
14
- constructor();
15
- use(handle: MiddlewareFunction): void;
16
- listen(...args: any): http.Server;
17
- }
18
- export default Server;
@@ -1,2 +0,0 @@
1
- declare const startTask: () => symbol;
2
- export default startTask;
@@ -1,15 +0,0 @@
1
- import type { ReadStream, WriteStream } from 'node:fs';
2
- interface ReadOption {
3
- path: string;
4
- encoding: string;
5
- start: number;
6
- end: number;
7
- highWaterMark: number;
8
- }
9
- interface WriteOption {
10
- path: string;
11
- encoding: string;
12
- }
13
- export declare const readStream: (option: ReadOption) => ReadStream;
14
- export declare const writeStream: (option: WriteOption) => WriteStream;
15
- export {};
@@ -1,2 +0,0 @@
1
- declare const taskEnd: (symbol: symbol) => number | bigint;
2
- export default taskEnd;
@@ -1,17 +0,0 @@
1
- import type { Stats } from 'node:fs';
2
- type Caller = (relPath: string, absPath: string, stats: Stats) => any;
3
- /**
4
- * @description: Walk every directory recursively, running a function for each file found
5
- * @param {string} dir
6
- * @param {Caller} callback
7
- * @param {*} pre
8
- */
9
- export declare function traverse(dir: string, callback: Caller, pre?: string): Promise<any>;
10
- /**
11
- * @description: Synchronous: walk every directory recursively, running a function for each file found
12
- * @param {string} dir
13
- * @param {Caller} callback
14
- * @param {*} pre
15
- */
16
- export declare function traverseSync(dir: string, callback: Caller, pre?: string): void;
17
- export {};
@@ -1,8 +0,0 @@
1
- /**
2
- * @description: Watch a file for changes and report its status
3
- * @param {string} path file to watch
4
- * @param {number} interval poll interval in milliseconds, defaults to 20
5
- * @return {Promise}
6
- */
7
- declare const watchFile: (path: string, interval?: number) => Promise<Ranuts.Identification>;
8
- export default watchFile;
@@ -1,8 +0,0 @@
1
- /**
2
- * @description: Write a file at the given path, truncating it if it exists and creating it if it does not
3
- * @param {string} path file path
4
- * @param {string} content file content
5
- * @return {Promise}
6
- */
7
- declare const writeFile: (path: string, content: string) => Promise<Ranuts.Identification>;
8
- export default writeFile;
@@ -1,8 +0,0 @@
1
- import type http from 'node:http';
2
- /**
3
- * Create a WebSocket Server
4
- * @constructor
5
- * @param { http.Server } server server from http(s).createServer()
6
- */
7
- declare function WSS(this: any, server: http.Server): void;
8
- export default WSS;
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,2 +0,0 @@
1
- declare const startDevServer: () => void;
2
- export { startDevServer };
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};