ranuts 0.1.0-alpha.11 → 0.1.0-alpha.13
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/dist/index.d.ts +5 -3
- package/dist/index.js +25 -16
- package/dist/{mimeType-Clvz2Teb.js → mimeType-eRf1TlBb.js} +4 -9
- package/dist/{reactify-C4cesbXi.js → reactify-Z-V9Vblb.js} +3 -8
- package/dist/{ml.js → src/ml/index.js} +19 -24
- package/dist/src/node/body.d.ts +0 -1
- package/dist/src/node/command.d.ts +0 -1
- package/dist/src/node/ctx2req.d.ts +0 -1
- package/dist/src/node/fs.d.ts +0 -2
- package/dist/src/node/index.d.ts +3 -2
- package/dist/src/node/index.js +54 -0
- package/dist/src/node/paresUrl.d.ts +0 -1
- package/dist/src/node/readFile.d.ts +0 -1
- package/dist/src/node/server.d.ts +0 -1
- package/dist/src/node/stream.d.ts +0 -1
- package/dist/src/node/traverse.d.ts +0 -1
- package/dist/src/node/watchFile.d.ts +1 -1
- package/dist/src/node/websocket.d.ts +2 -6
- package/dist/src/node/ws.d.ts +0 -1
- package/dist/src/optimize/index.d.ts +3 -3
- package/dist/src/react/index.js +4 -0
- package/dist/src/utils/behavior.d.ts +1 -1
- package/dist/src/utils/bom.d.ts +7 -7
- package/dist/src/utils/device.d.ts +9 -3
- package/dist/src/utils/dom.d.ts +87 -2
- package/dist/src/utils/img.d.ts +1 -1
- package/dist/src/utils/index.d.ts +8 -4
- package/dist/src/utils/index.js +4021 -0
- package/dist/src/utils/number.d.ts +1 -1
- package/dist/src/utils/obj.d.ts +10 -3
- package/dist/src/utils/storage.d.ts +2 -0
- package/dist/src/utils/subscribe.d.ts +34 -4
- 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 +10 -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 +21 -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 +3 -0
- package/dist/src/utils/visual/event/types.d.ts +32 -0
- package/dist/src/utils/visual/graphics/graphics.d.ts +19 -0
- package/dist/src/utils/visual/graphics/graphicsData.d.ts +10 -0
- package/dist/src/utils/visual/graphics/graphicsGeometry.d.ts +10 -0
- package/dist/src/utils/visual/graphics/index.d.ts +3 -0
- package/dist/src/utils/visual/index.d.ts +4 -0
- package/dist/src/utils/visual/math/bezier.d.ts +2 -0
- package/dist/src/utils/visual/math/enums.d.ts +2 -0
- package/dist/src/utils/visual/math/index.d.ts +4 -0
- package/dist/src/utils/visual/math/matrix.d.ts +32 -0
- package/dist/src/utils/visual/math/transform.d.ts +27 -0
- package/dist/src/utils/visual/render/canvasRenderer.d.ts +9 -0
- package/dist/src/utils/visual/render/index.d.ts +3 -0
- package/dist/src/utils/visual/render/render.d.ts +10 -0
- package/dist/src/utils/visual/render/webGlRenderer.d.ts +7 -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 +5 -0
- package/dist/src/utils/visual/shape/polygon.d.ts +10 -0
- package/dist/src/utils/visual/shape/rectangle.d.ts +12 -0
- package/dist/src/utils/visual/shape/shape.d.ts +7 -0
- package/dist/src/utils/visual/style/fill.d.ts +8 -0
- package/dist/src/utils/visual/style/index.d.ts +2 -0
- package/dist/src/utils/visual/style/line.d.ts +9 -0
- package/dist/src/utils/visual/types.d.ts +6 -0
- package/dist/src/utils/visual/vertex/application.d.ts +13 -0
- package/dist/src/utils/visual/vertex/container.d.ts +38 -0
- package/dist/src/utils/visual/vertex/index.d.ts +4 -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/{wasm.js → src/wasm/index.js} +4 -8
- package/dist/test/writeFile.test.d.ts +1 -0
- package/dist/tsconfig.json +1 -0
- package/dist/umd/index.umd.cjs +1 -1
- package/dist/umd/ml/ml.umd.cjs +1 -1
- package/dist/umd/node/node.umd.cjs +1 -1
- package/dist/umd/react/react.umd.cjs +1 -1
- package/dist/umd/utils/utils.umd.cjs +1 -1
- package/dist/{ws-DoSbcWWZ.js → ws-CQA-0Bzm.js} +31 -53
- package/package.json +18 -16
- package/readme.md +6 -2
- package/typings.d.ts +4 -10
- package/dist/node.js +0 -27
- package/dist/react.js +0 -4
- package/dist/utils.js +0 -2092
- /package/dist/test/{server/encodeUrl.test.d.ts → encodeUrl.test.d.ts} +0 -0
- /package/dist/test/{server/escapeHtml.test.d.ts → escapeHtml.test.d.ts} +0 -0
- /package/dist/test/{server/mimeType.test.d.ts → mimeType.test.d.ts} +0 -0
- /package/dist/test/{server/server.test.d.ts → server.test.d.ts} +0 -0
- /package/dist/test/{server/status.test.d.ts → status.test.d.ts} +0 -0
- /package/dist/test/{file/writeFile.test.d.ts → totp.test.d.ts} +0 -0
- /package/dist/test/{server/websocket.test.d.ts → websocket.test.d.ts} +0 -0
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
-
var __publicField = (obj, key, value) =>
|
|
4
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
-
return value;
|
|
6
|
-
};
|
|
3
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
7
4
|
import fs, { createReadStream, createWriteStream, stat, readdir, readdirSync, statSync } from "node:fs";
|
|
8
|
-
import { F as FMT, w as strParse, u as setMime, h as getMime } from "./mimeType-
|
|
5
|
+
import { F as FMT, w as strParse, u as setMime, h as getMime } from "./mimeType-eRf1TlBb.js";
|
|
9
6
|
import tty from "node:tty";
|
|
10
7
|
import process$1, { hrtime } from "node:process";
|
|
11
8
|
import childProcess from "node:child_process";
|
|
@@ -221,11 +218,9 @@ const getIPAdress = () => {
|
|
|
221
218
|
};
|
|
222
219
|
function paresUrl(req) {
|
|
223
220
|
const url = req.url;
|
|
224
|
-
if (url === void 0)
|
|
225
|
-
return;
|
|
221
|
+
if (url === void 0) return;
|
|
226
222
|
let obj = req._parsedUrl;
|
|
227
|
-
if (obj && obj._raw === url)
|
|
228
|
-
return obj;
|
|
223
|
+
if (obj && obj._raw === url) return obj;
|
|
229
224
|
obj = {};
|
|
230
225
|
obj.query = obj.search = void 0;
|
|
231
226
|
obj.href = obj.path = obj.pathname = url;
|
|
@@ -417,23 +412,18 @@ function onerror(err) {
|
|
|
417
412
|
console.error(err.stack || err.toString());
|
|
418
413
|
}
|
|
419
414
|
function compose(middleware) {
|
|
420
|
-
if (!Array.isArray(middleware))
|
|
421
|
-
throw new TypeError("Middleware stack must be an array!");
|
|
415
|
+
if (!Array.isArray(middleware)) throw new TypeError("Middleware stack must be an array!");
|
|
422
416
|
for (const fn of middleware) {
|
|
423
|
-
if (typeof fn !== "function")
|
|
424
|
-
throw new TypeError("Middleware must be composed of functions!");
|
|
417
|
+
if (typeof fn !== "function") throw new TypeError("Middleware must be composed of functions!");
|
|
425
418
|
}
|
|
426
419
|
return function(ctx, next) {
|
|
427
420
|
let index = -1;
|
|
428
421
|
function dispatch(i) {
|
|
429
|
-
if (i <= index)
|
|
430
|
-
return Promise.reject(new Error("next() called multiple times"));
|
|
422
|
+
if (i <= index) return Promise.reject(new Error("next() called multiple times"));
|
|
431
423
|
index = i;
|
|
432
424
|
let fn = middleware[i];
|
|
433
|
-
if (i === middleware.length && next)
|
|
434
|
-
|
|
435
|
-
if (!fn)
|
|
436
|
-
return Promise.resolve();
|
|
425
|
+
if (i === middleware.length && next) fn = next;
|
|
426
|
+
if (!fn) return Promise.resolve();
|
|
437
427
|
try {
|
|
438
428
|
return Promise.resolve(fn(ctx, dispatch.bind(null, i + 1)));
|
|
439
429
|
} catch (err) {
|
|
@@ -545,10 +535,8 @@ function createFrame(content, options) {
|
|
|
545
535
|
}
|
|
546
536
|
if (options) {
|
|
547
537
|
const opcode = options.opcode;
|
|
548
|
-
if (opcode && opcode < 15 && opcode >= 0)
|
|
549
|
-
|
|
550
|
-
} else
|
|
551
|
-
buf[0] = 129;
|
|
538
|
+
if (opcode && opcode < 15 && opcode >= 0) buf[0] = 128 | opcode;
|
|
539
|
+
} else buf[0] = 129;
|
|
552
540
|
return buf;
|
|
553
541
|
}
|
|
554
542
|
function parseFrameMeta(source) {
|
|
@@ -578,30 +566,24 @@ function parseFrameMeta(source) {
|
|
|
578
566
|
};
|
|
579
567
|
}
|
|
580
568
|
function iMask(data, key) {
|
|
581
|
-
if (!key)
|
|
582
|
-
return data;
|
|
569
|
+
if (!key) return data;
|
|
583
570
|
const d = Buffer$1.from(data);
|
|
584
|
-
for (let i = 0; i < d.length; ++i)
|
|
585
|
-
d[i] = d[i] ^ key[i % 4];
|
|
571
|
+
for (let i = 0; i < d.length; ++i) d[i] = d[i] ^ key[i % 4];
|
|
586
572
|
return d;
|
|
587
573
|
}
|
|
588
574
|
function Event() {
|
|
589
575
|
const listeners = {};
|
|
590
576
|
this.on = (event, callback) => {
|
|
591
|
-
if (listeners[event])
|
|
592
|
-
|
|
593
|
-
else
|
|
594
|
-
listeners[event] = [callback];
|
|
577
|
+
if (listeners[event]) listeners[event].push(callback);
|
|
578
|
+
else listeners[event] = [callback];
|
|
595
579
|
};
|
|
596
580
|
this.off = (event, callback) => {
|
|
597
581
|
const e = listeners[event];
|
|
598
582
|
const i = e.indexOf(callback);
|
|
599
|
-
if (e && i !== -1)
|
|
600
|
-
e.splice(i, 1);
|
|
583
|
+
if (e && i !== -1) e.splice(i, 1);
|
|
601
584
|
};
|
|
602
585
|
this.emit = (event, param) => {
|
|
603
|
-
if (listeners[event])
|
|
604
|
-
listeners[event].forEach((callback) => callback(param));
|
|
586
|
+
if (listeners[event]) listeners[event].forEach((callback) => callback(param));
|
|
605
587
|
};
|
|
606
588
|
}
|
|
607
589
|
function WSS(server) {
|
|
@@ -636,8 +618,7 @@ function WSS(server) {
|
|
|
636
618
|
},
|
|
637
619
|
close() {
|
|
638
620
|
const cliI = clients.indexOf(cli);
|
|
639
|
-
if (cliI === -1)
|
|
640
|
-
return false;
|
|
621
|
+
if (cliI === -1) return false;
|
|
641
622
|
clients.splice(clients.indexOf(cli), 1);
|
|
642
623
|
socket.write(createFrame("", { opcode: 8 }));
|
|
643
624
|
cli.emit("close");
|
|
@@ -665,10 +646,8 @@ function WSS(server) {
|
|
|
665
646
|
messageData = Buffer$1.concat([messageData, iMask(d, meta.maskKey)]);
|
|
666
647
|
frameEnd = true;
|
|
667
648
|
if (meta.fin) {
|
|
668
|
-
if (meta.opcode === 8)
|
|
669
|
-
|
|
670
|
-
if (meta.opcode === 9)
|
|
671
|
-
return cli.pong();
|
|
649
|
+
if (meta.opcode === 8) return cli.close();
|
|
650
|
+
if (meta.opcode === 9) return cli.pong();
|
|
672
651
|
cli.emit("message", messageData);
|
|
673
652
|
messageData = Buffer$1.allocUnsafe(0);
|
|
674
653
|
}
|
|
@@ -679,8 +658,7 @@ function WSS(server) {
|
|
|
679
658
|
}
|
|
680
659
|
socket.on("data", (chunk) => {
|
|
681
660
|
buf = Buffer$1.concat([buf, chunk]);
|
|
682
|
-
if (frameEnd)
|
|
683
|
-
nextFrame();
|
|
661
|
+
if (frameEnd) nextFrame();
|
|
684
662
|
while (dataList[0] && buf.byteLength >= dataList[0].l) {
|
|
685
663
|
const l = dataList[0].l;
|
|
686
664
|
dataList[0].f(buf.subarray(0, l));
|
|
@@ -706,20 +684,20 @@ export {
|
|
|
706
684
|
color as c,
|
|
707
685
|
connect as d,
|
|
708
686
|
getIPAdress as e,
|
|
709
|
-
|
|
687
|
+
prompt as f,
|
|
710
688
|
get as g,
|
|
711
|
-
|
|
689
|
+
readFile as h,
|
|
712
690
|
isColorSupported as i,
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
691
|
+
readStream as j,
|
|
692
|
+
runCommand as k,
|
|
693
|
+
staticMiddleware as l,
|
|
716
694
|
traverse as m,
|
|
717
695
|
traverseSync as n,
|
|
718
|
-
|
|
719
|
-
|
|
696
|
+
writeStream as o,
|
|
697
|
+
paresUrl as p,
|
|
720
698
|
queryFileInfo as q,
|
|
721
|
-
|
|
722
|
-
|
|
699
|
+
readDir as r,
|
|
700
|
+
startTask as s,
|
|
723
701
|
taskEnd as t,
|
|
724
|
-
|
|
702
|
+
watchFile as w
|
|
725
703
|
};
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ranuts",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.13",
|
|
4
4
|
"description": "lib",
|
|
5
5
|
"main": "dist/index.umd.cjs",
|
|
6
6
|
"module": "dist/index.js",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"types": "dist/index.d.ts",
|
|
9
9
|
"engines": {
|
|
10
|
-
"node": "
|
|
10
|
+
"node": "^16.20.2 || >=18.0.0"
|
|
11
11
|
},
|
|
12
12
|
"exports": {
|
|
13
13
|
".": {
|
|
@@ -17,27 +17,27 @@
|
|
|
17
17
|
},
|
|
18
18
|
"./react": {
|
|
19
19
|
"types": "./dist/src/react/index.d.ts",
|
|
20
|
-
"import": "./dist/react.js",
|
|
20
|
+
"import": "./dist/react/index.js",
|
|
21
21
|
"require": "./dist/umd/react/react.umd.cjs"
|
|
22
22
|
},
|
|
23
23
|
"./node": {
|
|
24
24
|
"types": "./dist/src/node/index.d.ts",
|
|
25
|
-
"import": "./dist/node.js",
|
|
25
|
+
"import": "./dist/src/node/index.js",
|
|
26
26
|
"require": "./dist/umd/node/node.umd.cjs"
|
|
27
27
|
},
|
|
28
28
|
"./utils": {
|
|
29
|
-
"types": "./dist/index.d.ts",
|
|
30
|
-
"import": "./dist/utils.js",
|
|
29
|
+
"types": "./dist/src/utils/index.d.ts",
|
|
30
|
+
"import": "./dist/src/utils/index.js",
|
|
31
31
|
"require": "./dist/umd/utils/utils.umd.cjs"
|
|
32
32
|
},
|
|
33
33
|
"./wasm": {
|
|
34
34
|
"types": "./dist/src/wasm/index.d.ts",
|
|
35
|
-
"import": "./dist/wasm.js",
|
|
35
|
+
"import": "./dist/src/wasm/index.js",
|
|
36
36
|
"require": "./dist/umd/wasm/wasm.umd.cjs"
|
|
37
37
|
},
|
|
38
38
|
"./ml": {
|
|
39
39
|
"types": "./dist/src/ml/index.d.ts",
|
|
40
|
-
"import": "./dist/ml.js",
|
|
40
|
+
"import": "./dist/src/ml/index.js",
|
|
41
41
|
"require": "./dist/umd/ml/ml.umd.cjs"
|
|
42
42
|
}
|
|
43
43
|
},
|
|
@@ -57,21 +57,23 @@
|
|
|
57
57
|
"scripts": {
|
|
58
58
|
"build": "sh ./bin/build.sh",
|
|
59
59
|
"test": "vitest run",
|
|
60
|
+
"dev": "vite --host",
|
|
60
61
|
"prepublish": "npm run build"
|
|
61
62
|
},
|
|
62
63
|
"keywords": [],
|
|
63
64
|
"author": "",
|
|
64
|
-
"license": "
|
|
65
|
+
"license": "MIT",
|
|
65
66
|
"devDependencies": {
|
|
66
|
-
"@babel/parser": "^7.
|
|
67
|
-
"@types/node": "^20.11
|
|
68
|
-
"@types/react": "^18.
|
|
69
|
-
"react": "^18.
|
|
70
|
-
"
|
|
71
|
-
"
|
|
67
|
+
"@babel/parser": "^7.24.5",
|
|
68
|
+
"@types/node": "^20.12.11",
|
|
69
|
+
"@types/react": "^18.3.1",
|
|
70
|
+
"react": "^18.3.1",
|
|
71
|
+
"typescript": "^5.4.5",
|
|
72
|
+
"vite": "^5.2.11",
|
|
73
|
+
"vitest": "^1.6.0"
|
|
72
74
|
},
|
|
73
75
|
"dependencies": {
|
|
74
76
|
"magic-string": "^0.27.0",
|
|
75
|
-
"tesseract.js": "^5.0
|
|
77
|
+
"tesseract.js": "^5.1.0"
|
|
76
78
|
}
|
|
77
79
|
}
|
package/readme.md
CHANGED
|
@@ -40,9 +40,9 @@ import { readFile } from 'ranuts/node';
|
|
|
40
40
|
import { word } from 'ranuts/wasm';
|
|
41
41
|
import { reactify } from 'ranuts/react';
|
|
42
42
|
import { ocr } from 'ranuts/ml';
|
|
43
|
-
|
|
44
43
|
```
|
|
45
|
-
|
|
44
|
+
|
|
45
|
+
Full import,(Full import will introduce many unnecessary modules. You are advised to import them on demand)
|
|
46
46
|
|
|
47
47
|
- ESM
|
|
48
48
|
|
|
@@ -82,6 +82,10 @@ document.body.appendChild(html);
|
|
|
82
82
|
<img src="https://contrib.rocks/image?repo=chaxus/ran" />
|
|
83
83
|
</a>
|
|
84
84
|
|
|
85
|
+
## Visitors
|
|
86
|
+
|
|
87
|
+

|
|
88
|
+
|
|
85
89
|
## Meta
|
|
86
90
|
|
|
87
91
|
[LICENSE (MIT)](/LICENSE)
|
package/typings.d.ts
CHANGED
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
declare module '@/file/*';
|
|
2
|
-
declare module '@/designMode/*';
|
|
3
|
-
declare module '@/node/*';
|
|
4
|
-
declare module '@/sort/*';
|
|
5
|
-
declare module '@/astParser/*';
|
|
6
|
-
declare module '@/utils/*';
|
|
7
|
-
declare module '@/bundler/*';
|
|
8
|
-
declare module '@/vnode/*';
|
|
9
|
-
declare module '@/server/*';
|
|
10
|
-
|
|
11
1
|
declare namespace Ranuts {
|
|
12
2
|
interface Identification {
|
|
13
3
|
success: boolean;
|
|
@@ -18,6 +8,7 @@ declare namespace Ranuts {
|
|
|
18
8
|
}
|
|
19
9
|
|
|
20
10
|
interface Window {
|
|
11
|
+
[key: any]: any;
|
|
21
12
|
returnCitySN: {
|
|
22
13
|
cid: string;
|
|
23
14
|
cip: string;
|
|
@@ -28,6 +19,9 @@ interface Window {
|
|
|
28
19
|
}
|
|
29
20
|
|
|
30
21
|
declare namespace NodeJS {
|
|
22
|
+
interface global {
|
|
23
|
+
[key: any]: any;
|
|
24
|
+
}
|
|
31
25
|
interface Process {
|
|
32
26
|
ranlog: boolean | undefined;
|
|
33
27
|
}
|
package/dist/node.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { R, S, a, b, c, d, g, e, i, f, p, q, h, j, l, r, k, s, t, m, n, o, w, W } from "./ws-DoSbcWWZ.js";
|
|
2
|
-
export {
|
|
3
|
-
R as Router,
|
|
4
|
-
S as Server,
|
|
5
|
-
a as appendFile,
|
|
6
|
-
b as body,
|
|
7
|
-
c as colors,
|
|
8
|
-
d as connect,
|
|
9
|
-
g as get,
|
|
10
|
-
e as getIPAdress,
|
|
11
|
-
i as isColorSupported,
|
|
12
|
-
f as paresUrl,
|
|
13
|
-
p as prompt,
|
|
14
|
-
q as queryFileInfo,
|
|
15
|
-
h as readDir,
|
|
16
|
-
j as readFile,
|
|
17
|
-
l as readStream,
|
|
18
|
-
r as runCommand,
|
|
19
|
-
k as startTask,
|
|
20
|
-
s as staticMiddleware,
|
|
21
|
-
t as taskEnd,
|
|
22
|
-
m as traverse,
|
|
23
|
-
n as traverseSync,
|
|
24
|
-
o as watchFile,
|
|
25
|
-
w as writeStream,
|
|
26
|
-
W as wss
|
|
27
|
-
};
|
package/dist/react.js
DELETED