ranuts 0.1.0-alpha → 0.1.0-alpha-21

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 (211) hide show
  1. package/LICENSE +21 -0
  2. package/dist/build/build.es.d.ts +2 -0
  3. package/dist/build/build.umd.d.ts +2 -0
  4. package/dist/build/build.umd.ml.d.ts +2 -0
  5. package/dist/build/build.umd.node.d.ts +2 -0
  6. package/dist/build/build.umd.react.d.ts +2 -0
  7. package/dist/build/build.umd.utils.d.ts +2 -0
  8. package/dist/build/build.umd.wasm.d.ts +2 -0
  9. package/dist/color-BgjAdNyp.js +82296 -0
  10. package/dist/examples/clone-deep-example.d.ts +1 -0
  11. package/dist/examples/is-equal-example.d.ts +1 -0
  12. package/dist/index.d.ts +9 -9
  13. package/dist/index.js +151 -84
  14. package/dist/plugins/vite-plugins-banner.d.ts +2 -0
  15. package/dist/reactify-Z-V9Vblb.js +83 -0
  16. package/dist/src/arithmetic/index.d.ts +186 -0
  17. package/dist/src/cache/expires.d.ts +1 -0
  18. package/dist/src/ml/index.d.ts +2 -0
  19. package/dist/src/ml/index.js +1243 -0
  20. package/dist/src/ml/ocr.d.ts +11 -0
  21. package/dist/src/node/appendFile.d.ts +7 -0
  22. package/dist/src/node/body.d.ts +9 -0
  23. package/dist/src/node/color.d.ts +7 -0
  24. package/dist/src/node/command.d.ts +8 -0
  25. package/dist/src/node/ctx2req.d.ts +5 -0
  26. package/dist/src/node/fileInfo.d.ts +7 -0
  27. package/dist/src/node/fs.d.ts +7 -0
  28. package/dist/src/node/get.d.ts +10 -0
  29. package/dist/src/node/getIPAdress.d.ts +1 -0
  30. package/dist/src/node/index.d.ts +25 -0
  31. package/dist/src/node/index.js +54 -0
  32. package/dist/src/node/isColorSupported.d.ts +2 -0
  33. package/dist/src/node/paresUrl.d.ts +19 -0
  34. package/dist/src/node/readDir.d.ts +6 -0
  35. package/dist/src/node/readFile.d.ts +9 -0
  36. package/dist/src/node/router.d.ts +42 -0
  37. package/dist/src/node/send.d.ts +7 -0
  38. package/dist/src/node/server.d.ts +18 -0
  39. package/dist/src/node/startTask.d.ts +2 -0
  40. package/dist/src/node/stream.d.ts +15 -0
  41. package/dist/src/node/taskEnd.d.ts +2 -0
  42. package/dist/src/node/traverse.d.ts +17 -0
  43. package/dist/src/node/watchFile.d.ts +8 -0
  44. package/dist/src/node/websocket.d.ts +57 -0
  45. package/dist/src/node/writeFile.d.ts +8 -0
  46. package/dist/src/node/ws.d.ts +8 -0
  47. package/dist/src/optimize/index.d.ts +36 -0
  48. package/dist/src/optimize/promise.d.ts +0 -0
  49. package/dist/src/ran/commit.d.ts +0 -0
  50. package/dist/src/ran/dom.d.ts +0 -0
  51. package/dist/src/ran/hooks.d.ts +0 -0
  52. package/dist/src/ran/index.d.ts +20 -0
  53. package/dist/src/ran/min.d.ts +32 -0
  54. package/dist/src/ran/reconcile.d.ts +0 -0
  55. package/dist/src/ran/schedule.d.ts +0 -0
  56. package/dist/src/react/index.d.ts +2 -0
  57. package/dist/src/react/index.js +4 -0
  58. package/dist/src/react/reactify.d.ts +2 -0
  59. package/dist/src/sort/bubble.d.ts +7 -0
  60. package/dist/src/sort/bucket.d.ts +7 -0
  61. package/dist/src/sort/count.d.ts +7 -0
  62. package/dist/src/sort/heap.d.ts +7 -0
  63. package/dist/src/sort/index.d.ts +0 -0
  64. package/dist/src/sort/insert.d.ts +7 -0
  65. package/dist/src/sort/merge.d.ts +7 -0
  66. package/dist/src/sort/quick.d.ts +7 -0
  67. package/dist/src/sort/radix.d.ts +7 -0
  68. package/dist/src/sort/randomArray.d.ts +9 -0
  69. package/dist/src/sort/select.d.ts +7 -0
  70. package/dist/src/sort/shell.d.ts +7 -0
  71. package/dist/src/utils/audioRecorder.d.ts +16 -0
  72. package/dist/src/utils/behavior.d.ts +15 -0
  73. package/dist/src/utils/bom.d.ts +230 -0
  74. package/dist/src/utils/color.d.ts +71 -0
  75. package/dist/src/utils/compose.d.ts +10 -0
  76. package/dist/src/utils/console.d.ts +1 -0
  77. package/dist/src/utils/debounce.d.ts +7 -0
  78. package/dist/src/utils/device.d.ts +25 -0
  79. package/dist/src/utils/dom.d.ts +105 -0
  80. package/dist/src/utils/error.d.ts +1 -0
  81. package/dist/src/utils/func.d.ts +1 -0
  82. package/dist/src/utils/img.d.ts +16 -0
  83. package/dist/src/utils/index.d.ts +35 -0
  84. package/dist/src/utils/index.js +4548 -0
  85. package/dist/src/utils/memoize.d.ts +7 -0
  86. package/dist/src/utils/mimeType.d.ts +9 -0
  87. package/dist/src/utils/monitor.d.ts +38 -0
  88. package/dist/src/utils/network.d.ts +39 -0
  89. package/dist/src/utils/noop.d.ts +2 -0
  90. package/dist/src/utils/number.d.ts +45 -0
  91. package/dist/src/utils/obj.d.ts +83 -0
  92. package/dist/src/utils/performance.d.ts +21 -0
  93. package/dist/src/utils/queue.d.ts +33 -0
  94. package/dist/src/utils/report.d.ts +8 -0
  95. package/dist/src/utils/request.d.ts +17 -0
  96. package/dist/src/utils/script.d.ts +7 -0
  97. package/dist/src/utils/signal.d.ts +6 -0
  98. package/dist/src/utils/storage.d.ts +2 -0
  99. package/dist/src/utils/str.d.ts +212 -0
  100. package/dist/src/utils/subscribe.d.ts +46 -0
  101. package/dist/src/utils/throttle.d.ts +15 -0
  102. package/dist/src/utils/time.d.ts +20 -0
  103. package/dist/src/utils/totp/sha/common.d.ts +151 -0
  104. package/dist/src/utils/totp/sha/converters.d.ts +88 -0
  105. package/dist/src/utils/totp/sha/custom_types.d.ts +60 -0
  106. package/dist/src/utils/totp/sha/primitives_32.d.ts +98 -0
  107. package/dist/src/utils/totp/sha/primitives_64.d.ts +116 -0
  108. package/dist/src/utils/totp/sha/sha.d.ts +103 -0
  109. package/dist/src/utils/totp/sha/sha1.d.ts +18 -0
  110. package/dist/src/utils/totp/sha/sha256.d.ts +20 -0
  111. package/dist/src/utils/totp/sha/sha3.d.ts +53 -0
  112. package/dist/src/utils/totp/sha/sha512.d.ts +21 -0
  113. package/dist/src/utils/totp/totp.d.ts +23 -0
  114. package/dist/src/utils/visual/application.d.ts +14 -0
  115. package/dist/src/utils/visual/demo/index.d.ts +1 -0
  116. package/dist/src/utils/visual/demo/sankey.d.ts +2 -0
  117. package/dist/src/utils/visual/enums.d.ts +27 -0
  118. package/dist/src/utils/visual/event/boundary.d.ts +22 -0
  119. package/dist/src/utils/visual/event/event.d.ts +14 -0
  120. package/dist/src/utils/visual/event/index.d.ts +6 -0
  121. package/dist/src/utils/visual/event/types.d.ts +32 -0
  122. package/dist/src/utils/visual/graphics/graphics.d.ts +81 -0
  123. package/dist/src/utils/visual/graphics/graphicsData.d.ts +13 -0
  124. package/dist/src/utils/visual/graphics/graphicsGeometry.d.ts +35 -0
  125. package/dist/src/utils/visual/graphics/index.d.ts +4 -0
  126. package/dist/src/utils/visual/index.d.ts +7 -0
  127. package/dist/src/utils/visual/math/bezier.d.ts +2 -0
  128. package/dist/src/utils/visual/math/enums.d.ts +3 -0
  129. package/dist/src/utils/visual/math/index.d.ts +5 -0
  130. package/dist/src/utils/visual/math/matrix.d.ts +113 -0
  131. package/dist/src/utils/visual/math/transform.d.ts +29 -0
  132. package/dist/src/utils/visual/render/batchRenderer.d.ts +72 -0
  133. package/dist/src/utils/visual/render/canvasRenderer.d.ts +10 -0
  134. package/dist/src/utils/visual/render/index.d.ts +3 -0
  135. package/dist/src/utils/visual/render/render.d.ts +15 -0
  136. package/dist/src/utils/visual/render/utils/batch/index.d.ts +90 -0
  137. package/dist/src/utils/visual/render/utils/float.d.ts +63 -0
  138. package/dist/src/utils/visual/render/utils/index.d.ts +3 -0
  139. package/dist/src/utils/visual/render/utils/verticy.d.ts +13 -0
  140. package/dist/src/utils/visual/render/utils/webgl/batchPool.d.ts +28 -0
  141. package/dist/src/utils/visual/render/utils/webgl/initShader.d.ts +2 -0
  142. package/dist/src/utils/visual/render/utils/webgl/shaders.d.ts +2 -0
  143. package/dist/src/utils/visual/render/utils/webgpu/shaders.d.ts +8 -0
  144. package/dist/src/utils/visual/render/webGPURenderer.d.ts +49 -0
  145. package/dist/src/utils/visual/render/webGlRenderer.d.ts +17 -0
  146. package/dist/src/utils/visual/shape/circle.d.ts +11 -0
  147. package/dist/src/utils/visual/shape/ellipse.d.ts +12 -0
  148. package/dist/src/utils/visual/shape/index.d.ts +7 -0
  149. package/dist/src/utils/visual/shape/polygon.d.ts +11 -0
  150. package/dist/src/utils/visual/shape/rectangle.d.ts +12 -0
  151. package/dist/src/utils/visual/shape/roundedRectangle.d.ts +13 -0
  152. package/dist/src/utils/visual/shape/shape.d.ts +6 -0
  153. package/dist/src/utils/visual/style/fill.d.ts +8 -0
  154. package/dist/src/utils/visual/style/index.d.ts +3 -0
  155. package/dist/src/utils/visual/style/line.d.ts +10 -0
  156. package/dist/src/utils/visual/types.d.ts +17 -0
  157. package/dist/src/utils/visual/vertex/container.d.ts +73 -0
  158. package/dist/src/utils/visual/vertex/index.d.ts +5 -0
  159. package/dist/src/utils/visual/vertex/point.d.ts +18 -0
  160. package/dist/src/utils/visual/vertex/vertex.d.ts +36 -0
  161. package/dist/src/vnode/chainDom.d.ts +47 -0
  162. package/dist/src/vnode/h.d.ts +6 -0
  163. package/dist/src/vnode/hooks.d.ts +23 -0
  164. package/dist/src/vnode/htmlDomApi.d.ts +33 -0
  165. package/dist/src/vnode/init.d.ts +2 -0
  166. package/dist/src/vnode/is.d.ts +5 -0
  167. package/dist/src/vnode/modules/attributes.d.ts +8 -0
  168. package/dist/src/vnode/modules/class.d.ts +8 -0
  169. package/dist/src/vnode/modules/index.d.ts +3 -0
  170. package/dist/src/vnode/modules/listeners.d.ts +12 -0
  171. package/dist/src/vnode/modules/props.d.ts +8 -0
  172. package/dist/src/vnode/modules/style.d.ts +14 -0
  173. package/dist/src/vnode/vnode.d.ts +31 -0
  174. package/dist/src/wasm/index.d.ts +2 -0
  175. package/dist/src/wasm/index.js +346 -0
  176. package/dist/src/wasm/word.d.ts +17 -0
  177. package/dist/src/wicket/bridge.d.ts +4 -0
  178. package/dist/src/wicket/index.d.ts +29 -0
  179. package/dist/test/arithmetic.test.d.ts +1 -0
  180. package/dist/test/cloneDeep.test.d.ts +1 -0
  181. package/dist/test/encodeUrl.test.d.ts +1 -0
  182. package/dist/test/escapeHtml.test.d.ts +1 -0
  183. package/dist/test/is-equal.test.d.ts +1 -0
  184. package/dist/test/mimeType.test.d.ts +1 -0
  185. package/dist/test/server.test.d.ts +1 -0
  186. package/dist/test/sort.test.d.ts +1 -0
  187. package/dist/test/status.test.d.ts +1 -0
  188. package/dist/test/totp.test.d.ts +1 -0
  189. package/dist/test/utils/compose.test.d.ts +1 -0
  190. package/dist/test/utils/mergeObj.test.d.ts +1 -0
  191. package/dist/test/utils/ocr.test.d.ts +1 -0
  192. package/dist/test/visual/math.test.d.ts +1 -0
  193. package/dist/test/vnode/index.d.ts +1 -0
  194. package/dist/test/vnode/server.d.ts +2 -0
  195. package/dist/test/vnode/vnode.d.ts +1 -0
  196. package/dist/test/websocket.test.d.ts +1 -0
  197. package/dist/test/writeFile.test.d.ts +1 -0
  198. package/dist/umd/index.umd.cjs +1 -0
  199. package/dist/umd/ml/ml.umd.cjs +1 -0
  200. package/dist/umd/node/node.umd.cjs +1 -0
  201. package/dist/umd/react/react.umd.cjs +1 -0
  202. package/dist/umd/utils/utils.umd.cjs +1 -0
  203. package/dist/umd/wasm/wasm.umd.cjs +1 -0
  204. package/dist/vite.config.d.ts +11 -0
  205. package/dist/ws-D7Jt2dzL.js +703 -0
  206. package/package.json +70 -13
  207. package/readme.md +91 -0
  208. package/typings.d.ts +28 -0
  209. package/dist/index.js.map +0 -1
  210. package/dist/index.umd.cjs +0 -2
  211. package/dist/index.umd.cjs.map +0 -1
