ranuts 0.1.0-alpha.2 → 0.1.0-alpha.20
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.
- package/LICENSE +21 -0
- package/dist/build/build.es.d.ts +2 -0
- package/dist/build/build.umd.d.ts +2 -0
- package/dist/build/build.umd.ml.d.ts +2 -0
- package/dist/build/build.umd.node.d.ts +2 -0
- package/dist/build/build.umd.react.d.ts +2 -0
- package/dist/build/build.umd.utils.d.ts +2 -0
- package/dist/build/build.umd.wasm.d.ts +2 -0
- package/dist/examples/clone-deep-example.d.ts +1 -0
- package/dist/examples/is-equal-example.d.ts +1 -0
- package/dist/index.d.ts +9 -16
- package/dist/index.js +147 -1116
- package/dist/mimeType-CrLryRe7.js +81821 -0
- package/dist/plugins/vite-plugins-banner.d.ts +2 -0
- package/dist/reactify-Z-V9Vblb.js +83 -0
- package/dist/src/arithmetic/index.d.ts +186 -0
- package/dist/src/cache/expires.d.ts +1 -0
- package/dist/src/ml/index.d.ts +2 -0
- package/dist/src/ml/index.js +1243 -0
- package/dist/src/ml/ocr.d.ts +11 -0
- package/dist/src/node/appendFile.d.ts +7 -0
- package/dist/src/node/body.d.ts +9 -0
- package/dist/src/node/color.d.ts +7 -0
- package/dist/src/node/command.d.ts +8 -0
- package/dist/src/node/ctx2req.d.ts +5 -0
- package/dist/src/node/fileInfo.d.ts +7 -0
- package/dist/src/node/fs.d.ts +7 -0
- package/dist/src/node/get.d.ts +10 -0
- package/dist/src/node/getIPAdress.d.ts +1 -0
- package/dist/src/node/index.d.ts +25 -0
- package/dist/src/node/index.js +54 -0
- package/dist/src/node/isColorSupported.d.ts +2 -0
- package/dist/src/node/paresUrl.d.ts +19 -0
- package/dist/src/node/readDir.d.ts +6 -0
- package/dist/src/node/readFile.d.ts +9 -0
- package/dist/src/node/router.d.ts +42 -0
- package/dist/src/node/send.d.ts +7 -0
- package/dist/src/node/server.d.ts +18 -0
- package/dist/src/node/startTask.d.ts +2 -0
- package/dist/src/node/stream.d.ts +15 -0
- package/dist/src/node/taskEnd.d.ts +2 -0
- package/dist/src/node/traverse.d.ts +17 -0
- package/dist/src/node/watchFile.d.ts +8 -0
- package/dist/src/node/websocket.d.ts +57 -0
- package/dist/src/node/writeFile.d.ts +8 -0
- package/dist/src/node/ws.d.ts +8 -0
- package/dist/src/optimize/index.d.ts +36 -0
- package/dist/src/optimize/promise.d.ts +0 -0
- package/dist/src/ran/commit.d.ts +0 -0
- package/dist/src/ran/dom.d.ts +0 -0
- package/dist/src/ran/hooks.d.ts +0 -0
- package/dist/src/ran/index.d.ts +20 -0
- package/dist/src/ran/min.d.ts +32 -0
- package/dist/src/ran/reconcile.d.ts +0 -0
- package/dist/src/ran/schedule.d.ts +0 -0
- package/dist/src/react/index.d.ts +2 -0
- package/dist/src/react/index.js +4 -0
- package/dist/src/react/reactify.d.ts +2 -0
- package/dist/src/sort/bubble.d.ts +7 -0
- package/dist/src/sort/bucket.d.ts +7 -0
- package/dist/src/sort/count.d.ts +7 -0
- package/dist/src/sort/heap.d.ts +7 -0
- package/dist/src/sort/index.d.ts +0 -0
- package/dist/src/sort/insert.d.ts +7 -0
- package/dist/src/sort/merge.d.ts +7 -0
- package/dist/src/sort/quick.d.ts +7 -0
- package/dist/src/sort/radix.d.ts +7 -0
- package/dist/src/sort/randomArray.d.ts +9 -0
- package/dist/src/sort/select.d.ts +7 -0
- package/dist/src/sort/shell.d.ts +7 -0
- package/dist/src/utils/audioRecorder.d.ts +16 -0
- package/dist/src/utils/behavior.d.ts +15 -0
- package/dist/src/utils/bom.d.ts +220 -0
- package/dist/src/utils/color.d.ts +71 -0
- package/dist/src/utils/compose.d.ts +10 -0
- package/dist/src/utils/console.d.ts +1 -0
- package/dist/src/utils/debounce.d.ts +7 -0
- package/dist/src/utils/device.d.ts +25 -0
- package/dist/src/utils/dom.d.ts +105 -0
- package/dist/src/utils/error.d.ts +1 -0
- package/dist/src/utils/img.d.ts +16 -0
- package/dist/src/utils/index.d.ts +35 -0
- package/dist/src/utils/index.js +4504 -0
- package/dist/src/utils/memoize.d.ts +7 -0
- package/dist/src/utils/mimeType.d.ts +3 -0
- package/dist/src/utils/monitor.d.ts +38 -0
- package/dist/src/utils/network.d.ts +39 -0
- package/dist/src/utils/noop.d.ts +2 -0
- package/dist/src/utils/number.d.ts +45 -0
- package/dist/src/utils/obj.d.ts +83 -0
- package/dist/src/utils/performance.d.ts +21 -0
- package/dist/src/utils/queue.d.ts +33 -0
- package/dist/src/utils/report.d.ts +8 -0
- package/dist/src/utils/request.d.ts +17 -0
- package/dist/src/utils/script.d.ts +7 -0
- package/dist/src/utils/signal.d.ts +6 -0
- package/dist/src/utils/storage.d.ts +2 -0
- package/dist/src/utils/str.d.ts +72 -0
- package/dist/src/utils/subscribe.d.ts +46 -0
- package/dist/src/utils/throttle.d.ts +15 -0
- package/dist/src/utils/time.d.ts +20 -0
- package/dist/src/utils/totp/sha/common.d.ts +151 -0
- package/dist/src/utils/totp/sha/converters.d.ts +88 -0
- package/dist/src/utils/totp/sha/custom_types.d.ts +60 -0
- package/dist/src/utils/totp/sha/primitives_32.d.ts +98 -0
- package/dist/src/utils/totp/sha/primitives_64.d.ts +116 -0
- package/dist/src/utils/totp/sha/sha.d.ts +103 -0
- package/dist/src/utils/totp/sha/sha1.d.ts +18 -0
- package/dist/src/utils/totp/sha/sha256.d.ts +20 -0
- package/dist/src/utils/totp/sha/sha3.d.ts +53 -0
- package/dist/src/utils/totp/sha/sha512.d.ts +21 -0
- package/dist/src/utils/totp/totp.d.ts +23 -0
- package/dist/src/utils/visual/application.d.ts +14 -0
- package/dist/src/utils/visual/demo/index.d.ts +1 -0
- package/dist/src/utils/visual/demo/sankey.d.ts +2 -0
- package/dist/src/utils/visual/enums.d.ts +27 -0
- package/dist/src/utils/visual/event/boundary.d.ts +22 -0
- package/dist/src/utils/visual/event/event.d.ts +14 -0
- package/dist/src/utils/visual/event/index.d.ts +6 -0
- package/dist/src/utils/visual/event/types.d.ts +32 -0
- package/dist/src/utils/visual/graphics/graphics.d.ts +81 -0
- package/dist/src/utils/visual/graphics/graphicsData.d.ts +13 -0
- package/dist/src/utils/visual/graphics/graphicsGeometry.d.ts +35 -0
- package/dist/src/utils/visual/graphics/index.d.ts +4 -0
- package/dist/src/utils/visual/index.d.ts +7 -0
- package/dist/src/utils/visual/math/bezier.d.ts +2 -0
- package/dist/src/utils/visual/math/enums.d.ts +3 -0
- package/dist/src/utils/visual/math/index.d.ts +5 -0
- package/dist/src/utils/visual/math/matrix.d.ts +113 -0
- package/dist/src/utils/visual/math/transform.d.ts +29 -0
- package/dist/src/utils/visual/render/batchRenderer.d.ts +72 -0
- package/dist/src/utils/visual/render/canvasRenderer.d.ts +10 -0
- package/dist/src/utils/visual/render/index.d.ts +3 -0
- package/dist/src/utils/visual/render/render.d.ts +15 -0
- package/dist/src/utils/visual/render/utils/batch/index.d.ts +90 -0
- package/dist/src/utils/visual/render/utils/float.d.ts +63 -0
- package/dist/src/utils/visual/render/utils/index.d.ts +3 -0
- package/dist/src/utils/visual/render/utils/verticy.d.ts +13 -0
- package/dist/src/utils/visual/render/utils/webgl/batchPool.d.ts +28 -0
- package/dist/src/utils/visual/render/utils/webgl/initShader.d.ts +2 -0
- package/dist/src/utils/visual/render/utils/webgl/shaders.d.ts +2 -0
- package/dist/src/utils/visual/render/utils/webgpu/shaders.d.ts +8 -0
- package/dist/src/utils/visual/render/webGPURenderer.d.ts +49 -0
- package/dist/src/utils/visual/render/webGlRenderer.d.ts +17 -0
- package/dist/src/utils/visual/shape/circle.d.ts +11 -0
- package/dist/src/utils/visual/shape/ellipse.d.ts +12 -0
- package/dist/src/utils/visual/shape/index.d.ts +7 -0
- package/dist/src/utils/visual/shape/polygon.d.ts +11 -0
- package/dist/src/utils/visual/shape/rectangle.d.ts +12 -0
- package/dist/src/utils/visual/shape/roundedRectangle.d.ts +13 -0
- package/dist/src/utils/visual/shape/shape.d.ts +6 -0
- package/dist/src/utils/visual/style/fill.d.ts +8 -0
- package/dist/src/utils/visual/style/index.d.ts +3 -0
- package/dist/src/utils/visual/style/line.d.ts +10 -0
- package/dist/src/utils/visual/types.d.ts +17 -0
- package/dist/src/utils/visual/vertex/container.d.ts +73 -0
- package/dist/src/utils/visual/vertex/index.d.ts +5 -0
- package/dist/src/utils/visual/vertex/point.d.ts +18 -0
- package/dist/src/utils/visual/vertex/vertex.d.ts +36 -0
- package/dist/src/vnode/chainDom.d.ts +47 -0
- package/dist/src/vnode/h.d.ts +6 -0
- package/dist/src/vnode/hooks.d.ts +23 -0
- package/dist/src/vnode/htmlDomApi.d.ts +33 -0
- package/dist/src/vnode/init.d.ts +2 -0
- package/dist/src/vnode/is.d.ts +5 -0
- package/dist/src/vnode/modules/attributes.d.ts +8 -0
- package/dist/src/vnode/modules/class.d.ts +8 -0
- package/dist/src/vnode/modules/index.d.ts +3 -0
- package/dist/src/vnode/modules/listeners.d.ts +12 -0
- package/dist/src/vnode/modules/props.d.ts +8 -0
- package/dist/src/vnode/modules/style.d.ts +14 -0
- package/dist/src/vnode/vnode.d.ts +31 -0
- package/dist/src/wasm/index.d.ts +2 -0
- package/dist/src/wasm/index.js +346 -0
- package/dist/src/wasm/word.d.ts +17 -0
- package/dist/src/wicket/bridge.d.ts +4 -0
- package/dist/src/wicket/index.d.ts +29 -0
- package/dist/test/arithmetic.test.d.ts +1 -0
- package/dist/test/cloneDeep.test.d.ts +1 -0
- package/dist/test/encodeUrl.test.d.ts +1 -0
- package/dist/test/escapeHtml.test.d.ts +1 -0
- package/dist/test/is-equal.test.d.ts +1 -0
- package/dist/test/mimeType.test.d.ts +1 -0
- package/dist/test/server.test.d.ts +1 -0
- package/dist/test/sort.test.d.ts +1 -0
- package/dist/test/status.test.d.ts +1 -0
- package/dist/test/totp.test.d.ts +1 -0
- package/dist/test/utils/compose.test.d.ts +1 -0
- package/dist/test/utils/mergeObj.test.d.ts +1 -0
- package/dist/test/utils/ocr.test.d.ts +1 -0
- package/dist/test/visual/math.test.d.ts +1 -0
- package/dist/test/vnode/index.d.ts +1 -0
- package/dist/test/vnode/server.d.ts +2 -0
- package/dist/test/vnode/vnode.d.ts +1 -0
- package/dist/test/websocket.test.d.ts +1 -0
- package/dist/test/writeFile.test.d.ts +1 -0
- package/dist/tsconfig.json +25 -0
- package/dist/umd/index.umd.cjs +1 -0
- package/dist/umd/ml/ml.umd.cjs +1 -0
- package/dist/umd/node/node.umd.cjs +1 -0
- package/dist/umd/react/react.umd.cjs +1 -0
- package/dist/umd/utils/utils.umd.cjs +1 -0
- package/dist/umd/wasm/wasm.umd.cjs +1 -0
- package/dist/vite.config.d.ts +11 -0
- package/dist/ws-ioQsn2UB.js +703 -0
- package/package.json +55 -21
- package/readme.md +90 -0
- package/typings.d.ts +28 -0
- package/assets/img/sort/bubble.gif +0 -0
- package/assets/img/sort/complexity.png +0 -0
- package/assets/img/sort/select.gif +0 -0
- package/assets/img/sort/sort.png +0 -0
- package/assets/img/tree/balanceTree.png +0 -0
- package/dist/index.js.map +0 -1
- package/dist/index.umd.cjs +0 -2
- 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,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,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 @@
|
|
|
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-ioQsn2UB.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,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,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,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,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,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,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
|
|
File without changes
|
|
@@ -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,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
|
+
}
|