@@ -0,0 +1,11 @@
1
+ import type { BaseReturn } from '@/utils/bom';
2
+ interface Options {
3
+ images: string[];
4
+ language: string;
5
+ langPath?: string;
6
+ }
7
+ interface OcrReturn extends BaseReturn {
8
+ data: null | Tesseract.RecognizeResult[];
9
+ }
10
+ export declare const ocr: ({ images, language, langPath }: Options) => Promise<OcrReturn>;
11
+ export {};
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @description: 给一个已经存在的文件追加内容
3
+ * @param {string} path 文件路径
4
+ * @param {string} content 新加的内容
5
+ * @return {Promise}
6
+ */
7
+ export declare const appendFile: (path: string, content: string) => Promise<Ranuts.Identification>;
@@ -0,0 +1,9 @@
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;
@@ -0,0 +1,7 @@
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;
@@ -0,0 +1,8 @@
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 {};
@@ -0,0 +1,5 @@
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;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @description: 查询一个文件的详细信息,一般用于区分文件还是目录(data.isDirectory())
3
+ * @param {string} path 文件路径
4
+ * @return {Promise}
5
+ */
6
+ declare const queryFileInfo: (path: string) => Promise<Ranuts.Identification>;
7
+ export default queryFileInfo;
@@ -0,0 +1,7 @@
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;
@@ -0,0 +1,10 @@
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;
@@ -0,0 +1 @@
1
+ export declare const getIPAdress: () => string | undefined;
@@ -0,0 +1,25 @@
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 };
@@ -0,0 +1,54 @@
1
+ import { R, S, W, a, b, c, d, g, e, i, p, f, q, r, h, j, k, s, l, t, m, n, w, o } from "../../ws-D7Jt2dzL.js";
2
+ import fs from "node:fs";
3
+ const writeFile = (path, content) => new Promise((resolve, reject) => {
4
+ fs.writeFile(
5
+ path,
6
+ content,
7
+ {
8
+ mode: 438,
9
+ // 可读可写666,转化为十进制就是438
10
+ flag: "w+",
11
+ // r+并不会清空再写入,w+会清空再写入
12
+ encoding: "utf-8"
13
+ },
14
+ (err) => {
15
+ if (err) {
16
+ reject({ success: false, _identification: false, data: err });
17
+ throw err;
18
+ } else {
19
+ resolve({
20
+ success: true,
21
+ _identification: false,
22
+ data: { path, content }
23
+ });
24
+ }
25
+ }
26
+ );
27
+ });
28
+ export {
29
+ R as Router,
30
+ S as Server,
31
+ W as WSS,
32
+ a as appendFile,
33
+ b as body,
34
+ c as colors,
35
+ d as connect,
36
+ g as get,
37
+ e as getIPAdress,
38
+ i as isColorSupported,
39
+ p as paresUrl,
40
+ f as prompt,
41
+ q as queryFileInfo,
42
+ r as readDir,
43
+ h as readFile,
44
+ j as readStream,
45
+ k as runCommand,
46
+ s as startTask,
47
+ l as staticMiddleware,
48
+ t as taskEnd,
49
+ m as traverse,
50
+ n as traverseSync,
51
+ w as watchFile,
52
+ writeFile,
53
+ o as writeStream
54
+ };
@@ -0,0 +1,2 @@
1
+ declare const isColorSupported: boolean;
2
+ export default isColorSupported;
@@ -0,0 +1,19 @@
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: 解析 IncomingMessage 类型的请求url,返回的类型永远是 ParseUrl
15
+ * @param {Req} req
16
+ * @return {ParseUrl}
17
+ */
18
+ export default function (req: Req): ParseUrl | undefined;
19
+ export {};
@@ -0,0 +1,6 @@
1
+ interface Options {
2
+ dirPath: string;
3
+ ignores?: Array<string>;
4
+ }
5
+ declare const readDir: (options: Options) => Array<string>;
6
+ export default readDir;
@@ -0,0 +1,9 @@
1
+ import type { FilePromiseResult } from '@/node/fs';
2
+ /**
3
+ * @description: 读取一个文件,读取成功返回状态码和文件内容
4
+ * @param {string} path 文件路径
5
+ * @param {string} format 读取格式,默认utf-8
6
+ * @return {Promise}
7
+ */
8
+ declare const readFile: (path: string, format?: BufferEncoding) => FilePromiseResult;
9
+ export default readFile;
@@ -0,0 +1,42 @@
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;
@@ -0,0 +1,7 @@
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;
@@ -0,0 +1,18 @@
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;
@@ -0,0 +1,2 @@
1
+ declare const startTask: () => symbol;
2
+ export default startTask;
@@ -0,0 +1,15 @@
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 {};
@@ -0,0 +1,2 @@
1
+ declare const taskEnd: (symbol: symbol) => number | bigint;
2
+ export default taskEnd;
@@ -0,0 +1,17 @@
1
+ import type { Stats } from 'node:fs';
2
+ type Caller = (relPath: string, absPath: string, stats: Stats) => any;
3
+ /**
4
+ * @description: 递归遍历每一个目录,为找到的文件都执行一个函数
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: 同步方法,递归遍历每一个目录,为找到的文件都执行一个函数
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 {};
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @description: 观察一个文件是否被改变,返回状态
3
+ * @param {string} path 监听的文件路径
4
+ * @param {number} interval 监听的时间,单位毫秒,默认 20 毫秒
5
+ * @return {Promise}
6
+ */
7
+ declare const watchFile: (path: string, interval?: number) => Promise<Ranuts.Identification>;
8
+ export default watchFile;
@@ -0,0 +1,57 @@
1
+ import http from 'node:http';
2
+ import type internal from 'node:stream';
3
+ import EventEmitter from 'node:events';
4
+ interface FrameMeta {
5
+ fin: boolean;
6
+ opcode: number;
7
+ mask: boolean;
8
+ maskKey: Buffer | null;
9
+ payloadSize: number;
10
+ size: number;
11
+ metaSize: number;
12
+ }
13
+ export declare class Client extends EventEmitter {
14
+ socket: internal.Duplex;
15
+ connectTime: number;
16
+ constructor(socket: internal.Duplex);
17
+ createFrame(content: string, options?: {
18
+ opcode: number;
19
+ }): Buffer;
20
+ send(data: string, options?: {
21
+ opcode: number;
22
+ }): void;
23
+ ping(): void;
24
+ pong(): void;
25
+ close(): void;
26
+ }
27
+ declare class WebSocket extends EventEmitter {
28
+ server: http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
29
+ clients: Array<Client>;
30
+ constructor({ port }: {
31
+ port: number;
32
+ });
33
+ /**
34
+ * @description: 向所有 client 广播
35
+ * @param {string} data
36
+ */
37
+ broadcast(data: string): void;
38
+ /**
39
+ * @description: 创建 client
40
+ * @param {http} req
41
+ * @param {internal} socket
42
+ */
43
+ create(req: http.IncomingMessage, socket: internal.Duplex): void;
44
+ /**
45
+ * @description: 增加 client 监听关闭事件
46
+ * @param {Client} client
47
+ */
48
+ addListenCloseClient(client: Client): void;
49
+ /**
50
+ * @description: 解析帧 meta
51
+ * @param {Buffer} source
52
+ * @return {FrameMeta}
53
+ */
54
+ parseFrameMeta(source: Buffer): FrameMeta;
55
+ iMask(data: Buffer, key: Buffer | null): Buffer;
56
+ }
57
+ export default WebSocket;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @description: 根据文件路径创建文件,如果文件存在会清空再写入,如果不存在会创建
3
+ * @param {string} path 文件路径
4
+ * @param {string} content 文件内容
5
+ * @return {Promise}
6
+ */
7
+ declare const writeFile: (path: string, content: string) => Promise<Ranuts.Identification>;
8
+ export default writeFile;
@@ -0,0 +1,8 @@
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;
@@ -0,0 +1,36 @@
1
+ /**
2
+ * @description: 实现 object.create,将传入的对象作为原型
3
+ * @param {*} obj
4
+ * @return {*}
5
+ */
6
+ /**
7
+ * @description: 实现 instanceof: object instanceof constructor
8
+ * @param {*} left
9
+ * @param {*} right
10
+ * @return {*}
11
+ */
12
+ export declare const instanceOf: (obj: Record<string, unknown>, cst: Function) => boolean;
13
+ /**
14
+ * @description: 实现 new 操作符
15
+ * @param {*} 构造函数
16
+ * @param {*} 参数
17
+ * @return {*} Object
18
+ */
19
+ export declare function customNew(...args: unknown[]): Record<string, unknown>;
20
+ /**
21
+ * @description: 防抖
22
+ * @param {Function} fn
23
+ * @param {number} wait
24
+ * @return {*}
25
+ */
26
+ export declare function debounce<T extends (...args: any[]) => any>(ms: number, callback: T): (...args: Parameters<T>) => Promise<ReturnType<T>>;
27
+ /**
28
+ * @description: 首节流
29
+ * @return {*}
30
+ */
31
+ export declare function throttle(fn: Function, wait?: number): Function;
32
+ /**
33
+ * @description: 实现 call 函数
34
+ * @param {unknown} this
35
+ * @return {*}
36
+ */
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,20 @@
1
+ type InventedElementProps = any;
2
+ interface InventedElement {
3
+ type: string;
4
+ props: InventedElementProps;
5
+ }
6
+ /**
7
+ * @description: 创建虚拟DOM,参考React源码:https://github.com/facebook/react/blob/main/packages/react/src/ReactElement.js
8
+ * @param {string} type
9
+ * @param {VirtualDomProps} props
10
+ * @param {array} children
11
+ * @return {VirtualDom}
12
+ */
13
+ declare function createElement(type: string, config: InventedElementProps, children: Array<InventedElement>): InventedElement;
14
+ /**
15
+ * @description: 传入虚拟DOM和需要挂载的根节点,将虚拟DOM转化为Fiber,将fiber转化为真实DOM进行挂载
16
+ * @param {InventedElement} inventedElement
17
+ * @param {Element} root
18
+ */
19
+ declare function render(inventedElement: InventedElement, root: Element): void;
20
+ export { render, createElement };
@@ -0,0 +1,32 @@
1
+ interface Fiber {
2
+ type: string;
3
+ dom?: HTMLElement | Text;
4
+ parent?: Fiber;
5
+ child?: Fiber;
6
+ sibling?: Fiber;
7
+ props: {
8
+ [x: string]: Array<Fiber> | string | undefined;
9
+ children?: Array<Fiber>;
10
+ };
11
+ }
12
+ /**
13
+ * @description: render 函数
14
+ * @param {RanElement} element
15
+ * @param {HTMLElement} container
16
+ */
17
+ declare const render: (element: Fiber, container: HTMLElement) => void;
18
+ export declare class Concurrent {
19
+ nextUnitOfWork: Fiber | undefined;
20
+ wipRoot: Fiber | undefined;
21
+ constructor(element: Fiber, container: HTMLElement);
22
+ workLoop(deadline: IdleDeadline): void;
23
+ /**
24
+ * @description: 执行一个任务单元,并返回下一个任务单元
25
+ * @return {*}
26
+ */
27
+ performUnitOfWork(fiber: Fiber): Fiber | undefined;
28
+ startWork(): void;
29
+ commitRoot(): void;
30
+ commitWork(fiber: Fiber | undefined): void;
31
+ }
32
+ export { render };
File without changes
File without changes
@@ -0,0 +1,2 @@
1
+ import reactify from '@/react/reactify';
2
+ export { reactify };
@@ -0,0 +1,4 @@
1
+ import { r } from "../../reactify-Z-V9Vblb.js";
2
+ export {
3
+ r as reactify
4
+ };
@@ -0,0 +1,2 @@
1
+ export declare const reactifyWebComponent: <T = unknown>(WC: string) => any;
2
+ export default reactifyWebComponent;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @description: 冒泡排序,两两比较,交换位置,遍历n^2
3
+ * @param {Array} list
4
+ * @return {Array}
5
+ */
6
+ declare const bubble: (list: number[]) => number[];
7
+ export default bubble;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @description: 桶排序
3
+ * @param {Array<number>} list
4
+ * @return {Array<number>}
5
+ */
6
+ declare const bucket: (list: Array<number>, bucketSize?: number, max?: number, min?: number) => Array<number>;
7
+ export default bucket;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @description: 计数排序
3
+ * @param {Array<number>} list
4
+ * @return {Array<number>}
5
+ */
6
+ declare const count: (list: number[]) => number[];
7
+ export default count;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @description: 堆排序
3
+ * @param {Array} list
4
+ * @return {Array}
5
+ */
6
+ declare const heap: (list: Array<number>) => Array<number>;
7
+ export default heap;
File without changes
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @description: 插入排序,维护一个有序的数组,将后面的数字插入到前面的有序数组中
3
+ * @param {Array} list
4
+ * @return {Array}
5
+ */
6
+ declare const insert: (list: number[]) => number[];
7
+ export default insert;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @description: 归并排序
3
+ * @param {Array} list
4
+ * @return {Array}
5
+ */
6
+ declare const merge: (list: Array<number>) => Array<number>;
7
+ export default merge;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @description: 快速排序
3
+ * @param {Array} list
4
+ * @return {Array}
5
+ */
6
+ declare const quick: (list?: number[]) => number[];
7
+ export default quick;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @description: 基数排序
3
+ * @param {Array<number>} list
4
+ * @return {Array<number>}
5
+ */
6
+ declare const radix: (list: Array<number>, maxDigit?: number) => Array<number>;
7
+ export default radix;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @description: 通过数组长度,数组最大值,数组的最小值随机生成数组
3
+ * @param {number} length
4
+ * @param {number} min
5
+ * @param {number} max
6
+ * @return {Array<number>}
7
+ */
8
+ declare const randomArray: (length?: number, min?: number, max?: number) => Array<number>;
9
+ export default randomArray;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @description: 选择排序,遍历一遍,找到最小值,放到最前面,重复n次上述操作。
3
+ * @param {Array} list
4
+ * @return {Array}
5
+ */
6
+ declare const select: (list: number[]) => number[];
7
+ export default select;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @description: 希尔排序,是简单插入排序的改进版。它与插入排序的不同之处在于,它会优先比较距离较远的元素。希尔排序又叫缩小增量排序。
3
+ * @param {Array} list
4
+ * @return {Array}
5
+ */
6
+ declare const shell: (list: number[]) => number[];
7
+ export default shell;
@@ -0,0 +1,16 @@
1
+ export declare const webmFixDuration: (blob: Blob, duration: number, type?: string) => Promise<Blob>;
2
+ /**
3
+ * @description: 录音
4
+ * @return {*}
5
+ */
6
+ export declare class AudioRecorder {
7
+ startTime: number;
8
+ chunks: Blob[];
9
+ mediaRecorder?: MediaRecorder;
10
+ blob?: Blob;
11
+ constructor();
12
+ private init;
13
+ start(): MediaRecorder | undefined;
14
+ pause(): MediaRecorder | undefined;
15
+ stop(): Blob | undefined;
16
+ }